akhauriyash/Code-Regression huggingface dataset:
from collections import deque
sa=deque(list(input()))
sb=deque(list(input()))
sc=deque(list(input()))
s=sa.popleft()
while True:
  if s=='a':
    if len(sa)>0:
      s=sa.popleft()
    else:
      print('A')
      exit()
  elif s=='b':
    if len(sb)>0:
      s=sb.popleft()
    else:
      print('B')
      exit()
  elif s=='c':
    if len(sc)>0:
      s=sc.popleft()
    else:
      print('C')
      exit()
    


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

llong mod = 1000000007;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
  int N;cin>>N;
  int D;cin>>D;
  std::vector<vector<int>> X(N,vector<int> (D));
  int c =0;
  REP(i,N)REP(j,D)cin >> X[i][j];
  REP(i,N){
    FOR(j,i+1,N){
      double d;
      int x=0;
      REP(k,D){
        x += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      d = sqrt(x);
      if(ceil(d)==floor(d))c++;
    }
  }
  cout <<c<<endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>

using namespace std;

class Question {
public:
	Question() : pena(0), ac(false){}
	~Question(){}

	void put(string &s){
		if(!ac) {
			if(s=="AC") {
				ac = true;
			} else {
				pena++;
			}
		}
	}
	int getPenarty() const {
		if(ac) return pena; 
		else return 0;
	}
	int getAC() const {
		if(ac) return 1;
		else return 0;
	}

private:
	int pena;
	bool ac;
};

int main()
{
	int n, m;

	cin>>n>>m;

	Question q[n];

	int index;
	string judge;

	for(int i=0; i<m ; i++){
		cin>>index;
		cin>>judge;
		q[index-1].put(judge);
	}

	int penalty=0;
	int ac=0;

	for(int i=0; i<n ; i++){
		penalty += q[i].getPenarty();
		ac      += q[i].getAC();
	}

	cout<<ac<<" "<<penalty<<endl;

	return 0;
}


Measured memory_bytes: 1024
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
	get_number(N),
    get_number(M),
    X is N - M + 1,
    writeln(X).


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

int main() {
	int a,n,c;
	cin>>n;
	int cnt=0;
	for (int i=1;i<=n;i++){
		cin>>a;
		if (i%2==1 && a%2==1){
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500][500];
ll x[800005],y[800005],z[900005];
ll ma1[500005],ma2[500005];

int main(){	
	cin>>n;
	m = (1<<n);
	for(i=0;i<m;i++){
		cin>>x[i];
		ma1[i] = x[i];
	}
	for(j=0;j<n;j++){
		for(i=0;i<m;i++){
			if((i & (1<<j))){
				y[0] = ma1[i^(1<<j)];
				y[1] = ma2[i^(1<<j)];
				y[2] = ma1[i];
				y[3] = ma2[i];
				sort(y,y+4);
				ma1[i] = y[3];
				ma2[i] = y[2];
			}
		}
	}
	for(i=1;i<m;i++){
		ans = max(num,ma1[i]+ma2[i]);
		num = ans;
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n,t,a;
  cin>>n>>t>>a;
  long long temp=1e13;
  int ans=-1;
  rep(i,n){
    int h;
    cin>>h;
    long long T=1000*t-6*h;
    if(abs(temp-a*1000)>abs(T-a*1000)){
      temp=T;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int a;cin>>a;
	cout<<24-a+24<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

int main() {
	int A, B, C;
	string S;
	cin >> A >> B >> C;
	cout << (C / A) * B << endl;
	return 0;
}



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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    vector<int> d(3);
    rep(i,3) cin >> d[i];
    VSORT(d);
    overlap(d);
    cout << d.size() << endl;
}

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

    solve();

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n), e(n);
  rep(i,n) cin >> d[i] >> e[i];
  rep(i,n-2) {
    if(d[i] != e[i]) continue;
    if(d[i+1] != e[i+1]) continue;
    if(d[i+2] != e[i+2]) continue;
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3616
N = int(input())
A = list(map(int, input().split()))
temp = A[0]
for x in range(1, N):
  if x % 2 == 1:
    temp -= A[x]
  else:
    temp += A[x]
res = [temp]
show = str(res[0])

for i in range(0, N - 1):
  res.append((A[i] - res[i] // 2) * 2)
  show += " " + str(res[i + 1])
print(show)
  

Measured memory_bytes: 14640
#!/usr/bin/env python
# coding: utf-8

import sys
import copy

THREASHHOLD = 10 ** 18


def main():
    # 1行目を得る
    line = sys.stdin.readline()
    n = int(line.rstrip())

    # 2行目を得る
    line = sys.stdin.readline()
    list_a1_an = list(map(lambda x: int(x), line.rstrip().split(' ')))

    if 0 in list_a1_an:
        result = 0
    else:
        result = list_a1_an[0]
        for index in range(1, len(list_a1_an)):
            result = result * list_a1_an[index]
            if result > THREASHHOLD:
                result = -1
                break
    print(result)

    #for line in sys.stdin:
    #    print(line)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24332
from collections import Counter
from math import factorial


n = int(input())
a = list(map(int, input().split()))

s = [0]
s_elem = 0

for ai in a:
  
  s_elem += ai
  s.append(s_elem)

ans = 0
for c in Counter(s).values():
  ans += c*(c-1)//2
    
print(ans)

Measured memory_bytes: 41720
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
string s;
int n, a, b, c, d;

bool rea(int b, int e){
    for(int i = b + 1; i <= e; i++){
        if(s[i] == '#' && s[i + 1] == '#'){
            return false;
        }
    }
    return true;
}

int main(){
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    a--; b--; c--; d--;
    s = "#" + s + "#";
    if((!rea(a, c)) || (!rea(b, d))){
        cout << "No";
        return 0;
    }
    if(c > d){
        for(int i = b + 1; i <= d + 1; i++){
            if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,ans=0;cin>>n;
  for(int i=1;i<=n;++i){
    int t;cin>>t;
    if(i%2==1&&t%2==1)ans++;
  }
  cout<<ans<<"\n";
  
  return 0;
}
//2020.07.11 20:02:09


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false


int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = K;
	for (ll i = 1; i <= N - 1; i++) ans *= (K - 1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string L;
  cin >> L;
  int k = L.length();
  vector<long long> A(k,0);//以下であると確定
  vector<long long> B(k,0);//以下かはわからない
  A[0] = 1;
  B[0] = 2;
  for(int a = 1;a < k;a++){
    if(L[a] == '0'){
     A[a] = A[a-1] * 3;
     B[a] = B[a-1]; 
    }else{
     A[a] = A[a-1] * 3 + B[a-1]; 
     B[a] = B[a-1] * 2;
    }
    A[a] %= 1000000007;
    B[a] %= 1000000007;
    
  }
  
 cout << (A[k-1] + B[k-1]) % 1000000007;
}


Measured memory_bytes: 5116
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string.h>

using namespace std;


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

  for(int i = 0; i < n; i++){
    char x[1000], y[1000];
    cin >> x >> y;
    int c[strlen(x) + 2][strlen(y) + 2];
    for(int j = 0; j <= strlen(x);j++) c[j][0] = 0;
    for(int j = 0; j <= strlen(y);j++) c[0][j] = 0;


    for(int j = 1; j <= strlen(x); j++){
      for(int k = 1; k <= strlen(y); k++){
        if(x[j - 1] == y[k - 1]) c[j][k] = c[j - 1][k - 1] + 1;
        else c[j][k] = max(c[j][k - 1], c[j - 1][k]);
      }
    }
    cout << c[strlen(x)][strlen(y)] << endl;

  }

  return 0;
}



Measured memory_bytes: 7012
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  ll a,b,x; cin>>a>>b>>x;
  ll l,r;
  r=b/x+1;
  l=(a-1)/x+1;
  if(a==0){l=0;}
  cout<<r-l;
}



Measured memory_bytes: 3588
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from math import hypot

while True:
    x = int(stdin.readline())
    h = int(stdin.readline())
    if not (x or h):
        break
    print('{:.6f}'.format(x * x + hypot(x, h * 2) * x))

Measured memory_bytes: 4396
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static int r;
    static int c;
    static void Main()
    {
        r = Read();
        c = Read();
        var n = Read();

        List<Tuple<int, int>> edgeIndices = new List<Tuple<int, int>>();
        for (int i = 0; i < n; i++)
        {
            var x1 = Read();
            var y1 = Read();
            var x2 = Read();
            var y2 = Read();
            if (!IsEdge(x1, y1) || !IsEdge(x2, y2)) continue;
            var edgeInd1 = ToEdgeIndex(x1, y1);
            var edgeInd2 = ToEdgeIndex(x2, y2);
            edgeIndices.Add(new Tuple<int, int>(Min(edgeInd1, edgeInd2), Max(edgeInd1, edgeInd2)));
        }
        Stack<int> stack = new Stack<int>();
        foreach (var item in edgeIndices.OrderBy(x => x.Item1))
        {
            while (stack.Count > 0 && stack.Peek() < item.Item1) stack.Pop();

            if (stack.Count > 0 && stack.Peek() < item.Item2)
            {
                Console.WriteLine("NO");
                return;
            }
            stack.Push(item.Item2);
        }
        Console.WriteLine("YES");
    }

    static bool IsEdge(int x, int y) => (x == 0 || x == r) || (y == 0 || y == c);

    static int ToEdgeIndex(int x, int y) => ((x == 0 && y != 0) || y == c) ? (c + r) * 2 - (x + y) : x + y;
     
    static readonly TextReader In = Console.In;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static int Read()
    {
        int res = 0;
        int next = In.Read();
        while (48 > next || next > 57) next = In.Read();
        while (48 <= next && next <= 57)
        {
            res = res * 10 + next - 48;
            next = In.Read();
        }
        return res;
    }
}


Measured memory_bytes: 19296
import sys
import math
from itertools import accumulate as acc

def func(s):
    return (int(s)-1)%K


N,K=map(int,input().split())
a=list(map(int,input().split()))
x=[0]
tmp=0
for i in range(N):
    tmp=(tmp+a[i]-1)%K
    x+=[tmp]
dic={}
ans=0
if N<K:
    for i in range(N+1):
        if x[i] in dic: dic[x[i]]+=1
        else: dic[x[i]]=1
    for i in dic:
        ans+=dic[i]*(dic[i]-1)//2

    
else:
    for i in range(K):
        p=x[i]
        if p in dic: dic[p]+=1
        else: dic[p]=1
        ans+=dic[p]-1
    for i in range(K,N+1):
        p=x[i]
        if p in dic: dic[p]+=1
        else: dic[p]=1
        dic[x[i-K]]-=1
        ans+=dic[p]-1

print(int(ans))

Measured memory_bytes: 40616
#include<bits/stdc++.h>
#define LL long long

namespace io {
    template <typename T> inline void read(T & _x) {
        int f = 0, ch; _x = 0;
        while(!isdigit(ch = getchar())) f |= ch == '-';
        while(isdigit(ch)) _x = _x * 10 + ch - '0', ch = getchar();
        if(f) _x = -_x;
    }
    template <typename T, typename ... Args> inline void read(T &_f, Args& ... args) {
        read(_f), read(args ...);
    }
    inline void _deal(char ch) { putchar(ch); }
    template <typename T> inline void _deal(T _x) {
        if (_x < 0) putchar('-'), _x = -_x;
        if (_x > 9) _deal(_x / 10);
        putchar(_x % 10 + '0');
    }
    inline void write() {}
    template <typename T, typename ... Args> inline void write(T _f, Args ... args) {
        _deal(_f), write(args...);
    }
}

const int N = 2e5 + 5;

int n, k, a[N], cf[N], fir;

int main() {
	io::read(n, k);
	for(int i = 1; i <= n; i++) {
		io::read(a[i]);
		if(a[i] >= i - 1)
			++fir;
		if(i - a[i] >= 2)
			++cf[i - a[i]];
		if(i + a[i] + 1 <= n)
			--cf[i + a[i] + 1];
	}
	for(int i = 1; i <= k; ++i) {
		a[0] = fir;
		int cnt = 0;
		for(int i = 1; i <= n; i++) {
			a[i] = a[i - 1] + cf[i];
			cf[i] = 0;
			cnt += (a[i] >= n);
		}
		fir = 0;
		if(cnt >= n)
			break;
		for(int i = 1; i <= n; i++) {
			if(a[i] >= i - 1)
				++fir;
			if(i - a[i] >= 2)
				++cf[i - a[i]];
			if(i + a[i] + 1 <= n)
				--cf[i + a[i] + 1];
		}
	}
	for(int i = 1; i <= n; ++i)
		io::write(a[i], ' ');
	return 0;
}

Measured memory_bytes: 5160
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <algorithm>
using namespace std;
int a[200005],f[1000005],t[1000005];
int main()
{
 ios::sync_with_stdio(false);
 int n,ans=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {
  cin>>a[i];
  t[a[i]]++;
 }
 sort(a+1,a+n+1);
 for(int i=1;i<=n;i++)
 {
  if(!f[a[i]])
  {
   if(t[a[i]]==1)ans++;
   for(int j=a[i];j<=1000000;j+=a[i])
    f[j]=1;
  }
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 12204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <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 V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}

vector<int> convertToRadix(ll x, int radix, int keta)
{
    x = abs(x);
    ll r = 0, q = 0;
    vector<int> ans;
    while (x >= 1)
    {
        r = x / radix;
        q = x % radix;
        ans.push_back(q);
        x = r;
    }
    while (ans.size() < keta)
        ans.push_back(0);

    reverse(all(ans));

    return ans;
}
ll convertToInteger(string S, int radix)
{
    ll ans = 0;
    rep(i, S.size())
    {
        ans += (S[i] - '0') * pow(radix, i);
    }
    return ans;
}
int main()
{
    int N, ans = INT_MAX;
    vint A(3);
    cin >> N >> A[0] >> A[1] >> A[2];
    vint l(N);
    rep(i, N)
    {
        cin >> l[i];
    }
    for (int i = 0; i < pow(4, N); i++) //4進法全探索
    {
        int tans = 0, ta = INT_MAX / 2;
        auto seq = convertToRadix(i, 4, N);
        int a[3] = {0, 0, 0};
        vint tmp;
        for (int j = 0; j < N; j++)
        {
            if (seq[j] != 3)
            {
                if (a[seq[j]] != 0)
                    tans += 10;

                a[seq[j]] += l[j];
            }
        }
        for (int j = 0; j < 3; j++)
        {
            if (a[j] == 0)
                goto L;
        }

        for (int k = 0; k < 3; k++)
        {
            for (int j = 0; j < 3; j++)
            {

                int w = 3 - (k + j); //A[0]とa[k]を、A[1]とa[j]を、A[2]とa[w]をマッチング
                if (k == j or k == w or j == w)
                    continue;
                int p = abs(A[0] - a[k]) + abs(A[1] - a[j]) + abs(A[2] - a[w]);
                chmin(ta, p);
            }
        }
        tans += ta;
        chmin(ans, tans);

    L:;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
from sys import stdin
H, W = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1e10 
for _ in range(2):
    for i in range(1, H):
        a = i*W
        b = (W//2) * (H-i)
        c = ((W+1)//2 * (H-i))
        ans = min(ans, abs(max([a,b,c]) - min([a,b,c])))
        b = ((H-i)//2 * W)
        c = ((H-i+1)//2 * W)
        ans = min(ans, abs(max([a,b,c]) - min([a,b,c])))
    H, W = W, H

print(ans)

Measured memory_bytes: 3064
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
const ll M=1e3+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll h,w,k;
ll xs,ys;
str jad[M];
ll dis[M][M];
ll xp[4]={0,1,0,-1};
ll yp[4]={1,0,-1,0};

int main()
{
    cin >> h >> w >> k;
    For(i,0,h)
    {
        cin >> jad[i];
        For(j,0,w)
        {
            if (jad[i][j]=='S') xs=i,ys=j;
        }
    }
    memset(dis,127,sizeof dis);
    dis[xs][ys]=0;
    // BFS
    {
        queue<pll> qu;
        qu.push({xs,ys});
        while (SZ(qu))
        {
            ll px,py;
            px=qu.front().X;
            py=qu.front().Y;
            qu.pop();
            For(r,0,4)
            {
                ll xx=px+xp[r];
                ll yy=py+yp[r];
                if (xx<0 || xx>=h || yy<0 || yy>=w) continue;
                if (jad[xx][yy]!='#' && dis[xx][yy]>dis[px][py]+1)
                {
                    dis[xx][yy]=dis[px][py]+1;
                    qu.push({xx,yy});
                }
            }
        }
    }
    ll res=xs;
    For(i,0,h) For(j,0,w)
    {
        if (dis[i][j]<=k)
        {
            //ER(i);ER(j);
            smin(res,(ll)min(i,j));
            smin(res,h-i-1);
            smin(res,w-j-1);
        }
    }
    RET(res/k+2-!(res%k));
}    


Measured memory_bytes: 8960
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;















signed main(){
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }else cout << "No";




}


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

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if (a == b && b == c) {
    printf("1");
  } else if (a == b || b == c || a == c) {
    printf("2");
  } else {
    printf("3");
  }
  return 0;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	string S_, T;
	cin >> S_ >> T;

	vector<string> candidate;
	if (S_.size() < T.size())
	{
		cout << "UNRESTORABLE" << endl;
		return EXIT_SUCCESS;
	}
	for (size_t i = 0; i <= S_.size() - T.size(); ++i)
	{
		bool ok = true;
		for (size_t j = 0; j < T.size() && i + j < S_.size() && ok; ++j)
		{
			if (S_[i + j] == '?')	continue;
			ok = S_[i + j] == T[j];
		}
		if (ok)
		{
			string S = S_.substr(0, i) + T;
			if (i + T.size() < S_.size())
			{
				S += S_.substr(i + T.size());
			}
			replace(S.begin(), S.end(), '?', 'a');
			candidate.push_back(S);
		}
	}
	if (candidate.empty())
	{
		cout << "UNRESTORABLE" << endl;
		return EXIT_SUCCESS;
	}
	cout << *min_element(candidate.begin(), candidate.end()) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int sum1 = (n - m) * 100;
    if(m == 0){
        cout << sum1;
        return 0;
    }
    int bnbo = 1;
    for(int i = 0; i < m; i++){
        bnbo *= 2;
    }
    int sum2 = 1900 * m * bnbo;
    cout << sum2 + sum1 * bnbo;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy" << endl;
  else if (s == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <deque>
#include <set>

using namespace std;
using ll = long long;

const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    multiset<ll> st;
    for(int i = 0; i < n; i++)
    {
        ll x; cin >> x;
        st.insert(x);
    }
    ll v = *st.begin();
    st.erase(v);
    ll k = 0;
    for(auto x : st)
    {
        k ^= x;
    }
    if(k == v) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                1010
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
    /*#ifndef ONLINE_JUDGE
        double start = clock(); READ(); WRITE();
    #endif*/
        int a, b, c; siii(a, b, c);
        swap(a, b);
        swap(a, c);

        pf("%d %d %d\n", a, b, c);

   /* #ifndef ONLINE_JUDGE
        printf("\n>>Runtime: %.10fs\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    #endif*/

    return 0;
}

Measured memory_bytes: 256
K=int(input())
 
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
 
ans=0
 
for a in range(1,K+1):
    for b in range(1,K+1):
        hoge=gcd(a,b)
        for c in range(1,K+1):
            g=gcd(hoge,c)
            ans += g
 
print(ans)

Measured memory_bytes: 68224
using System;

public class Problem_C
{
  static readonly int DIV = 1000000007;

  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int N = inputs[0], M = inputs[1];

    if (Math.Abs(N - M) >= 2) Console.WriteLine("0");
    else
    {
      long ans = (FactorialMod(N, DIV) * FactorialMod(M, DIV)) % DIV;
      ans = N == M ? 2 * ans % DIV : ans;
      Console.WriteLine($"{ans}");
    }
  }

  private static long FactorialMod(int num, int divider)
  {
    long ans = num;
    for (var i = num - 1; i > 1; i--)
    {
      ans = (ans * i) % divider;
    }
    return ans;
  }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(void) {
	int e,y;
	
	scanf("%d%d",&e,&y);
	if(e==0){
		if(1868<=y && y<=1911) printf("M%d\n",y-1868+1);
		else if(y<=1925) printf("T%d\n",y-1912+1);
		else if(y<=1988) printf("S%d\n",y-1926+1);
		else printf("H%d\n",y-1989+1);
		
	} else if(e==1){
		printf("%d\n",1868+y-1);
	} else if(e==2){
		printf("%d\n",1912+y-1);
	} else if(e==3){
		printf("%d\n",1926+y-1);
	} else{
		printf("%d\n",1989+y-1);
	}
	
	return 0;
}

Measured memory_bytes: 596
#dame datta
def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = 0
    ans = 0
    t = 0
    for i, v in enumerate(A):
        if t & v == 0:
            t |= v
        else:
            while t & v > 0:
                t ^= A[l]
                l += 1
            t |= v
        ans += i - l + 1
    return ans
print(main())


Measured memory_bytes: 24840
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr int MOD = 1000000007;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

VL prime_decomposition(ll n) {
	ll i = 2;
	VL table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace_back(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace_back(n);
		return table;
	}
}

int main() {
	ll n, m;
	cin >> n >> m;
	vector<PAIR> v;
	v.reserve(m);
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	auto cp = v;

	sort(ALL(v), [](const auto& a, const auto& b) {
		return a.second < b.second;
	});
	stable_sort(ALL(v), [](const auto& a, const auto& b) {
		return a.first < b.first;
	});

	map<PAIR, ll> mp;
	ll t = 0;
	ll count = 0;
	REPC(x, v) {
		if (x.first != t) {
			count = 0;
			t = x.first;
		}
		mp[x] = {++count};
	}

	cout << setfill('0')<< setw(6);
	REPC(x, cp) {
		cout << std::setfill('0') << x.first << setw(6);
		cout << std::setfill('0') << mp[x] << setw(6) << endl;;
	}
}

Measured memory_bytes: 10856
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int num1[2];
    int i;
    scanf("%d%d", &num1[0], &num1[1]);
    for (i = 1; i == num1[0] || i == num1[1]; i++) {
        
    }
    printf("%d", i);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int gcd(int a, int b) {
    return (a == 0) ? b : gcd(b % a, a);
}

bool used[260000];

struct Edge {
    int to, cap, rev;
};

void add_edge(vector<vector<Edge>> &G, int from, int to, int cap) {
    G[from].push_back((Edge){ to, cap, (int)G[to].size() });
    G[to].push_back((Edge){ from, 0, (int)G[from].size()-1 });
}

int dfs(vector<vector<Edge>> &G, int v, int to, int f) {
    used[v] = true;
    int ret = 0;
    if (v == to) {
        ret = f;
    } else {
        for (Edge &e: G[v]) {
            if (used[e.to] || e.cap <= 0) continue;
            int t = dfs(G, e.to, to, min(f, e.cap));
            if (t > 0) {
                e.cap -= t;
                G[e.to][e.rev].cap += t;
                ret = t;
                break;
            }
        }
    }
    return ret;
}

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

    int m, n;
    while (cin >> m >> n, m) {
        vector<int> b(m), r(n);
        for (int i=0; i<m; ++i) cin >> b[i];
        for (int i=0; i<n; ++i) cin >> r[i];

        vector<vector<Edge>> G(m+n+2);
        for (int i=0; i<m; ++i) {
            for (int j=0; j<n; ++j) {
                if (gcd(b[i], r[j]) != 1) {
                    add_edge(G, i, m+j, 1);
                }
            }
        }
        for (int i=0; i<m; ++i) {
            add_edge(G, m+n, i, 1);
        }
        for (int i=0; i<n; ++i) {
            add_edge(G, m+i, m+n+1, 1);
        }

        int res = 0;
        while (1) {
            fill_n(used, m+n+2, false);
            int f = dfs(G, m+n, m+n+1, INT_MAX);
            if ( ! f) break;
            res += f;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


int imos[100010];
int a[100010];
int main() {
	m0(imos);
	int N, M; cin >> N >> M;
	REP(i, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		imos[a]++;
		imos[b]--;
	}
	FOR(i, 1, N - 1) {
		imos[i] += imos[i - 1];
	}
	REP(i, N - 1) {
		if (imos[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
s = input()
K = int(input())

ans = []
for ch in s:
    v = ord("a") + 26 - ord(ch)
    if ch != "a" and v <= K:
        K -= v
        ans.append("a")
    else:
        ans.append(ch)

if K > 0:
    ans[-1] = chr(ord(ans[-1]) + K % 26)
print("".join(ans))


Measured memory_bytes: 10128
#include <iostream>
using namespace std;
int main() {

	int a;
	int b;

	cin >> a;
	cin >> b;

	if(a < b){
		cout << "a < b" << endl;
	}

	if (a > b) {
		cout << "a > b" << endl;
	}

	if (a == b) {
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
from collections import Counter
S = input()
ans = 0
c = Counter(S)
if c['W'] == 0 or c['B'] == 0:
    print(0)
    exit()
a = S[0]
while True:
    for i, s in enumerate(S):
        if s != a: break
    S = S[i:]
    c[a] -= i
    a = S[0]
    ans += 1
    if c['W'] == 0 or c['B'] == 0:break
print(ans)

Measured memory_bytes: 3444
/*
given H, find no. of attacks needed to kill all monsters, each kill will produce two more

each time / 2, ans * 2

*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long; 

const int mod = 1e9+7;

int add(int a, int b) {
    int c = a + b;
    if (c >= mod) {
        c -= mod;
    }
    return c;
}


int main() {
    ll H;
    ll base = 1;
    ll ans = 0;
    scanf("%lld", &H);
    while (H > 0) {
        ans += base;
        base *= 2;
        H /= 2;
    }
    printf("%lld", ans);
    return 0;
}

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

int N, M, Q;
set<vector<int>> SE;

void f(vector<int> tmp, int n) {
  if (n == N) {
    SE.insert(tmp);
    return;
  }
  int j;
  if (tmp.size()) j = tmp.at(tmp.size() - 1);
  else j = 1;
  for (int i = j; i <= M; i++) {
    vector<int> tmp2;
    tmp2 = tmp;
    tmp2.push_back(i);
    f(tmp2, n + 1);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M >> Q;
  vector<vector<int>> V(Q, vector<int>(4));
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> V.at(i).at(j);
    }
  }
  vector<int> tmp;
  f(tmp, 0);
  int mx = 0;
  for (auto se : SE) {
    int sum = 0;
    for (int i = 0; i < Q; i++) {
      if (se.at(V.at(i).at(1) - 1) - se.at(V.at(i).at(0) - 1) == V.at(i).at(2)) sum += V.at(i).at(3);
    }
    mx = max(mx, sum);
  } 
  cout << mx << "\n";
}


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

using ll = long long;
using ull = unsigned long long;

template <typename T> istream &operator>>(istream &istr, vector<T> &vec) {
  for(T &x : vec) istr >> x;
  return istr;
}

template <typename T> ostream &operator<<(ostream &ostr, vector<T> &vec) {
  if(!vec.empty()) {
    ostr << vec.front();
    for(auto itr = ++vec.begin(); itr != vec.end(); itr++) ostr << " " << *itr;
  }
  return ostr;
}

int main() {
  string s;
  string t;
  cin >> s;
  cin >> t;

  ll ans = 0;
  for(int i = 0; i < 3; i++) ans += (s[i] == t[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
 long long n,m;
 cin>>n>>m;
 long long a,b;
 long long path[n+100];
 for(long long i=0;i<n;i++){
  path[i]=0;
 }
 for(long long i=0;i<m;i++){
  cin>>a>>b;
  path[a-1]++;
  path[b-1]++;
 }
 for(long long i=0;i<n;i++){
  printf("%lld\n",path[i]);
 }
return 0;}

Measured memory_bytes: 3764
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    Integer[] antennas=new Integer[5];
    for(int i=0;i<5;i++){
      antennas[i]=scan.nextInt();
    }
    Arrays.sort(antennas,Collections.reverseOrder());
    int k=scan.nextInt();
    for(int i=0;i<5;i++){
      for(int j=i+1;j<5;j++){
        if(antennas[i]-antennas[j]>k){
          System.out.println(":(");
          System.exit(0);
        }
      }      
    }
    System.out.println("Yay!");
  }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int main(){

	int a,b,h;
	scanf("%d %d %d",&a,&b,&h);

	printf("%d\n",((a+b)*h)/2);

	return 0;
}


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

int main(){
  int a,b,ans=0;
  cin >> a >> b;
  for(int i = a;i<=b;i++){
    if(i/10000==i%10&&(i%10000)/1000==(i%100)/10)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N = int(stdin.readline().rstrip().split()[0])
aa = N//100
bb = N%100
a = False
b = False
if 1 <= aa <=12:
  a = True
if 1 <= bb <=12:
  b = True
if a and b:
  print("AMBIGUOUS")
elif not a and b:
  print("YYMM")
elif a and not b:
  print("MMYY")
elif not a and not b:
  print("NA")
  
  

Measured memory_bytes: 12472
/**
 *  author: Haunted_Cpp
**/
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
 
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int n;
  cin >> n;
  map<string, int> cnt;
  for (int i = 0; i < n; i++) {
    string w;
    cin >> w;
    ++cnt[w];
  }
  cout << "AC" << " x " << cnt["AC"] << '\n';
  cout << "WA" << " x " << cnt["WA"] << '\n';
  cout << "TLE" << " x " << cnt["TLE"] << '\n';
  cout << "RE" << " x " << cnt["RE"] << '\n';
  return 0;
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

def main():
# 整数の入力
    
    # スペース区切りの整数の入力
    n = [int(x) for x in input().split(' ')]
    # 文字列の入力
    s = n[0]
    w = n[1]
    if w >= s:
        print("unsafe")
    else:
        print("safe")
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
#pragma GCC opimize (3, "Ofast", "inline")
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
int n, k;
ll f[maxn];
inline ll ksm(int x, int k) {
	ll ret = 1, base = x;
	while(k) {
		if(k & 1) ret = ret * base % mod;
		base = base * base % mod, k >>= 1;
	}
	return ret;
}
inline ll C(int n, int m) {
	return f[n] * (ksm(f[n-m], mod-2) * ksm(f[m], mod-2) % mod) % mod;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> k;
	f[0] = f[1] = 1;
	for(int i = 2; i <= n; ++i) f[i] = f[i - 1] * i % mod;
	ll ans = 0;
	for(int i = 0; i <= min(n-1, k); ++i) {
		ans = (ans + C(n, i) * C(n-1, n-i-1)) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792