akhauriyash/Code-Regression huggingface dataset:
import heapq
def dijkstra_heap(s,C):
  #始点sから各頂点への最短距離
  d = [float("inf")] * 10
  used = [False] * 10
  d[s] = 0
  used[s] = True
  edgelist = []
  #edgelist : (sからの暫定(未確定)最短距離,頂点)のリスト
  #edge[s] : sから出る枝の(重み,終点)の配列
  for i,w in enumerate(C[s]):
    heapq.heappush(edgelist,[w,i]) #sの隣の点は枝の重さがそのまま暫定最短距離となる
  while len(edgelist):
    #まだ使われてない頂点の中から最小の距離のものを探す→確定させる
    minedge = heapq.heappop(edgelist)
    #minedge : (sからの(確定)最短距離,頂点)
    v = minedge[1]
    if used[v]:
      continue
    d[v] = minedge[0]
    used[v] = True
    for i,w in enumerate(C[v]):
      if not used[i]:
        heapq.heappush(edgelist,[d[v]+w,i])
  return d

H, W = map(int, input().split())
C = [[] for _ in range(10)]
for i in range(10):
  c = list(map(int, input().split()))
  for j in range(10):
    C[j].append(c[j])
d = dijkstra_heap(1,C)
#print(d)
ans = 0
for i in range(H):
  A = list(map(int, input().split()))
  for a in A:
    if a>=0:
      ans += d[a]
print(ans)

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

using namespace std;
int main()
{
	int A,B,C,D;
	cin >> A>>B>>C>>D;

	int E = C-(D-B);
	int F = D+(C-A);
	int G = E-(C-A);
	int H = F-(D-B);


	printf("%d %d %d %d\n",E,F,G,H);


	return 0;
}

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

typedef long long ll;
typedef pair<long, long> pll;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pll> g;
  vector<pll> c;
  for(int i = 0; i < N; i++){
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    g.push_back(make_pair(tmp1, tmp2));
  }
  for(int i = 0; i < M; i++){
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    c.push_back(make_pair(tmp1,tmp2));
  }
  for(auto x : g){
    ll tmpindex;
    ll tmpmin = 100000000 * 2;
    ll tmp;
    for(int i = 0; i < M; i++){
      tmp = abs(c[i].first - x.first) + abs(c[i].second - x.second);
      if(tmp < tmpmin){
        tmpindex = i;
        tmpmin = tmp;
      }
    }
    cout << tmpindex + 1 << endl;
  }


}

Measured memory_bytes: 256
n = int(input())
A = input().replace(" ","")
m = int(input())
B = input().replace(" ","")
if n > m:
  for i in range(n - m):
    B += " "
elif m > n :
  for i in range(m - n):
    A += " "

if A >= B :
  print(0)
else:
  print(1)



Measured memory_bytes: 5608
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [usize; n]
   }

   let mut s = 0;
   for i in 0..n {
      s ^= a[i];
   }

   for i in 0..n {
      print!("{} ", s ^ a[i]);
   }
}


Measured memory_bytes: 6320
#include <stdio.h>
int main(){
    int n;
    int x,y;
    scanf("%d",&n);
    for(int i = 0;i<=8;i++){
        x = 100*i+10*i+i;
        y = 100*(i+1)+10*(i+1)+i+1;
        if(x<n&&n<=y)
        printf("%d\n",y);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N <= 14) {
		cout << 800 * N << endl;
	}
	if (15 <= N && N <= 29) {
		cout << 800 * N - 200 << endl;
	}
	if (30 <= N && N<= 44) {
		cout << 800 * N - 400 << endl;
	}
	if (45 <= N && N<= 59) {
		cout << 800 * N - 600 << endl;
	}
	if (60 <= N && N<= 74) {
		cout << 800 * N - 800 << endl;
	}
	if (75 <= N && N<= 89) {
		cout << 800 * N - 1000 << endl;
	}
	if (90 <= N) { cout << 800 * N - 1200 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		string cur; cin >> cur;
		m[cur]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'x') {
			cnt++;
		}
	}
	if (cnt < 8) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int times = Integer.valueOf(s.nextLine());
		
		ArrayList<String> list = new ArrayList<String>();
		String word = s.nextLine();
		for(int x=0;x<word.length();x++) {
			list.add(""+word.charAt(x));
		}
		
		for(int x=1;x<times;x++) {
			ArrayList<String> temp = new ArrayList<String>();
			word = s.nextLine();
			for(int y=0;y<word.length();y++) {
				String a = ""+word.charAt(y);
				if(list.contains(a)) {
					list.remove(list.indexOf(a));
					temp.add(a);
				}
			}
			list = temp;
		}
		
		Collections.sort(list);
		String build = "";
		for(String thing : list)
			build+= thing;
		
		System.out.println(build);
	}
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 1000005
typedef long long int ll;
int main()
{
    int i,j,k,a,b,n,m,f,p;
    string str;
    in2(n,m);
    a=0,b=n;
    while(m--)
    {
        in2(i,j);
        a=max(a,i);
        b=min(b,j);
    }
    k=b-a+1;
    k=max(k,0);
    out(k);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 998244353;
ll dp[3010][3010];
void solve()
{
	int n,S;
	cin>>n>>S;
	vector<int>a(n);
	rep(i,n){
		cin>>a[i];
	}
	dp[0][0]=1;
	rep(i,n){
		rep(sum,S+1){
			dp[i+1][sum]+=2*dp[i][sum];
			dp[i+1][sum]%=M;
			if(sum+a[i]<=S){
				dp[i+1][sum+a[i]]+=dp[i][sum];
				dp[i+1][sum+a[i]]%=M;
			}
		}
	}
	cout<<dp[n][S]%M<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 74192
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N, K; cin >> N >> K;
    if (N == K)
    {
        cout << 0 << endl;
        return 0;
    }
    // N > K のとき，操作によって N は N - K に置き換わる
    // -> N を N > K を保ったまま K ずつなるべく減らす
    else if (N > K)
    {
        N -= (N / K - 1) * K;
    }
    set<LLONG> values;
    for (;;)
    {
        values.insert(N);
        N = abs(N - K);
        if (values.find(N) != values.end())
        {
            break;
        }
    }
    cout << *values.begin() << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc061/tasks/abc061_c

# N回操作, K番目に大きい整数
N, K = map(int, input().split())


a_b_list = []
for i in range(N):
    # aをb個挿入する
    a, b = map(int, input().split())
    a_b_list.append([a, b])

a_b_list = sorted(a_b_list)

ans = 0
sum_elements = 0

for i in range(N):

    sum_elements += a_b_list[i][1]
    ans = a_b_list[i][0]
    
    if sum_elements >= K:
        print(ans)
        exit()



Measured memory_bytes: 20872
//based on KOJ0011
long long m[1001][1001];main(i,a,b,q,x,y,X,Y){
	long long j,k;
	for(;~scanf("%d",&a);printf("%lld\n",j)){
		b=a;
		for(j=1;j<=a;j++)for(i=1;i<=b;i++)scanf("%lld",m[j]+i);
		for(j=1;j<=a;j++)for(i=1;i<=b;i++)m[j][i]+=m[j-1][i];
		for(j=1;j<=a;j++)for(i=1;i<=b;i++)m[j][i]+=m[j][i-1];
		//for(j=i=0;i<q;i++)scanf("%d%d%d%d",&y,&x,&Y,&X),j+=m[Y][X]-m[y-1][X]-m[Y][x-1]+m[y-1][x-1];
		j=-999999999;
		for(X=1;X<=a;X++)for(Y=1;Y<=a;Y++)for(x=0;x<X;x++)for(y=0;y<Y;y++){
			k=m[Y][X]-m[y][X]-m[Y][x]+m[y][x];
			if(j<k)j=k;
		}
	}
}

Measured memory_bytes: 1068
n=gets.to_i

(n-1).times{|i|
    array=[]
    (n-i-1).times{|j|
        dif=j+1
        ans=1
        loop{
           if dif%2==0
               dif/=2
               ans+=1
           else
               break
           end
        }
        array.push(ans)
    }
    
    puts array.join(' ')
}

Measured memory_bytes: 2172
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;
typedef long long ll;
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 long long INF = 1LL << 60;
typedef pair<int, int> P;


ll gcd(ll a, ll b) {
    if (a == 0) return b;
    return gcd(b%a, a);
}


int main() {
    /*
    int A, B; cin >> A >> B;
    if (A > B) swap(A,B);
    if (A == 1 && B == 2) {
        cout << 3 << endl; 
    } 
    if (A == 2 && B == 3) {
        cout << 1 << endl; 
    } 
    if (A == 1 && B == 3) {
        cout << 2 << endl; 
    } */
    /*
    int N; cin >> N;
    string S, T;
    cin >> S >> T;
    string res;
    for (int i = 0; i < N; i++) {
        res.push_back(S[i]);
        res.push_back(T[i]);
    }
    cout << res << endl;
    */
    ll A, B; cin >> A >> B;

    cout << A * B / gcd(A,B) << endl;




}


Measured memory_bytes: 256
n=int(input())

b=[0,0,0]
for i in map(int,input().split()):
    b[i-1]+=1
k1,k2,k3=b
dp=[[[None]*(k3+1) for _ in range(k2+k3+1)] for _ in range(k1+k2+k3+1)]
dp[0][0][0]=0

for k in range(k3+1):
    for j in range(k2+k3+1-k):
        for i in range(k1+k2+k3+1-j-k):
            if not i+j+k:continue
            dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)

print(dp[k1][k2][k3])

Measured memory_bytes: 313608
n=int(input())
a=list(map(int,input().split()))
f=0
from fractions import gcd
from functools import reduce



def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(*numbers):
    return reduce(lcm, numbers)
a_lcm=lcm_list(*a)
a_lcm=a_lcm-1
for i in range(n):
    f+=a_lcm % a[i]
print(f)

Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 
 
int main() {
    int n;
    cin >> n;
    int a = n%10,b = (n/10)%10,c = (n/100);
    if(a==7||b==7||c==7){
        cout << "Yes" <<endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(int x,int y){
    while(y != 0){
        ll tmp = y;
        y = x % tmp;
        x = tmp;
    }
    return x;
}

int main(){
    ll a,b,g;
    cin >> a >> b;
    if(a<b){
        g = gcd(b,a);
    }else{
        g = gcd(a,b);
    }
    cout << a * b / (g) << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)


int main(){
    int r,g;
    cin>>r>>g;

    cout<<2*g-r<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    long long X = 0, x = 0, ans = 1000000000000000000LL;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        X += a[i];
    }
    for (int i = 0; i < n; i++)
    {
        x += a[i];
        if (i + 1 < n)
            ans = min(ans, abs(X - 2 * x));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=2e3+10;
ll L[Maxn],ans,N;
bool vis[Maxn];
bool check(ll i,ll j,ll k){
    return L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[k] + L[j] > L[i];
}
int main() {
    ios::sync_with_stdio(false);
    cin>>N;
    for(ll i=1;i<=N;i++)    cin>>L[i];
    sort(L+1,L+N+1);
    for(ll i=1;i<=N;i++){
        bool f=0;
        for(ll j=i+1;j<=N;j++){
            for(ll k=j+1;k<=N;k++){
                if(check(i,j,k)) ans++;
                else{
                    f=1;
                    break;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3680
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N,K=list(map(int,input().split()))
D = list(map(int,input().split()))
Ds = set([0,1,2,3,4,5,6,7,8,9])-set(D)
if 0 in Ds:
    can = list(itertools.product(Ds,repeat = 5))
    candi = []
    for c in can:
        candi.append(10**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
    candi = sorted(candi)
else:
    Ds = Ds | set([0])
    can = list(itertools.product(Ds,repeat = 5))
    candi = []
    for c in can:
        cs = (10**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
        s = list(str(cs))
        if '0' in s:
            continue
        else:
            candi.append(cs)
    candi = sorted(candi)
    
print(candi[bisect.bisect_left(candi,N)])


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

using namespace std;

#define ll long long

int main()
{
	ll N;
	cin >> N;

	string ans = "";

	while (N > 0) {
		N--;
		ans.insert(ans.begin(), 'a' + N % 26);
		N /= 26;
	}

	cout << ans << endl;

	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
map<ll,ll>ma;
int main(){
  int a;
  cin>>a;
  vector<ll>num(a);
  vector<ll>sum(a);
  for(int i=0;i<a;i++){
    cin>>num[i];
    if(i!=0)
      sum[i]=sum[i-1]+num[i];
    else
      sum[i]=num[i];
  }
  if(a==1&&num[0]==0)
    cout<<1<<endl;
  else{
  sort(sum.begin(),sum.end());
  ll ans=0;
  for(int i=0;i<a-1;i++){
    ll cnt=1;
    while(i<a-1&&sum[i]==sum[i+1]){
      cnt++;
      i++;
    }
    if(sum[i]==0)
      ans+=(cnt*(cnt+1))/2;
    else
      ans+=(cnt*(cnt-1))/2;
  }
  cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;

int n, m, a[100][100], b[100][100], can[82][82][25800], val[100][100];


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> b[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            val[i][j] = abs(a[i][j] - b[i][j]);
        }
    }
    can[1][1][12800 + val[1][1]] = can[1][1][12800 - val[1][1]] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            for(int k = 0; k <= 25700; k++){
                if(can[i - 1][j][k] && i - 1){
                    assert(k - val[i][j] >= 0);
                    can[i][j][k + val[i][j]] = can[i][j][k - val[i][j]] = 1;
                }
                else if(can[i][j - 1][k] && j - 1){
                    assert(k - val[i][j] >= 0);
                    can[i][j][k + val[i][j]] = can[i][j][k - val[i][j]] = 1;
                }
            }
        }
    }
    int ans = mod;
    for(int i = 1; i <= 25780; i++){
        if(can[n][m][i]) ans = min(ans, abs(i - 12800));
    }
    cout << ans;


    return 0;
}


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

int main(){
    int n;
    cin >> n ;
    vector<double>a(n),b(n-1);
    for(int i=0; i<n; i++){
        cin>> a.at(i);
    }
    sort(a.begin(),a.end());
    b.at(0)=(a.at(0)+a.at(1))/2;
    for(int i=2; i<n; i++){
        b.at(i-1)=(a.at(i)+b.at(i-2))/2;
    }
    cout << b.at(n-2);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += i;
		if (sum > n) {
			int tmp = sum - n;
			for (int j = 1; j <= i; j++) {
				if (j == tmp)continue;
				cout << j << endl;
			}
			return 0;
		}
		if (sum == n) {
			for (int j = 1; j <= i; j++) {
				cout << j << endl;
			}
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int, input().split()))
XX = sorted(X)
mid = (XX[N//2-1] + XX[N//2])/2 
for i in range(N):
  if X[i] < mid:
    print(XX[ N//2 ])
  else:
    print(XX[N//2-1])
    


Measured memory_bytes: 26016
//1円硬貨A枚と500円硬貨∞枚だけで, ちょうど 
//N円を支払うことができるならば Yes, 
//そうでないならば No を出力しなさい.
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A;
  cin >> N >> A;

  if ((N % 500) <= A){
  cout << "Yes" <<endl;}
  else {
  cout << "No" << endl;}
}

Measured memory_bytes: 256
n, m= map(int, input().split())
ans = [10] * (n + 1)
#s-digit: ans = [dummy, 1st-d, 2nd-d, ...]
for i in range(m):
  s, c = map(int, input().split())
  if ans[s] == 10 and not (n!=1 and s==1 and c==0):
    ans[s] = c
  elif ans[s] == c:
    pass
  elif ans[s] != c or (n!=1 and s==1 and c==0):
    print(-1)
    exit()
for i in range(1, n+1):
  if ans[i] == 10:
    ans[i] = 0
    if i == 1 and n != 1:
      ans[i] += 1
print(''.join([str(x) for x in ans[1:]]))

Measured memory_bytes: 62064
#include <iostream>
#include <cstring> 
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <array>
using namespace std;

vector<array<int,13> > L;
int n,m,x;
int mmm=9999999;

void F(int i,array<int,13> now) {
  if ( n<=i ) return;
  F(i+1,now);

  array<int,13> tmp = now;
  for(int j=0;j<=m;++j) {tmp[j] += L[i][j];}
  
  bool test=true;
  for(int j=1;j<=m;++j) {if(tmp[j]<x) {test=false;break;}}
  if(test) {
    if (tmp[0]<mmm) {mmm=tmp[0];}
    return;
  }

  F(i+1,tmp);
  
}


int main() {
    cin >> n >> m >> x;

    for(int i=0;i<n;++i) {
        array<int,13> D;
        for(int j=0;j<=m;++j) {
          cin >> D[j];
        }
        L.push_back(D);
    }

    F(0,array<int,13>());
    if ( 9999999 <= mmm ) {
      cout << "-1";
      return 0;
    }

    cout << mmm;
}

Measured memory_bytes: 3596
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    N := nextInt()

    x := 1
    y := 1
    for i := 0; i < N; i++ {
        ti := nextInt()
        ai := nextInt()
        a := Max([]int{(x+ti-1)/ti, (y+ai-1)/ai});
        x = ti*a
        y = ai*a
    }
    fmt.Println(x+y)
}

/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    first, second int
}
 
type Pairs []Pair
  
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {

	double x;

	cin >> x;
	
	
	for (int i = -200; i < 200; i++)
	{
		for (int j = -200; j < 200; j++)
		{
			if (pow(i, 5) - pow(j, 5) == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

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

int main() {
int64_t H;
  cin>>H;
  
   int64_t i=2;
  while(H!=1)
  {H=H/2;
   i=i*2;
  }
  i=i-1;
  cout<<i<<endl;
}


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

int main()
{
	int n, i, x;
	
	cin >> n;

	i = 1;
	while (i <= n) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				else x /= 10;
				}
			}
		i++;
		}
	cout << endl;
    return 0;
}




Measured memory_bytes: 3100
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  // #define MAX 100001
  #define md 998244353
  #define add accumulate
  #define ll long long int
  #define ld long double
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define repa(a,n) for(int i=a;i<n;i++)
  const int MAX=1e5+5;
  const int mod=1e9+7;
  const int N=3e5+9;
  const long double eps=1e-9;
  const ld PI=acos(-1.0);
    ll dx[]={1,0,-1,0};
	ll dy[]={0,1,0,-1};
  //
  //
  int main(){
  	hs;
  	string str;	cin>>str;
  	ll ans1=0,ans2=0;
  	rep(i,0,str.length()){	//101010
  		if(i&1){
  			ans1+=(str[i]!='0');
  		}
  		else
  			ans1+=(str[i]!='1');
  	}
  	rep(i,0,str.length()){	// 010101{
  		if(i&1)
  			ans2+=(str[i]!='1');
  		else
  			ans2+=(str[i]!='0');
  	}
  	cout<<min(ans1,ans2);
  	return 0;
  }

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static void preorder(int node, int[] n_left, int[] n_right){
		System.out.print(" " + node);
		if(n_left[node] != -1){ preorder(n_left[node], n_left, n_right); }
		if(n_right[node] != -1){ preorder(n_right[node], n_left, n_right); }
	}
	
	public static void inorder(int node, int[] n_left, int[] n_right){
		if(n_left[node] != -1){ inorder(n_left[node], n_left, n_right); }
		System.out.print(" " + node);
		if(n_right[node] != -1){ inorder(n_right[node], n_left, n_right); }
	}

	public static void postorder(int node, int[] n_left, int[] n_right){
		if(n_left[node] != -1){ postorder(n_left[node], n_left, n_right); }
		if(n_right[node] != -1){ postorder(n_right[node], n_left, n_right); }
		System.out.print(" " + node);
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int[] parent = new int[n];
		Arrays.fill(parent, -1);
		int[] n_left = new int[n];
		int[] n_right = new int[n];
		
		for(int i = 0; i < n; i++){
			final int id = sc.nextInt();
			final int left = sc.nextInt();
			final int right = sc.nextInt();
	
			n_left[id] = left;
			n_right[id] = right;
			if(left != -1){ parent[left] = id; }
			if(right != -1){ parent[right] = id; }
		}
		
		int root_node = -1;
		for(int i = 0; i < n; i++){
			if(parent[i] == -1){
				root_node = i;
				break;
			}
		}
		
		System.out.println("Preorder");
		preorder(root_node, n_left, n_right);
		System.out.println();
		
		System.out.println("Inorder");
		inorder(root_node, n_left, n_right);
		System.out.println();
		
		System.out.println("Postorder");
		postorder(root_node, n_left, n_right);
		System.out.println();
		
		
		
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 1e5+100;
int num[MAX];
bool isp[MAX];

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

  fill(isp, isp+MAX, true);
  isp[0] = isp[1] = false;
  for(int i=2;i<MAX;++i)
	if(isp[i])
	  for(int j=i+i;j<MAX;j+=i)
		isp[j] = false;

  for(int i=1;i<MAX;i+=2){
	if(isp[i] && isp[(i+1)/2])
	  ++num[i];
	num[i] += num[i-2];
  }

  int Q;
  cin >> Q;
  while(Q--){
	int l, r;
	cin >> l >> r;
	cout << num[r] - num[max(1,l-2)] << endl;
  }

  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
using edge = pair<int, int>;
using graph = vector<vector<edge>>;
vector<int> color;

graph g;
int n;

//pはvの親
void dfs(int v, int p, int clr){
    color[v]= clr;
    for(auto e: g[v]){
        if(e.first == p){continue;}
        if(e.second & 1){dfs(e.first, v, 1-clr);}
        else{dfs(e.first, v, clr);}
    }
}

int main(){
    cin >> n;
    g.assign(n, vector<edge>());
    for(int i=0; i<n-1; ++i){
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        g[u].push_back(edge(v, w));
        g[v].push_back(edge(u, w));
    }
    color.assign(n, 0);
    dfs(0, -1, 1);
    for(auto v: color){cout << v << endl;}
}

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

int N;
set<int> st;

int main(){
    cin>>N;

    for (int i = 0; i < N; i++)
    {   
        int x;
        cin>>x;
        st.insert(x);
    }
    
    cout << st.size() << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	vector<ll> vec(n);
	ll nin = 1e9, nax = 0;
	for(int i = 0; i < n; i++){
		cin>>vec[i];
		nax = max(nax, vec[i]);
		nin = min(nin, vec[i]);
	}
	ll res = 1e9;
	for(int u = 0; u <= 100; u++){
		ll tmp = 0;
		for(int i = 0; i < n; i++){
			tmp += (u - vec[i]) * (u - vec[i]);
		}
		res = min(tmp, res);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
from collections import*
import functools
import sys
input=sys.stdin.readline
@functools.lru_cache(maxsize=None)
def Knapsack(N,W):
    for i in range(N):
        w,v=map(int,input().split())
        for k,b in d.copy().items():
            if k+w<=W:
                d[k+w]=max(d[k+w],b+v)
    return print(max(d.values()))
N,W=map(int,input().split())   #pypyで実行！
d=defaultdict(int)
d[0]=0
if __name__=='__main__':
  Knapsack(N,W)

Measured memory_bytes: 4116
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const ll MOD = 1000000007;
 
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> a(N), b(N), c(N);
    vector<ll>  ch(N,0);
    for(int i=0; i<N; i++)  cin >> a[i];
    for(int i=0; i<N; i++)  cin >> b[i];
    for(int i=0; i<N; i++)  cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    int tmp, l, m;
    l = 0;
    m = 0;
    while(l < N){
        if(c[m] <= b[l]){
            while(c[m] <= b[l] && m < N) m++;
        }
        ch[l] = N-m;
        l++;
    }
    for(int i=N-2; i>=0; i--)  ch[i] += ch[i+1];
    l = 0;
    m = 0;
    ll ans = 0;
    while(l < N){
        if(b[m] <= a[l]){
            while(b[m] <= a[l] && m < N) m++;
        }
        ans += ch[m];
        l++;
    }
    cout << ans;
}

Measured memory_bytes: 5020
//
// Created by munaiyi on 2020/3/21.
//
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int c[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", c + i);
    }
    sort(c, c + n, [](int x, int y) -> bool { return x > y; });
    long long ans = c[0];
    long long two = 1;
    for (int i = 1; i < n; i++) {
        ans = ans * 2;
        ans = (ans + (two * i % mod + two * 2) * c[i]) % mod;
        two = two * 2 % mod;
    }
    ans = ans * two * 2 % mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> A(N);

    rep(i,N){
        cin >> A[i];
    }

    ll ans=0; int RIGHT = 0;int sum =0;

    for(int LEFT = 0; LEFT < N; LEFT++){

        while(RIGHT < N && (A[RIGHT]^sum) == (A[RIGHT]+sum) ){
            sum += A[RIGHT];
            RIGHT++;
        }

        ans += RIGHT - LEFT;

        if(LEFT == RIGHT){
            RIGHT++;
        }

        else{
            sum -= A[LEFT];
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<int> a;
    int keta;
    int ff=0;
    if(n<=9) cout << n <<endl;
    else{
        while(n){
        a.push_back(n%10);
        n/=10;
        keta++;
    }

    rep(i,a.size()-1){
        if(a[i]==9) ff++;
    }
    int ans=9*(keta-1);
    if(ff==keta-1) ans+=a.back();
    else ans+=a.back()-1;
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)

ans = 0
1.upto(n) do |i|
  if i >= k
    ans += 1.0/n
  else
    ans += (1.0/n) * ((0.5) ** (Math.log2(k.to_f/i).ceil))
  end
end
p ans


Measured memory_bytes: 1788
//C - Scc Puzzle: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll n, m, ans = 0, aux;
    cin >> n >> m;
    aux = min(n, m/2);
    n -= aux; m -= aux*2;
    ans = aux;
    if(n == 0) ans = aux + (m/4);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define INF 100000000
#define N 2000001

int h,A[N];

void exchange(int i,int j)
{
  int temp;
  temp=A[i];
  A[i]=A[j];
  A[j]=temp;
}

int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

void maxHeapify(int i){
  int l,r,largest;
  l=left(i);
  r=right(i);
  if(l<=h&&A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=h&&A[r]>A[largest])
    largest=r;

  if(largest!=i){
    exchange(i,largest);
    maxHeapify(largest);
  }
  
}


int extract(){
  int max;
  if(h<1)return -INF;
  max=A[1];
  A[1]=A[h--];
  maxHeapify(1);
  return max;
}

void increaseKey(int i,int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    exchange(i,i/2);
    i/=2;
  }
}

void insert(int key){
  h++;
  A[h]=-INF;
  increaseKey(h,key);
}

int main(){
  int key;
  char c[10];

  while(1){

    scanf("%s",c);
    if(c[0]=='e'&&c[1]=='n')break;
    if(c[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());

    }

  }


  return 0;
}










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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    bool F[n];
    for(int i=0; i<n; i++) F[i] = true;

    int H[n];
    for(int i=0; i<n; i++) cin >> H[i];

    int a, b;
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        a--; b--;
        if(H[a] == H[b]) {
            F[a] = false;
            F[b] = false;
        }
        if(H[a]>H[b]) F[b] = false;
        else F[a] = false;
    }

    int cnt = 0;
    for(int i=0; i<n; i++) if(F[i]) cnt++;

    cout << cnt << endl;

    return 0;
}


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

main(){
  int n;cin >> n;
  int a[n];for(int i=0;i<n;i++)cin >> a[i];
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<n;){
    int cc = a[i];
    int cnt = 0;
    int j=i;
    while(a[j] == cc){
        cnt++;
        i++;
        j++;
      }
    ans+=cnt%2;
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 4000
N,M = map(int,input().split())
if M==0:
  if N==1:
    print(0)
    exit()
  elif N==2:
    print(10)
    exit()
  else:
    print(100)
    exit()
SC = [list(map(int,input().split())) for _ in range(M)]
if N==1:
  s,c = SC[0][0],SC[0][1]
  for sc in SC:
    if c==sc[1]:
      continue
    else:
      print(-1)
      exit()
  print(c)
  
else:
  lis = [[] for _ in range(N)]
  for sc in SC:
    lis[sc[0]-1].append(sc[1])
    
  if 0 in lis[0]:
    print(-1)
    exit()
    
  else:
    if N==2:
      if lis[0]==[]:
        a = str(1)
      else:
        a = str(lis[0][0])
        
      if lis[1]==[]:
        b = str(0)
      else:
        b = str(lis[1][0])
        
      for i in lis[0]:
        if a==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[1]:
        if b==str(i):
          continue
        else:
          print(-1)
          exit()
      print(int(a+b))
      exit()
      
    else:
      if lis[0]==[]:
        a = str(1)
      else:
        a = str(lis[0][0])
        
      if lis[1]==[]:
        b = str(0)
      else:
        b = str(lis[1][0])
        
      if lis[2]==[]:
        c=str(0)
      else:
        c = str(lis[2][0])
      for i in lis[0]:
        if a==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[1]:
        if b==str(i):
          continue
        else:
          print(-1)
          exit()
      for i in lis[2]:
        if c==str(i):
          continue
        else:
          print(-1)
          exit()
      print(int(a+b+c))
      exit()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,m,i,total=0;
  cin>>n;
  long long t[n+1];
  for(i=1;i<=n;i++)
  {
    cin>>t[i];
    total+=t[i];
  }
  cin>>m;
  long long temp=total;
  for(i=1;i<=m;i++)
  {
    long long x,y;
    cin>>x>>y;
    total-=t[x];
    total+=y;
    cout<<total<<"\n";
    total=temp;
  }
}
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void){

    int ans = 0;
    char s;

    for(int i = 0; i < 4; i++){
        cin >> s;
        if(s == '+'){
            ans++;
        }else{
            ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int H = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        
        System.out.println((H-h) * (W-w));
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin>>S;
    int i=0,j=0;
    int n=S.size();
    if(n<7) cout <<"NO"<<"\n";
    else{
    if(S[i]=='k'){
        i++;
        if(S[i]=='e'){
            i++;
            if(S[i]=='y'){
                i++;
                if(S[i]=='e') {
                    i++;
                    if(S[i]=='n'){
                        i++;
                        if(S[i]=='c'){
                            i++;
                            if(S[i]=='e'){
                                i++;
                            }
                        }
                    }
                }
            }
        }
    }
    if(S[n-1-j]=='e'){
        j++;
        if(S[n-1-j]=='c'){
            j++;
            if(S[n-1-j]=='n'){
                j++;
                if(S[n-1-j]=='e') {
                    j++;
                    if(S[n-1-j]=='y'){
                        j++;
                        if(S[n-1-j]=='e'){
                            j++;
                            if(S[n-1-j]=='k'){
                                j++;
                            }
                        }
                    }
                }
            }
        }
    }
    if(i+j>=7) cout <<"YES"<<"\n";
    else cout <<"NO"<<"\n";
    }
}

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

#define fi first
#define se second

using ll = long long;

const int N = 1e5L + 11;
const int M = 511;

int ds[] = {-1, 1, 0, 0};
int dt[] = {0, 0, -1, 1};

int s[N], t[N];

int d[M][M];

ll dis[M][M][5];
struct poi {
	int s, t;
	int dir;
	bool operator <(poi p) const {
		return tie(s, t, dir) < tie(p.s, p.t, p.dir);
	}
};

int main() {
	ios :: sync_with_stdio(false);
	int h, w; cin >> h >> w;
	ll a, b, c; cin >> a >> b >> c;
	int n; cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> s[i] >> t[i];

	{
		memset(d, -1, sizeof d);
		queue <pair <int, int>> q;
		for(int i = 1; i <= n; i ++) {
			d[s[i]][t[i]] = 0;
			q.push({s[i], t[i]});
		}
		while(!q.empty()) {
			auto p = q.front(); q.pop();
			for(int k = 0; k < 4; k ++) {
				int ns = p.first + ds[k];
				int nt = p.second + dt[k];
				if(ns >= 0 && ns <= h && nt >= 0 && nt <= w && d[ns][nt] == -1) {
					d[ns][nt] = d[p.first][p.second] + 1;
					q.push({ns, nt});
				}
			}
		}
	}

	{
		set <pair <ll, poi>> st;
		for(int k = 0; k < 5; k ++)
			for(int i = 0; i <= h; i ++)
				for(int j = 0; j <= w; j ++) {
					if(i == s[1] && j == t[1] && k == 4)
						dis[i][j][k] = 0;
					else
						dis[i][j][k] = 1e18L;
					st.insert({dis[i][j][k], {i, j, k}});
				}
		auto f = [&](ll id, int i, int j, int k) {
			if(id >= dis[i][j][k]) return;
			st.erase({dis[i][j][k], {i, j, k}});
			dis[i][j][k] = id;
			st.insert({dis[i][j][k], {i, j, k}});
		};
		while(!st.empty()) {
			auto p = *st.begin();
			st.erase(st.begin());
			int s = p.se.s, t = p.se.t, dir = p.se.dir;
			if(dir == 4) {
				for(int k = 0; k < 4; k ++) {
					f(p.fi + b, s, t, k);
					int ns = s + ds[k];
					int nt = t + dt[k];
					if(ns >= 0 && ns <= h && nt >= 0 && nt <= w) {
						f(p.fi + c, ns, nt, 4);
					}
				}
			}
			else {
				int ns = s + ds[dir];
				int nt = t + dt[dir];
				if(ns >= 0 && ns <= h && nt >= 0 && nt <= w)
					f(p.fi + a, ns, nt, dir);
				f(p.fi + d[s][t] * c, s, t, 4);
			}
		}
	}
	cout << dis[s[n]][t[n]][4] << '\n';
	return 0;
}

Measured memory_bytes: 93360
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N, K = map(int,input().split())
    #h = list(map(int, input().split()))
    h = [int(x) for x in input().split()] #こっちのほうが早い？
    dp = [0]*(N)

    #2:初期値
    dp[0] = 0

    #3:dp実行部(貰うDP)(配るDPでは事項時間制限に間に合わない)
    for i in range(1,N):
        L = [dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)

    #4:出力
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14108
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int N, d[100010], ans;
void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
        cin >> d[i];
    sort(d, d + N);
    ans = d[N / 2] - d[N / 2 - 1];
    if (ans < 0)
        ans = 0;
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 1024