akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<iomanip>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
#define all(in) in.begin(),in.end()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const double EPS=1e-5;
const int inf=1e10;

signed main(){
	int n;
	while(cin>>n,n){
		int d;
		cin>>d;
		vs in(n);
		rep(i,n)cin>>in[i];
		sort(all(in));
		int co=0;
		rep(x,n)loop(y,x+1,n){
			int n1=in[x].size();
			int n2=in[y].size();
			vvi dp(n1+1,vi(n2+1,inf));
			dp[0][0]=0;
			rep(i,n1+1)rep(j,n2+1){
				if(i&&j){
					rep(l,i-1)rep(w,j-1)if(in[x][i-1]==in[y][w]&&in[x][l]==in[y][j-1]){
						dp[i][j]=min(dp[i][j],dp[l][w]+i-l-2+j-w-2+1);
					}
				}
				if(i<n1&&j<n2)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+(in[x][i]!=in[y][j]));
				if(i<n1&&j<n2)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+1);
				if(i<n1)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
				if(j<n2)dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
			}
			// rep(i,n1+1){rep(j,n2+1)cout<<" "<<dp[i][j];cout<<endl;}
			if(dp[n1][n2]<=d){
				co++;
				cout<<in[x]<<","<<in[y]<<endl;
			}
		}
		cout<<co<<endl;
	}
}


Measured memory_bytes: 3088
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    M,D = map(int, input().split())
    days = set()
    for d in range(D+1):
        d_1 = d % 10
        d_10 = d // 10
        if d_1 < 2 or d_10 < 2:
            continue
        m = d_1*d_10
        day = (m,d)
        if (day not in days) and (m <= M):
            days.add(day)
    print(len(days))

if __name__ == '__main__':
    main()


Measured memory_bytes: 66028
// Problem : D - Friend Suggestions
// Contest : AtCoder - AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

struct dsu{
    int p[N], size[N], c;  //use 1-indexing and define dsu globally
    dsu(){
        for(int i=0;i<N;i++) size[i] = 1;
        c = 1;
    }
    int find(int u){
        if(!p[u]) return u;
        return p[u] = find(p[u]);
    }
    void merge(int u, int v){
        u = find(u);
        v = find(v);
        if(u != v){
            if(size[u] < size[v]) swap(u,v);
            p[v] = u;
            size[u] += size[v];
            c++;
        }
    }
} d;

int n,m,k,deg[N];
vi bad[N];

void solve(){
    cin>>n>>m>>k;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        deg[u]++, deg[v]++;
        d.merge(u,v);
    }
    for(int i=0;i<k;i++){
        int u,v;
        cin>>u>>v;
        bad[u].pb(v);
        bad[v].pb(u);
    }
    for(int i=1;i<=n;i++){
        int root = d.find(i);
        int cur = d.size[root]-deg[i]-1;
        for(int j : bad[i]){
            if(d.find(j) == root) cur--;
        }
        cout<<cur<<' ';
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

int main() {
    ios_base::sync_with_stdio( false );
    cin.tie( nullptr );
    int n, m;
    cin >> n >> m;
    ll sum = 0;
    for ( int i = 0; i < m; ++i ) {
        int x;
        cin >> x;
        sum += x;
    }
    cout << max( -1LL, n - sum) << '\n';
    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


ll solve(ll h)
{
	if(h==1) return 1LL;
	return 1+solve(h/2)*2;
}

int main(void)
{
	ll h;
	while(scanf("%lld", &h)==1)
	{
		ll ans=solve(h);
		printf("%lld\n", ans);
	}
	return 0;
}


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

int main(){
    int a,b,c;
    cin >> a  >> b >> c;
    if(a == b && b != c) cout << 2 << endl;
    else if(a != b && b == c) cout << 2 << endl;
    else if(a == c && a != b) cout << 2 << endl;
    else if(a == b && b == c) cout << 1 << endl;
    else if(a != b &&  b != c) cout << 3 << endl;
}

Measured memory_bytes: 256
N = int(input())
X = [int(x) for x in input().split()]

Xmax = max(X)
Xmin = min(X)

Pmin = 1000000
for i in range(Xmin, Xmax + 1):
    p = 0
    for x in X:
        p += (x - i) ** 2
        
    Pmin = min(Pmin, p)

print(Pmin)

Measured memory_bytes: 9144
let cnt = ref 0

let merge a l m r =
  let init_ary n p = Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i)) in
  let ai = init_ary (m - l) l in
  let aj = init_ary (r - m) m in
  let rec doit = function
    | (_, _, k) when k = r -> ()
    | (i, j, k) ->
      incr cnt;
      if ai.(i) <= aj.(j) then begin
        a.(k) <- ai.(i);
        doit (i + 1, j, k + 1)
      end else begin
        a.(k) <- aj.(j);
        doit (i, j + 1, k + 1)
      end in
  doit (0, 0, l)

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  print_int a.(0);
  for i = 1 to n - 1 do
    Printf.printf " %d" a.(i);
  done;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 19580
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

def popcount(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n //= 2
    return cnt
def f(n):
    cnt = 0
    while n != 0:
        n = n % popcount(n)
        cnt += 1
    return cnt

N = int(input())
X = input()
ones = X.count('1')
MOD1 = ones + 1
MOD2 = ones - 1
pow1 = [1] * (len(X) + 1)
pow2 = [1] * (len(X) + 1)
if MOD2 != 0:
    for i in range(1, len(X) + 1):
        pow1[i] = (pow1[i - 1] * 2) % MOD1
        pow2[i] = (pow2[i - 1] * 2) % MOD2
else:
    for i in range(1, len(X) + 1):
        pow1[i] = (pow1[i - 1] * 2) % MOD1

X1, X2 = 0, 0
for i in range(N):
    if X[i] == '1':
        X1 += pow1[N - i - 1]
        X2 += pow2[N - i - 1]
X1 %= MOD1
if MOD2 != 0:
    X2 %= MOD2

for i in range(N):
    d = N - i - 1
    if X[i] == '0':
        x = (X1 + pow1[d]) % MOD1
        print(f(x) + 1)
    else:
        if MOD2 != 0:
            x = (X2 - pow2[d]) % MOD2
            print(f(x) + 1)
        else:
            print(0)

Measured memory_bytes: 25380
package main

import (
	"fmt"
)

func Calculator(a, b int, op string) int {
	switch op {
	case "+":
		return a + b
	case "-":
		return a - b
	case "*":
		return a * b
	case "/":
		return a / b
	default:
		return 0 
	}
}

func main(){
	var a,b int
	var op string
		for {
			fmt.Scan(&a)
			fmt.Scan(&op)
			fmt.Scan(&b)
				if op == "?" {
					break
				}
			fmt.Println(Calculator(a, b, op))
		}

}


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

int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  
  int res = 0;
  
  for(int i= 0; i <= a; i++){
    for(int j= 0; j <= b; j++){
      for(int k= 0; k <= c; k++){
        int sum = 500 * i + 100 * j + 50 * k;
        if( sum == x ){
          res ++;
          }
        }
       }
      }
   cout << res << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; char op;
    cin>>a>>op>>b;
    if(op=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int l,r;
		int[] sum = new int[N];
		for (int i=1;i<N;i++) {
			if (S.charAt(i-1) == 'A' && S.charAt(i) == 'C') {
				sum[i] = sum[i-1] +1;
			} else {
				sum[i] = sum[i-1];
			}
		}
		for (int i=0;i<Q;i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			System.out.println(sum[r-1]-sum[l-1]);
		}

	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 49888
#include<bits/stdc++.h>
using namespace std;
const int N=5e6+5;
int n,k,tot,head[55],nex[N],to[N],fi[N],se[N];
void add(int u,int x,int y)
{
    ++tot;nex[tot]=head[u];head[u]=tot;fi[tot]=x;se[tot]=y;
}
int upbit(int x)
{
    for(int i=30;i>=0;i--)
        if(x>>i&1) return i;
    return -1;
}
long long sum[55];
int main()
{
    //freopen("01.txt","r",stdin);
    scanf("%d%d",&n,&k);
    long long ans=0,res=0;
    int u=upbit(k);
    for(int i=1;i<=n;i++)
    {
        int a,b;scanf("%d%d",&a,&b);
        int k=upbit(a);
        if(k==-1||(a&k)==a) res+=b;
        else add(k,a,b),sum[k]+=b;
    }
    for(int i=u;i>=0;i--)
    {
        if(k>>i&1)
        {
            long long s=0;
            for(int j=i-1;j>=0;j--)
                s+=sum[j];
            ans=max(ans,res+s);
            for(int j=head[i];j;j=nex[j])
            {
                int f=fi[j],s=se[j];
                f^=1<<i;
                int k=upbit(f);
                if(k==-1) res+=s;
                else add(k,f,s),sum[k]+=s;
            }
        }
    }
    ans=max(ans,res);
    printf("%lld\n",ans);
}


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

using namespace std;

#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 All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n;
   cin >> n;
   ll ans = 1;
   for(int i=1;i<=n;i++){
      ans *= i;
      ans %= (ll)(1e9+7);
   }
   cout << ans << endl;
   return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ull ans = 0;
ll sum = 0;
ll cnt = 0;
ull cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

int main() {
    cin >> n >> x;
    vl a(n);

    NREP() {
        cin >> a[i];
    }

    REP(i, 0, n - 1) {
        ans += max(a[i + 1] + a[i] - x, 0ll);
        a[i + 1] = min(a[i + 1], max(x - a[i], 0ll));
    }
    MSG(ans)
}


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

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,K,count=0;
  scanf("%d %d",&N,&K);
  int num[N];
  for(int i=0;i<N;i++) scanf("%d ",&num[i]);
  count =  (N-K)/(K - 1) + 1;
  if((N - K)%(K - 1) != 0)count ++;
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();
		int x=sc.nextInt();

		int[] cnds=new int[N];
		for(int i=0; i<N; i++) {
			cnds[i]=sc.nextInt();
		}

		Arrays.sort(cnds);
		int ninme=0;

		for(int i=0; i<N; i++) {
			if(x-cnds[i]>=0) {
				x-=cnds[i];
				ninme++;
				if(x==0) {
					System.out.println(ninme);
					System.exit(0);
				}
			}
			else if(x-cnds[i]<0) {
				if(ninme<N) {
					System.out.println(ninme);
					System.exit(0);
				}
				else {
					System.out.println(ninme-1);
					System.exit(0);
				}
			}
		}
		if(x>0) {
			System.out.println(ninme-1);
		}
	}
}




Measured memory_bytes: 21844
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] A = new int[100010];

    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      A[a]++;
    }

    sc.close();

    int mod = 1000000007;
  

    if (N % 2 != 0) {

      if (A[0] != 1) {
        System.out.println(0);
        return;
      }

      for (int i = 1; i < A.length; i++) {
        if (i % 2 == 0) {
          if (A[i] != 2 && A[i] != 0) {
            System.out.println(0);
            return;
          }
        } else {
          if (A[i] != 0){
            System.out.println(0);
            return;
          }
        }
      }

    } else {

      if (A[0] != 0) {
        System.out.println(0);
        return;
      }

      for (int i = 1; i < A.length; i++) {
        if (i % 2 != 0) {
          if (A[i] != 2 && A[i] != 0) {
            System.out.println(0);
            return;
          }
        } else {
          if (A[i] != 0) {
            System.out.println(0);
            return;
          }
        }
      }

    }

    long l = (long) N / 2;

    long result = 1;

    while (l > 0) {
      result = result * 2 % mod;
      l--;
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 49228
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)r=(r*a)%m;
		b = b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
    ll n; cin>>n;
    bool flag = false;
    while(n>0)
    {
        ll x = n%10;
        if(x==7)flag = true;
        n/=10;
    }
    if(flag)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}
/*
1
4
4 2
10 3
3 4
9 2
*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
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(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}

ll f(ll n){
    ll k=n+1;
    if(k%4 == 0) return 0;
    else if(k%4 == 1) return n;
    else if(k%4 == 2) return 1;
    else            return n+1;
}

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

    // solution comes here

    ll A, B;
    cin >> A >> B;

    if(A) cout << (f(A-1) ^ f(B)) << nl;
    else  cout << f(B) << nl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main{    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Player[][] r = new Player[3][8];
        for(int i=0;i<3;i++){
            for(int j=0;j<8;j++){r[i][j]=new Player(sc.nextInt(),sc.nextDouble());}
        }
        for(int i=0;i<3;i++){
        Arrays.sort(r[i]);
        }
        Player[] winner = new Player[6];
        int x = 0;
        for(int i=0;i<3;i++){
            System.out.printf("%d %.2f\n", r[i][0].id, r[i][0].time);
            System.out.printf("%d %.2f\n", r[i][1].id, r[i][1].time);
            winner[x++] = r[i][2];
            winner[x++] = r[i][3];
        }
        Arrays.sort(winner);
        System.out.printf("%d %.2f\n", winner[0].id, winner[0].time);
        System.out.printf("%d %.2f\n", winner[1].id, winner[1].time);
    }
    static class Player implements Comparable<Player>{
        int id;
        double time;
        public Player(int id, double time) {
            this.id = id;
            this.time = time;
        }
        public int compareTo(Player o) {
            return time-o.time<0?-1:o.time-time<0?1:0;
        }
    }
 
}	

Measured memory_bytes: 28188
N,M = map(int,input().split())
H = list(map(int,input().split()))
Bad = dict()

for i in range(M):
  A,B = map(int,input().split())
  A -= 1
  B -= 1
  if H[A] > H[B]:
    Bad[B] = 1
  elif H[A] < H[B]:
    Bad[A] = 1
  else:
    Bad[A] = 1
    Bad[B] = 1
print(N-len(Bad))

Measured memory_bytes: 20116
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define M 100001
int n,k,ans=1;
vector<int>edge[M];
void dfs(int x,int f,int p){
	ans=1ll*ans*p%mod;
	int w=0;
	if(!f)w=1;
	else w=2;
	for(int i=0;i<edge[x].size();i++){
		int y=edge[x][i];
		if(y==f)continue;
		if(w>k){
			ans=0;
			return;
		}
		dfs(y,x,k-w);
		w++;
	}
}
int main(){
	cin>>n>>k;
	for(int i=1,u,v;i<n;i++){
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	dfs(1,0,k);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
int main()
{
	int n,m,i,tmp=0,min=0x7fffffff,a[10000];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		tmp+=a[i];
		if(a[i]<min)
		{
			min=a[i];
		}
	}
	if(m<tmp)
	{
		printf("0");
	}
	else
	{
		m-=tmp;
		printf("%d",n+m/min);
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略

int main(){
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC";
  }else{
  	cout << "ABC";
  }
  
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;


int main(){
    int m;cin>>m;
    printf("%d",48-m);
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	int c = b - a;
	int ans = (c + 1)*c / 2 - b;
	printf("%d\n", ans);


	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);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) {
                return;
            }
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    if(i == 0 || i == H -1 || j == 0 || j == W -1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

int countTurnedOnLight(vector<bool> switchStateVec, vector<vector<int>> lightSwitchVec, vector<int> lightTurnOnRuleVec)
{
    int turnedOnLightNum = 0;

    int lightIndex = 0;
    for (const auto singleLightSwitchVec : lightSwitchVec)
    {
        int turnOnSwitchNum = 0;

        for (const auto singleLightSwitch : singleLightSwitchVec)
        {
            if (switchStateVec.at(singleLightSwitch))
            {
                ++turnOnSwitchNum;
            }
        }

        if ((turnOnSwitchNum % 2) == lightTurnOnRuleVec.at(lightIndex))
        {
            ++turnedOnLightNum;
        }

        ++lightIndex;
    }

    return turnedOnLightNum;
}

int countSwitchPattern(vector<vector<int>> lightSwitchVec, vector<bool> switchStateVec, int switchNum, int lightNum, vector<int> lightTurnOnRuleVec)
{
    if (switchStateVec.size() == switchNum)
    {
        int turnedOnLightNum = countTurnedOnLight(switchStateVec, lightSwitchVec, lightTurnOnRuleVec);

        return (turnedOnLightNum == lightNum ? 1 : 0);
    }
    else
    {
        int switchPatternCount = 0;

        vector<bool> newSwitchStateVecTrue(switchStateVec.size()), newSwitchStateVecFalse(switchStateVec.size());

        copy(switchStateVec.begin(), switchStateVec.end(), newSwitchStateVecTrue.begin());
        newSwitchStateVecTrue.push_back(true);
        switchPatternCount += countSwitchPattern(lightSwitchVec, newSwitchStateVecTrue, switchNum, lightNum, lightTurnOnRuleVec);

        copy(switchStateVec.begin(), switchStateVec.end(), newSwitchStateVecFalse.begin());
        newSwitchStateVecFalse.push_back(false);
        switchPatternCount += countSwitchPattern(lightSwitchVec, newSwitchStateVecFalse, switchNum, lightNum, lightTurnOnRuleVec);

        return switchPatternCount;
    }
}

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

    vector<vector<int>> lightSwitchVec;
    for (int i = 0; i < m; ++i)
    {
        int k;
        cin >> k;

        vector<int> singleLightSwitchVec;
        for (int j = 0; j < k; ++j)
        {
            int input;
            cin >> input;
            singleLightSwitchVec.push_back(input - 1);
        }

        lightSwitchVec.push_back(singleLightSwitchVec);
    }

    vector<int> lightTurnOnRuleVec;
    for (int i = 0; i < m; ++i)
    {
        int input;
        cin >> input;

        lightTurnOnRuleVec.push_back(input);
    }

    cout << countSwitchPattern(lightSwitchVec, {}, n, m, lightTurnOnRuleVec) << endl;
}

Measured memory_bytes: 256
import math
data = input()
target = int(data)

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

list = primes(2000000)
result =[]
for i in list:
    check = target
    k = 0
    while True:
        if check % i != 0:
            break
        else:
            check = check/i
            k +=1
    result.append(k)

ans = 0
for j in result:
    y = 0
    z = j
    while z > y:
        y += 1
        z -= y
        ans += 1


cover = 1
for i in range(len(list)):
    cover = cover*(list[i]**result[i])
if target/cover >2000000:
    ans +=1
print(ans)

Measured memory_bytes: 30876
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;

void file() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    if (freopen("input.txt", "r", stdin));
    if (freopen("output.txt", "w", stdout));
#endif
}


int main()
{
    file();

    int n;
    cin >> n;
    map < int, int > mp;
    for (int i = 1; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }
    for (int i = 1; i <= n; i++)
        cout << mp[i] << endl;


}


Measured memory_bytes: 13040
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    lint H, W;
    cin >> H >> W;
    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    if(H % 2 && W % 2){
        cout << H * W / 2 + 1 << endl;
    }else{
        cout << H * W / 2 << endl;
    }
}


Measured memory_bytes: 256
#import math
#import itertools
#import numpy as np
#from collections import deque
# sys.setrecursionlimit(10 ** 6)
#MOD = 10 ** 9 + 7
#INF = 10 ** 9
#PI = 3.14159265358979323846

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    A=LIST()
    A=sorted(A)
    print(A[n//2]-A[n//2-1])
if __name__=='__main__':
    do()

Measured memory_bytes: 20752
#include<bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 50000001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;
ll l;

int gcd(int a, int b) {
	return (b > 0) ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

ll abc150func(ll l, ll M) {
	ll i = 1;
	ll res = 0;
	while (true) {
		if (l*i > M) return res;
		else {
			res++;
			i += 2;
		}
	}
}

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N);
	ll temp = 0;
	rep(i, N) {
		cin >> a[i];
		a[i] /= 2;
	}

	l = a[0];
	rep(i, N) l = lcm(l, a[i]);

	rep(i, N) {
		if (l / a[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	// cout << abc150func(l, M) << endl;
	cout << M / l - M / (l << 1);
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int H, W, h, w, ans;

int main() {
    scanf("%d %d", &H, &W);
    scanf("%d %d", &h, &w);
    
    ans = H * W - h * W - w * H + h * w;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let t: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let a: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hv = vec![0i32; n];
    for i in 0..(n - 1) {
        hv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    hv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut min_b = 100000000;
    let mut ans = 0;
    for i in 0..n {
        let h = hv[i];
        let b = (a * 1000 - (t * 1000 - h * 6)).abs();
        if b < min_b {
            min_b = b;
            ans = i + 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int f[1<<3];
int val(char c){
	if(c == 'R') return 0;
	if(c == 'G') return 1;
	return 2;
}
int main(){
	int ans = 1;
	int n; cin >> n;
	string s; cin >> s;
	for(int i = 0; i < 3 * n; i++){
		int now = val(s[i]);
		for(int j = 6; j >= 0; j--){
			if(j == 0) {
				f[1<<now]++;
			}
			else if((j>>now)&1);
			else if(f[j]){
				ans = 1ll * ans * f[j] % mod;
				f[j|(1<<now)]++;
				f[j]--;
				break;
			}
		}
	}
	for(int i = 1; i <= n; i++)
		ans = 1ll * ans * i % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<cstdlib>
#include<cctype>
#include<cmath>
#define ll  long long
#define inf 99999999
using namespace std;


int main()
{
    int n;
    cin>>n;
    int sum=0;
    int temp=n;
    while(temp>0){
        sum+=(temp%10);
        temp=temp/10;
    }
    if(n%sum==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    S = readline().strip()
    ACGT = {'A', 'C', 'G', 'T'}

    ans = 0
    for left in range(len(S)):
        for right in range(1, len(S) + 1):
            if all(c in ACGT for c in S[left:right]) and ans < right - left:
                ans = right - left

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MOD = 1e9 + 7, MAX_N = 1e3 + 10;

int N, A, B, C, D;
int Dy[MAX_N][MAX_N], F[MAX_N], Fi[MAX_N];

void add(int &a, int b) {if((a+=b) >= MOD) a-=MOD;}
void mul(int &a, int b) {a = 1ll * a * b % MOD;}
int atob(int a, int b) {
	int res = 1, p = a;
	while(b) {
		if(b%2) mul(res, p);
		mul(p, p);
		b /= 2;
	}
	return res;
}
int inv(int a) {return atob(a, MOD-2);}

int main() {
	cin >> N >> A >> B >> C >> D;
	F[0] = 1; for(int i=1; i<=N; i++) F[i] = F[i-1], mul(F[i], i);
	for(int i=0; i<=N; i++) Fi[i] = inv(F[i]);

	Dy[A-1][0] = 1;
	for(int a=A; a<=B; a++) {
		for(int n=0; n<=N; n++) {
			add(Dy[a][n], Dy[a-1][n]);
			for(int k=C; k<=D && n-a*k>=0; k++) {
				int val = Dy[a-1][n-a*k];
				mul(val, Fi[k]);
				mul(val, atob(Fi[a], k));
				mul(val, F[n]);
				mul(val, Fi[n-a*k]);
				add(Dy[a][n], val);
			}
		}
	}
	printf("%d\n", Dy[B][N]);
	return 0;
}


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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) cin<<(x);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	int p[n+1];
	FI(n) cin>>p[i];
	int ans=0;
	FI(n-1) {
		if(p[i]!=i) continue;
		if(p[i+1]==i+1) {
			ans++;
			p[i+1] = p[i];
		}
		else ans++;
	}
	if(p[n]==n) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<functional> 
#include<algorithm>
#include<numeric>

using namespace std;

int main(){

	long long h;
	long long n;
	
	cin >> h >> n;

	long long A[n];

	for (long long i = 0; i < n; ++i)
		cin >> A[i];

	long long sum = 0;

	sum = accumulate(A, A+n, sum, plus<long long>());

	if(sum >= h)
		cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}

}



Measured memory_bytes: 1024
from sys import stdin

def main():

    input = stdin.readline

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

    a = 0
    for i in A:
        a = a ^ i

    ans_list = []
    for i in A:
        ans_list.append(a ^ i)

    print(*ans_list)


if __name__ == "__main__":
    main()

Measured memory_bytes: 114896
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#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 RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int MAX_N = 100000;
    int N;
    int A[MAX_N];
    cin >> N;
    REP(i, N) cin >> A[i];
    ll ret = 0;
    REP(i, N - 1) {
        ret += A[i] / 2;
        A[i] %= 2;
        if (A[i] == 1 && A[i + 1] > 0) {
            ret++;
            A[i] = 0;
            A[i + 1]--;
        }
    }
    ret += A[N - 1] / 2;
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 640
import std.stdio;
import std.algorithm;
import std.string;
import std.range;

string[dchar] code1;
dchar[string] code2;

void main() {
	code1[' '] = "101";
	code1['\''] = "000000";
	code1[','] = "000011";
	code1['-'] = "10010001";
	code1['.'] = "010001";
	code1['?'] = "000001";
	code1['A'] = "100101";
	code1['B'] = "10011010";
	code1['C'] = "0101";
	code1['D'] = "0001";
	code1['E'] = "110";
	code1['F'] = "01001";
	code1['G'] = "10011011";
	code1['H'] = "010000";
	code1['I'] = "0111";
	code1['J'] = "10011000";
	code1['K'] = "0110";
	code1['L'] = "00100";
	code1['M'] = "10011001";
	code1['N'] = "10011110";
	code1['O'] = "00101";
	code1['P'] = "111";
	code1['Q'] = "10011111";
	code1['R'] = "1000";
	code1['S'] = "00110";
	code1['T'] = "00111";
	code1['U'] = "10011100";
	code1['V'] = "10011101";
	code1['W'] = "000010";
	code1['X'] = "10010010";
	code1['Y'] = "10010011";
	code1['Z'] = "10010000";

	code2["00000"] = 'A';
	code2["00001"] = 'B';
	code2["00010"] = 'C';
	code2["00011"] = 'D';
	code2["00100"] = 'E';
	code2["00101"] = 'F';
	code2["00110"] = 'G';
	code2["00111"] = 'H';
	code2["01000"] = 'I';
	code2["01001"] = 'J';
	code2["01010"] = 'K';
	code2["01011"] = 'L';
	code2["01100"] = 'M';
	code2["01101"] = 'N';
	code2["01110"] = 'O';
	code2["01111"] = 'P';
	code2["10000"] = 'Q';
	code2["10001"] = 'R';
	code2["10010"] = 'S';
	code2["10011"] = 'T';
	code2["10100"] = 'U';
	code2["10101"] = 'V';
	code2["10110"] = 'W';
	code2["10111"] = 'X';
	code2["11000"] = 'Y';
	code2["11001"] = 'Z';
	code2["11010"] = ' ';
	code2["11011"] = '.';
	code2["11100"] = ',';
	code2["11101"] = '-';
	code2["11110"] = '\'';
	code2["11111"] = '?';
	while(!stdin.eof()) {
		auto s1 = readln().chomp();
		if(!s1.empty()) {
			auto s2 = map!(a => code1[a])(s1).join("");
			while(!s2.empty()) {
				while(s2.length < 5)
					s2 = s2 ~ '0';
				write(code2[s2[0..5]]);
				s2 = s2.drop(5);
			}
			writeln();
		}
	}
}

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

int main() {
  int n;cin>>n;
  vector<vector<int>> vec(n,vector<int>(n,-1));
  rep(i,n){
    int a;cin>>a;
    rep(j,a){
      int x,y;cin>>x>>y;
      x--;
      vec[i][x]=y;
    }
  }
  int ans=0;
  rep(bit,1<<n){
    vector<int> d(n);
    rep(j,n)if(bit&(1<<j))d[j]=1;
    bool ok=true;
    rep(j,n)if(d[j]){
      rep(k,n){
        if(vec[j][k]==-1)continue;
        if(vec[j][k]!=d[k])ok=false;
      }
    }
    if(ok)ans=max(ans,__builtin_popcount(bit));
  }
  cout<<ans<<endl;
}

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

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

using namespace std;

long double ent(vector<int> v) {
  vector<int> cnt(256);
  for(int i:v) ++cnt[i];
  sort(begin(cnt),end(cnt));
  long double n=v.size();
  long double h=0.0;
  for(int m:cnt) {
    if (m==0)continue;
    h -= m/n*logl(m/n);
  }
  return h;
}

vector<int> getv(int s,int a, int c, vector<int>& sub) {
  int n=sub.size();
  vector<int> v(n);
  int r=s;
  r=a*r+c;
  r%=256;
  REP(i,n) {
    v[i] = r+sub[i];
    v[i] %= 256;
    r=a*r+c;
    r%=256;
  }
  return v;
}

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> sub(n);
    REP(i,n)cin>>sub[i];
    auto ans = make_tuple(1000.0l, 0,0,0);
    REP(s,16)REP(a,16)REP(c,16) {
      auto v = getv(s,a,c,sub);
      ans = min(ans, make_tuple(ent(v), s,a,c));
    }
    int ms,ma,mc;
    tie(ignore,ms,ma,mc) = ans;
    cout<<ms<<' '<<ma<<' '<<mc<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

int Mod;

typedef class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
} Z;

Z qpow(Z a, int p) {
	Z rt = Z(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z Zi;

const int N = 102;

int n, m, K;
Zi comb[N][N];
Zi f[2][N][N];
Zi coef1[N][N];

int main() {
	scanf("%d%d%d%d", &n, &m, &K, &Mod);
	comb[0][0] = 1;
	int qaq = max(n, m);
	for (int i = 1; i <= qaq; i++) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; j++) {
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
	int cur = 0;
	f[cur][0][0] = 1;
	for (int k = 1; k <= K; k++) {
		memset(f[cur ^= 1], 0, sizeof(f[0]));
		for (int j = 0; j <= m; j++) {
			for (int x = 0; x <= n; x++) {
				coef1[j][x] = 0;
				Zi pw = qpow(k, x * (m - j)), a = ~qpow(k, m - j) * qpow(k - 1, m - j);
				for (int y = 0; y <= x; y++, pw *= a) {
					Zi tmp = pw * comb[x][y];
					if (y & 1) {
						coef1[j][x] -= tmp;
					} else {
						coef1[j][x] += tmp;
					}
				}
				coef1[j][x] *= qpow(K - k + 1, x * j);
			}
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				Zi v = f[cur ^ 1][i][j];
				if (!v.v)
					continue;
				for (int x = 0; i + x <= n; x++) {
					f[cur][i + x][j] += coef1[j][x] * comb[n - i][x] * v;
				}
			}
		}
		memset(f[cur ^= 1], 0, sizeof(f[0]));
		for (int i = 0; i <= n; i++) {
			Zi a = qpow(K - k + 1, i) - qpow(K - k, i);
			for (int j = 0; j <= m; j++) {
				Zi v = f[cur ^ 1][i][j];
				if (!v.v)
					continue;
				Zi pw = v, b = a * qpow(k, n - i);
				for (int x = 0; j + x <= m; x++, pw *= b)
					f[cur][i][j + x] += pw * comb[m - j][x];
			}
		}
	}
	Zi ans = f[cur][n][m];
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 384
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (vs, cs) => {
  let cost = 0
  for (var i = 0; i < vs.length; i++) {
    if (vs[i] > cs[i]) {
      cost += vs[i] - cs[i]
    }
  }
  return cost
  // ...
}
const main = (input) => {
  const [head, vs, cs] = input.split("\n")

  return solve(vs.split(" ").map(Number), cs.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

if (process.env.NODE_ENV === "test") {
  // module.exports = (input) => solve(input.trim())
  // main(``)
  // solve(1, [2, 3, 4])
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (u == s)
    {
        cout << (a - 1) << " " << b << endl;
    }
    else
    {
        cout << a << " " << (b - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256