akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) {}
#endif





ll n;
vector<ll> a;

struct sdata {
	ll len;
	ll count;
};

ll mpow_table[64]; // mのべき乗

vector<sdata> v;

void dump(){
	return;
	eprintf( "len=%d ", SZ(v) );
	for ( auto it : v )
		eprintf( "[%lld %lld] ", it.len, it.count );
	eprintf( "\n" );
}

bool is_possible(ll m){
	ll mp = 1;
	rep(i,64){
		mpow_table[i] = mp;
		mp = min(mp*m,200001LL);
	}
	auto mpow = [&](ll p){
		if ( m == 1 )
			return 1LL;
		if ( p < 64 )
			return mpow_table[p];
		return 200001LL;
	};
	
	v.resize(0);
	
	ll keta = 0;
	
	eprintf("\n\nm=%lld\n", m );
	rep(i,n){
		dump();
		if ( keta < a[i] ){
			v.push_back({a[i]-keta,0});
			keta = a[i];
		}
		else {
			// v.top の桁を狭める
			while ( keta - v.back().len >= a[i] ){
				keta -= v.back().len;
				v.pop_back();
			}
			
			ll keta_reduce = keta-a[i];
			
			rep(j,keta_reduce){
				v.back().count /= m;
				if ( v.back().count == 0 )
					break;
			}
			v.back().len -= keta_reduce;
			keta -= keta_reduce;
			
			v.back().count++;
			while ( v.back().count >= mpow(v.back().len) ){
				keta -= v.back().len;
				v.pop_back();
				if ( v.empty() )
					return false;
				v.back().count++;
			}
		}
	}
	dump();
	return true;
}



int main(){
	cin >> n;
	a.resize(n);
	rep(i,n) {
		cin >> a[i];
	}
	
	// l種類では不可能、h種類では可能.
	ll h = 200001;
	ll l = 0;
	
	while ( h-l > 1 ){
		ll m = l + (h-l)/2;
		if ( is_possible(m) )
			h = m;
		else
			l = m;
	}
	
	cout << h << endl;
	
	return 0;
}




Measured memory_bytes: 8872
N, T = map(int, input().split())
t_list = list(map(int, input().split()))
num = 0
for i in range(N - 1):
    t = t_list[i + 1] - t_list[i]
    if t <= T:
        num += t
    else:
        num += T
print(num + T)


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

int main() {
  ll n; cin >> n;
  ll s = 0;
  for (int i = 0; i < n; ++i) {
    ll v; cin >> v;
    s += v;
  }
  cout << s / n << endl;
  return 0;
}



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0; i<N; ++i)
    {
        int l, r; cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
}

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

int64_t digits(int64_t a) {
    int64_t tmp = a;
    int ret = 0;
    while(tmp) {
        tmp /= 10;
        ret++;
    }

    return ret;
}

int main(void) {
    int64_t N;
    int64_t r;
    int64_t ans= 0; 
    double tmpr;
    
    cin >> N;
    tmpr = sqrt((double)N);
    for(r=tmpr;r>1;r--) {
        if((N % r) == 0) {
            ans = N / r;
            break;
        }
    }

    if(ans) {
        cout << digits(ans) << "\n";
    } else {
        cout << digits(N) << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

typedef long long ll;

const int N=5e5+50; 

char s[N]; 
int n,a[N],sum,ans; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%s",s+1); 
	n=strlen(s+1); 
	reverse(s+1,s+n+1); 
	rep(i,1,n){
		a[i]=(s[i]-'0')*9; 
	}
	{
		int carry=0;
		rep(i,1,n){
			a[i]+=carry;
			carry=a[i]/10;
			a[i]%=10;
			sum+=a[i];
		}
		if(carry){
			a[++n]=carry; 
			sum+=carry;
		}
	}
	for(ans=1;;++ans){
		int carry=9,p=1; 
		while(carry){
			sum-=a[p];
			a[p]+=carry;
			carry=a[p]/10;
			a[p]%=10;
			sum+=a[p++];
		}
		if(sum<=9*ans)break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

int main()
{
	int w, h;
	cin >> h >> w;
	for(int i = 0; w != 0 && h != 0; i++)
	{
		rep(j, h)
		{
			rep(k, w)
			{
				if(j % 2 == 0)
				{
					if(k % 2 == 0)
					{
						cout << '#';
					}
					else
					{
						cout << '.';
					}
				}
				else if(j % 2 == 1)
				{
					if(k % 2 == 1)
					{
						cout << '#';
					}
					else
					{
						cout << '.';
					}
				}
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return 0;
}



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

int main()
{
    int N;
    scanf("%d", &N);
    int c1 = 0, c2 = 0, c4 = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        scanf("%d", &a);
        if(a%4 == 0) ++c4;
        else if(a%2 == 0) ++c2;
        else ++c1;
    }
    c4 -= c1;
    if(c4 == -1) {
        if(c2 == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(c4 >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
N, H = map(int, input().split(" "))
a = []
b = []
for i in range(N):
  c, d = map(int, input().split(" "))
  a.append(c)
  b.append(d)
  
amax = max(a)
b.sort()
b.reverse()
bf = [x for x in b if x > amax]

count = 0
judge = 0
for i in bf:
    H -= i
    if H <= 0:
        judge = 1
        count += 1
        print(count)
        break
    count += 1

if judge != 1:
    e = H//amax
    f = H%amax
    if f != 0:
        e += 1
    print(count+e)

Measured memory_bytes: 11928
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

const int maxp=50000;
typedef long long  ll;

bool h[maxp+10];
int pri[maxp+10];
int l=0;
int n;

const int MAXN = 2e5 + 10;
const int MOD = 1e9+7;
const int MOD1=1e9+7;
int fac[MAXN], finv[MAXN];
 
ll mod_pow(ll x, ll nn) {
    if (nn == 0) return 1;
    ll res = mod_pow(x * x % MOD, nn / 2);
    if (nn & 1) res = res * x % MOD;
    return res;
}
 
void init() {
    fac[0] = 1;
    for(int i = 1; i < MAXN; i ++)
        fac[i] = (ll)fac[i - 1] * i % MOD;
    finv[MAXN - 1] = (int)mod_pow(fac[MAXN - 1], MOD - 2);
    for(int i = MAXN - 1; i > 0; i --)
        finv[i - 1] = (ll) finv[i] * i % MOD;
}
 
ll C(int nn, int m) {
    if(nn < 0 || m < 0 || m > nn) return 0;
    return (ll)fac[nn] * finv[m] % MOD * finv[nn - m] % MOD;
}

ll answer(int m,int k)
{
	int nn=k+1;
	ll ans=0;
	for (int i = 0; i * nn <= k && i <= m; i ++) {
            if (i % 2) ans = (ans - C(m, i) * C(k - i * nn + m - 1, m - 1)% MOD + MOD) % MOD;  //  奇数为减
            else ans = (ans + C(m, i) * C(k - i * nn + m -1, m - 1)% MOD + MOD) % MOD;    //  偶数为加
        }
    return ans;
}

void make_prime_list()// make prime list in [0,50000]
{
	for(int i=2;i<=maxp;i++)
	{
		if(!h[i]) pri[l++]=i;
		for(int j=0;j<l && pri[j]<=maxp/i;j++)
		{
			h[i*pri[j]]=true;
			if(i%pri[j]==0) break;
		}
	}
}

void work(int m,int n)
{
	ll res=1;
	make_prime_list();
	for(int j=0;j<l;j++)
	{
		if(n%pri[j]==0)
		{
			int cnt=0;
			//printf("%d ",pri[j]);
			while(n%pri[j]==0) 
			{
				n/=pri[j];
				cnt++;
			}
			res=res*answer(m,cnt)%MOD;
			//cout<<cnt<<endl;
		}
	}
       if(n>1)
            res=res*answer(m,1)%MOD;
	//if(n!=1) printf("%d\n",n);
	cout<<res<<endl;
}

int main()
{
	int m,n;
	init();
	scanf("%d %d",&n,&m);
	work(n,m);
	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int a, b, k;
    scanf("%d%d", &a, &b);
    k=a+b;
    if(k%2!=0){
        printf("IMPOSSIBLE\n");
    }
    else{
        printf("%d\n", k/2);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> ans;
void bfs(int test){
    int c=0;
    queue<ll> q;
    for(ll i=1;i<10;i++)
        q.push(i);
    while(!q.empty()){
        //cout<<c<<'\n';
        //cout<<q.front()<<'\n';
        c++;
        if(c==test){
            cout<<q.front();
            return ;
        }

        ll last = q.front()%10,cur= q.front();
        q.pop();
        if(last==0){
            q.push(10*cur+last);
            q.push(10*cur+last+1);
        }else if(last==9){
            q.push(10*cur+last-1);
            q.push(10*cur+last);
        }else{
            q.push(10*cur+last-1);
            q.push(10*cur+last);
            q.push(10*cur+last+1);
        }



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



}


Measured memory_bytes: 1792
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 1; i < n; i++) cin >> c[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += b[a[i]];
        if (i && a[i] == a[i - 1] + 1) {
            ans += c[a[i]];
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;
inline void read(int &x){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}

int D,T,S;
void solve(){
    if(D <= S*T) cout<<"Yes\n";
    else cout<<"No\n";
}
int main(){
//    debug;
    ios;

    cin>>D>>T>>S;
    solve();


    return 0;
}

Measured memory_bytes: 3536
/*     !ya khoda!     */
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld long double

#define pp push
#define po pop()
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
#define I insert
#define E erase

#define F first
#define S second

#define mkp make_pair
#define pll pair<ll,ll>
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define all(a) a.begin(),a.end()

#define coutghat(x)      cout<<tolower(x);
#define coutashar(x,d)   cout<<fixed<<setprecision(x)<<(ld)d
#define IOS ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)
//#define poow(a,b,M)   b?(poow((a*a)%M,b/2)%M * (b&1?a))%M:1 ;
/*==========================================================================*/
using namespace std;
using namespace __gnu_pbds;
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>;
ll poow(ll x,ll n,ll Mod=1e9+7) { return (n==0?1:poow(x*x%Mod,n/2)*(n&1?x:1)%Mod); }
//#pragma optimize O3
// 107,109, 211,223, 307, 401,409, 503,509, 601,607, 701,709, 809, 907, 1009
/*==========================================================================*/
const int N=1e5+100 , M=1e6+10  , SQ=550 , LG=21 , base=2;
const int mod=1e9+7 , MOD=1e9+9;
const ll  INF=1e9   , inf=1e18 , super_inf=~0ull/4;
ll n,a[N],x=1,ans;
/*==========================================================================*/
int main()
{
	IOS;
    cin>>n;
    for(int i=1;i<=n;i++)   cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])   x++;
        if(a[i]!=a[i-1])   ans+=(x/2) , x=1;
    }
    ans+=(x/2);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 int a,b;
 scanf("%d", &a);
 scanf("%d", &b);
 if(a < b){printf("a < b\n");}
 if(a > b){printf("a > b\n");}
 if(a == b){printf("a == b\n");}
 return 0;
}

Measured memory_bytes: 580
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import math

n = int(input())
a_top = [[], []]
a_base = [[], []]
for _ in range(n):
    s = input().rstrip()
    if "." not in s:
        top = int(s)
        base = 1
    else:
        dot = s.index(".")
        length = len(s)
        lower_num = len(s) - dot - 1
        top = int(s.replace(".", ""))
        base = pow(10, lower_num)
    gcd = math.gcd(top, base)
    top = top // gcd
    base = base // gcd
    twos = 0
    fives = 0
    while top % 2 == 0:
        twos += 1
        top //= 2
    while top % 5 == 0:
        fives += 1
        top //= 5
    a_top[0].append(twos)
    a_top[1].append(fives)
    twos = 0; fives = 0
    while base % 2 == 0:
        twos += 1
        base //= 2
    while base % 5 == 0:
        fives += 1
        base //= 5
    a_base[0].append(twos)
    a_base[1].append(fives)

nums = dict()
offset = 16
field = [[0] * 35 for _ in range(35)]
for tt, tf, bt, bf in zip(a_top[0], a_top[1], a_base[0], a_base[1]):
    if tt - bt > 15:
        twos = 15
    else:
        twos = tt - bt
    if tf - bf > 15:
        fives = 15
    else:
        fives = tf - bf
    field[twos + offset][fives + offset] += 1

single = 0
double = 0
for i in range(35):
    for j in range(35):
        for k in range(35):
            for l in range(35):
                if i == k and j == l:
                    if i - offset + k - offset >= 0 and j - offset + l - offset >= 0:
                        double += field[i][j] * (field[i][j] - 1)
                else:
                    if i - offset + k - offset >= 0 and j - offset + l - offset >= 0:
                        double += field[i][j] * field[k][l]
print(single + double // 2)

Measured memory_bytes: 107404
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int c, d[] = { 1, 5, 10, 50, 100, 500 }, t = 0;
	for (int i = 0; i < 6; ++i) {
		cin >> c;
		t += d[i] * c;
	}

	if (t > 999)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    ll Mod = 1000000007;
    ll a = 1,b = 1,c = 1;
    for (ll i = 0; i < N; i++) {
        a *= 10;
        a %= Mod;
    }
    for (ll j = 0; j < N; j++) {
        b *= 9;
        b %= Mod;
    }
    for (ll k = 0; k < N; k++) {
        c *= 8;
        c %= Mod;
    }
    cout << (a + c - 2*b + 1000000000*Mod)%Mod << endl;
} 


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

int main() {
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int a;
  if(n<=k){
    cout<<n*x<<endl;
  }
  else {
    cout<<k*x+(n-k)*y<<endl;
  }
}

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

typedef long long ll;
typedef long double ld;

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

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

int main(){

    ll x, a, b;

    cin >> x >> a >> b;

    cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 *   author  : The San Cao (caothesan@gmail.com)
 *   created : 2020.06.05 07:59:05 +07
 */

#include <bits/stdc++.h>

using namespace std;


int main() {
  int W, H, N; cin >> W >> H >> N;
  int x, y, u, v;
  x = y = 0; u = W; v = H;

  for (int i = 0; i < N; ++i) {
    int _x, _y, t; cin >> _x >> _y >> t;
    if (t <= 2) (t - 2) ? x = max(x, _x) : u = min(u, _x);
    else (t - 4) ? y = max(y, _y) : v = min(_y, v);
  }
  cout << (v < y || u < x ? 0 : (u - x) * (v - y)) << "\n";
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int pd[1100];
int n;
long long int ans = 1;
int main(){
	scanf("%d",&n);
	//sieve for prime
	for (int i=2;i<=n;i++)
		for (int j=i+i;j<=n;j+=i) pd[j]=1;

    //for (int i = 0; i <=n; i++)
    //    cout << pd[i] << " ";
    //cout << endl;

	for (int i=2;i<=n;i++)
		if (pd[i]==0){//pri
			long long int tot=0;
			for (int j=i;j<=n;j*=i) tot+=n/j;

			ans = ans*(tot+1) % 1000000007;
		}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>

using namespace std;

void Solution()
{
    string s;
    int n;
    int m;
    
    while(cin>>s)
    {
        if(s == "-") break;
        
        string left;
        string right;
        
        cin>>n;
    
        while(n--)
        {
            cin>>m;
            
            left = s.substr(0, m); //get the string which from 0, and quantity is m; called s
            right = s.substr(m); //from m to the end
            s = right + left;
        }
        
        cout<<s<<endl;
    }
}

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

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

const int DEF = -1;
const int LU = 0;
const int RU = 1;
const int LD = 2;
const int RD = 3;
const int NEXT[] = {RU, LU, RD, LD};

int main() {
  int n;

  while (cin >> n, n != 0) {
    int cnt = 0;
    int state = DEF;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;

      int cmd = s == "lu" ? LU : s == "ru" ? RU : s == "ld" ? LD : RD;
      if (state != DEF && cmd == NEXT[state]) {
	cnt++;
	state = DEF;
	continue;
      }

      state = cmd;
    }

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3108
#include <iostream>

using namespace std;

void solve(int K)
{
    // Há K/2 números pares entre 1 e K
    // Há (K + 1)/2 números ímpares entre 1 e K
    int even = K / 2, odd = (K + 1)/2;

    // Cada par escolhe um par e um ímpar, logo a resposta é o produto dos totais de ambos tipos
    cout << even * odd << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int K;
    cin >> K;

    solve(K);

    return 0;
}


Measured memory_bytes: 3524
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
 
	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}
 
	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}
 
	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}
 
	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

int main() {
	cin >> N >> K >> L;
	UnionFind tree(2*N+1);
	rep(i, K){
		cin >> A >> B;
		tree.merge(A, B);
	}
	rep(i, L){
		cin >> A >> B;
		tree.merge(A+N, B+N);
	}
	map<Pa, int> ans;
	rep(i, N){
		ans[Pa(tree.root(i+1), tree.root(i+N+1))]++;
	}

	rep(i, N){
		cout << ans[Pa(tree.root(i+1), tree.root(i+N+1))] << " ";
	}
}

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

int readInt(){
  int ret = 0;
  char c;
  while((c=getchar()) && '0' <= c && c <= '9'){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

main(){
  int n,s;
  int r[101]={0};
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();
    for(int i=0;i<n;i++){
      int tmp;tmp=readInt();r[tmp]++;
    }
    int ans = 0;
    for(int i=1;i != 101;i++){
      if (r[i] && i+i > s)ans += r[i]*(r[i]-1)/2;
      if (!r[i])continue;
      for(int j=i+1;j != 101;j++){
	if (i+j > s)ans += r[i]*r[j];
      }
      r[i] = 0;
    }
    printf("%d\n",ans);
  }
}

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n;
pair<int,int> ab[110], cd[110];
int mem[110];

int main(){
    cin >> n;
    for(int i = 0; i <= 100; i++){
        ab[i].first = 100000;
        mem[i] = 1000000;
    }
    for(int i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
    }
    for(int i = 0; i < n; i++){
        cin >> cd[i].first >> cd[i].second;
    }

    sort(ab, ab+n);
    sort(cd, cd+n);
    int aa[101];
    for(int i = 0; i < n; i++){
        aa[i] = ab[i].second;
    }
   

    int couab = 0, coucd = 0, ans = 0;
    bool flag = false;
    while(coucd < n){
        if(couab < n){
            if(ab[couab].first < cd[coucd].first){
                ++couab;
            }
            else{
                if(couab == 0){
                    coucd++;
                    continue;
                }
                sort(ab, ab+couab, SecondCompareDes);
                flag = false;
                for(int i = 0; i < couab; i++){
                    if(ab[i].second < cd[coucd].second){
                        ++ans;
                        ab[i].second = 1000000;
                        ++coucd;
                        flag = true;
                        break;
                    }
                }
                if(!flag)   ++coucd;
            }
        }
        else{
        sort(ab, ab+couab, SecondCompareDes);
        while(coucd < n){
            flag = false;
            for(int i = 0; i < couab; i++){
                if(ab[i].second < cd[coucd].second){
                    ++ans;
                    ab[i].second = 1000000;
                    ++coucd;
                    flag = true;
                    break;
                }
            }
            if(!flag)   ++coucd;
        }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    char a,b;
    cin>>a>>b>>b;
    cout<<(a==b?"Yes\n":"No\n");    
    
    return 0;
}


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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int y = 0, z = 0;
  if(x == 1 && n != 1) cout << t * t << endl;
  else {
    while(n > z) {
      y++;
      z = x * y;
    }
  cout << y * t << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=200000+10;
const int INF=int(1e9)+10;
int maps[maxn];
int num1[maxn];
int num2[maxn];
int cmd(int a,int b) {
	return a>b;
}
int main() {
	int n;
	while(~scanf("%d",&n)) {
		for(int i=0; i<n; i++) {
			scanf("%d",&maps[i]);
			num1[i]=maps[i];
		}
		sort(maps,maps+n);
		int m=maps[n-1];
		int ans1=0;
		int ans2=INF;
		for(int i=0;i<n;i++){
			if(maps[i]<=m/2&&maps[i]>ans1){
				ans1=maps[i];
			}
			if(maps[i]>=m/2&&maps[i]<ans2){
				ans2=maps[i];
			}
		}
		/*int ans3=lower_bound(maps,maps+n,m/2)-maps;
		sort(num1,num1+n,cmd);
		int ans4=lower_bound(num1,num1+n,m/2,greater<int>())-num1;
		int ans5=upper_bound(maps,maps+n,m/2)-maps;
		*/
		int ans;
		if((m-ans2)>ans1)
			ans=ans2;
		else
			ans=ans1;
		printf("%d %d\n",m,ans);
	}
	return 0;
}

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

int main()
{
	string S;

	cin >> S;

	if (S == "hi")
	{
		cout << "Yes" << endl;
	}
	else if (S == "hihi")
	{
		cout << "Yes" << endl;
	}
	else if (S == "hihihi")
	{
		cout << "Yes" << endl;
	}
	else if (S == "hihihihi")
	{
		cout << "Yes" << endl;
	}
	else if (S == "hihihihihi")
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int calcurate(int cal[20],int i,int krg,int j) {
	if (j == 1) {
		/*for (int i = 1; i <= 20; i++) {
			cout << cal[i] << endl;
		}*/
		return cal[20];
	}
	cal[j] = (cal[j] * i);
	cal[j] += krg;
	if (cal[j] >= 10) {
		int tmp;
		tmp = int(cal[j] / 10);
		cal[j] %= 10;
		krg = tmp;	/*繰り上げ*/

	}
	else {
		krg = 0;
	}
	calcurate(cal, i, krg, j - 1);


}

int main() {
	int n, cal[21] = {0};
	cal[20] = 1;
	cin >> n;
	int krg = 0;
	for (int i = 1; n >= i; i++) {
		int j = 20;
		calcurate(cal, i, krg, j);


	}
	int x = 1;
	while (true) {
		if (cal[x] != 0) {
			break;
		}
		x += 1;
	}
	for (int i = x; i <= 20; i++) {
		cout << cal[i];
	}
	cout << endl;


}
	


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int a[maxn];
int main() {
    scanf("%d",&n);
    long long sum = 0;
    for(int i=1;i<=n;i++) {
        int x,y; scanf("%d%d",&x,&y);
        a[i] = x + y;
        sum -= y;
    }
    sort(&a[1],&a[n+1],[](int x, int y){return x > y;});
    for(int i=1;i<=n;i++) if(i&1) sum += a[i];
    printf("%lld",sum);
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int X;
    cin >> X;
    if(X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

int main()
{
    int t;
    int h,m,s;
    cin>>s;

    h=s/3600;
    m=(s%3600)/60;
    s=s%60;
    cout<<h<<":"<<m<<":"<<s;

    cout<<endl;
}


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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

LL n,a,b,ans,x,y;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>n >>a >>b;
	x=n/(a+b); y=n%(a+b);
	ans=x*a;
	if (y>a) ans+=a;
	else ans+=y;
	cout <<ans<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int a,b;

int main()
{
	cin>>a>>b;
	for(int i=1;i<=3;i++)
		if((a*b*i)&1) return puts("Yes"),0;
	puts("No");
}

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

int main()
{
  string s, t, u;
  cin >> s >> t >> u;
  cout << "A" << t[0] << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] += 'a' - 'A';
    cout << s << endl;
}

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

int main(int argc, char *argv[]) {
  int N,Q; cin>>N>>Q;
  vector<int> a(N-1);
  vector<int> b(N-1);
  vector<int> p(Q);
  vector<int> x(Q);
  for (int i = 0; i < N-1; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < Q; i++) {
    cin >> p[i] >> x[i];
  }


  vector<int> nodes(N,-1);
  for (int i = 0; i < N-1; i++) {
    nodes[b[i]-1] = a[i]-1;
  }

  vector<int> counter(N,0);
  for (int i = 0; i < Q; i++) {
    counter[p[i]-1] += x[i];
  }

  vector<int> memo(N,-1);

  for (int i = 0; i < N; i++) {
    int value = 0;
    value += counter[i];
    int j = i;
    while(true) {
      if (nodes[j] == -1) break;
      j = nodes[j];
      if (memo[j] != -1) {
        value += memo[j];
        break;
      }
      value += counter[j];
    }

    memo[i] = value;
    if (i != N-1)
      cout << value << " ";
    else
      cout << value << endl;
  }

  return 0;
}


Measured memory_bytes: 7936
package main
import "fmt"
// import "sort"

func main()  {
    var N int

    fmt.Scan(&N)

    if N == 1 {
        fmt.Println("Hello World")
    } else {
        var A, B int
        fmt.Scan(&A, &B)
        fmt.Println(A + B)
    }
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a==1){
    a = 14;
  }
  if(b==1){
    b = 14;
  }
  if(a==b){
    cout << "Draw" << endl;
  }else if(a < b){
    cout << "Bob" << endl;
  }else{
    cout << "Alice" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <set>
#include <stack>
#include <list>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

typedef long long ll;
using namespace std;

int main() {
    int max, A, B, res;

    cin >> A >> B;

    max = A+B;
    if(max < (A-B))
        max = A-B;

    if(max < A*B)
        max = A*B;

    cout << max;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
typedef unsigned long long ull;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
vector<vector<int> > AB,A,B;
int Aidx[5],Bidx[5];

unordered_set<ull> S;
ull VtoH(const vector<vector<int> > &v){
  const ull B = 1777771;
  ull res = 0;
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++) res = res * B + (v[i][j]+'0');
  return res;
}

vector<int> rev(vector<int> a){reverse(a.begin(),a.end());return a;}
void mirror(vector<vector<int> > &res){for(int i=0;i<5;i++) res[i] = rev(res[i]);}

vector<vector<int> > rot(const vector<vector<int> > &a){
  vector<vector<int> > res(5,vector<int>(5));
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++) res[i][j] = a[4-j][i];
  return res;
}

void insert(vector<vector<int> > v){
  S.insert(VtoH(v));
  v = rot(v) , v = rot(v), S.insert(VtoH(v));
  mirror(v), S.insert(VtoH(v));
  v = rot(v) , v = rot(v), S.insert(VtoH(v));
}

bool canPut(int idx,int j){
  int a = 1, b = 1;
  for(int i=0;i<5;i++) if(A[i][j] == B[idx][i]) a = 0;
  for(int i=0;i<5;i++) if(A[i][j] == B[idx][4-i]) b = 0;
  return a || b;
}

bool can(){
  int used = 0;
  for(int i=0;i<5;i++){
    for(int nx=0;nx<5;nx++){
      if((used>>nx&1) || !canPut(nx,i)) continue;
      Bidx[i] = nx;
      used |= (1<<nx);
      break;
    }
  }
  return used == (1<<5)-1;
}

int solve(){
  S.clear();
  int res = 0;
  for(int i=0;i<5;i++) Aidx[i] = i;
  for(int bit=0;bit<(1<<10);bit++){
    if(__builtin_popcount(bit) != 5) continue;    
    A.clear();B.clear();
    for(int i=0;i<10;i++) (bit>>i&1)? A.push_back(AB[i]):B.push_back(AB[i]);
    vector<vector<int> > tmp = A;
    do{
      for(int a=0;a<(1<<5);a++){
        for(int i=0;i<5;i++) A[Aidx[i]] = (a>>i&1)? rev(tmp[i]):tmp[i];
        if(S.count(VtoH(A)) || !can()) continue;
        insert(A);
        res++;
      }
    } while(next_permutation(Aidx,Aidx+5));
  }
  return res/2;
}

signed main(){
  while(1){
    AB.clear();
    for(int i=0;i<10;i++){
      string str;
      cin>>str;
      if(str == "END") return 0;
      vector<int> tmp(5);
      for(int j=0;j<5;j++) tmp[j] = str[j] - '0';
      AB.push_back(tmp);
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include <iostream>

using namespace std;

int main()
{
   int a ,b, i;

for(int i=1;i<=3000 ;i++){
    cin >> a >> b;
if (a>b)
{
   a = a+b;
   b = a-b;
   a = a-b;
}
   if (a==0 && b==0)
   break ;
   else
  
   cout << a << " " << b<< endl;
}
}


Measured memory_bytes: 3100
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, C = li_input()

    A = [[0] * 100001 for _ in range(C)]
    S = [0] * 100001

    for i in range(N):
        s, t, c = li_input()

        for j in range(s, t):
            A[c - 1][j] += 1

    for a in A:
        for i in range(1, len(a)):
            if a[i] == 1 or (i != len(a) - 1 and a[i + 1]) == 1:
                S[i] += 1

    print(max(S))


main()


Measured memory_bytes: 30972
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(void){
 
  char S[100],T[100];
 
  scanf("%s", S);
  scanf("%s", T);
 
  int len = strlen(S);
  char top;
  int j=0,flag=0;
 
  for(int i=0; i<len; i++){
    j = 0;
    flag = 0;
    while(j<len && flag==0){
      if(S[(j+i)%len]!=T[j]){
        flag++;
      }
      j++;
    }
    if(flag==0){
      printf("Yes\n");
      return 0;
    }
  }
 
  printf("No\n");
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;
ll limit = 1000000000000000000;

int main(){
fast;
int n;
cin>>n;
ll mul=1;
ll ans = 2;
for(int i=0;i<n;i++) {
    ll x;
    cin>>x;
    if(mul==0)
    {
        continue;
    }

    if(x==0) {
        ans = 0;
        mul=0;
    }
    else if(x > limit/mul and ans!=0) {
        ans = -1;
    } else {
        mul = mul*x;
    }
}

if(ans == -1) {
    cout<<ans<<endl;
    return 0;
}

cout<<mul<<endl;
return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int CR=0,CL=0;
    int CE=0,CO=0;
    vector<int> vt,vv;
    for(int i=0;i<S.length();i++){
        if((S[i]=='R'&&CR>0)||i==S.length()-1){
            vv.push_back(CE);
            vv.push_back(CO);
          //cout<<CE<<" "<<CO<<" ";
            CR=0,CL=0;
            CE=0;CO=0;
        }
        if(i%2==0){
            CE++;
            if(i==S.length()-2){
                CO++;
            }
        }else{
            CO++;
            if(i==S.length()-2){
                CE++;
            }
        }
        if(S[i]=='L'){
            CR++;
        }
        if(CL==0&&S[i]=='L'){
            CL++;
            vt.push_back(i-1);
            vt.push_back(i);
        }
    }
    int x=0;
    vector<int> ans(S.length(),0);
  /*for(int i=0;i<S.length();i++){
  	cout<<ans[i]<<" ";
  }*/
    for(int i=0;i<S.length();i++){
      if(x<vv.size()){
        if(i==vt[x]){
            if(i%2==0){
                ans[i]=vv[x];
                ans[i+1]=vv[x+1];
             // cout<<ans[i]<<" ";
              //cout<<ans[i+1]<<" ";
                //ans.push_back(vv[j]);
                //ans.push_back(vv[j+1]);
            }else{
                ans[i]=vv[x+1];
                ans[i+1]=vv[x];
             // cout<<ans[i]<<" "<<ans[i+1]<<" ";  
                //ans.push_back(vv[j+1]);
                //ans.push_back(vv[j]);
            }
            //cout<<i<<vv[j]<<vv[j+1]<<endl;
            x+=2;
            i+=1;
            /*cout<<i<<vv[j]<<vv[j+1]<<endl;
            j+=2;
            i++;*/
        }else{
          //cout<<0<<" ";
        }
    }
    }
   for(int i=0;i<S.length();i++){
        cout<<ans[i]<<" ";
    }
    return 0;
}

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

s = [1] * n
#st[b[i]] - st[a[i]]  = c[i]
num = n-1
#ans1 = [0] * 10000000
ans = 0
pre_ans = 0
t = 0

while(s[0] != m ):

    for i in range(q):
        if s[b[i]-1] - s[a[i]-1]  == c[i]:
            ans += d[i]
    #print(s)
    #print(ans)
    ans = max(pre_ans,ans)
    pre_ans = ans
    #t += 1

    ans = 0

    if s[num] < m:
        s[num] += 1
    elif num > 0 :
        num -= 1
        temp = s[num]+1
        if temp < m:
            for i in range(num,n):
                s[i] = temp
        else:
            while(s[num] == m):
                num -= 1
            temp = s[num]+1
            for i in range(num,n):
                s[i] = temp

        num = n-1

for i in range(q):
    if s[b[i]-1] - s[a[i]-1]  == c[i]:
        ans += d[i]

ans = max(pre_ans,ans)

print(ans)


Measured memory_bytes: 9292
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <string>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
vector <long long> A;
vector <long long> B;
int N;
int M = 30;
int main(void) {
	long long ans = 0;
	long long T = 1;
	cin >> N;
	rep(i, N) { 
		long long p;
        scanf("%d ",&p);
		A.push_back(p);
	}
	rep(i, N) { 
		long long p;
		cin >> p;
		B.push_back(p);
	}
	rep(k, M) {
		vector <long long> C;
		vector <long long> D;
		rep(i, N) { 
			C.push_back(B[i] % (2 * T));
			D.push_back(A[i] % (2 * T));
		}
		sort(C.begin(),C.end());
		long long tmp = 0;
		rep(i, N) {
			tmp += lower_bound(C.begin(), C.end(), 2 * T - D[i]) - C.begin();
			tmp -= lower_bound(C.begin(), C.end(), 1 * T - D[i]) - C.begin();
			tmp += lower_bound(C.begin(), C.end(), 4 * T - D[i]) - C.begin();
			tmp -= lower_bound(C.begin(), C.end(), 3 * T - D[i]) - C.begin();
		}
		ans += T * (tmp % 2);
		T = T * 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9204
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LS()
    if a[-1] == b[0] and b[-1] == c[0]:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
S = input()
N = len(S)
l = []
for i in range(N):
  for j in range(i,N):
    s = S[i:j+1]
    if s.strip("A C G T") == "":
      l.append(s)
if len(l) == 0:
  print(0)
  exit()
      
m = sorted(l, reverse=True, key=len)
print(len(m[0]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n,sum=0,tempsum=0;
  cin>>n;
  vector<ll>v1(n);
  for(ll i=0;i<n;i++){
    cin>>v1[i];
    sum+=v1[i];
    if(i%2==1){
      tempsum+=v1[i]*2;
    }
  }
  ll x1=sum-tempsum;
  cout<<x1<<" ";
  for(ll j=0;j<n-1;j++){
    ll y=v1[j]*2-x1;
    x1=y;
    cout<<x1<<" ";
  }
  
}
       
        
      
  
    

Measured memory_bytes: 4040
#!/usr/bin/env python3
import sys


def solve(H: "List[int]", M: "List[int]", K: int):
    assert H[0] <= H[1]
    t1 = 60 * H[0] + M[0]
    t2 = 60 * H[1] + M[1]
    # 制約がよくわからない
    return max(0, t2 - t1 - K)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = [int()] * (2)  # type: "List[int]"
    M = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  # type: int
    print(solve(H, M, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9220
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=25;
int a[N],b[N],n,m,c,res,now;
int main(){
    n=read(),m=read(),c=read();
    fp(i,1,m)b[i]=read();
    fp(i,1,n){
        now=c;
        fp(j,1,m)a[j]=read(),now+=a[j]*b[j];
        res+=(now>0);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;
    bool ok1=false,ok2=false,ok3=false;
    rep(i,n){
        int a,b; cin >> a >> b;
        if(a==b){
            if(!ok1){
                ok1=true;
            }else if(!ok2){
                ok2=true;
            }else{
                ok3=true;
            }
        }else{
            ok1=false;
            ok2=false;
        }
    }
    if(ok3) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 3648