akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    sa = sorted(a)

    for i in range(n):
        if a[i] == sa[-1]:
            print(sa[-2])
        else:
            print(sa[-1])


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 41876
#include <iostream>
#include <string>
using namespace std;

int main() {
  string S;
  int cnt = 0;
  cin >> S;
  int size = S.length();
  for (int i = 0; i < size / 2; i++) {
    if (S.at(i) != S.at(size - 1 - i)) {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	cout << (((g * 10 + b) % 4 == 0) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n,d;cin>>n>>d;
    vector<vector<int>>x(n,vector<int>(d));

    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }

    int ans=0;
    rep(i,n-1){
        rep2(j,i+1,n){
            int sum=0;
            rep(k,d){
                int y=abs(x[i][k]-x[j][k]);
                sum+=y*y;
            }

            rep2(k,1,sum+1){
                if(k*k==sum){
                    ans++;
                    break;
                }
            }
        }

    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())

memo = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
    s = str(i)
    memo[int(s[0] )][int(s[-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += memo[i][j] * memo[j][i]
print(ans)


Measured memory_bytes: 8888
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;

int main(void){
    int m; cin >> m;
    map<string, pii> s2d;
    rep(i, m){
        string name; cin >> name;
        cin >> s2d[name].first >> s2d[name].second;
    }

    int n; cin >> n;
    stack<vi> stk;
    rep(loop, n){
        string op; cin >> op;
        
        if(op == "+" or op == "-" or op == "*" or op == "/"){
            if(stk.size() < 2){
                cout << "error" << endl;
                return 0;
            }
            vi b = stk.top(); stk.pop();
            vi a = stk.top(); stk.pop();

            vi c(256);
            rep(i, 256){
                rep(j, 256){
                    if(a[i] and b[j]){
                        int res;
                        if(op == "+") res = (i + j) & 255;
                        if(op == "-") res = (i - j) & 255;
                        if(op == "*") res = (i * j) & 255;
                        if(op == "/"){
                            if(j == 0){
                                cout << "error" << endl;
                                return 0;
                            }
                            res = (i / j) & 255;
                        }
                        c[res] = true;
                    }
                }
            }
            stk.push(c);
        }
        else {
            vi a(256);
            if(s2d.find(op) != end(s2d)){
                range(i, s2d[op].first, s2d[op].second + 1){
                    a[i] = true;
                }
            }
            else {
                stringstream ss(op);
                int num; ss >> num;
                a[num] = true;
            }

            stk.push(a);
        }
    }

    if(stk.size() != 1){
        cout << "error" << endl;
        return 0;
    }

    cout << "correct" << endl;

	return 0;
}

Measured memory_bytes: 3216
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

const INF: i64 = 1 << 60;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let q: usize = read();

    let mut s = vec![-INF];
    for _ in 0..a {
        let s_i: i64 = read();
        s.push(s_i);
    }
    s.push(INF);
    let mut t = vec![-INF];
    for _ in 0..b {
        let s_i: i64 = read();
        t.push(s_i);
    }
    t.push(INF);
    let x: Vec<i64> = (0..q).map(|_| read()).collect();

    for x in x {
        let b = s.lower_bound(&x);
        let d = t.lower_bound(&x);
        let mut res = INF;

        for s in [s[b - 1], s[b]].iter() {
            for t in [t[d - 1], t[d]].iter() {
                let d1 = (s - x).abs() + (t - s).abs();
                let d2 = (t - x).abs() + (s - t).abs();
                res = *[res, d1, d2].iter().min().unwrap();
            }
        }
        println!("{}", res);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

// like c++ std::lower_bound and std::upper_bound
trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = low + (high - low) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less => low = mid + 1,
                _ => high = mid,
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = low + (high - low) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Greater => high = mid,
                _ => low = mid + 1,
            }
        }
        high
    }
}


Measured memory_bytes: 9468
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int N, _N; cin >> N;
    _N = N;
    int digitSum = 0;
    while(_N > 0) {
      digitSum += _N%10;
      _N /= 10;
    }
  
    cout << (N%digitSum == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<int> ope(n);
        for(int i=0; i<n; ++i)
            cin >> ope[i];
        vector<int> dice(m);
        for(int i=0; i<m; ++i)
            cin >> dice[i];

        int pos = 0;
        for(int i=0; i<m; ++i){
            pos += dice[i];
            if(pos >= n-1){
                cout << (i+1) << endl;
                break;
            }
            pos += ope[pos];
            if(pos >= n-1){
                cout << (i+1) << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
const int LIMIT = 1e6;
 
int main() {
    int n;
    cin >> n;
    vector<int> a(n), count(LIMIT + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        count[a[i]]++;
    }
    sort(a.begin(), a.end());
 
    vector<bool> divisible(LIMIT + 1);
    for (int i = 1; i <= LIMIT; i++) {
        if (count[i] > 0) {
            if (count[i] >= 2)divisible[i] = true;
            for (int j = i * 2; j <= LIMIT; j += i)divisible[j] = true;
        }
    }
 
    int ret = 0;
    for (auto x:a) {
        if (!divisible[x])ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


vector<P> G[1<<17];
vector<int> ans(1<<17);

void dfs(int u,int k,int l){
    if(l%2) ans[u]=1;
    else ans[u]=0;
    for (int i = 0; i < G[u].size(); i++) {
        if(G[u][i].fs==k) continue;
        dfs(G[u][i].fs,u,(l+G[u][i].sc)%2);
    }
}

int main(){
    int n;cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        G[a].pb(P(b,c%2));
        G[b].pb(P(a,c%2));
    }
    dfs(0,-1,0);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main(void){
    int N, K, Q;
    cin >> N >> K >> Q;
    int min = K - Q;
    int i;
    vector<int> t(N,min);
    int ans;
    for(i=0;i<Q;i++){
        cin >> ans;
        t[ans-1] += 1;
    }
    for(i=0;i<N;i++){
        if(t[i]>0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e3 + 5;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll p = 1e9 + 7;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

ll n, f[MAXN][MAXN<<1], pre[2][MAXN<<1];
void run(){
    cin >> n;
    int k = n << 1;
    f[0][0] = 1;
    for(int i = 0; i <= k; i++) pre[1][i] = 1;
    for(int i = 1; i <= n; i++){
        pre[0][i-1] = 0;
        for(int j = i; j <= k; j++){
            f[i][j] = pre[1][j-1];
            pre[0][j] = (pre[0][j-1] + f[i][j]) % p;
        }
        swap(pre[0], pre[1]);
    }
    int m = n / 3;
    ll ans = 0;
    for(int i = 1; i <= m; i++){
        int c = n - i * 3;
        ans = (ans + f[i][i+c]) % p;
    }
    DEBUG(ans);
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 57476
#include <cstdio>
#include <iostream>
#include <climits>
#include <cmath>
#include <utility>
#include <vector>
#include <string>

using namespace std;

class BinaryTree
{
  struct Node
  {
      int id;
      int parent;
      int left;
      int right;
  };
public:
  int size;
  vector<Node> nodes;
  Node operator[](int i)
  {
    return nodes[i];
  }
  BinaryTree(int n)
  {
    size = n;
    nodes.resize(n);
    for(int i = 0; i < n; i++)
    {
      nodes[i].id = i;
      nodes[i].parent = i;
      nodes[i].left = -1;
      nodes[i].right = -1;
    }
  }
  bool isRoot(int id)
  {
    return nodes[id].parent == id;
  }
  void SetSibling(int id, int left, int right)
  {
    nodes[id].left = left;
    nodes[id].right = right;
    if(left != -1) nodes[left].parent = id;
    if(right != -1) nodes[right].parent = id;
  }
  int parent(int id)
  {
    return isRoot(id)?-1:nodes[id].parent;
  }
  int sibling(int id)
  {
    if(isRoot(id)) return -1;
    if(nodes[nodes[id].parent].left == id) return nodes[nodes[id].parent].right;
    else return nodes[nodes[id].parent].left;
  }
  int degree(int id)
  {
    return (nodes[id].left != -1) + (nodes[id].right != -1);
  }
  int depth(int id)
  {
    int x = id;
    int cnt = 0;
    while(x != nodes[x].parent)
    {
      x = nodes[x].parent;
      cnt++;
    }
    return cnt;
  }
  int height(int id)
  {
    if(id == -1) return -1;
    return max(height(nodes[id].left),height(nodes[id].right)) + 1;
  }
  char* printType(int id)
  {
    if(id == nodes[id].parent)
      return (char *)"root";
    else if(nodes[id].left == -1 && nodes[id].right == -1)
      return (char *)"leaf";
    else return (char *)"internal node";
  }
  void printInfo(int id)
  {
    printf("node %d: ",id);
    printf("parent = %d, ",parent(id));
    printf("sibling = %d, ",sibling(id));
    printf("degree = %d, ",degree(id));
    printf("depth = %d, ",depth(id));
    printf("height = %d, ",height(id));
    printf("%s\n", printType(id));
  }
};

int main()
{
  int n; cin >> n;
  BinaryTree tree(n);
  for(int i = 0; i < n; i++)
  {
    int id, l, r;
    cin >> id >> l >> r;
    tree.SetSibling(id,l,r);
  }
  for(int i = 0; i < n; i++) tree.printInfo(i);
}

Measured memory_bytes: 1184
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if ((500 * i) + (100 * j) + (50 * k)) == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
const int maxn=500010;
vector<int>g[maxn];
int n,k;
void read(int& x){
	x=0;
	char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
}
int p[maxn],P[maxn];
int ans[maxn];
struct Segment_Tree{
	int Max[maxn<<2];
	void modify(int o,int l,int r,int c,int pos){
		if(l==r){
			Max[o]=pos;return;
		}
		int mid=(l+r)>>1;
		if(c<=mid) modify(o<<1,l,mid,c,pos);
		else modify(o<<1|1,mid+1,r,c,pos);
		Max[o]=max(Max[o<<1],Max[o<<1|1]);
	}
	int query(int o,int l,int r,int ql,int qr){
		if(ql<=l && qr>=r) return Max[o];
		int mid=(l+r)>>1;
		int ret=0;
		if(ql<=mid) ret=query(o<<1,l,mid,ql,qr);
		if(qr>mid) ret=max(ret,query(o<<1|1,mid+1,r,ql,qr));
		return ret;
	}
}T;
int cnt=-1;
void dfs(int x){
	ans[++cnt]=x;
	sort(g[x].begin(),g[x].end());
	for(int i=0;i<g[x].size();i++) dfs(g[x][i]);
}
int main(){
	read(n);read(k);
	for(int i=1;i<=n;i++){
		read(p[i]);
		P[p[i]]=i;
	}
	P[n+1]=n+1;
	T.modify(1,1,n,P[1],1);
	for(int i=1;i<=n;i++){
		int j=T.query(1,1,n,P[i]+1,min(n,P[i]+k-1));
		if(!j) j=n+1;
		g[P[j]].push_back(P[i]);
		//printf("%d %d\n",P[j],P[i]);
		T.modify(1,1,n,P[i],i);
	}
	dfs(n+1);
	for(int i=1;i<=n;i++) p[ans[i]]=i;
	for(int i=1;i<=n;i++) printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 67968
use proconio::{input};
use std::cmp::{max};

fn optmax<T:Ord + Copy>(x: Option<T>, v: T) -> Option<T> {
    return Some(max(x.unwrap_or(v), v));
}

#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        N: usize,
        K: usize,
        P: [usize; N],
        C: [i64; N],
    }

    let calc = |startIndex| {
        let mut res: Option<i64> = None;

        let mut nodes: Vec<Option<(usize, i64)>> = vec![None; N];

        let mut k: usize = 0;
        let mut index = startIndex;
        let mut score = 0;

        while (k < K && nodes[index] == None) {
            nodes[index] = Some((k, score));

            index = P[index] - 1;
            score += C[index];
            res = optmax(res, score);

            k += 1;
        }

        match nodes[index] {
            Some((kk, ss)) => {
                let dk = k - kk;
                let dn = max(0, ((K - k) / dk) as i64 - 1) as usize;
                let ds = score - ss;

                if ds > 0 { score += ds * (dn as i64); }
                res = optmax(res, score);

                k += dn * dk;
            },
            None => {}
        }

        while (k < K) {
            index = P[index] - 1;
            score += C[index];
            res = optmax(res, score);

            k += 1;
        }

        return res.unwrap_or_default();
    };

    let ans = ((0..N).map(|i| calc(i))).max();
    println!("{:?}", ans.unwrap_or_default());
}


Measured memory_bytes: 2464
import math._
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val X = in.nextInt

  val (a, b) = (for {
    a <- -200L to 200L
    b <- -200L to 200L
    if (a*a*a*a*a - b*b*b*b*b == X)
  } yield (a, b)).head

  println(s"${a} ${b}")
}

Measured memory_bytes: 56516
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

vector<vector<int>> dp1(301,vector<int>(301,0));
vector<vector<int>> dp2(301,vector<int>(301,MOD));

//maegasoko
ll solve(string a,string b,ll H){
  for(int i=H-1;i>=0;i--){
    for(int j=H-1;j>=0;j--){
      dp1[i][j]=dp1[i+1][j+1]+(a[i]==b[j]?1:0);
    }
  }
  for(auto &I:dp2){
    for(auto &J:I){J=MOD;}
  }
  dp2[0][0]=0;
  for(int i=0;i<=2*H;i++){
    for(int j=0;j<=H;j++){
      int x=j,y=i-j;
      if(x<0 || y<0 || x>H || y>H){continue;}
      if(x<H){
	dp2[x+1][y]=min(dp2[x+1][y],dp2[x][y]+dp1[x][y]);
      }
      if(y<H){
	dp2[x][y+1]=min(dp2[x][y+1],dp2[x][y]+dp1[x][y]);
      }
    }
  }
  return dp2[H][H];
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H,W;
  cin>>H>>W;
  vector<string> A(H);
  cin>>A;
  ll ans=0;
  for(int i=0;i+1<W;i++){
    string a,b;
    for(int j=0;j<H;j++){
      a+=A[H-j-1][i];
      b+=A[H-j-1][i+1];
    }
    ans+=solve(a,b,H);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1280
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
A,B,K=map(int,input().split())
G=gcd(A,B)
L=[]
i=1
while(i*i<=G):
    if G%i==0:
        L.append(i)
    i+=1
X=set()
for i in L:
    X.add(i)
    X.add(G//i)
X=sorted(list(X))
print(X[-K])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long int

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > v;

    for(int i = 1; i <= n; ++i){
        int a;
        cin >> a;
        v.push_back(make_pair(a,i));
    }

    sort(v.begin(),v.end());

    for(int i = 0; i < n; ++i){
        cout << v[i].second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define NIL -1

struct Node {
    int parent, left, right;
};

void preorder(vector<Node>& tree, int u) {
    if (u==NIL) return;
    cout << " " << u;
    preorder(tree, tree[u].left);
    preorder(tree, tree[u].right);
}

void inorder(vector<Node>& tree, int u) {
    if(u==NIL) return;
    inorder(tree, tree[u].left);
    cout << " " << u;
    inorder(tree, tree[u].right);
}

void postorder(vector<Node>& tree, int u) {
    if(u==NIL) return;
    postorder(tree, tree[u].left);
    postorder(tree, tree[u].right);
    cout << " " << u;
}

int main() {
    int num;
    cin >> num;
    vector<Node> tree(num);
    for(int i=0; i<num; i++) {
        tree[i].parent = tree[i].right = tree[i].left = NIL;
    }

    for(int i=0; i<num; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        if(left != NIL) {
            tree[id].left = left;
            tree[left].parent = id;
        }
        if(right != NIL) {
            tree[id].right = right;
            tree[right].parent = id;
        }
    }

    int rootId = NIL;
    for(int i=0; i<num; i++) {
        if(tree[i].parent == NIL) {
            rootId = i;
            break;
        }
    }
    cout << "Preorder" << endl;
    preorder(tree, rootId);
    cout << endl;
    
    cout << "Inorder" << endl;
    inorder(tree, rootId);
    cout << endl;

    cout << "Postorder" << endl;
    postorder(tree, rootId);
    cout << endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll a, b;
	cin >> a >> b;
	cout << (a - 1)*(b - 1) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

const int mod = 1000000007;

int main(){
    int N;
    cin >> N;
    LL ans = 1;
    for(LL i=1; i<=N; i++){
        (ans *= i) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    multiset<int> s;
    for (int i = n - 1; i >= 0; i--) {
        auto itr = s.upper_bound(a[i]);
        if (itr == s.end()) {
            s.insert(a[i]);
        } else {
            s.erase(itr);
            s.insert(a[i]);
        }
    }
    cout << s.size() << "\n";
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define per(i,x,y) for(in i=y;i>=(x);--i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

in v[3];

int main()
{
	IOS;
	in n;
	string s,t,ans="";
	cin >> n >> s >> t;
	rep(i,0,n)
	{
		ans+=s[i];
		ans+=t[i];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> hai_p(n);
    for(int i=0;i<n;i++){
        cin >> hai_p.at(i);
    }
    sort(hai_p.begin(),hai_p.end());
    hai_p.at(n-1) /=2;
    int s=0;
    for(int i=0;i<n;i++){
        s += hai_p.at(i);
    }
    cout << s <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    if(n % 2 == 1){
        for(int i = 1; i <= m; i++){
            cout << i << ' ' << n - i + 1 << '\n';
        }
    }
    else{
        bool f = true;
        int l = 1, r = n;
        for(int i = 1; i <= m; i++){
            cout << l << ' ' << r << '\n';
            l++, r--;
            if(f && 4 * l > n){
                l++;
                f = false;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)



vector<int> prime;

void calcPrime(int n){

    bool isPrime[n+1];
    fill(isPrime, isPrime+n+1, true);
    isPrime[0] = false;
    isPrime[1] = false;

    int i1 = 2; 
    while(i1 <= n){
        if(isPrime[i1] == false){
            i1++;
            continue;
        }

        int temp = i1;
        int i2 = i1*2;
        while(i2 <= n){
            isPrime[i2] = false;
            i2 += temp;
        }
        i1++;
    }

    prime.clear();
    for(int i=2; i<=n; i++){
        if(isPrime[i]){
            prime.push_back(i);
        }
    }
}



int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    calcPrime(55555);

    vector<int> vcand;

    rep(i, prime.size()){
        if(prime[i] % 5 == 1){
            vcand.push_back(prime[i]);
        }
    }

    rep(i, n){
        cout << vcand[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 3e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll r , g , b , n , ans;

int main() {
    fast_io;

    cin >> r >> g >> b >> n;
    for(ll i = 0 ; i < MAXN ; i++){
        for(ll j = 0 ; j < MAXN ; j++){
            ll x = n - i * r - j * g;
            if(x >= 0 && x % b == 0)    ans++;
        }
    }
    cout << ans << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define pw(x) (1LL<<(x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl

using namespace std;

typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;


int main() {
#define TASK "A"
#ifdef HOME
  assert(freopen(TASK".in", "r", stdin));
#endif
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  };
  vector<int> b(n - 1);
  for (int i = 0; i < n - 1; i++) {
    b[i] = a[i] > a[i + 1];
  }
  vector<int> pref(n);
  for (int i = 0; i < n - 1; i++) {
    pref[i + 1] = pref[i] + b[i];
  }
  int answer = 0;
  set<int> w(a.begin(), a.begin() + k);

  bool have_ident = 0;
  if (pref[k - 1] == 0) {
    have_ident = 1;
  }
  else {
    answer++;
  }

  for (int i = 1; i + k <= n; i++) {
    int cnt_inv = pref[i + k - 1] - pref[i];
    if (cnt_inv == 0) {
      have_ident = 1;
      w.erase(a[i - 1]);
      w.insert(a[i + k - 1]);
    }
    else {
      bool ok = 1;
      ok &= a[i - 1] == *w.begin();
      w.erase(a[i - 1]);
      ok &= *w.rbegin() < a[i + k - 1];
      w.insert(a[i + k - 1]);
      answer += !ok;
    }
  }

  answer += have_ident;
  cout << answer << endl;





  return 0;
}




Measured memory_bytes: 12032
from collections import defaultdict
N,K = map(int,input().split())
d = defaultdict(int)
for _ in range(N):
  a,b = map(int,input().split())
  d[a] += b
  
for k,v in sorted(d.items()):
  if v >= K:
    print(k)
    exit()
  K -= v

Measured memory_bytes: 14932
from collections import deque

def GCP(a, b):
  if a < b:
    a, b = b, a
  while b > 0:
    a, b = b, a % b
  return a

def LCM(a, b):
  return a * b // GCP(a, b)

def solve():
  MOD = 10**9 + 7

  N = int(input())
  A = list(map(int, input().split()))

  T = deque(A)
  while len(T) > 1:
    T.append(LCM(T.pop(), T.pop()))

  L = T.pop()

  ans = 0
  for i in range(N):
    ans += L // A[i]

  print(ans % MOD)

solve()

Measured memory_bytes: 4460
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,m,k;
	cin >> n >> m >> k;
	
	REP(i,n+1)REP(j,m+1)
	{
//		cout << (i) * m + (j) * n - (i)*(j) * 2 << endl;
		if((i) * m + (j) * n - (i)*(j) * 2 == k)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
 
int main() {
    int n;
    scanf("%d ",&n);
    long long int a[n],b[n];
    int i;
    for(i=0;i<=n-1;i++)scanf("%lld %lld",&a[i],&b[i]);
    long long int ans=0;
    for(i=n-1;i>=0;i--){
        if((a[i]+ans)%b[i]!=0)ans+=b[i]-(a[i]+ans)%b[i];
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;

void input(long &n, vector<long> &a) {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

long div(long n) { // 整数が2で割り切れる回数
    long count = 0;
    while (n % 2 == 0) {
        n /= 2;
        count++;
    }
    return count;
}

int main() {
    long n; vector<long> a;
    input(n, a);

    long sum = 0;
    for (long i = 0; i < a.size(); i++) { //各要素の2で割り切れる回数の総和
        sum += div(a[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3684
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

const int M = 62;

int n, a[N];
int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }

   vector<int> cnt(M, 0);
   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < M; ++j)
      {
         if(a[i] & (1LL << j))
            cnt[j]++;
      }
   }
   
   int ans = 0;
   for (int j = 0; j < M; ++j)
   {
      int ok = (cnt[j]) * (n - cnt[j]) % mod;
      ok *= ((1LL << j) % mod);
      ok %= mod;
      ans += ok;
      ans %= mod;
   }
   
   cout<<ans;

   return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
ll n,k,b,c,d;
cin>>n>>k;
vector<ll> vec(n+1);
vector<ll> r(n+1,0);
Fr(i,n){
cin>>vec[i];
}
b=1;
  d=0;
r[1] = 0;

Fr(i,k){
b=vec[b];

if(r[b] == 0){
r[b] = i;
}

else{
c = i-r[b];
d=i;
break;
}
}
if(d==0){
  cout<<b;
}
 else{
k = (k-d)%c;
Fr(i,k){
b=vec[b];
}
  cout<<b;
}
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v;
    map<int, int> freq;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        freq[x]++;
    }
    for(int i = 1; i <= n; i++){
        if(freq[i]){
            v.push_back(freq[i]);
        }
    }
    sort(v.begin(), v.end());
    if(v.size() <= k){
        cout << 0;
    }
    else{
        int sum = 0;
        for(int i = 0; i < v.size() - k; i++)   sum += v[i];
        cout << sum;
    }


    return 0;
}


Measured memory_bytes: 10744
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int[] a = new int[100000];
	int N, S, W, Q;
	int g, ans, p, prev, v, z, i;
	Scanner sc = new Scanner(System.in);
	void prime() {
		for(long i= 100000000;;i--) {
			boolean flg = false;
			for(long j=2;j*j< i;j++) if(i%j==0) { flg = true; break; }
			if(!flg) {
				debug(i); break;
			}
		}
	}
	void run() {
		for(;;) {
			N = sc.nextInt(); S = sc.nextInt(); W = sc.nextInt(); Q = sc.nextInt();
			if((N|S|Q|W) == 0) break;
			fill(a, 0);
			g = S;
		    for(i=0; i<N; i++) {
		        a[i] = (g/7) % 10;
		        if( g%2 == 0 ) { g = (g/2); }
		        else           { g = (g/2) ^ W; }
		    }
		    
		    if(Q == 2 || Q == 5) {
		    	ans = 0;
		    	z = 0;
		    	for(i=0;i<N;i++) {
		    		if(a[i] == 0) z++;
		    		if(a[i]%Q == 0) ans += i-z+1;
		    	}
		    	System.out.println(ans);
		    	continue;
		    }
		    p = 1; prev = 0; ans = 0;
		    HashMap<Integer, Integer> cnt = new HashMap<Integer, Integer>();
		    cnt.put(0, 1);
		    for(i=0;i<N;i++) {
		    	v = (prev + p * a[N - i-1])%Q;
		    	prev = v;
		    	if(cnt.containsKey(v)) {
		    		if(a[N - i-1] != 0) ans += cnt.get(v);
		    		cnt.put(v, cnt.get(v)+1);
		    	}
		    	else cnt.put(v, 1);
		    	
		    	p = (p*10)%Q;
		    }
		    
		    System.out.println(ans);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 96748
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
ll const INF = ll(1e18) + 1;


int main()
{
cin.tie(0);
ios::sync_with_stdio(false);

int n,m;
cin >> n >> m;

vl a(m);
vl T(m);

rep(i,m) {
    cin >> a[i];
    int b; cin >> b;
    rep(j,b) {
        int c; cin >> c;
        c--;
        T[i] |= (1<<c);
    }
}

vl dp(5000,INF);
dp[0] = 0;
for(int S = 0; S < (1<<n); ++S) {
    rep(i,m) {
        chmin(dp[S|T[i]], dp[S] + a[i]);
    }
}
if(dp[(1<<n) - 1] != INF) cout << dp[(1<<n) - 1] << endl;
else cout << -1 << endl;

return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, m, a, b;
    scanf("%d%d", &n, &m);
    vector<int> d(n + 1);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &a, &b);
        if (a == 1 || a == n) {
            if (d.at(b)) {
                printf("POSSIBLE\n");
                return 0;
            } else ++d.at(b);
        }
        if (b == 1 || b == n) {
            if (d.at(a)) {
                printf("POSSIBLE\n");
                return 0;
            } else ++d.at(a);
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())

dp=[[0]*2 for i in range(n+1)] 
mod=10**9+7

dp[0][0]=0
dp[0][1]=n
for i in range(n):
    dp[i+1][0]=(dp[i][0]+(i+1))%mod
dp[n][1]=dp[n][0]
for i in range(n-1,0,-1):
    dp[i][1]=(dp[i+1][1]-(n-1-i))%mod

mod=10**9+7

ksum=0
for kk in range(k-1,n+1):
    ksum=(ksum+dp[kk][1]-dp[kk][0]+1)%mod
print(ksum)

Measured memory_bytes: 38764
[X, N] = [int(i) for i in input().split()]
if N == 0:
    P = []
else:
    P = [int(i) for i in input().split()]

if P.count(X) == 0:
    print(X)
else:
    for i in range(100):
        if P.count(X-i) == 0:
            print(X-i)
            break
        elif P.count(X+i) == 0:
            print(X+i)
            break

Measured memory_bytes: 9108
#include <stdio.h>
#define N 100
int main(void){
    int n,m;
    int i;
    int ans;
    int max[N];
    int diff;
    int temp;
    while(1)
    {
        scanf("%d%d",&n,&m);
        if(n==0&&m==0) break;
        for(i=0;i<m;i++) max[i]=0;
        for(i=0;i<n;i++)
        {
            scanf("%d%d",&diff,&temp);
            if(max[diff-1]<temp) max[diff-1]=temp;
        }
        ans=0;
        for(i=0;i<m;i++) ans+=max[i];
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>

int main(){
	int k,x;
	int start,end,i;
	scanf("%d %d",&k,&x);
	start=x-k+1;
	end=x+k;
	for(i=start;i<end;i++){
		printf("%d ",i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, ll M, vector<ll> c){
    sort(all(c), greater<ll>());

    rep2(i, 1, N) {
        ll cnt = 0;
        rep(j, 2 * M) {
            if (c[c.size() - 1] == i) {
                cnt++;
              	c.pop_back();
                continue;
            }
            break;
        }
        cout << cnt << "\n";
    }
}

int main() {
    ll N;
    scanf("%lld",&N);
    ll M;
    scanf("%lld",&M);
    vector<ll> c(2 * M);
    for(int i = 0 ; i < 2 * M ; i++){
        scanf("%lld",&c[i]);
    }
    solve(N, M, move(c));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


class Main{




	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int N,s;
		while(true){
			N = in.nextInt();
			s = in.nextInt();
			if(N+s == 0)break;		//N 工数　S　和　　終了処理
			int cnt=0;		//
			for(int i=0;i<=9;i++){
				if(N <= 0)break;
				if(i == s && N == 1)cnt++;		//	1項がわならカウント　N=1
				for(int j=0;j<=9;j++){
					if(N <= 1)break;		//N1ik owari
					if(i == j)continue;
					if(i+j == s && N == 2)cnt++;		//2kou wa 
					for(int k=0;k<=9;k++){
						if(N <= 2)break;
						if(k==i||k==j)continue;		//k ga i or 
						if(i+j+k == s && N == 3)cnt++;
						for(int l=0;l<=9;l++){
							if(N <= 3)break;
							if(l==i||l==j||l==k)continue;
							if(i+j+k+l == s && N == 4)cnt++;
							for(int m=0;m<=9;m++){
								if(N <=4 )break;
								if(m==i||m==j||m==k||m==l)continue;
								if(i+j+k+l+m == s && N== 5)cnt++;
								for(int n=0;n<=9;n++){
									if(N <=5 )break;
									if(n==i||n==j||n==k||n==l||n==m)continue;
									if(i+j+k+l+m+n == s && N == 6)cnt++;
									for(int o=0;o<=9;o++){
										if(N <=6 )break;
										if(o==i||o==j||o==k||o==l||o==m||o==n)continue;
										if(i+j+k+l+m+n+o == s && N == 7)cnt++;
										for(int p=0;p<=9;p++){
											if(N <=7 )break;
											if(p==i||p==j||p==k||p==l||p==m||p==n||p==o)continue;
											if(i+j+k+l+m+n+o+p == s & N == 8)cnt++;
											for(int q=0;q<=9;q++){
												if(N <=8 )break;
												if(q==i||q==j||q==k||q==l||q==m||q==n||q==o||q==p)continue;
												if(i+j+k+l+m+n+o+p+q == s & N == 9)cnt++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
			int div=1;
			for(int i=2;i<=N;i++)div*=i;
			System.out.println(cnt/div);
		}

	}
	//funny
}


Measured memory_bytes: 29996
#include <stdio.h>
#include <string.h>



int main(){
	
	long int i,j,N;

	char S[200200],T[200200];
	
	scanf("%s%s",S,T);
	
	long len = strlen(S);
	long cnt=0;
	
	for(i=0;i<len;i++){
		if(S[i]!=T[i])cnt++;	
	}
		
	printf("%ld\n",cnt);
	return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  map<int,int>mp;
  rep(i,n)cin>>a[i],mp[a[i]]++;
  priority_queue<int,vector<int>,greater<int>>pq;
  for(auto x:mp){
    pq.emplace(x.second);
  }
  ll ans=0;
  rep(i,mp.size()-k)ans+=pq.top(),pq.pop();
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 11640
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, r) = InputLine.to_ia

  if n >= 10 then
    puts r.to_s
  else
    puts (r + (100 * (10 - n))).to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC82(void);
void ABC83(void);
void ABC84(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC89();
}

void ABC89(){
    int n,i,k=0;
    cin>>n;
    char c;
    vector<char> ch(n);
    for(i=0;i<n;i++){
        cin>>ch[i];
    }
    sort(ch.begin(),ch.end());
    c=ch[0];
    k=1;
    for(i=1;i<n;i++){
        if(ch[i]!=c){
            c=ch[i];
            k++;
        }
    }
    if(k==4)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}

Measured memory_bytes: 256