akhauriyash/Code-Regression huggingface dataset:
#-*- coding: utf-8 -*-
"""
https://atcoder.jp/contests/abc117/tasks/abc117_a
"""

def sol_naive(k, S):
    maxi = 0
    for x in range(k+1):
        ttl = 0
        for s in S:
            ttl += (x ^ s)
        maxi = max(maxi, ttl)
    return maxi


def keta(x):
    if x <= 0:
        return 0
    else:
        return 1 + keta(int(x/2))

def bin(x):
    return "{0:08b}".format(x)

def rec(k, S, b_keta, ans): # which digit
    #print("rec(%s, %s, %s, %s)" % (k, S, b_keta, ans))
    if b_keta == 0:
        #print("miso")
        return ans
    else:
        #print("soup")
        ones = 0
        for s in S:
            #print("checking %s and %s" % (bin(s), bin(1 << (b_keta-1))))
            if (1 << (b_keta-1) & s) > 0:
                #print("it's 1")
                ones += 1
        if ones < len(S) - ones: # should be set 1 in this digit
            if ans + (1 << (b_keta-1)) <= k:
                ans += (1 << (b_keta-1))
            #print("ans updated %s" % ans)
            return rec(k, S, b_keta-1, ans)
        else:
            return rec(k, S, b_keta-1, ans)


def sol(k, S):
    maxi = max(S)
    b_keta = keta(k)
    #print("find maxi(%s) and it's digit is %s and k is (%s)" % (maxi, b_keta, k))
    x = rec(k, S, b_keta, 0)
    ans = 0
    for s in S:
        ans += (x ^ s)
    return ans

test = False
#test = True
if test:
    n, k = 3, 7
    S =list( map(int, "1 6 3".split()))
    print(sol(k, S))

    n, k = 4, 9
    S =list( map(int, "7 4 0 3".split()))
    print(sol(k, S))
    #
    n, k = 1, 0
    S =list( map(int, "1000000000000".split()))
    print(sol(k, S))


else:
    n, k = map(int, input().split())
    S =list( map(int, input().split()))
    print(sol(k, S))




Measured memory_bytes: 14836
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  while(cin >> n >> m, n!=0 && m!=0){
    int t[n],h[m];
    int sumt = 0,sumh = 0,cht = 0,chh = 0,ch = 0;
    for(int i=0;i< n; i++){
      cin >> t[i];
      sumt += t[i];
    }
    for(int i=0;i<m;i++){
      cin >> h[i];
      sumh += h[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(sumt - sumh - 2*t[i] + 2*h[j] == 0){
	  if(ch == 0){
	    ch = t[i] + h[j];
	    cht = t[i];
	    chh = h[j];
	  }else if(ch > t[i] + h[j]){
	    ch = t[i] + h[j];
	    cht = t[i];
	    chh = h[j];
	  }
	}
      }
    }
    if(cht == 0){
      cout << -1 << endl;
    }else{
      cout << cht << " " << chh << endl;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll f(ll x){
	ll t=0;
	for(ll i=x/4*4;i<=x;i++) t^=i;
	return t;
}

ll a,b;

int main(){
	cin>>a>>b;
	cout<<(f(a)^f(b)^a)<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline

N = int(input())
n_np = np.zeros(105**3)
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            idx = i**2 + j**2 + k **2 + i*j + i*k + j*k
            n_np[idx-1] += 1
for i in range(N):
    print(int(n_np[i]))





Measured memory_bytes: 27428
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def make4(initial, L, M, N, O):
    return [[[[initial for i in range(O)]
                for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def make3(initial, L, M, N):
    return [[[initial for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    dp_use = [-IINF] * 5
    dp_not_use = [-IINF] * 5
    dp_not_use[0] = 0

    for k in range(N):
        dp_use_next = [-IINF] * 5
        dp_not_use_next = [-IINF] * 5
        for current_dif in range(-3,2):
            if current_dif-1 >= -3:
                dp_use_next[current_dif] = dp_not_use[current_dif - 1] + A[k]
            if current_dif+1 < 2:
                dp_not_use_next[current_dif] = max(dp_use[current_dif+1], dp_not_use[current_dif+1])
        dp_use = dp_use_next
        dp_not_use = dp_not_use_next

    dif = N//2 - (N-N//2)
    print(max(dp_use[dif], dp_not_use[dif]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 96936
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int a,b;
	cin >> a >> b;
	cout << 6-a-b;
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr[] = mylist.get(0).split(" ");
        long n = Long.valueOf(arr[0]);
        long k = Long.valueOf(arr[1]);
        long amari = n % k;
        long temp = Math.abs(amari - k);

//        System.out.println(temp + " " + amari);

        System.out.println(Math.min(amari, temp));

    }

}


Measured memory_bytes: 21076
#include<stdio.h>
int main()
{
  int a[1000], n, i, j, k, v;
  scanf("%d", &n);
  for(k = 0; k < n; k++)
    {
      scanf("%d",&a[k]);
    }
  for(k = 0; k < n-1; k++)
    {
      printf("%d ",a[k]);
    }
  printf("%d\n", a[n-1]);
  for(i = 1; i < n; i++)
    {
      v = a[i];
      j = i - 1;
      while (j >= 0 && a[j] > v)
	{
	  a[j+1] = a[j];
	  j--;
	  a[j+1] = v;
	}
      for(k = 0; k < n-1; k++)
	{
	  printf("%d ",a[k]);
	}
      printf("%d\n", a[n-1]);
    }
  return 0;
}



Measured memory_bytes: 2140
import sys
readlines = sys.stdin.buffer.readlines
input = sys.stdin.buffer.readline
N, Ma, Mb = map(int, input().split())
X = [map(int, line.split()) for line in readlines()]
X = [(a*Mb-b*Ma, c) for a, b, c in X]

INF = 1 << 30
MAX = 10000
MID = MAX//2
dp = [INF]*(MAX+1)
ans = INF
for i, (x, c) in enumerate(X):
    if x == 0:
        ans = min(ans, c)
        continue

    if x > 0:
        for j in range(MAX, x-1, -1):
            dp[j] = min(dp[j], dp[j-x]+c)
    else:
        for j in range(MAX+x):
            dp[j] = min(dp[j], dp[j-x]+c)

    dp[MID+x] = min(dp[MID+x], c)

ans = min(ans, dp[MID])
print(ans if ans < INF else -1)


Measured memory_bytes: 73460
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

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

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
int N, A;
vector<int> x;
vector<vector<ll>> dp;




//サブ関数
//入力
constexpr int MAX = 55;
void input()
{
	cin >> N >> A;
	int tmp;
	REP(i, N) {
		cin >> tmp;
		tmp -= A;
		x.push_back(tmp);
	}
}


//計算
void calc()
{
	map<int, ll> mpB, mpA;
	mpB[0] = mpA[0] = 1;

	for (auto num : x) {
		for (auto itr = mpB.begin(); itr != mpB.end(); ++itr) {
			int sum = itr->first + num;
			ll way = itr->second;
			if (mpA.find(sum) == mpA.end())mpA[sum] = way;
			else mpA[sum] += way;
		}
		mpB = mpA;
	}

	cout << mpB[0] - 1 << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 384
import sys
from collections import deque

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


def main():
    N, *A = map(int, read().split())

    B = deque([])
    for i, a in enumerate(A):
        if i % 2 == 0:
            B.append(a)
        else:
            B.appendleft(a)

    if N % 2 != 0:
        B = reversed(B)

    print(*B)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 111376
#include<iostream>
#include<algorithm>
#include <vector>
#include <set>
using namespace std;
long long MOD=1000000007;

int main(){
	int N;
	int max1=0;
	cin>>N;
	vector<int>A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
		max1=max(max1,A[i]);
	}
	int max2=0;
	int k=0;
	for(int i=0;i<N;i++){
	if(A[i]<max1)
		max2=max(max2,A[i]);
		if(max1==A[i])k=i;
	}
	//cout<<max2;
	sort(A.begin(),A.end(),greater<int>());
	if(A[0]==A[1]){
		for(int i=0;i<N;i++)cout<<max1<<endl;
	}
	else{
		for(int i=0;i<N;i++){
			if(i==k)cout<<max2<<endl;
			else cout<<max1<<endl;
		}
	}
	
	//1st
}


Measured memory_bytes: 2432
//与えられた数列を逆順に出力するプログラム

#include <stdio.h>

int main(void);

int main(void)
{
    int n, i;
    int a[100];//最大要素数は100


    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    for(i = n - 1; i > 0; i--){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[0]);

    return(0);
}


Measured memory_bytes: 2132
#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 DBG(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 mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

const int Nmax=334;
int buf[2][Nmax][Nmax];
vector<pi> qs[Nmax];

signed main(){
	int n=read(),m=read();
	REP(i,m){
		int l=read(),r=read(),x=read();
		qs[r].PB(pi(l,x));
	}
	int cur=0;
	buf[cur][0][0]=1;
	FOR(i,1,n+1){
		int nx=cur^1;
		memset(buf[nx],0,sizeof(buf[nx]));
		REP(j,i)REP(k,i)add(buf[nx][j][k],buf[cur][j][k]);
		REP(j,i)REP(k,i)add(buf[nx][i-1][k],buf[cur][j][k]);
		REP(j,i)REP(k,i)add(buf[nx][i-1][j],buf[cur][j][k]);
		for(auto q:qs[i])
			REP(j,i)REP(k,i){
				int cnt=1;
				if(q.first<=k)cnt++;
				if(q.first<=j)cnt++;
				if(cnt!=q.second)buf[nx][j][k]=0;
			}
		swap(cur,nx);
	}
	int ans=0;
	REP(i,n+1)REP(j,n+1)add(ans,buf[cur][i][j]);
	cout<<ans<<endl;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int a;
        cin>>a;
        cout<<(a+ (a*a)+(a*a*a))<<endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <sstream>
#include <deque>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
const int M = 1e9 + 7;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;


int main()
{
    fastio

    ll n;
    cin>>n;

    ll x=n%1000;

    if(x==0)
    {
        cout<<"0";
    }
    else
    {
        cout<<1000-x;
    }
    




 


       


 

        return 0;
    }

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 305;
ld dp[N][N][2];
int n, t[4];

void table() {
	for (int t3 = 0; t3 <= t[3]; t3++)
		for (int t2 = 0; t2 + t3 <= t[2] + t[3]; t2++)
			for (int t1 = 0; t1 + t2 + t3 <= n; t1++) {
				int t0 = n - (t1 + t2 + t3);
				ld &ans = dp[t1][t2][t3 % 2];
				if (t0 == n)
					ans = 0;
				else {
					ans = 1;
					if (t1)
						ans += dp[t1 - 1][t2][t3 % 2] * ((ld) t1 / n);
					if (t2)
						ans += dp[t1 + 1][t2 - 1][t3 % 2] * ((ld) t2 / n);
					if (t3)
						ans += dp[t1][t2 + 1][(t3 - 1) % 2] * ((ld) t3 / n);
					ans /= (1 - ((ld) t0 / n));
				}
			}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		t[a]++;
	}
	table();
	cout << fixed << setprecision(12) << dp[t[1]][t[2]][t[3] % 2];
	return 0;
}


Measured memory_bytes: 6216
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const double pi = acos(-1);
int main(){
  int ar[3];
  for(int i = 0;i < 3; ++i) scanf("%d", &ar[i]);
  sort(ar,ar + 3);
  int sisa = 2 * ar[2] - (ar[1] + ar[0]);
  if(sisa & 1) sisa += 3;
  printf("%d\n", sisa >> 1);
  return 0;
}

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

int main ()
{
   int n,x;
   set<int>s;
   cin>>n;
   while(n--)
   {
       cin>>x;
       if(s.count(x)==1)
       {
           s.erase(x);
       }
       else
       {
           s.insert(x);
       }
   }
   cout<<s.size();

   return 0;
}


Measured memory_bytes: 4864
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 998244353
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n; cin >> n;
	vint count(n+5);
	rep(i, n){
		int tmp; cin >> tmp;
		if(i == 0 && tmp != 0){
			cout << 0 << endl;
			return 0;
		}
		count[tmp]++;
	}
	if(count[0] != 1){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	ll idx = 1;
	while(1){
		if(count[idx] == 0) {
			rep2(i, idx, n){
				if(count[i] != 0) ans = 0;
			}
			break;
		}
		ans *= mod_pow(count[idx-1], count[idx]) % MOD;
		ans %= MOD;
		idx++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
from itertools import product

mod = 1000000007
H, W, K = map(int, input().split())
dp = {}
dp[0] = [1] + [0]*(W-1)

for h in range(1, H+1):
    dp[h] = [0] * W
    for pattern in product([0, 1], repeat=W-1):
        c = 0
        for p in pattern:            
            c = ((c + 1) if p == 1 else 0)
            if c >= 2:
                break            
        if c >= 2:
            continue
        for i in range(0, W):
            if i <= W-2 and pattern[i] == 1:
                dp[h][i] = (dp[h][i] + dp[h-1][i+1]) % mod
            elif i >= 1 and pattern[i-1] == 1:
                dp[h][i] = (dp[h][i] + dp[h-1][i-1]) % mod
            else:
                dp[h][i] = (dp[h][i] + dp[h-1][i]) % mod
print(dp[H][K-1])


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;


int main(){
    string s;
    cin >> s;
    int c = 0;
    rep(i, (int)s.size()){
        if(c == 0 && s[i] == 'C')   c++;
        if(c == 1 && s[i] == 'F')   c++;
    }

    cout << ((c == 2)? "Yes":"No") << endl;

    return 0;
}

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

int main() {
    
    int N;

    std::cin >> N;
    
    while (N--) {
        int a, b, c;
        std::cin >> a >> b >> c;
        
        int a2 = a * a;
        int b2 = b * b;
        int c2 = c * c;
        
        if (a2 == b2 + c2 || b2 == c2 + a2 || c2 == a2 + b2) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
    
    return 0;   
}

Measured memory_bytes: 1152
import Data.Functor

main :: IO ()
main = do
  (x:y:_) <- map read . words <$> getLine :: IO [Int]
  print $ gcd' x y

gcdGreed :: Int -> Int -> Int
gcdGreed x y = head [z | z <- reverse [1..(min x y)], mod x z == 0, mod y z == 0]

gcd' :: Int -> Int -> Int
gcd' x y = if x `mod` y == 0
           then y
           else gcd' y $! x `mod` y



Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if (a>=13)
	{
		printf("%d",b);
		return 0;
	}
	if (a>5)
	{
		printf("%d",b/2);
		return 0;
	}
	printf("0");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int a[]=new int[n];
        int s=0;
        for (int i = 0; i < a.length; i++) {
			a[i]=sc.nextInt();
			s+=a[i];
		}
        int mx=90000;
        mod=998244353;
//        mx=10;
        long dp[][]=new long[n+1][mx+301];
        long dp2[][]=new long[n+1][mx+301];
        dp[0][0]++;
        dp2[0][0]++;
        long ans=1;
        for (int i = 1; i <= n; i++) {
        	ans*=3; ans%=mod;
//        	dp[i-1][0]=1;
			for (int t = 0; t <= mx; t++) {
				dp[i][t+a[i-1]] += dp[i-1][t];
				dp[i][t] += 2*dp[i-1][t]; 
				dp[i][t+a[i-1]]%=mod;
				dp[i][t]%=mod;
				dp2[i][t+a[i-1]] += dp2[i-1][t];
				dp2[i][t] += dp2[i-1][t];
				dp2[i][t+a[i-1]]%=mod;
				dp2[i][t]%=mod;
			}
		}
        if(s%2==0)ans+=3*dp2[n][s/2];
        for (int i = (s+1)/2; i <= s ; i++) {
			ans-=3*dp[n][i];
	        ans%=mod;
		}
        ans=(ans+mod)%mod;
        db(s);
        out.println(ans);
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 558804
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {

        int inpt = int.Parse(Reader.ReadLine());
        int ans = 0;
        for (int i = 105; i <= inpt; i++) {
            if(i%2 ==0) {
                continue;
            }
            if(YakusuCount(i) == 8) {
                ans++;
            }
        }
        Console.WriteLine(ans);

    }


    private int YakusuCount(int num) {

        int ans = 0;
        bool isHeihou = false;
        for (int i = 1; i * i <= num; i++) {
                if(num % i == 0) {
                ans++;
                }
            if(i*i==num) {
                isHeihou = true;
            }
        }
        ans = ans * 2;
        if(isHeihou) {
            ans--;
        }
        return ans;
    }




    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"

200


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
int r,c,n;
vector<pair<int,int> >a;
stack<int>S;
main()
{
	cin>>r>>c>>n;
	for(int i=0;i<n;i++)
	{
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1!=0&&x1!=r&&y1!=0&&y1!=c)continue;
		if(x2!=0&&x2!=r&&y2!=0&&y2!=c)continue;
		int con1,con2;
		if(y1==0)con1=x1;
		else if(y1==c)con1=r+c+r-x1;
		else if(x1==0)con1=2*r+c+c-y1;
		else con1=r+y1;
		if(y2==0)con2=x2;
		else if(y2==c)con2=r+c+r-x2;
		else if(x2==0)con2=2*r+c+c-y2;
		else con2=r+y2;
		a.push_back(make_pair(con1,i));
		a.push_back(make_pair(con2,i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++)
	{
		if(S.size()>0&&S.top()==a[i].second)S.pop();
		else S.push(a[i].second);
	}
	cout<<(S.size()?"NO":"YES")<<endl;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<iostream>
using namespace std;
#define N 100
int main()
{
	int num[N];
	int i;
	int n;
	int j;
	int sw;
	int min;
	int a=0;
	cin >> n;
	for (i = 0;i < n;i++)
	{
		cin >> num[i];
	}
	for (i = 0;i < n-1;i++)
	{
		min = i;
		for (j = i + 1;j < n;j++)
		{
			if (num[j] < num[min])
			{		
				min = j;
			}
		}
		if (min != i)
		{
			sw = num[min];
			num[min] = num[i];
			num[i] = sw;
			a++;
		}
	}
	for (i = 0;i < n;i++)
	{
		if (i > 0)
			cout << " ";
		cout << num[i];
	}
	cout << endl;
	cout << a << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 3000 + 10;

int a[N],dp[N][N][2],n;
 
int dfs(int i,int j,int v){
   if(j < i) return 0;
   if(i<1 or i>n or j<1 or j>n) return 0;
   int &ans = dp[i][j][v];
   if(ans != -1){
      return ans;
   }
   if(v){
      return ans = min(dfs(i+1,j,1^v)-a[i],dfs(i,j-1,1^v)-a[j]);
   }else{
      return ans = max(dfs(i+1,j,1^v)+a[i],dfs(i,j-1,1^v)+a[j]);
   }
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   // #ifndef ONLINE_JUDGE
   //    freopen("input.txt", "r", stdin);
   //    freopen("output.txt", "w", stdout);
   // #endif
   cin >> n;
   f(i,1,n+1){
      f(j,1,n+1){
         f(k,0,2){
            dp[i][j][k] = -1;
         }
      }
   }
   f(i,1,n+1){
      cin >> a[i];
   }
   cout << dfs(1,n,0) << '\n';
   return 0;
}

Measured memory_bytes: 141824
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int digit_sum(int x) {
  int res = 0;
  while (x) res += x % 10, x /= 10;
  return res;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int K;
  cin >> K;
  vector<int> a;
  const int LIM = 1000000000000000;
  for (int i = 1; i < 1000; i++) {
    for (int j = 0; j < LIM; j = j*10+9) {
      string s = to_string(i);
      if (j != 0) s += to_string(j);
      if (s.size() < 16) a.push_back(stoll(s));
    }
  }
  UNI(a);
  const int az = a.size();
  int cnt = 0;
  for (int i = 0; i < az; i++) {
    bool ok = true;
    for (int j = i+1; j < az; j++) {
      if ((double) a[i] * digit_sum(a[j]) > (double) a[j] * digit_sum(a[i])) {
        ok = false;
        break;
      }
    }
    if (ok) {
      if (cnt >= K) break;
      cout << a[i] << endl;
      cnt++;
    }
  }

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long int ans = 0;
    for(int i=0; i<n; i++){
        long long int a;
        cin >> a;
        ans += a-i-1;
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
	// your code goes here
	int N = 0;
	int A = 0;
	int B = 0;
	cin>>N;
	cin>>A;
	cin>>B;
	int D = B - A;
  	if(D % 2 == 0)
    {
      cout<<"Alice";
    }
  	else
    {
      cout<<"Borys";
    }
  	return 0;
}


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

h, w = map(int, input().split())

if (h==1)or(w==1):
    print(1)
    exit()

allmas = h*w

if allmas % 2 == 1:
    print(int((allmas/2) + 0.5))
else:
    print(int(allmas/2))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    vector< stack<int> > player_matches(N, stack<int>());
    vector< pair<int, int> > matches;

    int player;

    // 入力を取得
    rep(i,N){
        rep(j,N-1){
            cin >> player;
            player_matches[i].push(player-1);
        }
    }

    // 現状誰が対戦出来るかを確認する。
    auto check = [&](int i) {
        if( player_matches[i].size() == 0 ){
            return;
        }
        int battler = player_matches[i].top();
       
        if( i == player_matches[battler].top()){
            P match = make_pair(i, battler);
            if ( match.first > match.second ) swap(match.first, match.second);
            matches.push_back(match);
        }

    };

    int days = 0;

    // ループで初回を処理するのが難しいため、初回は別に処理する。
    rep(i,N){
        check(i);
    }

    vector<pair<int,int>> next_candidates;

    // 1日ずつ大会を進める
    while(matches.size() > 0){// 対戦が無ければループを終わる
        // 1日進める
        days++;

        sort(matches.begin(), matches.end());
        matches.erase(unique(matches.begin(), matches.end()), matches.end());
        next_candidates = matches;

        // 対戦を処理する
        for(P match: next_candidates){
            player_matches[match.first].pop();
            player_matches[match.second].pop();
        }

        matches.erase(matches.begin(), matches.end());

        // 次に対戦可能なマッチを入れていく。
        for(P match: next_candidates ){
            check(match.first);
            check(match.second);
        }
        

        
    }

    // 全ての対戦可能な組み合わせが終わったにも関わらず、まだマッチが残っている場合には、消化できなかったということ。
    rep(i,N){
        if( player_matches[i].size() > 0 ){
            cout << "-1" << endl;
            return 0;
        }    
    }

    cout << days << endl;
}

Measured memory_bytes: 4736
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;

#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)n; i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll k, l, m, n;
const ll M = 1e9 + 7;

ll mini(ll a, ll b, ll c) {
    if(a < b) {
        if(a < c) return a;
        else return c;
    } else {
        if(b < c) return b;
        else return c;
    }
}

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

ll x, y;
cin >> n >> x >> y;

vl num(n, 0);
rep2(i, 1, n) {
    rep2(j, i + 1, n + 1) {
        num[mini(j - i, abs(j - x) + 1 + abs(i - y), abs(j - y) + 1 + abs(i - x))]++;
    }
}

rep2(i, 1, n) {
    cout << num[i] << endl;
}
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<int> T(n);
    REP(i, n) cin >> T[i];
    int m; cin >> m;
    vector<int> P(m), X(m);
    REP(i, m) cin >> P[i] >> X[i]; 
    int ans = whole(accumulate, T, 0);

    REP(i, m){
        int num = P[i] - 1;
        cout << ans + X[i] - T[num] << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n; cin>>n;
    int ans=0;
    for(int i=0; i<(int)n.size(); i++){
        ans+=n[i]-'0';
    }
    ans%=9;
    if(ans==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
#include <math.h>

int sosuu(int insuu);

int main(void) {
  int N,a[55],i;
  scanf("%d",&N);
  a[0] = sosuu(9);
  for (i = 1;i < N;i++) {
    a[i] = sosuu(a[i - 1]);
  }
  for (i = 0;i < N;i++) {
    printf("%d",a[i]);
    if (i < N - 1) printf(" ");
  }
  printf("\n");
  return 0;
}

int sosuu(int insuu)
{
	int b,c;

	for(b = insuu + 1;b <= 55555;b++)
	{
    if(b % 5 != 1) continue;
		for(c = 2;c <= sqrt(b);c++)
		{
			if(b % c == 0) break;
		}
  	if((int)(sqrt(b)) + 1 == c) break;
	}
	return b;
}


Measured memory_bytes: 256
#pragma region Preparation
/* competitive programming */
#include "bits/stdc++.h"
using namespace std;

/* using */
// long
using ll = long long;
using ld = long double;
// vector
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vld = vector<ld>;
using vs = vector<string>;
using vi2 = vector<vector<int>>;
using vll2 = vector<vector<ll>>;

/* define */
// array
#define ari(x) array<int, x>
#define ard(x) array<double, x>
#define arll(x) array<ll, x>
#define arld(x) array<ld, x>
#define ars(x) array<string, x>
#define ari2(x, y) array<array<int, y>, x>
#define arll2(x, y) array<array<ll, y>, x>
// int -> ll
#define int ll // int -> ll
// push_back系
#define pb(x) push_back(x)    // push_back
#define eb(x) emplace_back(x) // emplace_back
// all range
#define all(x) x.begin(), x.end() // all_range
// gcd, lcm
#define gcd(x, y) __gcd(x, y)         // gcd
#define lcm(x, y) (x / gcd(x, y) * y) // lcm
// PI
#define PI M_PI // PI
// 大文字・小文字変換
#define cup(x) toupper(x)                                              // char_toupper
#define clow(x) tolower(x)                                             // char_tolower
#define strup(x) *transform(x.begin(), x.end(), x.begin(), ToUpper())  // string_toupper
#define strlow(x) *transform(x.begin(), x.end(), x.begin(), ToLower()) // string_tolower
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// 大文字・小文字変換
struct ToUpper
{
    char operator()(char c) { return toupper(c); }
};
struct ToLower
{
    char operator()(char c) { return tolower(c); }
};
#pragma endregion

#pragma region External variables
/* A・B問題用外部変数 */
ll a, b, c, d, x, y; // 基本変数
ll n, k;             // 範囲・長さ・整数用
ll L, R;             // 左、右
string s;            // 文字列用
#pragma endregion

/* main */
void Main(void)
{
    cin >> a >> b >> c >> d;
    ll mx1 = max(a, b);
    ll mn1 = min(a, b);
    ll mx2 = max(c, d);
    ll mn2 = min(c, d);
    vll ans;
    ans.pb(mx1 * mx2);
    ans.pb(mx1 * mn2);
    ans.pb(mn1 * mx2);
    ans.pb(mn1 * mn2);
    ll ansmax = *max_element(all(ans));
    cout << ansmax << endl;
}

#pragma region main
signed main(void)
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0LL;
}
#pragma endregion


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

int main(void)
{
    int N;
    cin >> N;
    int B[N-1];
    for (int i = 0; i < N-1; i++) {
        cin >> B[i];
    }

    int A[N];
    A[0] = B[0];
    A[N-1] = B[N-2];
    for (int i = 1; i < N-1; i++) {
        A[i] = min(B[i-1], B[i]);
    }

    cout << accumulate(A, A+N, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
void prime_factorization(T n, unordered_map<T, int> &map) {
  for (T div = 2; div * div <= n; ++div) {
    if (n % div != 0) continue;
    int cnt = 0;
    while (n % div == 0) {
      ++cnt;
      n /= div;
    }
    map[div] += cnt;
  }
  if (n != 1) ++map[n];
}

int main(void) {
  int n;
  cin >> n;
  unordered_map<int, int> prime_num;
  rep1 (i, n) prime_factorization(i, prime_num);
  unordered_map<int, int> num;
  vector<int> check{2, 4, 14, 24, 74};
  allrep (p, prime_num) {
    allrep (x, check) {
      if (p.second >= x) ++num[x];
    }
  }
  int sum = 0;
  sum += num[4] * (num[4] - 1) / 2 * (num[2] - 2);
  sum += num[24] * (num[2] - 1);
  sum += num[14] * (num[4] - 1);
  sum += num[74];
  cout << sum << endl;
  return 0;
}

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

using pint = pair<int,int>;
int main() {
    int N, K; cin >> N >> K;
    int ma = (N-1)*(N-2) / 2;
    if (ma < K) cout << -1 << endl;
    else {
        vector<pint> res;
        for (int i = 1; i <= N-1; ++i) res.push_back({i, N});
        
        int rem = ma - K;
        int ci = 1, cj = 2;
        for (int _ = 0; _ < rem; ++_) {
            res.push_back({ci, cj});
            
            ++cj;
            if (cj == N) {
                ++ci;
                cj = ci + 1;
            }
        }
        
        cout << res.size() << endl;
        for (auto p : res) cout << p.first << " " << p.second << endl;
    }
}


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

int main(){
	char s[21];
	cin >> s;
	int len=strlen(s);

	for(int i=0;i<(len/2);i++){
		char c;
		c = s[i];
		s[i] = s[len-i-1];
		s[len-i-1] = c;
	}
	cout<<s<<"\n";
return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct LAKE {
	int start;	// start is negasitive integer.
	int end;	// end is positive integer.
	int square;
};

bool isInLake(int left, int right, vector<LAKE>& L, int& targetL) {
	for(int i=0; i<(int)L.size(); ++i) {
		if(L[i].start > left && L[i].end > right) {
			targetL=i;
			return true;
		}
	}
	targetL = -1;
	return false;
}

int main() {
	int n,max,min,h,k=0,S=0,idxL;
	string buf;
	LAKE tempL;
	vector<LAKE> L;
	vector<queue<int> > land;
	cin >> buf;
	n=(int)buf.size()+1;
	land.resize(2*n);
	h=0;
	max=n;
	min=n;
	for(int i=1; i<=n; ++i) {
		if(buf[i-1]=='/' ) {
			if(i!=1&&buf[i-2]=='/') ++h;
			land[n+h].push(i);
			if(n+h>max) { max=n+h; }
		} else if (buf[i-1]=='\\') {
			if(i!=1&&buf[i-2]!='/') --h;
			land[n+h].push(-i);
			if(n+h<min) { min=n+h; }
		} else if (buf[i-1]=='_') {
			if(i!=1&&buf[i-2]=='/') {
				++h;
			}
		}
	}
	for(int i=max; i>=min; --i) {
		int temp_l,temp_r;
		while(!(land[i].empty())) {
			temp_l=land[i].front();
			land[i].pop();
			if(temp_l<0 && !(land[i].empty()) ) {
				temp_r=land[i].front();
				land[i].pop();
				if(isInLake(temp_l,temp_r,L,idxL)==false) {
					tempL.start=temp_l;
					tempL.end=temp_r;
					tempL.square=temp_r+temp_l;
					L.push_back(tempL);
					++k;
				} else {
					L[idxL].square+=temp_r+temp_l;
				}
			}
		}
	}
	sort(L.begin(),L.end(),[](LAKE L1,LAKE L2) {
		return L1.end<L2.end;
	});
	for(int i=0; i<k; ++i) {
		S+=L[i].square;
	}
	printf("%d\n%d",S,k);
	for(int i=0; i<k; ++i) {
		printf(" %d",L[i].square);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 29936
//
//AtCoder Beginner Contest 137
//D - Summer Vacation
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> tbl(200000);
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        tbl[a-1].push_back(b);
    }

    priority_queue<int, vector<int>, less<int>> pq;
    int ans = 0;
    REP(i, m){
        for(int b : tbl[i]) pq.push(b);
        if (pq.empty()) continue;
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7936
module Main where

import Data.Bool
import Data.Functor

main :: IO ()
main =  do
  { [w,h,x,y,r] <- getInts
  ; putStrLn $ bool "No" "Yes" (and [x >= r, y >= r, x <= w - r, y <= h - r])
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3604
import java.util.*;
public class Main {
  
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long W = sc.nextLong();
    long H = sc.nextLong();
    long x = sc.nextLong();
    long y = sc.nextLong();

    int flag = 2*x == W && 2*y == H ? 1 : 0;

    System.out.println((double)W*H/2 + " " + flag);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
 
int main()
{
  char s[201], p[101];
 
  scanf("%s %s", s, p);
  sprintf(s, "%s%s", s, s);
  printf("%s\n", strstr(s, p) ? "Yes" : "No");
 
  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, t;
  cin >> n >> t;

  vector<int> vc;
  for (int i = 0; i < n; ++i) {
    int c, t2;
    cin >> c >> t2;
    if (t2 > t) {
      continue;
    }

    vc.push_back(c);
  }

  if (vc.size() == 0) {
    cout << "TLE" << '\n';
    return 0;
  }

  cout << *min_element(vc.begin(), vc.end()) << '\n';
  return 0;
}

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

int a[3][3];
int g[3][3];
int b[10];
int main() {
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  rep(i, n) cin >> b[i]; 

  rep(i, 3) {
    rep(j, 3) {
      rep(k , n) {
        if (a[i][j] == b[k]) g[i][j] = 1;
      }
    }
  }

  bool bingo = false;

  rep(i, 3) {
    int cnt = 0;
    rep(j, 3) {
      cnt += g[i][j];
    }
    if (cnt == 3) bingo = true;
  }

  rep(i, 3) {
    int cnt = 0;
    rep(j, 3) {
      cnt += g[j][i];
    }
    if (cnt == 3) bingo = true;
  }

  {
    int cnt = 0;
    rep(i, 3) {
      cnt += g[i][i];
    }
    if (cnt == 3) bingo = true;
  }

  {
    int cnt = 0;
    rep(i, 3) {
      cnt += g[i][2-i];
    }
    if (cnt == 3) bingo = true;
  }
  bingo ? cout << "Yes" << endl : cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256