akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::vector<int64_t> a(n);
  std::cin >> a;
  for (auto &i : a) {
    i--;
  }

  std::vector<int64_t> visited(n, -1);

  int64_t count = 0;
  int64_t pos = 0;
  visited[pos] = count;

  while (count < k) {
    count++;
    pos = a[pos];
    if (visited[pos] == -1) {
      visited[pos] = count;
    } else {
      int64_t ped = count - visited[pos];
      count = k - (k - count) % ped;
      break;
    }
  }

  while (count < k) {
    count++;
    pos = a[pos];
  }

  std::cout << pos + 1 << std::endl;
  return 0;
}


Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
   u=v;
    sort(v.B,v.E);
    for(i=0;i<n;i++)
    {
        if(u[i]>v[n/2-1])
        {
            cout<<v[n/2-1]<<endl;
        }
        else
        {
            cout<<v[n/2]<<endl;
        }
    }
    v.C;
    u.C;

    return 0;
}


Measured memory_bytes: 5488
from heapq import heappush, heappop
from operator import itemgetter
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = []
for i in range(K):
    ta, tb = map(int, input().split())
    t.append([ta,tb]) 
a = sorted(t, key=itemgetter(1))
x.sort()
x = x[::-1]
s = 0
l = []
while x or a:
    if a[-1][0] == 0:a.pop()
    if not a:
        s+=sum(x)
        break
    if len(x) ==0:break
    r = x.pop()
    if r < a[-1][1]:
        s+=a[-1][1]
        a[-1][0]-=1
    else:
        s+=sum(x)+r
        break
print(s)


Measured memory_bytes: 26568
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int main(){
	int a,b,c,d,e,f,a1;
	while(cin>>a>>b>>c>>d>>e>>f){
		double det = a*e - b * d;
        double x = 1 / det * (c * e - b * f);
        double y = 1 / det * (f * a - c * d);
		if(x==-0.0) x=0.0;
		if(y==-0.0) y=0.0;
		printf("%.3lf %.3lf\n",x,y);
	}
}

Measured memory_bytes: 1192
f=lambda:map(int,input().split())
h,w,n=f()
c=[(h-2)*(w-2)]+[0]*9
d={}
while n:
 n-=1;x,y=f()
 for i in range(9):
  a=(x+i%3,y+i//3)
  if h>=a[0]>2<a[1]<=w:d[a]=d.get(a,0)+1;c[d[a]-1]-=1;c[d[a]]+=1
print(*c)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  if (a >= 13) {
    ans = b;
  } else if (a >= 6) {
    ans = b / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:56:10 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]

fact = [1, 1] # 元テーブル
fact_inv = [1, 1] # 逆元テーブル
tmp_inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N+1):
    fact.append((fact[-1] * i) % mod)
    tmp_inv.append((-tmp_inv[mod % i] * (mod//i)) % mod)
    fact_inv.append((fact_inv[-1] * tmp_inv[-1]) % mod)
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return fact[n] * fact_inv[r] * fact_inv[n-r] % mod
#逆元作成
def inv(a,mod):
    return pow(a,mod-2,mod)

graph = [[] for _ in range(N+1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)

dp = [1] * (N + 1)
size = [0] * (N + 1)
def dfs(par, v):
    for u in graph[v]:
        if par == u:
            continue
        dfs(v, u)
        size[v] += size[u]
        dp[v] = dp[v] * dp[u] * fact_inv[size[u]] % mod
    dp[v] = dp[v] * fact[size[v]] % mod
    size[v] += 1

ans = [0] * (N + 1)
def reroot(par, val_par, size_par, v):
    ans[v] = val_par * dp[v] * cmb(N-1, size_par, mod) % mod
    for u in graph[v]:
        if par == u:
            continue
        val = ans[v] * inv(dp[u] * cmb(N-1, size[u],mod),mod) % mod
        reroot(v, val, N - size[u], u)

dfs(-1,1)
reroot(-1,1,0,1)
for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 168000
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main(){
    int n;
    int d1=0,d2=0;
    cin>>n;
    for(int i=0;i<n;i++){
        string s1,s2;
        cin>>s1>>s2;
        if(string(s1).compare(s2)==0){
            d1++;
            d2++;
        }
        else if(string(s1).compare(s2)>0){
            d1 +=3;
        }else if(string(s1).compare(s2)<0){
            d2 +=3;
        }
    }
    cout<<d1<<" "<<d2<<endl;
    return 0;
}


Measured memory_bytes: 3148
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int x = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();
	
	int s,t;
	
	if(a<x){
		s = x - a;
	}else {
		s =a - x;
	}
	
	if(b<x){
		t = x - b;
	}else {
		t = b - x;
	}
	
	if (t<s) {
		System.out.println("B");
	} else {
		System.out.println("A");
	}
	
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
 

int N;
ll a[3005], DP[3005][3005];

ll dp(int l, int r){
    if (l > r) return 0;
    if (DP[l][r] != -1e18) return DP[l][r];
    if (l == r) return DP[l][r] = a[l];
    if (r - l == 1) return DP[l][r] = abs(a[r]-a[l]);
    return DP[l][r] = max(a[r]-dp(l,r-1),a[l]-dp(l+1,r));
}
 
int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

    cin >> N;
    F0R(i,N) cin >> a[i];
    F0R(i,N) F0R(j,N) DP[i][j] = -1e18;
    finish(dp(0,N-1));
 

    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    SORT(L);
    int ans = 0;
    REP(i, N){
        Rep(j, i+1, N){
            int l = max(L[i]-L[j], L[j]-L[i]);
            int r = L[i]+L[j];
            int l_id = upper_bound(ALL(L), l) - L.begin();
            int r_id = lower_bound(ALL(L), r) - L.begin();
            if(l_id < j) l_id = j;

            ans += r_id - l_id - 1;
            if(l_id < i && i < r_id)ans--;
            if(l_id < j && j < r_id)ans--;
            // Rep(k, j+1, N){
            //     if(L[i]<L[j]+L[k] && L[j]<L[i]+L[k] && L[k]<L[i]+L[j]) ans++;
            //     if(L[k]>=L[i]+L[j])break;
            // }
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;

signed main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    REP(i,n){
        int h;
        cin >> h;
        if(h>=k) ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b,c,x,y;
  cin >> a>>b>>c>>x>>y;
  
  int yen ;
  if(a+b>2*c){
    if(x>y){
      if(a > 2*c) yen = x*c*2;
      else yen = y*c*2 + (x-y)*a;
    }else{
      if(b > 2*c) yen = y*c*2;
      else yen = x*c*2 + (y-x)*b;
    }
  }else{
    yen = a*x + b*y;
  }
  
  cout << yen << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<cctype>
using namespace std;
#define fec(i,x,y) (int i=head[x],y=g[i].to;i;i=g[i].ne,y=g[i].to)
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define FO(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define Edg(N,M) struct Edge{int to,ne;}g[M];int head[N],tot;\
	inline void Ad(int x,int y){g[++tot].to=y;g[tot].ne=head[x];head[x]=tot;}\
	inline void Adde(int x,int y){Ad(x,y);Ad(y,x);}
#define Edgc(N,M) struct Edge{int to,ne,w;}g[M];int head[N],tot;\
	inline void Ad(int x,int y,int z){g[++tot].to=y;g[tot].w=z;g[tot].ne=head[x];head[x]=tot;}\
	inline void Adde(int x,int y,int z){Ad(x,y,z);Ad(y,x,z);}
#define fi first
#define se second
#define pb push_back
template<typename I>inline void read(I&x){int f=0,c;while(!isdigit(c=getchar()))c=='-'?f=1:0;x=c&15;while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);f?x=-x:0;}
template<typename A,typename B>inline char SMAX(A&a,const B&b){return a<b?a=b,1:0;}
template<typename A,typename B>inline char SMIN(A&a,const B&b){return a>b?a=b,1:0;}
typedef long long ll;typedef unsigned long long ull;typedef std::pair<int,int>pii;

int A,B,C;

int main(){
	read(A),read(B),read(C);--C;
	int hkk=min(C,B+A),ans=hkk;
	ans+=B;++ans;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    ll d, s, t; cin >> d >> s >> t;
    ll travel = s * t;
    cout <<  (d <= travel ? "Yes" : "No");


    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long 
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/

int main(){
    //IOS;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        string s,t;
        cin>>s>>t;
        ll n=s.length(),m=t.length();
        ll l[n+2][m+2];
        FOR(i,n+1)l[i][0]=0;
        FOR(i,m+1)l[0][i]=0;

        FORE(i,1,n){
            FORE(j,1,m){
                if(s[i-1]==t[j-1])
                l[i][j]=l[i-1][j-1]+1;
                else{
                    l[i][j]=max(l[i-1][j],l[i][j-1]);
                }
            }
        }
       // cout<<l[n][m]<<"\n";
        ll i=n,j=m;
        string ans="";
        while(i>0 && j>0){
            if(s[i-1]==t[j-1])ans+=s[i-1],i--,j--;
            else if(l[i-1][j]>l[i][j-1])i--;
            else j--;
        }
        reverse(all(ans));

        cout<<ans;
    }
    return 0;
} 

Measured memory_bytes: 73992
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  int x,a,b;
  cin>>x>>a>>b;
  x-=a;
  cout<<x%b<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


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

#define ll long long

using namespace std;

ll n;

ll cnt, res = 1, ans;

int main () {
    cin >> n;
    if (n % 2 == 1) {
        cout << 0;
        exit (0);
    }else {
        res = 10;
        for (int i = 0;i < log (n);i ++) {
            ans += n / res;
            res *= 5;
        }
    }cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
 
struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};
 
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};
 
ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}
 
//-----------------------------------------------------------------------------
 
int n,f[100][10];
int p[100][11];
ll ans=-INF;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	cin>>n;
	REP(i,n) REP(j,10) cin>>f[i][j];
	REP(i,n) REP(j,11) cin>>p[i][j];
 
	FOR(i,1,1<<10) {
		ll sum=0;
		int cnt[n];
		REP(j,n) {
			cnt[j]=0;
			REP(k,10) if((i>>k)&f[j][k]) cnt[j]++;
		}
		REP(j,n) sum+=p[j][cnt[j]];
		//cout<<"i,sum "<<BIT(i,10)<<' '<<sum<<endl;
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
 
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll dp[3010][3010],v[3010];
ll ds(int l, int r) {
	if(l+r == n) {return 0;}
	if(dp[l][r] != 1LL<<35) {return dp[l][r];}
	if((l+r)%2) {
		return dp[l][r] = min(-v[l]+ds(l+1,r),-v[n-r-1]+ds(l,r+1));
	} else {
		return dp[l][r] = max(v[l]+ds(l+1,r),v[n-r-1]+ds(l,r+1));
	}
}
int main() {
	scanf("%d ",&n);
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			dp[i][j] = 1LL<<35;
		}
	}
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d ",&t);v[i]=t;
	}
	printf("%lld\n",ds(0,0));
}

Measured memory_bytes: 70912
n = gets.to_i
h = Hash.new(0)
n.times do
  s = gets
  h[s[0]] += 1
end
ans = 0
['M', 'A', 'R', 'C', 'H'].combination(3).to_a.each do |x|
  ans += h[x[0]] * h[x[1]] * h[x[2]]
end
puts ans

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

vector<vector<int> > grids;
vector<vector<int> > pathes;

int MAX = 1e9+7;

int go(){
    int h = grids.size();
    int w = grids[0].size();

    pathes[1][0] = 1;

    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            if(!grids[i][j])
                continue;
            int sum = (pathes[i][j-1] % MAX);
            sum += (pathes[i-1][j] % MAX);
            pathes[i][j] = (sum % MAX);
        }
    }
    return pathes[h-1][w-1];
}

int main(){
    int h, w;
    cin >> h >> w;

    grids = vector<vector<int> >(h+1, vector<int>(w+1, 0));
    pathes = vector<vector<int> >(h+1, vector<int>(w+1, 0));

    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++){
            char symbol;
            cin >> symbol;
            if(symbol == '.')
                grids[i][j] = 1;
            else
                grids[i][j] = 0;
        
        }

    int path_num = go();

    cout << path_num << "\n";

    return 0;
}


Measured memory_bytes: 8192
/* warshall_floyd.cpp
    ワーシャルフロイド法を用いて、全点間最短路を求める。

    初期化：dis[i][j] = iからjへの距離(辺がなければINF) (i≠j)
            dist[i][i] = 0
            prev[i][j] = i

    負閉路の検出：dis[i][i] < 0 となる i が存在するか

    verified:
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=ja
*/

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;

/* warshall_floyd(dist,prev)
    入力：初期化した dist, prev
    計算量：O(|V|^3)
    副作用：dis[i][j]にiからjへの最短路のコストを格納、prev[i][j]にiからjへの最短路でのjの1つ前の点を格納
*/
void warshall_floyd(vector<vector<long long>> &dist, vector<vector<long long>> &prev) {
    int V = dist.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    prev[i][j] = prev[k][j];
                }
            }
        }
    }
}

/* get_path(prev, s, t)
    入力：warshall_floyd で得た prev, スタート s, ゴール t
    出力：s から t への最短路のパス
*/
vector<int> get_path(const vector<vector<long long>> &prev, int s, int t) {
    vector<int> path;
    for (int cur = t; cur != s; cur = prev[s][cur]) {
        path.push_back(cur);
    }
    path.push_back(s);
    reverse(path.begin(), path.end());
    return path;
}

/* is_negative(dist)
    入力：warshall_floyd で得た dist
    出力：負の有向路を含むかどうか
*/
bool is_negative(const vector<vector<long long>> &dist) {
    int V = dist.size();
    for (int i = 0; i < V; i++) {
        if (dist[i][i] < 0) {
            return true;
        }
    }
    return false;
}

int main() {
    int W, H;
    cin >> W >> H;

    // initialization
    int V = 10;
    vector<vector<long long>> dist(V, vector<long long>(V, INF));
    vector<vector<long long>> prev(V);
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < 10; j++) {
            cin >> dist[i][j];
        }
        prev[i] = vector<long long>(V, i);
    }

    // input

    warshall_floyd(dist, prev);

    vector<vector<int>> A(H, vector<int>(W));
    long long ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
            if (A[i][j] != -1) {
                ans += dist[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
input = raw_input

#from copy import deepcopy

n, m, q = map(int, input().split(" "))

score_dict = {}

for i in range(1, n):
    for j in range(i+1, n+1):
        key = (i, j)
        score_dict[key] = []

As = []
def f(last_array, last_val, num):
    if num == n:
        As.append(last_array)
    else:
        for cur_val in range(last_val, m+1):
            cur_array = last_array + [cur_val]
            f(cur_array, cur_val, num+1)

f([1], 1, 1)

all_inputs = []
for i in range(q):
    a, b, c, d = map(int, input().split(" "))
    all_inputs.append([a, b, c, d])

out = 0
for A in As:
    cur = 0
    for a, b, c, d in all_inputs:
        b -= 1
        a -= 1
        if c == A[b] - A[a]:
            cur += d
    out = max(cur, out)

print(out)

Measured memory_bytes: 86444
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.12.29 19:57:47
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int dp[100010];

int main() {
    int n, k, r, s, p;
    string t;
    scanf("%d%d", &n, &k);
    scanf("%d%d%d", &r, &s, &p);
    cin >> t;

    ll ret = 0;
    rep(i, n) {
        if (t[i] == 's') {
            if (i - k >= 0 && dp[i - k] == 1) {
                dp[i] = 0;
                // 追加無し
            } else {
                dp[i] = 1;
                ret += r;
            }
        } else if (t[i] == 'p') {
            if (i - k >= 0 && dp[i - k] == 2) {
                dp[i] = 0;
                // 追加無し
            } else {
                dp[i] = 2;
                ret += s;
            }
        } else if (t[i] == 'r') {
            if (i - k >= 0 && dp[i - k] == 3) {
                dp[i] = 0;
                // 追加無し
            } else {
                dp[i] = 3;
                ret += p;
            }
        }
    }

    printf("%lld\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

bool solve() {
  int N;
  cin >> N;
  int mini = INF, maxi = NINF;

  vector<int> v(N);

  for (int &a:v) {
    cin >> a;
    mini = min(a, mini);
    maxi = max(a, maxi);
  }

  if (maxi - mini > 1) {
    return false;
  }

  if (maxi == mini) {
    return maxi * 2 <= N || maxi == N-1;
  }

  int cnt = 0;
  for (int &a:v) {
    if (a == mini) {
      cnt++;
    }
  }

  if (maxi < cnt) {
    return false;
  }

  int kind = maxi - cnt;

  if (kind == 0) {
    return false;
  }

  return kind * 2 <= (N - cnt);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  if (solve()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);

	ll a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	ll ans=1e18;
	c*=2;
	for(ll i=0;i<=max(x,y);i++)
	{
	    ans=min(ans,i*c+max(x-i,0ll)*a+max(y-i,0ll)*b);
	}
	cout<<ans<<endl;

    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, std::vector<std::string> s, std::vector<long long> t, std::string X){
	int i;
	for(i=0;i<N;i++){
		if(s[i]==X){
			i++;
			break;
		}
	}
	int ret=0;
	for(;i<N;i++){
		ret+=t[i];
	}
	cout << ret << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
        scanf("%lld",&t[i]);
    }
    std::string X;
    std::cin >> X;
    solve(N, std::move(s), std::move(t), X);
    return 0;
}


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

int main(){
	int x,y,o;
	cin >> x >> y;
	while (x != 0 || y != 0){
		if (x>y){
			o=x;
			x=y;
			y=o;
		}
		cout << x << " " << y << endl;
		cin >> x >> y;
	}
}

Measured memory_bytes: 1160
n, k = map(int, input().split())
a=list(map(int, input().split()))
k2=format(k, '041b')
a2=[format(ai, '041b') for ai in a]
memo=[0]*41
for x in range(41):
    cnt0=0
    cnt1=0
    for i in range(n):
        if a2[i][x]=='1':
            cnt0+=1
        else:
            cnt1+=1
    if cnt1>cnt0:
        memo[x]=1
for i in range(41):
    if int(k2[i])>memo[i]:
        break
    if int(k2[i])<memo[i]:
        memo[i]=0
mini=sum(memo[i]*2**(40-i) for i in range(41))
def f(x):
    return sum(x^ai for ai in a)
print(f(mini))
        

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

int main() {
  int n; cin >>n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >>a.at(i);
  vector<int> b(n);
  if (n%2==0){
    for (int i=0; i<n; i+=2){
      b.at(n/2+i/2) = a.at(i);
    }
    for (int i=1; i<n; i+=2){
      b.at(n/2-(i+1)/2) = a.at(i);
    }
  }else{
    for (int i=0; i<n; i+=2){
      b.at(n/2-i/2) = a.at(i);
    }
    for (int i=1; i<n; i+=2){
      b.at(n/2+(i+1)/2) = a.at(i);
    }
  }
  
  for (int i=0; i<n; i++){
    cout <<b.at(i);
    if (i!=n-1) cout <<" ";
  }
  //cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n,k,dd;
  cin>>n>>k;
  vector<int> d(10,0);
  for(int i=0;i<k;i++){
    cin>>dd;
    d[dd]=1;
  }
  
  for(int i=n;i<=100000;i++){
      int flag=1;
    int tmp=i;
    while(tmp!=0){
      if(d[tmp%10]==1){
        flag=0;
        break;
      }
      tmp/=10;
    }
    if(flag){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


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

void row(vector< vector<bool> > &t, int N ,int M, int num, int& count){
	for (int j = 0; j< M ; j++) {
		if(t[num][j]){
			t[num][j] = false;
			count--;
		}else{
			t[num][j] = true;
			count++;
		}
	}
}

void col(vector< vector<bool> > &t, int N ,int M, int num, int &count){
	for(int i = 0; i<N; i++){
		if(t[i][num]){
			t[i][num] = false;
			count--;
		}else{
			t[i][num] = true;
			count++;
		}
	}
}

int main(){
	int N, M, K;
	cin >> N >> M >> K;
	vector< vector<bool> > table;
	table.resize(N);
	bool ok = false;
	int count = 0;
	for (int i = 0; i < N; i++){
		table[i].resize(M);
	}
	for(int i = 0; i< N; i++) for(int j = 0; j< M; j++) {
		table[i][j] = false;
	}

	for (int j = 0; j<M ;j++){
		if(ok == true || count == K){
			ok = true;
			break;
		}
		col(table, N, M, j, count);
		for(int i = 0; i < N; i++){
			if(ok == true || count == K){
				ok = true;
				break;
			}
			row(table, N, M, i ,count);
		}
	}
	if(ok == true || count == K){
		ok = true;
	}

	if(ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,m,c;cin>>n>>m>>c;
    ll b[m];
    rep(i,0,m)cin>>b[i];
    ll a[n][m];
    rep(i,0,n)rep(j,0,m)cin>>a[i][j];
    ll ans=0;
    ll sum;
    rep(i,0,n){
        sum=0;
        rep(j,0,m){
            sum+=a[i][j]*b[j];
        }
        if(sum+c>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,m,p,k;
	scanf("%d%d", &a,&b);
	p=a+b;
	m=a-b;
	k=a*b;
	if((p>=m)&&(p>=k))
		printf("%d\n", p);
	else if((m>=p)&&(m>=k))
		printf("%d\n", m);
	else if((k>=p)&&(k>=m))
		printf("%d\n", k);
	return 0;
}


Measured memory_bytes: 128
s=input()
#n進数への変換関数の定義
#Python 3.7とかではデフォであるが，Python 3.4.3(AtCoder仕様)ではまだない
########10進法からn進法への変換関数部分##############
def format(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
############################

########10進法からn進法への変換関数(m桁埋める)部分##############
def format0(X, n, m):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    if len(out) < m:
        out = "0" * (m - len(out)) + out
    return out
############################

for i in range(8):
  j=format0(i,2,3)
  memo=[]
  for i in range(3):
    if j[i]=="0":
      memo.append("+")
    else:
      memo.append("-")
  a = s[0]+memo[0]+s[1]+memo[1]+s[2]+memo[2]+s[3]
  if eval(a)==7:
    print(a + "=7")
    exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int n,m;
           cin>>n>>m;
           cout<<(n*(n-1)+m*(m-1))/2<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m,i,j,k,l;
	char a[60][60],b[60][60];
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<m;i++){
		scanf("%s",b[i]);
	}
	int flag=0;
	for(i=0;i<=n-m;i++){
		for(j=0;j<=n-m;j++){
			flag=0;
			for(k=0;k<m;k++){
				for(l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l])flag=1;
				}
			}
			if(flag==0){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<double, double> P;
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; }

int n;
vector<P> v;

double dist(P p, P q){
    double x = (p.first - q.first) * (p.first - q.first);
    double y = (p.second - q.second) * (p.second - q.second);
    return sqrt(x+y);
}

double f(double x, double y){
    double ret = 0;
    rep(k,n){
        chmax(ret, dist(P(x, y), v[k]));
    }
    return ret;
}

double g(double x){
    double d = 0, u = 1000;
    rep(j,100){
        double c3 = (d*2+u)/3;
        double c4 = (d+u*2)/3;
        if(f(x, c3) > f(x, c4)) d = c3;
        else u = c4;
    }
    return f(x, d);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n){
        double x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    double l = 0, r = 1000;
    rep(i,100){
        double c1 = (l*2+r)/3;
        double c2 = (l+r*2)/3;
        if(g(c1) > g(c2)) l = c1;
        else r = c2;
    }
    double ans = g(l);
    cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b) {
    for(int i=0;i<b;i++) {
      printf("%d",a);
    }
  }else if(a>b) {
    for(int i=0;i<a;i++) {
      printf("%d",b);
    }
  }else if(a==b) {
    for(int i=0;i<b;i++) {
      printf("%d",a);
    }
  }
  return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

int main()
{
	long long sum = 0;

	long long N;
	cin>>N;

	long long sq = (long long)sqrt(N);
	//cout<<sq<<endl;
	for(long long i=1; i<sq; i++)
	{
		if(N % i == 0)
		{
			sum += ((N-i) / i);
		}
	}

	if(sq*sq+sq<N)
	{
		if(N%sq==0)
		{
			sum += ((N-sq) / sq);
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
//Target for Pupil
//Implementation and Data structures
//Prodip sarker(student_ip)
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define al(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
	int a,b,c,n,i,t,tmp,d,e,f,p;
//	cin>>t;
t=1;
string str;
	while(t--)
	{
		cin>>str;
		if(str[str.length()-1]=='s')
		{
			
			cout<<str<<"es\n";
		}
		else
		cout<<str<<"s"<<endl;
		
	}

	return 0;
}

Measured memory_bytes: 3648
import sys
N = int(input())
A = list(map(int,input().split()))
ALL = 0
for a in A:
    ALL ^= a

if ALL == 0:
    print(0)
    sys.exit()

ALL ^= A[0] ^ A[1]

K = A[0] + A[1]
L = []

for i in range(40, -1, -1):
    if (1 << i) & ALL:
        L.append(1)
        K -= (1 << i)
    else:
        if K >= 2 * (1 << i):
            L.append(2)
            K -= 1 << (i + 1)
        else:
            L.append(0)

if K != 0:
    print(-1)
    sys.exit()

ans = 0
for i in range(41):
    if L[i] == 2:
        ans += 1 << (40 - i)

if ans >= A[0]:
    print(-1)
    sys.exit()

for i in range(41):
    if L[i] == 1:
        if ans + (1 << (40 - i)) < A[0]:
            ans += 1 << (40 - i)

if ans == 0:
    print(-1)
    sys.exit()

print(A[0] - ans)

Measured memory_bytes: 9092
import sys
s = [int(input()) for i in range(5)]
s.sort()
n = len(s)
k = int(input())
for i in range(n):
  for j in range(i+1,n):
    if s[j]-s[i] > k:
      print(":(")
      sys.exit()
print("Yay!")      
    


Measured memory_bytes: 38384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn gcd(a: u64, b: u64) -> u64 {
    if a % b == 0 { return b; }
    return gcd(b, a % b);
}
fn lcm(a: u64, b: u64) -> u64 {
    return a * b / gcd(a, b);
}
fn main() {
    input!{
        a: u64,
        b: u64,
    }
    println!("{}", lcm(a, b));
}


Measured memory_bytes: 4352
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, d = 0, ct = 0, x = 0, y = 0; lli dd = 0ll;
	cin >> n >> d;
	dd = 1ll * d * d;
	auto calcDis = [&](int x, int y)
	{
		return (1ll * x * x) + (1ll * y * y);
	};
	for (int i = 0; i < n; ++i)
	{
		cin >> x >> y;
		if (calcDis(x, y) <= dd)
			++ct;
	}
	cout << ct << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;
int n;

void CountingSort(vector<int>& A, vector<int>& B, int k)
{
	vector<int> C(k + 1);
	C.clear();

	for (int j = 1; j <= n; ++j)
		C[A[j]]++;

	for (int i = 1; i <= k; ++i)
		C[i] = C[i] + C[i - 1];

	for (int j = n; j > 0; --j)
		B[C[A[j]]] = A[j], C[A[j]]--;
}

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

	cin >> n;

	int max = 0;
	vector<int> A(n + 1), B(n + 1);
	for (int i = 1; i <= n; ++i)
	{
		cin >> A[i];
		if (A[i] > max) max = A[i];
	}
	
	CountingSort(A, B, max);

	cout << B[1];
	for (int i = 2; i <= n; ++i)
		cout << " " << B[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 16812
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1129&lang=jp

while arr = gets.split(" ").map(&:to_i)
  n , r = arr
  break if n == 0 && r == 0
  arr = n.times.map{|i| i+1}
  r.times.each do
    p, c = gets.split(" ").map(&:to_i)
    pick = arr.slice!(n-p-c+1, c)
    arr = arr + pick
  end
  p arr.last
end

Measured memory_bytes: 9360
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main(){
	uint16_t N;
	cin >> N;
	uint16_t *H;
	H = new uint16_t[N];

	for(uint16_t i = 0;i < N;++i)
		cin >> H[i];
	uint16_t res = 1;
	uint16_t j = 0;
	for(uint16_t i = 1;i < N;++i){
		for(j = 0;j < i;++j){
			if(H[i] < H[j])
				break;
		}
		if(j == i )
			++res;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
INF = 10**12
ans = [INF] * 26

for _ in range(N):
    S = input()
    tmp = [0] * 26
    for s in S:
        tmp[ord(s)-ord('a')] += 1
    
    for i in range(26):
        ans[i] = min(ans[i],tmp[i])

ansS = ''
for i in range(26):
    ansS += chr(i+97) * ans[i]

print(ansS)

Measured memory_bytes: 9144
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String A = s.replaceAll("0", "");
        String B = s.replaceAll("1", "");
        
        System.out.println(Math.min(A.length(), B.length())*2);
    }
}

Measured memory_bytes: 34864
//in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    //int t=222;while(t--){
    int n;
    cin>>n;
    int a[n];
    ll s=0,b,c,d,e;
    set<ll>se;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        s+=a[i];
        se.insert(a[i]);
    }
    if(se.size()==1)
        cout<<0<<endl;
    else
    {
        bool f=0;
        ll b=s/n;
            d=b+1;
            e=b-1;

        ll c=0,c1=0,c2=0;
        for(int i=0; i<n; i++)
        {
            c+=(a[i]-b)*(a[i]-b);

        }

            for(int i=0; i<n; i++)
            {
                c1+=(a[i]-d)*(a[i]-d);

            }
            for(int i=0; i<n; i++)
            {
                c2+=(a[i]-e)*(a[i]-e);

            }
           // cout<<c<<" "<<c1<<" "<<c2<<endl;
            c=min(min(c,c1),c2);

        cout<<c<<endl;
    }



    }






Measured memory_bytes: 3612