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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> p;


long mod_pow(ll a, int p){
  if(p == 0) return 1;
  if(p % 2 == 0){
    int half_p = p / 2;
    long half = mod_pow(a, half_p);
    return half * half % MOD;
  }else{
    return a * mod_pow(a, p-1) % MOD;
  }
}

long long comb(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)

    ll mul = 1;
    ll div = 1;
    for(int i = 0; i < r; i++) {
      mul *= (n-i);
      div *= (i+1);
      mul %= MOD;
      div %= MOD;
    }
    ll ans = mul * mod_pow(div, MOD-2) % MOD;
    return ans;
}

vector<pair<ll, int>> factoring(ll a){
  vector<pair<ll, int>> v;
  for (int i = 2; i <= a; i++) {
    if(a % i == 0){
      int count = 0;
      while(a % i == 0){
        count++;
        a /= i;
      }
      v.push_back({i, count});
    }
  }
  return v;
}

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<ll, int>> v = factoring(m);
  ll res = 1;
  for (pair<ll, int> a : v) {
    res *= comb(a.second + n - 1, n - 1);
    res %= MOD;
  }
  cout << res << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            int per8 = int.Parse(line[0]);
            int per10 = int.Parse(line[1]);
            int standard = per10 * 10;
            bool flag = false;
            for (int i = standard - 50; i < standard + 50; i++)
            {
                if (Math.Floor(i * 0.08) == per8 && Math.Floor(i * 0.1) == per10)
                {
                    Console.WriteLine(i);
                    flag = true;
                    break;
                }
            }
            if(flag == false)
            {
                Console.WriteLine("-1");
            }
            //Console.ReadKey();
        }
    }
}


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

int main() {
    int n; cin >> n;
    /* auto Check = [&](int s) {
        int v = s, cnt = 0;;
        while (true) {
            cnt += 1;
            int bit = (v & 1);
            v >>= 1;
            if (bit == 0) v ^= (1 << (n - 1));
            if (v == s) return cnt;
        }
    };

    int p = -1, m = n;
    for (int i = 2; i <= m; ++i) {
        if (m % i == 0) {
            while (m % i == 0) m /= i;
            p = i;
        }
    }

    set<int> st, ck;
    for (int i = 1; i <= n; ++i) {
        if (n % i != 0 && i % 2 == 0 && (n + n) % i == 0) ck.insert(i);
    }
    vector<int> v(n + 1);
    for (int s = 0; s < (1 << n); ++s) {
        int cnt = Check(s);
        if (cnt != n + n) {
            // assert(cnt % 2 == 0 && (n + n) % cnt == 0);
            // for (int i = 0; i < n; ++i) printf("%d", (s >> i & 1));
            // printf(": %d\n", cnt);
            // st.insert(cnt);
            v[cnt]++;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (v[i] > 0) printf("v[%d] = %d\n", i, v[i]);
    } */
    
    string x; cin >> x;

    constexpr int kMod = 998244353;
    int cnt = 0;
    vector<int> dp(n + 1), gd(n + 1);
    vector<vector<int>> dv(n + 1);
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i) dv[j].push_back(i);
    }
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0 && n % i != 0 && (n + n) % i == 0) {
            for (int d : dv[i]) gd[d] = true;
        }
    }

    for (int i = 0; i < n; ++i) {
        int nxt = 0;
        if (x[i] == '1') nxt = (cnt * 2 + 1) % kMod;
        else nxt = cnt * 2 % kMod;
        if ((i + 1) * 2 <= n) {
            dp[(i + 1) * 2] = nxt;
            if (gd[(i + 1) * 2]) {
                string t = "";
                for (int j = 0; j <= i; ++j) t += x[j];
                for (int j = 0; j <= i; ++j) t += (x[j] ^ '0' ^ '1');
                string r = "";
                for (int j = 0; j < n; ++j) r += t[j % t.size()];
                if (r <= x) dp[(i + 1) * 2]++;
            }
        }
        cnt = nxt;
    }
    for (int i = 1; i <= n; ++i) {
        for (int d : dv[i]) if (i > d && (i / d) % 2 == 1) (dp[i] += kMod - dp[d]) %= kMod;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) ans = (ans * 2 + (x[i] - '0')) % kMod;
    ans = 1LL * (ans + 1) * (n + n) % kMod;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0 && n % i != 0 && (n + n) % i == 0) {
            ans += kMod - 1LL * dp[i] * (n + n) % kMod;
            if (ans >= kMod) ans -= kMod;
            ans += 1LL * dp[i] * i % kMod;
            if (ans >= kMod) ans -= kMod;
            // printf("dp[%d] = %d\n", i, dp[i]);
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 25220
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll int //long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m;
    cin >> n >> m;
    map<ll, ll> mp;
    rep(i, n)
    {
        ll k;cin >> k;
        rep(j, k) {
            ll x;
            cin >> x;
            mp[x]++;
        }
    }
    ll ans = 0;
    itr(it, mp)
    {
        if(it->sd == n) ans++;
    }
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
    #include <limits.h>
    using namespace std;
     
    int diff(int a, int b)
    {
      return (a-b>0)?a-b:b-a;
    }
     
    int min(int a, int b)
    {
      return (a<b)?a:b;
    }
     
    int main()
    {
      int n,k;
      cin >> n;
      cin >> k;
 
      int ht[100001];
      int min_cost[100001];
      for (int i =0 ; i < n; i++) {
           cin >> ht[i];
           min_cost[i] = 0;
    }
    
      if (n ==1 ){ cout << "0\n"; return 0;}
      min_cost[0] = 0;

         for (int i=1 ;i < n; i++) {
           min_cost[i] = INT_MAX;
            for (int j = 1; j<=k && i-j>=0; j++){
               min_cost[i] = min(min_cost[i-j] + diff(ht[i],ht[i-j]),
                                     min_cost[i]);
            }
         }
      cout << min_cost[n-1];
    }

Measured memory_bytes: 1024
from heapq import heappushpop

N = int(input())
A = list(map(int, input().split()))

l_list = sorted(A[:N])
l_sum = [sum(l_list)]
for a in A[N:2 * N]:
    l_sum.append(l_sum[-1] - heappushpop(l_list, a) + a)

r_list = sorted(-x for x in A[-N:])
r_sum = [sum(r_list)]
for a in reversed(A[N:2 * N]):
    r_sum.append(r_sum[-1] - heappushpop(r_list, -a) - a)

ans = -(10 ** 15)
for l, r in zip(l_sum, r_sum[::-1]):
    ans = max(ans, l + r)
print(ans)

Measured memory_bytes: 37212
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String S = in.readLine();
		boolean oddCond = true;
		boolean evenCond = true;
		for (int i = 0; i < S.length(); ++i) {
			if (i % 2 != 0) {
				if (S.charAt(i) == 'R') {
					evenCond = false;
				}
			} else {
				if (S.charAt(i) == 'L') {
					oddCond = false;
				}
			}
		}
		if (evenCond && oddCond) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21204
#include <stdio.h>
int main(void){
  int h,w,i,j,x,d,e;
  scanf("%d %d",&h,&w);
  char s[50][51];
  for(i=0;i<h;i++){
      scanf("%s",s[i]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      x=0;
      if(s[i][j]=='#'){
	putchar('#');
      }
      else {
	for(d=-1;d<=1;d++){
	  for(e=-1;e<=1;e++){
	    if(s[i+e][j+d]=='#'){
	      x++;
	    }
	  }
	}
	printf("%d",x);
      }
    }
    putchar('\n');
  }
  return 0;
}


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


int main() {

	long long int n;
	long long int a;
	long long int b;
	long long total = 0;

	scanf("%lld %lld %lld", &n, &a, &b);

	long long sum = a + b;		// 赤と青のボールの個数
	long long dif = n / sum;	// 前からn個にsum(=赤と青）が何個分フルに入るか
	long long mod = n % sum;	// total = sum * dif + mod

	if(mod > a) {
		total = (dif + 1) * a;
	} else {
		total = dif * a + mod;
	}

	printf("%lld", total);

	return 0;

}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,K=map(int,input().split())
print(-(-(N-1)//(K-1)))

Measured memory_bytes: 38256
def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n = int(input())
irons = [ int(v) for v in input().split() ]

irons_cum = cumsum(irons)

irons_sep = [ (irons_cum[-1] - irons_cum[i], irons_cum[i])  for i in range(n-1)]
irons_def = [ abs(a-b)  for a, b in irons_sep]
print(min(irons_def))

Measured memory_bytes: 106564
a = []
a = gets.chomp.split("")
bit = []
cnt=0
c = []
for i in 0..(2**(a.length-1))-1
  c = a.clone
  #puts c.join(" ")
  b = i.to_s(2)
  bit = b.split("")
  while bit.length < a.length
    bit.insert(0,0)
  end
#puts bit.join(" ")
  for j in 0..bit.length-1   
   if bit[bit.length-1-j] == "1"
     c.insert(bit.length-1-j,"+") #後ろからやらないと挿入位置がずれる
   end
  end
  #puts c.join(" ")
  #puts eval(c.join(""))
  cnt = cnt + eval(c.join(""))
end
puts cnt
  


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

int main(){
    int n,ans=0,mae=1000000;
    cin>>n;
    vector<int> A(n+1);
    vector<int> B(n);
    for(int i=0;i<n-1;i++){
        cin>>B[i];
    }
  A[0]=B[0];
  for(int i=1;i<n;i++){
    A[i]=min(B[i-1],B[i]);
  }
  for(int i=0;i<n;i++){
    ans+=A[i];
  }
  ans+=B[n-2];
  cout<<ans;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char c;
  cin>>c;
  int d=(int)c;
  if(d>=65 && d<=90)
  {
    cout << 'A'<<'\n';
  }
  if(d>=97 && d<=122)
  {
    cout << 'a'<<'\n';
  }
}


Measured memory_bytes: 3616
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

ll x, y;
int cnt;


int main(){
	cin >> x >> y;
	cnt = 0;
	while (x <= y) {
		x = x * 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int> Q(N);
  int T=0;
  for(int i=0; i<N; i++){
    cin>>Q.at(i);
    T+=Q.at(i);
  }
  int M; cin>>M;
  vector<vector<int>> D(M,vector<int>(2));
  for(int i=0 ;i<M; i++){
    for(int j=0; j<2; j++){
      cin>>D.at(i).at(j);
    }
  }
  for(int i=0 ;i<M; i++){
    T-=Q.at(D.at(i).at(0)-1);
    cout<<T+D.at(i).at(1)<<endl;
     T+=Q.at(D.at(i).at(0)-1);
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int tgt = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        tgt ^= A[i];
    }
    vector<bool> use(N, false);
    int cnt = 0;
    for (int i = 30; i >= 0; i--) {
        int mask = (1<<(i+1))-1;
        int k = (1<<i);
        if ((tgt&k) == 0) continue;
        for (int j = 0; j < N; j++) {
            if (use[j]) continue;
            if ((A[j]&mask)==k) {
                tgt ^= mask;
                use[j] = true;
                cnt++;
                break;
            }
        }
    }
    if (tgt != 0) cout << -1 << endl;
    else cout << cnt << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


int main(){
    ll a, b, c;
    cin >>  a >> b >> c;

    vector<ll> v;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(all(v));

    if(v[0] == 5 && v[1] == 5 && v[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//const int maxN = 1e5 + 100;
const int MOD = 1000000007;

void doc() {
    freopen("OB.inp","r",stdin);
    freopen("OB.out","w",stdout);
    ///cerr << "OK" << '\n';
}

void solve() {
    int n;
    cin >> n;
    int res = - MOD * 2, temp = MOD;
    for(int i = 0; i  < n ; i++){
        int x;
        cin >> x;
        if (i != 0) res = max(res, x - temp);
        temp = min(x, temp);
    }
    cout << res << '\n';

}
int main(){
    
    solve();
}




Measured memory_bytes: 3112
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string s;
    cin >> s;
    int n = s.size();
    REP(i, n) {
        if (i == 5 || i == 13) {
            cout << " ";
        } else {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc001 {

    class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         2 10 20
         * out
         30
         50
         90
         170
         330
         650
         1290
         2570
         5130
         10250
         */
        main(): void {
            const [r, d, x]: number[] = this.args[0].split(' ').map(Number);
            // x[i+1] = rx[i] -d

            let wkX: number = x;
            for (let i: number = 0; i < 10; i++) {
                console.log((r * wkX) - d);
                wkX = (r * wkX) - d;
            }
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new Program(args);
    prg.main();
}



Measured memory_bytes: 7628
M = int(input())
sumd, sumc = 0, 0
for i in range(M):
    d, c = map(int, input().split())
    sumd += d * c
    sumc += c

tmp = sumd // 10
while tmp > 0:
    pre = sumd
    sumd += tmp
    tmp = sumd // 10 - pre // 10

ans = sumd // 10 + sumc - 1
print(ans)


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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    string N;
    cin >> N;
    string tmp = N;
    reverse(tmp.begin(), tmp.end());
    cout << (N == tmp ? "Yes" : "No") << endl;
}

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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

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

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}


void solve()
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll p1=a*c;
    ll p2=a*d,p3=b*c,p4=b*d;
    print(max(max(p1,p2),max(p3,p4)));
}

int main()
{
    //fastio;
   // test
    solve();
}


Measured memory_bytes: 3632
s = input()
check = 0;check2 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != '0':check += 1
        if s[i] != '1':check2 += 1
    else:
        if s[i] != '1':check += 1
        if s[i] != '0':check2 += 1
print(min(check,check2))


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
int N;

string s;
set <string> ses;
int K;

int x=0;
int main(){
  cin >> s;
  cin >> K;
  K--;
  for(char c='a';c<='z';c++){
    vector<int> v;
    for(int i=0;i<s.length();i++){
      if(s[i]!=c) continue;
      string ss="";
      for(int j=i;j<s.length();j++){
	ss+=s[j];
	ses.insert(ss);
	if(ss.size()>K)break;
	//cout << ss << endl;
        
      }
      //cout << endl;
    }
    
    if(ses.size()>K){
      for(set<string>::iterator it=ses.begin();it!=ses.end();it++){

	if(x==K)  {
	  cout << *it<< endl;
	  return 0;
	}
	x++;
      }
    }
  }
 
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


ll gcd(ll x, ll y){
  return y ? gcd(y, x%y) : x;
}

ll lcm( ll m, ll n ){
	if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n);// lcm = m * n / gcd(m,n)
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    set<int> pf;
    ll L = 1;
    REP(i,N){
        cin >> a[i];
        a[i] /= 2;
        L = lcm(L, a[i]);
        int cnt = 0;
        while(a[i] % 2 == 0){
            cnt++;
            a[i] /= 2;
        }
        pf.insert(cnt);
        if(L > M){
            cout << 0 << endl;
            return 0;
        }
    }
    if(pf.size() > 1){
        cout << 0 << endl;
        return 0;
    }
    cout << (M / L + 1) / 2 << endl;
}

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

int main() {
	string s, t;
	int ans=0;
	cin >> s >> t;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3916
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define it vector<int>::iterator
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	ll dp[10][1010]={0};
	dp[0][0]=1;
	rep(k,101)for(int i=8;i>=0;i--)rep(j,1010-k)
		dp[i+1][j+k]+=dp[i][j];
	
	int n,s;
	while(cin>>n>>s,n+s){
		cout<<dp[n][s]<<endl;
	}
}

Measured memory_bytes: 1244
n,m = map(int, input().split())
def guess_num(n,m):
    number_cond = [-1]*n
    for i in range(m):
        s,c = map(int, input().split())
        s = s-1
        if number_cond[s] >= 0 and number_cond[s] != c:
            return -1
        number_cond[s] = c
    # print(number_cond)
    if number_cond[0] == 0:
        if n == 1:
            return 0
        return -1
    if number_cond[0] < 0:
        if n == 1:
            return 0
        number_cond[0] = 1
    ret = 0
    for i in range(n):
        num = max(0, number_cond[i])
        ret += num*(10**(n-i-1))
    return ret
print(guess_num(n,m))

Measured memory_bytes: 3064
#include <stdio.h>

char field[15][10005], cfield[15][10005];

int max(int a, int b)
{
	if (a > b) return(a);
	else return(b);
}

int main(void)
{
	int i, j, k, r, c, a, b, sum, ans, c1, c2;
	
	while (1){	
		scanf("%d %d", &r, &c);
		
		if (r == 0 && c == 0) break;
		
		a = 1;
		ans = 0;
		
		for (i = 0; i < r; i++){
			for (j = 0; j < c; j++){
				scanf("%d", &field[i][j]);
			}
			a *= 2;
		}
		
		for (i = 0; i < a; i++){
			
			for (j = 0; j < r; j++)
				for (k = 0; k < c; k++) cfield[j][k] = field[j][k];
			
			b = 1;
			for (j = 0; j < r; j++){
				
				if ( (b & i) == b){
					for (k = 0; k < c; k++){
						if (cfield[j][k] == 0) cfield[j][k] = 1;
						
						else cfield[j][k] = 0;
					}
				}
				b *= 2;
			}
			
			sum = 0;
			for (j = 0; j < c; j++){
				c1 = 0;
				c2 = 0;
				for (k = 0; k < r; k++){
					if (cfield[k][j] == 0) c1++;
					else c2++;
				}
				sum += max(c1, c2);
			}
			ans = max(ans, sum);
		}
		
		printf("%d\n", ans);
	}
	return (0);
}

Measured memory_bytes: 796
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {

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

        final long MAX = 1000000000000000000L;
        final int N = sc.nextInt();


        BigInteger[] A = new BigInteger[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextBigInteger();
            if (A[i].compareTo(BigInteger.ZERO) == 0) {
                System.out.println(0);
                return;
            }
        }

        Arrays.sort(A, Comparator.reverseOrder());

        BigInteger ans = BigInteger.ONE;
        for (int i = 0; i < N; i++) {
            if (ans.multiply(A[i]).compareTo(BigInteger.valueOf(MAX)) > 0) {
                System.out.println(-1);
                return;
            }
            ans = ans.multiply(A[i]);
        }

        System.out.println(ans.compareTo(BigInteger.valueOf(MAX)) > 0 ? -1 : ans);
    }
}


Measured memory_bytes: 68396
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int M = max(A, max(B, C));
  cout << A + B + C + M * pow(2, K) - M << endl;
  return 0;
}


Measured memory_bytes: 512
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
#define int long long

int n;
vector<vector<int>> g;

int dp[55][1<<20];

void solve() {
	cin >> n;
    vector<int> a(n - 1), b(n - 1);
    g.assign(n, vector<int>());
    rep(i, n - 1) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        g[a[i]].pb(b[i]);
        g[b[i]].pb(a[i]);
    }
    int m; cin >> m;
    int pa[30][55];
    rep(i, 30) rep(j, 55) pa[i][j] = 0;
    rep(i, m) {
        int u, v; cin >> u >> v;
        --u; --v;

        priority_queue<P, vector<P>, greater<P>> pque;
        vector<int> pre(n, -1);
        vector<int> d(n, INF);
        pque.push(P(0, u));
        pre[u] = -1;
        d[u] = 0;
        while(pque.size()) {
            P p = pque.top(); pque.pop();
            if(d[p.sc] < p.fr) continue;
            for(auto x: g[p.sc]) {
                if(chmin(d[x], d[p.sc] + 1)) {
                    pre[x] = p.sc; //最短距離が最後に確定したポイントの記録が残るのでok
                    pque.push(P(d[x], x));
                }
            }
        }
        vector<int> path;
        for(int t = v; t != -1; t = pre[t]) {
            path.pb(t);
        }
        for(auto x: path) pa[i][x] = 1;
    }

    rep(i, 55) rep(j, (1<<20)) dp[i][j] = 0;
    dp[0][0] = 1;
    rep(i, n - 1) {
        for(int j = 0; j < (1<<m); ++j) {
            //白
            dp[i + 1][j] += dp[i][j];
            //黒
            int bit = j;
            rep(k, m) {
                if(pa[k][a[i]] && pa[k][b[i]]) {
                    bit |= (1<<k);
                }
            }
            dp[i + 1][bit] += dp[i][j];
        }
    }
    cout << dp[n - 1][(1<<m) - 1] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 450816
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if math.Abs(float64(a-c)) <= float64(d) || (math.Abs(float64(a-b)) <= float64(d) && math.Abs(float64(b-c)) <= float64(d)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = "";
        
        if ((a * b) % 2 == 1) {
            s = "Odd";
        } else {
            s = "Even";
        }
        
        System.out.println(s);
    }
}


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

using namespace std;

int main(){
	int n;
	cin>>n;
	
	int a[n+1];
	for(int i = 1;i<=n;i++){
		cin>>a[i];
	}
	
	int count = 0;
	
	for(int i=0;i<=n;i++){
		if(i%2 != 0 && a[i]%2 != 0){
			count++;
		}
	}
	
	cout<<count;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
LL d(LL a,LL b,LL c){
	return abs(b-a)+abs(c-b);
}

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int a,b,q;
	cin>>a>>b>>q;
	vector<LL> s(a+4);
	vector<LL> t(b+4);
	s[0]=t[0]=-mod*10001LL;
	s[1]=t[1]=-mod*10000LL;
	s[a+2]=t[b+2]=mod*10000LL;
	s[a+3]=t[b+3]=mod*10001LL;
	FOR(i,0,a){
		cin>>s[i+2];
	}
	FOR(j,0,b){
		cin>>t[j+2];
	}
	FOR(i,0,q){
		LL x;
		cin>>x;
		auto si=lower_bound(s.begin(),s.end(),x)-s.begin();
		auto ti=lower_bound(t.begin(),t.end(),x)-t.begin();
		if(s[si]==x){
			cout<<min(abs(x-t[ti]),abs(x-t[ti-1]))<<endl;
		}else if(t[ti]==x){
			cout<<min(abs(x-s[si]),abs(x-s[si-1]))<<endl;
		}else{
			cout<<min(min(min(d(x,s[si],t[ti]),d(x,s[si-1],t[ti-1])),min(d(x,s[si-1],t[ti]),d(x,s[si],t[ti-1]))),
						min(min(d(x,t[ti],s[si]),d(x,t[ti],s[si-1])),min(d(x,t[ti-1],s[si]),d(x,t[ti-1],s[si-1]))))<<endl;
		}
	}

	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int a=1;
  
  for(int i=0; i<N; i++){
    if(a*2 < a+K){
      a *= 2;
    }
    else{
      a += K;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
            
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> s[i] >> p[i];
        a[i] = i;
    }

    sort(a.begin(), a.end(), [&](const int x, const int y){
                if(s[x] == s[y]){
                    return p[x] > p[y];
                }else{
                    return s[x] < s[y];
            }});
    for(int i=0;i<n;i++) cout << a[i] + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=55;
uli f[mx][mx];
int Y;
int can[mx];
uli mask=0;
uli maxi=0;
int check(int X){//X->y
  if(can[X]!=-1)return can[X];
  if(f[X][Y]!=-1 && f[X][Y]<=maxi)return can[X]=1;
  can[X]=0;
  for(int m=1;m<mx;m++)if(mask&(1ll<<m))if(X%m<X && f[X%m][Y]!=-1)
    if(check(X%m))return can[X]=1;
  return can[X];
}
int solvable(int X){//X->y
  if(can[X]!=-1)return can[X];
  if(X==Y)return can[X]=1;
  can[X]=0;
  for(int m=1;m<mx;m++)if(mask&(1ll<<m))if(X%m<X)
    if(solvable(X%m))return can[X]=1;
  return can[X];
}

int main(){
  memset(f,-1ll,sizeof f);
  for(int y=0;y<mx;y++){
    f[y][y]=0;
    for(int x=y+1;x<mx;x++){
      f[x][y]=-1;
      for(int m=1;m<mx;m++){
        if(f[x%m][y]!=-1ll){
          f[x][y]=f[x%m][y];
          f[x][y]|=(1ll<<m);
          break;
        }
      }
    }
  }
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    if(f[a[i]][b[i]]==-1){
      puts("-1");
      return 0;
    }
  }
  for(int i=mx-1;i>=0;){
    bool ok=true;
    for(int k=0;k<n;k++){
      memset(can,-1,sizeof can);
      Y=b[k];
      if(!solvable(a[k])){
        ok=false;
        break;
      }
    }
    if(ok)break;
    for(int j=0;j<=i;j++){
      mask^=(1ll<<j);
      maxi=(1ll<<j);
      ok=true;
      for(int k=0;k<n;k++){
        memset(can,-1,sizeof can);
        Y=b[k];
        if(!check(a[k])){
          ok=false;
          break;
        }
      }
      if(ok){
        i=j-1;
        break;
      }
      mask^=(1ll<<j);
    }
  }
  printf("%lld\n",mask);
  return 0;
}


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

#define ran 81

int n, m;
int a[ran][ran], b[ran][ran];
int q[ran*ran*ran*ran*2*3], l, r;
bool f[ran][ran][ran*ran*2];

void upd(int x, int y, int v) {
	if (f[x][y][v]) return;
	f[x][y][v] = true;
	q[r++] = x;
	q[r++] = y;
	q[r++] = v;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
		scanf("%d", &a[i][j]);
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
		scanf("%d", &b[i][j]);
	
	memset(f, false, sizeof f);
	l = r = 0;
	upd(0, 0, labs(a[0][0] - b[0][0]));
	while(l<r) {
		int x = q[l++];
		int y = q[l++];
		int v = q[l++];
		if(x<n-1) {
			upd(x+1, y, labs(v+a[x+1][y]-b[x+1][y]));
			upd(x+1, y, labs(v-a[x+1][y]+b[x+1][y]));
		}
		if(y<m-1) {
			upd(x, y+1, labs(v+a[x][y+1]-b[x][y+1]));
			upd(x, y+1, labs(v-a[x][y+1]+b[x][y+1]));
		}
	}
	int ans = n*m*ran;
	for(int i=0;i<ans;i++)
		if(f[n-1][m-1][i]) ans = i;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 319744
N = int(input())
st = set() # 空のセットを生成
s = [] # 空のリストを生成

for i in range(N):
    char = input()
    st.add(char) # セットに要素を追加するにはadd()を使う
    s.append(char) # リストに要素を追加するにはappend()を使う

M = int(input())
t = [] # 空のリストを生成

for i in range(M):
    t.append(input())

ans = -100 # ありうる最小値を初期値に設定
char = 0

for x in st:
    char = s.count(x)
    char -= t.count(x)
    ans = max(ans, char)

print(ans if 0 <= ans else 0)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<int>a(N-1),b(N-1);
  for(int i=0;i<N-1;i++)cin>>a[i]>>b[i];
  for(int i=0;i<N-1;i++)a[i]--,b[i]--;
  vector<int>c(N);
  for(int i=0;i<N;i++)cin>>c[i];
  sort(rng(c));
  vector<set<int>>v(N);
  for(int i=0;i<N-1;i++){
    v[a[i]].insert(b[i]);
    v[b[i]].insert(a[i]);
  }
  vector<int>ans(N);
  queue<int>q;
  for(int i=0;i<N;i++)if(v[i].size()==1)q.push(i);
  int cnt=0;
  while(q.size()){
    int now=q.front();
    q.pop();
    ans[now]=c[cnt];
    cnt++;
    for(auto it:v[now]){
      v[it].erase(now);
      if(v[it].size()==1)q.push(it);
    }
  }
  ll sum=0;
  for(int i=0;i<N-1;i++)sum+=min(ans[a[i]],ans[b[i]]);
  cout<<sum<<endl;
  for(auto it:ans)cout<<it<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int Max=1e5+5;
int a[Max];
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> a[i];
	a[0]--;
	for(int i=1;i<N;i++){
		if(a[i]>a[i-1]){
			a[i]--;
		}
	}
	int k=0;
	for(int i=1;i<N;i++){
		if(a[i]<a[i-1]){
			k=1;
		}
	}
	if(k) cout << "No" << endl;
	else cout << "Yes" << endl;		
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  int odd=0;
  REP(i,n){
    cin>>a[i];
    if(a[i]%2) odd++;
  }
  cout<<((odd%2)? "NO":"YES")<<endl;

  return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

var N, X, T int

func main() {
  fmt.Scanf("%d%d%d", &N, &X, &T)
  if N <= X {
    fmt.Println(T)
    return
  }
  res := 0
  for N > 0 {
  	N -= X
    res += T
  }
  fmt.Println(res)
}


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

int main()
{
    string s;
    cin >> s;
    for( int i =0; i < s.length(); i++ )
    {
        if(s[i] == '?') s.replace(i, 1, "D");
    }
    cout << s;

}

Measured memory_bytes: 3744
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;
 

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int l[n + 1];
  l[n] = n;
  int st = 0, l_st = 0;
  for (int i = 1; i < n + 1; i++)
    if (s[i] == '0')
      st = 0;
    else
      st += 1, l_st = max(l_st, st);
  if (l_st >= m)
    cout << -1 << endl;
  else{
    for (int i = n; i >= 0; i--)
      if (s[i] == '0')
	l[i] = i;
      else
	l[i] = l[i + 1];
    int c = n;
    Vi ans;
    for (int i = 0; i < n + 1; i++){
      if (c - m < 0){
	ans.pb(c);
	break;
      }
      else{
	ans.pb(c - l[c - m]);
	c = l[c - m];
	if (c == 0)
	  break;
      }
    }
    for (int i = 0; i < ans.size(); i++)
      cout << ans[ans.size() - 1 - i] << " ";
    cout << endl;
  }
  
}


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

int main() {
    int N, K;
    int x[101];
    cin >> N;
    cin >> K;
    for (int i = 1; i <= N; i++) {
        cin >> x[i];
    }
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        int pos = x[i];
        if (abs(pos) < abs(K - pos)) {
            ans += pos * 2;
        } else {
            ans += abs(K - pos) * 2;
        }
    }

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


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


int K;


void input() {
    cin >> K;
}


int main() {
    input();
    int a, b;
    a = b = K / 2;
    if (K % 2 == 1) b++;
    int ans = a * b;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (){
	
	char str[1000];
	int k;
	
	scanf("%d", &k);
	scanf("%s", str);
	
	
	int len = strlen(str);
	
  if (len <= k) {
    printf("%s", str);
  } 
  
  else { 
    for (int i = 0; i < k; i++) {
      
	  printf("%c", str[i]); 
    
	}
    puts("...");
  }

	
}

Measured memory_bytes: 1732
C=[input() for c in range(3)]
C1=[]
C2=[]
C3=[]
ANS=' '
for c in C[0]:
    C1.append(c)
for c in C[1]:
    C2.append(c)
for c in C[2]:
    C3.append(c)
    
ANS=C[0][0]+C[1][1]+C[2][2]

print(ANS)

Measured memory_bytes: 3064
import java.util.*;
//import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a <= b){
            System.out.println(a);
        }else{
            System.out.println(a-1);
        }

    }
}


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

int main(){
    int N;  cin >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++) cin >> p[i];

    sort(p.begin(), p.end());
    int ans = 0;
    for(int i=0; i<N; i++){
        if(i!=N-1) ans+=p[i];
        else ans += p[i]/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int i,j,k;
	int n,m;
	int f[111][7][4]={};
	int p[111][12]={};
	cin>>n;
	FOR(i,1,n+1)FOR(j,1,5+1)FOR(k,1,3){
		cin>>f[i][j][k];
	}
	FOR(i,1,n+1)FOR(j,0,11){
		cin>>p[i][j];
	}
	int max=-mod;
	int d[n+1]={};
	FOR(i,1,1024){
		FOR(j,1,n+1)d[j]=0;
		FOR(j,1,n+1){
			FOR(k,1,11){
				d[j]+=((i>>(k-1))&1&f[j][(k-1)/2+1][(k+1)%2+1]);
			}
		}
		int a=0;
		FOR(j,1,n+1){
			a+=p[j][d[j]];
		}
		if(max<a)max=a;
	}
	cout<<max<<endl;
    return 0;
}


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

int main() {
	   int n , m; 
	   cin >> n >> m ; 
	   if ( n >= m && n == m)
	    cout << "Yes" << endl;
	   else
	    cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;


int main()
{
	int H ,N;
	cin >> H >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++)
		cin >> a.at(i);

	int sum = 0;
	for (int i = 0; i < N; i++)
		sum += a.at(i);

	if (sum >= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        long a, b, k;
        Input(out a, out b, out k);
        if(a >= k) {
            a = a - k;
        } else {
            if(b >= k - a) {
                b = b - (k - a);
            } else {
                b = 0;
            }
            a = 0;
        }
        Console.WriteLine(a + " " + b);
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

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

ll h;
ll a[1001000];

void max_heapify(ll i){
    ll l = 2*i, r = 2*i + 1, largest;

    if(l <= h && a[l] > a[i]) largest = l;
    else largest = i;
    if(r <= h && a[r] > a[largest]) largest = r;

    if(largest != i){
        swap(a[i], a[largest]);
        max_heapify(largest);
    }

    return;
}

void build_max_heap(){
    for(ll i = h/2; i >= 1; i--) max_heapify(i);
    return;
}

int main(){
    cin >> h;
    for(ll i = 1; i <= h; i++) cin >> a[i];

    build_max_heap();

    for(ll i = 1; i <= h; i++) cout << ' ' << a[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 7012