akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int n, m;
vvi g;

void dfs(int v, int prev, int color, vi &used, vvi &g, bool &can) {
	used[v] = color;
	for (auto u : g[v]) {
		if (u == prev) {
			continue;
		}

		if (used[u] == -1) {
			dfs(u, v, 1 - color, used, g, can);
		} else if (used[u] != 1 - color) {
			can = true;
		}
	}
}

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

	cin >> n >> m;

	g.resize(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	vi used(n, -1);
	bool can = false;

	dfs(0, -1, 0, used, g, can);

	ll res = 0;
	if (can) {
		res = (ll)n * (n - 1) / 2;
	} else {
		int black = 0;
		for (int i = 0; i < n; i++) {
			black += used[i];
		}
		res = (ll)black *  (n - black);
	}

	cout << res - m << endl;
	return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string s;
	string A = "CODEFESTIVAL2016";
	int x = 0;
	cin >> s;
	rep(i, 16) {
		if (s[i] != A[i])
			x++;
	}
	cout << x << endl;
}

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

long int ar[100][3];
typedef long long ll;

int main()
{
    //FASTIO
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n,m;
    cin >> n >> m;
    int z = max(n,m);

    for(long int i=0; i<=z; i++){
        for(long int j=0; j<=i && j<3; j++){
            if(j==0 || i==j){ar[i][j]=1; continue;}
            ar[i][j] = ar[i-1][j-1] + ar[i-1][j];
        }
    }
    ll ans = 0;
    if(n>=2){
        ans += ar[n][2];
    }
    if(m>=2){
        ans += ar[m][2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,x;
    cin>>n>>x;
    if(x==1||x==2*n-1) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        n=2*n-1;
        vector<int> ans(n);
        ans[n/2-1]=x-1;
        ans[n/2]=x;
        ans[n/2+1]=x+1;
        
        int now=1;
        rep(i,0,n){
            if(n/2-1<=i && i<=n/2+1) continue;
            while(x-1<=now && now<=x+1) now++;
            ans[i]=now;
            now++;
        }
        rep(i,0,n) cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 128;

vector <int> adj[MAX];
int d[MAX];

void solve(void){
	ENJYU;
	int N;
	cin >> N;
	rep(N, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, i) {
			int v;
			cin >> v;
			v--;
			adj[u].pb(v);
		}
	}
	memset(d, -1, sizeof(d));
	queue <int> q;
	q.push(0);
	d[0] = 0;
	while (!q.empty()) {
		int n = q.front();
		q.pop();
		for (int nv : adj[n]) {
			if (d[nv] >= 0) {
				d[nv] = min(d[nv], d[n] + 1);
				continue;
			}
			d[nv] = d[n] + 1;
			q.push(nv);
		}
	}

	rep(N, i) cout << i+1 << ' ' << d[i] << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



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

  int N  ;
  cin >> N ;
  vector<int> A(N);
  int dp[100100] = {0};
  rep(i,N) cin >> A.at(i) ;
  dp[0] = 0 ;
  dp[1] = abs( A.at(1) - A.at(0) );
  //dp[i] = i番目の段に行くまでの最小値
  for(int i = 2 ; i < N ; i++ ) {
    dp[i]= min ( dp[i-1] + abs( A.at(i) - A.at(i-1) ) , dp[i-2] + abs ( A.at(i) - A.at(i-2) ) ) ;
  }
  cout << dp[N-1] ;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
int a[211111];
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	int rig=0,sum=0,xorsum=0;
	for(int lef=0;lef<n;lef++){
		while(rig<n && (sum+a[rig]==(xorsum^a[rig]))){
			sum+=a[rig];
			xorsum^=a[rig];
			rig++;
		}
		ans+=rig-lef;
		if(lef==rig)rig++;
		else{
			sum-=a[lef];
			xorsum^=a[lef];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Wed Mar 18 20:16:45 JST 2020
 **/

signed main() {
    Int n, D;
    cin >> n >> D;
    vector<vector<Int>> X(n, vector<Int>(D));
    REP(i, n) REP(j, D) cin >> X[i][j];
    Int ans = 0;
    REP(i, n) {
        REP(j, i) {
            Int acc = 0;
            REP(k, D) {
                Int d = X[i][k] - X[j][k];
                acc += d * d;
            }
            Int sq = sqrt(double(acc)) + 0.5;
            ans += sq * sq == acc;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    vector<int> ans(4);
    int N;
    cin >> N;
    REP(i, N) {
        string s;
        cin >> s;
        if (s == "AC") {
            ans[0]++;
        } else if (s == "WA") {
            ans[1]++;
        } else if (s == "TLE") {
            ans[2]++;
        } else {
            ans[3]++;
        }
    }
    printf("AC x %d\n", ans[0]);
    printf("WA x %d\n", ans[1]);
    printf("TLE x %d\n", ans[2]);
    printf("RE x %d\n", ans[3]);
    
    return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[1050] = {}, f[100010];
double syo = 0, su = 0;
long long mur, kmr, yju, counto = 0,counto1=0;
char mado[105];
string rik;
bool mazi[110], gi[110],zi,manji;
pair<int, int>n[110];
vector<int> aa,bb,cc;
map<int, int>kazu;
int main() 
{
	
	cin >> a >> b;
	if (b%a == 0) {
		cout << a + b << endl;
	}
	else { cout << b - a << endl; }
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int[] prime = new int[51000];
		for (int i = 0; i < prime.length; i++) {
			prime[i] = 1;
		}
		
		for (int i = 2; i < (prime.length / 2); i++) {
			for (int j = 2; (i * j) < prime.length; j++) {
				prime[i * j] = 0;
			}
		}
		prime[0] = 0;
		prime[1] = 0;
		prime[2] = 1;
		
		while (sc.hasNextLine()) {
			int num = Integer.parseInt(sc.nextLine());
			
			int tmp = num - 1;
			while (prime[tmp] == 0) {
				tmp = tmp - 1;
			}
			System.out.print(tmp + " ");
			
			tmp = num + 1;
			while (prime[tmp] == 0) {
				tmp = tmp + 1;
			}
			System.out.println(tmp);
		}
	}
}

Measured memory_bytes: 26188
from itertools import groupby

N,K = map(int,input().split())
S = input()
cntS = []
sum_num = 0
for key, elems in groupby(S):
  num = len(list(elems))
  sum_num += num
  cntS.append([key,num,sum_num])
len_cntS = len(cntS)  

cnt0 = []
for i in range(len_cntS):
  key, num, sum_num = cntS[i]
  if key == '0':
    cnt0.append([i,num,sum_num])
  i += 1
  
if len(cnt0) <=K:
  print(N)
else:
  len_cnt0 = len(cnt0)
  ans = -float('inf')
  for i in range(-1,len_cnt0-K):
    if i == -1:
      tmp_ans = cnt0[i+K][2]
      if cnt0[i+K][0]+1 < len_cntS:
        tmp_ans += cntS[cnt0[i+K][0]+1][1]
    else:
      tmp_ans = cnt0[i+K][2]-cnt0[i][2]
      if cnt0[i+K][0]+1 < len_cntS:
        tmp_ans += cntS[cnt0[i+K][0]+1][1]
    ans = max(ans,tmp_ans)
    #print(i,i+K,ans)
  print(ans)

Measured memory_bytes: 70108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var cards = Console.ReadLine();
                if (cards == "-")
                {
                    return;
                }

                var times = 0;
                {
                    var input = Console.ReadLine();
                    times = int.Parse(input);
                }

                for (var i = 0; i < times; ++i)
                {
                    var input = Console.ReadLine();
                    var h = int.Parse(input);
                    cards = cards.Substring(h) + cards.Substring(0, h);
                }

                Console.WriteLine(cards);
            }
        }
    }
}

Measured memory_bytes: 5308
import bisect

k = int(input())

def runrun(n):
    str_n = str(n)
    for i in range(len(str_n)-1):
        if abs(int(str_n[i]) - int(str_n[i+1])) > 1:
            return False
    return True

def build_runrun(d):
    r = ["0","1","2","3","4","5","6","7","8","9"]
    ans = []
    for i in r:
        if i == "0":
            continue
        queue = [[i,1,i]]
        while queue != []:
            q = queue.pop(0)
            if q[1] > d:
                continue
            if q[1] == d:
                bisect.insort(ans,int(q[2]))
                continue

            queue.append([q[0],q[1]+1,q[2]+q[0]])

            low = int(q[0])-1
            if low >= 0:
                queue.append([str(low),q[1]+1,q[2]+str(low)])
            high = int(q[0])+1
            if high < 10:
                queue.append([str(high),q[1]+1,q[2]+str(high)])

    return ans

run = []
d = 1
while len(run) < k:
    run.extend(build_runrun(d))
    d+=1

print(run[k-1])


Measured memory_bytes: 21008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fcout cout << fixed << setprecision(18)

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

  double pi = 3.14159265358979;
  double A, B; cin >> A >> B;
  double H, M; cin >> H >> M;
  double t = 30.0 * H - 11.0 * M / 2.0;
  double c2 = A * A + B * B - 2 * A * B * cos(t * pi / 180.0);
  double c = sqrt(c2);
  
  fcout << c;
  return 0;
}

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

n = int(input())
a = [int(x) for x in input().split()]

ret = [0,0]
sum = [0,0]

if a[0]==0:
    sum[0] = 1
    ret[0] = 1
    sum[1] = -1
    ret[1] = 1
elif a[0]>0:
    sum[0] = a[0]
    sum[1] = -1
    ret[1] = a[0]+1
else:
    sum[0] = 1
    ret[0] = -1*a[0]+1
    sum[1] = a[0]

for i in range(1,n):
    for j in range(2):
        if sum[j]*(sum[j]+a[i])<0:
            sum[j] += a[i]
        elif sum[j]+a[i]==0:
            if sum[j]>0:
                sum[j] = -1
            else:
                sum[j] = 1
            ret[j] += 1
        elif sum[j]+a[i]>0:
            ret[j] += sum[j]+a[i]+1
            sum[j] = -1
        else:
            ret[j] += -1*(sum[j]+a[i])+1
            sum[j] = 1

print(min(ret[0],ret[1]))


Measured memory_bytes: 14332
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
void trace(int N, int A[]) {
    for(int i = 0; i < N; i++) {
        if(i >= 1) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void swap(int a[], int n1, int n2) {
    int temp = a[n1];
    a[n1] = a[n2];
    a[n2] = temp;
}

int bubble_sort(int n, int a[]) {
    int count=0;
    for(int i = 0; i < n - 1; i++) {
        for(int j = n - 1; i < j; j--) {
            if(a[j - 1] > a[j]) {
                swap(a, j, j - 1);
                count++;
            }
        }
    }
    return count;
}

int main() {
    int N,count;
    cin >> N;
    int data[N];
    for(int i = 0; i < N; i++)
        cin >> data[i];
    count = bubble_sort(N, data);
    trace(N, data);
    cout << count << endl;
    return 0;
}


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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    int sum = 0, cnt = 0;
    for(int i = 0; i < n; i++) {
        if(sum + v[i] < k) {
            sum += v[i];
            cnt++;
        }
        else {
            cnt = 0;
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype> // isdigit
#include<cassert> // assert
using namespace std;

struct Result{int value,pos;};

int calculate(string expression);
Result equation(string expression,int pos);
Result factor(string expression,int pos);
Result term(string expression,int pos);

int calculate(string expression)
{
  return equation(expression,0).value;
}

Result equation(string expression,int pos)
{
  Result r=factor(expression,pos);
  // Á¸Z
  while(expression[r.pos]=='+' || expression[r.pos]=='-'){
    Result _r=factor(expression,r.pos+1);
    if(expression[r.pos]=='+')r.value += _r.value;
    if(expression[r.pos]=='-')r.value -= _r.value;
    r.pos=_r.pos;
  }
  return r;
}
Result factor(string expression,int pos)
{
  Result r=term(expression,pos);
  // æZ
  while(expression[r.pos]=='*' || expression[r.pos]=='/'){
    Result _r=term(expression,r.pos+1);
    if(expression[r.pos]=='*')r.value *= _r.value;
    if(expression[r.pos]=='/')r.value /= _r.value;
    r.pos=_r.pos;
  }
  return r;
}
Result term(string expression,int pos)
{
  Result r;
  // l
  if(isdigit(expression[pos])){
    int value=0;
    while(isdigit(expression[pos]))value = value*10 + expression[pos++]-'0';
    r.value=value;
    r.pos=pos;
    return r;
  }
  // PZqÌ}CiX
  if(expression[pos]=='-'){
    r=equation(expression,pos+1);
    r.value*=-1;
    return r;
  }
  // Ê
  if(expression[pos]=='('){
    r=equation(expression,pos+1);
    assert(expression[r.pos++]==')');
    return r;
  }
}

int main()
{
  int n;
  string s;
  cin>>n;
  while(n-->0){
    cin>>s;
    s=s.substr(0,s.size()-1);
    cout<<calculate(s)<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> m(N, 0);
    for(auto &x : a) cin >> x;
    int d = *max_element(WHOLE(a)) + 1;
    bool ans = true;
    for(int i = 0; i < N; i++) {
        m[a[i]]++;
    }
    for(int i = 0; i < d; i++) {
        if(i < d / 2) {
            ans &= m[i] == 0;
        } else if(i == d / 2) {
            if(d % 2 == 0) {
                ans &= m[i] == 2;
            } else {
                ans &= m[i] == 1;
            }
        } else if(i > d / 2) {
            ans &= m[i] >= 2;
        }
    }
    cout << (ans ? "Possible" : "Impossible") << endl;
    return 0;
}

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

int main(){
    int x,y;
    cin >> x >> y;

    for(int i=0;i<=x;i++){
        int ytmp = 2*i + 4*(x-i);
        if( ytmp==y ){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
 
#define LL long long
 
int main(){
	int A, B;
	cin >> A >> B;

	if(A == B) cout << "Draw" << endl;
	else if (B == 1) cout << "Bob" << endl;
	else {
		if (A == 1) cout << "Alice" << endl;
		else if (A > B) cout << "Alice" << endl;
		else cout << "Bob" << endl;
	}	
}


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

int main() {
    string s;
    cin >> s;
    
    int n = s.size();
    int ch[26] = {0};
    for(int i = 0; i < n; ++i) {
        ch[s[i]-'a']++;
    }
    
    bool NotFound = true;
    char ans;
    for(int i = 0; i < 26; ++i) {
        if(ch[i] == 0) {
            ans = 'a' + i;
            NotFound = false;
            break;
        }
    }
    
    if(NotFound) cout << "None" << endl;
    else cout << ans << endl;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

int main(){
	string s;
	cin>>s;
	int k=read();
	for(auto& c:s){
		if(c=='a')
			continue;
		int p='z'+1-c;
		if(p<=k){
			c='a';
			k-=p;
		}
	}
	int l=s.size();
	s[l-1]='a'+(s[l-1]-'a'+k)%26;
	cout<<s<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>

#define N 103
#define INF 10000000
#define NIL -1
#define BLACK 1

int G[N][N];

int d[N],pi[N],color[N];
int ci[N];
int v[N];

int num;

void initialize(int);
void dij(int);

int main(){
  int i,j;
  int k,u;
  int start=0;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      G[i][j] = NIL;
    }
  }
  

  for(i=0;i<num;i++){
    scanf("%d%d",&u,&k);
      for(j=0;j<k;j++){
	scanf("%d%d",&v[j],&ci[j]);
	G[u][v[j]] = ci[j]; 
      }
  }

  dij(start);

  /*for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      printf("%d ",G[i][j]);
    }
    printf("\n");
  }
  */

  for(i=0;i<num;i++){
    printf("%d %d\n",i,d[i]);
  }
  
  return 0;

}

void initialize(int s){
  int v;
  for(v=0;v<num;v++){
    d[v] = INF;
    pi[v] = NIL;
  }

  d[s] = 0;
}

void dij(int s){
  int mincost;
  int i,v,u;
  
  initialize(s);

  while(1){
    
    mincost = INF;

    for(i=0;i<num;i++){
      
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;

      }
    }

    //printf("u=%d\n", u);
    if(mincost == INF) break;

    color[u] = BLACK;
    
    for(v=0;v<num;v++){
      
      if(G[u][v] == -1) continue;
      if(color[v] != BLACK && d[u] + G[u][v] < d[v]){
	pi[v]= u;
	d[v] = d[u] + G[u][v];
      }
    }
  }
}
	



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long longest = -1;
  long long n;
  cin >> n;
  for (int i = 0; i < 5; i++) {
    long long x;
    cin >> x;
    longest = max(longest, (n - 1) / x);
  }
  cout << longest + 5 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int d,i,j=0,s[24]={0};
  while(scanf("%d",&d)!=-1) {
    for(i=d;i<600;i+=d) s[j]+=i*i*d;
    j++;
  }
  for(i=0;i<j;i++)printf("%d\n",s[i]);
  return 0;
}

Measured memory_bytes: 596
function main()
  
  N = parse(Int, readline())
  a = map(x -> parse(Int, x), split(readline()))
  
  ans = 10^10
  
  for i in -100:100
    check = 0
    for j in a
      check += (i - j)^2
    end
    ans = min(ans, check)
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 167976
#include<iostream>
#include<queue>
#include<string>
#include<list>
using namespace std;
typedef long long ll;

const int MAXI = 1024;

ll a[MAXI];

int main() {

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll sum1 = 0, sum2 = 0;
	for (int i = 0; i < n; i += 2) {
		sum1 += (a[i] > 0) ? a[i] : 0LL;
	}
	for (int i = 1; i < n; i += 2) {
		sum2 += (a[i] > 0) ? a[i] : 0LL;
	}

	vector<int> ans;
	ll sum = 0;
	int startInd = 0;
	if (sum1 > sum2 || (sum1 == sum2 && sum1 > 0))
		sum = sum1;
	else if (sum2 > sum1) {
		sum = sum2;
		startInd = 1;
		ans.push_back(1);
	}
	else {
		ll maxInd = 0;
		for (int i = 1; i < n; i++) {
			maxInd = (a[maxInd] > a[i]) ? maxInd : i;
		}
		cout << a[maxInd] << endl;
		cout << n - 1 << endl;
		for (int i = 0; i < maxInd; i++)
			cout << "1" << endl;
		for (int i = n - 1; i > maxInd; i--)
			cout << i - maxInd + 1 << endl;
		return 0;
	}

	list<ll> l;
	cout << sum << endl;
	for (int i = startInd; i < n; i++) {
		l.push_back(a[i]);
	}
	if (l.size() % 2 == 0) {
		ans.push_back(l.size());
		l.pop_back();
	}
	while (l.size() > 1) {
		int curPos = 1;
		for (auto it = l.begin(); it != l.end() && l.size() > 1;) {
			if (it == l.begin() && (*it) <= 0) {
				ans.push_back(1);
				ans.push_back(1);
				l.pop_front();
				l.pop_front();
				it = l.begin();
			}
			else if (it == (--(l.end()))) {
				if ((*it) <= 0) {
					ans.push_back(l.size());
					l.pop_back();
					ans.push_back(l.size());
					l.pop_back();
					it = (--(l.end()));
					curPos = l.size();
				}
				else
					it++;
			}
			else if ((*it) <= 0) {
				ans.push_back(curPos);
				auto tempIt1 = it;
				auto tempIt2 = it;
				it--;
				tempIt2++;
				l.erase(tempIt1);
				l.erase(tempIt2);
				it++;
			}
			else {
				auto tempIt1 = it;
				auto tempIt2 = it;
				tempIt1++;
				tempIt2++;
				tempIt2++;
				if ((*tempIt2) > 0 && (*it) > 0) {
					ans.push_back(curPos + 1);
					l.erase(tempIt1);
					l.erase(tempIt2);
				}
				else {
					curPos += 2;
					it++;
					it++;
				}
			}
		}
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n,a,b;
vector<ll> h;

bool check(ll x){
  ll res = 0;
  for(ll i=0;i<n;i++){
    ll tmp = h[i] - b*x;
    if(tmp > 0){
      res += (tmp - 1) / (a - b) + 1;
    }
  }
  if(res <= x){
    return true;
  }else{
    return false;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  h.resize(n);
  for(ll i=0;i<n;i++){
    cin >> h[i];
  }
  ll ok = INF;
  ll ng = 0;
  while(ok-ng>1){
    ll mid = (ok+ng)/2;
    if(check(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  String s = sc.next();
	  
	  if (s.charAt(a) != '-') {
		  System.out.println("No");
		  System.exit(0);
	  }
	  
	  for (int i = 0; i < s.length(); i++) {
		  if (i != a) {
			  if (!Character.isDigit(s.charAt(i))) {
				  System.out.println("No");
				  System.exit(0);
			  }
		  }
	  }
	  System.out.println("Yes");
	  System.exit(0);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 21460
N, M, X = map(int, input().split())
CA = [] * N
for _ in range(N):
    CA.append([int(s) for s in input().split()])

ans = -1
for bits in range(2 ** N):
    cost = 0
    param = [0] * M
    for i in range(N):
        if (bits >> i) & 1 == 1:
            cost += CA[i][0]
            for j in range(M):
                param[j] += CA[i][j + 1]

    if min(param) >= X:
        ans = min(ans, cost) if ans != -1 else cost

print(ans)


Measured memory_bytes: 9204
#include <stdio.h>
#include <stdlib.h>

int main() {

	char c[4][4];

	for (int i = 0; i < 2; i++) {
		scanf("%s", &c[i]);
	}

	if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) printf("YES");
	else printf("NO");

	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,m;
    Scd2(n,m);

    bool red[100004] = {};
    red[1] = true;
    int ob[100004] = {};
    fill(ob,ob+100004,1);
    int l,r;
    Rep(i,m){
        Scd2(l,r);
        if( red[l] ) red[r] = true;
        ob[l]--;
        ob[r]++;
        if( ob[l] == 0) red[l] = false;
    }

    int ans = 0;
    Rep(i,n+1){
        if(red[i]) ans++;
    }

    printf ("%d\n", ans);


    return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;

const int N = (int)1e5+5;

void solve() {
  int n;
  cin>>n;
  int notes = (n + 999) / 1000;
  cout << 1000 * notes - n;
}

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

    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++) {
      //cout<<"Case #"<<i<<": ";
      solve();
      cout<<"\n";
    }
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool p[10];

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

	int N, M; cin >> N >> M;
	vector<vector<int>> V(M);
	for (int i = 0; i < M; i++) {
		int num; cin >> num;
		for (int j = 0; j < num; j++) {
			int tmp; cin >> tmp;
			V[i].push_back(tmp);
		}
	}
	for (int i = 0; i < M; i++) cin >> p[i];

	int ans = 0;
	int up = 1;
	for (int i = 0; i < N; i++) up *= 2; // スイッチのパターンは全部で2^N
	for (int i = 0; i < up; i++) {
		vector<bool> swi; // light[k] : k番目のスイッチが入っている
		swi.push_back(0);
		int tmp = i;
		for (int i = 0; i < N; i++) {
			swi.push_back(tmp % 2);
			tmp /= 2;
		}
		//for(int i=0;i<)

		bool flag = true;
		for (int j = 0; j < M && flag; j++) {
			int cnt = 0;
			for (int k = 0; k < V[j].size(); k++) cnt += swi[V[j][k]];
			bool res = cnt % 2;
			if (p[j] != res) flag = false;
		}

		if (flag) ans++;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a;

int main(){
	cin >> n >> a;
	
	int cnt = 0, ans = INF, ans2 = INF;
	for(int i = a; i < n+a; i++){
		if(ans2 > abs(i)){
			ans = i;
			ans2 = abs(i);
		}
		cnt += i;
	}
	cout << cnt-ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b;cin>>a>>b;
  vector<ll>c(a);
  rep(i,a)cin>>c[i];
  rep(j,b){
    vector<ll>d(a+1);
    rep(i,a){
      ll e=max((ll)(0),i-c[i]),f=min(i+c[i]+1,a);
      d[e]++;d[f]--;
    }
    rep(o,a)d[o+1]+=d[o];
    d.pop_back();
    if(c==d)break;
    else c=d;
  }
  rep(i,a)cout<<c[i]<<endl;
}


Measured memory_bytes: 29860
using System;
class latte
{
    static void Main()
    {
        int[] V = new int[10];
        for (int i = 0; i < 10; i++)
        {
            V[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(V);
        Array.Reverse(V);
        for (int i = 0; i < 3; i++)
            Console.WriteLine(V[i]);
    }
    
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    itn a,b,c; cin>>a>>b>>c;

    int cnt = 0;
    
    while(1){
        
        if(a%2 == 1|| b%2 == 1|| c%2 == 1){
        cout<<cnt<<endl;
        return 0;
        }
        int tmpa = a/2,tmpb = b/2,tmpc = c/2;
        
        a = tmpb+tmpc, b=tmpa+tmpc, c = tmpa + tmpb;
        cnt++;
        if(cnt >50000000) {cout<<-1<<endl; return 0;}
    }
}


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

int main()
{
    int N, L;
    int A[100005];
    int pos = -1;

    cin >> N >> L;

    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for(int i = 0; i < N - 1; i++) {
        if(A[i] + A[i + 1] >= L) pos = i;
    }

    if(!~pos) cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        for(int i = 0; i < pos; i++) cout << i + 1 << endl;
        for(int i = N - 2; i > pos; i--) cout << i + 1 << endl;
        cout << pos + 1 << endl;
    }
    return (0);
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n; cin >> n;
    vector<P> v(n);
    int l = 0;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        l = max(l,b);
        v[i] = make_pair(b,a);
        sum += a;
    }
    sort(v.begin(),v.end());
    int tmp = 0;
    bool can = true;
    for(int i= 0; i < n; i++){
        tmp += v[i].second;
        if(tmp > v[i].first){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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


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

    int N,M;
    cin >> N >> M;
    int K[N];
    int A[N][M];
    rep(i,N){
        cin >> K[i];
        rep(j,K[i]){
            cin >> A[i][j];
        }
    }
    int ans=0;

 
    int count=0;
    rep(i,M){
        count=0;
        rep(j,N){
            rep(k,K[j]){
                if(A[j][k]==i+1){
                    count++;
                    break;
                }
            }
        }
        if(count==N) ans++;
    }
    cout << ans << endl;


}


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

int main(){
  string s, t;  cin >> s >> t;
  for(int i=s.size()-1; i+1>=t.size(); i--){
    bool ok = true;
    for(int j=t.size()-1; j>=0; j--){
      if(t[j] == s[i-(int)(t.size())+1+j] || s[i-(int)(t.size())+1+j] == '?'){
      }else{
	ok = false;
	break;
      }
    }
    if(ok){
      for(int j=0; j+t.size()<i+1; j++)  printf("%c", s[j]=='?' ? 'a' : s[j]);
      cout << t;
      for(int j=i+1; j<s.size(); j++)  printf("%c", s[j]=='?' ? 'a' : s[j]);
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE\n";
  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>


int main(void)
{
   
	int w,h,x,y,r;
   

	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
   

	if(0<=x-r && 0<=y-r && x+r<=w && y+r<=h)
 
 		printf("Yes\n");
  
	 else
    
		 printf("No\n");
  

	 return 0;

}


Measured memory_bytes: 2108
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

template<typename _T> void OutIter(_T beg, _T end, string separator = " ", bool eol = true) {
	cout << *beg;
	for (auto it = beg + 1; it != end; ++it) {
		cout << separator << *it;
	}
	if(eol)cout << endl;
}

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN_V(ll, bls, n - 1);

	vector<ll> als(n, 1000000);
	als[n - 1] = bls[n - 2];
	REPR(i, 1, n - 1) {
		als[i] = min({ bls[i], bls[i - 1], als[i] });
	}
	als[0] = bls[0];

	ll sum = 0;
	REP(i, 0, n)sum += als[i];

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s, t; cin >> s >> t;
    int sa[100001], ta[100001];
    sa[0] = 0; ta[0] = 0;
    for (int i = 0; i < s.size(); i++) sa[i+1] = sa[i] + (s[i] == 'A');
    for (int i = 0; i < t.size(); i++) ta[i+1] = ta[i] + (t[i] == 'A');
    int q; cin >> q;
    while (q--) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        cout << ((2*(b - a) - sa[b] + sa[a-1] - (2*(d - c) - ta[d] + ta[c-1])) % 3 == 0 ? "YES" :"NO") << endl;
    }
}


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

#define mod 1000000007
#define INF (ll)9999999999999999

#define add emplace
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for (int i = (int)a; i >= (int)b; --i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


#define rsum(i,j) pre[j]-(i>0?pre[i-1]:0)

int main() {

	int n;
	cin >> n;

	vi s1(n),s2(n),pre(n);
	rep (i, n) cin >> s1[i];
	rep (i, n) cin>>s2[i], pre[i]=s2[i]+(i>0?pre[i-1]:0);

	ll x = 0, y = 0, mx = -1;
	rep (i, n) {
		x += s1[i];
		y = rsum(i, n-1);
		mx = max(mx, x+y);
	}

	log(mx);

	return 0;
}





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

class Program{

  static int a, b, c, x, y, i, cost, cost2, answer;

  static int Main() {
    string[] nyu = new string[5];

    nyu = Console.ReadLine().Split(' ');
    a = int.Parse(nyu[0]);
    b = int.Parse(nyu[1]);
    c = int.Parse(nyu[2]);
    x = int.Parse(nyu[3]);
    y = int.Parse(nyu[4]);

    cost = a*x + b*y ;
    answer = cost;

    for (i = 1; i<=Math.Max(int.Parse(nyu[3]), int.Parse(nyu[4]))*2; i++){
      if(x > 0) x -= 1;
      if(y > 0) y -= 1;

      cost =  a*x + b*y + c*2*i;

      if(cost < answer){
       answer = cost;
      }else{
        break;
      }
    }

    Console.Write("{0}", answer);
    return 0;
  }

}


Measured memory_bytes: 13140
import math
import itertools
n = int(input())
lista = []
anslist = 0
for i in range(n):
    x, y = map(int, input().split())
    lista.append([x, y])
# permutasion 引数１つのみ
# len(lista)!通り出る
for i in itertools.permutations(lista):
    for j in range(n - 1):
        anslist += math.sqrt((i[j + 1][0] - i[j][0]) ** 2 + (i[j + 1][1] - i[j][1]) ** 2)
        #if i != j:
            #print([lista[i], lista[j]])
            #anslist += math.sqrt((lista[j][0] - lista[i][0]) ** 2 + (lista[j][1] - lista[i][1]) ** 2)
# math.factorial 階乗
print(anslist / math.factorial(n))

Measured memory_bytes: 40812
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BGraphPartition {
public:

    vector<int> graph[202];
    vector<int> color;
    bool possible = true;


    void dfs(int p, int c) {
      for(auto e: graph[p]) {
        if (color[e] == 0) {
          color[e] = -c;
          dfs(e, -c);
        } else if (color[e] != -c) {
          possible = false;
        }
      }
    }


    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      color.resize(n);
      int mat[n][n];

      rep(i, n) {
        rep(j, n) {
          char c; cin >> c;
          if (c=='1') {
            graph[i].push_back(j);
            mat[i][j] = 1;
          } else {
            mat[i][j] = INT_MAX/2;
          }
          if (i==j) mat[i][j] = 0;
        }
      }

      color[0] = 1;
      dfs(0, 1);
      if (!possible) {
        cout << -1 << endl;
        return;
      }

      rep(k, n) {
        rep(i, n) {
          rep(j, n) {
            chmin(mat[i][j], mat[i][k] + mat[k][j]);
          }
        }
      }

      int ans = 0;
      rep(i, n) {
        rep(j, n) {
          chmax(ans, mat[i][j]);
        }
      }
      cout << ans+1 << endl;
    }

};

signed main() {
  BGraphPartition solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,c,k;cin>>n>>c>>k;
  vector<int>T(n);
  for(int i=0;i<n;i++)
    cin>>T[i];
  sort(T.begin(),T.end());
  ll ans=0;
  for(int i=0;i<n;){
    int now=i+c-1;
    if(now>=n)now=n-1;
    while((T[now]-T[i]>k))
      now--;
    ans++;
    i=now+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int n,k,ans,cnt,tmp;
vector<set<Int> > G;
void dfs(Int x){
  //cout<<x<<endl;
  if(x==n)
    ans=min(ans,tmp);
  if(tmp>=ans) return;

  if(G[x].empty()){
    dfs(x+1);
    return;
  }
  
  if(tmp+1<ans&&G[x].size()>1u){
    vector<Int> v;
    for(Int u:G[x]){
      v.emplace_back(u);
      G[u].erase(x);
    }
    cnt++;
    tmp++;
    dfs(x+1);
    cnt--;
    tmp--;
    for(Int u:v){
      G[u].emplace(x);
    }
  }

  if(tmp+(Int)G[x].size()<ans){
    vector<Int> v;
    vector<set<Int> > S;
    for(Int u:G[x]){
      if(G[u].empty()) continue;
      v.emplace_back(u);
      S.emplace_back(G[u]);
      G[u].clear();
      cnt++;
      tmp++;
    }
    
    for(Int i=0;i<(Int)v.size();i++)
      for(int w:S[i]) G[w].erase(v[i]);
    
    cnt++;
    dfs(x+1);
    cnt--;
    
    for(Int i=0;i<(Int)v.size();i++){
      G[v[i]]=S[i];
      for(int w:G[v[i]]) G[w].emplace(v[i]);
      cnt--;
      tmp--;
    }
  }
  
};
signed main(){
  Int m,k;
  cin>>n>>m>>k;
  G.resize(n);
  for(Int i=0;i<m;i++){
    Int u,v;
    cin>>u>>v;
    u--;v--;
    G[u].emplace(v);
    G[v].emplace(u);
  }
  ans=k+1;
  cnt=tmp=0;
  dfs(0);
  if(ans<=k) cout<<ans<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}

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

int main(){
    int n,k; cin >> n >> k;
    vector<bool> ok(n,false);
    rep(i,k){
        int d; cin >> d;
        rep(j,d){
            int x; cin >> x;
            x--;
            ok[x] = true;
        }
    }
    int cnt = 0;
    rep(i,n) if(!ok[i]) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	int num,n_min,n_max,div,div_max,ans,pre,tmp;

	while(true){
		scanf("%d %d %d",&num,&n_min,&n_max);
		if(num == 0 && n_min == 0 && n_max == 0)break;

		div_max = -1;
		for(int i = 1; i <= num; i++){
			scanf("%d",&tmp);

			if(i >= n_min+1 && i <= n_max+1){
				div = pre - tmp;
				if(div >= div_max){
					div_max = div;
					ans = i-1;
				}
			}
			pre = tmp;
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 3160
D = input()
d1  = [raw_input().split() for i in range(input())]
p1  = sorted([int(i[1]) for i in d1 if i[0] == "D"])[::-1]
d2  = [raw_input().split() for i in range(input())]
p2  = sorted([int(i[1]) for i in d2 if i[0] == "DD"])[::-1]

ans = 0
for i in range(D+1):
	try:
		cur = sum(p1[:i]) + sum(p2[:(D-i)/2])
		ans = max(ans,cur)
	except:
		pass
print ans

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
ll gcd(ll a, ll b) { return (b > 0) ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a*b/gcd(a, b); }
using ipair = pair<ll, ll>;

int main()
{
  ll X, now=100, cnt=0;
  cin >> X;  
  while(now < X){
    now *= 1.01;
    ++cnt;
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 3612