akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000
#define N 200001

using namespace std;
ll table[N + 2];

ll power(ll n, ll k, ll mod){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % mod;
    n = n * n % mod;
    k >>= 1;
  }
  return res;
}

ll popcount(ll a){
  ll ret = 0;
  for (int i = 0; i <= 20; i++){
    if ((a >> i) == 0)
      break;

    if ((a >> i) & 1)
      ret++;
  }
  return ret;
}

void make_table(){
  for (int i = 1; i <= N; i++){
    ll t = i;
    ll num = 0;
    while (t != 0){
      t = t % popcount(t);
      num++;
    }
    table[i] = num;
  }
}

int main(void){
  make_table();

  ll n;
  cin >> n;
  
  string x;
  cin >> x;
  
  ll pc = 0;
  for (int i = 0; i < n; i++){
    if (x[i] == '1')
      pc++;
  }
  if (pc != 1 && pc != 0){
    ll rem[2] = {0, 0};
    for (int j = 0; j < n; j++){
      if (x[j] == '1'){
        rem[0] = (rem[0] + power(2, n-j-1, pc-1)) % (pc-1);
        rem[1] = (rem[1] + power(2, n-j-1, pc+1)) % (pc+1);
      }
    }
    for (int i = 0; i < n; i++){
      if (x[i] == '1'){
        ll t = (rem[0] - power(2, n - i - 1, pc-1) + pc-1) % (pc-1);
        cout << table[t] + 1 << endl;
      }
      else {
        ll t = (rem[1] + power(2, n - i - 1, pc+1) + pc+1) % (pc+1);
        cout << table[t] + 1 << endl;
      }
    }
  }
  else if (pc == 0){
    for (int i = 0; i < n; i++){
      cout << 1 << endl;
    }
  }
  else if (pc == 1){
    ll rem[1] = {0};
    for (int j = 0; j < n; j++){
      if (x[j] == '1'){
        rem[1] = (rem[1] + power(2, n-j-1, pc+1)) % (pc+1);
      }
    }
    for (int i = 0; i < n; i++){
      if (x[i] == '1'){
        cout << 0 << endl;
      }
      else {
        ll t = (rem[1] + power(2, n - i - 1, pc+1) + pc+1) % (pc+1);
        cout << table[t] + 1 << endl;
      }
    }
 
  }

  

  return 0;
}


Measured memory_bytes: 5280
#include <cstdio>
#include <algorithm>

int main()
{
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  long long ans1 = (b - a) & 1 ? (long long)(4e18) : (b - a) / 2;
  long long ans2 = (a - 1) + 1 + (b - a) / 2;
  long long ans3 = (n - b) + 1 + (b - a) / 2;
  printf("%lld\n", std::min(std::min(ans1, ans2), ans3));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int n, m, i, j, d1[36] = {}, d2[36] = {};
	char t1[36] = {}, t2[36] = {};
	cin >> n;
	for(i = 0; i < n; ++i){
		cin >> t1[i] >> d1[i];
		t2[i] = t1[i];
		d2[i] = d1[i];
	}

	for(i = 0; i < n; ++i){
		for(j = n - 1; j > i; --j){
			if( d1[j] < d1[j-1] ){
				swap(d1[j], d1[j-1]);
				swap(t1[j], t1[j-1]);
			}
		}
	}

	for(i = 0; i < n; ++i){
		cout << t1[i] << d1[i];
		if( i != n -1 )
			cout << " ";
	}
	cout << "\nStable\n";

	for(i = 0; i < n; ++i){
		m = i;
		for(j = i; j < n; ++j){
			if( d2[j] < d2[m] )
				m = j;
		}
		if( i != m){
			swap(d2[i], d2[m]);
			swap(t2[i], t2[m]);
		}
	}

	for(i = 0; i < n; ++i){
		cout << t2[i] << d2[i];
		if( i != n -1 )
			cout << " ";
	}
	cout << "\n";

	bool stable = true;
	for(i = 0; i < n; ++i){
		if( t1[i] != t2[i] )
			stable = false;
	}

	if(stable) cout << "Stable\n";
	else cout << "Not stable\n";

	return 0;
}

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

typedef long long ll;
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define MOD 10e9+7

void max_self(int& a, int b) { a=a>b?a:b; }
void min_self(int& a, int b) { a=a<b?a:b; }

using namespace std;

int n, k;

int main() {
    cin >> n >> k;
    

    k+=k+1;
    cout << (n+k-1)/k << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

	vector<char> abc { 'a', 'b', 'c' };
	vector<char> tmp;
	char t;

	cin >> t;
	tmp.push_back(t);
	cin >> t;
	tmp.push_back(t);
	cin >> t;
	tmp.push_back(t);

	if ( is_permutation(abc.begin(), abc.end(), tmp.begin()) )
		cout << "Yes" << endl;
	else
		cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
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 <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

char in[5];
int main() {
	scanf("%s", in);
	sort(in, in + 3);
	if (strcmp(in, "abc") == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

int main()
{
	int x, a;
	std::cin >> x >> a;

	std::cout << (x >= a ? 10 : 0) << std::endl;

	return 0;
}

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

typedef pair<ll, int> P;

int sum[100000];
int tsum[100000];


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

	int N, R, L;
	cin >> N >> R >> L;
	int cur = 0;

	set<P> s;
	for(int i = 0; i < N; i++) {
		s.insert({ 0, i });
	}

	while(R--) {
		int d, t, x;
		cin >> d >> t >> x;
		d--;

		int dt = t - cur;
		int top = s.begin()->second;
		tsum[top] += dt;

		s.erase({ -sum[d], d });
		sum[d] += x;
		s.insert({ -sum[d], d });
		cur = t;
	}

	int dt = L - cur;
	int top = s.begin()->second;
	tsum[top] += dt;

	int tmax = *max_element(tsum, tsum + N);
	for(int i = 0; i < N; i++) {
		if(tsum[i] == tmax) {
			cout << i + 1 << endl;
			break;
		}
	}
}

Measured memory_bytes: 9992
class CumulativeSum2D:
  def __init__(self,a):
    self.h=len(a)
    self.w=len(a[0])
    self.s=[(self.w+1)*[0]for _ in range(self.h+1)]
    for i in range(self.h):
      for j in range(self.w):
        self.s[i+1][j+1]=self.s[i+1][j]+self.s[i][j+1]-self.s[i][j]+a[i][j]
  def su(self,i1,j1,i2,j2):
    return self.s[i2+1][j2+1]-self.s[i1][j2+1]-self.s[i2+1][j1]+self.s[i1][j1]
  def prin(self):
    for i in self.s:print(i)
h,w,kk=map(int,input().split())
h-=1
b=[list(map(int,list(input())))for _ in range(h+1)]
bs=CumulativeSum2D(b)
ans=h+w-1
for i in range(2**h):
  bi=[-1]+[j for j in range(h)if (1<<j)&i]+[h]
  anss=len(bi)-2
  flag=False
  cut=[0]
  for k in range(w):
    for j in range(len(bi)-1):
      up=bi[j]+1
      down=bi[j+1]
      s=bs.su(up,cut[-1],down,k)
      if s>kk:
        if k==cut[-1]:flag=True
        else:cut.append(k)
        break
    if flag:break
  if flag:continue
  anss+=len(cut)-1
  ans=min(ans,anss)
print(ans)

Measured memory_bytes: 44124
def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def mod_fac(a, mod):
    ret = 1
    for aa in range(1, a + 1):
        ret *= aa
        ret %= mod
    return ret


def main():
    MOD = 10**9 + 7
    N = int(input())
    X = list(map(int, input().split()))
    ans = 0
    for n in range(N - 1):
        ans += (X[N - 1] - X[n]) * mod_inv(n + 1, MOD)
    ans *= mod_fac(N - 1, MOD)
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20292
#temprate
from sys import setrecursionlimit
setrecursionlimit(10**6)
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#temprate
N = int(input())
A = inputlist()
B = inputlist()
C = [A[i]-B[i] for i in range(N)]
s = sum(C)
if s < 0:
    print(-1)
    exit()
C.sort()
ans = 0
for i in range(N):
    if C[i] <0:
        pass
    elif C[i] <= s:
        ans +=1
        s -= C[i]
    else:
        break
print(N-ans)

Measured memory_bytes: 18668
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)

#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal var
//------------------------------------------
 
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  str S,T;
  while(cin >> S >> T){
    if(S==T){
      cout << S << endl;
      return 0;
    }
    str ans = "UNRESTORABLE";
    vector<string> ansV;
    reverse(ALL(S));
    reverse(ALL(T));
    str orgS=S;
    int lS=S.length();
    int lT=T.length();
    REP(i,lS-lT+1){
      int flg=true;
      S = orgS;
      REP(j,lT){
        if(S[i+j]!='?'&&S[i+j]!=T[j]){
          flg=false;
          break;
        } 
      }
      if(flg){
        S.replace(S.begin()+i,S.begin()+i+lT,T);
        EACH(j,S){
          if(*j=='?') *j='a';
        }
        reverse(ALL(S));
        ansV.PB(S);
      }
    }
    if(!ansV.empty()){
      SORT(ansV);
      ans = ansV[0];
    }
    cout << ans <<  endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int cnt[100010];
main(){
    int N,A;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A;
        cnt[A]++;
    }
    int maxn,maxi;
    maxn = cnt[0] + cnt[1];
    maxi = 0;
    for(int i = 1;i < 99999;i++){
        if(maxn < cnt[i] + cnt[i-1] + cnt[i+1]){
            maxn = cnt[i] + cnt[i-1] + cnt[i+1];
            maxi = i;
        }
    }
    if(maxn < cnt[99998] + cnt[99999]){
        maxn = cnt[99998] + cnt[99999];
    }
    cout << maxn << endl;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
int main(){
	int x,y,z=1E9,sum=0;
	cin>>x>>y;
	for(int i=0;i!=x;++i){
		int temp;
		cin>>temp;
		z=min(z,temp);
		sum+=temp;
	}
	cout<<x+(y-sum)/z;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,i;
  scanf("%d %d",&a,&b);
  for(i=1;i<=2000;i++){
    if((8*i/100==a)&&(10*i/100==b)){
      printf("%d\n",i);
      return 0;
    }
  }

  printf("-1\n");
  return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a,const void *b)
{
    return (*(char*)b-*(char*)a);
}
int main()
{
    int n,i;
    scanf("%d",&n);
    char s[n][11];
    for(i=0; i<n; i++)
    {
        scanf("%s",s[i]);
        qsort(s[i],10,sizeof(char),cmp);
    }
    qsort(s,n,sizeof(char)*11,strcmp);
    long long ans=0,c=0;
    for(i=1; i<n; i++)
        if(strcmp(s[i],s[i-1])==0)
        {
            c++;
            ans+=c;
        }
        else
            c=0;
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
  vector<long long> n(3);
  cin >> n.at(0) >> n.at(1) >> n.at(2);
  
  sort(n.begin(), n.end());
  if(n.at(0)*n.at(1)%2 && n.at(2)%2) cout << n.at(0)*n.at(1) << endl;
  else cout << 0 << endl;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string s; cin >> s;
        cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=100050;
int dp[N][3],a[N][3];
int f[3]={1,2,0};
int g[3]={2,0,1};
int main()
{
int n;
scanf("%i",&n);
for(int i=1;i<=n;i++) 
for(int j=0;j<3;j++)
scanf("%i",&a[i][j]);
for(int i=1;i<=n;i++) 
for(int j=0;j<3;j++)
dp[i][j]=max(dp[i-1][f[j]],dp[i-1][g[j]])+a[i][j];
int ans=max(dp[n][0],dp[n][1]);
ans=max(ans,dp[n][2]);
printf("%i",ans);
return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,A,B;cin>>N>>A>>B;
  vector<int> X(N);
  REP(i,0,N)cin>>X[i];
  int ans=0;
  REP(i,1,N){
    if((X[i]-X[i-1])*A>B){
      ans+=B;
    }
    else {
      ans+=(X[i]-X[i-1])*A;
    }
  }
  print(ans);

}


Measured memory_bytes: 1024
#include <stdio.h>

    int main(void)
    { 
        int x,a; 
        a=1;
        while(1){
        x=0;
        scanf("%d",&x);
        if(x==0){
           break;
        }
        printf("Case %d: %d\n",a,x);
        a++;
    
        }
	return 0;
    }

Measured memory_bytes: 600
# Traveling Salesman around Lake https://atcoder.jp/contests/abc160/tasks/abc160_c
N,K= map(int, input().split())

Travel_List=list(map(int,input().split()))
for i in range(K):
    Travel_List.append(Travel_List[i]+N)

Answer =0 
for i in range(K):
    Temp = Travel_List[i+K-1]-Travel_List[i]
    if (i==0) or (Temp<Answer):
        Answer=Temp
    


    
print(Answer)

Measured memory_bytes: 26000
import java.util.*;


public class Main {

    private static final int INF = 1000000007;
    private static final int INF1 = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int train = n * a;

        int result = 0;

        if(train <= b){
            result = train;
        }else{
            result = b;
        }

        System.out.println(result);


    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,l;
  cin>>n>>l;
  int a[200];
  int sum=0;
  rep(i,n){
    a[i]=l+i;
    sum+=a[i];
  }
  if(l>0) cout<<sum-a[0]<<endl;
  else if(l+n-1 < 0) cout<<sum-a[n-1]<<endl;
  else cout<<sum<<endl;
  
  return 0;
}


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

int main(){
	int mem[31] = {};
	int x;
	for(int i = 1; i <= 28; i++){
		cin >> x;
		mem[x]++;
	}
	for(int i = 1; i <= 30; i++){
		if(mem[i] == 0){
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int m1,d1,m2,d2;

    cin>>m1>>d1>>m2>>d2;

    if(m1!=m2){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc113/tasks/abc113_c

City = Struct.new(:p, :y, :id)

N, M = gets.split.map(&:to_i)
cs = Array.new(M)
M.times do |i|
  cs[i] = City.new(*gets.split.map(&:to_i), nil)
end

cs
.group_by { |c| c.p }
.each do |_k, vs|
  vs
  .sort_by { |v| v.y }
  .each.with_index(1) do |v, i|
    v.id = format('%06d', v.p) + format('%06d', i)
  end
end

cs.each { |c| puts "#{c.id}" }


Measured memory_bytes: 35324
#include<iostream>
#include<string>
using namespace std;;
int main(void){
long long n;
cin >>n;
long long a[n];
int guusuu=0;
int  kisuu=0;
for(int i=0;i<n;i++){
cin >>a[i];
if((a[i]%2)==0){
guusuu++;
}
else{
kisuu++;
}
}
long long ans1=1;
for(int i=0;i<guusuu;i++){
ans1=ans1*2;
}
long long ans2=1;
for(int i=0;i<n;i++){
ans2=ans2*3;
}
ans2=ans2-ans1;
cout <<ans2;

return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#尺取り法

import numpy as np
n, k = map(int,input().split())
a = np.array(list(map(int,input().split())))
a.sort()
posi = a[a>0]
zero = a[a==0]
nega = a[a<0]
#print(posi)
# 2分探索, midより小さいものを数える
l = -10**18-1
r = 10**18+1
while r-l > 1:
    mid = (r+l)//2
    cnt = 0
    if mid >= 0:
        cnt += len(zero)*n

    # a.searchsorted(v, side="left"): a[i-1] < v <= a[i]であるvのindexを返す
    # a.searchsorted(v, side="right"): a[i-1] <= v < a[i]であるvのindexを返す

    cnt += a.searchsorted(mid//posi, side="right").sum()
    cnt += (n - a.searchsorted(-(-mid//nega), side="left")).sum()
    cnt -= np.count_nonzero(a*a <= mid)
    cnt //= 2
    #print("mid:", mid)
    #print("mid//posi:", mid//posi)
    #print("search:", a.searchsorted(mid//posi,side="right"))
    #print("-(-mid//nega):", -(-mid//nega))
    #print("search:", a.searchsorted(-(-mid//nega),side="left"))
    #print("nonzero_count:", np.count_nonzero(a*a<=mid))
    #print("count:", cnt)
    #print('-' * 20)
    if cnt >= k:
        r = mid
    else:
        l = mid
print(r)

Measured memory_bytes: 32276
/*
 
 */
 #include <bits/stdc++.h>
 
 using namespace std;
 
 #define ll           long long int
 #define vi 			 vector<int>
 #define pb           push_back
 #define fi           first
 #define si           second
 #define pii 		 pair<int,int>
 #define vii 		 vector<pair<int,int>>
 #define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
 #define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
 #define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
 #define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
 #define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
 #define mem(a,b)     memset(a, b, sizeof a)
 #define matrix(x) 	 vector<vector<x>>
 #define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
 #define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
 #define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
 #define PNF1(a,n,m)  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
 const int nax = 1e7;
 const int mod = 1e9+7;
 
 int main(){
 	fastIO
 	ll n, a, b;
 	vector<ll> v, vc;
 	cin>>n;
 	for(int i=0; i<n; i++){
 		cin>>a>>b;
 		v.pb(a+b);
 		vc.pb(a-b);
 	}
 	sort(v.begin(), v.end());
 	sort(vc.begin(), vc.end());
 	cout<<max(v.back()-v[0], abs(vc.back() - vc[0]));
 }

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int main() {
	int64_t A, B, C;
	cin >> A >> B >> C;
	set<vector<int64_t>> seen;
	int steps = 0;
	while (1) {
		if (A%2 || B%2 || C%2) {
			cout << steps << endl;
			return 0;
		}
		vector<int64_t> curr = {A, B, C};
		if (seen.count(curr)) {
			cout << -1 << endl;
			return 0;
		}
		seen.insert(curr);
		int64_t nA = B/2+C/2, nB = A/2+C/2, nC = A/2+B/2;
		A = nA;
		B = nB;
		C = nC;
		++steps;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    int64 ans=0;
    cin>>N;
    vector<int64> B(N);
    for(int64 i=1;i<N;i++){
        cin>>B[i];
    }
    ans+=B[1];
    for(int64 i=2;i<N;i++){
        ans+=min(B[i-1],B[i]);
    }
    ans+=B[N-1];

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }

    cout << mp.size() << endl;

}

Measured memory_bytes: 19228
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  s <- getLine
  print $ solve s

solve s = min p g' - min g p'
  where
    l = length s
    (p, g) = (l `div` 2, l - p)
    (p', g') = (length $ filter (== 'p') s, length $ filter (== 'g') s)

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

int main(){
  int N;
  scanf("%d",&N);
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    scanf("%d",&H[i]);
  }

  int count = 0, max = 0;
  for (int i = 0; i < N - 1; i++){
    if (H[i] >= H[i+1])
      count++;
    else
      count = 0;
    if (max < count)
      max = count;
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 640
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
typedef long long LL;
typedef unsigned long long ULL;

int a[55];

int main()
{
    int m,n,s;
    cin>>n>>m;
    for(int i=1;i<=m*2;i++)
    {
        cin>>s;
        a[s]++;
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;
    return 0;
}





















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

int main(){
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	long long minv = min({a, b, c, d, e});
	cout << (n + minv - 1) / minv + 4 << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int w = sc.nextInt();
        int h = sc.nextInt();
        char[][] q = new char[w][h];
        int[][] a = new int[w][h];
        
        for(int i=0; i<w; i++){
            String s = sc.next();
            for(int j=0; j<h; j++){
                q[i][j] = s.charAt(j);
                a[i][j] = 0;
            }
        }
        
        for(int i=0; i<w; i++){
            for(int j=0; j<h; j++){
                if(q[i][j]=='#'){
                    a[i][j]=100;
                    if(i!=0){
                        if(j!=0){
                            a[i-1][j-1]++;
                        }
                        a[i-1][j]++;
                        if(j!=h-1){
                            a[i-1][j+1]++;
                        }
                    }
                    if(j!=0){
                        a[i][j-1]++;
                    }
                    if(j!=h-1){
                        a[i][j+1]++;
                    }
                    if(i!=w-1){
                        if(j!=0){
                            a[i+1][j-1]++;
                        }
                        a[i+1][j]++;
                        if(j!=h-1){
                            a[i+1][j+1]++;
                        }
                    }
                }
            }
        }
        
         for(int i=0; i<w; i++){
            for(int j=0; j<h; j++){
                if(a[i][j]<100){
                    System.out.print(a[i][j]);
                }else{
                    System.out.print("#");
                }
            }
            System.out.println();
        }
        
        
   }
}


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

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
     
        int A, B;
        A = sc.nextInt();
        B = sc.nextInt();
        if(A + B < 10)
            System.out.println(A + B);
        else
            System.out.println("error");
    }
}

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

int diff(string x, string y) {
    int ans = 0;
    for (int i = 0; i < x.size(); ++i) {
        ans += x[i] != y[i];
    }
    return ans;
}

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = 1001001001;
    for (int i = 0; i < n - m + 1; ++i) {
        ans = min(ans, diff(s.substr(i, m), t));
    }
    cout << ans << endl;
}


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

int main()
{
    int n;
    cin >> n;
    set<int> st;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        st.insert(a);
    }
    if((int)st.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n; ll x;
ll a[100100];
ll ans;
int main()
{
	scanf("%d%lld", &n, &x);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		if (a[i] > x)
		{
			ans += a[i] - x;
			a[i] = x;
		}
	}
	for (int i = 2; i <= n; i++)
	{
		if (a[i - 1] + a[i] > x)
		{
			ll v = a[i - 1] + a[i] - x;
			a[i] -= v;
			ans += v;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
# from math import gcd
def gcd(a,b):
    if b == 0 :return a
    return gcd(b,a%b)


n = int(input())
arr = [int(x) for x in input().split()]


ans = arr[0]

for i in range(1,n):
    ans = gcd(ans,arr[i])

print(ans)


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

int main(){
    int n;  cin>>n;
    int v[n];   for(int i=0;i<n;i++)cin>>v[i];
    int c[n];   for(int i=0;i<n;i++)cin>>c[i];

    int x_y[n];
    for(int i=0;i<n;i++){
        x_y[i]=v[i]-c[i];
    }

    int sum=0;

    for(int i=0;i<n;i++){
        if(x_y[i]>0)sum+=x_y[i];
    }

    cout<<sum<<endl;


    return 0;
}


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

int main(){
	string s;
	cin >> s;
	ll k;
	cin >> k;
	rep(i,s.size()){
		if(i+1 == k){
			cout << s[i] << endl;
			return 0;
		}
		if(s[i] == '1') continue;
		if(s[i] != '1' || i == (s.size()-1)){
			cout << s[i] << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    unsigned long long n, a, b, cur;

    cin >> n >> a >> b >> cur;

    unsigned long long tot = 0;

    for(unsigned long long i = 1; i < n; ++i){
        unsigned long long nx;
        cin >> nx;
        tot += min(b, a * (nx - cur));
        cur = nx;
    }

    cout << tot;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
//  Table is the complete reverse of dp
//  Always think of the pattern (LCM, GCD)
//  Be careful of unsigned
//  double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it
int n, k, *x;
bool *dp[2];
int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    cin >> n >> k;
    x = new int[n];
    for(int i = 0; i < 2; i++)
    	dp[i] = new bool[k + 1];
    for(int i = 0; i < n; i++)
    	cin >> x[i];
    for(int i = 0; i < x[0]; i++)
    {
    	dp[0][i] = 1;
    	dp[1][i] = 0;
    }
    for(int i = x[0]; i <= k; i++)
    {
    	int ans0 = 0, ans1 = 0;
    	for(int j = 0; x[j] <= i && j < n; j++)
    	{
    		if(dp[0][i - x[j]])
    			ans0 = j;
    		if(!dp[1][i - x[j]])
    			ans1 = j;
    	}
    	dp[0][i] = dp[1][i - x[ans0]];
    	dp[1][i] = dp[0][i - x[ans1]];
    }
    cout << (dp[0][k]? "Second": "First");
}


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

class Main {

    int N, M, R;
    int[] r;
    int[][] d;
    int res = Integer.MAX_VALUE;
    boolean[] used;

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

    void dfs(int c, int las, int dist) {
        if (c == R) {
            if (res > dist) {
                res = dist;
            }
            return;
        }
        for (int i = 0; i < R; i++) {
            if (!used[i]) {
                used[i] = true;
                if (las == -1) {
                    dfs(c + 1, i, 0);
                } else {
                    dfs(c + 1, i, dist + d[r[las]][r[i]]);
                }
                used[i] = false;
            }
        }
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        R = sc.nextInt();
        r = new int[R];
        used = new boolean[R];
        for (int i = 0; i < R; i++) {
            r[i] = sc.nextInt() - 1;
        }
        d = new int[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(d[i], Integer.MAX_VALUE / 9);
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt() - 1;
            int B = sc.nextInt() - 1;
            int C = sc.nextInt();
            d[A][B] = C;
            d[B][A] = C;
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) {
                    d[j][k] = Math.min(d[j][k], d[j][i] + d[i][k]);
                }
            }
        }
        dfs(0, -1, 0);
        System.out.println(res);
    }
}


Measured memory_bytes: 46992
import java.util.*;

class Main{
    void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if ( a == b && c == d ||
             a == c && b == d ||
             a == d && b == c ) System.out.println("yes");
        else System.out.println("no");
    }

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




Measured memory_bytes: 26336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define sbit __builtin_popcount
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define sz(a) (int)a.size()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sp(x) setprecision(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
#define scni(x) scanf("%d",&x)
#define prt(x) printf("%d\n",x)
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> myset;
const int mod=1e9+7;
const int mex=1e6+1;
inline ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int pr[mex];
vec prime;
inline void seive()
{
    rp(i,2,mex) pr[i]=1;
    for(int i=2;i*i<mex;i++)
    {
        if(pr[i])
        for(int j=i*i;j<mex;j+=i)
        pr[j]=0;
    }
    vec prime;
    rp(i,2,mex)
    {
        if(pr[i]) prime.pb(i);
    }
}
ll int xx,xy,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        xx=1;
        xy=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=xx;
        xx=xy;
        xy=temp-(a1/b1)*xy;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (xx%M+M)%M;
}
int main()
{
    fast
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    fr(i,n-2)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') cnt++;
    }
    cout<<cnt;
    
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int L = 1, R = N;
    for(int i=0; i<M; i++){
        int l, r;
        cin >> l >> r;
        L = max(L, l);
        R = min(R, r);
    }
    cout << max(0, R-L+1) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
int solve(){
   string s;cin>>s;         
   if(s[2]==s[3] && s[4]==s[5]){
       cout<<"Yes"<<endl;
   }         
   else{
       cout<<"No"<<endl;
   }
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  int N,M,C,i,j,tmp,ans=0;
  cin >> N >> M >> C;

  int B[M];
  for(i=0 ; i<M ; i++){
    cin >> B[i];
  }

  int A[N][M];
  for(i=0 ; i<N ; i++){
    tmp = 0;
    for(j=0 ; j<M ; j++){
      cin >> A[i][j];
      tmp += A[i][j] * B[j];
    }
    if((tmp+C) > 0){
      ans++;
    }
  }

  cout << ans << endl;


}


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

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

        int N = sc.nextInt();

        int result = 0;
        if (N % 2 == 0) {
            result = N;
        } else {
            result = N * 2;
        }

        System.out.println(result);
    }
}

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


int main(){
	int n, m;
	cin >> n>>m;
	int a[100][100];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	int b[1000];
	for (int i = 0; i < m; i++){
		cin >> b[i];
	}
	int output = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			output+=a[i][j]*b[j];
		}
		cout << output<<endl;
		output = 0;
	}
}


Measured memory_bytes: 3120
#ABC8

N, Y = ( int(i) for i in input().split() )

#10000円札が最大何枚あるうるかを計算
A_max = Y // 10000  


for i in range(A_max + 1): #iは0...A_maxの値をとる
	Res_Y = Y - i * 10000 #各i毎に残りの金額を計算
	B_max = Res_Y // 5000 #その時に5000円札が最大何枚ありうるか計算
	for j in range(B_max + 1): #jは0...B_maxの値をとる
		A = i
		B = j
		C = (Res_Y - (j * 5000))//1000	#残りの金額を1000で割れば1000円札が何枚必要かわかる
		if A + B + C == N:
			print(A, B, C)
			break
	else:
		continue

	break
else:
	print(-1, -1, -1)


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

int main(){
	int h, w, B;
	char panel[6][6];
	cin >> h >> w >> B;
	for (int k = 0; k < h; k++) {
		string str;
		cin >> str;
		for (int i = 0; i < w; i++) {
			panel[k][i] = str[i];
		}
	}
	int Y = 1, X = 1, CNT = 0;
	for (int i = 0; i < h; i++) Y *= 2;
	for (int i = 0; i < w; i++) X *= 2;
	for (int y = 0; y < Y; y++) {
		for (int x = 0; x < X; x++) {
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					int pi = 1, pj = 1;
					for (int k = 0; k < i; k++) pi *= 2;
					for (int k = 0; k < j; k++) pj *= 2;
					if (panel[i][j] == '#' && y / pi % 2 == 0 && x / pj % 2 == 0) cnt++;
				}
			}
			if (cnt == B) CNT++;
		}
	}
	cout << CNT << endl;
}


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

int main(){
  int N;
  
  cin >> N;
  
  int t = N,tmp = 0;
  
  while(t > 0){
    tmp += t % 10;
    t = t / 10;
  }
  
  if(N % tmp == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3600
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[110][200000], a[200000], b[200000];
string str, ss;
bool f;
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Edge>vec[20000];
vector<edge>ed;
vector<LL>v[23];
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n>>m;
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, m) {
			if (j)
				dp[i][j] = max(dp[i][j], dp[i][j - 1] );
			if (i)
				dp[i][j] = max(dp[i][j],dp[i-1][j]);
			if (j + a[i] <= m)
				dp[i + 1][j + a[i]] = max(dp[i + 1][j + a[i]], dp[i][j] + b[i]);
		}
		dp[i + 1][m] = max(dp[i+1][m],dp[i][m]);
	}
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 160512
#include <iostream>
#include<string>
#include<sstream>
#include<stack>
using namespace std;

int main(){
    stack<int> s;
    string expr;
    getline(cin, expr);
    istringstream is(expr);
    while(!is.eof()){ 
        string op; is >> op;
        int tmp1, tmp2;
        switch(op[0]){ 
            case '+': 
                tmp1 = s.top(); s.pop();
                tmp2 = s.top(); s.pop();
                s.push(tmp2+tmp1);
                break; 
            case '-': 
                tmp1 = s.top(); s.pop();
                tmp2 = s.top(); s.pop();
                s.push(tmp2-tmp1);
                break; 
            case '*': 
                tmp1 = s.top(); s.pop();
                tmp2 = s.top(); s.pop();
                s.push(tmp2*tmp1);
                break; 
            default: 
                istringstream is2(op);
                is2 >> tmp1;
                s.push(tmp1);
                break; 
        }
    }
    cout<<s.top()<<endl;
    return 0;
}


Measured memory_bytes: 3192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    if(a!=c) cout<<1<<endl;
    else cout<<0<<endl;
}


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

using namespace std;

bool sameSet(int x, int y, const set<int> &s) {
    return s.find(x) != s.end() && s.find(y) != s.end();
};

int main() {
    int x, y;
    cin >> x >> y;
    set<int> s1{1, 3, 5, 7, 8, 10, 12}, s2{4, 6, 9, 11}, s3{2};

    if (sameSet(x, y, s1) || sameSet(x, y, s2) || sameSet(x, y, s3)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

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

int main(){
  int n,f[100][10],p[100][11];
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>f[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin>>p[i][j];
    }
  }
  long long ans=-1e18;
  for(int bit=1;bit<(1<<10);bit++){
    long long array[10]={},kaiten[n]={};
    long long rieki=0;
    for(int i=0;i<10;i++){
      if(bit&(1<<i)){
        array[i]++;
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<10;j++){
        if(array[j]==1&&f[i][j]==1){
          kaiten[i]++;
        }
      }
    }
    for(int i=0;i<n;i++){
      rieki+=p[i][kaiten[i]];
    }
    ans=max(rieki,ans);
  }
  cout<<ans<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K;
ll W[101010],D[101010];

ll cnt(ll v) {
	ll ret=0;
	int i;
	FOR(i,N) {
		if(v>=W[i]) ret+=1+(v-W[i])/D[i];
		if(ret>=K) return 1;
	}
	return 0;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>W[i]>>D[i];
	ll ret=(1LL<<62)-1;
	for(i=61;i>=0;i--) if(cnt(ret-(1LL<<i))) ret-=1LL<<i;
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1792