akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
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<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
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<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

const int S=4005;

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

vl fact(10000,-1);

ll Fact(ll n){
	if(fact[n]!=-1) return fact[n];
	if(!n) return fact[0]=1;
	return fact[n]=Fact(n-1)*n%mod;
}

ll Division_mod(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

ll Combination(ll n,ll k){
	return Division_mod(Fact(n),Fact(n-k)*Fact(k)%mod);
}

inline int Ind(int x){
	return x+2002;
}

int n;
vi a,b;

int main(){
	cin>>n;
	a=b=vi(n);
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	vvl dp(S,vl(S));
	for(int i=0;i<n;i++) dp[Ind(-a[i])][Ind(-b[i])]++;
	for(int i=0;i<S;i++) for(int j=0;j<S;j++){
		if(i) (dp[i][j]+=dp[i-1][j])%=mod;
		if(j) (dp[i][j]+=dp[i][j-1])%=mod;
	}
	ll ans=0;
	for(int i=0;i<n;i++) (ans+=dp[Ind(a[i])][Ind(b[i])])%=mod;
	for(int i=0;i<n;i++) ((ans-=Combination(2*(a[i]+b[i]),2*a[i]))+=mod)%=mod;
	cout<<Division_mod(ans,2)<<endl;
}

Measured memory_bytes: 127488
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[230000];
int s[306][306];
string ans[306];
signed main() {
	int h, w, k; cin >> h >> w >> k;
	rep(i, h)cin >> ans[i];
	int nk = 1;
	rep(i, h) {
		rep(j, w) {
			if (ans[i][j] == '#') {
				s[i][j] = nk; nk++;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] && !s[i][j + 1]) {
				s[i][j + 1] = s[i][j];
			}
		}
	}
	rep(i, h) {
		for (int j = w - 1; j > 0; j--) {
			if (s[i][j] && !s[i][j - 1]) {
				s[i][j - 1] = s[i][j];
			}
		}
	}
	rep(i, h - 1) {
		rep(j, w) {
			if (s[i][j] && !s[i + 1][j]) {
				s[i + 1][j] = s[i][j];
			}
		}
	}
	for (int i = h - 1; i > 0; i--) {
		rep(j, w) {
			if (s[i][j] && !s[i - 1][j]) {
				s[i - 1][j] = s[i][j];
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (j)cout << ' '; cout << s[i][j];
		}cout << endl;
	}
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>

int comparing(const void *a, const void *b){
  return *(double*)a - *(double*)b;
}

int main(){
  int n = 0;
  double v[50] = {};
  int i = 0;
  double sum = 0;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%lf",&v[i]);
  }
  
  qsort(v,n,sizeof(double),comparing);
  sum = v[0];
   for(i = 1;i < n;i++){
     sum = (sum + v[i])/2;
   }
  printf("%lf",sum);
  return 0;
}


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

using namespace std;

int main(){
  int n;
  string s[309];
  cin >> n;
  for(int i=0;i<n;i++)cin >> s[i];
  int cnt=0;
  for(int k=0;k<n;k++){
    bool is_sym=true;
    for(int i=0;i<n&&is_sym;i++){
      for(int j=1;j<n-i&&is_sym;j++){
        if(s[(i+k+j)%n][(i)%n]!=s[(i+k)%n][(i+j)%n])is_sym=false;
      }
    }
    if(is_sym)cnt++;
  }
  cout << cnt*n << endl;
}



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

int main(){
    int h,w;
    cin >> h >> w;
    char s[100];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s[j];
            cout << s[j];
        }
        cout << endl;
        for(int j=0;j<w;j++)
        cout << s[j];
        cout << endl;
        }
}

Measured memory_bytes: 256
# N
# a_1 b_1
# ...
# a_N b_N

# [[a_1, b_1], ..., [a_N, b_N]] を転置して
# [[a_1, ..., a_N], [b_1, ..., b_N]] にする

# N = gets.to_i
# a, b = N.times.map{gets.split.map(&:to_i)}.transpose

# n進数変換は、to_s(n)

# 素数列挙、約数列挙
# require 'prime'
# Prime.each(15).to_a       #=> [2, 3, 5, 7, 11, 13]  15以下の素数
# Prime.prime_division(24)  #=> [[2, 3], [3, 1]]      2**3 * 3**1

# 平方根
# require 'complex'
# Math.sqrt()

# 無限はFloat::INFINITY
# MOD = 10 ** 9 + 7

# 文字コードの変換はordとchr

# N = gets.to_i
# a = gets.split.map(&:to_i)
# a = N.times.map{gets.to_i}  # 縦に並んだ複数の整数。たまにある
# s = gets.chomp

S = gets.chomp

size = S.length

S.chars.each_with_index do |s, i|
    if (size / 2) % 2 == 0
        break if i == (size / 2) - 1
    else
        break if i == (size / 2)
    end

    if s != S[-(i+1)]
        puts "No"
        exit
    end
end

S2 = S.chars[0..((size-1)/2 -1)]
size2 = S2.size

S2.each_with_index do |s, i|
    if (size2 / 2) % 2 == 0
        break if i == (size2 / 2) - 1
    else
        break if i == (size2 / 2)
    end

    if s != S2[-(i+1)]
        puts "No"
        exit
    end
end

S3 = S.chars[((size+3) / 2 -1)..(size-1)]
size3 = S3.size

S3.each_with_index do |s, i|
    if (size3 / 2) % 2 == 0
        break if i == (size3 / 2) - 1
    else
        break if i == (size3 / 2)
    end

    if s != S3[-(i+1)]
        puts "No"
        exit
    end
end

puts "Yes"


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

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> S(N+1);
  for (int i = 0; i < N; i++) S.at(i+1) = S.at(i) + A.at(i);
  sort(S.begin(), S.end());
  map<long long, long long> M;
  for (auto v : S) {
    if (M.count(v)) M[v]++;
    else M[v] = 1;
  }
  long long ans = 0;
  for (auto p : M) ans += p.second * (p.second - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 15872
import java.util.*;
public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int t = sc.nextInt();
			int l = sc.nextInt();
			int b = sc.nextInt();
			if((n|t|l|b) == 0)break;
			int [] lList = new int[n+1];
			int [] bList = new int[n+1];
			for(int i = 0; i < l; i++){
				lList[sc.nextInt()] = 1;
			}
			for(int i = 0; i < b; i++){
				bList[sc.nextInt()] = 1;
			}
			double [][] dp = new double[t + 1][n + 1];
			for(int i = 0; i <= t; i++){
				Arrays.fill(dp[i], 0.0);
			}
			dp[0][0] = 1.0;
			for(int i = 0; i < t; i++){
				for(int j = 0; j < n; j++){
					for(int k = 1; k <= 6; k++){
						int  nextind = j + k;
						if(nextind <= n){
							if(bList[nextind] == 1){
								dp[i+1][0] += dp[i][j] * (1.0 / 6);
							}
							else if(lList[nextind] == 1){
								if(i+2 <= t){
									dp[i+2][nextind] += dp[i][j] * (1.0 / 6);
								}
							}
							else{
								dp[i+1][nextind] += dp[i][j] * (1.0 / 6);
							}
						}
						else{
							int diff = nextind - n;
							nextind = n - diff;
							if(bList[nextind] == 1){
								dp[i+1][0] += dp[i][j] * (1.0 / 6);
							}
							else if(lList[nextind] == 1){
								if(i+2 <= t){
									dp[i+2][nextind] += dp[i][j] * (1.0 / 6);
								}
							}
							else{
								dp[i+1][nextind] += dp[i][j] * (1.0 / 6);
							}
						}
					}
				}
				//n
				dp[i+1][n] += dp[i][n];
			}
			//debug
//			for(int i = 0; i <= t; i++){
//				System.out.println(Arrays.toString(dp[i]));
//			}
			System.out.printf("%.6f\n",dp[t][n]);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int S;
	cin >> S;

	bool flag1 = 1 <= S / 100 && S / 100 <= 12;
	bool flag2 = 1 <= S % 100 && S % 100 <= 12;
	if (flag1 && flag2) cout << "AMBIGUOUS" << "\n";
	else if (flag1) cout << "MMYY" << "\n";
	else if (flag2) cout << "YYMM" << "\n";
	else cout << "NA" << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=300009;


int n;
long long ans=0;
int a[maxn]={0};

int b[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	
	
	for(int i=n;i>=1;--i){
		if(a[i+1]==0){
			b[i]=0;
		}else{
			b[i]=a[i+1]-1;
		}
		if(b[i]>a[i]){
			cout<<-1<<endl;
			return 0;
		}else if(b[i]!=a[i]){
			if(a[i]>=i){
				cout<<-1<<endl;
				return 0;
			}
			ans+=a[i];
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
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;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  map<int, int> cnt;
  srep(i, 2, n+1) {
    int x = i;
    for (int j = 2; x != 1; j++) {
      while (x % j == 0) x /= j, cnt[j]++;
    }
  }
  vi vec; for (auto &p : cnt) vec.pb(p.se);
  sort(rrng(vec));
  int ans = 0, len = vec.size();
  rep(i, len) srep(j, i+1, len) srep(k, j+1, len) {
    if (vec[i] >= 4 && vec[j] >= 4 && vec[k] >= 4)
      ans += 3;
    else if (vec[i] >= 4 && vec[j] >= 4 && vec[k] >= 2)
      ans++;
  }
  rep(i, len) srep(j, i+1, len) {
    if (vec[i] >= 24 && vec[j] >= 24) ans += 2;
    else if (vec[i] >= 24 && vec[j] >= 2) ans++;
    if (vec[i] >= 14 && vec[j] >= 14) ans += 2;
    else if (vec[i] >= 14 && vec[j] >= 4) ans++;
  }
  rep(i, len) {
    if (vec[i] >= 74) ans++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
struct Val {
    int val, i;
};
 
const int M = 1 << 18, N = 2*M;
 
Val a[N];
int maxi[N];
 
int getMax(int i) {
    int ans = 0;
    while(i > 0) {
        if(i % 2 == 1)
            ans = max(ans, maxi[i-1]);
        i /= 2;
    }
    return ans;
}
 
void insert(int i, int val) {
    while(i > 0) {
        maxi[i] = max(maxi[i], val);
        i /= 2;
    }
}
 
signed main() {
    /*
    freopen("exercise.in", "r", stdin);
    freopen("exercise.out", "w", stdout);
    */
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i].val;
        a[i].i = i;
    }
    sort(a, a+n, [](Val a, Val b){return a.val < b.val;});
    int p = a[0].val;
    a[0].val = 0;
    for(int i = 1; i < n; i++)
        if(p == a[i].val) {
            p = a[i].val;
            a[i].val = a[i-1].val;
        } else {
            p = a[i].val;
            a[i].val = a[i-1].val + 1;
        }
    sort(a, a+n, [](Val a, Val b){return a.i < b.i;});
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int pds; cin >> pds;
        int nb = getMax(a[i].val + M) + pds;
        insert(a[i].val + M, nb);
        ans = max(ans, nb);
    }
    cout << ans;
}

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
struct Data{
    int n, x;
};

int main(){
    int n=1, x=1, count=0;
    struct Data data[10000];
    
    int data_num=0;
    while(n+x!=0){
        cin >> n >> x;
        data[data_num].n = n;
        data[data_num].x = x;
        data_num++;
    }
    
    
    int num=0;
    while(num<data_num-1){
        for(int i=1; i<data[num].n-1; i++){
            for(int j=i+1; j<data[num].n; j++){
                for(int k=j+1; k<=data[num].n; k++){
                    if(i+j+k==data[num].x) count++;
                    
                }
            }
        }
        cout << count << endl;
        count=0;
        num++;
    }
}


Measured memory_bytes: 3104
#include<stdio.h>

int main()
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if(a<b)
    {
        if(b>c && a<c) printf("Yes\n");
        else printf("No\n");
    }
    else
    {
        if(b>c || a<c) printf("No\n");
        else if(a>c) printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int ABS(int a){
	return a >= 0 ? a : -a;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, i, ans = 1000;
	char S[11];
	scanf("%s", S);
	for(N = 0; S[N] != '\0'; N++);
	int A[N];
	for(i = 0; i < N; i++){
		A[i] = (int)S[i] - (int)'0';
	}
	for(i = 2; i < N; i++){
		ans = min(ans, ABS(100 * A[i - 2] + 10 * A[i - 1] + 1 * A[i] - 753));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define pb push_back
using namespace std;

int main() {
	IOS;
	ll n,w;
	cin>>n>>w;
	ll wt[n+1],val[n+1];
	ll ans[n+1][w+1];
	for(int i=0;i<=w;i++)ans[0][i]=0;
	for(ll i=1;i<=n;i++){
		cin>>wt[i]>>val[i];
		for(int j=0;j<=w;j++){
			if(j==0)
			ans[i][j]=0;
			else if(wt[i]>j){
				ans[i][j]=ans[i-1][j];
			}else if(wt[i]<=j){
				ans[i][j]=max(ans[i-1][j],val[i]+ans[i-1][j-wt[i]]);
			}
		}
	}
	cout<<ans[n][w];
}


Measured memory_bytes: 79104
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int S = stdIn.nextInt();
         
        int h = S / 3600;
        S = S - h*3600;
         
        int m = S / 60;
        S = S - m*60;
         
        System.out.println(h+ ":" + m + ":" + S);
    }
}


Measured memory_bytes: 26300
#include<bits/stdc++.h>
#define fi first
#define se second
#ifdef CX_TEST
#define Debug printf
#else
#define Debug(...)
#endif
#define LL long long
using namespace std;
typedef pair<int, int> P;
const int maxn = 1e5 + 5;

int a[maxn], b[maxn], c[maxn], p[maxn];
LL s[maxn], d[maxn];
bool vis[maxn];
vector<int> g[maxn];

bool cmp(const int x, const int y) {
    return a[x] < a[y];
}

int ff(int x) {
    if(p[x] != x) p[x] = ff(p[x]);
    return p[x];
}

int main() {
#ifdef CX_TEST
    freopen("E:\\program--GG\\test_in.txt", "r", stdin);
#endif
    int n, m, i, j, u, v;
    scanf("%d%d", &n, &m);
    for(i = 1;i <= n; i++) {
        scanf("%d%d", &a[i], &b[i]);
        a[i] = max(a[i] - b[i], 0);
        s[i] = b[i];
        d[i] = a[i];
    }
    for(i = 0;i < m; i++) {
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(i = 1;i <= n; i++) c[i] = i;
    for(i = 1;i <= n; i++) p[i] = i;
    sort(c + 1, c + n + 1, cmp);
    for(i = 1;i <= n; i++) {
        j = c[i];
        vis[j] = 1;
        for(auto e:g[j]) {
            if(vis[e]) {
                u = ff(j), v = ff(e);
                if(u != v) {
                    s[u] += s[v];
                    p[v] = u;
                    d[u] = min(d[u], d[v] + max(0LL, a[u] - d[v] - s[v]));
                }
            }
        }
    }
    cout << s[c[n]] + d[c[n]] << endl;
    return 0;
}


Measured memory_bytes: 9084
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


int N;
int L[1000];

signed main()
{
	cin >> N;
	REP(i, N) cin >> L[i];

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			for (int k = j + 1; k < N; k++)
			{
				int a[3] = { L[i], L[j], L[k] };
				if (L[i] != L[j] && L[j] != L[k] && L[i] != L[k])
				{
					ARY_SORT(a, 3);
					if (a[0] + a[1] > a[2]) ans++;
				}
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
#define min(a,b) ((a>b)?b:a)
/*ABC 140 c*/

int main(void)
{
  int N;
  int B[100] = {0};
  int sum    = 0;

  scanf("%d", &N);
  for (size_t i = 0; i < N-1; i++) {
    scanf("%d", &B[i]);
  }

  if (N == 2) {
    printf("%d\n", B[0] * 2);
    return 0;
  }

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

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


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

int main() {
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin>>s[i];
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++) cout<<s[i];
    cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

const int mx=200010;
const ll mod=1e9+7;

int d;
int ans = 0;


int main(){
  cin >> d;

  cout << d*d << endl;
  return 0;  
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  char c = 'A', comma, one, two;

  while(cin >> one >> comma >> two) {
    if(one == c) c = two;
    else if(two == c) c = one;
  }
  cout << (char)c << endl;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int t = 0;
  if (A < 0) {
    t = abs(A) * C + D + B * E;
  } else {
    t = (B - A) * E;
  }
  cout << t << "\n";
  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;


int main() {
    unsigned int N, M;
    cin >> N >> M;

    unsigned int sum = 0;
    priority_queue <unsigned int, vector<unsigned int>, greater<unsigned int> > pq; 
    for (int i = 0; i < N; i++) {
        unsigned int a;
        cin >> a;
        sum += a;
        pq.push(a);
        if (i >= M) pq.pop();
    }

    unsigned int mthLargest = pq.top();
    float lowerBound = sum / (4.0 * M);

    if (mthLargest >= lowerBound) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("io\\in.txt", "r", stdin);
    freopen("io\\out.txt", "w", stdout);
#endif

    int x;
    cin >> x;
    cout << 10 - x / 200;

    return 0;
}


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

struct Dice {
  vector<int> num;
  void roll_north() {
    int t = num.at(0);
    num.at(0) = num.at(1);
    num.at(1) = num.at(5);
    num.at(5) = num.at(4);
    num.at(4) = t;
  }
  void roll_south() {
    int t = num.at(0);
    num.at(0) = num.at(4);
    num.at(4) = num.at(5);
    num.at(5) = num.at(1);
    num.at(1) = t;
  }
  void roll_east() {
    int t = num.at(0);
    num.at(0) = num.at(3);
    num.at(3) = num.at(5);
    num.at(5) = num.at(2);
    num.at(2) = t;
  }
  void roll_west() {
    int t = num.at(0);
    num.at(0) = num.at(2);
    num.at(2) = num.at(5);
    num.at(5) = num.at(3);
    num.at(3) = t;
  }
  void spin() {
    int t = num.at(1);
    num.at(1) = num.at(2);
    num.at(2) = num.at(4);
    num.at(4) = num.at(3);
    num.at(3) = t;
  }
  int get_top() {
    return num.at(0);
  }
  int get_front() {
    return num.at(1);
  }
  int get_right() {
    return num.at(2);
  }
  int get_left() {
    return num.at(3);
  }
};

int main() {
  Dice d1, d2;
  rep(i, 6) {
    int n;
    cin >> n;
    d1.num.push_back(n);
  }
  rep(i, 6) {
    int n;
    cin >> n;
    d2.num.push_back(n);
  }
  if (d1.get_top() == d2.get_left()) {
    d2.roll_east();
  }
  if (d1.get_top() == d2.get_right()) {
    d2.roll_west();
  }
  bool find = false;
  rep(i, 4) {
    if (d1.get_top() == d2.get_top()) {
      find = true;
      break;
    }
    d2.roll_north();
  }
  if (find) {
    find = false;
    rep(i, 4) {
      if (d1.get_front() == d2.get_front() &&
          d1.get_right() == d2.get_right() &&
          d1.get_left() == d2.get_left())
      {
        find = true;
        break;
      }
      d2.spin();
    }
  }
  if (find) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

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

typedef long long ll;
typedef pair<double,double> pdd;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<pdd> v_p;
    REP(i, N) {
        pdd tmp;
        cin >> tmp.first >> tmp.second;
        v_p.push_back(tmp);
    }
    double res = 0;
    ll cnt = 0;
    sort(v_p.begin(),v_p.end());
    do {
        REP(i, v_p.size()-1) {
            res += hypot(v_p[i+1].first - v_p[i].first, v_p[i+1].second - v_p[i].second);
        }
        cnt++;
    } while (next_permutation(v_p.begin(), v_p.end()));
    cerr << res << ":" << cnt << endl;
    cout << std::fixed << std::setprecision(10) << res/cnt << endl;
    return 0;
}


Measured memory_bytes: 256
r, g, b, n = map(int, input().split())
count = 0
for i in range(n//r + 1):
  for j in range((n-r*i) // g + 1):
    d = n - r*i - g*j
    if d%b == 0 and d >= 0:
      count += 1
print(count)


Measured memory_bytes: 2940
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
h = [t-i*0.006 for i in h]
c = 100000000000
d = 0
for i in range(len(h)):
  b = abs(h[i] - a)
  if c > b:
    c = b
    d = i + 1
print(d)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")

#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 long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
int N, M, Q;
int prev_i = 1;
ll ans = 0;
vector<ll> a(50), b(50), c(50), d(50);

void dfs(vector<int> &A) {
    if (A.size() == N) {
        ll sum = 0;
        rep(i, Q) {
            if (A[b[i]] - A[a[i]] == c[i])
                sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }

    for (int i = prev_i; i <= M; i++) {
        A.push_back(i);
        prev_i = i;
        dfs(A);
        A.pop_back();
    }
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q), b.resize(Q), c.resize(Q), d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int> A;
    dfs(A);
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  
  int num[10] = {0,2,5,5,4,5,6,3,7,6};
  vector < pair<int, int> > candidate;
  int N, M; cin >> N >> M;
  for (int i = 0; i < M; i++){
    int A; cin >> A;
    candidate.push_back(make_pair(A, num[A]));
  }
  sort(candidate.begin(), candidate.end(), greater< pair<int, int> >());
  
  int DP[N + 1];
  for (int i = 0; i < N + 1; i++){
    DP[i] = 0;
  }
  
  for (int i = 0; i < candidate.size(); i++){
    DP[candidate[i].second] = 1;
  }
  
  for (int i = 2; i < N + 1; i++){
    if (DP[i] > 0){
      for (int j = 0; j < candidate.size(); j++){
        int num = candidate[j].second;
        DP[i + num] = max(DP[i + num], DP[i] + 1);
      }
    }
  }
  
  int dig = DP[N], sum = N;
  while (dig > 0){    
    for (int i = 0; i < candidate.size(); i++){
      int now = candidate[i].second;
      if (DP[sum - now] + 1 == DP[sum] && DP[sum] > 1){
        cout << candidate[i].first;
        sum -= now;
        break;
      }else if(DP[sum] == 1 && sum == now){
        cout << candidate[i].first;
        sum -= now;
        break;
      }
    }
    dig--;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    string S;
    cin >> N >> S;
    vector<vector<int>> vec(3);
    vector<set<int>> se(3);
    string str = "RGB";
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            if(str[j] == S[i]){
                se[j].insert(i);
                vec[j].push_back(i);
            }
        }
    }
    for(int i=0; i<3; i++){
        sort(vec[i].begin(),vec[i].end());
    }
    ll ans = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(S[i] != S[j]){
                int id;
                for(int k=0; k<3; k++){
                    if(str[k]!=S[i] and str[k]!=S[j]) id = k;
                }
                int temp = 0;
                if(se[id].count(j+(j-i))) temp--;
                temp += vec[id].size() - (lower_bound(vec[id].begin(),vec[id].end(),j) - vec[id].begin());
                ans += temp;
            }
        }
    }
    cout << ans << enld;
    return 0;
}

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

using namespace std;
int main() {
  int N,ans=0;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
    while(A[i]%2==0){
      ans++;
      A[i]/=2;
    }
  }
  cout<<ans<<endl;
}	

Measured memory_bytes: 256
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m; string s;
	cin >> n >> m >> s;
	vi f(n+1,1e9);
	f[n]=0; queue<int>q;
	q.push(0);
	for(int i=n-1; i>=0; i--){
		while(1){
			if(q.empty()){
				cout << -1 << endl; 
				return 0;
			}
			if((int)q.size()>m||q.front()==(int)1e9)q.pop();
			else break;
		}
		if(s[i]=='0')f[i]=q.front()+1;
		q.push(f[i]);
	}
	vi ans;
	int x = 0;
	int cur = f[0];
	while(x<n){
		cur--;
		int i=1;
		while(f[x+i]!=cur)i++;
		ans.pb(i);
		x += i;
	}
	for(auto i:ans)cout << i << ' ';
	cout << endl;
}	


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, M; cin>>N>>M; //N個のタスク、 M日後
    vec_int A(N), B(N);
    rep(i, N)cin>>A.at(i)>>B.at(i); //A日後に報酬B

    vector<P> vec_income(N);
    rep(i,N){
        vec_income.at(i) = make_pair(A.at(i),B.at(i));
    }
    sort(vec_income.begin(), vec_income.end());
    
    int index = 0;
    priority_queue<int> pq;
    int tot_money = 0;
    for(int i=1;i<M+1;i++){
        while(true){
            if(index==N)break;
            int Aval, Bval;
            tie(Aval, Bval) = vec_income.at(index);
            if(Aval<=i){
                pq.push(Bval);
                index++;
            }else{
                break;
            }
        }
        if(pq.size()==0)continue;
        int money = pq.top();pq.pop();
        tot_money += money;
    }
    cout<<tot_money<<endl;












    return 0;
}

Measured memory_bytes: 7376
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,c=0,d=0;
        cin>>n;
        ll A[n];
        for(ll i=0;i<n;i++)
        {
            cin>>A[i];
            if(A[i]%4==0)
            c++;
            if(A[i]%2==0)
            d++;
        }
        if(c>=n/2)
        cout<<"Yes";
        else
        {
            if(c>=n-d)
            cout<<"Yes";
            else
            cout<<"No";
        }
    } 
    return 0;
}


Measured memory_bytes: 4368
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[101];
	while(scanf("%d",&n)!=EOF){
		int s=0;
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		sort(a,a+n);
		if(a[0]==a[n-1])
		printf("0");
		else {
			s=1234567;
			int t=0,j;
			for(int i=a[0];i<a[n-1];i++){
				t=0;
				for(j=0;j<n;j++){
					t+=(i-a[j])*(i-a[j]);
				}
				if(t<s)s=t;
			}
			printf("%d\n",s);
		}
	}
	return 0;
} 

Measured memory_bytes: 128
a,b,k = io.read("n","n","n")
t = {}
for i=1,math.max(a,b) do
    q1 = a % i
    q2 = b % i
    if (q1 == 0 and q2 == 0) then
        table.insert(t, i)
    end
end
print(t[#t + 1 - k])

Measured memory_bytes: 760
from collections import defaultdict

H,W,M=map(int,input().split())
hw = defaultdict(int)
sum1=[0]*H
sum2=[0]*W
for i in range(M):
  h,w=map(int,input().split())
  hw[(h-1,w-1)] += 1
  sum1[h-1] += 1
  sum2[w-1] += 1

sum1 = sorted(enumerate(sum1),key=lambda x:x[1],reverse=True)
sum2 = sorted(enumerate(sum2),key=lambda x:x[1],reverse=True)

max1,max2=set([sum1[0][0]]),set([sum2[0][0]])
for i in range(1,H):
  if sum1[i][1]<sum1[0][1]:
    break
  else:
    max1.add(sum1[i][0])
    
for i in range(1,W):
  if sum2[i][1]<sum2[0][1]:
    break
  else:
    max2.add(sum2[i][0])

ans = sum1[0][1]+sum2[0][1]
count=0
for k in hw.keys():
  h,w=k
  if h in max1 and w in max2:
    count += 1
    
if count < len(max1)*len(max2):
  print(ans)
else:
  print(ans-1)

Measured memory_bytes: 202996
import bisect

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for i in range(m):
    bc.append(list(map(int, input().split())))
bc.sort(key = lambda x: x[1], reverse = True)
a.sort(reverse = True)
count = 0 
count2 = 0
a2 = [0]
for i in range(n):
    a2.append(a2[-1] + a[i])
a.reverse()
sum_a = 0
for i in range(m):
    num = bc[i][1]
    num2 = bc[i][0]
    temp = n - bisect.bisect_left(a, num)
    count += temp
    count2 += temp
    temp2 = min(num2, n - count2)
    sum_a += num * temp2
    count2 += temp2
    if count2 == n:
        break
    count -= temp
    count2 -= temp
count3 = n - (count2 - count)
sum_a += a2[count3]
print(sum_a)

Measured memory_bytes: 37268
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int k,i,j,cnt=0;
  cin>>k;
  string s;
  cin>>s;
  for(i=0;i<k-2;){
      if(s[i+2]=='C'&&s[i+1]=='B'&&s[i]=='A')
      {cnt++;i+=3;}
      else 
      i++;
  }
  cout<<cnt;
}

Measured memory_bytes: 768
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(0, A+1):
  for b in range(0, B+1):
    for c in range(0, C+1):
      if a*500 + b*100 + c*50 == X:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
import sys

def is_onepair(x):
    for i in range(4):
        if x.count(x[i]) == 2:
            return True

    return False

def is_twopair(x):
    count = 0
    i = 0
    x.sort()
    while i < 5:
        if x.count(x[i]) == 2:
            i += 2
            count += 1
        else:
            i += 1
        if count == 2:
            return True

    return False

def is_threecard(x):
    for i in range(3):
        if x.count(x[i]) == 3:
            return True

    return False

def is_straight(x):
    x.sort()
    if x[0] == 1 and x[1:] == [10, 11, 12, 13]:
        return True
    for i in range(4):
        if x[i]+1 != x[i+1]:
            return False
    
    return True

def is_fullhouse(x):
    if is_threecard(x) and is_onepair(x):
        return True

    return False
    
def is_fourcard(x):
    for i in range(2):
        if x.count(x[i]) == 4:
            return True

    return False

for line in sys.stdin.readlines():
    hand = list(map(int, line.split(',')))
    if is_fourcard(hand):
        print("four card")
    elif is_fullhouse(hand):
        print("full house")
    elif is_straight(hand):
        print("straight")
    elif is_threecard(hand):
        print("three card")
    elif is_twopair(hand):
        print("two pair")
    elif is_onepair(hand):
        print("one pair")
    else:
        print("null")

Measured memory_bytes: 7748
#include<iostream>
#include<cstdio>
#define maxn 200010
using namespace std;
int n;
long long d,c;
int main(){
	long long sum=0,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&d,&c);
		sum+=d*c;
		ans+=c;
	}
	ans=ans+sum/9-1;
	if(sum%9==0)ans--;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$arr = [];
for ($i=0; $i < $n; $i++) { 
    $arr[$i] = trim(fgets(STDIN));
}
$arr = array_count_values($arr);
arsort($arr);
$tmp = $arr;
$tmp = array_shift($tmp);
$arr = array_filter($arr, function($v) use ($tmp) {
    return $v === $tmp;
});
$arr = array_keys($arr);
sort($arr);
echo implode("\n", $arr);

Measured memory_bytes: 29680
#include <stdio.h>

unsigned long long getGcd(unsigned long long A, unsigned long long B){
    unsigned long long tmp1, tmp2, r;
    unsigned long long ans;

    if ( A >= B ) {
        tmp1 = A;
        tmp2 = B;
    } else {
        tmp1 = B;
        tmp2 = A;
    }

    while ( tmp2 != 0 ) {
        r = tmp1 % tmp2;
        tmp1 = tmp2;
        tmp2 = r;
    }
    ans = tmp1;

    return ans;
}

unsigned long long getFactorNum( unsigned long long A ) {
    unsigned long long tmp;
    unsigned long long k, ans;
    char flg;

    tmp = A;
    ans = 1;
    flg = 0;

    while ( (tmp != 1) && (tmp % 2) == 0 ) {
        tmp = tmp >> 1;
        flg = 1;
    }
    if (flg == 1){
        ans++;
        flg = 0;
    }

    for ( k=3; k <= tmp; k+=2 ) {
        if ( k*k >= A ) {
            ans++;
            break;
        }
        if (tmp % k != 0) continue; 
        while ( (tmp != 1) && (tmp % k) == 0 ) {
            tmp /= k;
            flg = 1;
        }
        if (flg == 1){
            ans++;
            flg = 0;
        }
    }

    return ans;
}

int main( void ) {
    unsigned long long A, B;
    int i;
    unsigned long long ans;

    scanf("%lld %lld", &A, &B);

    ans = getGcd(A,B);
    ans = getFactorNum(ans);

    printf( "%lld", ans );

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

int main() {
    // input
    int n; cin >> n;
    vector<int> a0(n); REP (i, n) cin >> a0[i];
    vector<int> a1(n); REP (i, n) cin >> a1[i];
    // solve
    vector<int> acc0(n + 1); partial_sum(ALL(a0), acc0.begin() + 1);
    vector<int> acc1(n + 1); partial_sum(ALL(a1), acc1.begin() + 1);
    int result = 0;
    REP (i, n) {
        chmax(result, (acc0[i + 1] - acc0[0]) + (acc1[n] - acc1[i]));
    }
    // output
    cout << result << endl;
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline bool check(string& s) {
    return s[2] == s[3] && s[4] == s[5];
}

int main() {
    string s;
    cin >> s;
    cout << (check(s) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
ans = []
for ai in range(31):
    bb = (f - (ai * a * 100)) // b
    for bi in range(bb + 1):
        if ai == bi == 0:
            continue
        cc = (f - (ai * a * 100 + bi * b * 100)) // c
        for ci in range(cc + 1):
            dd = (f - (ai * a * 100 + bi * b * 100 + ci * c)) // d
            for di in range(dd + 1):
                if 100 * a * ai + 100 * b * bi + c * ci + d * di <= f:
                    if (c * ci + d * di)/(100 * a * ai + 100 * b * bi) <= e/100:
                        ans.append([(c * ci + d * di)/(100 * a * ai + 100 * b * bi + c * ci + d * di), 100 * a * ai + 100 * b * bi + c * ci + d * di, c * ci + d * di])
ans.sort(reverse=True)
print(ans[0][1], ans[0][2])

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

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

	int n;
	cin >> n;
	vector<int> arr(n + 1);
	vector<int> ball(n + 1);

	for (int i = 1; i <= n; ++i) cin >> arr[i];

	int ans = 0;
	for (int i = n; i >= 1; --i) {
		int cnt = 0;
		for (int j = i * 2; j <= n; j += i) {
			if (ball[j]) cnt++;
		}
		cnt %= 2;
		if (arr[i]) {
			if (cnt) ball[i] = 0;
			else {
				ball[i] = 1;
				ans++;
			}
		}
		else {
			if (cnt) {
				ball[i] = 1;
				ans++;
			}
			else ball[i] = 0;
		}
	}
	cout << ans << '\n';
	for (int i = 1; i <= n; ++i) if (ball[i]) cout << i << ' ';
}

Measured memory_bytes: 2560
//cod2017final_a.cpp
//Sun Dec  2 10:20:08 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	string ans = "KIHBR";
	int anspos = 0;
	int prevA = 0;
	int prevKI = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]=='A'){
			if (prevKI==1){
				cout << "NO" << endl;
				return 0;
			}else if (prevA==0){
				prevKI=0;
				prevA=1;
			}else{
				cout << "NO" << endl;
				return 0;
			}
		}else if (s[i] == ans[anspos]){
			anspos++;
			prevA = 0;
			prevKI = 0;
			if (s[i] == 'K' || s[i] == 'I'){
				prevKI = 1;
			}
		}else {
			cout << "NO" << endl;
			return 0;
		}
	}

	if (anspos == 5){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=1005;

int main()
{
    IO;
    ll a,b,c;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    cout<<(a-b)*((k%2)?-1:1);
    re 0;
}

Measured memory_bytes: 256