akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] cnt = new int[5];
            Arrays.fill(cnt, 0);
            Set<ArrayList<Integer>> comb = new HashSet<>();
            combination(new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4, 5)), 3, comb);
            for (int i = 0; i < n; i++) {
                String str = in.next();
                switch (str.charAt(0)) {
                    case 'M':
                        cnt[0]++;
                        break;

                    case 'A':
                        cnt[1]++;
                        break;

                    case 'R':
                        cnt[2]++;
                        break;

                    case 'C':
                        cnt[3]++;
                        break;

                    case 'H':
                        cnt[4]++;
                        break;

                    default:
                        break;
                }
            }
            long ans = 0;
            for (ArrayList<Integer> list : comb) {
                long tmp = 1;
                for (int index : list) {
                    tmp *= cnt[index - 1];
                }
                ans += tmp;
            }

            out.print(ans);

        }

        private void combination(ArrayList<Integer> n, int r, Set<ArrayList<Integer>> ans) {
            if (n.size() == r) {
                ans.add(n);
                return;
            }

            for (int i = 0; i < n.size(); i++) {
                ArrayList<Integer> list = new ArrayList<>();
                list.addAll(n);
                list.remove(i);
                combination(list, r, ans);
            }
        }

    }
}



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

const ll MOD = 1000000007;

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    vector<ll> dp(max(a, b) + 1, 0);

    dp.at(0) = 1;
    rep(i, max(a, b))
    {
        dp.at(i + 1) = ((dp.at(i) * (n - i)) % MOD * modinv(i + 1, MOD)) % MOD;
    }

    ll ans = modpow(2, n, MOD) - 1 - dp.at(a) - dp.at(b);
    while (ans < 0)
    {
        ans += MOD;
    }

    ans %= MOD;

    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    getline(cin,s);
    int m=1<<(s.size()-1);
    long long ans=0;
    for(int i=0;i<m;i++)
    {
        long long t=s[0]-'0';
        for(int j=0;j<s.size();j++)
        {
            if(j==s.size()-1||i&1<<j)     
            {
                ans+=t;
                t=0;
                if(j==s.size()-1)  
				break;
            }
            t*=10;
            t+=s[j+1]-'0';
        }
    }
    cout<<ans<<endl;
}

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

int A, B;
string s;
int N;
int flg;
int k;
int judge(string s, int start_min1, int fin){
  // 長さnの文字列が回文かどうか
  // 回文なら0
  int len = fin - start_min1 + 1;
  for(int i=start_min1; i<len/2; i++){ //6の時3にしたくて5の時2にしたい
     //0, 1, 2
     // 0, 1
    if(s[i] != s[len-2-i]) {

      // printf("%d, %d, %c != %c \n",i, len-2-i, s[i], s[len-2-i]);
      return 1;
    }
  }
  return 0;
}

int main(){
  cin>>s;
  N = s.length();
  //5 -> 1&5, 2&4 だから 0&4, 1&3
  if(judge(s,0, N) == 0){
    // printf("sは回文\n");
    if(judge(s,0, (N-1)/2) == 0){
      // printf("第二段階clear\n");
      // 11 -> 1文字目から5文字目まで回文 つまり 0, 1, 2, 3, 4
      // (N+3)/2 から N
      // 11 -> 7から11, 長さは5
      k=0;
      for(int i=(N+1)/2+1; i<=N; i++){
        // s[k] = s[i];
        // k++;
        // printf("t[%d]は", i);
        // printf("%c", s[i-1]);
      }
      // printf("\n");

      if(judge(s, (N+3)/2-1, N) == 0){
        // printf("第3段階clear\n");
        flg = 1;
      }
    }
  }
  if(flg == 1) printf("Yes\n");
  else printf("No\n");
  // (flg ==  1) ? printf("Yes\n") : printf("No\n");

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f first 
#define s second
int main()
{
  int n,t;
  cin>>n>>t;
  pair<int,int>p[n];
  for(int i=0;i<n;i++)
    cin>>p[i].f>>p[i].s;
  sort(p,p+n);
  ll ans=0;
  ll dp[t]={0};
  for(int i=0;i<n;i++)
  {
    ans=max(ans,dp[t-1]+p[i].s);
    for(int j=t-1;j>=p[i].first;j--)
    {
      dp[j]=max(dp[j],dp[j-p[i].f]+p[i].s);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

int main() {
    int n, flag = 1, count = 0;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    while(1) {
        for(int i = 0; i < n; i++) {
            if(a[i]%2 == 1) {
                flag = 0;
                break;
            }
            a[i] /= 2;
        }
        if(flag == 0) break;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[1001],temp[1001],act[10],p[1001];
    int a,b,n;
    scanf("%s",&s);
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %d %d",&act,&a,&b);
        if (strcmp(act,"replace")==0){
            scanf("%s",&p);
            for (int j=0;j<strlen(p);j++){
                s[a+j]=p[j];
            }
        }else if(strcmp(act,"reverse")==0){
            strcpy(temp,s);
            for (int j=0;j<(b-a+1);j++){
            s[a+j]=temp[b-j];
            }
        }else if (strcmp(act,"print")==0){
            for (int j=a;j<=b;j++){
                printf("%c",s[j]);
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 2100
#include <cstdio>
const int mod = 1000000007;
struct M {
	long long a[60][60];
};
int n;
M mul(M &a, M &b) {
	M c;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			c.a[i][j] = 0;
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				c.a[i][j] += a.a[i][k] * b.a[k][j];
				c.a[i][j] %= mod;
			}
		}
	}
	return c;
}
M pow(M &a, long long k) {
	if (k == 1) return a;
	M r = pow(a, k / 2);
	r = mul(r, r);
	if (k & 1) r = mul(r, a);
	return r;
}
int main() {
	long long k;
	scanf("%d%lld", &n, &k);
	M a;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a.a[i][j]);
		}
	}
	a = pow(a, k);
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += a.a[i][j];
		}
	}
	printf("%lld\n", ans % mod);
	return 0;
}


Measured memory_bytes: 3456
import sys


def mode(hash):
    m = max(hash.values())
    for k in hash.keys():
        if hash[k] == m:
            return k

def longest(hash):
    h = {}
    for k in hash.keys():
        h[k] = len(k)
    m = max(h.values())
    l = ''
    for k in h.keys():
        if h[k] == m:
            l = k
            break
    return l


h = {}

#input_file = open(sys.argv[1], 'r')

for line in sys.stdin:
    terms = line.rstrip('\r\n').split(' ')
    for t in terms:
        if t in h:
            h[t] += 1
        else:
            h[t] = 1

print mode(h), longest(h)

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t; 
  if (a>b) {
    a -= v*t;
    b -= w*t;
    if (a<=b) {
      cout << "YES" << '\n';
    }
    else cout << "NO" << '\n';
  }
  else {
    a += v*t;
    b += w*t;
    if (a>=b) {
      cout << "YES" << '\n';
    }
    else cout << "NO" << '\n';
  } 
  return 0;
}

Measured memory_bytes: 3640
while 1 do
a,b=gets.split.map(&:to_i)
if a!=0 || b!=0 then
for i1 in 1..a do
if i1%2==1 then
for i2 in 1..b do
if i2%2==0 then
print "."
else
print "#"
end
end
else
for i2 in 1..b do
if i2%2==0 then
print "#"
else
print "."
end
end
end
print "\n"
end
else break
end
print "\n"
end

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

int S[1000],top;

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top + 1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];

    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 2044
import sys
readline = sys.stdin.readline


def main():
    n, k = map(int, readline().rstrip().split())
    nList = [0] * n
    for _ in range(k):
        d = int(readline().rstrip())
        aList = map(int, readline().rstrip().split())
        for a in aList:
            nList[a - 1] += 1
    print(nList.count(0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int x[] = new int[M];
		for (int i = 0; i < M; i++) {
			x[i] = sc.nextInt();
		}
		if (N >= M) {
			System.out.println(0);
			return;
		}
		Arrays.sort(x);

		Integer L[] = new Integer[M-1];

		for (int i = 0; i < M-1; i++) {
			L[i] = x[i+1] - x[i];
		}
		Arrays.sort(L,Collections.reverseOrder());

		int ans = 0;

		for (int i = 0; i < M-1; i++) {
			if (i < N-1) {
				continue;
			}
			ans += L[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49552
#include <stdio.h>

int main(void){
    
    int w,h;
    int i,j;
    
    while(1){
        scanf("%d %d",&h,&w);
        
        if(h==0&&w==0){
            break;
        }
        
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if((i+j)%2==0){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        
        printf("\n");
        
    }
    return 0;
}

Measured memory_bytes: 1804
from collections import defaultdict, deque
n=int(input())
es=[]

for i in range(n):
    *A,=map(int,input().split())
    for j in range(n-2):
        a=A[j]
        x,y=min(a-1,i),max(a-1,i)
        ith=((n-x)+(n-1))*x//2-1+(y-x)
        b=A[j+1]
        x,y=min(b-1,i),max(b-1,i)
        jth=((n-x)+(n-1))*x//2-1+(y-x)
        es.append([ith, jth])
#print(es)
v=n*(n-1)//2
outs = defaultdict(list)
ins = defaultdict(int)
for i,j in es:
    outs[i].append(j)
    ins[j] += 1
#print(outs, ins)
q = deque((v1,0) for v1 in range(n*(n-1)//2) if ins[v1] == 0)
res = []
while q:
    v1,cnt = q.popleft()
    res.append((v1,cnt))
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append((v2,cnt+1))

x=len(res)
if x!=n*(n-1)//2:
    print(-1)
else:
    print(res[-1][1]+1)

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))



ll solve(ll h,ll w){
    ll mah=1;
    ll ans=mod;
    rep(i,mah,h){
        ll ma=i*w;
        ll meh=(h-i+1)/2;
        ll mih=(h-i-meh);
        ll maxa=max(ma,meh*w);
        ll mina=min(ma,mih*w);
        ans=min(ans,maxa-mina);
    }
    rep(i,mah,h){
        ll ma=i*w;
        ll mew=(w+1)/2;
        ll miw=(w-mew);
        ll maxa=max(ma,mew*(h-i));
        ll mina=min(ma,miw*(h-i));
        ans=min(ans,maxa-mina);
    }
    return ans;



}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        ll h,w;cin>>h>>w;
        cout<<min(solve(h,w),solve(w,h));
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int n, a;
    cin >> n;
    vector<int> B;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if(i%2 == 0)B.push_back(a);
        else B.insert(B.begin(), a);
    }
    if(n%2==0){
        for (int i = 0; i < n; i++) {
            cout << B[i] << " ";
        }
    }
    else{
        for (int i = n-1; i >= 0; i--) {
            cout << B[i] << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[110];
bool rua;
int main()
{
	gets(a);
	int i,len=strlen(a);
	for(i=0;i<len;i++)
	{
		if(a[i]=='C')
			rua=true;
		if(a[i]=='F'&&rua)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
o,x,b;
main(a){
  for(scanf("%d");~scanf("%s",&a);o=o==3?b=x=!printf("%d\n",x):o)
      for(a%=9,a-8?b=b*2+1,x+=b/8,b&=7:o++;a<7&&b;b/=2)x+=b&1;
}

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

using namespace std;
#define int long long

int A, B, C, D;

int gcd(int a, int b)
{
	int c;
	while (b != 0)
	{
		c = a % b;
		a = b;
		b = c;
	}

	return a;
}

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

signed main()
{
	cin >> A >> B >> C >> D;

	int cntUntilB = B - ((B / C) + (B / D) - (B / lcm(C, D)));
	int cntUntilA = (A - 1) - (((A - 1) / C) + ((A - 1) / D) - ((A - 1) / lcm(C, D)));

	cout << cntUntilB - cntUntilA;

	return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

const int NUM = 3;
const int MAX_N = 100;

bool check (array<int, NUM>& ty, const array<int, MAX_N> xy, const int n) {
    bool flg = false;
    ty[xy[n]]++;
    if (ty[xy[n]] == NUM) flg = true;
    return flg;
}

bool check_naname (array<int, 2>& nnm, const array<int, MAX_N> y,
                   const array<int, MAX_N> x, const int n) {
    bool flg = false;
    if (y[n] == x[n]) {
        nnm[0]++;
        if (nnm[0] == NUM) flg = true;
    }
    if (y[n] == NUM - x[n] - 1) {
        nnm[1]++;
        if (nnm[1] == NUM) flg = true;
    }
    return flg;
}

int main() {
    array<int, MAX_N> y, x;
    y.fill (-1);
    x.fill (-1);
    REP (i, NUM) REP (j, NUM) {
        int cur;
        cin >> cur;
        cur--;
        y[cur] = i;
        x[cur] = j;
    }
    int N;
    cin >> N;
    array<int, NUM> tate, yoko;
    array<int, 2> naname;
    tate.fill (0);
    yoko.fill (0);
    naname.fill (0);
    bool flg = false;
    REP (i, N) {
        int cur;
        cin >> cur;
        cur--;
        if (y[cur] == -1) continue;
        flg = check (yoko, y, cur);
        if (flg) break;
        flg = check (tate, x, cur);
        if (flg) break;
        flg = check_naname (naname, y, x, cur);
        if (flg) break;
    }

    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int n = Integer.parseInt(br.readLine());
    String[] s = br.readLine().split(" ");
    int[] arr = new int[n];
    for (int i=0; i<n; i++) {
      arr[i] = Integer.parseInt(s[i])-(i+1);
    }
    Arrays.sort(arr);
    int med = arr[n/2];
    long sum = 0;
    for (int i=0; i<n; i++) {
      sum += (long)(Math.abs(arr[i]-med));
    }
    System.out.println(sum);
    /*
    long best = Long.MAX_VALUE;
    while (lo<=hi) {
      int mid = lo + (hi-lo)/2;
      long sum = 0;
      for (int i=0; i<n; i++) {
        sum += (long)(Math.abs(arr[i]-mid));
      }
      if (sum<best) {
        best = sum;
      }
      if ()
    }
    */
  }
}


Measured memory_bytes: 49748
S = input()
num = [0] * (len(S) + 1)
min_cnt = 0
plu_cnt = 0
flag = 0
ans = 0
if S[0] == ">":
    flag = 1
for i in range(len(S)):
    if flag == 1:
        if S[i] == "<":
            flag = 0
            plu_cnt = 0
        else:
            plu_cnt += 1
            ans += plu_cnt
    if S[i] == "<":
        if min_cnt == 0:
            plu_cnt += 1
        else: #ansに精算する
            M = max(plu_cnt, min_cnt)
            m = min(plu_cnt, min_cnt)
           # ans += ((plu_cnt+1)*plu_cnt)/2
           # ans += (min_cnt*(min_cnt-1))/2
            ans += ((M + 1) * M) // 2
            ans += (m*(m-1))//2
            plu_cnt, min_cnt = 0, 0
            plu_cnt += 1
    elif S[i] == ">" and flag == 0:
        min_cnt += 1
if flag == 1:
    plu_cnt, min_cnt = 0, 0
M = max(plu_cnt, min_cnt)
m = min(plu_cnt, min_cnt)
ans += ((M + 1) * M)//2
ans += (m*(m-1))//2
print(ans)

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

#define REP(i, n) for(ll i = 0; i < n; ++i)
#define REP3(i, B, E) for(ll i = B; i <= E; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

template<class T> T& chmin(T &obj, T val){ return obj = min(obj, val); }
template<class T> T& chmax(T &obj, T val){ return obj = max(obj, val); }

// 二分探索 : [low, high) の範囲で述語 pred がtrue を返す最大の値を返す
template<class Pred>
ll bsearch(ll low, ll high, Pred pred){
    while(low + 1 < high){
        const ll mid = low + (high - low) / 2;
        if(pred(mid)){ low = mid; }
        else{ high = mid; }
    }
    return low;
}

int main() {
    ll K, X;
    cin >> K >> X;
    if(500 * K >= X){ cout << "Yes"; }
    else { cout << "No"; }
    cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    int k, t; cin >> k >> t;
    vint a(t);
    rep(i, t) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    if(a[0] < k-a[0]) cout << 0 << endl;
    else cout << a[0]-(k-a[0])-1 << endl;
    return 0;
}


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

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int NMAX = 3010, TMAX = 3010;

ll dp1[NMAX][TMAX];
ll dp2[NMAX][TMAX];

int solve(){
  int N,T;cin >> N >> T;
  vector<PII> v(N);
  rep(i,N)cin >> v[i].first >> v[i].second;
  sort(all(v));

  ll ans = 0;
  rep(i,N){
    rep(t,T){
      dp1[i+1][t] = max(dp1[i+1][t],dp1[i][t]);
      int t_  = t+v[i].first;
      if(t_<T) dp1[i+1][t_] = max(dp1[i+1][t_],dp1[i][t]+v[i].second);
    }
    ans = max(ans, dp1[i][T-1]+v[i].second);
  }

  cout << ans << endl;
  return 0;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  solve();
  return 0;
}


Measured memory_bytes: 72064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 200010
ll n,q;
string s;
char t[N],d[N];
int solt(ll x){
    for(int i=0;i<q;i++){
	if(s[x]==t[i]){
	    if(d[i]=='L')x--;
	    if(d[i]=='R')x++;
	}
	if(x==-1)return 1;
	if(x==n)return 2;
    }
    return 0;
}
int main(){
    cin>>n>>q>>s;
    for(int i=0;i<q;i++){
	cin>>t[i]>>d[i];
    }
    //for(int i=0;i<n;i++)cout<<solt(i)<<" ";cout<<endl;
    ll mid;
    ll ls=-1,rs=n;
    while(ls<rs-1){
	mid=(ls+rs)/2;
	if(solt(mid)==1)ls=mid;
	else rs=mid;
    }
    ll lt=-1,rt=n;
    while(lt<rt-1){
	mid=(lt+rt)/2;
	if(solt(mid)==2)rt=mid;
	else lt=mid;
    }
    //cout<<rt<<" "<<ls<<endl;
    cout<<rt-ls-1<<endl;
    return 0;
}


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

#define int long long

#define ii pair<int, int>
#define fi first
#define sc second
#define set unordered_set
#define map unordered_map
#define all(x) (x).begin(), (x).end()

signed main() {
#ifdef _DEBUG
	freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int s, w; cin >> w >> s;
	if (s >= w) cout << "unsafe";
	else cout << "safe";
}


Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
int ch;
int max=0;
int cnt=0;
while((ch=getchar())!='\n'){
if(ch=='A'||ch=='T'||ch=='G'||ch=='C')
{cnt++;
max=max<cnt?cnt:max;}
else {
cnt=0;}
}
printf("%d",max);
return 0;
}


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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 10000000/*1LL << 60*/;

int A[15][15];

int main(){
    int N,M,X;
    cin >> N >> M >> X;
    int C[15];
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }
    int cost,now = INF;
    int study[M];
    rep(bit,1<<N){
        cost = 0;
        rep (i,M){
            study[i] = 0;
        }
        rep (i,N){
            if (bit & (1 << i)){
                cost += C[i];
                rep (j,M){
                    study[j] += A[i][j]; 
                }
            }
        }
        bool hoge = true;
        rep (k,M){
            if (study[k] < X){
                hoge = false;
            }
        }
        if (hoge){
            now = min(now,cost);
        }
    }
    cout << (now == INF ? -1 : now) << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

int dp[100002];

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    dp[i] = INF;
    for (int j = 1; j <= K; j++) {
      if (i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]));
      }
    }
  }
  cout << dp[N - 1] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


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

d = [0]*n
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            f = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if f <= n:
                d[f-1] += 1

for i in range(n):
    print(d[i])

Measured memory_bytes: 9364
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

if A<B:
    if A+T*V>=B+T*W:
        print('YES')
    else:
        print('NO')

elif B<A:
    if -1*T*V+A<=-1*T*W+B:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9176
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
#include <string.h>
#include <math.h>
//#include <vector>

using namespace std;


int main() {
  int N;
  int A[100000];
  
  int i,keta=0;
  int ans=0; 
  int prev; 
  
  cin >> N;
  
  while(N>0){
    A[keta]=N%10;
    N = N/10;
    keta++;
  }

  //  for(i=0; i<keta; i++)
  //printf("%d\n",A[i]);
    
  prev = -2; 
  
  for(i=0;i<keta;i++){
    if(A[i]>0){
      if(prev == i-1 && A[i]==1 && i==keta-1)
	ans += 10;
      else
	ans += A[i];
    }else{
      prev = i;
    }
  }

  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}



template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int k;
  cin>>k;
  
  if(k<=500){
    cout<<k<<endl;
    for(Int i=0;i<k;i++){
      for(Int j=0;j<k;j++){
        if(j) cout<<" ";
        cout<<i+1;
      }
      cout<<endl;
    }
    return 0;
  }
  
  Int n=2*((k+3)/4);
  auto s=make_v<Int>(n,n);
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      s[i][j]=((i&1)*n)+((i+j)%n);

  Int d=n*2-k;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      if(s[i][j]<d) s[i][j]+=n;
  
  vector<Int> v;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      v.emplace_back(s[i][j]);
  v=compress(v);
  auto m=dict(v);

  cout<<n<<endl;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<m[s[i][j]]+1;
    }
    cout<<endl;
  }  
  return 0;
}


Measured memory_bytes: 6256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

int main(){
	string s;
	cin>>s;
	ll k,a;
	cin>>k;
	char alt='?';
	rep(i,s.size()){
		if(s[i]!='1'){
			a=i+1;
			alt=s[i];
			break;
		}
	}
	if(a<=k){
		cout<<alt<<endl;
	}else{
		cout<<'1'<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def Monstery():
    H, A = wczytaj_liste()
    odp = H//A
    if H - odp*A > 0:
        odp += 1
    print(odp)

Monstery()



Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
const int inf = 1012345678;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a,b; cin >> a >> b;

    cout << a * b << ln;
    return 0;
}

Measured memory_bytes: 3628
/*
  AUTHOR:SOURABH
  CREATED:14:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

ll n;
set<string> b;
set<string>::iterator it;

void solve(string s,ll id,ll ma)
{
    //cout<<s<<" "<<id<<" "<<ma<<endl;
    if(id==n+1)
    {b.insert(s);return;}

    char c='a';
    ll i;
    fs(i,1,ma+1)
    {
        solve(s+(c++),id+1,max(i+1,ma));
    }
}

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        solve("",1,1);
        fit(it,b)
        cout<<*it<<"\n";
    }
    return 0;
}






Measured memory_bytes: 12416
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        sc.close();

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (v[i] > c[i]) {
                ans += v[i] - c[i];
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  REP(i, 0, N / 2) {
    int j = i + N / 2;

    if (S[i] != S[j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define int long long

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

int n, fac[N];

int fast_pw(int x, int y) {
	int ret = 1;
	for(;y;y>>=1) {
		if(y&1) ret=(ret*x)%mod;
		x=(x*x)%mod;
	}
	return ret;
}

int calculate_fac(int a) {
	int ret = 1;
	for(int i=n;i>n-a;i--) {
		ret = (ret*i)%mod;
	}
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	fac[0]=1;
	for(int i=1;i<N;i++) fac[i]=(fac[i-1]*i)%mod;
	int a, b;
	cin >> n >> a >> b;
	long long all = fast_pw(2, n) - 1;
	long long other1 = (calculate_fac(a) * fast_pw(fac[a], mod-2))%mod;
	long long other2 = (calculate_fac(b) * fast_pw(fac[b], mod-2))%mod;
	cout << (all-other1-other2+mod+mod)%mod;


	return 0;
}


Measured memory_bytes: 1792
#
# abc102 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)
    print(A[-1]-A[0])


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
1 4 6 3"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
1000000000 1"""
        output = """999999999"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
1 1 1 1 1"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 5684
#include <stdio.h>
#include <math.h> 
#include <string.h>
int main(){
	
	long long i,j,k,n,l;
	char s[200];
	scanf("%s",&s);
	scanf("%lld",&k);
	l=strlen(s);
	for(i=0;i<l;i++){
    if(s[i]!='1')break;
}
if(i>=k){
	printf("1");
	return 0;
} 
if(i==l)i--; 
printf("%c",s[i]);
return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll a,b,c;
    Scll3(a,b,c);
    ll s = a+b+c;

    int ans = 0;
    while( !(a%2|b%2|c%2) ){
        if( a==b && b==c ){
            ans = -1;
            break;
        }
        a = (s-a)/2;
        b = (s-b)/2;
        c = (s-c)/2;
        ans++;
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			var a = cin.ArrayInt(n);
			var b = cin.ArrayInt(n);
			var c = cin.ArrayInt(n - 1);
			int ans = 0;
			int prev = -3;
			for (int i = 0; i < n; i++) {
				ans += b[a[i] - 1];
				if (prev == a[i] - 1) {
					ans += c[prev - 1];
				}

				prev = a[i];
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11220
#include <cmath>
#include <cstdio>
#include <algorithm>
#define rg register
#define llint long long
using namespace std;
const int N=1008611;

struct ios
{
	template <typename _tp>
	inline ios operator >> (_tp &x)
	{
		x = 0;int f = 1;char c = getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f = -1;
		for(;c<='9'&&c>='0';c=getchar()) x = (x<<1)+(x<<3)+(c^48);
		x *= f;
		return *this;
	}
	template <typename _tp>
	inline ios operator << (_tp x)
	{
		char s[66];int dgt = 0;
		if(x==0) putchar('0');
		if(x<0) putchar('-'),x = -x;
		while(x) ++dgt,s[dgt] = x%10+'0',x/=10;
		while(dgt) putchar(s[dgt]),--dgt;
		return *this;
	}
	inline ios operator << (char x)
	{
		putchar(x);
		return *this;
	}
}io;

int n;
int num[N],ans;

int main()
{
	io >> n;
	for(rg int i=1;i<=n;++i)
		io >> num[i],ans^=num[i];
	if(ans)
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define maxn 100000 * 2 + 10
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n < 10 && m < 10)
    {
        int mid = n*m;
        cout<<mid<<endl;
    }
    else
        cout<<-1<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        double ans = 0;
        ans = (double)w * h / 2;
        System.out.print(ans);
        System.out.print(" ");
        if (x * 2 == w && y * 2 == h) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
#define MAX 10000
#define NIL -1

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

struct Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if ( u == NIL ) return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if ( T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
    if ( T[u].right != NIL ) h2 = setHeight(T[u].right) + 1;
    return H[u] = ( h1 > h2 ? h1 : h2 );
}

int getSibling(int u) {
    if ( T[u].parent == NIL ) return NIL;
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
    if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL ) return T[T[u].parent].right;
    return NIL;
}

void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if ( T[u].left != NIL ) deg++;
    if ( T[u].right != NIL ) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    if ( T[u].parent == NIL ) {
        printf("root\n");
    } else if ( T[u].left == NIL && T[u].right == NIL ) {
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}

int main() {
    int v, l, r, root = 0;
    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) T[i].parent = NIL;

    for ( int i = 0; i < n; i++ ) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if ( l != NIL) T[l].parent = v;
        if (r != NIL ) T[r].parent = v;
    }

        for (int i = 0; i < n; i++) if ( T[i].parent == NIL ) root = i;

        setDepth(root, 0);
        setHeight(root);

        for (int i = 0; i < n; i++ ) print(i);

    return 0;
}



Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,n,k;
    cin>>n>>k>>x>>y;
    n<=k?cout<<(unsigned long long)(n*x)<<endl:cout<<(unsigned long long)(x*k+y*(n-k))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int c = 0;
  for (int i = 1; i <= N; i++) {
    //cout << log10(i) << endl;
    if (int(ceil(log10(i + 1))) % 2 == 1) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    cin >> a;
    string b;
    if( a > 26 ) {
        while( a >= 1 ) {
            if( a % 26 ) b += a % 26 + 'a' - 1;
            else b += 'z';
            if( a % 26 == 0 ) a--;
            a /= 26;
        }
    } else {
        char c = a % 26 + 'a' - 1;
        if( a == 26 ) cout << 'z';
        else cout << c;
    }
    reverse( b.begin() , b.end() );
    cout << b;
} 


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,ll> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

template< typename T >
struct BinaryIndexedTree {
	vector<T> data;

	BinaryIndexedTree(int size):data(size+1,0) {}

	T sum(int k) {
		T res=0;
		for(++k;k>0;k-=(k&-k)) res+=data[k];
		return res;
	}

	void add(int k,T x) {
		for(++k;k<(int)data.size();k+=(k&-k)) data[k]+=x;
	}
};

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

	int n,q;
	cin>>n>>q;
	BinaryIndexedTree<long long> tree(n+1);
	while(q--) {
		int type,x,y;
		cin>>type>>x>>y;
		if(type==0) {
			tree.add(x,y);
		}
		else {
			cout<<tree.sum(y)-tree.sum(x-1)<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3644
from math import sqrt
N, D = map(int, input().split())
X_list = [input().split() for i in range(N)]
cnt = 0
for x in range(N-1):
    d = 0
    tmp = 0
    for y in range(x+1, N):
        d = 0
        tmp = 0
        while d < D:
            x_d = int(X_list[x][d])
            y_d = int(X_list[y][d])
            tmp += (x_d - y_d) ** 2
            d += 1
        if sqrt(tmp).is_integer():
            cnt += 1

print(cnt)

Measured memory_bytes: 3064