akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
bool b[8][8];
int ans=0,n,m,k;
char c;
void baoli(int row,int col)//&=1没涂色，需要统计；&=0涂红色，不用统计 
{
	int s=0,i,j;
//	bool d[8][8];
//	for(i=0;i<n;i++)
//	{
//		for(j=0;j<m;j++)
//		{
//			d[i][j]=b[i][j];
//		}
//	}
	for(i=0;i<n;i++)
	{
		if(row&(int(pow(2,i))))
			for(j=0;j<m;j++)
			{
				if(col&int(int(pow(2,j))))
					s+=b[i][j];
			}
	}
	if(s==k)ans++;
}
int main()
{
	int i,j;
	cin>>n>>m>>k;
	for(i=0;i<n;i++)
	{
		getchar();
		for(j=0;j<m;j++)
		{
			scanf("%c",&c);
			if(c=='.')b[i][j]=0;
			else b[i][j]=1;
		}
	}
	int maxi=pow(2,n),maxj=pow(2,m);
	for(i=0;i<maxi;i++)
	{
		for(j=0;j<maxj;j++)
		{
			baoli(i,j);
		}
	}
	//printf("%d\n",b[0][0]);//-----------
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4164
n,m=map(int,input().split())
a,b=[0]*n,[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
c,d=[0]*m,[0]*m
for i in range(m):
    c[i],d[i]=map(int,input().split())

for i in range(n):
    res=min(range(m),key=lambda j:abs(a[i]-c[j])+abs(b[i]-d[j]))
    print(res+1)


Measured memory_bytes: 39152
#include <stdio.h>

int main(void){
  int N,A,B;
  int ans = 0;

  scanf("%d%d%d",&N,&A,&B);

  for(int i = 1;i <= N;i++){
    int j = i;
    int sum = 0;
    while(j > 0){
      sum += j%10;
      j /= 10;
    }
    if(A <= sum && sum <= B){
      ans += i;
    }
  }

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

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

int main(){
	int n,m;
	cin>>n>>m;
	int a[n]={};
	int k[n]={};
	int ans=0, amax=0;
	int b;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	//cout<<"a";
	for(int i=0; i<m; i++){
		cin>>b;
		for(int j=0; j<n; j++){
			if(a[j]<=b){
				k[j]++;
				if(k[j]>amax){
				ans=j;
				amax=k[j];
				}
				break;
			}
			
		}
	}
	//for(int i=0; i<n; i++){
	//	cout<<a[i]<<" "<<k[i]<<endl;
	//}
	cout<<ans+1<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
main() {
	for(int n,p[7]={},a,i;cin>>n,n;){
		for(i=n;i--;)cin>>a,p[(a/10)<=5?a/10:6]++;
		for(i=0;i<7;p[i]=0,++i)cout<<p[i]<<endl;
	}
}

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

int main(){
  int x[5];
  int ans = 0;
  for(int i = 0; i < 5; i++){
    cin >> x[i];
    if(x[i] == 0){
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n";
#define all(c)  (c).begin(),(c).end()
#define SORT(a) sort((a).begin(),(a).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

string s;
string t;
int main(){
    cin >> s >> t;
    int n = s.size();
    t+=t;
    bool flag = false;
    REP(i,n*2){
        bool flag2 = true;
        REP(j,n){
            if(s[j]!=t[i+j])flag2=false;
        }
        if(flag2)flag=true;
    }
    if(flag){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
n,y=gets.chomp.split(" ").map(&:to_i)
found = false
catch(:break_loop) do
  (0..n).each do|ichiman|
    (0..n-ichiman).each do |gosen|
      sen = n - ichiman - gosen
      total = ichiman * 10000 + gosen * 5000 + sen * 1000
      if total == y
        puts "#{ichiman} #{gosen} #{sen}"
        found = true
        throw :break_loop
      end
    end
  end
end
puts '-1 -1 -1' unless found


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

using namespace std;

int main(void)
{
	int n, m;
	cin >> n >> m;
	string str;
	for (int i = 0; i < n; i++) {
		str.push_back('-');
	}
	for (int i = 0; i < m; i++) {
		int s, c;
		cin >> s >> c;
		if (str[s-1] != '-' && str[s-1] != '0'+c) {
			cout << -1 << endl;
			return 0;
		} else {
			str[s-1] = '0'+c;
		}
	}
	if (str[0] == '-') {
		if (n == 1)
			str[0] = '0';
		else
			str[0] = '1';
	}
	for (int i = 1; i < n; i++) {
		if (str[i] == '-')
			str[i] = '0';
	}
	if (n != 1 && str[0] == '0')
		cout << -1 << endl;
	else
		cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
  	int m1,m2,d1,d2; cin >> m1 >> d1 >> m2 >> d2;
  	if( m1 == 1 ||
       m1 == 3 ||
       m1 == 5 ||
       m1 == 7 ||
       m1 == 8 ||
       m1 == 10 ||
       m1 == 12)
    {
      if(d1 == 31)
      {
        cout << 1 << endl;
        return 0;
      }
        else
        {
          cout << 0 << endl;
        return 0;
        }
    }
  	else if(m1 == 2)
    {
      if(d1 == 28)
      {
        cout << 1 << endl;
        return 0;
      }
      else
      {
        cout << 0 << endl;
        return 0;
      }
    }
    else
    {
      if(d1 == 30)
      {
        cout << 1 << endl;
        return 0;
      }
      else
      {
        cout << 0 << endl;
        return 0;
      }
	}
  }

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int s=in();
  set<int> c;
  c.emplace(s);
  for(int i=1;;i++){
    int v = s%2 ? 3*s+1 : s/2;
    auto r = c.emplace(v);
    if(!r.second){
      cout << i+1 << endl;
      return 0;
    }
    s = v;
  }
  
  return 0;
}


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

int main()
{
    int a, b, d, r;
    double f;
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    cout << d << " " << r << " ";
    cout << fixed << setprecision(10) << f << endl;
}


Measured memory_bytes: 3284
N,M = map(int, input().split())
A = list(map(int, input().split()))
dp = [None]*(N+1)
dp[0] = ""
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed

def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])

Measured memory_bytes: 136924
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = a.length - 1; i >= 0; i--) {
            System.out.print(a[i]);
            if(i != 0) {
                System.out.print(" ");
            }
        }
        System.out.println("");
        sc.close();
    }
}


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k < a) cout << k << endl;
    else if (a + b >= k) cout << a << endl;
    else cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  cout << (m <= 4 ? "Heisei" : "TBD") << '\n';
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x, i, m;
  cin >> n >> k;
  m=0;
  for(i=0;i<n;i++) {
    cin >> x;
    if(x <= k / 2) {
      m += 2 * x;
    }
    else {
      m += 2 * (k - x);
    }
  }
  cout << m << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
 
int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}
 
int32_t main()
{
	fast;

	int h, a;
	cin>>h>>a;
	cout<<(h+a-1)/a<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=b;i>=a;i--)
#define sc(x) scanf("%d",&x)
#define pb push_back
int c[15];
int a[15][15];
int f[15];
int main(int argc, char** argv) {
	int n,m,x;
	cin>>n>>m>>x;
	rep(i,1,n)
	{
		sc(c[i]);
		rep(j,1,m)
		sc(a[i][j]);
	}
	int ans=1e9;
	rep(i,0,(1<<n)-1)
	{
		int now=0;
		memset(f,0,sizeof(f));
		rep(j,1,n)
		{
			if((1<<(j-1))&i)
			{
				now+=c[j];
				rep(k,1,m)
				{
					f[k]+=a[j][k];
				}
			}
		}
		int fg=0;
		rep(i,1,m)
		{
			if(f[i]<x)fg=1;
		}
		if(!fg)
		{
			//cout<<ans<<endl;
			ans=min(ans,now);
		}
	}
	if(ans==1e9)cout<<-1;
	else
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3764
# import numpy as np
# import math
# import copy
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M = map(int,input().split())
    pS = [input().split() for _ in range(M)]

    ACWA = [[0,0] for _ in range(N)]
    res = [0,0]

    for i in range(M):
        pnum = int(pS[i][0]) - 1
        result = pS[i][1]
        if result == 'AC':
            if ACWA[pnum][0] == 0:
                ACWA[pnum][0] += 1
                res[0] += 1
                res[1] += ACWA[pnum][1]
        elif result == 'WA':
            ACWA[pnum][1] += 1

    print(res[0],res[1])





main()


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


int main(){
	int N,K,M;
	cin >> N >> M >> K;
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			if(j*N + i*M - i*j*2 == K){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int g, b;
  scanf("%*d%d%d", &g, &b);
  int tmp = g * 10 + b;
  puts(tmp % 4 == 0 ? "YES" : "NO");
  return 0;
}


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

int main(){
	int b, f, r, v;
	int n;
	int people[4][3][10];

	cin >> n;

	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				people[i][j][k] = 0;
			}
		}
	}

	for(int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		people[b-1][f-1][r-1] += v;
	}

	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << ' ' << people[i][j][k];
			}
			cout << endl;
		}
		if(i != 3)
			cout << "####################" << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
def eat_candies(candies, x):
    eaten = max(0, candies[0] - x)
    candies[0] -= eaten
    for i in range(1, len(candies)):
        extra = max(0, candies[i-1] + candies[i] - x)
        candies[i] -= extra
        eaten += extra
    return eaten
        
        
if __name__ == '__main__':
    n, x = list(map(int, input().split()))
    candies = list(map(int, input().split()))
    print(eat_candies(candies, x))

Measured memory_bytes: 14252
loop do
  n = gets.to_i
  break if n.zero?
  i, j, k = n / 2, n / 2 + 1, 1
  s = Array.new(n) { Array.new n }
  while k <= n * n
    i, j = (i - 1) % n, (j + 1) % n while s[j][i]
    s[j][i] = k
    k += 1
    i, j = (i + 1) % n, (j + 1) % n
  end
  puts s.map {|r| r.map {|c| '%4d' % (c || 0) }.join }.join ?\n
end

Measured memory_bytes: 8756
def gcd(x,y):
  if x<y:
    x,y=y,x
  if y==0:
    return x
  return gcd(y,x%y)

N,K=map(int,input().split())
A=[int(i) for i in input().split()]
G=A[0]
for i in range(1,N):
  G=gcd(G,A[i])
if max(A)>=K and K%G==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 62576
#include <bits/stdc++.h>
using namespace std;
 
int main(){vector<char> n(9);
           cin>>n[0]>>n[1]>>n[2]>>n[3]>>n[4]>>n[5]>>n[6]>>n[7]>>n[8];
           cout<<n[0]<<n[4]<<n[8];}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX_N 1001000
const int INF = 1<<29;
int n,p[MAX_N];
int main(){
    cin>>n;
    rep(i,n)cin>>p[i];
    int min=INF;
    int count=0;
    rep(i,n){
        if(min>p[i]){
            count++;
            min=p[i];
            }

    }
    cout<<count<<endl;
}

Measured memory_bytes: 1024
N,K = map(int, input().split())
D = []
A = []
for _ in range(K):
    d = int(input())
    D.append(d)
    a = [int(i) for i in input().split()]
    A.append(a)

L = [1]*N
for a in A:
    for i in a:
        L[i-1] = 0
print(sum(L))

Measured memory_bytes: 67472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 2e5 + 5;
set<ll> gph[N];
ll val[N];
bool vis[N];
ll n, m;

void dfs(ll src, ll &ans){
    vis[src] = true;
    ll _max = INT_MIN;
    for(auto v : gph[src])
        _max = max(_max, val[v]);
    if(val[src] > _max)
        ans++;
    for(auto v : gph[src])
        if(!vis[v])
            dfs(v, ans);
}

void solve(){
    cin >> n >> m;
    for(ll i = 1; i <= n; i++){
        cin >> val[i];
        vis[i] = false;
    }
    for(ll i = 1; i <= m; i++){
        ll x, y;
        cin >> x >> y;
        gph[x].insert(y);
        gph[y].insert(x);
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(vis[i])
            continue;
        dfs(i, ans);
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 25320
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	string s;
	cin >> N >> s;
	for(int i = 0; i < 4; i++) {
		string t = "";
		for(int j = 0; j < 2; j++) t += (i&(1<<j))?"S":"W";
		for(int j = 1; j < s.size()+1; j++) {
			string tmp = string(t.end()-2,t.end());
			char add = (s[j%N]=='o') ? tmp[0] : ('S' + 'W' - tmp[0]);
			if(tmp[1] == 'W') add = 'S' + 'W' - add;
			t += add;
		}
		if(string(t.begin(), t.begin()+2) == string(t.end()-2, t.end())) {
			cout << string(t.begin(), t.begin()+N) << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string alpha = "";
    for(int i=0; i<26; i++){
        alpha += i + 'a';
    }
    for(int i=0; i<26; i++){
        alpha += i + 'A';
    }
    int N;
    cin >> N;
    while(N != 0){
        vector<int> key(N);
        for(int i=0; i<N; i++){
            cin >> key[i];
        }
        string S;
        cin >> S;
        for(int i=0; i<S.size(); i++){
            int now = S[i];
            if(islower(S[i])){
                now = S[i] - 'a';
            }else{
                now = S[i] - 'A' + 26;
            }
            cout << alpha[(now - key[i%N] + 52)%52];
        }
        cout << endl;
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < maxbits; j++)
		{
			dp[(i ^ 1) & 1][j][0][0] = 0;
			dp[(i ^ 1) & 1][j][0][1] = 0;
			dp[(i ^ 1) & 1][j][1][0] = 0;
			dp[(i ^ 1) & 1][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) & (maxbit - 1);

			int sum0 = (dp[i & 1][j][0][0] + dp[i & 1][j][1][0]) % 100000;
			int sum1 = (dp[i & 1][j][0][1] + dp[i & 1][j][1][1]) % 100000;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[(i ^ 1) & 1][conv[nxt]][0][0] += sum0;
				dp[(i ^ 1) & 1][conv[nxt]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[(i ^ 1) & 1][conv[nxt + 1]][1][0] += dp[i & 1][j][0][0];
					dp[(i ^ 1) & 1][conv[nxt + 1]][1][1] += dp[i & 1][j][0][1];

					dp[(i ^ 1) & 1][conv[nxt + 1]][1][0] %= 100000;
					dp[(i ^ 1) & 1][conv[nxt + 1]][1][1] %= 100000;

					dp[(i ^ 1) & 1][conv[nxt]][1][0] += (sum0 - dp[i & 1][j][0][0] + 100000);
					dp[(i ^ 1) & 1][conv[nxt]][1][1] += (sum1 - dp[i & 1][j][0][1] + 100000);
				}
				else
				{
					dp[(i ^ 1) & 1][conv[nxt]][1][0] += sum0;
					dp[(i ^ 1) & 1][conv[nxt]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[(i ^ 1) & 1][conv[nxt]][1][1] += sum0;
				}
				else
				{
					dp[(i ^ 1) & 1][conv[nxt]][1][0] += sum0;
				}

				dp[(i ^ 1) & 1][conv[nxt]][1][1] += sum1;
			}

			dp[(i ^ 1) & 1][conv[nxt]][1][0] %= 100000;
			dp[(i ^ 1) & 1][conv[nxt]][1][1] %= 100000;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= 100000;
	}

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

	return 0;
}

Measured memory_bytes: 3476
n=int(input())
X=[]
Y=[]
H=[]
for i in range(n):
  x,y,h=map(int,input().split())
  X.append(x)
  Y.append(y)
  H.append(h)
for x in range(101):
  for y in range(101):
    for i in range(n):
      if H[i]>0:
        h=H[i]+abs(X[i]-x)+abs(Y[i]-y)
    for i in range(n):
      if H[i]!=max(0,h-abs(X[i]-x)-abs(Y[i]-y)):
        break
    else: #for文の下のelseは(breakすることなしに)for文を抜けることができたら反映
      print(x,y,h)
      exit()

Measured memory_bytes: 3064
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
string S;
int ok=0;
vector<int > each[26];
vector<mp > v;

const int MAXN=2e5;
struct BIT{
	int bit[MAXN+10],n;
	int sum(int i){
		int s=0;
		while(i>0){
			s+=bit[i];
			i-=i &(-i);
		}
		return s;
	}
	int query(int l,int r){
//		if(l>r) retur
		return sum(r)-sum(l-1);
	}
	void add(int i,int x){
		while(i<=n){
			bit[i]+=x;
			i+= i&(-i);	
		}
	}
}f,t;

int main(){
	fastio;
	cin>>S;
	rep(i,S.length())
		each[S[i]-'a'].PB(i);
	f.n=t.n=S.length();
	rep(i,26){
		ok+=(each[i].size()&1);
	}
	if(ok>1){
		cout<<"-1\n";
		return 0;
	}
	rep(i,26){
		rep(j,each[i].size()/2){
			v.PB(II(each[i][j],each[i][each[i].size()-j-1]));
//			cout<<each[i][j]<<" "<<each[i][each[i].size()-j-1]<<endl;
		}
	}
	LL res=0;
	sort(ALL(v));
	rep(i,v.size()){
		int F,S;
		F=v[i].FIR,S=v[i].SEC;
		F++;
		S++;
		if(F==S) continue;
		f.add(F,1);
		t.add(S,1);
		res+=f.query(S+1,f.n)+t.sum(S-1)+t.sum(F-1);
	}
	rep(i,26){
		if(each[i].size()&1){
			int mid=each[i][each[i].size()/2];
			mid++;
			res+=f.query(mid+1,f.n)+t.query(1,mid-1);
			break;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3852
#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 100000;

int v[1 + MAXN];
long long sum[1 + MAXN];

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &v[i]);
        sum[i] = sum[i - 1] + v[i];
    }
    long long best = 0, now = 0;
    for (int i = n; i >= k + 1; i--)
        if (v[i] > 0)
            now += v[i];
    best = max(best, now + max(0LL, sum[k]));
    for (int i = k + 1; i <= n; i++) {
        if (v[i] > 0)
            now -= v[i];
        if (v[i - k] > 0)
            now += v[i - k];
        best = max(best, now + max(0LL, sum[i] - sum[i - k]));
    }
    printf("%lld\n", best);
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,K,ans = 0;
  cin >> H >> W >> K;
  string nums[H];
  for(int i = 0; i < H; i++){
    cin >> nums[i];
  }
  
  for(int i = 0; i < pow(2,H);i++){
    for(int j = 0; j < pow(2,W);j++){
      int c = 0;
      for(int x = 0; x < H; x++){
        for(int y = 0; y < W; y++){
          if( ((i>>x)&1) == 0 && ((j>>y)&1) == 0){
            if(nums[x][y] == '#'){c+=1;}
          }
        }
      }
      if(c == K){ans+= 1;}
    }
  }
  cout << ans;
  
}

Measured memory_bytes: 3984
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int a, b, c; cin >> a >> b >> c;//c > b > aにする
    int k; cin >> k;
    int cnt = 0;
     while (b <= a) {
        b *= 2;
        cnt++;
    }
    while (c <= b) {
        c *= 2;
        cnt++;
    }
    
    if (cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<cstdlib>
#include<cctype>
#include<cmath>
#define ll long long
#define inf 99999999
using namespace std;
int n,k;
map<int ,int> a;
int main()
{
    cin>>n>>k;
    int num;
    for(int i=0;i<n;i++){
        scanf("%d",&num);
        ++a[num];
    }
    if(a.size()<=k){
        cout<<0<<endl;
    }else{

        map<int,int>::iterator it;

        it = a.begin();
        int count[a.size()];
        int temp_count=0;
        while(it != a.end())
        {
            count[temp_count] = it->second;
            ++temp_count;
            //it->first;
            //it->second;
            it ++;
        }

        sort(count,count+temp_count);
        ll res=0;
        for(int i=0;i<(temp_count-k);i++){
            res+=count[i];
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 10496
import math
import random
import heapq
from collections import Counter, defaultdict
from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING
from functools import lru_cache, reduce
from itertools import combinations_with_replacement, product, combinations


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def mt(f):
    import time
    import sys

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        print(e - s, 'sec', file=sys.stderr)
        return ret

    return wrap


@mt
def slv(a, b):

    c = a - 1

    if b >= a:
        c += 1
    return c


def main():
    a, b = read_int_n()
    print(slv(a, b))


if __name__ == '__main__':
    main()

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

int64_t pow(int64_t a, int n){
	int64_t r = 1;
	while(n){
		if(n & 1) r *= a;
		a *= a;
		n >>= 1;
	}
	return r;
}

int main(){
	int n, p;
	cin >> n >> p;
	int odd = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a & 1) odd++;
	}
	cout << (odd ? pow(2, n - 1) : p ? 0 : pow(2, n)) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque

n, m = map(int, input().split())
xy = []
node = defaultdict(int)
branch = defaultdict(list)
dp = [0]*(n+1) 

for _ in range(m):
    x, y = map(int, input().split())
    xy.append([x, y])
    node[y] += 1 #入り込むノードの数
    branch[x].append(y) # 枝分かれ先


res = []
queue = deque([i for i in range(1, n+1) if node[i]==0])
while queue:
    v = queue.popleft()
    res.append(v)
    
    for u in branch[v]:
        dp[u] = max(dp[u], dp[v]+1)
        node[u] -= 1
        if node[u] == 0:
            queue.append(u)



print(max(dp))

Measured memory_bytes: 47976
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    h.append(0)
    num = 0

    while sum(h) > 0:
        for i in range(n+1):
            if i > 0:
                if h[i-1] != 0 and h[i] == 0:
                    num += 1
        for i in range(n+1):
            if h[i] != 0:
                h[i] -= 1
    print(num)
resolve()

Measured memory_bytes: 39280
package main

import "fmt"

type sunuke struct {
	sweets []int
}

func newSunuke(sweetsMax int) *sunuke {
	return &sunuke{
		sweets: make([]int, 0, sweetsMax),
	}
}

func (s *sunuke) feed(sweetsID int) {
	s.sweets = append(s.sweets, sweetsID)
}

func main() {
	var n, k int
	fmt.Scanf("%d%d", &n, &k)

	sunukes := make([]*sunuke, n)

	for i := 0; i < n; i++ { // すぬけn-iを作成
		sunukes[i] = newSunuke(k)
	}

	for i := 0; i < k; i++ { // お菓子の種類分だけループ
		var d int
		fmt.Scanf("%d", &d)      // お菓子iを配る人数を取得
		for j := 0; j < d; j++ { //お菓子iを配る対象を取得
			var x int
			fmt.Scanf("%d", &x)
			sunukes[x-1].feed(j)
		}
	}

	var count int = 0
	for i := 0; i < n; i++ {
		if len(sunukes[i].sweets) == 0 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 2588
#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

typedef struct {
	char name[11] = "\0";
	int time;
} P;

class Queue {
private:
	int size;
	P *queue;
	int head = 0;
	int tail = 0;
public:
	Queue(int n);
	void enqueue(P p);
	void dequeue();
	bool isEmpty();
	P get();
	void clear();
};

Queue::Queue(int n)
{
	size = n+1;
	queue = new P[size];
}

void Queue::enqueue(P p)
{
	queue[tail] = p;
	tail = (tail + 1) % size;
}

void Queue::dequeue()
{
	head = (head + 1) % size;
}

bool Queue::isEmpty()
{
	return head == tail;
}

P Queue::get()
{
	return queue[head];
}

void Queue::clear()
{
	delete[] queue;
}

int main(void)
{	
	int n, q;
	cin >> n >> q;
	
	Queue queue(n);
	for (int i = 0; i < n; i++) {
		P p;
		cin >> p.name;
		cin >> p.time;
		queue.enqueue(p);
	}
	
	int time = 0;
	while (!queue.isEmpty()) {
		P p = queue.get();
		if (p.time <= q) {
			time += p.time;
			queue.dequeue();
			cout << p.name << " ";
			cout << time << endl;
		} else {
			time += q;
			p.time -= q;
			queue.dequeue();
			queue.enqueue(p);
		}
	}
	
	queue.clear();
	return 0;
}

Measured memory_bytes: 3480
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] c = new char[h + 2][w + 2];

    for (int i = 0; i < (h + 2); i++) {
      if ((i == 0) || (i == (h + 1))) {
        for (int j = 0; j < (w + 2); j++) {
          c[i][j] = '#';
        }
      } else {
        String s = sc.next();
        for (int j = 0; j < (w + 2); j++) {
          if ((j == 0) || (j == (w + 1))) {
            c[i][j] = '#';
          } else {
            c[i][j] = s.charAt(j - 1);
          }
        }
      }
    }

    for (int i = 0; i < (h + 2); i++) {
      for (int j = 0; j < (w + 2); j++) {
        System.out.print(c[i][j]);
      }
      System.out.println();
    }

  }
}

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

int main()
{
  int y, m, d;
  long n[4], num;

  n[0] = 1868 * 10000 + 9 * 100 + 8;
  n[1] = 1912 * 10000 + 7 * 100 + 30;
  n[2] = 1926 * 10000 + 12 * 100 + 25;
  n[3] = 1989 * 10000 + 1 * 100 + 8;

  while (cin >> y >> m >> d){
    num = y * 10000 + m * 100 + d;
  
    if (n[0] <= num && num < n[1]){
      cout << "meiji " << y - 1867 << ' ' << m << ' ' << d;
    }
    else if (n[1] <= num && num < n[2]){
      cout << "taisho " << y - 1911 << ' ' << m << ' ' << d;
    }
    else if (n[2] <= num && num < n[3]){
      cout << "showa " << y - 1925 << ' ' << m << ' ' << d;
    }
    else if (n[3] <= num){
      cout << "heisei " << y - 1988 << ' ' << m << ' ' << d;
    }
    else {
      cout << "pre-meiji";
    }
    cout << endl;
  }
  return (0);
}

Measured memory_bytes: 1164
#include<stdio.h>
#include <math.h>
#include <stdlib.h>
int main (){
	//kkc
int n,m,a[52],b[52],c[52],d[52],i,j,e,f,g;
scanf("%d %d",&n, &m);
for(i=1;i<=n;i++){
scanf("%d %d",&a[i],&b[i]);
}
for(i=1;i<=m;i++){
scanf("%d %d",&c[i],&d[i]);
}
for(i=1;i<=n;i++){
e=500000000;
for(j=m;j>=1;j--){
f=abs(a[i]-c[j])+abs(b[i]-d[j]);
if (f<=e) {
e=f;
g=j;
}
}
printf("%d\n",g);
}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int64_t> l = { 2,1 };
	for (int i = 2; i <= n; i++) {
		l.push_back(l.at(i - 2) + l.at(i - 1));
	}
	cout << l.at(n) << endl;
	system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>                                                         
using namespace std;
int main()
{
  int N;
  cin >> N;
  int i=0;
  while(1){
    if(i*i>N){
      cout << (i-1)*(i-1) << endl;
      break;
    }
    i++;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[105][100005];
int n, m;
int w[105];
long long v[105];
long long rec(int x,int y){
	if(y > m)return (long long)-9999999999999999;
	if(x == n)return 0;
	if(dp[x][y] != -1)return dp[x][y];
	return dp[x][y] = max(rec(x+1, y), rec(x+1, y+w[x]) + v[x]);
}
int main(){
	for(int i = 0; i <= 100; i++)
		for(int j = 0; j <= 100000; j++)dp[i][j] = -1;
	cin >> n >> m;
	for(int i = 0; i < n; i++)cin >> w[i] >> v[i];
	cout << rec(0,0);
}

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


int main(){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<int> ab, cd;
  for (int a = 0; (a * A) * 100 <= F; a++) {
    for (int b = 0; (b * B  + a * A) * 100 <= F; b++) {
      ab.push_back(a*A*100 + b*B*100);
    }
  }

  for (int c = 0; c * C<= F; c++) {
    for (int d = 0; d * D <= F; d++) {
      cd.push_back(c*C + d*D);
    }
  }
  sort(cd.begin(), cd.end());
  sort(ab.begin(), ab.end());
  pair<int,int> res;
  res.first = 100*A;
  res.second = 0;
  double mx = -1;
  for (int i = 1; i < sz(ab); i++) {
    for (int j = 1; j < sz(cd); j++) {
      if (ab[i] + cd[j] > F) break;
      if (100 * cd[j] > ab[i] * E) break;
      if (mx  < ((1.0*cd[j])/(1.0*(ab[i]+cd[j])))) {
        mx = ((1.0*cd[j])/(1.0*(ab[i]+cd[j])));
        res.first = ab[i] + cd[j];
        res.second = cd[j];
      }
    }
  }
  cout << res.first << " " << res.second << endl;
  return 0;
} 

Measured memory_bytes: 2420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc082_a solver = new abc082_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc082_a {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            out.println((int) Math.ceil(((double) in.scanInt() + in.scanInt()) / 2));
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 20692
#include <iostream>
#include <utility>
#include <array>
#include <vector>
using namespace std;

int main(){
	int n, jtemp, ptemp;
	string stemp;
	cin >> n;
	vector<pair<string, array<int, 2>>> s(n);
	for(int i=0; i<n; i++){
		cin >> s[i].first >> s[i].second[0];
		s[i].second[1] = 0;
	}	
	
	//stemp = s[0].first;
	//ptemp = s[0].second[0];
	//jtemp = 0;
	for(int i=0; i<n; i++){
		stemp = "zzzzzzzzzz";
		ptemp = -1;
		jtemp = 0;
		for(int j=0; j<n; j++){
			if(s[j].second[1]==0 && stemp >= s[j].first){
				if(stemp == s[j].first && ptemp > s[j].second[0]){
					continue;
				}
				stemp = s[j].first;
				ptemp = s[j].second[0];
				jtemp = j;
			}
		}
		s[jtemp].second[1] = i+1;
		cout << jtemp+1 << endl;
	}
	//for(int i=0; i<n; i++){
	//	cout << s[i].first << " " << s[i].second[0] << " " << s[i].second[1] << endl;
	//}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string a,b,ans;
int main(){
	int n;
	cin>>n;
	cin>>a>>b;
	for(int i=0;i<n;i++){
		ans.push_back(a[i]);
		ans.push_back(b[i]);  
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
  int n;
  cin>>n;
  int h[n+1];
  h[0]=0;
  int ans=0;
  for(int i=1;i<=n;i++) cin>>h[i];
  for(int i=1;i<=n;i++){
      if(h[i]>h[i-1]) ans+=h[i]-h[i-1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
main::IO()
main =do
  _<-getLine
  dc<-getLine
  let dat = map read (words dc) ::[Int]
  putStr ((if (solver dat) then "YES" else "NO")++"\n")
  
solver::[Int]->Bool
solver xs =  if mod (sum (map (\ x -> mod x 2) xs)) 2 == 1 then False else True

Measured memory_bytes: 59772
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  int n;cin >> n;
  while(n--){
    int a,b;cin >> a >> b;
    if(d.left()==a) d.roll('E');
    if(d.right()==a) d.roll('W');
    while(d.top()!=a) d.roll('N');
    while(d.front()!=b) d.roll('R');
    cout << d.right() << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
from math import floor, ceil
A, B = [int(x) for x in input().split(" ")]

min_origin_a = ceil(A*12.5)     # contains
max_origin_a = ceil((A+1)*12.5)       # not contains

flag = False
for i in range(min_origin_a, max_origin_a):
    if floor(0.1*i) == B:
        print(i)
        flag = True
        break

if not flag:
    print(-1)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define INF (1e+18)
int main(void) {
    int num;
    cin >> num;
    vector<int> arr(num);
    cins(arr);
    int64_t sum = 0;
    for(int i = 0; i < num; i++) {
        sum += arr[i];
    }

    int64_t mmin = INF;
    int64_t left = 0;
    for(int i = 0; i < num-1; i++) {
        left += arr[i];
        mmin = min(mmin, abs(sum-left-left));
    }
    cout << mmin << endl;
    return 0;
}

Measured memory_bytes: 3988
import java.util.*;
     
    public class Main{
         public static void main(String[] args) {
             Scanner sc=new Scanner(System.in);
             
       for(;;){
       int n=sc.nextInt();
         if(n==0) break;
        int N[]=new int[n+1];
         
        for(int i=0;i<n+1;i++){N[i]=sc.nextInt();}
         
        bi:for(int i=0;i<n+1;i++){
            List<Integer>tousa=new ArrayList<Integer>();
        for(int p=0;p<n+1;p++){
            tousa.add(N[p]);}
        tousa.remove(i);
            for(int p=0;p<n-2;p++){
                if(tousa.get(p)-tousa.get(p+1)!=tousa.get(p+1)-tousa.get(p+2)){continue bi;}
            }System.out.println(N[i]);break;
          }}}}
         
         
         
         
         
         

Measured memory_bytes: 54816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  string s;
  cin >> s;

  int ans=1000;
  for(int i=0; i<s.size()-2; i++){
    int a=s[i]-'0', b=s[i+1]-'0', c=s[i+2]-'0';
    ans=min(ans, abs(753-(100*a+10*b+c)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if((A==7&&B==5&&C==5)||(A==5&&B==7&&C==5)||(A==5&&B==5&&C==7)) printf("YES\n");
	else printf("NO\n");
	return 0;
 } 

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

using namespace std;

int main() {
	int len, sum;
	string str;

	while (cin >> str, str[0] != '0') {
		len = str.length();
		sum = 0;
		for (int i = 0; i < len; ++i) {
			sum += str[i] - '0';
		}		
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 3232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
using namespace std;

int main(){
  stack<int> stk;
  char s[10];
  while(scanf("%s",s)!=EOF){
    if(strcmp(s,"+")==0){
      int ope1 = stk.top();
      stk.pop();
      int ope2 = stk.top();
      stk.pop();
      stk.push(ope1+ope2);
    }
    else if(strcmp(s,"-")==0){
      int ope1 = stk.top();
      stk.pop();
      int ope2 = stk.top();
      stk.pop();
      stk.push(ope2-ope1);
    }
    else if(strcmp(s,"*")==0){
      int ope1 = stk.top();
      stk.pop();
      int ope2 = stk.top();
      stk.pop();
      stk.push(ope1*ope2);
    }
    else{
      int x = atoi(s);
      stk.push(x);
    }
  }
  printf("%d\n",stk.top());
  return 0;
}

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();

    if( n == m ){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n, k;
    string s;
    cin>>n>>s>>k;
    k--;
    char x=s[k];
    rep(i,n){
        if(s[i]!=x){ 
            s[i]='*';
        }
    }
    out(s);
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n,k,a[200010];

bool isOK(int x){
	int sum = 0;
	for(int i = 0;i < n;i++){
		sum += (a[i] - 1) / x;
	}
	return (sum <= k);
}

signed main(){
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	int ng = 0,ok = INF;
	while(ok - ng > 1){
		int mid = (ok + ng) / 2;
		if(isOK(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

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

N,K = map(int,readline().split())
A = [0] + list(map(int,readline().split()))

pos = 1

while K:
  if K & 1:
    pos = A[pos]
  A = [A[A[i]] for i in range(N + 1)]
  K >>= 1
  
print(pos)

Measured memory_bytes: 31220