akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n ; cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
        v[i] = v[i]-i-1;
    }
    sort(ALL(v));

    int b;
    if(n%2==0){
        b = v[n/2-1];
    }else{
        b = v[(n+1)/2-1];
    }
    ll ans = 0;
    for(int i = 0;i<n; i++){
        ans += abs(v[i]-b);
    }
    cout << ans << endl;
    return 0;
}

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

int main(int argc, char* argv[])
{
    long long n, p;
    scanf("%lld %lld",&n, &p);

    if(n==1) {
        printf("%lld\n", p);
        return 0;
    }

    long long a = 1;

    long flag[10000] = {0};
    flag[0] = flag[1] = 1;
    long i, j;
    for(i=2; i<5000; i++) {
        long tmp = i*2;
        while( tmp < 10000 ) {
            flag[tmp] = 1;
            tmp += i;
        }
    }

    for(i=0; i<10000; i++) {
        if( flag[i] ) {
            continue;
        }
        if ( n < flag[i] ) {
            break;
        }

        long count= 0;
        while( 1 ) {
            if( p % i == 0 ) {
                count ++;
                p = p / i;
            }
            else {
                break;
            }
        }
        long count2 = count / n;
        long k;
        for(k=0; k<count2; k++) {
            a = a * i;
        }
    }

    if ( p > 1 && n==2 ) {
        double s = sqrt((double)p);

        long long b = (long long)s;

        if (b * b == p ) {
            a = a * b;
        }
    }

    //printf("%d\n", p);
    printf("%d\n", a);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int cnt=1;
  sort(a.begin(),a.end());
  for(int i=1;i<n;i++){
    if(a[i-1]!=a[i]){
      cnt++;
    }
  }
  if(cnt%2==0){
    cout << cnt-1 << endl;
  }
  else{
    cout << cnt << endl;
  }
}

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


public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        Integer[] P = new Integer[N];
        for(int i=0;i<N;i++){
            P[i] = sc.nextInt();
        }
        int result = 0;
        int now = P[0];
        for(int i=0;i<N;i++){
            if(now>=P[i]) {
                result++;
                now = Math.min(now,P[i]);
            }
        }


        out.println(result);
        out.flush();
    }
        
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e18;
const ll SIZE = 1e5 + 5;
const ll MOD  = 1e9 + 7;

ll a, b;
double c;


int main() { speedhack()

	cin >> a >> c;
	b = (c * 100) + 0.5;

	a = a * b;
	a = a / 100;

	cout << a << endl;


	return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;

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

int main(){
    int D;
    ll G;
    cin >> D >> G;
    vector<int> ps(D, 0);
    vector<int> cs(D, 0);

    rep(i, D){
        cin >> ps[i] >> cs[i];
    }

    int last = (1 << D);
    int ans = (1 << 31) - 1;
    rep(i, last){
        ll score = 0;
        bitset<11> pt(i);
        int ncmp = -1;
        int tmp_ans = 0;
        rep(j, D){
            if(pt[j]){
                score += 100 * (j + 1) * ps[j] + cs[j];
                tmp_ans += ps[j];
            }
            if(pt[j] == 0){
                ncmp = max(ncmp, j);
            }
        }
        int tmp = 100 * (ncmp + 1);
        ll delta = (G - score + tmp - 1) / tmp;
        if(score < G && delta < ps[ncmp]){
            tmp_ans += delta;
            score += delta * tmp;
        }
        if(score >= G){
            ans = min(ans, tmp_ans);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
       int n,l;
       cin>>n>>l;
       string s1[n];
       for(int i=0;i<n;i++)
       {
           cin>>s1[i];
       }
       sort(s1,s1+n);
       string s;
       for(int i=0;i<n;i++)
       {
           s.append(s1[i]);
       }
       cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Position this line where user code will be pasted.


int main() {
    
	string s;
    cin>>s;

    vector<int > a(26, 0);

    int sz = s.size();

    for(int i=0;i<sz;i++){
        a[s[i] - 'A']++;
    }

    int c = 0;
    for(int i=0;i<26;i++){
        if(a[i] == 2) c++;
    }
    if(c == 2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

#define ll long long
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2 scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%ld",n)
#define prln(n) printf("%ld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)




int main()
{
    char s[1000000];
    scanf("%s",s);
    int len=strlen(s);
    int x,y;
    x=y=0;
    map<char,int>mp;
    fo(i,0,len)
    {
        if(s[i]=='S')x++;
        if(s[i]=='N')x--;
        if(s[i]=='E')y++;
        if(s[i]=='W')y--;
        mp[ s[i] ]++;
    }

    if ( mp['N'] && mp['S'] && !mp['E'] && !mp['W'] )
    puts("Yes");
    else if( !mp['N'] && !mp['S'] && mp['E'] && mp['W'] )
    puts("Yes");
    else{
        if(!x && !y)
        puts("Yes");
        else
        puts("No");
    }
    return 0;
}















Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int sum = 0, cnt = 0;
    double k = 0;
    string str, n;
    while(cin >>str){
        k++;
        stringstream ss(str);
        vector<int> v;
        while(getline(ss, n, ',')) v.push_back(atoi(n.c_str()));
        sum += (v[0] * v[1]);
        cnt += v[1];
    }
    cout <<sum <<endl <<round(cnt / k) <<endl;
    return 0;
}

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

int main(){
    int n,a,min=9999,p;
    int ans=0;

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >>a;
        p=0;
        while (a%2==0){
            a/=2;
            p++;
        }
        if(p<min)min=p;
    }

    cout << min <<endl;
    return 0;
}


Measured memory_bytes: 256
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
a,b,k = arrIN()
if a>=k:
    a-=k
    print(a,b)
    exit(0)
k-=a
a = 0
b-=min(b,k)
print(a,b)

Measured memory_bytes: 402840
from collections import deque

s = input()
Q = int(input())
query = [list(map(str, input().split())) for _ in range(Q)]

d = deque(s)

cnt = 0
for q in query:
    if q[0] == '1':
        cnt += 1
    else:
        if q[1] == '1':
            if cnt % 2:
                d.append(q[2])
            else:
                d.appendleft(q[2])
        else:
            if cnt % 2:
                d.appendleft(q[2])
            else:
                d.append(q[2])
        
d_list = list(d)
s = ''.join(d_list)
if cnt % 2 == 0:
    print(s)
else:
    print(s[::-1])

Measured memory_bytes: 117976
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

 int a[5],k;
 for(int i=0;i<5;++i) cin>>a[i];
 cin>>k;
 
 for(int i=0;i<5;++i)
 for(int j=i+1;j<5;++j)
 if(abs(a[i]-a[j])>k){
     cout<<":("<<endl;
     return 0;
 }

cout<<"Yay!"<<endl;
 
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;

int main(void){
	int n, k;
	cin >> n >> k;
	cout << n-k+1 << endl;

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  lines = input.split(" ")
  a = lines[0] * 1
  b = lines[1] * 1
  t = lines[2] * 1
  ans = 0
  for(var i = 1; i <= t; i++) {
    if (i%a==0) {
      ans = ans + b
    }
  }
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import math

n = int(input())
k = int(input())
x = list(map(int,input().split()))
cnt = 0

dis = math.ceil(k/2)
for i in x:
    if i == k:
        continue
    elif i <= dis:
        cnt += i*2
    else:
        cnt += (k-i)*2
print(cnt)


Measured memory_bytes: 9108
import sys

mat=[]
for i in range(3):
  array=list(map(int,input().split()))
  mat.append(array)
  
N=int(input())
bset=set()
for i in range(N):
  b=int(input())
  bset.add(b)
  
#print(mat)
#print(bset)

#yoko
for i in range(3):
  for j in range(3):
    if not mat[i][j] in bset:
      break
  else:
    print("Yes")
    sys.exit()
    
#tate
for i in range(3):
  for j in range(3):
    if not mat[j][i] in bset:
      break
  else:
    print("Yes")
    sys.exit()
    
#naname
for i in range(3):
  if not mat[i][i] in bset:
    break
else:
  print("Yes")
  sys.exit()
for i in range(3):
  if not mat[i][2-i] in bset:
    break
else:
  print("Yes")
  sys.exit()
  
print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (a>b){
        cout << "a > b" << "\n";
    }
    if (a<b){
        cout << "a < b" << "\n";
    }
    if (a==b){
        cout << "a == b" << "\n";
    }    
    return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100;

int main(void){
    ll N;
    ll A[2][MAX_N];
    ll L[MAX_N], R[MAX_N];
    ll answer = 0;

    cin >> N;
    rep(j, 2) rep(i, N) cin >> A[j][i];

    L[0] = A[0][0];
    R[0] = A[1][N - 1];
    rep(i, N - 1){
        L[i + 1] = L[i] + A[0][i + 1];
        R[i + 1] = R[i] + A[1][N - 2 - i];
    }
    rep(i, N){
        answer = max(answer, L[i] + R[N - i - 1]);
    }

    cout << answer << endl;

    return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 59;

int64 N, A[401];
int64 dp[400][400];

int64 getCost(int l, int r) {
  return A[r + 1] - A[l];
}

int64 rec(int l, int r) {
  if(l == r) return 0;
  if(~dp[l][r]) return dp[l][r];
  int64 ret = INF;
  for(int i = l + 1; i <= r; i++) {
    ret = min(ret, rec(l, i - 1) + rec(i, r) + getCost(l, r));
  }
  return dp[l][r] = ret;
}

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i + 1];
  for(int i = 1; i <= N; i++) A[i] += A[i - 1];
  memset(dp, -1, sizeof(dp));
  cout << rec(0, N - 1) << endl;
}



Measured memory_bytes: 1536
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        HashSet hs = new HashSet();
        for(int i = 0; i < n; i++){
        	hs.add(sc.next());
        }
        if(n == hs.size()){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 78196
#include <iostream>
using namespace std;
typedef long long LL;
LL  a,b,c,d;
LL solve(LL a,LL b,LL subject){
    if(a == 1){
        return b/subject;
    }
    else{
        return b/subject - (a-1)/subject;
    }
}
LL LCM(LL e,LL f){
    LL tmp=1;
    LL g,h;
    if(f>e){
        g = f;
        h = e;
    }
    else{
        g = e;
        h = f;
    }
    while(tmp != 0){
        tmp = g%h;
        g = h;
        h = tmp;
    }
    /*cout << g << endl;
    cout << e/g << endl;
    cout << f/g << endl;
    */
    return (e/g)*f;
}

int main(){
    cin >> a >> b >>c >> d;
    LL  i_c = solve(a,b,c);
    LL i_d = solve(a,b,d);
    LL cd = LCM(c,d);
    LL i_cd = solve(a,b,cd);
    LL ans = (b-a+1) - i_c - i_d + i_cd;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
t=input()
dp=[[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

res=""
i=len(s); j=len(t)
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        res="".join([s[i-1],res])
        i-=1
        j-=1
print(res)

Measured memory_bytes: 113244
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	vector<int> num(100010,-1);
	rep(i,N){
		num[A[i]]++;
	}
	int cnt = 0;
	rep(i,100010){
		if(num[i] > 0) cnt += num[i];
	}
	cout << (cnt % 2 == 0 ? N-cnt : N-cnt-1) << endl;
}

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

int main() {
  // 入力部(N)
  int N;
  cin >> N;

  // 条件を満たすパターンの数をカウントする変数
  int cnt = 0;

  // 1~9までのループを行う。
  for(int i = 1; i < 10; i++) {

    // iでちょうど割り切れて、Nをiで割ったあまりが9以下の時、
    // この i と N/iの演算結果 に積は N になり、
    // Nをiで割ったあまりなので問題文の条件を満たす。
    if(N % i == 0 && N / i < 10) {

      //cnt(条件を満たすパターンの数をカウントする変数) に1を加算
      cnt++;

    }
  }

  if(cnt) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=1000;i++)
	{
		if(a*i%b==c)
		{
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()
 

const ll MOD = (ll)(1e9 + 7); 
const ll N = 0;

int main()
{
	FIO;
	int n;
	cin >> n;
	if(n%2 == 1) {
		cout << ((n/2) + 1.00) / n << "\n";
	} else {
		cout << "0.5\n";
	}
	return 0;	
}	

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

//#define int long long
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, k;
    cin >> n >> k;
    
    set<string> like;
    rep(i,10) like.insert(to_string(i));
    rep(i,k){
        string d; cin >> d;
        like.erase(d);
    }
    
    queue<string> q;
    for(string s : like) q.push(s);
    
    while(true){
        int i = stoi(q.front());
        if(n <= i){
            cout << i << endl;
            break;
        }
        if(q.front() != "0"){
            for(string s : like){
                q.push(q.front() + s);
            }
        }
        q.pop();
    }
}

Measured memory_bytes: 3456
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
set<string> S;

int main() {
  INCANT;
  cin >> N;
  string a;
  rep(i, N) {
    cin >> a;
    S.insert(a);
  }
  cout << S.size() << "\n";
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string S;
    cin >> S;
    ll nWin = 0;
    for(auto c : S){
        if(c=='o') nWin++;
    }
    if(nWin + (15-S.size()) >= 8){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		
      	if((a * b) % 2 == 0){
          		// 出力
		System.out.println("Even");
        }
        else{
                // 出力
		System.out.println("Odd");
        }
 
	}
}

Measured memory_bytes: 35660
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string N;
    cin >> N;
    ll sum = 0;
    rep(0, i, N.size())
    {
        sum += ((ll)N.at(i) - '0');
    }

    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3732
#include <stdio.h>

int main(void) {
    char a[3];
    scanf("%s", a);
    int count = 700;
    for(int i = 0; i < 3; i++){
        if(a[i] == 'o'){
            count += 100;
        }
    }
    printf("%d\n", count);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define reps(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) for(int i=0;i<int(b);i++)
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
#define M 998244353
#define N 1000000007
ll dp[2005][2005] = {};
int main()
{
    csl;
    ll n;
    cin >> n;
    pll a[n+1];
    reps(i,1,n+1)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a+1,a+n+1,greater<pll>());
    reps(i,1,n+1)
    {
        reps(j,0,i)
        {
            ll L = j;
            ll R = i-1-j;
            dp[L+1][R] = max(dp[L+1][R],dp[L][R] + abs(L+1-a[i].second)*a[i].first);

              R = j;
              L = i-1-j;
              dp[L][R+1] = max(dp[L][R+1],dp[L][R] + abs(n - R - a[i].second)*a[i].first);
        }
    }

    ll cnt = 0;
    rep(i,n+1)
    {
        cnt = max(cnt,dp[i][n-i]);
    }

    cout << cnt << endl;

}


Measured memory_bytes: 26332
import sys

def gcd(a, b):
    while b % a:
        a, b = b % a, a
    return a
def lcm(a, b):
    return a * b // gcd(a, b)

for line in sys.stdin:
    a, b = sorted(list(map(int, line.split())))
    print(gcd(a, b), lcm(a, b))

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
  
typedef long long ll;
typedef pair<int, int> ii;
 
#define DEBUG false
 
#define MAXI 1000001
 
vector<ll> prime;
 
int main(){
 
    ll l;
    bool used[MAXI] = {false};
    REP(i, 2, MAXI){
        if(!used[i]) prime.push_back(i);
        for(int j = 2; i * j < MAXI; j++) used[i*j] = true;
    }
     
    while(cin >> l, l){
        ll tmp = l;
        ll ans = 1;
        ll mul = 1;
        rep(i, prime.size()){
        	ll cnt = 0;
            while(tmp != 1 && tmp % prime[i] == 0) {
                cnt++;
                tmp /= prime[i];
            }
            mul *= (cnt * 2 + 1);
        }
        if(tmp >= MAXI) mul *= 3;
        ans += mul;
        cout << ans / 2 << endl;
    }
     
     
     
    return 0;
}

Measured memory_bytes: 4664
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007


int i,j,k,l;
static const int MAX_N=10e2;
int L[MAX_N];
int main(void){
	int N;cin >> N;
	rep(i,0,N){
		cin >> L[i];
	}sort(L,L+N);
	
	int ans=0;
	_rep(i,N-1,1){
		_rep(j,i-1,0){
			if(L[i]==L[j])continue;
			_rep_(k,j-1,0){
				if(L[i]>=L[j]+L[k])
					break;
				else if(L[i]==L[k] || L[j]==L[k])continue;
				ans++;
			}
		}
	}puts(ans);
	return 0;
}


Measured memory_bytes: 3644
def cout(num, d):
    if num%2==0:
        return d+1
    else:
        return d
count=0

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

for i in A:

    j = i
    while j%2==0:
        count = cout(j,count)
        j=j/2

print(count)


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

#define UNION_FIND_MAX_N 100005

struct union_find {

  int par[UNION_FIND_MAX_N];
  int ran[UNION_FIND_MAX_N];
  int num[UNION_FIND_MAX_N];

  union_find(int __n) { init(__n); }

  void init(int n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      ran[i] = 0;
      num[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;

    if (ran[x] < ran[y]) {
      par[x] = y;
      num[y] += num[x];
      num[x] = 0;
    } else {
      par[y] = x;
      num[x] += num[y];
      num[y] = 0;
      if (ran[x] == ran[y])
        ran[x]++;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }
};

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  ll n, m;
  cin >> n >> m;
  vector<pii> ab(m);
  REP(i, m) {
    cin >> ab[i].first >> ab[i].second;
    ab[i].fst--;
    ab[i].snd--;
  }
  reverse(all(ab));

  union_find uf = union_find(n);

  vll ans(m, n);
  ll a = n * (n - 1LL) / 2LL;

  REP(i, m) {
    ans[m - 1 - i] = a;
    if (!uf.same(ab[i].fst, ab[i].snd)) {
      ll nf = uf.num[uf.find(ab[i].fst)];
      ll ns = uf.num[uf.find(ab[i].snd)];
      a += nf * (nf - 1LL) / 2LL + ns * (ns - 1LL) / 2LL;
      uf.unite(ab[i].fst, ab[i].snd);
      ll na = uf.num[uf.find(ab[i].fst)];
      a -= na * (na - 1LL) / 2LL;

      // cout << nf << " " << ns << " " << na << " " << (na * (na - 1) / 2)
      //      << endl;
    }
  }

  // reverse(all(ans));

  REP(i, m) cout << ans[i] << endl;

  return 0;
}


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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  for(int i=0;i<k;i++){
    if(b<=a&&c<=a){
      a*=2;
    }
    else if(a<=b&&c<=b){
      b*=2;
    }
    else{
      c*=2;
    }
  }
  cout << a+b+c <<endl;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
r,s,p = map(int, input().split())
t = list(input())
a = [1]*n
for i in range(k,n):
    if t[i] == t[i-k] and a[i-k] == 1:
        a[i] = 0
ans = 0
for j in range(n):
    if t[j] == 'r' and a[j] == 1:
        ans += p
    elif t[j] == 's' and a[j] == 1:
        ans += r
    elif t[j] == 'p' and a[j] == 1:
        ans += s
print(ans)

Measured memory_bytes: 10392
/*Author : Yuvraj Singh
 * Patience is Power
 * 
 * */
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
#define ar array
ll power(ll x,ll y) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return ((temp%mod)*(temp%mod))%mod; 
    else
        return ((x%mod)*(temp%mod)*(temp%mod))%mod; 
}

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}


bool cmp(pair<int,int>a,pair<int,int>b){
	return a.second<b.second;
}



#define mm 998244353
void solve(){
	ll n,x,m;
	cin>>n>>x>>m;
	ll res=0;
	ll i=0;
	vector<ll>v;
	ll tmp=x;
	vector<ll>::iterator it;
	while(i<n){
		it = find(v.begin(),v.end(),tmp);
		if(it!=v.end()) break;
		res+=tmp;
		v.push_back(tmp);
		tmp = tmp*tmp%m;
		i++;
		

	}
	if(i==n){
		cout<<res; return;
	} 
	else{
		ll sum=0;
		ll diff = v.end()-it;
		for(auto tt=it;tt!=v.end();tt++)
			sum+=*tt;
		ll d=(n-i)/diff;
		res+=d*sum;
		ll rim=(n-i)%diff;
		auto tt=it;
		for(ll j=0;j<rim;j++){
			res+=*tt;
			++tt;
		}
		cout<<res; return;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	//int t; cin>>t;
	//while(t--)
		solve();
    return 0;
}

Measured memory_bytes: 3844
#include <stdio.h>

int S, h, m, s, c;
int main(){
    scanf("%d", &S);
	h = S/60/60;
	m = S/60-h*60;
	s = S-h*60*60-m*60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}



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

int main(){
  int n, k; cin >> n >> k;
  vector<int> a(n); rep(i,n) cin >> a[i];
  vector<bool> ans(k+1,false);
  rep(i,k) if(!ans[i]) rep(j,n) if(i+a[j] <= k) ans[i+a[j]] = true;
  cout << (ans[k] ? "First" : "Second") << endl;
  return 0;
}

Measured memory_bytes: 3628
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
using ll = long long;
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int a, b, c;
    cin >> a >> b >> c;
    if(a == b and a == c)
    {
        cout << "No";
        return 0;
    }
    if(a == b or b == c or a == c)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";

    return 0;
}

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

const ll INF = 1e18;
const int MX = 2005;

ll c2(ll n){
  return n * (n-1) / 2;
}

int main() {
  ll n;
  cin >> n;
  ll a[n];
  ll cnt[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
    cnt[i] = 0;
  }
  rep(i,n){
    cnt[a[i]]++;
  }
  ll tot = 0;
  rep(i,n){
    tot += c2(cnt[i]);
  }
  rep(i,n){
    ll ans = tot;
    ans -= c2(cnt[a[i]]);
    ans += c2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5760
h, w = [ int(v) for v in input().split() ]
field = [ list(input()) for i in range(h) ]
ans = "Yes"

for i in range(h):
	for j in range(w):
		if field[i][j] == "#":
			adjust = [ (i-1,j), (i,j-1), (i,j+1), (i+1,j) ]
			adjust = [ field[k[0]][k[1]] for k in adjust if 0 <= k[0] < h and 0 <= k[1] < w ]
			if adjust.count("#") == 0:
				ans = "No"
				break
print(ans)

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int a,b,c;

int main() {
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << '\n';
    } else if (b == c) {
        cout << a << '\n';
    } else {
        cout << b << '\n';
    }

    return 0;
}


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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

template<typename T>
void swap(T*,T*);

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    vector<int> complete(N);
    rep(i,N)
    {
        cin >> v.at(i);
        complete.at(i) = v[i];
    }
    SORT(complete);
    int count = 0;
    rep(i,N)
    {
        if(v[i] != complete[i])
        {
            count++;
        }
    }
    if(count <= 2)
    {
        YES(true);
    }
    else
    {
        YES(false);
    }
}

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

namespace Competition
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = nm[0]; var M = nm[1];

            var ab = Enumerable.Repeat(0, M).Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).OrderBy(a => a[1]).ToArray();

            var bridge = new bool[N - 1];
            var count = 0;
            for (var m = 0; m < M; m++)
            {
                var ok = true;
                for (var a = ab[m][0] - 1; a < ab[m][1] - 1; a++)
                {
                    if (bridge[a])
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    bridge[ab[m][1] - 2] = true;
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 28728
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto comp = [](const pair<int,int>& l,const pair<int,int>& r){return l.first==r.first ? l.second<r.second : l.first<r.first;};
	vector<pair<int,int>> P(N);
	map<pair<int,int>,int,decltype(comp)> x(comp);
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
	}
	REP(i,N){
		for(int j=0;j<N;j++){
			if(i==j) continue;
			x[make_pair(P[j].first-P[i].first,P[j].second-P[i].second)]++;
		}
	}
	int max_num = 0;
	for(auto& y:x){
		max_num = max(max_num,y.second);
	}
	out(N-max_num);
	
	return 0;
}


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

int main() {
    
    long long int n,i,j=1;
    cin>>n;
    i=pow(n,0.5);
    long long int arr[i];
    arr[0]=n+1;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            arr[j++]=(i+(n/i));
        }
    }
    sort(arr,arr+j);
    cout<<arr[0]-2;


  return 0;
    
}
    


Measured memory_bytes: 2304
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()

const int maxsize=200000+16;

int n,m;
int a[maxsize];
int w,e[maxsize],c[maxsize];

void add(int p)
{
	++c[p];
	int d=p-c[p];
	if (d>=0 && d<n && (++e[d])==1) ++w;
}
void del(int p)
{
	int d=p-c[p];
	--c[p];
	if (d>=0 && d<n && (--e[d])==0) --w;
}
int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	REP(i,n) cin>>a[i];
	memset(e,0,sizeof(e));
	memset(c,0,sizeof(c));
	w=0;
	REP(i,n) add(a[i]);
	REP(step,m)
	{
		int x,y;
		cin>>x>>y;
		--x;
		del(a[x]);
		a[x]=y;
		add(a[x]);
		printf("%d\n",n-w);
	}
	return 0;
}



Measured memory_bytes: 3840
#include<stdio.h>
int main(){
  int n,m,i,j,k,l,d[110][110],p[60][60],min;
  while(scanf("%d %d",&n,&m),n){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++)scanf("%d",&d[i][j]);
    }
    for(i=0;i<m;i++){
      for(j=0;j<m;j++)scanf("%d",&p[i][j]);
    }
    for(i=0;i+m<=n;i++){
      for(j=0;j+m<=n;j++){
	min=1e9;
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(p[k][l]==-1)continue;
	    if(d[i+k][j+l]-p[k][l])goto NX1;
	  }
	}
	for(k=0;k<m;k++){
	  if(p[0][k]+1)min=min<k?min:k;
	}
      NX1:;
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(p[l][m-k-1]==-1)continue;
	    if(d[i+k][j+l]-p[l][m-k-1])goto NX2;
	  }
	}
	for(k=0;k<m;k++){
	  if(p[k][m-1]+1)min=min<k?min:k;
	}
      NX2:;
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(p[m-k-1][m-l-1]==-1)continue;
	    if(d[i+k][j+l]-p[m-k-1][m-l-1])goto NX3;
	  }
	}
	for(k=0;k<m;k++){
	  if(p[m-1][m-k-1]+1)min=min<k?min:k;
	}
      NX3:;
	for(k=0;k<m;k++){
	  for(l=0;l<m;l++){
	    if(p[m-l-1][k]==-1)continue;
	    if(d[i+k][j+l]-p[m-l-1][k])goto NX4;
	  }
	}
	for(k=0;k<m;k++){
	  if(p[m-k-1][0]+1)min=min<k?min:k;
	}
      NX4:;
	if(min-1e9)goto END;
      }
    }
    printf("NA\n");
    continue;
  END:;
    printf("%d %d\n",j+min+1,i+1); 
  }
  return 0;
}

Measured memory_bytes: 672
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

int main() {
    const string str[] = {
        "KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA",
        "AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA",
    };
    
    string s;
    cin >> s;
    
    for (auto t: str) {
        if (t == s) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    int max=-1;
    int sum=0;
    cin >> n;
    int l[n];
    REP(i,n){
        cin >> l[i];
        if(l[i]>max)max=l[i];
        sum+=l[i];
    }
    if(max < sum-max)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int a, b, s = 0;
  cin >> a >> b;
  if(a == 1) s += 300000;
  else if(a == 2) s += 200000;
  else if(a == 3) s += 100000;
  if(b == 1) s += 300000;
  else if(b == 2) s += 200000;
  else if(b == 3) s += 100000;
  if(a == 1 && b == 1) s += 400000;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

using namespace std;

const long long MM = 1e9+7;

long long gcd(long long a, long long b, long long & x, long long & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    long long x1, y1;
    long long d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

long long inverse(long long a) {
  long long x,y;

  gcd(a, MM, x, y);
  return (x+MM)%MM;
}

int main() {

  int N, W, H;

  cin >> H >> W >> N; N++;
  vector<pair<int, int>> wall(N);

  wall[N-1].first = H;
  wall[N-1].second = W;

  for(auto i=0; i<N-1; i++) cin >> wall[i].first >>  wall[i].second;

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

  vector<long long> fac(3e5+1, 1), facinv(3e5+1, 1);
  for(auto i=1;i<3e5+1;i++) {
    fac[i] = (fac[i-1]*i) % MM;
    facinv[i] = inverse(fac[i]); 
  }

  auto nchoosek = [&fac, &facinv](long long x, long long y) { 
    return (( (fac[x+y] * facinv[x] ) % MM) * facinv[y] ) % MM;
    };

  vector<long long> F_on(N+1, 0), F_off(N+1, 0);

  for (auto i=0; i < N; i++) {
    for (auto j=0; j< i; j++) {
      long long dx = wall[i].first - wall[j].first;
      long long dy = wall[i].second - wall[j].second;
      if (dx >= 0 && dy >=0){
        F_on[i] += (F_off[j] * nchoosek(dx, dy)) % MM;
        F_on[i] %= MM;
      }

    }
    F_off[i] = nchoosek(wall[i].first-1, wall[i].second-1) - F_on[i];
    F_off[i] = (F_off[i] + MM)  % MM;
  }

  cout << F_off[N-1] << endl;

  return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    private static int DAY_MAX = 100;

    public static void main(String[] args) {
        while (true) {
            int N = scanner.nextInt();
            int Q = scanner.nextInt();
            if (N == 0 && Q == 0) return;

            int[] calendar = new int[DAY_MAX];
            for (int n = 0; n < N; n++) {
                int M = scanner.nextInt();

                for (int m = 0; m < M; m++) {
                    int date = scanner.nextInt();
                    calendar[date] += 1;
                }
            }

            int maxAttendee = -1;
            int heldDay = -1;
            for (int day = 0; day < DAY_MAX; day++) {
                int attendee = calendar[day];

                if (attendee > maxAttendee) {
                    maxAttendee = attendee;
                    heldDay = day;
                }
            }

            System.out.println(maxAttendee >= Q ? heldDay : 0);
        }
    }

}



Measured memory_bytes: 69636
import java.util.Scanner;

//Unable Count
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			if((n|a|b)==0)break;
			boolean[] p = new boolean[n+1];
			p[0] = true;
			int c = 0;
			for(int i=1;i<=n;i++){
				if(i-a>=0&&p[i-a])p[i]=true;
				if(i-b>=0&&p[i-b])p[i]=true;
				if(!p[i])c++;
			}
			System.out.println(c);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include <stdio.h>                                                                     
#include <stdlib.h> 
 
void* smalloc ( size_t size ) 
{ 
    void* pntr = malloc( size );  
    if ( pntr == NULL ) 
    {   
        fputs( "malloc failed.\n", stderr );  
        exit( EXIT_FAILURE );  
    }   
    return pntr; 
} 
 
void sorter ( int* data, int elements ) 
{ 
    int i, j, cmp, key; 
 
    for ( i = 0; i < elements; i++ ) 
    {   
        key = data[i]; 
 
        for ( j = i; j > 0; j-- ) 
        {   
            cmp = data[j - 1]; 
            if ( key < cmp ) 
            {   
                break; 
            }   
            else 
            {   
                data[j] = cmp; 
            }   
        }   
 
        data[j] = key; 
    }   
} 
 
int main ( void ) 
{ 
    int i; 
    int* data = (int*)smalloc( sizeof(int) * 10 ); 
 
    for ( i = 0; i < 10; i++ ) 
    { 
        scanf("%d", data + i); 
    } 
 
    sorter(data, 10); 
 
    for ( i = 0; i < 3; i++ ) 
    { 
        printf("%d\n", data[i]); 
    } 
 
    free(data); 
 
    return 0; 
}                                                                                      

Measured memory_bytes: 600
import math

pi = math.pi

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

rad = pi * 2 * (( H *60 +M) / (12*60) - M /60 ) 

XX = A*A + B*B -2*A*B* math.cos(rad)

X = math.sqrt(XX)

print(X)

Measured memory_bytes: 9380