akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve() {
    int d;
    cin >> d;
    VI c(26);
    VVI s(d,VI(26));
    REP(i,0,26) {
        cin >> c[i];
    }
    REP(i,0,d) REP(j,0,26) cin >> s[i][j];
    VI t(d);
    VI lasts(26, -1);
    int score = 0;
    REP(i,0,d) {
        cin >> t[i];
        --t[i];
    }
    VI scores(26);
    REP(i,0,26) {
        REP(j,0,d) {
            if (t[j] == i) {
                scores[i] += s[j][i];
                lasts[i] = j;
            }
            scores[i] -= c[i] * (j - lasts[i]);
        }
    }
    REP(i,0,26) score += scores[i];
    dump(score);

    int m,dt,q;
    cin >> m;
    REP(mmm,0,m) {
        cin >> dt >> q;
        --dt; --q;
        int oldt = t[dt];
        score -= scores[oldt] + scores[q];
        t[dt] = q;
        // dump(scores[oldt]);
        // dump(scores[q]);
        scores[oldt] = 0;
        scores[q] = 0;
        lasts[oldt] = -1;
        lasts[q] = -1;

        REP(j,0,d) {
            if (t[j] == oldt) {
                scores[oldt] += s[j][oldt];
                lasts[oldt] = j;
            }
            scores[oldt] -= c[oldt] * (j - lasts[oldt]);
        }
        REP(j,0,d) {
            if (t[j] == q) {
                scores[q] += s[j][q];
                lasts[q] = j;
            }
            scores[q] -= c[q] * (j - lasts[q]);
        }
        // dump(scores[oldt]);
        // dump(scores[q]);
        score += scores[oldt] + scores[q];
        cout << score << endl;
    }
}

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false) ,cin.tie(0);
	int x;
	cin >> x;
	int sum = 0;
	while(x >= 5){
		while(x >= 500){
			sum += x / 500 * 1000;
			x %= 500;
		}
		while(x >= 5){
			sum += x/5 * 5;
			x %= 5;
		}
	}
	cout << sum;
}


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

typedef long long ll;

ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  ll n=s.size();
  ll a=0,b=0,c=0,count=1;
  for(ll i=0;i<n;i++){
    if(s[i]=='C'){
      c=(c+b)%mod;
    }
    else if(s[i]=='B'){
      b=(b+a)%mod;
    }
    else if(s[i]=='A'){
      a=(a+count)%mod;
    }
    else{
      c=(c+b+c*2)%mod;
      b=(b+a+b*2)%mod;
      a=(a*3+count)%mod;
      count=(count*3)%mod;
    }
    //cout << a << " " << b << " " << c << endl;
  }
  cout << c << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int a,b,c,d;

int main() {
	cin>>a>>b>>c>>d;
	int t=1;
	while(a*c>0){
		if(t%2)c-=b;
		else a-=d;
		t++;
	}
	cout<<(a<=0?"No":"Yes")<<endl;
	return 0;
}



Measured memory_bytes: 3592
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1000

int V,num_BLUE,num_RED;
vector<int> G[NUM];
int match[NUM],red[NUM],blue[NUM];
bool used[NUM];


int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}
void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
}

int dfs(int node_id){
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int adj_node_id = G[node_id][i],pair_id = match[adj_node_id];
		if((pair_id < 0)||(used[pair_id] == false && dfs(pair_id) == true)){
			match[node_id] = adj_node_id;
			match[adj_node_id] = node_id;
			return true;
		}
	}
	return false;
}


int bipartie_matching(){
	int ret = 0;
	for(int i = 0; i < V; i++)match[i] = -1;
	for(int node_id = 0; node_id < V; node_id++){
		if(match[node_id] < 0){
			for(int i = 0; i < V; i++)used[i] = false;
			if(dfs(node_id)){
				ret++;
			}
		}
	}
	return ret;
}

void func(){

	V = num_BLUE+num_RED;
	for(int i = 0; i < V; i++)G[i].clear();

	for(int i = 0; i < num_BLUE; i++)scanf("%d",&blue[i]);
	for(int i = 0; i < num_RED; i++)scanf("%d",&red[i]);

	int common;

	for(int i = 0; i < num_BLUE; i++){
		for(int k = 0; k < num_RED; k++){
			if(blue[i] >= red[k]){
				common = calc(blue[i],red[k]);
			}else{
				common = calc(red[k],blue[i]);
			}
			if(common > 1){
				add_edge(i,num_BLUE+k);
			}
		}
	}

	printf("%d\n",bipartie_matching());
}

int main(){

	while(true){
		scanf("%d %d",&num_BLUE,&num_RED);
		if(num_BLUE == 0 && num_RED == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string r, g, b;
    cin >> r >> g >> b;
    cout << ( stoi( r + g + b ) % 4 == 0 ? "YES" : "NO" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int K = 60;
const int INF = 1e18 + 239;

int dp[K][2][2];

void init() {
	for (int i = 0; i < K; i++) {
		for (int f = 0; f < 2; f++) {
			for (int s = 0; s < 2; s++) {
				dp[i][f][s] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
}

int safe_shift(int a, int b) {
	if (a == 0) return 0;
	return (a << b);
}

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

	int n;
	cin >> n;
	int x, y;
	int z = 0;
	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		if (i == 0) {
			x = v;
		} else if (i == 1) {
			y = v;
		} else {
			z ^= v;
		}
	}
	//(x - a) ^ (y + a) == z
	init();
	for (int i = 0; i + 1 < K; i++) {
		for (int cf = 0; cf < 2; cf++) {
			for (int cs = 0; cs < 2; cs++) {
				if (dp[i][cf][cs] == INF) continue;
				for (int b = 0; b < 2; b++) {
					int ncf = 0;
					int ncs = 0;
					int bx = (x >> i) & 1;
					int by = (y >> i) & 1;
					int rbf = b ^ bx ^ cf;
					int rbs = b ^ by ^ cs;
					if ((bx << i) - (b << i) - safe_shift(cf, (i - 1)) < 0) ncf = 1;
					if ((by << i) + (b << i) + safe_shift(cs, (i - 1)) > (1LL << i)) ncs = 1;
					if ((rbf ^ rbs) != ((z >> i) & 1)) continue;
					dp[i + 1][ncf][ncs] = min(dp[i + 1][ncf][ncs], dp[i][cf][cs] + (b << i));
				}
			}
		}
	}
	int ans = dp[K - 1][0][0];
	if (ans >= x) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
}


Measured memory_bytes: 3192
#include<iostream>

using namespace std;

int main(){
	int i,w,n,a,b,temp;
	int *amida;
	char comma;
	cin>>w>>n;
	amida=new int[w];
	for(i=0;i<w;i++){
		amida[i]=i+1;
	}
	while(n--){
		cin>>a>>comma>>b;
		temp=amida[a-1];
		amida[a-1]=amida[b-1];
		amida[b-1]=temp;
	}
	for(i=0;i<w;i++){
		cout<<amida[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
    }

    let mut ans = 0;
    for i in 1..n + 1 {
        if i % 2 == 0 {
            continue;
        }

        let mut divisor_num = 0;
        for j in 1..i + 1 {
            if i % j == 0 {
                divisor_num += 1;
            }
            if divisor_num > 8 {
                break;
            }
        }
        if divisor_num == 8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  string s; cin>>s;
  int x=0;
  for (char c: s) {
    if (c=='+') x++; else x--;
  }
  cout<<x;

  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
 // input = input.split("\n");
  
  //	input = input.split(" ");
  
  
  
  	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	

	
	var N = tmp[0];
   var D = tmp[1];

    var N= parseInt(N, 10);
    var D= parseInt(D, 10);
   
   var a=0;
   var b=0;
   var c=0;
   var e=0;
  
   var a= 1 + D;
   var b = a + D;
 //  var c = N/b;
  var c = Math.floor(N / b);
  var  e = N%b;
  
//  console.log(N,D,a,b,c,e);
  
  if( e == 0){
    console.log(c);}
   else{var c = c + 1;
        console.log(c);}
  
  
     }
     
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));    
 

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


inline void solve(){

    int n,a,b,c;
    string str;
    int m[3];
    FOR(i,3) cin >> m[i];
    
    sort(m,m+3);
    cout << m[0]+m[1] fin;
    

  

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


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

using namespace std;

int main()
{
	int n, num[7];
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i <= 6; i++){
			num[i] = 0;
		}
		int d;
		for(int i = 0; i < n; i++){
			cin >> d;
			d = min(d, 60);
			num[d / 10]++;
		}
		for(int i = 0; i <= 6; i++){
			cout << num[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    int d = B - A;
    
    string ans = "NO";

    REP(i, N) if(C * i - D * (N - i - 1) <= d && d <= D * i - C * (N - i - 1)) ans = "YES";

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int di(long long x){
    string di1 = to_string(x);
    return di1.size();
} 
int main(){
long long a;
int b=1000000;
cin >> a;
long long i = 1;
    while (i*i<=a){
        if(a%i == 0){
            if(b>max(di(i),di(a/i))) b = max(di(i),di(a/i));
        }
    i++;    
    }
    cout << b << endl;
}

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

long minl(long a,long b);
int main()
{
	long N,K,i,temp,zp,ans=3*pow(10,8),flag=1;
	bool alc=1;
	vector<long> x;
	cin>>N>>K;
	zp=N-1;
	for(i=0;i<N;i++){
		cin>>temp;
		x.push_back(temp);
		if(alc){
			if(temp>0){
				zp=i-1;
				alc=0;
			}else if(temp==0){
				zp=i;
				alc=0;
				flag=0;
			}
		}
	}
	for(i=0;i<K+flag;i++){
		if(zp-K+1+i>=0){
			if(zp+i<N){
				temp=x.at(zp+i)-x.at(zp-K+1+i)+minl(abs(x.at(zp+i)),abs(x.at(zp-K+1+i)));
				if(temp<ans){
					ans=temp;
				}
			}else{
				break;
			}
		}
	}
	cout<<ans;
}
long minl(long a,long b)
{
	if(a<=b){
		return a;
	}else{
		return b;
	}
}

Measured memory_bytes: 1400
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n, cnt = 0;
	int l, r;
	cin >> n;
	loop(n) {
		cin >> l >> r;
		cnt += r - l + 1;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    int count = 0;
    rep(i,s.size()){
        if(s[i]!='A' and s[i]!='C' and s[i]!='G' and s[i]!='T') count = 0;
        else count++;
        if(count>ans)ans = count;
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n%2 == 1) cout << "No";
  else{
    string s1 = s.substr(0, n/2);
    string s2 = s.substr(n/2, n/2);
    if(s1 == s2) cout << "Yes";
    else cout << "No";
  }
}

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

using namespace std;

#define int long long
int const maxn = 2e5 + 5;
int a[maxn], sum[maxn], pref[maxn];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) pref[i] = (pref[i - 1]^a[i]);
    for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
    for (int i = 1; i <= n; ++i) {
        int lef = i, righ = n + 1;
        while (righ - lef > 1) {
            int mid = (righ + lef) / 2;
            if (sum[mid] - sum[i - 1] == (pref[mid]^pref[i - 1])) lef = mid;
            else righ = mid;
        }
        ans += (lef - i + 1);
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(int.Parse).ToArray();
        var st = new DisjointSparseTable<int>(A, GCD);
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans = Max(ans, GCD(st.Query(0, i), st.Query(i + 1, N)));
        }
        WriteLine(ans);
        Out.Flush();
    }

    static int GCD(int a, int b)
    {
        while (b != 0)
        {
            var c = a;
            a = b;
            b = c % b;
        }
        return a;
    }
}

public class DisjointSparseTable<T> // 半群
{
    T[,] buffer;
    Func<T, T, T> F;
    int[] log2;

    public DisjointSparseTable(T[] init, Func<T, T, T> f)
    {
        F = f;

        var n = init.Length;

        //Query[l, r) で log2[l ^ (r - 1)]を計算するため 1 << log2(r - 1) + 1 = 1 << log2(n - 1) + 1
        var log = 0;
        while ((1 << log) <= n - 1) log++;
        log2 = new int[1 << log + 1];
        for (int i = 2; i < log2.Length; i++) log2[i] = log2[i >> 1] + 1;
        log2[0] = -1;
        //log2[1] = -1;

        var h = log2[n - 1] + 1;//ceil(log2(n))
        buffer = new T[h, n];

        for (int i = 0; i < h; i++) for (int j = 0; j < n; j++) buffer[i, j] = init[j];
        for (int i = 1; i < h; i++)
        {
            for (int j = 0, s = 1 << i; j < n; j += s << 1)
            {
                int t = Min(j + s, n);
                for (int k = t - 2; k >= j; k--) buffer[i, k] = f(buffer[i, k], buffer[i, k + 1]);//非可換

                if (n <= t) break;
                int r = Min(t + s, n);
                for (int k = t + 1; k < r; k++) buffer[i, k] = f(buffer[i, k - 1], buffer[i, k]);//非可換
            }
        }
    }

    public T Query(int l, int r)
    {
        if (l == r) return default(T);
        if (r - l == 1) return buffer[0, l];
        r--;//閉区間
        var h = log2[l ^ r];
        return F(buffer[h, l], buffer[h, r]);
    }
}


Measured memory_bytes: 29916
import java.awt.Point;
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = scanner.nextInt();
        List<Point>[] list = new List[n];
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            list[i] = new ArrayList();
            for (int j = 0; j < a; j++) {
                int x = scanner.nextInt() - 1;
                int y = scanner.nextInt();
                list[i].add(new Point(x, y));
            }
        }
        int max = 0;
        l: for (int i = 0; i < 1 << n; i++) {//1=本当
            for (int j = 0; j < n; j++) {
                if (((i >> j) & 1) == 1) {
                    for (Point p : list[j]) {
                        if (((i >> p.x) & 1) != p.y) {
                            continue l;
                        }
                    }
                }
            }
            max = Math.max(max, Integer.bitCount(i));
        }
        System.out.println(max);
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            System.out.flush();
        } catch (Throwable t) {
            System.out.flush();
            t.printStackTrace();
        }
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 23764
n, m, k = map(int, input().split())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
ls = an[::-1] + bn
l = 0
r = n
s = sum(an)
ans = 0
while r < n + m and l <= n:
    if s <= k:
        ans = max(ans, r - l)
        s += ls[r]
        r += 1
    else:
        s -= ls[l]
        l += 1
if s <= k:
    ans = max(ans, r-l)
print(ans)

    

Measured memory_bytes: 118296
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int h, w;
  cin >> h >> w;
  char masu[h][w];
  rep (i, h) rep (j, w) cin >> masu[i][j];
  rep (i, h) {
    rep (j, w) {
      if (masu[i][j] == '#') {
        int flag = 0;
        for (int tate = -1; tate <= 1; tate++) {
          if (tate == 0) continue;
          if (i + tate < 0 || i + tate > h - 1) continue;
          if (masu[i + tate][j] == '#') {
            flag = 1;
            break;
          }
        }
        for (int yoko = -1; yoko <= 1; yoko++) {
          if (yoko == 0) continue;
          if (j + yoko < 0 || j + yoko > w - 1) continue;
          if (masu[i][j + yoko] == '#') {
            flag = 1;
            break;
          }
        }
        if (flag == 0) {
          No;
          return 0;
        }
      }
    }
  }
  Yes;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define MAX 100

int n;
float sum=0.0f;
float ave;
int near_index=0;
float min_distance = 100;
float temp;

int main()
{
  scanf("%d", &n);
  int a[n];
  rep(i,n) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  ave = sum / n;
  rep(i,n) {
    temp = abs(ave-a[i]);
    if(temp < min_distance) {
      min_distance = temp;
      near_index = i;
    }
  }
  printf("%d\n", near_index);
  return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int t;
     t=0;
    for(int s=a;s<=b;s++){
        if(c%s==0){
         t++;   
        }
    
    }
   cout << t << endl;
   return 0;
    
}


Measured memory_bytes: 3100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] v = {in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()};
            int res = Math.min(v[1], v[3]) - Math.max(v[0], v[2]);
            out.println(Math.max(0, res));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
void main() {
	auto s = rs;
	ulong tmp;
	foreach(i, v; s) {
		if(v == 'A') {
			tmp = i;
			break;
		}
	}
	foreach_reverse(i, v; s) {
		if(v == 'Z') {
			(i - tmp + 1).writeln;
			return;
		}
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main() {
    int n, k;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    int answer = a.at(n-1) - a.at(0);
    for(int i = 0;i < n-1;i++){
        answer = min(answer, k-(a.at(i+1)-a.at(i)));
    }

    cout << answer << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    long ans = 0;
    for(long a = 1; a <= k; a++) {
      for(long b = 1; b <= k; b++) {
        for(long c = 1; c <= k; c++) {
          long t = gcd(a, b);
          t = gcd(t, c);
          ans += t;
        }
      }
    }
    System.out.println(ans);
  }

  public static long gcd(long a, long b) {
    if(b == 0) return a;
    return gcd(b, (a % b));
  }
}

Measured memory_bytes: 35572
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long A, long long B, long long K){
  long long a, b;
  a = max(0LL, A - K);
  b = max(0LL, B + min(0LL, A - K));
  std::cout << a << " " << b << std::endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long K;
  scanf("%lld",&K);
  solve(A, B, K);
  return 0;
}


Measured memory_bytes: 888
#include<cstdio>

#define NUM 6

int main()
{
	int n;
	scanf("%d", &n);

	bool spade[13] = {false};
	bool hart[13] = {false};
	bool club[13] = {false};
	bool dia[13] = {false};

	char suit;
	char str[NUM];
	int rank = 0;

	getchar();

	for (int id = 0; id < n ; id++) {

		
		fgets(str, NUM, stdin);
		sscanf(str, "%c %d", &suit, &rank);

		//printf("%s suit = %c, id = %d, rank = %d\n", str, suit,id,rank);

		switch (suit) {
			case 'S':
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						spade[i] = true;
				}
				break;
			case 'H':
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						hart[i] = true;
				}
				break;
			case 'C':
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						club[i] = true;
				}
				break;
			case 'D':
				for (int i = 0; i < 13; i++) {
					if (i+1 == rank)
						dia[i] = true;
				}
				break;
			default:
				//printf("\n");
				//printf("###%s###", str);
				//printf("\n");
				break;
		}
	}

	for (int i = 0; i < 13; i++) {
		if (spade[i] == false)
			printf("S %d\n",i+1);
	}
	for (int i = 0; i < 13; i++) {
		if (hart[i] == false)
			printf("H %d\n",i+1);
	}
	for (int i = 0; i < 13; i++) {
		if (club[i] == false)
			printf("C %d\n",i+1);
	}
	for (int i = 0; i < 13; i++) {
		if (dia[i] == false)
			printf("D %d\n",i+1);
	}	
	return 0;
}


Measured memory_bytes: 2756
import java.util.HashSet;
import java.util.Scanner;

class Main{
  public static void  main(String[]args){
    
    Scanner  sc=new Scanner(System.in);
    
    HashSet<String> hs=new HashSet<String>();
    
    int n=sc.nextInt();
    for(int i=0;i<n;i++)
      hs.add(sc.next());
    
    System.out.println(hs.size());
      
  }
}



Measured memory_bytes: 76716
#include<stdio.h>
int main(void)
{
  int n[4];
  int sum=0;

  for(int i=0;i<4;i++){
    scanf("%d",&n[i]);
  }

  int flag1=0,flag2=0,flag3=0,flag4=0;

  for(int i=0;i<4;i++){
    if(n[i]==1)flag1++;
    if(n[i]==7)flag2++;
    if(n[i]==9)flag3++;
    if(n[i]==4)flag4++;
  }
  if(flag1==1&&flag2==1&&flag3==1&&flag4==1){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;
const int maxv = 1e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, W;
    cin>>n>>W;
    vi weight(n), val(n);
    for(int i=0; i<n; i++) {
        cin>>weight[i]>>val[i];
    }
    vvi dp(n, vi(maxv+1, inf));
    // for(int v=0; v<=maxv; v++) {
    //     if(w < weight[0]) {
    //         dp[0][w] = 0;
    //     }
    //     else {
    //         dp[0][w] = val[0];
    //     }
    // }
    dp[0][val[0]] = weight[0];
    dp[0][0] = 0;

    for(int i=1; i<n; i++) {
        dp[i][0] = 0;
        for(int v=1; v<=maxv; v++) {
            if(val[i] > v) {
                dp[i][v] = dp[i-1][v];
            }
            else {
                dp[i][v] = min(dp[i-1][v], dp[i-1][v-val[i]] + weight[i]);
            }
        }
    }
    for(int v = maxv; v>=0; v--) {
        if(dp[n-1][v]<=W) {
            cout << v << "\n";
            return 0;
        }
    }
    // watch(dp[n-1]);
    // watch(dp[n-1][5]);
    return 0;
}



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

int main(){
	int n, score_t = 0, score_h = 0;
	string taro, hanako;
	
	cin>>n;

	for(int i =0; i < n; i++){
		cin>>taro>>hanako;
		if(taro == hanako) {
			score_t++;
			score_h++;
		} else if(taro > hanako) score_t += 3;
		else score_h += 3;
	}
	
	cout<<score_t<<" "<<score_h<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define M 131
using namespace std;
typedef unsigned long long ull;

int main(){
  string t,p;
  ull a=0,b=0,c=1;
  cin>>t>>p;
  ull tlen=t.size();
  ull plen=p.size();
  //t??¨p?????????????????°?????§??¨??£???????????????0????????????????????????????????????????¨???????
  //a??¨b???????????§????????§???a????????????????±???§???????????????????????????c??????????????´??????????????????????????????????????????????????????
  //c?????????????????????????????§?¨??????????????????????????????????
  for(int i=0;i<plen;i++)a=a*M+p[i];
  for(int i=0;i<plen;i++)b=b*M+t[i],c*=M;
  if(a==b)cout<<0<<endl;
  for(int i=plen;i<tlen;i++){
    //b??????????????§??????????????????????????????????????????????????°??????????????????????????§??????M?????????????????????????????°??????????????£?????????????????????
	b=b*M+t[i]-c*t[i-plen];
    if(a==b)printf("%d\n",i-plen+1);
  }
  return 0;
}

Measured memory_bytes: 3904
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 1e3;

void solve() {
    int n;
    cin >> n;
    while (n) {
        if (n % 10 == 7) {
            cout << "Yes";
            return;
        }
        n /= 10;
    }
    cout << "No";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

Measured memory_bytes: 3640
A, B, K = map(int, input().split())
ans = 1
k = 0
l = []
while True:
    if A % ans == 0 and B % ans == 0:
        l.append(ans)
        k += 1
    #if k == K:
    #    break
    ans += 1
    if ans > A  or ans > B:
        break

print(l[-K])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int e = sc.nextInt();
				if(e == 0) break;
				
				int min = Integer.MAX_VALUE;
				for(int z=0; z<1000000; z++) {
					if(z > e) break;
					for(int y=0; y<=1000000; y++) {
						if(z*z*z+y*y > e || min <= z+y) break;
						int x = e - y*y - z*z*z;
						min = Math.min(x+y+z, min);
					}
				}
				System.out.println(min);
			}
		}
	}
}


Measured memory_bytes: 33464
#include<iostream>
using namespace std;
int main(){
int n,x,c=0,q=1;
cin>>n>>x;
int l[n];
for(int a=0;a<n;a++){
cin>>l[a];
c+=l[a];
if(c<=x)q++;
}
cout<<q;
return 0;
}


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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;

  cin >> s;

  int n = s.size();

  for(int i=0;i<n;i++) {
    for(int j=i;j<=n;j++){
      auto t = s.substr(0, i) + s.substr(j, n-j);
      if (t == "keyence") {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll n, m, t, a[MAXN];
string s;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> s)
		cout << (n >= 3200 ? s : "red") << endl;
}
/*
3200
pink

3199
pink

4049
red
*/

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N-1):
    ans+=B[int(A[i])-1]
    if int(A[i])+1==int(A[i+1]):
        ans+=C[int(A[i])-1]
print(ans+B[int(A[N-1])-1])

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

int main() {
	string str;
	cin >> str;
	if (str.size()==2) {
		cout << str << endl;
	} else {
		reverse(str.begin(), str.end());
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 100000000
#define NUM 1000000007
#define all(x) begin(x), end(x)

int main() {
	int n;
	cin >> n;
	VI a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	int s = 0;
	ll tate=0, yoko=0;
	int cnt = 0;
	for (int i = n - 1; i > 0; i--) {
		if (a[i] == a[i - 1]) cnt++;
		else cnt = 0;

		if (a[i] == a[i - 1] && tate==0) {
			tate = a[i];
		}else if (a[i] == a[i - 1] && tate != 0 ) {
			yoko = a[i];
			if (tate == a[i] && cnt < 3) {
				yoko = 0;
			}
		}
		if (tate != 0 && yoko != 0) break;
	}
	cout << tate * yoko << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String U = sc.next();

        if (S.equals(U)) {
            System.out.println((A-1)+" "+B);
        } else {
            System.out.println(A+" "+(B-1));
        }
    }
}



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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> num(5,-1);
	for(int i=0;i<m;i++){
		int s;
		cin >> s;
		int c;
		cin >> c;
		if(num[s] != -1 && num[s] != c){
			cout << -1 << endl;
			return 0;
		}
		num[s] = c;
	}
	int ans = 0;
	if(n == 3){
		for(int i=1;i<n+1;i++){
			if(i==1 && num[i] == 0){
				cout << -1 << endl;
				return 0;
			}
			if(i==1 && num[i] == -1){
				num[1] = 1;
			}
			if(i!=1 && num[i] == -1){
				num[i] = 0;
			}
			if(i==1) ans += num[1] * 100;
			if(i==2) ans += num[2] * 10;
			if(i==3) ans += num[3];
		}
	}else if(n == 2){
		if(num[1] == 0){
			cout << -1 << endl;
			return 0;
		}
		if(num[1] == -1){
			num[1] = 1;
		}
		if(num[2] == -1){
			num[2] = 0;
		}
		ans += num[1] * 10;
		ans += num[2];
	}else{
		if(num[1] == -1){
			cout << 0 << endl;
		}else{
			cout << num[1] << endl;
		}
		return 0;
	}
	cout << ans << endl;
	return 0;
}


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

const int mod = 998244353;

template <int Modulus>
struct modint {
    ll x;  // typedef long long ll;
    modint(ll x = 0) : x((x % mod + mod) % mod) {}
    modint operator-() const { return modint(-x); }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint pow(ll t) const {
        if (!t) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    modint inv() const { return pow(mod - 2); }
    modint& operator/=(const modint a) { return *this *= a.inv(); }
    modint operator/(const modint a) const { return modint(*this) /= a; }
};
template <int Modulus>
istream& operator>>(istream& is, modint<Modulus>& a) {
    return is >> a.x;
}
template <int Modulus>
ostream& operator<<(ostream& os, const modint<Modulus>& a) {
    return os << a.x;
}

signed main() {
    using mint = modint<mod>;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<mint>> dp(c + 1, vector<mint>(d + 1, 0));
    dp[a][b] = 1;
    for (int i = a; i <= c; ++i)
        for (int j = b; j <= d; ++j) {
            if (i == a && j == b) continue;
            // A or B = A + B - (A and B)
            dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i -
                       dp[i - 1][j - 1] * (i - 1) * (j - 1);
        }
    cout << dp[c][d] << endl;
}

Measured memory_bytes: 73700
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int n, k;
	cin >> n >> k;
	cout << min(n % k, k - n % k) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
         
        #define F first
        #define S second
        #define MP make_pair
        #define pb push_back
        #define all(a) a.begin(), a.end()
        #define rall(a) a.rbegin(), a.rend()
        #define LCM(a, b) (a) / __gcd((a), (b)) * (b)
        #define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
        #define ln '\n'
         
        using namespace std;
        using LL = long long;
        using ldouble = long double;
        using P = pair<int, int>;
        using LP = pair<LL, LL>;
         
        static const int INF = INT_MAX;
        static const LL LINF = LLONG_MAX;
        static const int MIN = INT_MIN;
        static const LL LMIN = LLONG_MIN;
        static const int MOD = 1e9 + 7;
        static const int SIZE = 200005;
         
        const int dx[] = {0, -1, 1, 0};
        const int dy[] = {-1, 0, 0, 1};
         
        vector<LL> Div(LL n) {
            vector<LL> ret;
            for(LL i = 1; i * i <= n; ++i) {
                if(n % i == 0) {
                    ret.pb(i);
                    if(i * i != n) ret.pb(n / i);
                }
            }
            sort(all(ret));
            return ret;
        }
         
        int main() {
            ios::sync_with_stdio(false);
            cin.tie(0);
         
            int d, n;
            cin >> d >> n;
            int c = 0;
            for(int i = 1; i <= 5000000; ++i) {
                int t = i;
                bool f = true;
                int ct = d;
                while(ct > 0) {
                    if(t % 100 != 0) f = false;
                    t /= 100;
                    --ct;
         
                }
                if(f && t % 100 != 0) ++c;
                if(c == n) {
                    cout << i << endl;
                    return 0;
                }
            }
            return 0;
        }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
	int N,Wcnt=0,Rcnt=0;
	string s;
	cin>>N;
    cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='W'){
          Wcnt++;
        }
    }
	for(int i=N-1;i>=N-Wcnt;i--){
		if(s[i]=='R'){
			Rcnt++;
        }
    }
	printf("%d\n",Rcnt);
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i=0; i<m; i++){
        cin >> a[i];
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    if(n - sum < 0){
        cout << -1 << endl;
        return 0;
    }
    cout << n - sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#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() {
   string s;
   cin >> s;

   int ans = 0;

   rep(i, 4) {
       if (s[i] == '+') {
           ans++;
       } else {
           ans--;
       }
   }

   cout << ans << endl;
}

Measured memory_bytes: 256