akhauriyash/Code-Regression huggingface dataset:
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
#define int long long 
#define pb push_back 
#define vii vector < int > 
#define pii pair < int , int >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// const ll mod=998244353;
const int  mod = 1000000000+7;
const int  N=1000000+6;
#define M_PI           3.14159265358979323846

// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
// int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
// int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
// int x2[]={-2,-2,-1,-1,+1,+1,+2,+2};
// int y2[]={-1,+1,-2,+2,-2,+2,-1,+1};

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===

main() 
{
    hs;
    int n;cin>>n;
    vector< pair<int,int> >  v(n);
    f(i,0,n)
    cin>>v[i].fi>>v[i].se;

    int mi=LONG_LONG_MAX,ma=LONG_LONG_MIN;
    f(i,0,n)
    {
        mi=min(mi,v[i].fi+v[i].se);
        ma=max(ma,v[i].fi+v[i].se);
    }
    int ans=ma-mi;
    mi=LONG_LONG_MAX,ma=LONG_LONG_MIN;
    f(i,0,n)
    {
        mi=min(mi,v[i].fi-v[i].se);ma=max(ma,v[i].fi-v[i].se);
    }
    ans=max(ans,ma-mi);
    cout<<ans;
} 

Measured memory_bytes: 6276
n=int(input())
t=[]
time=0
for i in range(n):
    a, b = map(int, input().split())
    t.append((a,b))

t_sort=sorted(t,key=lambda x: x[1])
for i in range(n):
    time+=t_sort[i][0]
    if time>t_sort[i][1]:
        print("No")
        break
    else:
        if i==(n-1):
            print("Yes")

Measured memory_bytes: 33408
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>

using namespace std;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
    if (b == 0) return a;
    return gcd(b, a%b);
}

unsigned long long int lcm(unsigned long long int a, unsigned long long int b){
    return (a*b)/gcd(a,b);
}

unsigned long long int not_divisor(unsigned long long int a, unsigned long long int b, unsigned long long int x){
    return x/a + x/b - x/lcm(a,b);
}

unsigned long long int A, B, C, D;

int main(){
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    unsigned long long int ret = ((B - (A-1)) - not_divisor(C,D,B)) + not_divisor(C,D,A-1);

    printf("%lld\r\n", ret);
    fflush(stdout);
    return 0;
}

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

using namespace std;

#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define INF 0x3f3f3f3f
#define f1(n) for(int i=0 ; i<n ; i++)
#define f2(m) for(int j=0 ; j<m ; j++)
#define ll long long
typedef pair<int, int> iPair;
const double epsilon = 1e-7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  
  int a = N/1000;
  int b = N/100 - a*10;
  int c = N/10 - a*100 - b*10;
  int d = N - a*1000 - b*100 -c*10;
  
  if(a == b && b == c || b == c && c == d ){
    cout << "Yes" << endl;
  }
  if(!(a == b && b == c || b == c && c == d )){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std; 
int main(){
  int n, k,i,sum; 
  cin>>n>>k; 
  int ar[n];
  for(i=0;i<n;i++){
    cin>>ar[i];
  }
  sort(ar,ar+n);
  sum=0;
  for(i=0;i<k;i++){
    sum=sum+ar[i];
  }
  cout<<sum; 
  return 0;
}

Measured memory_bytes: 3624
A,B,C,X,Y = map(int, input().split())

a_cnt = 0
b_cnt = 0
c_cnt = 0

if A + B > C * 2:
    c_cnt += min(X,Y) * 2
else:
    a_cnt = b_cnt = min(X,Y)

if X > Y:
    if A < C * 2:
        a_cnt += X-Y
    else:
        c_cnt += (X-Y) * 2
elif Y > X:
    if B < C * 2:
        b_cnt += Y-X
    else:
        c_cnt += (Y-X) * 2
print(a_cnt * A + b_cnt * B + c_cnt * C)


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int MAX = 1e5 + 5;

int dis[MAX];
int k;

int bfs(int source) {
	deque<int> dq;
	dq.push_back(source);
	memset(dis, 0x3F, sizeof dis);
	dis[source] = 1;
	while(!dq.empty()) {
		int cur = dq.front(); dq.pop_front();
		if(dis[(10 * cur) % k] > dis[cur]) {
			dis[(10 * cur) % k] = dis[cur];
			dq.push_front((10 * cur) % k);
		}
		if(dis[(cur + 1) % k] > dis[cur] + 1) {
			dis[(cur + 1) % k] = dis[cur] + 1;
			dq.push_back((cur + 1) % k);
		}
	}
	return dis[0];
}

int main() {
	scanf("%d", &k);
	printf("%d\n", bfs(1));
	return 0;
}



Measured memory_bytes: 896
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1
  else:A[k]=R[j];j+=1;c+=m-l-i
 return c
def s(A,l,r):
 if l+1<r:
  m=(l+r)//2
  return s(A,l,m)+s(A,m,r)+g(A,l,m,r)
 else:return 0
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(c)


Measured memory_bytes: 27484
def sel_sort(A, N):
    ''' 選択ソート '''
    count = 0
    for n in range(N):
        minm = n
        for m in range(n, N):
            if A[m] < A[minm]:
                minm = m
            
        if minm != n:
            A[n], A[minm] = A[minm], A[n]
            count += 1
    
    return (A, count)


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    ans = sel_sort(A, N)

    print(' '.join([str(x) for x in ans[0]]))
    print(ans[1])


Measured memory_bytes: 5608
N = int(input())
W = [input() for _ in range(N)]

ans = "Yes"
if len(set(W)) != N:
    ans = "No"
else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            ans = "No"
            break
print(ans)

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

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 3005;
int N;
double P[MAX_N];

double dp[MAX_N][MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> P[n];
  }

  dp[0][0] = 1.0;
  REP(n,N) {
    REP(m,n+1) {
      dp[n+1][m] += dp[n][m]*(1.0-P[n]);
      dp[n+1][m+1] += dp[n][m]*(P[n]);
    }
  }

  double ans = 0.0;
  FOR(m,(N+1)/2,N+1) {
    ans += dp[N][m];
  }
  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 68992
from collections import Counter
N = int(input())
S = []
T = []
for i in range(N):
    S.append(input())
M = int(input())
for i in range(M):
    T.append(input())
ans = 0
#SS = set(S)|set(T)
CS = Counter(S)
CT = Counter(T)
A = [0]
for x in CS:
    if CS[x] > CT[x]:
        A.append(CS[x]-CT[x])
print(max(A))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
struct union_find{
    vector<ll> parent;
    union_find(ll n){
        parent.resize(n);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry) parent[rx] = ry;
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }
};

int main(){
    ll N, M;
    cin >> N >> M;
    union_find t(N);
    rep(i, 0, M){
        ll x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        t.unite(x, y);
    }
    map<ll,ll> mp;
    rep(i, 0, N){
        mp[t.root(i)]++;
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 7296
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long mod = (long)1e9+7;
		long[] iv = new long[N];
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(A[j] < A[i]) iv[i]++;
			}
		}
		
		long[] iv2 = new long[N];
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				if(A[j] < A[i]) iv2[i]++;
			}
		}
		
		long ans = 0;
		for(int i=0;i<N;i++){
			ans += (K - 1) * K / 2 % mod * iv[i] % mod;
			ans %= mod;
			ans += K * iv2[i] % mod;
			ans %= mod;
		}
		Console.WriteLine(ans );
		
		
		
	}
	int N;
	long K;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13156
from heapq import heappop, heappush
N, K = map(int, input().split())
AB = []

cnt = 0
for i in range(N):
  a, b = map(int, input().split())
  heappush(AB, (a, b))


while AB:
  a, b = heappop(AB)
  cnt += b
  
  if K <= cnt:
    print(a)
    exit()

Measured memory_bytes: 16660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b; cin >> a >> b;
    if (a == b) cout << "Draw" << endl;
    else if (a == 1) cout << "Alice" << endl;
    else if (b == 1) cout << "Bob" << endl;
    else if (a < b) cout << "Bob" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]
last = W[0][0]
flag = True
for i in W:
    if(W.count(i)>1 or last!=i[0]):
        flag = False
        break
    else:
        last = i[-1]
if(flag):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
s = input()
l = len(s)
ans = 0
search = l-1

if search < 2:
    print(0)
    exit()

while search >= 2:
    if search % 2 == 0:
        if s[0:search//2] == s[search//2:search]:
            ans = max(ans, search)
    else:
        pass
    search -= 1
print(ans)

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

#define ll long long int
#define rep(i,a,n) for(ll i=(a); i<(n); i++)
#define chmin(x,y) {x = min(x,y); }
#define chmax(x,y) {x = max(x,y); }

using namespace std;

ll N, M, MOD=1000000007;
vector<ll> s(4000);
vector<ll> t(4000);

// dp[i][j]: i,j番目が部分共通文字列となるときの組み合わせ数
ll dp[4000][4000];

ll memo[4000][4000];

ll sum(ll i, ll j) {
	if (memo[i][j] != -1)
		return memo[i][j];
	ll res;
	if (i == 0 && j == 0) {
		res= dp[0][0];
	} else if (i == 0) {
		res = dp[0][j] + sum(0, j-1);
	} else if (j == 0) {
		res= dp[i][0] + sum(i-1, 0);
	} else {
		// res = dp[i][j] + sum(i-1, j) + sum(i, j-1) - sum(i-1, j-1);
		res = dp[i][j];
	        (res += sum(i-1, j)) %= MOD;
		(res += sum(i, j-1)) %= MOD;
		(res += MOD - sum(i-1,j-1)) %= MOD;
	}
	res %= MOD;
	return memo[i][j] = res;
}

signed main() {
	cin>>N>>M;
	rep(i,0,4000) rep(j,0,4000) memo[i][j]=-1;
	rep(i,1,N+1) cin>>s[i];
	rep(i,1,M+1) cin>>t[i];
	for (ll i=1; i<=N; i++)
		for (ll j=1; j<=M; j++) {
			if (s[i] == t[j]) {
				dp[i][j] = sum(i-1, j-1) + 1;
			} else {
				dp[i][j] = 0;
			}
			dp[i][j] %= MOD;
		}

	ll ans = 1 + sum(N, M);
	ans %= MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 188800
n = int(input())
s = input() 

ans = 0
for i in range(1,n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    if len(x) >= len(y):
        ans = max(ans, len(x) - len(list(set(x)- set(y))))
    else:
        ans = max(ans, len(y) - len(list(set(y)- set(x))))


print(ans)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define inf 1000000007 //10^9+7
#define for(i,n) for(int i=0;i<n;i++)
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define in(a,b,vec,n) a n; cin>>n; vector<b>vec(n);
#define gcd __gcd
using namespace std;

signed main() {
  in(int,int,vec,n);
  for(i,n) cin>>vec.at(i);
  rever(vec);
  for(i,n) {
    if(i%2==0) {
      cout<<vec.at(i)<<" ";
    }
  }
  rever(vec);
  if(n%2==0) {
    for(i,n) {
      if(i%2==0) {
        if(i<n-1) {
          cout<<vec.at(i)<<" ";
        }
        else {
          cout<<vec.at(i)<<endl;
        }
      }
    }
  }
  else {
    for(i,n) {
      if(i%2==1) {
        if(i<n) {
          cout<<vec.at(i)<<" ";
        }
        else {
          cout<<vec.at(i)<<endl;
        }
      }
    }
  }
}

Measured memory_bytes: 3712
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(2e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    
    int n;
    cin>>n;
    int mx = 61;
    int arr[mx] = {0};
    for(int i=0;i<mx;i++)
    	arr[i] = 0;

    int p[mx];
    p[0]=1;
    for(int i=1;i<mx;i++)
    	p[i] = (p[i-1]*2)%MOD;

    for(int i=0;i<n;i++){
    	int x;cin>>x;
    	for(int j=0;j<mx;j++)
    		if(x&(1LL<<j))
    			arr[j]++;
    }
    // for(int i=0;i<mx;i++)
    // 	cout<<arr[i]<< " ";
    int ans = 0;
    for(int i=0;i<mx;i++){
    	int one = arr[i];
    	int zero = n-one;
    	int tmp = one*zero;
    	tmp%=MOD;
    	tmp = (tmp*p[i])%MOD;
    	ans = ans + tmp;
    	ans%=MOD;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
struct unionfind{
	int par[16];
	void init(int N){rep(i,N) par[i]=i;}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		par[y]=x;
	}
}UF;

typedef pair<int,int> P;
typedef pair<double,P> edge;
int N;
double x[16],y[16],a[16];
double c[1<<16];
double dp[1<<16];
vector<edge> es;
double inf=1e50;
bool B(int x,int i){return (x>>i)&1;}
int main(){
	int N;
	cin>>N;
	rep(i,N) cin>>x[i]>>y[i]>>a[i];
	rep(i,N) rep(j,i){
		double dis=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		es.pb(edge(dis,P(j,i)));
	}
	sort(all(es));
	rep(b,1<<N){
		if(b==0) continue;
		UF.init(N);
		double sum=0;
		rep(i,N) if(B(b,i)) sum+=a[i];
		for(edge e:es){
			double d=e.fs;
			int x=e.sc.fs,y=e.sc.sc;
			if(B(b,x)&&B(b,y)&&!UF.same(x,y)){
				sum-=d;
				UF.unite(x,y);
			}
		}
		c[b]=max(0.0,sum/__builtin_popcount(b));
	}
	dp[0]=inf;
	rep(b,1<<N){
		int left=(1<<N)-1-b;
		int x=left;
		do{
			chmax(dp[b|x],min(dp[b],c[x]));
			x=(x-1)&left;
		}while(x!=0);
	}
	printf("%.12f\n",dp[(1<<N)-1]);
}


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

int main(){
  int N;
  cin >> N;
  int ans=1;
  for (int i=2;i<=sqrt(N);i++){
    for (int j=2;pow(i,j)<=N;j++){
      ans=max(ans,int(pow(i,j)));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: m = 10 ** 9 + 7
  integer(8) :: n, k, i, g, res
  integer(8), allocatable :: s(:), t(:)
  read *, n, k
  allocate (s(k), t(k))
  do i = 1, k
    t(i) = get_t(i)
  end do
  s(:) = t(:)
  do g = k, 1, -1
    do i = 2, k / g
      s(g) = s(g) - s(i * g)
      s(g) = modulo(s(g), m)
    end do
  end do
  res = 0
  do g = 1, k
    res = res + g * s(g)
    res = modulo(res, m)
  end do
  print "(i0)", res

  contains

  integer(8) function get_t(f)
    integer(8), intent(in) :: f
    integer(8) :: ng
    ng = k / f
    get_t = pow(ng, n)
  end function get_t

  recursive function pow(n, p) result(res)
    integer(8), intent(in) :: n, p
    integer(8) :: res, buf(0:31), i
    buf(0) = modulo(n, m)
    do i = 1, 31
      buf(i) = modulo(buf(i - 1) ** 2, m)
    end do
    res = 1
    do i = 0, 31
      if (btest(p, i)) then
        res = res * buf(i)
        res = modulo(res, m)
      end if
    end do
  end function pow
end program main


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

int main()
{
    int x;
    cin >> x;

    ll ans = (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
  int W;
  int H;
  int x;
  int y;
  int r;
int main(void){
  cin>>W>>H>>x>>y>>r;
  if(W >= x + r && 0 <= x - r &&H >= y + r &&0 <= y - r) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

void compress(vector<int>& v) {
	auto vs = v;
	sort(vs.begin(), vs.end());
	vs.erase(unique(vs.begin(), vs.end()), vs.end());
	for (auto& val : v) {
		val = lower_bound(vs.begin(), vs.end(), val) - vs.begin();
	}
}

int main()
{
	int N;
	cin >> N;
	vector<int> S(1 << N);
	for (int i = 0; i < (1 << N); i++) {
		cin >> S[i];
	}
	compress(S);
	sort(S.rbegin(), S.rend());
	if (count(S.begin(), S.end(), S[0]) > 1) {
		puts("No");
		return 0;
	}
	const int M = S[0] + 1;
	vector<int> cnt(M + 1);
	for (int i = 0; i < (1 << N); i++) {
		cnt[S[i]]++;
	}
	vector<int> dp(N, 1);
	bool ng = false;
	for (int i = M - 2; i >= 0; i--) {
		auto tmp = dp;
		for (int j = 0; j < cnt[i]; j++) {
			bool ok = false;
			for (int k = N - 1; k >= 0; k--) if (tmp[k] > 0) {
				--tmp[k], --dp[k];
				for (int l = 0; l < k; l++) {
					++dp[l];
				}
				ok = true;
				break;
			}
			if (!ok) {
				ng = true;
			}
		}
	}
	puts(ng ? "No" : "Yes");
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int diff(int a, int b) {
    if (a < b) return b - a;
    return a - b;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector< pair<int, int> > s(n), c(m);
    for (int i = 0; i < n; ++i) cin >> s.at(i).first >> s.at(i).second;
    for (int i = 0; i < m; ++i) cin >> c.at(i).first >> c.at(i).second;
    for (int i = 0; i < n; ++i) {
        vector<int> d(m);
        for (int j = 0; j < m; ++j) d.at(j) = diff(s.at(i).first, c.at(j).first) + diff(s.at(i).second, c.at(j).second);
        cout << min_element(d.begin(), d.end()) - d.begin() + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int prime[] = new int[100004];
		Arrays.fill(prime, 1);

		for (int i = 2; i <= 100003; i++) {
			int tmp = i;
			int next = i * 2;
			int j = 3;
			while (next <= 100003) {
				prime[next] = 0;
				next = tmp * j;
				j++;
			}
		}

		for (int i = X; i <= 100003; i++) {
			if (prime[i] == 1) {
				System.out.println(i);
				break;
			}
		}
	}
}

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

const int N = 110;
const int mod = 998244353;

typedef long long LL;

map<string, int> f, g;

int solve(string s);

vector<int> divs[N];

int fold(string s) {
    if (s.size() == 1) return 1 + (s[0] == '1');
    if (f.count(s)) return f[s];
    int res = 0;
    for (auto l : divs[s.size()]) {
        string tmp;
        for (int i = 1; i <= l; i++) {
            bool flag = true;
            for (int j = i; flag && j <= s.size(); j += l)
                if (s[j - 1] != '1') flag = false;
            if (flag) tmp += '1';
            else tmp += '0';
        }
        res = (res + solve(tmp)) % mod;
    }
    return f[s] = res;
}

int solve(string s) {
    if (s.size() == 0) return 1;
    if (s.size() == 1) return 1 + (s[0] == '1');
    if (g.count(s)) return g[s];
    int res = 0; 
    for (int i = 1; i <= s.size(); i++) {
        string L, R;
        for (int j = 1; j <= s.size() - i; j++) L += s[j - 1];
        for (int j = s.size() - i + 1; j <= s.size(); j++) R += s[j - 1];
        res = (res + (LL)solve(L) * fold(R)) % mod;
    }
    return g[s] = res;
}

int main() {
    string s; cin >> s;
    for (int i = 1; i <= N - 10; i++)
        for (int j = i * 2; j <= N - 10; j += i) divs[j].push_back(i);
    printf("%d\n", solve(s));
    return 0;
}//

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

int main(void) {
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];
  bool key = true;

  for(int i = 0; i <= n-m; i++) {
    for(int j = 0; j <= n-m; j++) {
      key = true;
      for(int k = 0; k < m; k++) {
        if(b[k].compare(0,m,a[k+j],i,m) != 0) {
           key = false; break;
        }
      }
      if(key) {break;}
    }
    if(key)break;
  }
  if(key)
  cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll fd(ll n){
  rep(i,51){
    if((1LL<<i)&n){
      return i;
    }
  }
}
ll ed(ll n){
  for(ll i=50;i>=0;i--){
    if((1LL<<i)&n){
      return i;
    }
  }
}
ll pa(ll n){
  ll res=1LL<<fd(n);
  for(ll i=fd(n)+1;i<=50;i++){
    if(i==ed(n))break;
    if(!((1LL<<i)&n)){
      res+=1LL<<i;
    }
  }
  return res;
}
ll r(ll n){
  for(ll i=50;i>=0;i--){
    if((1LL<<i)&n){
      return i+1;
    }
  }
}
int main(){
  ll n;
  cin>>n;
  map<ll,ll> p;
  vll a(n);
  rep(i,n){
    cin>>a[i];
    p[a[i]]++;
  }
  sort(rall(a));
  ll ans=0;
  rep(i,n){
    if(p[a[i]]==0)continue;
    if(p[(1LL<<r(a[i]))-a[i]]){
      if(((1LL<<r(a[i]))-a[i]==a[i])&&(p[(1LL<<r(a[i]))-a[i]]<2)) continue;
    ans++;
    p[(1LL<<r(a[i]))-a[i]]--;
    p[a[i]]--;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 26752
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
map<int,int> mp;
int n,m;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		mp[a]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int a;
		cin>>a;
		if(mp[a]>0){
			mp[a]--;
		}
		else{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

int main(){

    int h, w;
    cin >> h >> w;
    vector<vector<char>> v(h, vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> v[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(v[i][j] == '#'){
                bool ok = false;
                for(int dx = -1; dx <= 1; dx+=2){
                    if(j+dx < 0 || j+dx >= w) continue;
                    if(v[i][j+dx] == '#') ok = true;
                }
                
                for(int dy = -1; dy <= 1; dy+=2){
                    if(i+dy < 0 || i+dy >= h) continue;
                    if(v[i+dy][j] == '#') ok = true;
                }                
                if(!ok){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,A,B;
ll H[101010];

ll i, j, k;


bool bs(ll aa){
    ll i, ct = 0;
    fornum(i,0,N){
        ll h = H[i];
        h -= aa * B;
        if(h>0){
            ct += (h - 1) / (A - B) + 1;
        }
    }
    return aa >= ct;
}

int main(){
    scanf("%lld%lld%lld", &N, &A, &B);
    fornum(i,0,N){
        scanf("%lld", &H[i]);
    }
    ll l = 0, r = 1e9;
    while(l<r){
        ll c = (l + r) / 2;
        if(bs(c)){
            r = c;
        }else{
            l = c + 1;
        }
    }
    printf("%lld", l);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
std::pair<string,pair<int,int>> Q[101];
    ll N,M,K;
    ll A,B,C;
    bool F[5][5];
    bool ad=false;
    ll ans=0;
    string S;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>K;
    do{
        N/=K;
        ans++;
    }while(N>=1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const x = parseInt(args[0][0], 10)
	const y = parseInt(args[0][1], 10)
	const group1 = [1, 3, 5, 7, 8, 10, 12]
	const group2 = [4, 6, 9, 11]

	let f1 = false 
	let f2 = false

	for (let i = 0; i < group1.length; i++) {
		if (x === group1[i]) f1 = true 
		if (y === group1[i]) f2 = true
	}

	let f3 = false 
	let f4 = false

	for (let i = 0; i < group2.length; i++) {
		if (x === group2[i]) f3 = true 
		if (y === group2[i]) f4 = true
	}

	if (f1 && f2) console.log('Yes')
	else if (f3 && f4) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int lbound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] >= b){
			e = m;
		}
		else{
			s = m;
		}
	}
	if(v[max(s - 1, 0)] >= b) return max(s - 1, 0);
	else if(v[s] >= b) return s;
	else if(v[min(s + 1, l - 1)] >= b) return min(s + 1, l - 1);
	else return v.size();
}

long long N, M;
vector<long long> A, B, C;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	for(int i=0; i<M; i++){
		long long b, c;
		cin >> b >> c;
		B.push_back(b);
		C.push_back(c);
	}
	for(int i=0; i<M; i++){
		if(i<M-1 && B[i+1]==N && C[i+1]>=C[i]) continue;
		long long b = B[i];
		long long c = C[i];
		long long k = (long long)lbound(A, c);
		long long u = min(k, b);
		if(k > 0){
			for(int j = u; j <= k - 1; j++){
				A[j - u] = A[j];
			}
			for(int j = k - u; j <= k - 1; j++){
				A[j] = c;
			}
		}
	}
	long long ans = 0;
	for(int i=0; i<N; i++){
		ans += A[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
 
#define rep(i,n) for(int i = 0; i < n; i++)
 
typedef long long ll;
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

bool check(string s){
  string tmp = s;
  bool ok = false;
  if(s.size()==1) return true;
  rep(i,s.size()/2){
    if(s[i] == tmp[s.size()-1-i]) ok = true;
    else return false;
  }
  return ok;
}
 
int main(){
  string s1,s2="",s3="";
  cin >> s1;
  int l = s1.size();
  int a = (l-1)/2, b = (l+3)/2;  
  rep(i,l){
    if(i<=(a-1)) s2+=s1[i];
    if((b-1)<=i && i<=(l-1)) s3+=s1[i];
  }
  if(check(s1) && check(s2) && check(s3)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque
H, W = map(int, input().split())
sh, sw = map(int, input().split())
sh -= 1
sw -= 1
gh, gw = map(int, input().split())
gh -= 1
gw -= 1

C = []
for i in range(H):
    C.append(list(input()))

d = deque()
kabe = deque()
d.append([sh, sw])
looked = [[0 for i in range(W)]for j in range(H)]
looked[sh][sw] = 1
ans = 0
dx_dy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
kabe.append([sh, sw])
while d:
    x = d.pop()
    lookx = x[0]
    looky = x[1]
    for i in dx_dy:
        a = lookx+i[0]
        b = looky+i[1]
        if not(0 <= a < H) or not(0 <= b < W) or looked[a][b] == 1:
            continue
        if C[a][b] == "#":
            kabe.append([lookx, looky])
            continue
        if a == gh and b == gw:
            print(ans)
            sys.exit()
        d.append([a, b])
        looked[a][b] = 1

    if len(d) == 0:
        ans += 1
        ok = 0
        for _ in range(len(kabe)):
            kx, ky = kabe.pop()
            wapuxm = max(kx-2, 0)
            wapuxM = min(kx+2, H-1)
            wapuym = max(ky-2, 0)
            wapuyM = min(ky+2, W-1)
            for ki in range(wapuxm, wapuxM+1):
                for kj in range(wapuym, wapuyM+1):
                    if C[ki][kj] == "#" or looked[ki][kj] == 1:
                        continue
                    if C[ki][kj] == ".":
                        d.append([ki, kj])
                        looked[ki][kj] = 1
                        ok = 1
                    if ki == gh and kj == gw:
                        print(ans)
                        sys.exit()
        if ok == 0:
            print(-1)
            sys.exit()



Measured memory_bytes: 136372
import sys
readline = sys.stdin.readline

N,X = map(int,readline().split())

# レベルNバーガーの厚さ = (レベルN - 1バーガーの厚さ) * 2 + 3
# レベル1〜Nの厚さを先に求めておく

T = [1] * (N + 1)
for i in range(1, len(T)):
  T[i] = T[i - 1] * 2 + 3

# レベルNバーガーをX枚目まで食べたとき、パティを何枚食べるか
# レベルN - 1バーガーの厚さをtとする
# X = 1 : 0枚
# X <= t + 1 : レベルN - 1バーガーのX - 1枚目まで
# X = t + 2 : レベルN - 1バーガーのt枚目まで + 1
# X < t * 2 + 3 : レベルN - 1バーガーのすべてと、1枚と、レベルN - 1バーガーのX - (t + 2)枚目まで
# X = t : レベルN - 1バーガーのすべて * 2 + 1

def bargar(n,x):
  if n == 1:
    return min(x - 1, 3)
  t = T[n - 1] # レベルNバーガーの厚さ
  if x == 1:
    return 0
  elif x <= t + 1:
    return bargar(n - 1, x - 1)
  elif x == t + 2:
    return bargar(n - 1, t) + 1
  elif x < t * 2 + 3:
    return bargar(n - 1,t) + 1 + bargar(n - 1, x - (t + 2))
  else:
    return bargar(n - 1,t) * 2 + 1

print(bargar(N,X))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

ll n;
char s;

int main(){
  cin>>n;
  bool flf=false;
  for(ll i=0;i<n;i++){
    cin>>s;
    if(s=='Y')flf=true;
  }
  if(flf)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

ll mod = 1000000007;

ll expo(ll a, ll b) {
	a = a % mod;
	ll ret = 1;
	while(b) {
		if(b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b = b / 2;
	}
	return ret;
}

ll f[500005], invf[500005];

ll ncr(ll n, ll r) {
	ll ret = f[n];
	ret = (ret * invf[r]) % mod; 
	ret = (ret * invf[n - r]) % mod; 
	return ret;
}

signed main() {
    IO;

    f[0] = 1;
    invf[0] = expo(f[0], mod - 2);
    for(ll i = 1; i < 500005; ++i) {
    	f[i] = (f[i - 1] * i) % mod;
    	invf[i] = expo(f[i], mod - 2);
    }
    
    ll ans = 0, n, m, r1, r2;
    cin >> n >> m;

    r1 = ncr(m, n);
    r1 = (r1 * f[n]) % mod;
    ans = (r1 * r1) % mod;

    bool minus = true;

    for(ll i = 1; i <= n; ++i) {
 		
 		r1 = ncr(n, i);
 		r1 = (r1 * ncr(m, i)) % mod;
 		r1 = (r1 * f[i]) % mod;
 		
 		r2 = ncr(m - i, n - i);
 		r2 = (r2 * f[n - i]) % mod;
 		r2 = (r2 * r2) % mod;

 		r1 = (r1 * r2) % mod;

 		if(minus) {
    		ans = (ans - r1) % mod;
    	}	
    	else {
    		ans = (ans + r1) % mod;
    	}
    	ans = (ans + mod) % mod;
    	minus = !minus;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 11428
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num;
    while(cin>>num){
        char str;
        int hand[14]={};
        hand[num]++;
        for(int i=0;i<4;i++){
            cin>>str>>num;
            hand[num]++;
        }
        bool four=0,three=0,two[2]={};
        for(int i=1,j=0;i<14;i++){
            if(hand[i]==4)four=1;
            else if(hand[i]==3)three=1;
            else if(hand[i]==2){
                two[j]=1;
                j++;
            }
        }
        if(four)cout<<"four card"<<endl;
        else if(three&&two[0])cout<<"full house"<<endl;
        else if(three)cout<<"three card"<<endl;
        else if(two[1])cout<<"two pair"<<endl;
        else if(two[0])cout<<"one pair"<<endl;
        else{
            bool kawa=0;
            for(int i=1;i<=10;i++){
                if(hand[i]==1){
                    for(int j=0;j<5;j++){
                        if(j+i>13&&hand[1]!=1)break;
                        else if(j+i<14&&hand[i+j]!=1)break;
                        if(j==4)kawa=1;
                    }
                }
            }
            if(kawa)cout<<"straight"<<endl;
            else cout<<"null"<<endl;
        }

    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t; 
    //cin>>t;
    t=1;
    while(t--){
        ll n; cin>>n;
        ll arr[n][3];
        rep(i,0,n-1){
            rep(j,0,2){
                cin>>arr[i][j];
            }
        }
        ll dp[n][3]={0};
        dp[0][0] = arr[0][0];
        dp[0][1] = arr[0][1];
        dp[0][2] = arr[0][2];
        rep(i,1,n-1){
            dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
            dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
            dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
        }
        ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
        cout<<ans;
    }
}


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

int main(){
  int a1=0,a2=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]=='0')
        a1++;
      else
        a2++;
    }
    else{
      if(s[i]=='0')
        a2++;
      else
        a1++;
    }
  }
    cout << min(a1,a2) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define loop(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
int height, width,n;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> width >> height >> n;
	n--;
	int x, y;
	cin >> x >> y;
	int ans = 0;
	loop(i, n) {
		int nowX, nowY;
		cin >> nowX >> nowY;
		bool xincrease = (nowX - x) > 0;
		bool yincrease = (nowY - y) > 0;
		if (xincrease == yincrease) {
			ans += max(abs(nowX - x), abs(nowY - y));
		}
		else {
			ans += abs(nowX - x) + abs(nowY - y);

		}
		x = nowX; y = nowY;

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


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
int a,b;
  string S;
  cin >>a>>b>>S;
  int N = a+b-1;
  bool f = true;
  for(int i=0;i<N;i++){
   if((i > a || i < a) && (S[i] == '-') )f =false;
      else if (i==a && S[i] != '-') f = false;
  }
      if(f) cout << "Yes" <<endl;
      else cout << "No" <<endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(100000000)


def main():
    n, m = map(int, input().split())
    res = []
    # n = 2m+1を考える
    if m % 2 == 0:
        half_m = int(m / 2)
        for i in range(half_m):
            res.append((half_m - i, half_m + 1 + i))
            res.append((m + half_m - i, m + half_m + 2 + i))
    else:
        half_m = int(m / 2)
        for i in range(half_m):
            res.append((half_m - i, half_m + 2 + i))
            res.append((m + half_m + 1 - i, m + half_m + 2 + i))
        res.append((m + 1, m + 2 * half_m + 2))

    for r in res:
        print(str(r[0]) + " " + str(r[1]))


main()


Measured memory_bytes: 20880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

string s;

int main() {
	fastio; cin >> s;
	FOR(i, 0, s.length()-1) {
		if (s[i] == '?') cout << 'D';
		else cout << s[i];
	}
}


Measured memory_bytes: 3772
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Main app = new Main();
		Scanner scan = new Scanner(System.in);
		int[] num = new int[10];
		int ans;
		while(scan.hasNext()){
			app.input(num,scan);
			ans = app.operation(num);
			System.out.println(ans);
		}
	}
	
	public int operation(int[] num){
		int i,j;
		int[] tmp = new int[10];
		for(i=0;i<10;i++){
			tmp[i] = num[i];
		}
		
		for(i=9;i>=1;i--){
			for(j=0;j<i;j++){
				num[j] = tmp[j]+tmp[j+1];
				if(num[j]>=10){
					num[j]-=10;
				}
			}
			for(j=0;j<i;j++){
				tmp[j] = num[j];
			}
		}
		
		return num[0];
	}
	
	public void input(int[] num,Scanner scan){
		String str = scan.nextLine();
		for(int i=0;i<str.length();i++){
			num[i] = Integer.parseInt(""+str.charAt(i));
		}
	}
}

Measured memory_bytes: 17148
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll ans = 1;
    ll mod = 1e9+7;
    int n; cin >> n;
    rng(i,1,n+1){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/06/09
 *      Author: family
 */

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

int W[101] = {0};

int main()
{
	int N = 0, i = 0;
	int sall = 0, s1 = 0, s2 = 0, ans = 0x7fffffff;
	scanf("%d", &N);
	for(i = 0; i < N; i++) {
		scanf("%d", &W[i]);
		sall += W[i];
	}
	s2 = sall;
	for(i = 0; i < N-1; i++) {
		s1 += W[i];
        s2 -= W[i];
        if(abs(s1 - s2) < ans) {
        	ans = abs(s1 - s2);
        }
	}
	printf("%d\n",ans);
    return 0;
}


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

int main(){
	double v, y;
	while(cin >> v){
	y = 4.9 * pow(v / 9.8, 2);
	int n;
	for(n = 0;;n++){
		if(y <= 5*n-5)break;
	}
	cout << n << endl;
	}
	return 0; 
}
//25.4
//32

Measured memory_bytes: 3124