akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

long a,b,c,d;

// upper以下のnの倍数の数を返す
long count(long upper, long n){
    return upper / n;
}

// 最大公約数を求める
long gcd(long x, long y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

int main(){
    cin >> a >> b >> c >> d;

    // a未満の倍数の数
    long underACnt = count(a-1, c) + count(a-1, d) - count(a-1, c*d/gcd(c,d));

    // b以下の倍数の数
    long underBCnt = count(b, c) + count(b, d) - count(b, c*d/gcd(c,d));

    // a以上b以下の倍数の数
    long betweenCnt = underBCnt - underACnt;

    // 答え
    cout << (b - a + 1) - betweenCnt << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    tmd = collections.defaultdict(list)
    tmdc = collections.defaultdict(int)
    for i in range(n-1):
        tma, tmb, tmc = list(map(int, input().rstrip('\n').split()))
        tmd[tma-1] += [tmb-1]
        tmd[tmb-1] += [tma-1]
        tmdc[tma-1, tmb-1] = tmc
        tmdc[tmb-1, tma-1] = tmc

    q, k = list(map(int, input().rstrip('\n').split()))
    ql = [[0, k-1]]
    ql = collections.deque(ql)
    fq = collections.defaultdict(int)
    fq[k-1]
    while True:
        if len(ql) != 0:
            cost, tmp = ql.popleft()
            for tmv in tmd[tmp]:
                if tmv not in fq or cost + tmdc[tmp, tmv] < fq[tmv]:
                    ql.append([cost + tmdc[tmp, tmv], tmv])
                    fq[tmv] = cost + tmdc[tmp, tmv]
        else:
            break
    for i in range(q):
        x, y = list(map(int, input().rstrip('\n').split()))
        print(fq[x-1] + fq[y-1])


if __name__ == '__main__':
    solve()


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

int main(){
    ll H, W;
    cin >> H >> W;
    vector<vector<char>> table(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char mark;
            cin >> mark;
            table.at(i).at(j) = mark;
        }
    }
    
    for(int i = 0; i < H; i++){
        ll countW = 0;
        for(int j = 0; j < W; j++){
            if(table.at(i).at(j) == '.'){
                countW++;
            }
        }
        if(countW == W){
            for(int k = 0; k < W; k++) table.at(i).at(k) = '!';
        }
    }
    
    for(int i = 0; i < W; i++){
        ll countH = 0;
        for(int j = 0; j < H; j++){
            if(table.at(j).at(i) == '.' || table.at(j).at(i) == '!'){
                countH++;
            }
        }
        if(countH == H){
            for(int k = 0; k < H; k++) table.at(k).at(i) = '!';
        }
    }

    for(int i = 0; i < H; i++){
        bool returnFlag = false;
        for( int j = 0; j < W; j++){
            if(table.at(i).at(j) != '!'){
                cout << table.at(i).at(j);
                returnFlag = true;
            }
        }
        if(returnFlag == true) cout << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		int n = in.nextInt();
		int m= in.nextInt();
		int [] a= new int[n];
		for(int i=0; i<m; i++){
			int b= in.nextInt()-1;
			int c= in.nextInt()-1;
			a[b]++;
			a[c]++;
		}
		for (int i = 0; i < a.length; i++) {
			System.out.println(a[i]);
		}
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
    IOS;

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    lln ans = 0;
    for(int i=1;i<n;i++){
        if(a[i] < a[i-1]){
            ans = ans + a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 3880
n, x, y = map(int, input().split())
count_dist = [0]*(n+1)
for i in range(1, n):
  for j in range(i+1, n+1):
    dist = min(j-i, abs(x-i)+1+abs(y-j), abs(x-j)+1+abs(y-i))
    count_dist[dist] += 1

for k in range(1, n):
  print(count_dist[k])


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

using namespace std;

int main()
{
    int x,a,b,c,i,j,k;
    cin>>a>>b>>c>>x;
    long cnt=0;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(k=0;k<=c;k++)
            {
                if((500*i+100*j+50*k)==x)
                    cnt++;
            }
        }
    }
    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<int> L;
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;

        int ligft = 0;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            s--;
            ligft = ligft | (1 << s);
        }

        L.push_back(ligft);
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = (1 << n) - 1; i >= 0; i--) {
        bool isall = true;
        for (int j = 0; j < m; j++) {
            if (__builtin_popcount(i & L[j]) % 2 != p[j]) {
                isall = false;
                break;
            }
        }

        if (isall) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans;
        int ansTmp;
        if(N % 1000 == 0) {
        	ans = N % 1000;
        }else {
        	ansTmp = N % 1000;
        	ans = 1000 - ansTmp;
        }
      		// 文字列の入力
		System.out.println(ans);
	}
}

Measured memory_bytes: 27080
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
const int MOD=1000000007;

int main() {
  int64_t N;
  cin>>N;
  vector<int>a(N+1);
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }

  vector<int>ans(N+1);
  int tot=0;
  for(int64_t i=N;i>=1;i--){
    int cnt=0;
    for(int64_t j=2;j<=N/i;j++){
      if(i*j<=N){cnt+=ans[i*j];}
    }
    if(cnt%2!=a[i]){ans[i]++;tot++;}
  }

  cout<<tot<<endl;
  if(tot==0){return 0;}
  for(int i=1;i<=N;i++){
    if(ans[i]>0){cout<<i;
    if(i<N){cout<<" ";}
    }
    //if(i<=N-1){cout<<" ";}
  }cout<<endl;
  return 0;
}

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

typedef unsigned int L;
int main(){
	for(L n; cin>>n && n;){
		vector<L> v(n);
		for(L i=0; i<n; i++) cin>>v[i];
		sort(v.begin(),v.end());
		L ans=0;
		for(L i=0; i<n; i++) ans += v[i]*(n-i-1);
		cout<<ans<<endl;
	}
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[111];
int K;

LL dpE[111][5], dpL[111][5];

void MAIN() {
    scanf("%s%d", S, &K);
    N = strlen(S);

    REP (i, N) {
	int C = S[i] - '0';
	if (i == 0) {
	    for (int d=1; d<C; d++) dpL[1][1] += 1;
	    dpE[1][1] += 1;
	} else {
	    for (int d=1; d<10; d++){dpL[i+1][1] += 1;}

	    REP (k, K+1) {
		dpE[i+1][k + (C==0?0:1)] += dpE[i][k];

		REP (d, C) {dpL[i+1][k + (d==0?0:1)] += dpE[i][k];}
		REP (d, 10) {dpL[i+1][k + (d==0?0:1)] += dpL[i][k];}
		}
	}
    }
//    for(int i=1;i<=N;i++){
//    	for(int j=1;j<=K;j++){
//    		cout<<i<<" "<<" "<<j<<" "<<dpL[i][j]<<" "<<dpE[i][j]<<endl;
//		}
//	} 

    LL ans = 0;
    ans += dpE[N][K];
    ans += dpL[N][K];
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
} 

Measured memory_bytes: 256
// do the game in reverse order
// you start with a certain amount (minimize this amount)
// pick any vertex
// do these operations as many times as possible
// 1. get the donation money, and check if there is enough money for this node
// 2. check if there is enough money for this node, then move to an adjacent node
// note: you can only get the donation money for one node at most once

// binary search + disjoint set is possible?
// order the edges by the amount needed to traverse this edge

#include <stdio.h>
#include <vector>
#include <queue>
#include <string.h>

int t1,t2;

int n,m;

std::vector<int> g[100005];

int a[100005];
int b[100005];

// disjoint set stuff
std::vector<int> todo;
bool todo2[100005];     // determine if a vertex is in todo

std::priority_queue<std::pair<int,int> > pq[100005];
int endval;
int up[100005];
int sz[100005];
long long money[100005];
bool active[100005];

int getroot(int u)
{
    if (u==up[u]) return u;
    return up[u]=getroot(up[u]);
}

void join2(int u,int v)
{
    up[v]=u;
    sz[u]+=sz[v];
    money[u]+=money[v]-endval;
    active[u]=1;
    while (!pq[v].empty()) {
        pq[u].push(pq[v].top());
        pq[v].pop();
    }
}

int join(int u,int v)
{
    // return the root of their union
    u=getroot(u);
    v=getroot(v);
    if (u==v) return u;
    if (sz[u]>=sz[v]) {
        join2(u,v);
        return u;
    }
    else {
        join2(v,u);
        return v;
    }
}

bool good(int x)
{
    endval=x;
    memset(active,0,sizeof active);
    // make the pq
    for (int i=1; i<=n; i++) {
        up[i]=i;
        sz[i]=1;
        money[i]=x+b[i];
        if (money[i]>=a[i]) active[i]=1;
        while (!pq[i].empty()) pq[i].pop();
        for (int j:g[i]) pq[i].push({b[j]-a[j],j});
    }
    // do vertices
    for (int i=1; i<=n; i++) {
        int u=getroot(i);
        if (!active[u]) continue;
        //printf("start at %d\n",i);
        // do this vertex
        while (!pq[u].empty() && -pq[u].top().first<=money[u]) {
            int v=pq[u].top().second;
            pq[u].pop();
            //printf("do %d -> %d\n",u,v);
            u=join(u,v);
        }
    }
    // check
    for (int i=2; i<=n; i++) {
        if (getroot(1)!=getroot(i)) return 0;
    }
    return 1;
}

int lo=0;
int hi=0x3f3f3f3f;
int mid;

long long ans;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d",&n,&m);
    for (int i=1; i<=n; i++) scanf("%d%d",a+i,b+i);
    for (int i=0; i<m; i++) {
        scanf("%d%d",&t1,&t2);
        g[t1].push_back(t2);
        g[t2].push_back(t1);
    }
    if (n==1) {
        if (a[1]>b[1]) printf("%d\n",a[1]);
        else printf("%d\n",b[1]);
        return 0;
    }
    //good(0); return 0;
    while (lo<hi) {
        mid=(lo+hi)/2;
        if (good(mid)) hi=mid;
        else lo=mid+1;
        //printf("%d %d\n",lo,hi);
    }
    ans=lo;
    for (int i=1; i<=n; i++) ans+=b[i];
    printf("%lld\n",ans);
}


Measured memory_bytes: 17152
N,C,K = map(int,input().split())

T = []

for i in range(N):
    T.append(int(input()))
T.sort()
res = 0
cnt = 0
i = 0

while i < N:
    lim = T[i]+K
    while T[i] <= lim and cnt < C:
        i += 1
        cnt += 1
        if N == i:
            break
    res += 1
    cnt = 0
print(res)

Measured memory_bytes: 13384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=1000001;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-((M/i)*inv[M%i])%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll COMBI(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M*finv[K]%M;
}

ll PERMU(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M;
}

int main() {
    COMinit(MOD);
    ll N,K;
    cin >> N >> K;
    if(K>=N-1){
        cout << COMBI(2*N-1,N-1,MOD) << endl;
    }
    else{
        ll ans=0;
        rep(i,K+1){
            ans+=COMBI(N,i,MOD)*COMBI(N-1,N-i-1,MOD)%MOD;
            ans%=MOD;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 27052
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 1e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll dp[N][3];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

	// cin >> tc;
	while (tc--) {

		ll n, i, j, a, b, c, k, w, h;

		cin >> n;

		cin >> a >> b >> c;

		dp[0][0] = a, dp[0][1] = b, dp[0][2] = c;
		i = 0;
		// cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;


		for (i = 1; i < n; i++) {
			cin >> a >> b >> c;

			dp[i][0] =  max(dp[i - 1][1] , dp[i - 1][2]) + a;
			dp[i][1] =  max(dp[i - 1][0], dp[i - 1][2]) + b;
			dp[i][2] =  max(dp[i - 1][1], dp[i - 1][0]) + c;

			// cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
		}


		ll ans = max(dp[n - 1][0], dp[n - 1][1]);
		ans = max(ans, dp[n - 1][2]);

		cout << ans << endl;

	}

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	ll A,B,C;
	A=B=C=0;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x<=a){
			A++;
		}
		else if(x>=b+1){
			C++;
		}
		else{
			B++;
		}
	}
	cout << min({A,B,C});
	// your code goes here
	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, a, b) for(int i = (a); i < (b); i++)
typedef long long ll;

int main() {
   vector<int> a(3);
   rep(i, 3) {
       cin >> a[i];
   }

   sort(a.begin(), a.end());

   cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,s,e)for(int i=s;i<=e;i++)
#define out(a)cout << a << endl;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a/b << " " << a%b << " ";
    printf("%.8f\n", (double) a/b);
    return 0;
}


Measured memory_bytes: 3224
fun main(args: Array<String>) {
    var (N, W) = pairIntLong()
    val WV = Array(N) { pairIntLong() }
    val WVs = Array(4) { mutableListOf<Long>() }
    val baseW = WV[0].first.toLong()
    WV.forEach { wv -> WVs[wv.first - WV[0].first].add(wv.second) }
    WVs.forEach {
        val w = it.sorted().toList()
        it.clear(); it.add(0L)
        for (n in w.indices.reversed()) it.add(w.subList(n, w.size).sum())
    }
    var ans = 0L
    for (n0 in (0 until WVs[0].size).reversed()) {
        val w0 = (baseW + 0) * n0
        for (n1 in (0 until WVs[1].size).reversed()) {
            val w1 = (baseW + 1) * n1
            for (n2 in (0 until WVs[2].size).reversed()) {
                val w2 = (baseW + 2) * n2
                for (n3 in (0 until WVs[3].size).reversed()) {
                    val w3 = (baseW + 3) * n3
                    if (w0 + w1 + w2 + w3 > W) continue
                    ans = Math.max(ans, WVs[0][n0] + WVs[1][n1] + WVs[2][n2] + WVs[3][n3])
                }
            }
        }
    }
    println(ans)
}
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 39224
x, k, d = [int(z) for z in input().strip().split()]
step = int(abs(x) / d)
# print(step)
if step > k:
    if x > 0:
        print(abs(x - k * d))
    else:
        print(abs(x + k * d))
else:
    if step % 2 == k % 2:
        if x > 0:
            print(abs(x - step * d))
        else:
            print(abs(x + step * d))
    else:
        if x > 0:
            print(abs(x - step * d - d))
        else:
            print(abs(x + step * d + d))


Measured memory_bytes: 9192
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	string s;
	cin >> s;
	cout << string(sz(s), 'x');
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]='a'+(s[k-1]-'A');
    cout << s<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
 
int main()
{
  char ch;
  while(true){
    scanf("%c",&ch); //scanf???' '???????????????
    if(ch=='\n') break;
    if(islower(ch)!=0){ //?°???????????????°true
      ch=toupper(ch); //?°?????????? ??§??????
      cout << ch;
    }else if(isupper(ch)!=0){ //??§??????????????°true
      ch=tolower(ch); //??§????????? ?°???????
      cout << ch;
    }else{
      cout << ch;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  int ans = 1;
  for(int i = 1; ans <= n; i++){
    ans = pow(2,i);
  }
  ans /= 2;
  cout << ans << endl; 
}


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

ll gcd(ll a, ll b){
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

int main(){

    ll k; cin >> k;

    ll sum = 0;
    rep(a, k){
        rep(b, k){
            rep(c, k){
                sum += gcd(gcd(a+1, b+1), c+1);
            }
        }
    }

    cout << sum << endl;

    return 0;
}

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

int main(void){
        char s[1000000];
        scanf("%s", s);
        for (int i = 0; i < strlen(s); i++) {
                if (s[i]=='9') {
                        printf("Yes\n");
                        return 0;
                }
        }
        printf("No\n");
        return 0;
}

Measured memory_bytes: 128
import collections
N = int(input())
A = list(map(int, input().split()))
cntA = collections.Counter(A)

ans = 0
eve = 0
for i in cntA.items():
    if i[1] % 2 == 0:
        eve += 1
    ans += 1
if eve % 2 == 0:
    print(ans)
else:
    print(ans-1)


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,m;
	cin >> n >> m;
	vector<vector<int>> ta1(n,vector<int>(m)),ta2(n,vector<int>(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> ta1[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> ta2[i][j];
			ta1[i][j]-=ta2[i][j];
		}
	}
	vector<vector<vector<bool>>> dp(n,vector<vector<bool>>(m,vector<bool>(12800)));
	dp[0][0][abs(ta1[0][0])+6400]=true;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int px=i-1,py=j;
			if(px>=0){
				for(int k=0;k<12800;k++){
					int v=abs(ta1[i][j]);
					if((k-v)>=0){
						if(dp[px][py][k-v]) dp[i][j][k]=true;
					}
					if((k+v)<12800){
						if(dp[px][py][k+v]) dp[i][j][k]=true;
					}
				}
			}
			px=i,py=j-1;
			if(py>=0){
				for(int k=0;k<12800;k++){
					int v=abs(ta1[i][j]);
					if((k-v)>=0){
						if(dp[px][py][k-v]) dp[i][j][k]=true;
					}
					if((k+v)<12800){
						if(dp[px][py][k+v]) dp[i][j][k]=true;
					}
				}
			}
		}
	}
	int res=1<<29;
	for(int i=0;i<12800;i++){
		if(dp[n-1][m-1][i]){
			res=min(res,abs(6400-i));
		}
	}
	cout << res << "\n";
	return 0;
}

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

class BinaryIndexedTree
{
private:
    std::vector<int> vals;
    int n;
public:
    BinaryIndexedTree(int n_)
        : vals(n_, 0), n(n_) { }

    void add(int a, int w)
    {
        for (int x = a; x <= n; x += x & -x) {
            vals[x - 1] += w;
        }
    }

    int sum(int a) const
    {
        int ret = 0;
        for (int x = a; x > 0; x -= x & -x) {
            ret += vals[x - 1];
        }
        return ret;
    }
};

class SnLine
{
private:
    struct ProdRange
    {
        ProdRange() { l = r = 0; }
        ProdRange(int l_, int r_) { l = l_; r = r_; }
        int l, r;
    };

    static ProdRange makeProdRange(int l, int r)
    {
        return ProdRange { l, r };
    }

    std::vector<ProdRange> prList;

    int numProds;
    int numStops;

public:
    SnLine(int numStops_, int numProds_)
    {
        numStops = numStops_;
        numProds = numProds_;
        prList.reserve(numProds);
    }

    void addProdRange(int l, int r)
    {
        prList.emplace_back(l, r);
    }

    void solve()
    {
        std::sort(prList.begin(), prList.end(),
            [](const auto& a, const auto& b)
            { return ((a.r - a.l) < (b.r - b.l)); });

        BinaryIndexedTree bit(numStops);

        int numRemainingProds = numProds;
        auto pr = prList.begin();

        for (int d = 1; d <= numStops; ++d)
        {
            int r = numRemainingProds;

            if (1 < d)
            {
                for (int a = d; a <= numStops; a += d)
                {
                    r += bit.sum(a);
                }
            }

            std::cout << r << "\n";

            for(; pr != prList.end() && (d == pr->r - pr->l + 1); ++pr)
            {
                bit.add(pr->l, 1);
                bit.add(pr->r + 1, -1);
                --numRemainingProds;
            }
        }
    }
};

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

    int N, M;
    std::cin >> N >> M;

    SnLine sl(M, N);

    for (int i = 0; i < N; ++i)
    {
        int l, r;
        std::cin >> l >> r;

        sl.addProdRange(l, r);
    }

    sl.solve();
    return 0;
}


Measured memory_bytes: 3712
S = input()

ans=0
num = [int(i) for i in S]
num.reverse()

def judge(keta):
    if keta >= len(S):
        return true
    tmp = num[keta]
    if tmp < 5:
        return false
    elif tmp > 5:
        num[keta] = 10 - num[keta]
        num[keta+1] += 1
        return true
    else:
        if judge(keta):
            pass
        
for i in range(len(S)-1):
    tmp = num[i]
    if tmp < 5:
        pass
    elif tmp > 5:
        num[i] = 10-num[i]
        num[i+1] +=1
    else:
        if num[i+1] >= 5:
            num[i] = 10-num[i]
            num[i+1] +=1
        else:
            pass

last = len(S)-1
ans = 0
if num[last] > 5:
    num[last] = 10 - num[last]
    ans =1
print(sum(num)+ans)
            



Measured memory_bytes: 13636
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    ll x = n%k;
    cout << min(x, abs(k-x)) << '\n';
    return 0;
}

Measured memory_bytes: 256
z[4000],*a=z,*b=z+2000,m,i,j;main(n){for(;scanf("%d",&n),i=n;printf("%d\n",m))for(memset(a,m=0,8e3);i--;j=a,a=b,b=j)for(j=0;j++<=n;)m=fmax(m,b[j]=getchar()-42&&j-1?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);}

Measured memory_bytes: 0
#include <iostream>
#include <unordered_map>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define PAIR(x, y) make_pair(x, y)
using namespace std;

const int MOD = 998244353;

long long int gcd(long long int a, long long int b){
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

long long int congruence(long long int a, long long int b, long long int m)
{
    long long int c, d, e, f;
    long long int q, r;
    long long int tmp;
    
    if (m == 0) return -1;
    
    c = a;
    e = b;
    d = m;
    f = 0;
    while ((r = c % d) != 0) {
        q = c / d;
        c = d;
        d = r;
        tmp = f;
        f = e - q * f;
        e = tmp;
    }
    if (b % d != 0) return -1;
    q = (f/d) % (m/d);
    if (q < 0) q += m/d;
    return q;
}

    
int main(void){
    
    long long int n, a, b, k;
    cin >> n >> a >> b >> k;
    
    // ax + by = k なる (x, y) \in \mathbb N で、x が最小のものを見つける
    // 解がなければ 0
    long long int d = gcd(a, b);
    if(k % d != 0){
        cout << 0 << "\n";
        return 0;
    }
    a /= d; b /= d; k /= d;
    
    long long int x = 0, y;
    while(1){
        if((k - a*x) % b == 0 && (k - a*x) / b <= n) break;
        x ++;
    }

    
    // 全整数解について nCx * nCy を計算して和を取る
    long long int nC[1000000];
    nC[0] = 1;
    for(long long int i = 0; i < n; i ++){
        nC[i+1] = congruence(i+1, (nC[i] * (n-i)) % MOD, MOD);
    }
    
    long long int sum = 0;
    for(x; x <= n; x += b){
        y = (k - a*x) / b;
        if(y < 0) break;
        (sum += (nC[x] * nC[y]) % MOD) %= MOD;
    }
    
    cout << sum << "\n";
}


Measured memory_bytes: 4352
// B - Not Found
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string S; cin>>S;
	int n = 'z'-'a';
	vector<bool> A(n+1, false);
	rp(i, 0, S.size()) A[S[i]-'a'] = true;
	rp(i, 0, A.size()){
		if(!A[i]){
			printf("%c\n", i+'a');
			return 0;
		}
	}
	puts("None");
}

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

#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--)

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

int main(void) {
    int a, b, k;
    cin >>a >>b >>k;
    FOR(i,a,b+1){
        if(a+k>i || b-k<i){
            cout << i << endl;
        }
    }
    return 0;
}


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

using namespace std;
using ll=long long;

template <typename T=int>
struct Segtree {
    int n; // leaf [n, 2n), view as original [0, n)
    int sz_v;
    const T ID;
    vector<T> v; //tree
    
    Segtree(int _n = 100005) : n(_n), sz_v(n<<1), ID() {
        v.assign(sz_v, ID);
    }
    void init() {// set leaf value
        for (int i = 0; i < n; i++) {
            // v[i+n] = raw[i];
        }
        build();
    }
    void build() {
        for (int i = n-1; i > 0; i--) {
            v[i] = v[i<<1] + v[i<<1|1];
        }
    }
    inline void update(int p, T val) {
        assert(p>=0);
        for (v[p += n] += val; p >>= 1;) { // change to  min upd
            v[p] = v[p<<1] + v[p<<1|1];
        }
    }
    inline T query(int l, int r) {
        T resl(ID), resr(ID);
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) { resl = resl + v[l++]; }
            if (r & 1) { resr = v[--r] + resr; }
        }
        return resl + resr;
    }
    // Note only when range-assign, single-access not interfere. e.g max
    //inline void update(int l, int r, T val) {
    //    for (l += n, r += n; l < r; l >>= 1, r >>= 1){
    //        if (l & 1) { v[l++] = val; }
    //        if (r & 1) { v[--r] = val; }
    //    }
    //}
    //inline T query(int p){
    //    T res(ID);
    //    for (p += n; p > 0; p >>= 1) { res += v[p]; }
    //    return res;
    //}
};

struct Node {// monoid
    ll x;
    Node() : x(0x3f3f3f3f3f3f3f3f) {} // DO!! identity
    Node(ll _x) : x(_x) {}
    Node(const Node& _r) : x(_r.x) {}// DO!! set
    Node& operator = (const Node& _r) {// DO!! set
        x = _r.x;
        return *this;
    }
    Node& operator += (const Node& _r) {// DO!! may not communitative
        x = min(x, _r.x);
        return *this;
    }
    friend Node operator + (const Node& _lhs, const Node& _rhs) {
        return Node(_lhs) += _rhs; // derive from +=
    }
};

typedef Segtree<Node> Seg;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int,int>>> g(n+1);
    for (int _ = 0; _ < m; _++) {
        int l,r,c;
        cin >> l >> r >> c;
        g[r].emplace_back(l,c);
    }
    Seg s(n+1);
    s.update(1, Node(0));
    //cout << s.query(1, 2).x << "\n";
    for (int r = 2; r <= n; r++) {
        for (auto& p: g[r]) {
            int l,c;
            tie(l,c) = p;
            auto mi = s.query(l, r);
            mi.x += c;
            //cout << mi.x << "\n";
            s.update(r, mi);
        }
    }
    ll res = s.query(n, n+1).x;
    if (res > 1e16) res = -1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 7168
#include <iostream>
using namespace std;
int main(void){
   int A,B,C;
   cin>>A>>B>>C;
   if(A==B & A!=C){
       cout<<"Yes"<<endl;
   }
   else if(B==C & A!=C){
       cout<<"Yes"<<endl;
   }
   else if(C==A & A!=B){
       cout<<"Yes"<<endl;
   }
   else {
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
# coding: utf-8
import sys
from math import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K = ir()
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            answer += gcd(a, gcd(b, c))

print(answer)


Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a;
vector<lli> sum;
vector<vector<lli>> dp;
int main() {
  cin >> n; read_n(a, n);
  init_n(sum, n+1);
  sum[0] = 0;
  for (lli i=1; i<=n; ++i) sum[i] = sum[i-1] + a[i-1];
  init_n(dp, n, vector<lli>(n, 1e15));
  for (lli i=0; i<n; ++i) dp[i][i] = 0;
  for (lli d=1; d<n; ++d) {
    for (lli l=0; l<n-d; ++l) {
      lli r = l + d;
      lli s = sum[r+1] - sum[l];
      for (lli k=l+1; k<=r; ++k) {
	dp[l][r] = min(dp[l][r], dp[l][k-1] + dp[k][r] + s);
      }
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String date = sc.nextLine();
		String[] dateParts = date.split("/");
		String dateStr = "";
		for(String part: dateParts){
			dateStr += part;
		}
		int date2Int = Integer.parseInt(dateStr);
		if(date2Int <= 20190430){
			System.out.println("Heisei");
		}else{
			System.out.println("TBD");
		}
		
	}


}

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

int main() {
  unsigned long long int n, a, b;
  cin >> n >> a >> b;
  unsigned long long int sum = n / (a + b) * a;
  if(n % (a + b) < a) cout << sum + n%(a+b) << endl;
  else cout << sum + a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
       	final int R = sc.nextInt();
        final int C = sc.nextInt();
        final int K = sc.nextInt();
        
        final int[][] Val = new int[R][C];
        for (int k = 0; k < K; k++) {
            int r = sc.nextInt() - 1;
            int c = sc.nextInt() - 1;
            int v = sc.nextInt();
            Val[r][c] = v;
        }
  	long[][][] data = new long[R][C][4];
  	//00
      {
  int v = Val[0][0];
  if(v>0)
    data[0][0][1]=v;
      }
  
  //left
  for(int i=1;i<R;i++){
  	data[i][0][0]=Long.max(data[i-1][0][0],data[i-1][0][1]);
    int v = Val[i][0];
    if(v>0){
   	data[i][0][1]=data[i][0][0]+v;
    }
    }
    
    //up
    for(int j=1;j<C;j++){
    	int v = Val[0][j];
      	if(0<v){
        data[0][j][0]=data[0][j-1][0];
          for(int p=1;p<4;p++){
          data[0][j][p]=Long.max(data[0][j-1][p],data[0][j-1][p-1]+v);
          }
          
        }else{
        data[0][j]=data[0][j-1];
        }
    
    }
    
    //DP
    
    for(int i=1;i<R;i++){
    	for(int j=1;j<C;j++){
        	int v = Val[i][j];
          	long maxUp = maxFrom4(data[i-1][j]);
          	if(0<v){
            	data[i][j][0]=Long.max(data[i][j-1][0],maxUp);
              	data[i][j][1]=maxFrom3(data[i][j-1][1],data[i][j-1][0]+v,maxUp+v);
              	data[i][j][2]=Long.max(data[i][j-1][2],data[i][j-1][1]+v);
              	data[i][j][3]=Long.max(data[i][j-1][3],data[i][j-1][2]+v);
            } else if (data[i][j - 1][0] < maxUp) {
                    data[i][j][0] = maxUp;
                    data[i][j][1] = data[i][j - 1][1];
                    data[i][j][2] = data[i][j - 1][2];
                    data[i][j][3] = data[i][j - 1][3];
                } else {
                    data[i][j] = data[i][j - 1];
                }
          	
        }
    }
      System.out.println(maxFrom4(data[R - 1][C - 1]));
  
  }
		static long maxFrom3(long val1, long val2, long val3) {
        return Long.max(Long.max(val1, val2), val3);
    }
    
    	static long maxFrom4(long[] vals) {
        return Long.max(Long.max(vals[0], vals[1]), Long.max(vals[2], vals[3]));
    }
}


Measured memory_bytes: 702496
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    print("ABC" if input().strip() == "ARC" else "ARC")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9628
from collections import deque
from sys import exit, stdin

S = deque(stdin.readline().rstrip())
Q = int(stdin.readline().rstrip())
query = [stdin.readline().rstrip().split() for _ in range(Q)]
front = 0

for q in query:
    if q[0] == '1':
        if front == 0:
            front = -1
        elif front == -1:
            front = 0
    elif q[0] == '2':
        if q[1] == '1':
            if front == 0:
                S.appendleft(q[2])
            elif front == -1:
                S.append(q[2])
        elif q[1] == '2':
            if front == 0:
                S.append(q[2])
            elif front == -1:
                S.appendleft(q[2])
if front == 0:
    print(''.join(S))
elif front == -1:
    S.reverse()
    print(''.join(S))

Measured memory_bytes: 44524
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;

signed main() {
  assert(1);
	string s; cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val ans = if (canComplete()) "Yes" else "No"
    println(ans)
}

data class Work(val require:Int, val limit:Int)

fun canComplete():Boolean {
    val workCount = readLine()!!.toInt()
    var works = Array<Work>(workCount, {Work(0,0)})
    (0..workCount-1).forEach{
        val (a,b) = readLine()!!.split(" ").map { it.toInt() }
        works[it] = Work(a, b)
    }
    works = works.sortedBy { it.limit }.toTypedArray()
    var now = 0
    works.forEach {
        now = now + it.require
        if(now > it.limit) {
            return false
        }
    }
    return true
}

Measured memory_bytes: 127816
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if ((i + 1) % 2 == 1 && a % 2 == 1) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define MOD	((int)1e5)

int main(void)
{
	int dp[64][3001];
	int n, m, s;
	int i, j, k;

	// n : 1 ~ 7 
	// m : 1 ~ 2000
	// s : 1 ~ 3000
	while (scanf("%d %d %d", &n, &m, &s), n + m + s){
		n *= n;
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for (i = 1; i <= m; i++){
			for (j = s; j > 0; j--){
				for (k = n; k > 0; k--){
					if (j - i >= 0 && dp[k - 1][j - i]) dp[k][j] = (dp[k][j] + dp[k - 1][j - i]) % MOD;
				}
			}
		}
		printf("%d\n", dp[n][s]);
	}
	return (0);
}

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

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

    int a, b, c, sum = 0;
    cin >> a >> b >> c;
    for (int i = 1; i < 100000 ; i++) {
        sum += a;
        if (sum % b == c) {
            cout << "YES";
            return 0;
        }
    }
    
    cout << "NO";
    
    return 0;
}



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

struct saikoro{
	int ue, shita, migi, hidari, oku, temae;
};
saikoro sai = {1, 6, 3, 4, 5, 2};

void north() {
	int buf = sai.oku;
	sai.oku = sai.ue;
	sai.ue = sai.temae;
	sai.temae = sai.shita;
	sai.shita = buf;
}
void south() {
	int buf = sai.temae;
	sai.temae = sai.ue;
	sai.ue = sai.oku;
	sai.oku = sai.shita;
	sai.shita = buf;
}
void east() {
	int buf = sai.migi;
	sai.migi = sai.ue;
	sai.ue = sai.hidari;
	sai.hidari = sai.shita;
	sai.shita = buf;
}
void west() {
	int buf = sai.hidari;
	sai.hidari = sai.ue;
	sai.ue = sai.migi;
	sai.migi = sai.shita;
	sai.shita = buf;
}
void right() {
	int buf = sai.hidari;
	sai.hidari = sai.temae;
	sai.temae = sai.migi;
	sai.migi = sai.oku;
	sai.oku = buf;
}
void left() {
	int buf = sai.migi;
	sai.migi = sai.temae;
	sai.temae = sai.hidari;
	sai.hidari = sai.oku;
	sai.oku = buf;
}

int main() {
	int n, ans;
	string s;
	while(1) {
		sai.ue = 1; sai.shita = 6; sai.migi = 3;
		sai.hidari = 4; sai.oku = 5; sai.temae = 2;
		ans = 0;
		cin >> n;
		if(n == 0) return 0;
		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s == "North") {
				north();
				ans += sai.ue;
			}else if(s == "South") {
				south();
				ans += sai.ue;
			}else if(s == "East") {
				east();
				ans += sai.ue;
			}else if(s == "West") {
				west();
				ans += sai.ue;
			}else if(s == "Right") {
				right();
				ans += sai.ue;
			}else if(s == "Left") {
				left();
				ans += sai.ue;
			}
		}
		cout << ans + 1 << endl;
	}
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	ll n; cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}
	sort(all(a));
	vector<ll> sum(n+1,0LL);
	for (int i = 0; i < n; i++){
		sum[i+1] = sum[i] + a[i];
	}
	int ans = 1;
	for (int i = 0; i < n-1; i++){
		if(sum[i+1]*2 < a[i+1]) ans = 1;
		else ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1920