akhauriyash/Code-Regression huggingface dataset:
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

N, K = map(int, stdin.readline().strip().split())


m = 100
grid = [range(start, start+7) for start in range(1, m*7, 7)]

for_y = [0] * 11
for y in range(11):
    for x in range(5):
        here = sum(sum(grid[y+i][x:x+3]) for i in range(3))
        if here % 11 == K:
            for_y[y] += 1

#print for_y
N -= 2
if N <= 2:
    print 0
else:
    rr = (N // 11) * sum(for_y)
    extra = N % 11
    if extra >= 1:
        rr += sum(for_y[:extra])

    print rr






Measured memory_bytes: 2696
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;

  return 0;
}


Measured memory_bytes: 256
module Map_int = Map.Make(struct
  type t = int
  let compare = (-)
end)
module M = Map_int

let add1 k m =
  let v = 1 + (try M.find k m with _ -> 0) in
  M.add k v m

let sub1 k m =
  let v = try M.find k m - 1 with _ -> 0 in
  if v = 0 then M.remove k m else M.add k v m

module Set_ii = Set.Make(struct
  type t = int * int
  let compare (a, b) (d, e) =
    if a <> d then a-d else b-e
end)
module S = Set_ii

type state = { tl: int Map_int.t; tr: int Map_int.t; sl: int; sr: int; b: int }

let update {tl; tr; sl; sr; b=tb} n a b =
  let (kl, vl), (kr, vr) = M.max_binding tl, M.min_binding tr in
  let tl, km, tr, sl, sr =
    if a <= kl then
      let tl' = sub1 kl tl in
      (add1 a tl', kl, tr, sl-kl+a, sr)
    else if a <= kr then
      (tl, a, tr, sl, sr)
    else
      let tr' = sub1 kr tr in
      (tl, kr, add1 a tr', sl, sr-kr+a)
  in
  if n mod 2 = 1 then
    {tl; tr = add1 km tr; sl = sl; sr = sr+km; b = tb+b}
  else
    {tl = add1 km tl; tr; sl = sl+km; sr; b = tb+b}

let calc n {tl; tr; sl; sr; b} =
  let x, _ = M.max_binding tl in
  let _, _ = M.min_binding tr in
  let sum = (n mod 2) * x - sl + sr + b in
  (x, sum)

let rec loop n st =
  Scanf.scanf " %d" @@ function
  | 1 -> Scanf.scanf " %d %d" (update st n) |> loop (n+1)
  | _ -> begin
      let x, fx = calc n st in
      Printf.printf "%d %d\n" x fx;
      loop n st
  end

let inf = 100000000000000000
let _ = Scanf.scanf "%d" @@ fun _ ->
  try loop 0 {
    tl = M.singleton (-inf) inf; tr = M.singleton inf inf;
    sl = 0; sr = 0; b = 0
  } with _ -> ()


Measured memory_bytes: 27008
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, r = 1;
int t[20][20];
int dp[20][1200000];
int solve(int pos,int x) {
	if (x == r) return 0;
	if (dp[pos][x] > 0) return dp[pos][x];
	int ans = iinf;
	for (int i = 1; i <= n; i++) {
		if (!(x & 1 << i)) {
			int sum = iinf, k = solve(i, x | 1 << i);
			for (int j = 0; j <= n; j++) {
				if (x & 1 << j)
					sum = min(sum, t[i][j] + k);
			}
			ans = min(ans, sum);
		}
	}
	return dp[pos][x] = ans;
}
signed main() {
	while (cin >> n&&n) {
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 1200000; j++)
				dp[i][j] = 0;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= n; j++)
				cin >> t[i][j];
		}
		r = 1;
		for (int i = 1; i <= n; i++) {
			r += pow(2, i);
		}
		int ans = iinf;
		for (int i = 1; i <= n; i++) {
			ans = min(ans, t[i][0] + solve(i, 1 | 1 << i));
		}
		cout << ans << endl;
	}
	getchar(); getchar();
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

map<int64, int64> mp;

int64 dfs(int64 h) {
  if (h == 0) return 0;
  if (mp.count(h)) return h;
  mp[h] = dfs(h/2)*2+1;
  return mp[h];
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 H;
	cin >> H;

  cout << dfs(H) << endl;
}


Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    string s;cin>>s;
    
    ll cnt=0;
    rep(i,3)cnt+=s[i]=='1';

    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline



    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    ss=readline().rstrip()
    
    yn(ss[2]==ss[3] and ss[4]==ss[5])

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()


Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n;
    cin>>n;
    vi a(n);
    c(a,n);
    vi dp(n);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<lc;
    return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 123451

int vis[10];

int main(){
        int a, b, c;
        cin >> a>> b>> c;
        vis[a]++;
        vis[b]++;
        vis[c]++;
        if (vis[5] == 2 && vis[7] == 1)
                cout << "YES\n";
        else 
                cout << "NO\n";
        return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    if (b >= a) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
a,b = gets.split.map(&:to_i)
res_10 = []
res_8 = []
cnt = 0
for i in 0..1000
    if (i*0.08).to_i == a
        res_8[cnt] =  i
        cnt += 1
    end
end
cnt = 0
for i in 0..1000
    if (i*0.1).to_i == b
        res_10[cnt] =  i
        cnt += 1
    end
end
result = []
result = res_10 & res_8
if result.size >= 1
    puts result[0]
else
    puts -1
end

Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 4 * 1e18;
/* -- template -- */

int main() {
    int N; cin >> N;
    ll A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    ll add = 0;
    for(int i = N - 1;i >= 0;--i) {
        if((A[i] + add) % B[i] != 0)
            add += B[i] - (A[i] + add) % B[i];
    }
    cout << add << endl;
}


Measured memory_bytes: 1792
x = int(input())
expo = [0] * (x + 1)
expo[1] = 1
for i in range(2, x + 1):
    v = i*i
    while v <= x:
        expo[v] = 1
        v *= i
for i in range(x,0,-1):
    if expo[i]:
        print(i)
        quit() 
    

Measured memory_bytes: 2940
text = ""
while 1:
    try:
        x = input()
        text += x
    except EOFError:
        break
text_new = text.lower()
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in alphabet:
    tmp = 0
    for j in text_new:
        if j == i:
            tmp += 1
    print(i + " : " + str(tmp))



Measured memory_bytes: 5560
n = int(input())
l = list(map(int, input().split()))
a = -1
b  = True
while b == True:
    for i in range(n):
        if l[i] % 2 == 0:
            l[i] = l[i]/2
        else:
            b = False
            break
    a += 1

print(a)

Measured memory_bytes: 2940
#include<stdio.h>
int main(){
    double N;
    int x=0;
    double sum=0;
    scanf("%lf",&N);
    for(int i=1;i<=N;i++){
        x=x+1;
        if((x%3==0)&&(x%5==0)){

        }else if(x%3==0){

        }else if(x%5==0){

        }else if((x%3!=0)&&(x%5!=0)){
            sum=sum+x;
        }
    }
    printf("%.0f\n",sum);
}

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

int main() {
    int n, ans = 0;
    cin >> n;
    int a;
    map<int, int> mp;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        mp[a]++;
    }
    for(auto i = mp.begin(); i != mp.end(); ++i) {
        if(i->first == i->second) continue;
        else if(i->first < i->second) ans += i->second - i->first;
        else ans += i->second;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4736
/**Bismillahir Rahmanir Rahim.**/
/*gcd=--gcd(a,b);*/
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
   long long int a,b,c,d,i,j;
   cin>>a>>b;
   d=0;
   c=max(d,a-2*b);
   cout<<c<<endl;
}


Measured memory_bytes: 3560
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def diverta19_c():
    _ = int(readline())
    S = [ln.strip().decode('UTF-8') for ln in read().split()]

    # _AB_ , B_A , B_ , _A の個数をそれぞれ数える
    inner, st, ed, sted = 0, 0, 0, 0
    for si in S:
        inner += si.count('AB')
        if si[0] == 'B' and si[-1] == 'A': sted += 1
        elif si[0] == 'B': st += 1
        elif si[-1] == 'A': ed += 1

    ans = inner  # これは確定
    if sted > 0:
        ans += (sted - 1)  # x個でx-1組のABができる
        if st > 0:
            ans += 1  # B_A + B_ で1組
            st -= 1
        if ed > 0:
            ans += 1  # _A + B_A で1組
            ed -= 1
    ans += min(st, ed)  # _A + B_ で1組
    print(ans)

diverta19_c()

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

#define x first
#define y second
#define PII pair<int,int>

using namespace std;

const int N = 400005;
int e[N],ne[N],h[N / 2],idx;
int dist[N];
int n,m;

void add(int a,int b)
{
    e[idx] = b ,ne[idx] = h[a], h[a] = idx ++;
}

void djikstar()
{
    memset(dist,0x3f,sizeof dist);
    queue<int> q;
    q.push(1);
    dist[1] = 0;
    int cnt = 1;
    
    while(q.size() && cnt != n)
    {
        int t = q.front() ; q.pop();
        
        for(int i = h[t] ; ~i ;i = ne[i])
        {
            int j = e[i];
            if(dist[j] == 0x3f3f3f3f)
            {
                cnt ++;
                dist[j] = t;
                q.push(j);
            }
            if(cnt == n) break;
        }
    }
}

int main()
{
    cin >> n >> m;
    memset(h,-1,sizeof h);
    for(int i = 1 ; i <= m; i ++)
    {
        int a,b; cin >> a >> b;
        add(a,b);
        add(b,a);
    }
    djikstar();
    
    bool flag = true;
    for(int i = 2 ; i <= n; i ++) if(dist[i] == 0x3f3f3f3f) flag = false;
    
    if(!flag) puts("No");
    else
    {
        puts("Yes");
        for(int i = 2 ; i <= n ;i ++) cout << dist[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
int len;
string s[62];
int step;
int ask(string s){
assert(++step<=850);
	cout<<"? "<<s<<endl;
	int x;cin>>x;return x;
}
string solve(int l,int r){
	if(l==r)return s[l];
	int m=l+r>>1;
	string L=solve(l,m),R=solve(m+1,r);
	if(L.empty())return R;
	if(R.empty())return L;
	string ret;int i=0,j=0;
	for(;i<L.size() || j<R.size();)
		if(i<L.size() && (j==R.size() || ask(ret+L[i]+string(R.begin()+j,R.end()))
				==len-ret.size()-1-(R.size()-j)))ret=ret+L[i++];
			else ret=ret+R[j++];
	return ret;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int p=0;char c;
	for(c='a';c<='z';++c)s[p++]=string(128-ask(string(128,c)),c);
	for(c='A';c<='Z';++c)s[p++]=string(128-ask(string(128,c)),c);
	for(c='0';c<='9';++c)s[p++]=string(128-ask(string(128,c)),c);
	for(auto u:s)len+=u.size();
auto zz=solve(0,61);
assert(zz.size()<=128 && zz.size()==len);
	cout<<"! "<<zz<<endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int ac[123456], wa[123456];
int main() {
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int n, m;
    cin >> n >> m;
    ll acs = 0, was = 0;
    rep(i, 0, m){
        int p;
        string s;
        cin >> p >> s;
        if (s == "WA"){
            wa[p]+=!ac[p];
        }
        else{
            acs+=!ac[p];
            ac[p] = 1;
        }
    }
    rep(i, 1, n + 1){
        if (ac[i]) was += wa[i];
    }
    cout << acs << ' ' << was << '\n';
    return 0;
}

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

long long a[101];

int main(){
	int n;
	long long x;

	ios_base::sync_with_stdio(0);
	cin >> n >> x;
	long long sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}

	if(sum == x){
		cout << n;
		return 0;
	}

	if(sum < x){
		cout << n-1;
		return 0;
	}
	
	sort(a, a+n);
	int k = 0;
	for(int i = 0; i < n; i++){
		if(x >= a[i]){
			k++;
			x -= a[i];
		}else{
			break;
		}
	}	
	cout << k;
	return 0;
}

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

using namespace std;

int main () {

    int T;
    cin >> T;
    vector<int> xs(T);
    for (int i = 0; i < T; i++)
        cin >> xs[i];

    auto sum = accumulate(xs.begin(), xs.end(), 0);
    int p = 0;
    int ans = INT_MAX;
    for (int i = 0; i < xs.size() - 1; i++) {
    
        p += xs[i];
        sum -= xs[i];
        ans = min (ans, abs(p - sum));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	string s,t; cin >> s >> t;
	int cnt = 0;
	rep (i, s.length()) {
		if (s[i] == t[i]) cnt++;
	}
	cout << cnt << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int count = 0;
    int x;
    for(int i = 1;i<=n;i++){
        cin>>x;
        if(i%2!=0 && x%2 !=0){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

int main() {
  string s;
  //vector<int> year(4),month(2),day(2);
  string year="aaaa",month="aa",day="aa";
  cin >> s;
  for(int i=0;i<4;i++){
    year.at(i) = s.at(i);
  }
  for(int i=0;i<2;i++){
    month.at(i) = s.at(i+5);
    day.at(i) = s.at(i+8);
  }
  
  if( stoi(year) < 2019 ){
    cout << "Heisei" << endl;
    return 0;
  }else if( stoi(month) < 5 ){
    cout << "Heisei" << endl;
    return 0;
  }
  /*
  cout << year << endl
       << month << endl
       << day   << endl;*/
  
  cout << "TBD" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	cout << (a + b + 1) / 2 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
 
int n,m;
vector<int> nxt[222222];
int L[222222];
int Lcnt[222222];
void dfs(int u, int p, int lvl =0) {
	L[u] = lvl;
	Lcnt[lvl]++;
	for(int v: nxt[u]) {
		if(v == p)
			continue;
		dfs(v, u, lvl+1);
	}
}
deque<int> avail[3];
int ans[222222];
int main() {
	scanf("%d", &n);
	REP(i, n-1) {
		int a,b;
		scanf("%d%d", &a, &b);
		a--;b--;
		nxt[a].pb(b);
		nxt[b].pb(a);
	}
	dfs(0, -1);
	REP(i, n) {
		avail[(i+1)%3].pb(i+1);
	}
	int sudy = 0, lichy = 0;
	REP(i, n+10) if(i%2 == 0) sudy += Lcnt[i]; else lichy += Lcnt[i];
	if(avail[0].size() >= sudy) {
		REP(i, n) if(L[i]%2 == 0) {
			ans[i] = avail[0].front();
			avail[0].pop_front();
		} else {
			if(avail[1].size()) {
				ans[i] = avail[1].front();
				avail[1].pop_front();
			} else if(avail[2].size()) {
				ans[i] = avail[2].front();
				avail[2].pop_front();
			} else {
				ans[i] = avail[0].front();
				avail[0].pop_front();
			}
		}
	} else if(avail[0].size() >= lichy) {
		REP(i, n) if(L[i]%2 == 1) {
			ans[i] = avail[0].front();
			avail[0].pop_front();
		} else {
			if(avail[1].size()) {
				ans[i] = avail[1].front();
				avail[1].pop_front();
			} else if(avail[2].size()) {
				ans[i] = avail[2].front();
				avail[2].pop_front();
			} else {
				ans[i] = avail[0].front();
				avail[0].pop_front();
			}
		}
	} else {
		if(lichy > sudy) {
			REP(i, n) if(L[i]%2 == 1) {
				if(avail[1].size()) {
					ans[i] = avail[1].front();
					avail[1].pop_front();
				} else {
					ans[i] = avail[0].front();
					avail[0].pop_front();
				}
			} else {
				if(avail[2].size()) {
					ans[i] = avail[2].front();
					avail[2].pop_front();
				} else {
					ans[i] = avail[0].front();
					avail[0].pop_front();
				}
			}
		} else {
			REP(i, n) if(L[i]%2 == 0) {
				if(avail[1].size()) {
					ans[i] = avail[1].front();
					avail[1].pop_front();
				} else {
					ans[i] = avail[0].front();
					avail[0].pop_front();
				}
			} else {
				if(avail[2].size()) {
					ans[i] = avail[2].front();
					avail[2].pop_front();
				} else {
					ans[i] = avail[0].front();
					avail[0].pop_front();
				}
			}
		}


	}
	REP(i, n) printf("%d ", ans[i]);
	return 0;
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,l,r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (l > r){
    cout << "Left" << endl;
  }
  else if (l < r){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int ans = 0;
    int sum = 1;
    while(sum < b){
        ans++;
        sum += a-1;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
#print(a)
kai = [1]
gai = []
for i in range(n):
	j = (kai[i] * (i+1)) % MOD
	kai.append(j)
for i in range(n+1):
	j = kai[i]
	l = pow(j, MOD-2, MOD)
	gai.append(l)
#print(kai)
#print(gai)

ans = 0
for i in range(n):
	if i <= (n-k):
		#print('xあり')
		x = (a[i] * kai[n-i-1] * gai[n-i-k] * gai[k-1]) % MOD
	else:
		x = 0
	#print('xha', x)

	if i >= (k-1):
		#print('yあり')
		y = (a[i] * kai[i] * gai[i-k+1] * gai[k-1]) % MOD
	else:
		y = 0
	#print('yha', y)

	ans = (ans + y - x) % MOD
	#print(ans)

print(ans)

Measured memory_bytes: 65064
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, A; cin >> N >> A;
	cout << N*N-A << endl;


	return 0;

}


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

namespace AtCoder2.Heuristic
{
    class Node
    {
        /// <summary>積み終わったコンテストの数</summary>
        public int Day;
        public List<int> Contests;
        public int[] ContestPenalties = new int[26];
        public long Score;
        public int NextPenalty;                         // 総和は最大で3650
        public Node AddContest(int contestNo)
        {
            var node = new Node()
            {
                Day = Day + 1,
                Contests = new List<int>(Contests),
            };
            node.Score = Score - NextPenalty + ContestPenalties[contestNo] + Introduction.ContestScore[Day][contestNo];
            node.Contests.Add(contestNo);

            node.ContestPenalties[contestNo] = 0;
            node.NextPenalty = 0;
            for (var i = 0; i < 26; i++)
            {
                node.ContestPenalties[i] = (i == contestNo ? 0 : ContestPenalties[i]) + Introduction.ScoreMinus[i];
                node.NextPenalty += node.ContestPenalties[i];
            }

            return node;
        }
    }

    class Contest
    {
        public List<int> Score;
        public List<int> ScoreMinus;
    }

    class Introduction
    {
        public static List<int> ScoreMinus = new List<int>();
        public static List<List<int>> ContestScore = new List<List<int>>();
        static System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();


        static Random Random = new Random(42);


        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());  // 365

            ScoreMinus = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            for (int i = 0; i < N; i++)
            {
                ContestScore.Add(Console.ReadLine().Split(' ').Select(int.Parse).ToList());
            }

            sw.Start();

            var startNode = new Node();
            for (int i = 0; i < 26; i++)
            {
                startNode.ContestPenalties[i] += ScoreMinus[i];
                startNode.NextPenalty += ScoreMinus[i];
            }

            // B問題シミュレーション
            var bNode = new Node() { NextPenalty = startNode.NextPenalty, Contests = new List<int>(), ContestPenalties = startNode.ContestPenalties.ToArray() };

            for (int i = 0; i < N; i++)
            {
                int v = int.Parse(Console.ReadLine()) - 1;
                bNode = bNode.AddContest(v);
                Console.WriteLine(bNode.Score);
            }

            return;
        }
    }

}


Measured memory_bytes: 29772
import java.util.*;

public class Main {
    int fast[][];
    int ans = Integer.MAX_VALUE;

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();

        int rn = sc.nextInt();
        int r[] = new int[rn];
        for (int i = 0; i < rn; i++) {
            r[i] = sc.nextInt();
        }

        int map[][] = new int[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(map[i], 20000000);
            map[i][i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            map[a - 1][b - 1] = c;
            map[b - 1][a - 1] = c;
        }

        fast = new int[n][n];
        for (int i = 0; i < n; i++) {
            fast[i] = dijkstra(i, n, map);
        }

        int route[] = new int[rn];
        boolean visit[] = new boolean[n];
        foo(0, rn, r, route, visit);

        System.out.println(ans);
    }

    private void foo(int now, int n, int r[], int route[], boolean visit[]) {
        if (now == n) {
            int res = 0;
            for (int i = 0; i < n - 1; i++) {
                res += fast[route[i] - 1][route[i + 1] - 1];
            }
            ans = Math.min(ans, res);
            return;
        }

        for (int i = 0; i < n; i++) {
            if (!visit[r[i] - 1]) {
                route[now] = r[i];
                visit[r[i] - 1] = true;
                foo(now + 1, n, r, route, visit);
                visit[r[i] - 1] = false;
            }
        }
    }

    private int[] dijkstra(int start, int n, int map[][]) {
        int mins[] = new int[n];
        boolean fix[] = new boolean[n];
        Arrays.fill(mins, Integer.MAX_VALUE);
        mins[start] = 0;

        do {
            fix[start] = true;
            int minc = Integer.MAX_VALUE;
            int next = -1;
            for (int i = 0; i < n; i++) {
                if (!fix[i]) {
                    mins[i] = Math.min(mins[i], mins[start] + map[start][i]);
                    if (mins[i] <= minc) {
                        minc = mins[i];
                        next = i;
                    }
                }
            }

            start = next;
        } while (start != -1);

        return mins;
    }

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


Measured memory_bytes: 48324
n,m=map(int,input().split())
a=[0 for i in range(n)]
b=[0 for i in range(n)]
c=[0 for i in range(m)]
d=[0 for i in range(m)]
for i in range(n):
  x,y=map(int,input().split())
  a[i]=x
  b[i]=y
for i in range(m):
  x,y=map(int,input().split())
  c[i]=x
  d[i]=y
for i in range(n):
  x,y=a[i],b[i]
  ans=int(10**9)
  p,q,l,r=0,0,0,0
  for j in range(m):
    p=c[j]
    q=d[j]
    l=abs(x-p)+abs(y-q)
    if l<ans:
      ans=l
      r=j+1
  print(r)

Measured memory_bytes: 3444
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
       Scanner sc = new Scanner(System.in);
       int s = sc.nextInt();
       
       int h,m,b;
       h=s/3600;
       m=(s%3600)/60;
       b=((s%3600)-m*60);
       System.out.println(h+":"+m+":"+b);
       
       
	}

}

Measured memory_bytes: 26140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
  long long kazu = 0;
  long long a,b;
  cin >> kazu >> a >> b;
  long long kotae = 0;
  if(a == 0 && b == 0){
    kotae = 0;
  }
  else if(kazu % (a + b) == 0){
    kotae = kazu / (a + b) * a;
  }
  else{
    kotae = kazu / (a + b) * a + min(kazu % (a + b),a);
  }
  cout << kotae << endl;
  return 0;
}

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

int main(){
  long long l;
  int i = 0;
  cin >> l;
  while(l>0) {
    l -= 500;
    i += 1000;
    if(l<0) {
      l += 500;
      i -= 1000;
      break;
    }
  }
  while(l>0) {
    l -= 5;
    i += 5;
    if(l<0) {
      l += 5;
      i -= 5;
      break;
    }
  }
  cout << i << endl;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
#include<list>
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;

ifstream f1;
ofstream f2;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	//system("pause");
	ll a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << '\n';
	}
	else {
		cout << "IMPOSSIBLE" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<algorithm>
int main()
{
	int x,ans=0;
	scanf("%d",&x);
	for(int i=1;i<=1000;i++)
		for(int j=2;j<=1000;j++)
		{
			int t=pow(i,j);
			if(t>x)
				break;
			if(ans<t)
				ans=t;
		}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    ll h,w,tmp=0;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    bool flag = true;
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) cin>>a[i][j];
    }
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            if(a[i][j] == '#') {
                if(tmp > j) flag = false;
                else tmp = j;
            }
        }
    }
    cout<<(flag == true ? "Possible" : "Impossible")<<endl;
}

Measured memory_bytes: 256
n = gets.strip.to_i
lists = gets.split.map(&:to_i).combination(3).to_a
cnt = 0
lists.each do |l0, l1, l2|
  next if l0 == l1 || l1 == l2 || l2 == l0
  cnt += 1 if l0 + l1 > l2 && l1 + l2 > l0 && l0 + l2 > l1
end
p cnt

Measured memory_bytes: 22660
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string trans(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

bool binary(vector<int> vec, int key)
{
        int left = 0;
        int right = vec.size();

        while (left < right)
        {
                int mid = (left + right) / 2;
                if (vec[mid] == key)
                {
                        return true;
                }
                else if (vec[mid] > key)
                {
                        right = mid;
                }
                else
                {
                        left = mid + 1;
                }
        }
        return false;
}

int main() //input->compute->output
{
        int N, M;
        cin >> N >> M;
        vector<int> a(N), b(N), c(M), d(M);
        rep(i, N)
        {
                cin >> a[i] >> b[i];
        }
        rep(i, M)
        {
                cin >> c[i] >> d[i];
        }

        int ans = 0;
        rep(i, N)
        {
                int ans = 0;
                int tmp = (int)1e9;
                rep(j, M)
                {
                        int cnt;
                        cnt = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                        if (tmp > cnt)
                        {
                                tmp = cnt;
                                ans = j;
                        }
                }
                cout << ans + 1 << endl;
        }

        return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    s = sum(map(int, [i for i in str(N)]))
    if s % 9 == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n ;
  cin>>n;
  
  vector<ll> a(n);
  int odd=0,two=0,four=0;
  rep(i,n){
    cin >> a[i];
    if(a[i]%2!=0) odd++;
    else if(a[i]%4==0) four++;
  }
  if(four>=odd) cout<<"Yes"<<endl;
  else if(four+odd==n && four+1==odd)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}
  



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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  if((B-A)%2==0) cout << (B-A)/2 << endl;
  else cout << min((N-B+1+N-A)/2, min((A+B-1)/2, min(B-1, N-A))) << endl;
}

Measured memory_bytes: 256
using System;

namespace PrintaRectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			while (true) {
				string[] hw = Console.ReadLine().Split(' ');
				int H, W;

				//???
				H = int.Parse (hw [0]);
				//?¨?
				W = int.Parse (hw [1]);

				//H, W ?????¨?????? 0 ?????¨????????\???????????????
				if (H == 0 && W == 0)
					break;

				//????????\??????????????????
				for (int i = 0; i < H; i++) {
					//?¨??????\??????????????????
					for (int j = 0; j < W; j++) {
						Console.Write ("#");
					}
					Console.Write ("\n");
				}
				Console.Write ("\n");
			}
		}
	}
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[N],b[N],c[N];
int ab[N],bc[N],ac[N];
int ch(char x,char y){
  if(x==y || x=='?' || y=='?')return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>a+1>>b+1>>c+1;
  int A=strlen(a+1);
  int B=strlen(b+1);
  int C=strlen(c+1);
  for(int i=1;i<=A;i++){
    for(int j=1;j<=B;j++){
      if(!ch(a[i],b[j]))ab[i-j+20000]=1;
    }
  }
  for(int i=1;i<=A;i++){
    for(int j=1;j<=C;j++){
      if(!ch(a[i],c[j]))ac[i-j+20000]=1;
    }
  }
  for(int i=1;i<=B;i++){
    for(int j=1;j<=C;j++){
      if(!ch(b[i],c[j]))bc[i-j+20000]=1;
    }
  }
  int ans=A+B+C;
  for(int i=-4000;i<=4000;i++){
    for(int j=-4000;j<=4000;j++){
      if(!ab[i+20000] && !bc[j+20000] && !ac[i+j+20000]){
//        cout<<i<<' '<<j<<'\n';
//        if(i==4&&j==-2)cout<<1<<endl;
          int x=min(0,min(i,i+j));
          int y=max(0,B-(A-i));
          int z=max(0,C-(A-(i+j)));
          ans=min(ans,max(y,z)-x+A);
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 384
// Problem Code: abc174_e

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int logs(int N, int K, vector<int>& A) {
	int low, mid, high;
	low = 1;
	high = *max_element(A.begin(), A.end());

	// helper function
	auto good = [&](int len) {
		int cuts = 0;
		for (int& log: A)
			cuts += (log - 1) / len;
		return cuts <= K;
	};

	// binary search
	while (low < high) {
		mid = low + (high - low) / 2;
		if (good(mid))
			high = mid;
		else
			low = mid + 1;
	}

	return high;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << logs(N, K, A);
	return 0;
}

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

typedef long long ll;

ll get_gcd(ll a, ll b){
    if(a < b) swap(a,b);
    return((a%b == 0 ? b : get_gcd(b,a%b)));
}

vector<pair<ll,ll>> prime_factorize(ll gcd){
    vector<pair<ll,ll>> ans;

    for(ll i=2; i*i<=gcd; i++){
        if(gcd % i != 0) continue;
        int ex = 0;
        while(gcd % i == 0){
            ex++;
            gcd /= i;
        }
        ans.push_back({i,ex});
    }

    if(gcd != 1) ans.push_back({gcd,1});

    return ans;

}


int main(){
    ll a,b;
    cin>>a>>b;
    ll gcd = get_gcd(a,b);

    vector<pair<ll,ll>> ans = prime_factorize(gcd);

    cout<<((int)ans.size()+1)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            cout << s.at(i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,a0) memset(a,a0,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii;
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
#define int ll
int n,m,q,ans;
int rec[N],a[N],b[N],c[N],d[N];

void cal(){
	ll sum=0;
	repeat(i,0,q)
	if(rec[b[i]]-rec[a[i]]==c[i])
		sum+=d[i];
	ans=max(ans,sum);
}
void dfs(int x,int pre){
	if(x==n+1){
		cal();
		return;
	}
	repeat(i,pre,m+1){
		rec[x]=i;
		dfs(x+1,i);
	}
}
signed main(){
	cin>>n>>m>>q;
	repeat(i,0,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1,1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3664