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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int32 d;
int32 c[26];
int32 s[365][26];

int32 score(vector<int32> &t){
  vector<int32> last(26,-1);
  int32 res = 0;
  REP(i,d){
    res += s[i][t[i]];
    last[t[i]] = i;
    REP(j,26)res -= c[j] * (i - last[j]);
    ANS(res);
  }
  return res;
}

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

  // input
  cin >> d;
  REP(i,26)cin >> c[i];
  REP(i,d)REP(j,26)cin >> s[i][j];

  // scoring
  vector<int32> t(d);
  REP(i,d)cin >> t[i];
  REP(i,d)t[i]--;
  score(t);
  // ANS(score(t));


  return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll a[7],b[7],l,k;

void DICE(ll x, ll y){
	k=0;
	if(x==a[1]){
		if(y==a[4] && a[2]==b[l]) k=1;
		if(y==a[2] && a[3]==b[l]) k=1;
		if(y==a[3] && a[5]==b[l]) k=1;
		if(y==a[5] && a[4]==b[l]) k=1;
	}
		if(x==a[2]){
			if(y==a[1] && a[4]==b[l]) k=1;
			if(y==a[4] && a[6]==b[l]) k=1;
			if(y==a[6] && a[3]==b[l]) k=1;
			if(y==a[3] && a[1]==b[l]) k=1;
		}
			if(x==a[3]){
				if(y==a[1] && a[2]==b[l]) k=1;
				if(y==a[2] && a[6]==b[l]) k=1;
				if(y==a[6] && a[5]==b[l]) k=1;
				if(y==a[5] && a[1]==b[l]) k=1;
			}
				if(x==a[4]){
					if(y==a[1] && a[5]==b[l]) k=1;
					if(y==a[5] && a[6]==b[l]) k=1;
					if(y==a[6] && a[2]==b[l]) k=1;
					if(y==a[2] && a[1]==b[l]) k=1;
				}
					if(x==a[5]){
						if(y==a[1] && a[3]==b[l]) k=1;
						if(y==a[3] && a[6]==b[l]) k=1;
						if(y==a[6] && a[4]==b[l]) k=1;
						if(y==a[4] && a[1]==b[l]) k=1;
					}
						if(x==a[6]){
							if(y==a[2] && a[4]==b[l]) k=1;
							if(y==a[4] && a[5]==b[l]) k=1;
							if(y==a[5] && a[3]==b[l]) k=1;
							if(y==a[3] && a[2]==b[l]) k=1;
						}
}
int main(){
	ll i;
	
	for(i=1;i<=6;i++){
		cin>>a[i];
	}
	for(i=1;i<=6;i++){
		cin>>b[i];
	}
	
	l=3;
	DICE(b[1],b[2]);
	if(k==1) DICE(b[2],b[6]);
	if(k==1) DICE(b[6],b[5]);
	if(k==1) cout<<"Yes\n"; 
		else cout<<"No\n";
	
	return 0;
}


Measured memory_bytes: 3096
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
            n: usize,
            orig_v: [u32; n],
        }

    let mut v: Vec<u32> = orig_v;
    v.sort();

    let first: f64 = v[0] as f64;

    let ans: f64 = v.iter().fold(first, |memo, &val| (memo + val as f64) / 2f64 );

    println!("{}", ans);
}

Measured memory_bytes: 4352
import math
def main():
    dice = Dice([int(a) for a in input().split()])
    commands = input()
    for d in range(len(commands)):
        dice.move(commands[d])
    dice.show()

class Dice():
    def __init__(self, surface):
        self.l = surface
 
    def move(self, dir):
        if(dir == 'N'):
            self.l = [self.l[1], self.l[5], self.l[2], self.l[3], self.l[0], self.l[4]]
        elif(dir == 'W'):
            self.l = [self.l[2], self.l[1], self.l[5], self.l[0], self.l[4], self.l[3]]
        elif(dir == 'E'):
            self.l = [self.l[3], self.l[1], self.l[0], self.l[5], self.l[4], self.l[2]]
        elif(dir == 'S'):
            self.l = [self.l[4], self.l[0], self.l[2], self.l[3], self.l[5], self.l[1]]

    def show(self):
        print(self.l[0])


main()


Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  int ans=0;
  rep(i,0,N-2){
    rep(j,i+1,N-1){
      if(A[i]+A[j]>A[N-1])
        ans+=N-1-j;
      else{
        ans+=max(dislow(A,A[i]+A[j])-j-1,0LL);
        }
      }
    }
  cout<<ans;
  }


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

const ll mod = 1e9+7;


int num[2000+10];
int a[2000+10];
int b[2000+10];

int main()
{
	ll n,k;
	cin>>n>>k;
	for(int i=0; i<n; i++)
		cin>>num[i];
	for(int i=0; i<n; i++)
	{
		int j=i+1;
		while(j < n) 
		{
			if(num[j] < num[i]) a[i]++;	
			j++;		
		}
		if(!b[num[i]])
			{
				for(int k=0; k<n; k++)
				{
					if(num[k] < num[i])
					b[num[i]]++;
				}
			}
	}
//	for(int i=0; i<n; i++) cout<<a[i]<<' '<<b[num[i]]<<endl;

	ll ans=0;
	ll sum=(k-1)*k/2;
	sum = sum % mod;
	for(int i=0; i<n; i++)
	{
		ans += b[num[i]]*sum%mod;
		ans += k*a[i]%mod;
		
//		ans=(ans+k*a[i]%mod+b[num[i]]*((k-1)*k%mod)/2%mod)%mod;
	}
	cout<<ans%mod;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>


using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;


struct S {
    int w, s, v;
    void read(){
        cin >> w >> s >> v;
    }
    bool operator < (const S&b) const{
        return w + s < b.w + b.s;
    }
};




int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<S> in(n);
    int MAX_S = 20123;
    for(int i = 0; i < n; i++){
        in[i].read();
    }
    sort(in.begin(), in.end());
    vector<ll> dp(MAX_S + 1);
    //dp[i]  best score of boxes with total weight i
    for(S block : in){
        for(int w = min(block.s, MAX_S - block.w); w >= 0; w--){
            dp[w + block.w] = max(dp[w + block.w], dp[w] + block.v);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= MAX_S; i++){
        answer = max(answer, dp[i]);
    }
    cout << answer;
}



Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		int N = inputs.nextInt();
		//holds all the sums!!!!
		int[][] ans = new int[N][3];
		int one = inputs.nextInt();
		int two = inputs.nextInt();
		int tre = inputs.nextInt();
		ans[0][0] = one;
		ans[0][1] = two;
		ans[0][2] = tre;
		for(int i=1;i<N;i++) {
			one = inputs.nextInt();
			two = inputs.nextInt();
			tre = inputs.nextInt();
			ans[i][0] = Math.max(ans[i-1][1], ans[i-1][2])+one;
			ans[i][1] = Math.max(ans[i-1][0], ans[i-1][2])+two;
			ans[i][2] = Math.max(ans[i-1][1], ans[i-1][0])+tre;
		}
		int fin = Math.max(ans[N-1][0], ans[N-1][1]);
		fin = Math.max(fin, ans[N-1][2]);
		System.out.println(fin);
	}

}


Measured memory_bytes: 96124
using System;

namespace abc162A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = A.Substring(0, 1);
            string C = A.Substring(1, 1);
            string D = A.Substring(2, 1);
            if (B == "7" || C == "7" || D == "7")
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25736
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long

int N;
int t[100001], x[100001], y[100001];

int main(){

	cin >> N;

	for (int i = 1; i <= N; i++)
		cin >> t[i] >> x[i] >> y[i];

	bool possible = true;
	for (int i = 1; i <= N; i++){
		if (t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) possible &= false;
		if ((t[i] - t[i - 1] -( abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])))%2==1 ) possible &= false;
	}

	if (possible) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int count = 0;
			while(true) {
				int W = sc.nextInt();
				if(W == 0)break;
				count++;
				int N = sc.nextInt();
				//dp[重さ] = max 価値
				long[] dp = new long[W+1];
				int[] v = new int[N];
				int[] w = new int[N];
				for(int i=0; i<N; i++) {
					String str = sc.next();
					String[] strs = str.split(",");
					v[i] = Integer.parseInt(strs[0]);
					w[i] = Integer.parseInt(strs[1]);
				}
				for(int i=0; i<W+1; i++) {
					dp[i] = 0;
				}
				for(int i=0; i<N; i++) {
					for(int j=W; j>0; j--) {
						if(j-w[i] >= 0)
							dp[j] = Math.max(dp[j], dp[j-w[i]]+v[i]);
					}
				}
				for(int i=0; i<W+1; i++) {
					if(dp[i] == dp[W]) {
						System.out.println("Case "+count+":");
						System.out.println(dp[i]);
						System.out.println(i);
						break;
					}
				}
			}

		}
	}

}




Measured memory_bytes: 36988
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> C(N), S(N), F(N);
  REP(i,N) cin>>C[i]>>S[i]>>F[i];
  REP(k,N-1) {
    int	ans = S[k];
    for(int i = k; i < N-1; i++) {
      if(ans <= S[i]) ans = S[i];
      else {
	int d =	ans - S[i];
	if (d %	F[i] != 0) {
          ans =	S[i] + (d / F[i] + 1) *	F[i];
        }
      }
      //      cout << i << " " << ans << endl;                                      
      ans += C[i];
    }
    cout << ans	<< endl;
  }
  cout << 0 << endl;
  return 0;
}


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

ll mod=1e9+7;
int main() {
  ll n,k;
  cin>>n>>k;

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

  ll out=0;
  ll d=0;
  rep(j, n) {
    rep(i, j) {
      if(a[i]>a[j]) out++;
      if(a[i]!=a[j]) d++;
    }
  }
  out%=mod;
  out=out*k%mod;

  d%=mod;
  d=d*(k*(k-1)/2%mod)%mod;

  cout << (out+d)%mod << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)1e10
using namespace std;

long long w;
vector<long long> pre, suf, a;

long long solve();

int main() {
  cin >> w;
  a.resize(w);
  for(int i = 0; i < w; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  pre.assign(w + 2, 0);
  suf.assign(w + 2, 0);
  for(int i = 0; i < w; ++i)
    if(a[i] == 0)
      pre[i + 1] = inf;
    else if(a[i] < 0)
      pre[i + 1] = min(pre[i] - 1, -a[i]);
    else
      pre[i + 1] = pre[i] - 1;
  for(int i = w; i > 0; --i)
    if(a[i - 1] == 0)
      suf[i] = inf;
    else if(a[i - 1] < 0)
      suf[i] = min(suf[i + 1] - 1, -a[i - 1]);
    else
      suf[i] = suf[i + 1] - 1;
  for(int i = 0; i < w; ++i)
    if(a[i] > 0)
      ans += min(a[i], max({0LL, pre[i + 1], suf[i + 1]}));
  return ans;
}


Measured memory_bytes: 5220
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
long long DP[102][2][102] = {};

int main(){
    string S;
    int K,N;
    cin >> S >> K;
    N = S.length();
    //rep(i, N+1) rep(j, 2) rep(k,N+1) DP[i][j][k] = -1;
    DP[0][0][0] = 1;
    rep(i,N+1){
        int D = S[i] - '0';
        rep(j,2){
            rep(k,N+1){
                for ( int d = 0; d <= ( j ? 9 : D ); d++ )
				{
					DP[ i + 1 ][ j || ( d < D ) ][k + (int)(d != 0)] += DP[i][j][k];
                    //cout <<  i + 1 << " " <<  (j || ( d < D ))  << " " << (k + d == 0) << endl;
                    //cout << DP[ i + 1 ][ j || ( d < D ) ][k + d == 0] << endl;
				}
            }
        }
    }
    /*
    rep(k,K+1){
        cout << k << " " << DP[N][0][k] << " " << DP[N][1][k] << endl;
    }
    */

    cout << DP[N][0][K] + DP[N][1][K] << endl;

        return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d){
        cout << "Yes" << '\n';
    }
    else if(abs(b-a)<=d && abs(c-b)<=d){
        cout << "Yes" << '\n';
    }
    else{
        cout << "No" << '\n';
    }
}

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

int main() {
int n,l;
cin >> n >> l;
vector<string> a(n);
rep(i,n) cin >> a.at(i);
sort(a.begin(),a.end());
string ans;
rep(i,n){
  ans += a.at(i);
}
cout << ans << endl;
}


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


def solve(A: int, B: int):
    print((A - 1) * (B - 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
ac = 0
wa = 0
tle =0
re = 0
n = int(input())
for i in range(n):
  s = input()
  if s == "AC":
    ac = ac + 1
  elif s == "WA":
    wa = wa + 1
  elif s == "TLE":
    tle = tle + 1
  elif s == "RE":
    re = re + 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))



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

struct data{
    string l;
    double s;
    data(string l, double s) : l(l), s(s) {}
    bool operator<(const data other) const{
        if(s == other.s){
            return l < other.l;
        }else{
            return s > other.s;
        } 
    }
};

int main(){
    int n;
    while(cin >> n, n){
        vector<data> v;
        string l;
        int p, a, b, c, d, e, f, s, m;
        for(int i = 0; i < n; i++){
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            v.push_back(data(l, (double)(f*s*m-p)/(a+b+c+m*(d+e))));
        }
        sort(v.begin(), v.end());
        for(data d : v) cout << d.l << endl;
        cout << "#" << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
typedef long long ll;
const int MOD = 2019;
int qpow(int base, int exp){
	int res = 1;
	while(exp>0){
		if(exp&1)res = res*base%MOD;
		base = base*base%MOD;
		exp>>=1;
	}
	return res;
}
string S;
int N, tmp, psa[2019], cnt;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> S; N = S.size();
	int cur = 1, pre = 0;
	for(int i = N-1;i>=0;i--){
		int digit = S[i]-'0';
		tmp=tmp+digit*qpow(10, N-i-1)%MOD;
		tmp%=MOD;
		if(tmp==0)cnt++;
		cnt+=psa[tmp]; psa[tmp]++;
	}
	cout << cnt << nl;
	return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF

int main(){
  long long n,q,xx,nn;
  scanf ("%lld %lld",&n,&q);
  xx=int(sqrt(n))+1;
  nn=xx*xx;
  vector<long long> a(nn,0);
  vector<long long> aa(xx,0);
  long long int x,y,c,xxx,yyy;
  for(int i=0;i<q;i++){
    scanf ("%lld %lld %lld",&c,&x,&y);
    x--;
    y--;
    xxx=x/xx;
    yyy=y/xx;
    if(c==0){
      a[x]=a[x]+y+1;
      aa[xxx]=aa[xxx]+y+1;
    }
    else{
      long long ma,mb,ans;
      ans=0;
      ma=xxx*xx+xx;
      mb=yyy*xx;
      if((y-x)>=xx*2){
        for(int t=x;t<ma;t++){
          ans=ans+a[t];
        }
        for(int t=xxx+1;t<yyy;t++){
          ans=ans+aa[t];
        }
        for(int t=mb;t<=y;t++){
          ans=ans+a[t];
        }
      }
      else{
        for(int t=x;t<=y;t++){
          ans=ans+a[t];
        }
      }

      printf("%lld\n",ans);
    }
    /*for(int s=0;s<nn;s++){
      printf("%d",a[s]);
    }
    printf("\n");*/
  }
}



Measured memory_bytes: 3596
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

using namespace std;

#define BOOST 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ALL(a) 			(a).begin(), (a).end()
#define SZ(a) 			(int)(a).size()
#define FOR(a, b, c) 	for (int a = (b); a <  (c); a++)
#define FORR(a, b, c) 	for (int a = (b); a >= (c); a--)
#define TRAV(a, b) 		for (auto& a : b)
#define ELO 			exit(0)
#define SORT(a)         sort(ALL(a))
#define REV(a)          reverse(ALL(a))
#define SORTR(a)        SORT(a), REV(a)
#define PB              push_back
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using vi = 				vector<int>;
using vll = 			vector<ll>;
using vpii = 			vector<pii>;
using vpll = 			vector<pll>;

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

namespace fastio {
    template <class T> istream &operator>>(istream &os, vector<T> & vec){for (auto &u : vec)os >> u;return os;}
    template <class T> ostream &operator<<(ostream &os, const vector<T> & vec){for (auto &u : vec)os << u << " ";return os;}
    template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> & con) { for (auto &u : con) os << u << " "; return os; }

    void re() {}
    template <typename T, typename... args> void re(T& x, args&... tail) { cin >> x; re(tail...); }
    void pr() {}
    template <typename T, typename... args> void pr(T x, args... tail) { cout << x << " "; pr(tail...);}
    template <typename... args> void prln(args... tail) { pr(tail...); cout << "\n";}
}
using namespace fastio;

namespace debug {
    template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
    template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }
    
    #if 1
        #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
        #define cerr cout
    #else
        #define debug(...) 1999
        #define cerr if(0) cout
    #endif
}
using namespace debug;

//////////////_________CODE_________//////////////

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

ll get(ll a, ll c, ll d) {
    ll res = a;
    auto temp = [&](ll x) -> ll {
        return a / x;
    };

    return res - temp(c) - temp(d) + temp(lcm(c, d));
}

int main() {
    BOOST;
    ll a, b, c, d; 
    re(a, b, c, d);
    prln(get(b, c, d) - get(a - 1, c, d));
    ELO;
}

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

using namespace std;

typedef long long LL;
typedef long double LD;





int main()
{
  LL N,Q;
  cin >> N >> Q ;
  string S;
  cin >> S;

  vector<LL> Counter(N);
  for (LL i = 0; i < N - 1; i++) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      Counter[i]++;
    }
  }
  vector<LL> Integral(N);
  Integral[0] = Counter[0];
  for (LL i = 1; i < N; i++) {
    Integral[i] = Counter[i]+ Integral[i-1];
  }

  for (LL i = 0; i < N; i++) {
    //cerr << Counter[i];
  }
  //cerr << endl;
  for (LL i = 0; i < N; i++) {
    //cerr << Integral[i];
  }
  //cerr << endl;

  for (LL q = 0; q < Q; ++q) {
    LL l, r;
    cin >> l >> r;
    l--;
    l--;
    r--;
    r--;
    LL lv=0;
    LL rv=0;
    if (l >= 0) {
      lv = Integral[l];
    }
    if (r >= 0) {
      rv = Integral[r];
    }
    //cerr << lv << " : " << rv << " : " << rv-lv << endl;
    cout << rv - lv << endl;
  }

  return 0;
}

Measured memory_bytes: 2688
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):

      if i*500 + j*100 + k*50 == x:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<string> removeWhite(const vector<string>& v) {
	vector<string> out;
	auto itr = v.begin();
	for (itr; itr != v.end(); ++itr) {
		if (count(itr->begin(), itr->end(), '.') != itr->size()) out.push_back(*itr);
	}
	return out;
}

vector<string> transpose(const vector<string>& v) {
	size_t t_h = v[0].size();
	vector<string> out(t_h);
	auto itr = v.begin();
	for (itr; itr != v.end(); ++itr) {
		int tmp = 0;
		auto itr2 = itr->begin();
		for (itr2; itr2 != itr->end(); ++itr2) {
			out[tmp] += *itr2;
			tmp +=1;
		}
	}
	return out;
}


int main() {
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	for (int i = 0; i < h; ++i) {
		cin >> v[i];
	}
	vector<string> v_r_r= removeWhite(v);
	vector<string> v_r_r_rot = transpose(v_r_r);
	vector<string> v_rc_r = removeWhite(v_r_r_rot);
	vector<string> v_out = transpose(v_rc_r);
	
	auto itr2 = v_out.begin();
	for (itr2; itr2 != v_out.end(); ++itr2) {
		cout << *itr2 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
N, W = [int(x) for x in input().split()]
v = [0] * (N + 1);  w = [0] * (N + 1);
for i in range(1, N + 1):
    v[i], w[i] = [int(x) for x in input().split()]

dp = [[0 for _ in range(W + 1)] for _ in range(2)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        if j < w[i]:
            dp[i % 2][j] = dp[(i - 1) % 2][j]
        else:
            dp[i % 2][j] = max(dp[(i - 1) % 2][j], dp[i % 2][j - w[i]] + v[i])

print(dp[N % 2][W])


Measured memory_bytes: 6520
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
 
typedef long long ll;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

int main(){
    string str;
    cin >> str;
    REP(i, str.length()){
        if(str[i] == ',') cout << " ";
        else cout << str[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
# E
from collections import Counter

N = int(input())
xy_list = [list(map(int, input().split())) for _ in range(N)]

M = 998244353

res = pow(2, N, M)
# 0 points
res -= 1
# 1 points
res -= N

# all lines
line_cnt = [0]*(N+1)

for i in range(N):
    xi, yi = xy_list[i]
    angle_list = []
    for j in range(N):
        xj, yj = xy_list[j]
        if xj != xi:
            angle_list.append((yj-yi)/(xj-xi))
        elif yj != yi:
            angle_list.append(10000.0)
        
    # count points in same line
    cnt_i = Counter(angle_list)
    for k in cnt_i.values():
        line_cnt[k+1] += 1

for i in range(2, N+1):
    cnt = line_cnt[i] // i
    res -= cnt*(pow(2, i, M)-i-1)

res = res % M
print(res)

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
const long long mod= 998244353ll;
const int MSIZE=400000;

void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
long long sq(long long a){return a*a%mod;}
long long pw(long long a,long long n)
{
  return n==0?1ll:sq(pw(a,n/2))*(n%2==1?a:1ll)%mod;
}
long long iv(long long a){return pw(a,mod-2);}
long long inv[MSIZE],F[MSIZE],iF[MSIZE];

void prev(int N)
{
  inv[0]=0;
  inv[1]=1;
  for(int i=2;i<N;i++){
    inv[i]=(mod-mod/i)*inv[mod%i]%mod;
  }
  F[0]=iF[0]=1;
  for(int i=1;i<N;i++){
    F[i]=F[i-1]*i%mod;
    iF[i]=iF[i-1]*inv[i]%mod;
  }
}

long long Ch(int i,int j)
{
  return F[i]*iF[j]%mod*iF[i-j]%mod;
}

int main()
{
  int n;
  long long a,b,K;
  scanf("%d%lld%lld%lld",&n,&a,&b,&K);
  prev(n+10);
  long long ans=0;
  for(int i=0;i<=n;i++){
    if((K-a*i)%b!=0)continue;
    int j=(K-a*i)/b;
    if(j<0||n<j)continue;
    ad(ans,Ch(n,i)*Ch(n,j)%mod);
  }
  printf("%lld\n",ans);
  return 0;
}



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

int main() {
  string s;
  cin >> s;
  bool flag=false;
  for(int i=0;i<7;i++) {
    string temp=s.substr(0,i)+s.substr(s.size()-7+i,7-i);
    if(temp=="keyence") {
      flag=true;
    }
  }
  if(flag) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(void){
  string S; int A=0;
  cin >> S;
  FOR(i,0,3) if(S[i]=='A') A++;
  if(A==0 || A==3) {cout << "No"; return 0;}
  else cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<string, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}



int main()
{
	int n;
	cin >> n;
	vector<tuple<string, int, int>>a;
	rep(i, n) {
		string city;
		int pt;
		cin >> city >> pt;
		pt *= -1;
		a.push_back(make_tuple(city, pt, i + 1));
	}
	sort(all(a));
	rep(i, n) {
		cout << get<2>(a[i]) << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

long long power(long long n)
{
    long long ret = 1;

    for (long long i = 0; i < n; i++) ret *= 2;

    if (n == -1) return 0;
    else return ret;
}

int main()
{
    int n, p;
    int a;
    long long cnt[2] = {};

    cin >> n >> p;
    for (int i = 0; i < n; i++) {
        cin >> a;

        cnt[a % 2]++;
    }

    if (p == 0 && cnt[1] == 0) {
        cout << power(n) << endl;
    } else if (p == 1 && cnt[1] == 0) {
        cout << 0 << endl;
    } else {
        cout << power(n  - 1) << endl;
    }

    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  char c[200001];
  int white=0;
  for (int i=1; i<=N; i++){
    c[i]=S[i-1];
    if (c[i] == 'W'){
      white++;
    }
  }
  
  int ans=0;
  for (int i=0; i<white; i++){
    if (c[N-i] == 'R'){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

namespace AtCoder.Question
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            var x = ReadHelper.ReadValue<long>();
            var zandaka = 100L;
            var nen = 0;
            while (x > zandaka)
            {
                nen++;
                zandaka = (long)Math.Floor(zandaka * 1.01);
            }
            Console.WriteLine(nen);
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 27572
//{
#include<bits/stdc++.h>
using namespace std;
 
#define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}

const int MXL = 100005;

vl cnts(MXL, 0);

ll givesm() {
    ll sm = 0;
    FOR(i, 0 , MXL) {
        sm += cnts[i] * i;
    }
    
    return sm;
}

void solve(ll n, vl &A, ll q, vector<pair<ll, ll> > &P) {
    FOR(i,0,n)
        cnts[A[i]]++;
    ll sm = givesm();
    // deb(sm);
    
    FOR(i, 0, q) {
        ll x = P[i].F, y = P[i].S;
        ll ct_x = cnts[x];
        
        sm -= ct_x * x;
        sm += ct_x * y;
        cnts[y] += ct_x;
        
        cnts[x] = 0;
        cout << sm << endl;
    }
}

void Input() {
    rd1(ll, n);
    vl A(n);
    FOR(i, 0, n)
        cin >> A[i];
    rd1(ll, q);
    vector<pair<ll, ll> > P(q);
    FOR(i,0,q)
        cin >> P[i].F >> P[i].S;
        
    solve(n, A, q, P);
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

Measured memory_bytes: 6308
import scala.io.StdIn.readLine

object Main {
  def getNum(c:Char) = c match {
    case 'I' => 1
    case 'V' => 5
    case 'X' => 10
    case 'L' => 50
    case 'C' => 100
    case 'D' => 500
    case 'M' => 1000
    case _ => 0
  }

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_!=null).foreach { s =>
      var prev = getNum(s(0))
      var sum = prev
      for(j<-1 until s.length) {
        val n = getNum(s(j))
        if(n>prev) sum += n -(2*prev) else sum += n
        prev = n
      }
      println(sum)
    }
  }
}

Measured memory_bytes: 43344
#include<stdio.h>

int main(void){

int a;
int b;
int i,j;
int kosu=0;
int ans=1;

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

kosu=a;

while(kosu<b){
kosu=kosu-1+a;
ans++;
}
if(b==1){
  ans=0;
}

printf("%d",ans);
return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int ans = m;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		m += a;
		m -= b;
		ans = max(ans, m);
		if (m < 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<map>
#include<queue>
using namespace std;

char change(char,char);
int ok(string);
int BFS(string);

int main(void){
  string s;
  
  while(cin >> s){
    if(s=="0")break;
    
    int res=BFS(s);
    
    if(res>=0)cout << res << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

char change(char c1,char c2){
  string s="rgb";
  if(c1==c2)return '*';
  for(int i=0;i<3;i++){
    if(c1!=s[i] && c2!=s[i])return s[i];
  }
}

int ok(string s){
  for(int i=0;i<s.length()-1;i++)
    if(s[i]!=s[i+1])return 0;
  return 1;
}

int BFS(string s){
  queue<string>Q;

  map<string,int>dist;
  Q.push(s);
  dist[s]=1;

  while(!Q.empty()){
    string now=Q.front();
    Q.pop();

    if(ok(now))return dist[now]-1;

    for(int i=0;i<now.length()-1;i++){
      char res=change(now[i],now[i+1]);
      if(res=='*')continue;

      string tmp=now;
      tmp[i]=tmp[i+1]=res;
      if(dist[tmp]==0){
	dist[tmp]=dist[now]+1;
	Q.push(tmp);
      }
    }
  }
  return -1;
}

Measured memory_bytes: 1876
#include <cstdio>
#include <queue>
using namespace std;

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

class State
{
public:
	int x,y,cx,cy,c;
	State(int x, int y, int cx, int cy, int c)
	:x(x),y(y),cx(cx),cy(cy),c(c)
	{}
	
	bool operator<(const State& s) const
	{
		return c>s.c;
	}
};

int main()
{
	int w,h;
	while(scanf("%d%d", &w,&h), (w||h))
	{
		bool hs[7][7][7][7]={0};
		int f[7][7],sx,sy,cx,cy;
		
		for(int i=0; i<h; i++)
		for(int j=0; j<w; j++)
		{
			scanf("%d", &f[j][i]);
			if(f[j][i]==4)
			{
				sx=j;
				sy=i;
			}
			if(f[j][i]==2)
			{
				cx=j;
				cy=i;
			}
		}
		
		priority_queue<State> q;
		q.push(State(sx,sy,cx,cy,0));
		
		bool g=false;
		while(!q.empty())
		{
			State s=q.top(); q.pop();
			if(f[s.cx][s.cy]==3)
			{
				g=true;
				printf("%d\n", s.c);
				break;
			}
			
			for(int i=0; i<4; i++)
			{
				int tx=s.x+dx[i], ty=s.y+dy[i];
				int tcx=s.cx, tcy=s.cy, tc=s.c;
				if(tx<0||ty<0||tx>=w||ty>=h) continue;
				if(f[tx][ty]==1) continue;
				
				if(tx==s.cx&&ty==s.cy)
				{
					tcx+=dx[i], tcy+=dy[i];
					if(tcx<0||tcy<0||tcx>=w||tcy>=h) continue;
					if(f[tcx][tcy]==1) continue;
					tc++;
				}
				
				if(hs[tx][ty][tcx][tcy]) continue;
				hs[tx][ty][tcx][tcy]=1;
				
				q.push(State(tx,ty,tcx,tcy,tc));
			}
		}
		
		if(!g) puts("-1");
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, vector<ll>>;

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

    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    priority_queue<P> que;
    set<vector<ll>> s;
    que.push(P(A[0]+B[0]+C[0], {0, 0, 0}));
    for (int i = 0; i < K; i++) {
        P p = que.top(); que.pop();
        cout << p.first << "\n";
        ll a = p.second[0];
        ll b = p.second[1];
        ll c = p.second[2];
        vector<ll> v = p.second;
        if (a+1 < X) {
            vector<ll> w = {a+1, b, c};
            if (!s.count(w)) {
                que.push(P(A[a+1]+B[b]+C[c], w));
                s.insert(w);
            }
        }
        if (b+1 < Y) {
            vector<ll> w = {a, b+1, c};
            if (!s.count(w)) {
                que.push(P(A[a]+B[b+1]+C[c], w));
                s.insert(w);
            }
        }
        if (c+1 < Z) {
            vector<ll> w = {a, b, c+1};
            if (!s.count(w)) {
                que.push(P(A[a]+B[b]+C[c+1], w));
                s.insert(w);
            }
        }
    }
}

Measured memory_bytes: 1408
import java.io.IOException
import java.io.InputStream
import java.io.PrintWriter
import java.util.NoSuchElementException

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt() - 1
    val s = sc.next().toCharArray()
    s[k] = s[k].toLowerCase()
    println(s.joinToString(""))
}

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 31816
// 1_5_A

#include <iostream>
using namespace std;

int main(){
  int H, W;

  while(true){
    cin >> H >> W;
    if(H == 0 && W == 0) return 0;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}

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

// 数字の各桁の和を返す
int sumDigits (int n) {
    int s;
    while (n < 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

// 最大公約数を返す
int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main () {
  long long int N; cin >> N;

  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }

  string ans = "";
  while (N != 0) {
    if (N % 2 == 0) {
      ans.push_back('0');
    } else {
      ans.push_back('1');
      N -= 1;
    }
    N /= -2;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
c=[0]*n
#a[i]は1以上n以下で、cの要素番号は0~n-1(acは1ずれている。)
all=0
for i in range(n):
  c[a[i]-1]+=1
for i in range(n):
  if c[i]>=2:
    d=c[i]*(c[i]-1)/2
    all+=d
for i in range(n):
  print(int(all-(c[a[i]-1]-1)))

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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    if (( N % X ) == 0) cout << (( N / X ) ) * T << endl;
    else cout << (( N / X ) + 1 ) * T << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int x,a=400;
	cin >>x;
	rep(i, 100) {
		a += 200;
		if (x < a) {
			cout << 8 - i;
			return 0;
		}
	}
}

Measured memory_bytes: 3648
List=input()
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for (i,j) in zip(List,a):
	if int(i) != int(j):
		c1 += 1

for (i,j) in zip(List,b):
	if int(i) != int(j):
		c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)

Measured memory_bytes: 5620
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::string s,t;
  cin>>s>>t;
  int result=0;
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      result++;
    }
  }

  cout<<result<<endl;

  return 0;
}


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

        string a;
        cin >> a;
        if (!a.compare("Sunny")){
            cout << "Cloudy";
        } else if (!a.compare("Cloudy")){
            cout << "Rainy";
        } else if (!a.compare("Rainy")){
            cout << "Sunny";
        }
        
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  string s;
  char c[300000];
  ll ans,d,q;
  d=0;
  ans=0;

  cin >> s;
    q=s.length();
  rep(i,q)c[i]=s[i];
  rep(i,q)if(c[i]=='W'){ans+=i;
                       d++;
                      }
  printf("%lld",ans-(d-1)*d/2);

}


Measured memory_bytes: 772