akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    bool f=false;
    int now = 1;
    for(int i=0;i<N;i++){
        //cerr << now << " ";
        if(a[i] == now){
            now ++;
            f=true;
        }
    }
    if(!f){
        cout << -1 << endl;
    }else{
        cout << N-now+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll x;
    cin>>x;
    cout<<1-x<<endl;   
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())

snuke = [False] * N
for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        snuke[a[j] - 1] = True

ans = 0
for i in range(N):
    if not snuke[i]:
        ans += 1

print(ans)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
int main()

{
	ll x,y;

	cin>>x>>y;

	map<ll,ll>mp;

	for(ll i=0;i<y;i++)
    {
        ll a;

        cin>>a;

		mp[a]=1;
	}

	if(mp[x]==0)
    {
		cout<<x<<endl;
		return 0;
	}

	ll n=x,m=x;

	while(1)
    {
		n--,m++;

		if(mp[n]==0)
            {
		 	cout<<n<<endl;
			return 0;
		}
		if(mp[m]==0)
		{
			cout<<m<<endl;
			return 0;
		}
 	}
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, t, x, y, nextt, nextx, nexty;

int main(){
	cin >> n;
	t = 0;
	x = 0;
	y = 0;
	
	string ans = "Yes";
	for(ll i = 1; i <= n; i++){
		cin >> nextt >> nextx >> nexty;
		ll dst = abs(nextx-x)+abs(nexty-y);
		if(dst > nextt-t || dst%2 != (nextt-t)%2){
			ans = "No";
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
jobs = [[] for _ in range(10 ** 5 + 100)]
# 隣接リストっぽく
for i in range(n):
    a, b = map(int, input().split())
    jobs[a].append(b)

hq = []
res, j = 0, 0
for i in range(1, m + 1):
    for v in jobs[i]:
        heappush(hq, -v)
    if len(hq) > 0:
        res += -heappop(hq)
print(res)

Measured memory_bytes: 72480
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, l[10], ta;

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> l[i];
		ta += l[i];
	}
	sort(l,l + n);
	if (ta - l[n - 1] > l[n - 1])cout << "Yes" << endl;
	else cout << "No" << endl;
	getchar(); getchar();
	return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m; cin >> n >> m;

  ll left = 0, right = infll;

  auto f = [&](ll x) {
    if (x * 2 > m) return false;
    ll y = m - (x * 2);

    ll z = y / 2;

    if (n + z >= x) return true;
    else return false;
  };

  while (right - left > 1) {
    ll mid = (right + left) / 2;

    if (f(mid)) left = mid;
    else right = mid;
  }

  cout << left << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = IOUtils.ReadInts();

            for (int i = 0; i < 5; i++)
            {
                if (vals[i] == 0) {
                    System.Console.WriteLine(i + 1);
                    return;
                }
            }

        }
    }
    
    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 27964
n, k = gets.split.map(&:to_i)
row = gets.chomp
zero = row.split('1').map{|it| it.size}.select{|it| it != 0}
one = row.split('0').map{|it| it.size}.select{|it| it != 0}

one.unshift(0) if row[0] == '0'  # starts with one
zero.push(0) if one.size > zero.size

sums = one.zip(zero).flatten.inject([0]){|acc, it| acc.push(acc[-1] + it)}
range = (k + 1) * 2 - 1
last_index = sums.size - 1

puts (0..last_index).step(2).map{|left|
    right = [left + range, last_index].min
    sums[right] - sums[left]
}.max



Measured memory_bytes: 15352
n,a,b=map(int,input().split())
cnt=0
c=100000000000000000
if (b-a)%2 == 0:
  cnt=b-(b+a)//2
  print(cnt)
  exit()
if (b-a)%2 == 1:
  if a==1:
    if b==n:
        c=n-a
    d=1+((b-1)-(((b-1)+a)//2))
    cnt=min(c,d)
    print(cnt)
    exit()
  if b==n:
    if a==1:
        c=b-1
    d=1+(b-(b+a+1)//2)
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1==n-b:
    c=(a-1)+(b-(a-1)-1+1)//2
    d=round(b-1)
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1 > n-b:
    c=n-b+1+(n-(n+(a+1+(n-b)))//2)
    d=n-a
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1 < n-b:
    c=(a-1)+(b-(a-1)-1+1)//2
    d=b-1
    cnt=min(c,d)
    print(cnt)
    exit()

Measured memory_bytes: 3188
#include <iostream>
#include<string>
using namespace std;
int main() 
{
    char arr[10];
    cin>>arr;
    string s(arr);
    string S;
    if(s=="ABC")
        S.append("ARC");
    else
        S.append("ABC");
    for(int i=0;i<3;i++)
        cout<<S[i];
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(void){

int N, M, a, b, i;

cin >> N >> M;

int c[N];

for(i = 0; i < N + 1; i++){
    c[i] = 0;
}

for(i = 0; i < M; i++){
    
    cin >> a >> b;
    
    c[a] = c[a] + 1;
    
    c[b] = c[b] + 1;
    
}

for(i = 1; i <= N; i++){
    cout << c[i] << endl;
}
    
}


Measured memory_bytes: 3556
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    cin >> n >> a;
    REP(i,a+1){
        if((n-i)%500==0){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

    return 0;
}

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

int main(){

    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0){
            break;
        }
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin >> a[i];
        } 
        vector<int> c;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int t=a[i]+a[j];
                if(t<=m){
                    c.push_back(t);
                }
            }
        }
        if(c.size()==0){
            cout << "NONE" << endl;
        }else{
            sort(c.begin(),c.end());
            cout << c.back() << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

int main() {
    ll N, K, S;
    cin >> N >> K >> S;

    vector<ll> ans(K, S);
    ll tmp = S == 1000000000 ? 1 : S + 1;
    rep(i, N - K) { ans.push_back(tmp); }
    rep(i, N - 1) { cout << ans[i] << " "; }
    cout << ans[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 4820
H,W=map(int,input().split())
A=[list(input())for i in range(H)]
ww=set()
hh=set()
for h in range(H):
  for w in range(W):
    if A[h][w]=='#':
      ww.add(w)
      hh.add(h)
ww=sorted(list(ww))
for h in sorted(list(hh)):
  _=''
  for w in ww:
    _+=A[h][w]
  print(_)

Measured memory_bytes: 3188
#include <stdio.h>

int main(int argc, char *argv[]) {
    int n, k, s;
    int l;
    int a[100000];
    int i;
    
    scanf("%d %d %d", &n, &k, &s);
    
    for (i = 0; i < k; i++) {
        a[i] = s;
    }
    
    for (i = k; i < n; i++) {
        if (s == 1000000000) {
            a[i] = 1000000000 - 1;
        } else {
            a[i] = s + 1;
        }
    }
    
    printf("%d", a[0]);
    for (i = 1; i < n; i++) {
        printf(" %d", a[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1664
n=int(input())
A=[int(x) for x in input().rstrip().split()]
B=[int(x) for x in input().rstrip().split()]
C=[int(x) for x in input().rstrip().split()]
A.sort()
C.sort()
ans=0

for i in B:
  left=0
  right=n
  while(left<right):
    now=(left+right)//2
    if A[now]<i:
      left=now+1
    else:
      right=now

  left2=0
  right2=n
  while(left2<right2):
    now=(left2+right2)//2
    if C[now]<=i:
      left2=now+1
    else:
      right2=now

  ans+=right*(n-right2)
print(ans)


Measured memory_bytes: 23292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuilder sba = new StringBuilder();
		StringBuilder sbb = new StringBuilder();
		for(int i =0; i < b; i++) {
			sba.append(String.valueOf(a));
		}

		for(int i =0; i < a; i++) {
			sbb.append(String.valueOf(b));
		}

		String stringA = sba.toString();
		String stringB = sbb.toString();

		if(a < b) {
			System.out.println(stringA);
		}else {
			System.out.println(stringB);
		}
	}
}

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

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

    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(n == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

bool field[64][64];
bool block[64][64];
int need[64];

int BW, BH, FW, FH;
int minx, miny, maxx, maxy;

void adjust()
{
	minx = 999; miny = 999;
	maxx = 0;   maxy = 0;

	for(int i=0; i<64; i++) {
		bool f = false;
		for(int j=0; j<64; j++) {
			if(block[j][i]) {
				f = true;
			}
		}

		if(f) {
			miny = min(miny, i);
			maxy = max(maxy, i);
		}
	}

	for(int i=0; i<64; i++) {
		bool f = false;
		for(int j=0; j<64; j++) {
			if(block[i][j]) {
				f = true;
			}
		}

		if(f) {
			minx = min(minx, i);
			maxx = max(maxx, i);
		}
	}
}

void rotate()
{
	bool tmp[64][64];
	memset(tmp, 0, sizeof(tmp));

	for(int i=0; i<64; i++)
	for(int j=64-1; j>=0; j--) {
		tmp[i][64-1-j] = block[j][i];
	}

	memcpy(block, tmp, sizeof(block));
}

int solve()
{
	adjust();

	int W = maxx - minx + 1;
	int H = maxy - miny + 1;

	int res = -1;

	for(int i=0; i<=FH - H; i++) {
		for(int j=0; j<=FW - W; j++) {
			bool valid = true;
			int score = 0;

			for(int y=miny; y<=maxy; y++) {
				int cnt = 0;
				for(int x=minx; x<=maxx; x++) {
					if(!block[x][y]) continue;

					if(!field[j + x - minx][i + y - miny]) {
						valid = false;
					}
					else {
						cnt++;
					}
				}

				if(valid && need[i + y - miny] == cnt) score++;
			}

			if(valid) {
				res = max(score, res);
			}
		}
	}

	return res;
}

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

	while(N--) {
		memset(need, 0, sizeof(need));
		memset(field, 0, sizeof(field));
		memset(block, 0, sizeof(block));

		cin >> BH >> BW;
		string b[64], f[64];

		for(int i=0; i<BH; i++)
			cin >> b[i];

		cin >> FH >> FW;
		for(int i=0; i<FH; i++)
			cin >> f[i];

		for(int i=0; i<BH; i++)
		for(int j=0; j<BW; j++) {
			if(b[i][j] == '#') {
				block[j][i] = 1;
			}
		}

		for(int i=0; i<FH; i++)
		for(int j=0; j<FW; j++) {
			if(f[i][j] == '.') {
				field[j][i] = 1;
				need[i]++;
			}
		}

		int res = -1;
		for(int i=0; i<4; i++) {
			res = max(res, solve());
			rotate();
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1248
N=int(input())
if N==1:
  print(0)
  exit()
  
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=factorization(N) 
A=[]
d=0
for i in range(1,50):
  d+=i
  A.append(d)
import bisect
cnt=0
for x,y in a:
  e=bisect.bisect_right(A,y)
  cnt+=e
print(cnt)

Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N, K, L, R, M, l, r, m, cnt;
vector<ll> num;
int main()
{
    cin>>N>>K;
    num.clear();
    for(ll i = 0; i<N; ++i)
    {
        ll n;
        cin>>n;
        num.push_back(n);
    }
    sort(num.begin(), num.end());
    L = -2e18;
    R = 2e18;
    //L = -15;
    //R = 15;
    while(R-L>1)
    {
        M = (L+R)/2;
        cnt = 0;
        
        for(ll i = 0; i<N; ++i)
        {
            int l = i, r = N; 
            while(r-l>1)
            {
                int m = (l+r)/2;
                if(num[i]*num[m]<=M) //too small
                    (num[i]>0) ? l = m : r = m;
                else //too big
                    (num[i]>0) ? r = m : l = m;
                //cout<<"(l, r, m, cnt) = ("<<l<<", "<<r<<", "<<m<<", "<<cnt<<")\n";
            }
            if(num[i]>0) cnt+=l-i;//not sure
            else cnt+=N-r;// not sure
        }
        (cnt<K) ? L = M : R = M; //too small
        //cout<<"(L, R, M) = ("<<L<<", "<<R<<", "<<M<<")\n";
    }
    cout<<R<<"\n";
}


Measured memory_bytes: 2420
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    boost::multi_array<int, 2> mat(boost::extents[3][3]);

    auto s = 0;
    for (auto p = mat.origin(); p < (mat.origin() + mat.num_elements()); ++p) {
        cin >> *p;
        s += *p;
    }
    s /= 3;

#if 0
    for (auto q: mat) {
        for (auto qq: q) {
            cerr << qq << " ";
        }
        cerr << endl;
    }
#endif

    std::vector<int> I = {0, 1, 2};

    do {
        int sum = 0;
        for (size_t i = 0; i < 3; ++i) {
            sum += mat[I[i]][i];
        }
        if (sum != s) {
            std::cout << "No" << std::endl;
            return 0;
        }
    } while (std::next_permutation(I.begin(), I.end()));

    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 256
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

void solve() {
    lli a, b;
    cin >> a >> b;
    lli ans = a + (b / 2);
    cout << ans << endl;
}

int main()
{
    opt;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){

	int m,n,a,b;
	while(1){

		cin >> n >> m;
		if(n==0 && m==0) break;

		vector<pair<int,int> >L;

		for(int i=0;i<m;i++){
			cin >> a >> b;
			L.push_back(make_pair(a,b));
		}

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

		vector<int>s(501,0);

		for(int i=0;i<m;i++){
			if(L[i].first==1) s[L[i].second]=1;
			else break;

			for(int j=0;j<m;j++){
				if(L[j].first==L[i].second)
					s[L[j].second]=1;
				if(L[j].second==L[i].second && L[j].first!=1)
					s[L[j].first]=1;
			}
		}

		int c=0;
		for(int i=1;i<=500;i++)
			if(s[i]) c++;

		cout << c << endl;

		L.clear();
	}

	return 0;
}

Measured memory_bytes: 1328
import java.util.*;

class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
      	int B = Integer.parseInt(sc.next());
      	int C = Integer.parseInt(sc.next());
      	int K = Integer.parseInt(sc.next());
        int[]hako = {A,B,C};
      
      	Arrays.sort(hako);
      int max = hako[2];
      	for(int i=0;i<K;i++){
          max = max *2;
        }
      max = max + hako[0] + hako[1];
      System.out.print(max);
      
      
      
    }
}

Measured memory_bytes: 21588
#include<stdio.h>

int main()
{
	int carda,cardb;
	int pointa,pointb;
	int game,i;
	
	while(1)
	{
		scanf("%d",&game);
		if(game==0)break;
		pointa=0;
		pointb=0;
		for(i=0;i<game;i++)
		{
			scanf("%d %d",&carda,&cardb);
			if(carda>cardb)
			{
				pointa+=carda+cardb;
			}
			else if(carda<cardb)
			{
				pointb+=carda+cardb;
			}
			else
			{
				pointa+=carda;
				pointb+=cardb;
			}
		}
		printf("%d %d\n",pointa,pointb);
	}
	return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int n, k;
long long ans, fac[100005];
vector<int> edge[100005];

long long inv(long long x, int y)
{
    if (y == 0) return 1LL;
    long long tmp = inv(x, y >> 1);
    tmp = tmp * tmp % MOD;
    return (y & 1) ? tmp * x % MOD : tmp;
}

void dfs(int x, int f)
{
    if (k < (int)edge[x].size() + 1) {
        printf("0\n");
        exit(0);
    }
    if (x == 1)
        ans = ans * fac[k - 1] % MOD * inv(fac[k - 1 - edge[x].size()], MOD - 2) % MOD;
    else ans = ans * fac[k - 2] % MOD * inv(fac[k - 2 - edge[x].size() + 1], MOD - 2) % MOD;
    for (int i = 0, i_END_ = edge[x].size(); i < i_END_; ++i) {
        int y = edge[x][i];
        if (y == f) continue;
        dfs(y, x);
    }
    return;
}

int main(void)
{
    scanf("%d%d", &n, &k);
    ans = k;
    fac[0] = 1LL;
    for (int i = 1; i <= 100003; ++i)
        fac[i] = fac[i - 1] * i % MOD;
    for (int i = 1; i < n; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    dfs(1, 0);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 9984
/*input
20
0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0
1 1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1
1 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0
0 1 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0
0 1 1 0 1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 1 1 0 1 1 1 0 1 1 1 0 0 0 1
1 1 1 0 0 1 0 1 0 0 0 1 0 1 0 0 0 1 1 1
0 0 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0
0 0 1 1 1 1 1 1 0 0 1 0 0 1 0 0 1 0 1 1
0 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 0 1 1 1
0 0 0 0 1 1 0 0 0 1 0 1 1 0 1 1 0 0 1 1
0 0 0 1 1 1 1 0 1 1 0 0 0 1 0 0 1 1 1 1
0 1 1 0 1 1 1 0 0 0 0 1 0 1 1 0 0 1 1 1
1 0 0 0 1 0 1 1 0 1 0 1 1 1 1 1 1 1 0 0
0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 0
1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 0
1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 1
0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0
1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 0
0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =6e5+10;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int dp[21][(1<<21)+10];
int val[21][21];
int n;
int recurr(int cur,int temp)
{
	if(cur==n)
		return 1;
	else if(dp[cur][temp]!=-1)
		return dp[cur][temp];
	else
	{
		int tmp=0;
		for(int i=0;i<n;i++)
		{
			if(val[cur][i]==1&&(!((1<<i)&(temp))))
			{
				tmp+=recurr(cur+1,(temp|(1<<i)));
				tmp%=modd;
			}
		}
		dp[cur][temp]=tmp;
		return dp[cur][temp];
	}
}

signed main()
{
	speed
	cin>>n;
	rep(i,n)
	{
		rep(j,n)
		{
			cin>>val[i][j];
		}
	}
	rep(i,21)
	{
		rep(j,(1<<21)+10)
		{
			dp[i][j]=-1;
		}
	}
	int ans=recurr(0,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 344448
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll mod = 998244353;
int n;
string s[66];
int t[66],ans;

int main(){
	cin>>n;
	rep(i,n) cin >> s[i] >> t[i];
	string S; cin >> S;
	int f = 0;
	rep(i,n){
		if(f) ans += t[i];
		else if(s[i] == S) f=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = b-a;
		int longer = 0;

		for(int i=1; i<=x; i++) {
			longer += i;
		}

		System.out.println(longer - b);

	}

}


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

//C++14 (GCC 5.4.1)
int main() {
    int a,b,c,d,e,k;
    cin >>a>>b>>c>>d>>e>>k;
    bool is=(e-a>k);
    //-----------------------------------
    cout << ((is) ? ":(" : "Yay!") <<endl;
    return (0);
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: i32 = input();
    let x: Vec<i32> = (0..n).map(|_| input()).collect();
    let x: Vec<_> = x.iter().map(|x| x - a).collect();

    let mut v = vec![vec![0i64; 5001]; n + 1];
    v[0][2500] = 1;
    for i in 0..n {
        for j in 0..5001 {
            v[i + 1][j] = v[i][j];
            let k = j as i32 - x[i];
            if 0 <= k && k < 5001 {
                v[i + 1][j] += v[i][k as usize];
            }
        }
    }

    println!("{}", v[n][2500] - 1);
}


Measured memory_bytes: 6396
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int N;cin >> N;
    if(N==1){
        cout << "Hello World" << endl;
        return 0;
    }

    if(N==2){
        int A,B; cin >> A >> B;
        cout << A+B << endl;
        return 0;
    }
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 110 };

bitset<MAX> found;
vector<int> adj[MAX];

struct Point { int x, y; };

int aug(int u, vector<int>& match)
{
    if (found[u])
        return 0;

    found[u] = true;
#ifdef DEBUG
cout << "   aug(" << u << ")" << endl;
#endif
    for (auto v : adj[u])
    {
#ifdef DEBUG
cout << "   v = " << v << ", match = " << match[v] << endl;
#endif
        if (match[v] == -1 or aug(match[v], match))
        {
            match[v] = u;

#ifdef DEBUG
cout << "   new match: " << v << " -> " << u << endl;
#endif
            return 1;
        }
    }

#ifdef DEBUG
cout << "   nothing for u = " << u << endl;
#endif
    return 0;
}

int solve(int N, const vector<Point>& xs)
{
    for (int u = 0; u < N; ++u)
        for (int v = N; v < 2*N; ++v)
            if (xs[u].x < xs[v].x and xs[u].y < xs[v].y)
                adj[u].push_back(v);

    vector<int> ms(2*N, -1);
    int ans = 0;

    for (int u = 0; u < N; ++u) 
    {
#ifdef DEBUG
cout << "--- Processando u = " << u << endl;
#endif
        found.reset();
        ans += aug(u, ms);
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<Point> xs(2*N);

    for (int i = 0; i < 2*N; ++i)
        cin >> xs[i].x >> xs[i].y;

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
xyabc=input().split()
x=int(xyabc[0])
y=int(xyabc[1])
a=int(xyabc[2])
b=int(xyabc[3])
c=int(xyabc[4])
list1=input().split()
list2=input().split()
list3=input().split()
d=a-x+b-y
an=[]
bn=[]
cn=[]
for num in list1 :
  an.append(int(num))
for num in list2 :
  bn.append(int(num))
for num in list3 :
  cn.append(int(num))
an.sort(reverse=True)
bn.sort(reverse=True)

an=an[:x]
bn=bn[:y]

for a in an :
  cn.append(a)
for b in bn :
  cn.append(b)
cn.sort(reverse=True)
count=0
for i in range(x+y) :
  count+=cn[i]

print(count)

Measured memory_bytes: 113260
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;

int main() {
	int n;
	ll t;
	ll t1=0,t2;
	cin>>n>>t;
	ll r=0;
	for(int i=0;i<n;++i){
		cin>>t2;
		if(t2-t1>t){
			r+=t;
		}else{
			r+=t2-t1;
		}
		t1=t2;
	}
	r+=t;
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 1 << 18 ; 
const int P = 998244353 ; 
const int I = 499122177 ;
int n, limit, A[N] ; 
int fpow( int x, int k ) {
	int ans = 1, base = x ; 
	while(k) {
		if( k & 1 ) ans = ans * base % P ; 
		base = base * base % P, k >>= 1 ;  
	} return ans ; 
}
void FWT( int *a ) {
	for( re int k = 1; k < limit; k <<= 1 ) 
	for( re int i = 0; i < limit; i += ( k << 1 ) )
	for( re int j = i; j < i + k; ++ j )  {
		int nx = a[j], ny = a[j + k] ;
		a[j] = ( nx + ny ) % P, a[j + k] = ( nx - ny + P ) % P ; 
	}
}
void IFWT( int *a ) {
	for( re int k = 1; k < limit; k <<= 1 ) 
	for( re int i = 0; i < limit; i += ( k << 1 ) )
	for( re int j = i; j < i + k; ++ j )  {
		int nx = a[j], ny = a[j + k] ;
		a[j] = ( nx + ny ) * I % P, a[j + k] = ( nx - ny + P ) * I % P ; 
	}
}
signed main()
{
	n = gi(), limit = ( 1 << n ) ; int S = 0 ;
	rep( i, 1, limit ) A[i - 1] = gi(), S += A[i - 1] ; 
	S = fpow( S, P - 2 ) ;
	rep( i, 1, limit ) A[i - 1] = A[i - 1] * S % P ; 
	FWT( A ), A[0] = 0 ; 
	for( re int i = 1; i < limit; ++ i ) 
		A[i] = ( P - limit ) * fpow( 1 - A[i] + P, P - 2 ) % P,
		A[0] = ( A[0] + P - A[i] ) % P ; 
	IFWT( A ) ;
	rep( i, 1, limit ) printf("%lld\n", A[i - 1] % P ) ;
	return 0 ;
}

Measured memory_bytes: 5632
n = int(input())
s = input()
a = []
for i in range(1, len(s)):
    s1 = list(s[:i])
    s2 = list(s[i:])
    b = []
    for j in s1:
        if j in s2 and j not in b:
            b.append(j)
    a.append(len(b))
print(max(a))

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  
  rep(i, N) {
    int x;
    cin >> x;
    
    int da = x;
    int db = K - x;
    
    sum += min(da, db) * 2;
  }
 
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<ctype.h>
#include<queue>
//#include<bits/stdc++.h>
#include<algorithm>
using namespace std; 
int arr[1000];  
int flash; 
int leftt,rightt;   
void dfs(int n){ 
//	printf("%d %d %d\n",n,leftt,rightt);
//	getchar();
	if(n>10){
		flash=1;
		return;
	}
	if(flash==1||flash==2) return;
	if((arr[n]<leftt)&&(arr[n]<rightt)){
		flash=2;
		return;
	}
	int a,b,c;
	a=leftt;
	b=rightt;
	c=n;
	if(arr[n]>leftt){
		leftt=arr[n];
		dfs(n+1);
		if(flash) return;
		leftt=a;
		rightt=b;
		n=c;
		if(arr[n]>rightt){
			rightt=arr[n];
			dfs(n+1);
			if(flash) return;
			flash=2;
			return;
		}else{
			flash=2;
			return;
		}
	}else if(arr[n]>rightt){
		rightt=arr[n];
		dfs(n+1);
		if(flash) return;
		flash=2;
		return;
	}else{
		flash=2;
		return;
	}
}          
                                                                                                                                                                                                                                                                                                                                             
int main(){
	int t;
	while(scanf("%d",&t)!=EOF){
	while(t--){
	flash=0;
	for(int i=1;i<=10;i++){
	   scanf("%d",&arr[i]);
	}
	leftt=-1;
	rightt=-1;
	dfs(1);
	if(flash==1) printf("YES\n");
	 else printf("NO\n");
	}	
	}
	
    return 0;
}





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

int D;

int main(){
  cin >> D;
  switch (D){
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 25:
      cout << "Christmas" << endl;
      break;
  }
}


Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
    int a[10],i,b=0,c=0;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==5)
            b++;
        if(a[i]==7)
            c++;
    }
    if(b==2&&c==1)
        printf("YES\n");
    else
        printf("NO\n");
return 0;
}

Measured memory_bytes: 128
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>


int main(){
    double pai=3.14159265358;
    int A,B,H,M;
    scanf("%d %d %d %d",&A,&B,&H,&M);
    double Aw,Bw,Ar,Br;
    Aw=(2*pai)/(12*60);
    Bw=(2*pai)/60;
    Ar=Aw*((H*60)+M);
    Br=Bw*M;
    double C;
    C=pow(A,2)+pow(B,2)-2*A*B*cos(Ar-Br);
    C=pow(C,0.5);
    printf("%.9f\n",C);
    return 0;
}

Measured memory_bytes: 2724
from collections import deque
def C():
    N, M = map(int, input().split())
    A = set([int(input()) for _ in range(M)])
    dp = deque([1, 1 if 1 not in A else 0])
    MOD = 1000000007
    for i in range(2,N+1):
        #print(i, dp)
        if i in A:
            dp.append(0)
        else:
            dp.append((dp[0]+dp[1]) % MOD)
        dp.popleft()
    print(dp[-1])

C()

Measured memory_bytes: 19132
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int main()
{
     cin>>n>>k;
     ans=1;
     for(int i=0;i<n;i++)
    {
        if(ans>k)
            ans+=k;
        else 
        	ans*=2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

ll getsn(ll n) {
  ll sn = 0;
  while (n > 0) {
    sn += n % 10;
    n /= 10;
  }
  return sn;
}

int main() {
  ll k;
  cin >> k;
  
  ll ans = 1;
  for (ll i = 0, d = 1; i < k; i++) {
    cout << ans << endl;

    while ((ans + d - 1) / getsn(ans + d) >= d) {
      d *= 10;
    }
    ans += d;
  }


  
  return 0;
}

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


int N;
int main() {
    cin >> N;
    vector<int> v;
    for (int i =0 ;i < 2 * N; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i =0 ;i < N; i++) {
        ans += v[2 * i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int n;
	long long d[200000];
	int m;
	long long t[200000];

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld", &d[i]);
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		scanf("%lld", &t[i]);
	}

	sort(d,d+n);
	sort(t,t+m);
	//printf("%lld\n",d[0]);

	int j=0;
	for(int i=0;i<m;i++){

		bool found = false;
		while(!found){
			if(t[i] == d[j]){
				found = true;
				j++;
				break;
			}
			j++;
			if(j==n){
				printf("NO\n");
				return 0;
			}
		}

	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define k 10000
int n, C[k];

int main(){
	scanf("%d", &n);
	int *A = (int *)malloc(sizeof(int)*n);
	int *B = (int *)malloc(sizeof(int)*n);
	
	for(int i = 0;i < n;i++)scanf("%d", &A[i]);
	
	for(int i = 0;i < k;i++)C[i] = 0;
	for(int i = 0;i < n;i++)C[A[i]]++;
	for(int i = 1;i < k;i++)C[i] += C[i - 1];
	for(int i = n - 1;i >= 0;i--){
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
	
	for(int i = 0;i < n - 1;i++)printf("%d ", B[i]);
	printf("%d\n", B[n - 1]);
	return 0;
}

Measured memory_bytes: 18372
use proconio::*;
use proconio::marker::Chars;
use std::cmp::min;

#[fastout]
fn run() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! {
            n: usize,
            mut a: [usize; n],
            s: Chars,
        }
        let mut ans = 0;
        for (i, c) in s.into_iter().enumerate().rev() {
            let v = a[i];
            if v == 0 {
                continue;
            }
            if c == '1' {
                ans = 1;
            } else {
                for a in a.iter_mut() {
                    *a = min(*a, *a ^ v);
                }
            }
        }
        println!("{}", ans);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

vector <pair <int, int> > adj[100001];
int dist[100001];
bool seen[100001] = {};

vector<int> front;
vector<int> back;

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

	int n, u, v, w;
	cin >> n;

	for (int i = 1; i < n; i++){
		cin >> u >> v >> w;
		w &= 1;
		adj[u].emplace_back(v, w);
		adj[v].emplace_back(u, w);
	}

	seen[1] = 1;
	dist[1] = 0;
	back.push_back(1);
	while (!back.empty()){
		for (int i = 0; i < back.size(); i++){
			u = back[i];
			for (int j = 0; j < adj[u].size(); j++){
				v = adj[u][j].first;
				w = adj[u][j].second;
				if (!seen[v]){
					seen[v] = 1;
					dist[v] = dist[u] ^ w;
					front.push_back(v);
				}
			}
		}
		back.clear();
		front.swap(back);
	}

	for (int i = 1; i <= n; i++) cout << dist[i] << '\n';

	
}

Measured memory_bytes: 10032
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  string str;
  map<string, int> dic;

  for (int i = 0; i < N; ++i) {
    cin >> str;
    sort(str.begin(), str.end());
    auto itr = dic.find(str);
    if (itr != dic.end()) {
      // 新規
      dic[str] += 1;
    } else {
      // アナグラムあり
      dic[str] = 1;
    }
  }
  long long ans = 0;
  for (auto itr = dic.begin(); itr != dic.end(); ++itr) {
    long long num = itr->second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S;
  cin >> S ;
  
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  if (S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  if(S == "Rainy") {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
S = input()
l = len(S)
S_list = []
flag = False
for i in S:
    S_list.append(i)

for i in range(l):
    if i % 2 == 0 and S_list[i] == 'L':
        flag = True
    elif i % 2 == 1 and S_list[i] == "R":
        flag = True
    else:pass


if flag:
    print("No")

else:
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    int h,m,s;
    cin >> s;
    h = s / 3600; s %= 3600;
    m = s / 60;   s %= 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
    
    
}


Measured memory_bytes: 3108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
typedef long long LL;
LL a[MaxN + 5], Min = 1e9, ans;
int n;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	int x;
	if(n % 2 == 0) x = a[n] / 2;
	if(n % 2 == 1) x = (a[n] + 1) / 2;
	for(int i = 1; i <= n - 1; i++)
	{
		if(a[i] < x)
		{
			if(x - a[i] < Min)
			{
				Min = x - a[i];
				ans = a[i];
			}
		}
		else 
		{
			if(a[i] - x < Min)
			{
				Min = a[i] - x;
				ans = a[i];
			}
		}
	}
	printf("%lld %lld\n", a[n], ans);
	return 0;
}

Measured memory_bytes: 1024
X = int(input())
dp = [0 for _ in range(X + 110)]
dp[0] = 1
for i in range(X + 1):
    if dp[i] == 0:
        continue
    dp[i + 100] = 1
    dp[i + 101] = 1
    dp[i + 102] = 1
    dp[i + 103] = 1
    dp[i + 104] = 1
    dp[i + 105] = 1
print(dp[X])

Measured memory_bytes: 9756
#include <stdio.h>
#include <vector>
#include <map>

class Union_Find
{
	std::vector<int>per;
	std::vector<int>rank;
public:
	void init(int size)
	{
		for (int i = 0; i < size; ++i)
		{
			per.push_back(i);
			rank.push_back(0);
		}
	}
	int get_per(int x)
	{
		if (x == per[x]) { return x; }
		return per[x] = get_per(per[x]);
	}
	bool is_same_per(int x, int y)
	{
		return (get_per(x) == get_per(y) ? true : false);
	}
	void togett(int x, int y)
	{
		int x_per = get_per(x), y_per = get_per(y);
		if (x_per == y_per) { return; }
		if (rank[x_per] < rank[y_per])
		{
			per[x_per] = y_per;
		}
		else
		{
			per[y_per] = x_per;
			if (rank[x_per] == rank[y_per]) { ++rank[x_per]; }
		}
	}
};

int N, K, L;
Union_Find road, railway;
std::map<std::pair<int, int>, int>ans;

int main()
{
	scanf("%d%d%d", &N, &K, &L);
	road.init(N), railway.init(N);
	for (int i = 0; i < K; ++i)
	{
		int p, q;
		scanf("%d%d", &p, &q);
		road.togett(p - 1, q - 1);
	}
	for (int i = 0; i < L; ++i)
	{
		int r, s;
		scanf("%d%d", &r, &s);
		railway.togett(r - 1, s - 1);
	}

	for (int i = 0; i < N; ++i)
	{
		std::pair<int, int>temp = std::make_pair(road.get_per(i), railway.get_per(i));
		++ans[temp];
	}

	for (int i = 0; i < N; ++i)
	{
		std::pair<int, int>temp = std::make_pair(road.get_per(i), railway.get_per(i));
		printf("%d", ans[temp]);
		if (i < N - 1)
		{
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long longan

int n, k;

signed main()
{
    cin >> n >> k;

    int ans = n % k;
    ans = min(ans, abs(ans - k));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b) {
    return *(int*)a-*(int*)b;
}
int main() {
    int n;
    int a[3000];
    while(scanf("%d",&n)!=EOF) {
        int t;
        for(t=0; t<n; t++) {
            scanf("%d",&a[t]);
        }
        qsort(a,n,sizeof(a[0]),cmp);
        int flag=0;
        int gray=0;
        int brown=0;
        int grenn=0;
        int cyan=0;
        int blue=0;
        int yellow=0;
        int orange=0;
        int red=0;
        for(t=0; t<n; t++) {
                if(a[t]>=1 && a[t]<=399)
                    gray++;
                 else if(a[t]>=400 && a[t]<=799)
                    brown++;
               else  if(a[t]>=800 && a[t]<=1199)
                    grenn++;
               else if(a[t]>=1200 && a[t]<=1599)
                    cyan++;
                else if(a[t]>=1600 && a[t]<=1999)
                    blue++;
               else  if(a[t]>=2000 && a[t]<=2399)
                    yellow++;
               else if(a[t]>=2400 && a[t]<=2799)
                    orange++;
               else if(a[t]>=2800 && a[t]<=3199)
                    red++;
                   else if(a[t]>=3200)
                        flag++;
            }
        int sum=0;
        if(gray>0)
            sum++;
        if(brown>0)
            sum++;
        if(grenn>0)
            sum++;
        if(cyan>0)
            sum++;
        if(blue>0)
            sum++;
        if(yellow>0)
            sum++;
        if(orange>0)
            sum++;
        if(red>0)
            sum++;
        if(sum!=0)
           printf("%d ",sum);
           else
            printf("1 ");
        if(flag>0)
            {
                sum=sum+flag;
        }

        printf("%d\n",sum);
        for(t=0; t<n; t++) {
            a[t]=0;
        }
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()

res = 0
phase = 0
for c in s:
    if c == "A":
        phase = 1
    elif c == "B" and phase == 1:
        phase = 2
    elif c == "C" and phase == 2:
        phase = 0
        res += 1
    else:
        phase = 0

print(res)

Measured memory_bytes: 3060