akhauriyash/Code-Regression huggingface dataset:
import math

A, B = map(int, input().split())


def f(num):
    n_max = math.ceil(math.log2(num+1))
    result = 0
    for n in range(n_max):
        if n == 0:
            r = num % 4
            if r == 1 or r == 2:
                result += 1
            continue
        r = (num+1) % 2**(n+1)
        if r <= 2**n:
            continue
        else:
            r -= 2**n

        if r % 2 == 1:
            result += 2**n

    return result


if A > 0:
    print(f(A-1) ^ f(B))
else:
    print(f(B))


Measured memory_bytes: 3064
import numpy as np


H,W,K = list(map(int,input().split()))

c = np.empty(0)

for i in range(H):
    tmp = list(input())
    c = np.append(c, tmp)
    
c = c.reshape([H, W])

num = 0
_max = 2 ** (H+W)
count = 0

for i in range(_max):
    bin_num = format(num, 'b')
    for j in range((H+W) - len(bin_num)):
        bin_num = '0' + bin_num
    tmp = bin_num
    c2 = c.copy()
    for j in range(H):
        if bin_num[j] == '1':
            c2[j, :] = 'r'
    for j in range(H, H+W):
        if bin_num[j] == '1':
            c2[:, j-H] = 'r'
    if np.count_nonzero(c2 == '#') == K:
        count += 1
    num += 1
        
print(count)
            

Measured memory_bytes: 27088
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n;
	rd(n);
	vint arr(n);
	for(auto& v:arr)rd(v);
	vint sum(n,0);
	sum[n-1]=arr[n-1]%MOD;
	for(int i=n-2;i>=0;i--){
		sum[i]=(arr[i]%MOD+sum[i+1]%MOD)%MOD;
	}	
	int ans=0;
	for(int i=0;i<n-1;i++){
		ans=(ans%MOD+((arr[i]%MOD)*(sum[i+1]%MOD))%MOD)%MOD;
	}
	ans%=MOD;
	pp(ans);
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int M = nextInt();
  int X = nextInt();
  int Y = nextInt();
  int x[100];
  int y[100];
  REP(i, N) x[i] = nextInt();
  REP(i, M) y[i] = nextInt();
  int x_max = *max_element(x, x+N);
  int y_min = *min_element(y, y+M);

  bool ok = false;
  for (int z = X + 1; z <= Y; z++) {
    if (x_max < z && z <= y_min)
      ok = true;
  }
  if (ok)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int N, lastdig;
scanf("%d",&N);
lastdig=N%10;
if(lastdig==2||lastdig==4||lastdig==5||lastdig==7||lastdig==9){
printf("hon");}
else if(lastdig==0||lastdig==1||lastdig==6||lastdig==8){
printf("pon");}
else{
printf("bon");}
return 0;
}

Measured memory_bytes: 2112
#include <cstdio>
typedef long long ll;
ll n, q, a[50], b[50];
void GetList(ll x, ll *a) {
	ll tot = 1, now = 1;
	a[0] = 1;
	while (tot < x) {
		now *= n;
		tot += now;
		++a[0];
	}
	for (int i = a[0]; i >= 1; --i) {
		tot -= now;
		now /= n;
		a[i] = x;
		x = tot - now + (x - tot - 1) / n + 1;
	}
}
int main() {
	scanf("%lld%lld", &n, &q);
	while (q--) {
		ll l, r;
		scanf("%lld%lld", &l, &r);
		if (n == 1) {
			printf("%lld\n", l < r ? l : r);
			continue;
		}
		GetList(l, a);
		GetList(r, b);
		for (int i = 1; ; ++i)
			if (i > a[0] || i > b[0] || a[i] != b[i]) {
				printf("%lld\n", a[i-1]);
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();

        if (a == b && b == c && a == c) {
            System.out.println("No");
            return;
        }
        else if (a != b && b != c && a != c) {
            System.out.println("No");
            return;
        } 
        System.out.println("Yes");
    }
}

Measured memory_bytes: 21716
LARGE = 10 ** 9 + 7
n, a, b = map(int, input().split())

s, l = min(a, b), max(a, b)
s_factorial_inv = s_factorial_upper = l_factorial_inv = l_factorial_upper = m = 1

while True:
    if m <= s:
        s_factorial_inv *= m
        s_factorial_inv %= LARGE
        s_factorial_upper *= n - s + m
        s_factorial_upper %= LARGE
    if m <= l:
        l_factorial_inv *= m
        l_factorial_inv %= LARGE
        l_factorial_upper *= n - l + m
        l_factorial_upper %= LARGE
    else:
        break
    m += 1

nCs = pow(s_factorial_inv, LARGE - 2, LARGE) * s_factorial_upper
nCl = pow(l_factorial_inv, LARGE - 2, LARGE) * l_factorial_upper

print((pow(2, n, LARGE) - nCs - nCl - 1 + LARGE) % LARGE)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a,b,cnt,s;
	while(scanf("%d %d",&a,&b)!=EOF){
		cnt=0;
		s=a+b;
		while(s>0){
			s=s/10;
			cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
const int maxn = 5e5 + 5;//拆点后点变多，这里有问题
typedef pair<int,int> pr;

int n,m;
int u,v,c;
map<int,int> id[maxn];//??
int sz = 0;

struct edge{
    int v,w;
};
vector<edge> mp[maxn];

int getid(int u,int c)
{
    if(id[u][c] == 0) id[u][c] = ++sz;
    return id[u][c];
}
bool inq[maxn];
int d[maxn];//??
queue<int> q;
const int inf = 0x3f3f3f3f;

void SPFA(int s,int t)
{
    for(int i=1;i<=sz;i++)
        d[i]=inf,inq[i]=0;
    q.push(s);
    d[s]=0,inq[s]=1;
    while(!q.empty())
    {
        int u=q.front();
        q.pop(),inq[u]=0;
        for(int i=0;i<mp[u].size();i++)
        {
            int v=mp[u][i].v,w=mp[u][i].w;
            if(d[v]>d[u]+w)
            {
                d[v]=d[u]+w;
                if(!inq[v])
                    inq[v]=1,q.push(v);
            }
        }
    }
    printf("%d\n",d[t]>=inf?-1:d[t]/2);
}

int main()
{
    while(scanf("%d%d",&n,&m) != EOF)
    {
        sz = n;
        for(int i = 1;i <= n;i ++) mp[i].clear();
        while(m --){
            scanf("%d%d%d",&u,&v,&c);
            int uc = getid(u,c);
            int vc = getid(v,c);
            mp[u].push_back(edge{uc,1});
            mp[uc].push_back(edge{u,1});
            mp[uc].push_back(edge{vc,0});
            mp[vc].push_back(edge{uc,0});
            mp[vc].push_back(edge{v,1});
            mp[v].push_back(edge{vc,1});
        }
        SPFA(1,n);
        //        printf("sz = %d\n",sz);
        //        for (int i = 1; i <= sz; i ++) {
        //            printf("%d%c",d[i],i == sz ? '\n' : ' ');
        //        }
        for (int i = 0; i < sz; i ++) {
            mp[i].clear();
            id[i].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 75136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 1001000
int n,a[N],i,b[N],c[N],m;
int main()
{
	scanf("%d",&n);
	m=0;
	for (i=1;i<=n;i++) scanf("%d",&a[i]),m=max(m,a[i]);
	for (i=1;i<=n;i+=2) b[a[i]]++;
	for (i=2;i<=n;i+=2) c[a[i]]++;
	int mb1=0,mb2=0,mc1=0,mc2=0;
	for (i=1;i<=m;i++)
	{
		if (b[i]>b[mb1]) mb2=mb1,mb1=i; else if (b[i]>b[mb2]) mb2=i;
		if (c[i]>c[mc1]) mc2=mc1,mc1=i; else if (c[i]>c[mc2]) mc2=i;
	}
	if (mb1!=mc1) printf("%d\n",n-b[mb1]-c[mc1]);
	else 
	{
		int o=n-b[mb1]-c[mc2];
		int p=n-b[mb2]-c[mc1];
		printf("%d\n",min(o,p));
	}
	return 0;
}

Measured memory_bytes: 8832
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def merge(A, left, mid, right):
    global count

    L = A[left:mid] + [1e9]
    R = A[mid:right] + [1e9]

    i, j = 0, 0

    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return None


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert array_length == len(array)
    count = 0
    print(*merge_sort(A=array, left=0, right=array_length))
    print(count)

Measured memory_bytes: 67728
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define LL long long
#define PP std::pair<LL,LL>
std::string ser[] = { "dream","erase" };
int main() {
	std::string S;
	std::cin >> S;
	bool bef;
	bool ok;
	for (int i = 0; i < S.size(); i++) {
		bool g = false;
		for (int k = 0; k < 2; k++) {
			for (int j = 0; j < 5; j++) {
				if (ser[k][j] != S[i + j])break;
				if (j == 4) {
					g = true;
					ok = true;
					bef = k;
					i += 4;
				}
			}
		}
		if (!g) {
			if (!ok) {
				std::cout << "NO" << std::endl;
				return 0;
			}
			ok = false;
			if (S[i] == 'r'&&bef)i += 0;
			else if(S[i] == 'e'&&S[i + 1] == 'r' && !bef)i++;
		else {
			std::cout << "NO" << std::endl;
			return 0;
		}
		}
	}
	std::cout << "YES" << std::endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		
		
		int n = 0;
		n = sc.nextInt();
		
		String ans = "Three";
		
		char[] letters = new char[n];
		String[] sLetters = new String[n];
		
		String string = sc.nextLine();
		sLetters = string.split(" ");
		
		for (int l = 0; l < letters.length; l++) {
			if (sLetters[l].equals("Y")) {
				ans = "Four";
			}
		}
		
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	int ans=0;
	for(int i=1;i<n;i++)
	{
		int cnt=0;
		
		for(char c='a';c<='z';c++)
		{
			bool l=false,r=false;
			
			for(int j=0;j<i;j++)
			{
				if (s[j]==c)
				l=true;
			}
			
			for(int j=i;j<n;j++)
			{
				if (s[j]==c)
				r=true;
				
			}
			
			if(l && r)
			cnt++;
		}
		
		if(cnt>ans)
		ans=cnt;
	}
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int cnt = 0;
		String a;
		a = stdin.next();
		for (int i = 0; i < 6; i++) {
			if (a.charAt(i)- '0' == 1) {
				cnt++;
			}

		}
		System.out.println(cnt);

	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll p[n];mset(p);
    p[0]=a[0];ll ans=0;
    if(a[0]==0){
        p[0]++;
        ans++;
    }
    for(int i=1;i<n;i++){
        p[i]=p[i-1]+a[i];
        if(p[i-1]>0&&p[i]>0){
            ans+=p[i]+1;
            p[i]=-1;
        }
        if(p[i-1]<0&&p[i]<0){
            ans-=(p[i]-1);
            p[i]=1;
        }
        if(p[i]==0){
            if(p[i-1]>0)p[i]--;
            else p[i]++;
            ans++;
        }
    }
    mset(p);
    ll ans2;
    if(a[0]==0)p[0]--,ans2++;
    else if(a[0]>0)ans2+=a[0]+1,p[0]=-1;
    else ans2-=(a[0]-1),p[0]=1;
    for(int i=1;i<n;i++){
        p[i]=p[i-1]+a[i];
        if(p[i-1]>0&&p[i]>0){
            ans2+=p[i]+1;
            p[i]=-1;
        }
        if(p[i-1]<0&&p[i]<0){
            ans2-=(p[i]-1);
            p[i]=1;
        }
        if(p[i]==0){
            if(p[i-1]>0)p[i]--;
            else p[i]++;
            ans2++;
        }
    }
    cout<<min(ans,ans2)<<"\n";
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

ll a, b;

signed main(){
//	freopen("PERFECT1.inp","r",stdin);
//	freopen("PERFECT1.out","w",stdout);
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	cout << max(a*b, max(a-b, a+b));
}



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

using namespace std;

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

  string s;
  cin >> s;
  int n = s.size();

  int c1 = 0, c2 = 0;
  for (int i = 0; i < n; ++i) {
    if (i%2 == 0 && s[i] == '1') c1++;
    if (i%2 == 1 && s[i] == '0') c1++;
    if (i%2 == 0 && s[i] == '0') c2++;
    if (i%2 == 1 && s[i] == '1') c2++;
  }
  cout << min(c1, c2) << endl;

  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = (3 * 1e5) + 10;
const long double PI = acos(-1);

  

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

    vector<int> v(n+1, 0);

    for (int i=1; i*i<=n; i++){
        for (int j=1; j*j <=n; j++){
            ll val;
            for (int k=1; k*k<=n; k++){
                val = i*i + j*j + k*k + i*j + i*k + j*k;
                if (val <= n) v[val]++;
                else break;
            }
        }
    }

    for (int i=1; i<=n; i++) cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
a = 'abcdefghijklmnopqrstuvwxyz'
 
for s in sys.stdin:
    for n in range(1, 27):
        t = s[:-1].translate(str.maketrans(a, a[n:] + a[:n]))
        if 'the' in t or 'this' in t or 'that' in t: break
    print(t)

Measured memory_bytes: 5564
#include <iostream>
using namespace std;
int main(void){
    
    int S;
    cin >> S;
    
    int h = S / 3600;
    int m = (S % 3600) / 60;
    int s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
}



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

int main() {
    int H, W, K;
    std::cin >> H >> W >> K;

    char S[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            std::cin >> S[i][j];
        }
    }

    int min_cnt = INT32_MAX;
    for (int b = 0; b < (1 << (H - 1)); ++b) {
        int hcut_count= 0;

        std::vector<std::vector<int>> cnts;  
        std::vector<int> rows(W);
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (S[i][j] == '1') {
                    rows[j]++;
                }
            }

            if ((b >> i) & 1) {
                cnts.push_back(rows); 
                rows = std::vector<int>(W);
                ++hcut_count;
            }
        }
        cnts.push_back(rows); 

        bool ok = true;
        for (int i = 0; i < hcut_count + 1; ++i) {
            for (int j = 0; j < W; ++j) {
                if (cnts[i][j] > K) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok == false) {
            continue;
        }

        int vcut_count = 0;
        std::vector<int> whites(hcut_count + 1);
        for (int i = 0; i < W; ++i) {
            bool clear = false;

            for (int j = 0; j < hcut_count + 1; ++j) {
                if (whites[j] + cnts[j][i] > K) {
                    ++vcut_count;
                    clear = true;
                    break;
                } else {
                    whites[j] += cnts[j][i];
                }
            }

            if (clear) {
                for (int j = 0; j < hcut_count + 1; ++j) {
                    whites[j] = cnts[j][i];
                }
            }
        }

        min_cnt = std::min(min_cnt, hcut_count + vcut_count);
    }

    std::cout << min_cnt << std::endl;

    return 0;
}


Measured memory_bytes: 3560
# -*- coding: utf-8 -*-

from collections import deque

n = int(raw_input())
que = deque()
for i in range(n):
    com = str(raw_input())
    if com == "deleteFirst":
        del que[0]
    elif com == "deleteLast":
        del que[-1]
    else:
        c, p = com.split()
        if c == "insert":
            que.appendleft(p)
        else:
            try: que.remove(p)
            except: pass
print " ".join(map(str, que))

Measured memory_bytes: 126068
s = input()

n = len(s)+1
L = [0]*(n)

for i in range(n-1):
  if s[i]=='<':
    L[i+1] = max(L[i+1],L[i]+1)

for i in range(n-2,-1,-1):
  if s[i]=='>':
    L[i] = max(L[i],L[i+1]+1)
    
print(sum(L))    

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a == (b + c)) {
    cout << "Yes" << endl;
  }
  else if (b == (a + c)) {
    cout << "Yes" << endl;
  }
  else if (c == (a + b)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;

vector<vector<int>> g;
int n, k;
int64_t ans;

void dfs(int u, int p)
{
    int64_t cnt = k - 1;
    if (u!=0) cnt--;
    for (int v: g[u])
    {
        if (v==p) continue;
        if (cnt<=0)
        {
            ans = 0;
            return;
        }
        ans *= cnt;
        ans %= mod;
        cnt--;
        dfs(v, u);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    g.resize(n);
    for (int i=1; i<n; i++)
    {
        int u, v; cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ans = k;
    dfs(0, -1);
    cout << ans;
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
using namespace std;
int n, sum = 0;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
program main
      implicit none
      integer(4) :: a, b, i, j, k

      read(*,*) a, b

      do k = 1, 1009
        i = k * 0.08
        j = k * 0.10
        if (( i == a ) .and. ( j == b )) then
          print *, k
          exit
        end if
      end do
      if ( k == 1010 ) then
        print *, "-1"
      end if

end program main



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll power(ll x,ll y) 
{ 
    ll res = 1; // Initialize result 
  
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1;
        x = x * x; 
        x%=mod;
        res%=mod;
    } 
    return res; 
} 
ll a[21][21];
ll p;
ll find(ll val[],ll peo,ll i,ll n)
{
    if(peo==p)
        return 1;
    if(i==n)
        return 0;
    if(val[peo]!=-1)
        return val[peo];
    ll sum=0;
    for(ll j=0;j<n;j++)
    {
        if(a[j][i]==1&&((peo|power(2,j))!=peo))
        {
            sum+=find(val,(peo|power(2,j)),i+1,n);
            sum%=mod;
        }
    }
    val[peo]=sum;
    return sum;
}
int main()
{  
    FAST
    ll n;
    cin>>n;
    p=power(2,n);
    p--;
    ll val[p];
    for(ll i=0;i<=p;i++)
    {
        val[i]=-1;
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    cout<<find(val,0,0,n);
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
vector<ll> g,v;
ll n,res,hell=pow(10,18);
ll gcd(ll a,ll b,ll& x,ll& y) {
    if(!b){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll d=gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
ll inv(ll a,ll m){
	ll x,y;
	gcd(a,m,x,y);
	x=(x%m+m)%m;
	return x;
}
void f(ll cnt){
	if(cnt==sz(v)){
		ll j=0,x=1,y=1;
		for(ll i=0;i<sz(v);i++){
			if(j<sz(g)&&g[j]==i){
				x*=v[i];
				j++;
				continue;
			}
			y*=v[i];
		}
		ll val=inv(x,y),cnt=0;
		while(cnt<5){
			if(val>hell/x){
				cnt=100;
				break;
			}
			ll jok=(val*x-1)/y;
			if(val*x>1&&(val%2==0||jok%2==0))
				break;
			val+=y;
			cnt++;
		}
		if(cnt<5)
			res=min(res,val*x-1);
		return;
	}
	f(cnt+1);
	g.push_back(cnt);
	f(cnt+1);
	g.pop_back();
}
void solve(){
	cin>>n;
	res=hell;
	for(ll i=2;i*i<=n;i++)
		if(n%i==0){
			v.push_back(1);
			while(n%i==0){
				v.back()*=i;
				n/=i;
			}
		}
	if(n>1)
		v.push_back(n);
	f(0);
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 3792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * 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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            int m = (s.charAt(5) - '0') * 10 + (s.charAt(6) - '0');
            int d = (s.charAt(8) - '0') * 10 + (s.charAt(9) - '0');
            if (m < 4 || (m == 4 && d <= 30))
                out.println("Heisei");
            else
                out.println("TBD");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;


int main(){
  map<int,int> l,r;
  int n;
  cin>>n;
  
  ll ans=0;

  rep(i,n){
    int a;
    cin>>a;
    l[i+1-a]++;
    r[i+1+a]++;
 
    //cout<<ans<<endl;
    if(r.find(i+1-a)==r.end()){
      continue;
    }else{
      ans+=r[i+1-a];
    }
    
    
  }    
 cout<<ans<<endl;

}



Measured memory_bytes: 20916
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n; (n = in());) {
		vector<int> A(n);
		for (int &a: A)
			a = in();
		int c = 0;
		for (int i = n - 1; i; i--)
			for (int j = 1; j <= i; j++)
				if (A[j - 1] > A[j]) {
					c++;
					swap(A[j - 1], A[j]);
				}
		outl(c);
	}
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=114514;
vi g[Nmax];
int dfs(int v,int p){
	int res=0;
	for(auto ch:g[v])if(ch!=p)
		res^=dfs(ch,v);
	return res+1;
}

signed main(){
	int n=read();
	REP(i,n-1){
		int x=read()-1,y=read()-1;
		g[x].PB(y);
		g[y].PB(x);
	}
	if(dfs(0,-1)==1)
		cout<<"Bob"<<endl;
	else
		cout<<"Alice"<<endl;
}

Measured memory_bytes: 12160
def main():
    n = int(input())

    ans = 0
    l = n
    i = 1
    while l > 0:
        k = i*(i+1)//2
        l_n = n//(i+1)
        ans += k*(l*(l+1)//2-l_n*(l_n+1)//2)
        l = l_n
        i+=1
    
    print(ans)
main()

Measured memory_bytes: 63072
import java.util.*;
public class Main {
	static boolean prime[] = new boolean[200000];
	static int[] result = new int[10002];
	static void Do(int k){
		int sum=0;
		for(int i=1;i<=k;i++){
			sum+=P(i);
		}
	}
	static int P(int n){
		int cnt=0;
		for(int i=0;i<prime.length;i++){
			if(prime[i]){
				cnt++;
				if(cnt==n)return i;
			}
		}
		return 0;
	}
	
	static void doIt(int n){
		if(n==0)return;
		result[n]=result[n-1]+P(n);
	}
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		for(int i=0;i<prime.length;i++)prime[i]=true;
		prime[0]=false;prime[1]=false;
		for(int s=0;s<prime.length;s++){
			if(prime[s])
				for(int i=s+s;i<prime.length;i+=s)prime[i]=false;
		}
		for(int i=1;i<result.length;i++)doIt(i);
		while(in.hasNext()){
			int x = in.nextInt();
			if(x==0)break;
			System.out.println(result[x]);
		}
	}
}

Measured memory_bytes: 20364
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::log;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int A, B;

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

	cin >> A >> B;
	cout << (A-1)*(B-1);

	return 0;
}


Measured memory_bytes: 256
// AOJ 0351 Quiet Town
// 2018.2.25 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 2000
typedef struct { int t, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 1503
int n, dmax, sz;
short hi[MAX], *to[MAX], *dt[MAX];		// to, dist
short hi2[MAX], *to2[MAX];
int   dist[MAX];
char  mk[MAX], ans[MAX];
short q[2*MAX], top, tail;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void dijkstra(int start)
{
	int i, s, d, e;
	int max;

	memset(dist, INF, n << 2);
	memset(hi2, 0, n << 1);
	qsize = 0;
	dist[start] = 0, enq(start, 0);
	while (qsize) {
		s = que[0].s, deq();
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], d = dist[s] + dt[s][i];
			if (dist[e] < d) continue;
			if (dist[e] > d) hi2[e] = 0, dist[e] = d, enq(e, d);
			to2[e][hi2[e]++] = s;
		}
	}

	top = 0, tail = 0;
	max = 0; for (i = 1; i < n; i++) {
		if (dist[i] > max) max = dist[i], q[0] = i, tail = 1;
		else if (dist[i] == max) q[tail++] = i;
	}

	if (max < dmax) return;
	if (max > dmax) { dmax = max, sz = n-1, memset(ans, 0, n); }

	memset(mk, 0, n);
	while (top < tail) {
		s = q[top++];
		if (mk[s]) continue;
		mk[s] = 1;
		for (i = 0; i < hi2[s]; i++) {
			e = to2[s][i];
			if (mk[e]) continue;
			q[tail++] = e;
			if (!ans[s]) sz--, ans[s] = 1;
			if (!ans[e]) sz--, ans[e] = 1;
		}
	}
}

int main()
{
	int i, j, r, k, s, t, d;
	short *memo;
	
	n = in()+1, r = in();
	memo = malloc(r*6);
	j = 0, i = r; while (i--) {
		memo[j++] = s = in(), hi[s]++;
		memo[j++] = t = in(), hi[t]++;
		memo[j++] = in();
		
	}
	for (s = 0; s < n; s++) if (hi[s]) {
		to [s] = malloc(hi[s] << 1), dt[s] = malloc(hi[s] << 1);
		to2[s] = malloc(hi[s] << 1);
	}
	
	memset(hi, 0, n << 1);
	j = 0; while (r--) {
		s = memo[j++], t = memo[j++], d = memo[j++];
		k = hi[s]++, to[s][k] = t, dt[s][k] = d;
		k = hi[t]++, to[t][k] = s, dt[t][k] = d;
	}
	free(memo);

	sz = k = n-1; if (k > 100) k >>= 1;
	for (s = 1; s <= k && sz; s++) dijkstra(s);

	printf("%d\n", sz);
	if (sz) for (s = 1; s < n; s++) if (!ans[s]) printf("%d\n", s);
	return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int e = scan.nextInt();
			if(e == 0){
				break;
			}
			int min = e;
			int a;
			int k;
			for(int i = (int)Math.cbrt(e);i >= 0;i--){
				a = i*i*i;
				for(int j = (int)Math.sqrt(e-a);j >= 0;j--){
					k = e-a-(j*j);
					if(k+(j*j)+a == e && i+j+k < min){
						min = i+j+k;
					}
				}
			}
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 26028
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int R, w, c, r;
	while(cin>>R>>w>>c>>r && r){
		for(int i = 0; i < 1e6; i++){
			if((R+i*r)>=c*w){
				cout<<i<<endl;
				break;
			}
		}
	}
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int mn = min(x, y);
    cout << min({
        a * x + b * y,
        a * (x - mn) + b * (y - mn) + c * mn * 2,
        max(x, y) * c * 2
    });
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
 
int main() {
  int a, b, m, i;
  cin >> a >> b >> m;
  vector<int> A(a);
  vector<int> B(b);

  for(i=0; i<a; i++) cin >> A[i];
  
  for(i=0; i<b; i++) cin >> B[i];
  int tmpa = 100001;
  int tmpb = 100001;
  int mint = 100001;
  for(i=0; i<a; i++){
    if(tmpa > A[i]) tmpa = A[i];
  }
  for(i=0; i<b; i++){
    if(tmpb > B[i]) tmpb = B[i];
  }
  mint = tmpa + tmpb;
  int x, y, c;
  for(i=0; i<m; i++){
    cin >> x >> y >> c;
    if(A[x-1]+B[y-1]-c <mint) mint = A[x-1]+B[y-1]-c;
    else mint;
  }
  cout << mint << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	bool flag=0;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		if(t%2==0){
			if(t%3!=0&&t%5!=0) flag=1;
		}
	}
	if(flag) cout<<"DENIED"<<endl;
	else cout<<"APPROVED"<<endl;
    return 0;
}


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

int main(void)
{
  char str[10000000];
  scanf("%s",str);
  int l=0,i,j;
  l = strlen(str);
  //01010101010になりたい
  int num1=0;
  for(i = 0;i <l;i ++)
  {
    if(i%2==0)
    {
      if(str[i]=='0')
      {
         num1++;
      }
    }else
    {
      if(str[i]=='1')
      {
        num1++;
      }
    }
  }
  //101010101010101010になりたい
  int num2=0;
  for(i = 0;i <l;i ++)
  {
    if(i%2==0)
    {
      if(str[i]=='1')
      {
        num2++;
      }
    }else
    {
      if(str[i]=='0')
      {
        num2++;
      }

    }
  }
  //101010101010101010になりたい
  if(num1>=num2)
  {
    printf("%d",num2);
  }else
  {
    printf("%d",num1);
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
    char h[200], a[200], b[200];
    int m, n, i, j, k, length;

    while (1){
        scanf("%s", h);

        if (!strcmp(h, "-")){
            break;
        }

        scanf("%d", &m);

        for (i = 0; i < m; i++){
            scanf("%d", &n);

            for (j = n; h[j] != '\0'; j++){
                a[j - n] = h[j];
            }

            for (k = 0; k < n; k++){
                a[j - n + k] = h[k];
            }

            for (j = 0; h[j] != '\0'; j++){
                h[j] = a[j];
            }
        }

        printf("%s\n", h);
    }

    return (0); 
}



Measured memory_bytes: 2696
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        int r = Integer.parseInt (reader.readLine());
        System.out.println (3 * (int)Math.pow (r, 2));
        return;
    }
}

Measured memory_bytes: 32588
N=int(input())
X,Y,H=[],[],[]
for i in range(N):
  XX,YY,HH=map(int,input().split())
  X.append(XX)
  Y.append(YY)
  H.append(HH)
for i in range(101):
  for j in range(101):
    ans=1
    m=0
    for l in range(N):
      if(H[l]!=0):
        m=abs(X[l]-i)+abs(Y[l]-j)+H[l]
        break
    for k in range(N):
      if(max(m-abs(X[k]-i)-abs(Y[k]-j),0)!=H[k]):
        ans=0
    if(ans):
      print(i,j,m)
      break

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  string taro[1000], hanako[1000];
  int n, score_t=0, score_h=0;

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

    if(taro[i] > hanako[i]){
      score_t += 3;
    }else if(taro[i] < hanako[i]){
      score_h += 3;
    }else{
      score_t += 1;
      score_h += 1;
    }
  }
  cout<<score_t<<" "<<score_h<<endl;
}

Measured memory_bytes: 3296
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int a = scan.nextInt();
      int b = scan.nextInt();

      if (a > b) {
         System.out.println("a > b");
      } else if (a < b) {
         System.out.println("a < b");
      } else {
         System.out.println("a == b");
      }
   }
}



Measured memory_bytes: 26148
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0016
	Integral
*/

#include <stdio.h>
int main(void)
{
	int d,x,i,y,sum;
	while (scanf("%d", &d) != EOF){
		x = 600 / d;
		sum = 0;
		for (i = 1; i < x; ++i)
		{
			y = i * d * i * d * d;
			sum += y;
		}

		printf("%d\n", sum);
	}

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vp;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

bool check(ll a)
{
    string s = to_string(a);
    REP(i, 1, sz(s)-1)
    {
        if(abs(s[i]-s[i-1]) > 1) return 0;
    }
    return 1;
}

ll next(ll a)
{
    string s = to_string(a);
    int ind;
    REPR(i, sz(s)-1, 1)
    {
        if(abs(s[i]-s[i-1]) > 1) ind = i;
    }
    // if(a == 90) watch(ind);
    string ret = s.substr(0, ind);
    ll num = stoll(ret, nullptr, 10); 
    {
        if(num%10 != 9) num++;
    }
    // ll num = 1;i
    // if(a == 90) watch(num);
    rep(i, sz(s)-ind)
    {
        num = num*10 + max(0ll, num%10 - 1);
    }
    return num;
}

int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    vl v;
    int cnt = 0;
    ll num = 1;
    while(cnt <= 1e5)
    {
        if(check(num)) {v.pb(num);num++;cnt++;}
        else num = next(num);
    }
    int n; cin>>n;
    cout<<v[n-1];
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
loop vars,1LL in mult, out of bounds, int v ll, endl, finish taking inputs, large doubles, larger INF
*/





Measured memory_bytes: 1528
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=5e5+5;
int min3(int a,int b,int c)
{
    return min(min(a,b),c);
}
int max3(int a,int b,int c)
{
    return max(max(a,b),c);
}
int gcd(int x, int y)
{
    if(y==0)return x;
    return gcd(y, x%y);
}
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
string s;
string s1="keyence";

int main()
{
    /*
    char s1[105];
    strcpy(s1,"keyence");
    */

    cin>>s;
    if(s.substr(0,7)==s1)return 0*printf("YES\n");

    if(s.substr(s.size()-7,7)==s1)return 0*printf("YES\n");

    for(int i=0; i<s.length()-7; i++)
    {
        if(s.substr(i,i+7)==s1)
        {
            return 0*printf("YES\n");

        }
    }

    for(int i=1; i<=6; i++)
    {
        string str=s.substr(0,i)+s.substr(s.length()-7+i);
        if(s1==str)
        {
            return 0*printf("YES\n");

        }
    }
    printf("NO\n");

    return 0;
}


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

#define R register

bool mp[2010][2010];
char s[2010];
int s1[2010][2010], s2[2010][2010], s3[2010][2010], s4[2010][2010];
int main()
{
	R int n, m, Q; scanf("%d%d%d", &n, &m, &Q);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j)
			mp[i][j] = s[j] - '0';
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			s1[i][j] = s1[i - 1][j] + s1[i][j - 1] - s1[i - 1][j - 1] + mp[i][j];
			s2[i][j] = s2[i - 1][j] + s2[i][j - 1] - s2[i - 1][j - 1] + (mp[i][j] && mp[i - 1][j]) + (mp[i][j] && mp[i][j - 1]);
			s3[i][j] = s3[i - 1][j] + (mp[i][j] && mp[i][j - 1]);
			s4[i][j] = s4[i][j - 1] + (mp[i][j] && mp[i - 1][j]);
		}
	}
	for (int i = 1; i <= Q; ++i)
	{
		int x_1, y_1, x_2, y_2; scanf("%d%d%d%d", &x_1, &y_1, &x_2, &y_2);
		int ans = s1[x_2][y_2] - s1[x_1 - 1][y_2] - s1[x_2][y_1 - 1] + s1[x_1 - 1][y_1 - 1];
//		printf("point %d %d ", ans, s1[x_2][y_2]);

		ans -= s2[x_2][y_2] - s2[x_1 - 1][y_2] - s2[x_2][y_1 - 1] + s2[x_1 - 1][y_1 - 1]
		- (s3[x_2][y_1] - s3[x_1 - 1][y_1]) - (s4[x_1][y_2] - s4[x_1][y_1 - 1]);
//		printf("edge %d\n", s2[x_2][y_2] - s2[x_1 - 1][y_2] - s2[x_2][y_1 - 1] + s2[x_1 - 1][y_1 - 1]
//		- (s3[x_2][y_1] - s3[x_1 - 1][y_1]) - (s4[x_1][y_2] - s4[x_1][y_1 - 1]));
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 68736