akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>


using namespace std;


int main()
{

	string st;
	cin >> st;
	long answer = 0;

	for (long i = 0; i < st.size(); i++) {
		if ((i % 2 == 0) && (st.at(i) == '1')) answer++;
		if ((i % 2 == 1) && (st.at(i) == '0')) answer++;
	}
	if (answer > st.size() / 2) answer = st.size() - answer;

	cout << answer << endl;

    return 0;
}

Measured memory_bytes: 512
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=100010;

bool dp[85][85][13000];

void solve() {
    int h,w;
    cin>>h>>w;
    int a[h][w],b[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>b[i][j];
    }
    int g[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            g[i][j]=abs(a[i][j]-b[i][j]);
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0 && j==0) dp[0][0][g[0][0]]=true;
            if(i){
                for(int k=0;k<13000;k++){
                    if(dp[i-1][j][k]){
                        dp[i][j][abs(k+g[i][j])]=true;
                        dp[i][j][abs(k-g[i][j])]=true;  
                    }
                }
            }
            if(j){
                for(int k=0;k<13000;k++){
                    if(dp[i][j-1][k]){
                        dp[i][j][abs(k+g[i][j])]=true;
                        dp[i][j][abs(k-g[i][j])]=true;
                    }
                }
            }
        }
    }

    for(int k=0;k<13000;k++){
        if(dp[h-1][w-1][k]){
            cout<<k<<endl;
            return ;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 67700
using System;
using System.Linq;

class Program
{
	static void Main()
	{
		var input = Console.ReadLine().Split();
		var i = input.Select(s => int.Parse(s)).ToArray();

		if (i[0] < i[1] && i[1] < i[2])
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");
	}
}

Measured memory_bytes: 9296
#define _CRT_SECURE_NO_WARNINGS

#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a); }
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;//СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚
					//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 1e5 + 228;
const ll inf = 1e9;
const ld EPS = 1e-4;
const ld PI = acos(-1);
const int mod = (int)998244353;
//const int MOD = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ll MOD = 1000000007;
const int maxelem = 12000000;
const int fsconst = 12000;
int len(int n)
{
	int ans = 0;
	while (n)
	{
		ans++;
		n /= 10;
	}
	return ans;
}
signed main()
{
	fastio();
	int n;
	cin >> n;
	int aans = 0;
	for (int i = 1; i <= n; ++i)
	{
		aans += len(i) % 2;
	}
	cout << aans;
	//sp;
}

Measured memory_bytes: 384
#include<iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main(){
	string s;
	int n;
	cin >> n >> s;
	int l=0,r=0;
	/*queue<string> qs;
	qs.push("(");qs.push(")");
	while(!qs.empty()){
		
	int l=0,r=0;
		string str=qs.front();
		qs.pop();
		if(str.size()!=n){qs.push(str+"(");qs.push(str+")");
		}else{
			cout << str <<' ';
			s=str;*/
	for(int i=0;s[i]!='\0';++i){
		if(s[i]=='('){
			if(r>0){
				if(l<r){
					r-=l;
					l=0;
					while(r-->0){
						s.insert(s.begin(),'(');
						++i;
					}
				}
				else {
					l-=r;/*
					while(l-->0){
						s.insert(s.begin()+i,')');
						++i;
					}*/
				}
				r=0;
			}
			l++;
		}
		else r++;
		
		//cout <<l<<r;
	}
	if(l<r){
		r-=l;
		l=0;
		while(r-->0)s.insert(s.begin(),'(');
	}
	else {
		l-=r;
		r=0;
		while(l-->0)s.push_back(')');
	}
	cout<<s<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,x,t;
  cin>>n>>x>>t;
  ll cnt = n/x + ((n%x)?1:0);
  cout<<cnt*t;
  
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int H, W, K;
	vector<string> cake;
	vector<vector<int>> ans, hoge;
	
	cin>>H>>W>>K;
	
	cake.resize(H);
	ans.resize(H, vector<int>(W, 0));
	hoge.resize(H);
	
	for(int i = 0; i < H; i++){
		cin>>cake[i];
		for(int j = 0; j < W; j++){
			if(cake[i][j] == '#')
				hoge[i].push_back(j);
		}
	}
	
	int con = 1;
	for(int i = 0; i < H; i++){
		sort(hoge[i].begin(), hoge[i].end());
		
		if(hoge[i].size() == 0){
			if(i) ans[i] = ans[i-1];
			//cout<<"X"<<endl;
			continue;
		}
		if(hoge[i].size() == 1){
			for(int j = 0; j < W; j++){
				ans[i][j] = con;
			}
			//cout<<"i = <> "<<i<<" con "<<con<<endl;
			con++;
		} else {
			//cout<<"i = "<<i<<" con "<<con<<endl;
			for(int j = 0, k = 0; j < hoge[i].size(); j++){
				for(; k <= hoge[i][j]; k++){
					ans[i][k] = con;
				}
				con++;
			}
			for(int j = hoge[i][hoge[i].size()-1]; j < W; j++){
				ans[i][j] = con-1;
			}
		}
	}
	
	for(int i = H-2; i >= 0; i--){
		if(hoge[i].size() == 0){
			ans[i] = ans[i+1];
		}
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(j) cout<<" ";
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  int D; std::cin >> D;

  std::cout << "Christmas";
  for(int i=0; i<25-D; i++) {
    std::cout << " Eve";
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let m: usize = read().unwrap();
    let mut vec: Vec<usize> = Vec::new();
    for _ in 0..m {
        vec.push(read().unwrap());
    }
    let total = vec.iter().sum();
    if n >= total {
        println!("{}", n - total);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2176
import java.util.*;


public class Main{
    public static void main(String[] args){
        HashSet<String> set = new HashSet<String>();
        Scanner sc = new Scanner(System.in);
        String str = "";    
        String text;
        String word;
        int count=0;
        
        count = sc.nextInt();

        for(int i=0;i<count;i++){
            str = sc.next();
            if(str.equals("insert")){
                word = sc.next();
                set.add(word);

            }else if(str.equals("find")){
                word = sc.next();
                if(set.contains(word)==true){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 252740
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // aの読み込み
    let x: usize = iter.next().unwrap().parse().unwrap();
    // bの読み込み
    let a: usize = iter.next().unwrap().parse().unwrap();

    if x < a {
        println!("{}", 0);
    } else {
        println!("{}", 10);
    }
}

Measured memory_bytes: 4352
/*
                        Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
}      
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    int a,b;
    cin>>a>>b;
    if(b*2>=a)
    cout<<0;
    else
    cout<<a-(2*b);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a[200],b[200];
    int i = 0;
    while(cin){
        cin >> a[i] >> b[i];
        i++;
    }
    for(int j=0; j < i-1; j++ ){
        int c = a[j] + b[j];
        int count = 0;
        while(c > 0){
            c = c  / 10;
            count++;
        }
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
//以下数组下标统一0开始
char s[20];
long long ans, n;//n存下字符串长，方便使用
bool pls[20];//第i个为true表示在数字i和i+1间有加号
long long calc() {//计算结果
    //main函数提前处理了字符（s[i]-='0'）
    long long t = 0, sum = 0;
    for (int i = 0; i < n - 1; ++i) {
        t = t * 10 + s[i];
        if (pls[i]) {
            sum += t;
            t = 0;
        }
    }
    t = t * 10 + s[n - 1];
    return t + sum;
}
void dfs(int k) {
    if (k == n - 1) {
        ans += calc();
        return;
    }
    pls[k] = false;
    dfs(k + 1);
    pls[k] = true;
    dfs(k + 1);
}
int main() {
    cin >> s;
    n = strlen(s);
    for (int i = 0; i < n; ++i) {
        s[i] -= '0';
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
int Prim[60000],rwa[60000];
bool isp[60000];
int sieve(int n) {
	int p = 0;
	rep(i, n + 1)isp[i] = true;
	isp[0] = isp[1] = false;
	for (int i=2; i <= n; i++) {
		if (isp[i]) {
			Prim[p++] = i;
			for (int j = 2 * i; j <= n; j += i)isp[j] = false;
		}
	}
	return p;
}

bool Pr(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (!(n%i))return false;
	}
	return n >1;
}
signed main() {
	int n; cin >> n;
	int S = sieve(55555);
	vector<int>V;
	rep(i, S) {
		if (Prim[i] % 5 == 1)V.push_back(Prim[i]);
	}
	rep(i, n) {
		if (i)cout << ' '; cout << V[i] ;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mx 1000000007
#define ll long long int

using namespace std;

ll dp[1003][1003]={0},h,w;
char grid[1001][1001];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll h,w;
    cin>> h >> w ;
    for(ll i=1;i<=h;++i){
    	string str;
    	cin>> str;
        for(ll j=1;j<=w;++j){
            grid[i][j] = str[j-1] ;
        }
    }
    for(ll i=0;i<=h+1;++i){
        grid[i][w+1]='#';
    }
    for(ll i=0;i<=w+1;++i){
        grid[h+1][i]='#';
    }
    dp[h][w]=1;
    for(ll i=h;i>=1;--i){
        for(ll j=w;j>=1;--j){
        	if(grid[i][j]=='#'){
        		dp[i][j]=0;
        		continue;
        	}
            ll d=0,f=0;
            if(grid[i+1][j]=='.')
                d=dp[i+1][j];
            if(grid[i][j+1]=='.')
                f=dp[i][j+1];
            dp[i][j]=(dp[i][j]+d+f)%mx ;
        }
    }
    cout<< dp[1][1] ;
	return 0;
}


Measured memory_bytes: 12480
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") 
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define PI 3.1415926535897932384626 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd; 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define Rep(i, a, b) for (int i=a; i<(b); i++)
#define rep(i, a) for (int i=0; i<(a); i++)
#define Dep(i,a,b) for (int i = (b)-1; i >= a; i--)
#define dep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for(auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // Random No.
 
const int MOD = 1000000007;
const char nl = '\n';

void sol() {
    int N ;
    cin >> N;
    ll sum =0;
    
    map <ll, ll> m;
    
    rep(i, N){
        ll t;
        cin >> t ;
        m[t]++;
        sum = sum + t;
    }


    int Q;
    cin >> Q;
    while(Q--){
        int B , C;
        cin >> B >> C;
        sum += (C - B)*(m[B]);

        auto it = m.find(C);
        if(it != m.end()){
            m[C] = m[C] + m[B];
            m.erase(B);
        }
        else{
            m[C] = m[B];
            m.erase(B);
        }
        cout << sum << nl;

    }



}               

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

    #ifndef ONLINE_JUDGE
    	freopen("inputD.txt", "r", stdin);
	  #endif    
	
    int T=1;
    while(T--) {            
        sol();                
    }
	
	return 0;
}

Measured memory_bytes: 7584
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

long double sisya(long double a) {
	a *= 1000.0;
	//cout << a << endl;
	a += 0.5;
	a = (int)a;
	a /= 1000.0;
	return a; 
}

double ll(double x1, double y1, double x2, double y2) {
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double x[3], y[3];
		for (int j = 0; j < 3; j++) {
			cin >> x[j] >> y[j];
		}
		double a1, a2, b1, b2, c1, c2;
		a1 = 2.0 * (x[1]-x[0]);
		a2 = 2.0 * (x[2]-x[0]);
		b1 = 2.0 * (y[1]-y[0]);
		b2 = 2.0 * (y[2]-y[0]);
		c1 = x[0]*x[0]-x[1]*x[1]+y[0]*y[0]-y[1]*y[1];
		c2 = x[0]*x[0]-x[2]*x[2]+y[0]*y[0]-y[2]*y[2];
		double X, Y, R;
		X = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		Y = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		R = ll(X, Y, x[0], y[0]);
		//X = sisya(X);
		//Y = sisya(Y);
		//R = sisya(R);
		printf("%.3f %.3f %.3f\n", X, Y, R);
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m;
	cin >> n >> m;
	vi a(m);
	rep(i, m) cin >> a[i];

	ll sum = 0;
	rep(i, m) sum += a[i];
	ll ans = n - sum;
	if(ans < 0) ans = -1;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s == "ooo"){
    cout << 1000 << endl;
  }else if(s == "xxx"){
    cout << 700 << endl;
  }else if( s == "oxx" || s == "xox" || s == "xxo"){
    cout << 800 << endl;
  }else{
    cout << 900 << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def main():
    n, t = [int(i) for i in raw_input().split()]
    a_list = [int(i) for i in raw_input().split()]
    num_max_gain = 0
    max_gain = 0
    cur_min_cost = a_list[0]
    for i in xrange(1, len(a_list)):
        b_a, a = a_list[i-1], a_list[i]
        if b_a > a:
            cur_min_cost = min(cur_min_cost, a)
        else:
            gain = a-cur_min_cost
            if gain > max_gain:
                num_max_gain = 1
                max_gain = gain
            elif gain == max_gain:
                num_max_gain += 1
    print num_max_gain

if __name__ == '__main__':
    main()


Measured memory_bytes: 11808
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A += [a]
    B += [b]
ans = 0
for i in range(N-1, -1, -1):
    if (A[i] + ans) % B[i] == 0:
        continue
    ans += (B[i] - (A[i] + ans) % B[i])
    
print(ans)

Measured memory_bytes: 85552
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long d = c - a - b;
    if(d < 2){
        cout << "No" << endl;
        return 0;
    }
    long long e = 4 * a * b, f = d * d;
    if(e < f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//自作関数 a^n mod MODを求める
int m_pow(int a, int n){
  if(n == 0) return 1;
  if(n % 2 == 0){
    int t = m_pow(a, n / 2);
    return t * t % MOD;
  }
  return a * m_pow(a, n - 1) % MOD;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int a,b;

  cin >> a >> b;

  REP(i,10000){
    if(floor(i * 0.08) == a && floor(i * 0.1) == b){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  
  return 0;
}

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

using ll = long long int;

const int MOD = 1e9 + 7;

#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

template <class T>
class my_array{
  private:
    int n;
    vector<T> A;
  public:
    my_array(int k){n = k; A.resize(n);}
    ~my_array(void){};
    // input a_0, a_1, ..., a_(n-1)
    void get(void){
      for(int i = 0; i < n; i++) cin >> A.at(i);
    }
    // sort A
    void sorted(bool flag = true){
      if(flag) sort(A.begin(), A.end());
      else sort(A.begin(), A.end(), greater<T>());
    }
    // print : a_0, a_1, ... a_(n-1)
    void show(void){
      for(int i = 0; i < n - 1; i++) cout << A.at(i) << " ";
      cout << A.at(n - 1) << "\n";
    }
    int solve(int a, int b){
      if(a >= b) return 0;
      int mn_idx = 0, min = 1e9;
      for(int i = a; i < b; i++) if(min > A.at(i)){
        min = A.at(i);
        mn_idx = i;
      }
      for(int i = a; i < b; i++) A.at(i) -= min;
      return solve(a, mn_idx) + min + solve(mn_idx + 1, b);
    }
};


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

ll max_l(ll a, ll b, ll c){
  ll res;
  res = (a > b) ? a : b;
  if(res >= c) return res;
  return c;
}

int main(void){
  ll n, a, b;
  cin >> n >> a >> b;
  ll res;
  int time_s = (n - a + 1);
  ll tmp = a + (time_s / 2) * (b - a) + (time_s % 2);
  res = MAX(tmp, n + 1);
  cout << res << "\n";
  return 0;
}

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

// Ngoc Minh

using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define f first
#define s second
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);

string s,res;
int n;
map<int,char> m;
int main()
{
//    freopen("test.inp","r",stdin);
//    freopen("test.out","w",stdout);
    fast_io

    cin>>n>>s;

    int stt=65;
    for(char c='A'; c<='Z'; c++)
    {
        m[stt]=c;
        stt++;
    }

    ford(i,0,s.length()-1)
    {
        int val=s[i]+n;
        if(val>90)
        {
            int tg=val-90;
            val=64+tg;
        }
        res+=m[val];
    }

    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
}
int main(void)
{
    lli X;
    cin >> X;
    for (int i = 1; i <= X; i++)
    {
        if ((i * (i + 1)) / 2 >= X)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <vector>
#include <algorithm>

int greedy(
    const std::vector<std::vector<int>> &table,
    int &a, int b
) {
  int lb=0, ub=32;
  while (ub-lb > 1) {
    int mid=(lb+ub)>>1;
    ((table[mid][a] < b)? lb:ub) = mid;
  }

  a = table[lb][a];
  fprintf(stderr, "%d ", a);
  return 1 << lb;
}

int answer(
    const std::vector<std::vector<int>> &table,
    int a, int b
) {
  int next=a, res=0;
  while (next < b)
    res += greedy(table, next, b);

  return res;
}

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

  std::vector<int> x(N);
  for (int i=0; i<N; ++i)
    scanf("%d", &x[i]);

  int L, Q;
  scanf("%d %d", &L, &Q);

  std::vector<std::vector<int>> table(33, std::vector<int>(N));
  for (int i=0; i<N; ++i)
    table[0][i] = std::upper_bound(x.begin(), x.end(), x[i]+L)
      - x.begin() - 1;

  for (int i=1; i<=32; ++i)
    for (int j=0; j<N; ++j)
      table[i][j] = table[i-1][table[i-1][j]];

  for (int i=0; i<32; ++i)
    for (int j=0; j<N; ++j)
      fprintf(stderr, "%d%c", table[i][j], j+1<N? ' ':'\n');

  for (int i=0; i<Q; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);

    if (a > b)
      std::swap(a, b);

    --a, --b;
    printf("%d\n", answer(table, a, b));
  }

  return 0;
}


Measured memory_bytes: 15608
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    prepare :: [Int] -> (Integer, Int)
    prepare = foldl step (1, 0)
      where
        step :: (Integer, Int) -> Int -> (Integer, Int)
        step (c, m) a = c `seq` m `seq` (lcm c (toInteger a), (m + inv a) `mod` modulus)
  print . (`mod` modulus) . ((*) <$> fromInteger . (`mod` toInteger modulus) . fst <*> snd) . prepare $ as

inv :: Int -> Int
inv = (invs V.!)
  where
    inv' 1 = 1
    invs :: V.Vector Int
    invs = V.constructN (10 ^ 6 + 1) rec
      where
        rec v = case l of
                  0 -> 0
                  1 -> 1
                  _ -> let (q, r) = modulus `divMod` l in (modulus - (v V.! r) * q) `mod` modulus
          where
            l = V.length v

modulus = 10 ^ 9 + 7 :: Int

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 11004
#include"bits/stdc++.h"
using namespace std;
int main(){
	string s;
	cin>>s;
	set<int> x;
	for(auto i:s)
		x.insert(i);
	int ans=1E9;
	for(auto i:x){
		int cur=0,cnt=0;
		for(auto j:s){
			if(j==i){
				cur=max(cur,cnt);
				cnt=0;
			}
			else
				++cnt;
		}
		cur=max(cur,cnt);
		ans=min(ans,cur);
	}
	cout<<ans;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n,i;
  string s,t;
  cin >> n >> s >> t;
  for(i = n; i > 0; i--){
    if(s.substr(n - i,i) == t.substr(0,i))break;
  }
  cout << 2 * n - i << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    //std::cout << "Hello, World!" << std::endl;
    int i,count=0;
    char n[4];
    cin >> n;
    for(i=0;i<4;i++){
        if(n[i]=='2')count++;
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b;
  cin >> a >> b;

  if((b-a)%4==0){
    if(a%2==0)cout << b <<endl;
    else cout << a << endl;
  }
  else if((b-a)%4==1){
    if(a%2==0)cout << 1 << endl;
    else{
      ll c=a^b;
      cout << c << endl;
    }
  }
  else if((b-a)%4==2){
    if(a%2==0){
      ll c=b^1;
      cout << c << endl;
    }
    else{
      ll c=a^1;
      cout << c << endl;
    }
  }
  else{
    if(a%2==0)cout << 0 << endl;
    else{
      ll c=a^1^b;
      cout << c << endl;
    }
  } 

}

Measured memory_bytes: 3604
import bisect
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
C.sort()
ans = 0

for i in range(N):
  ans += bisect.bisect_left(A,B[i]) * (N-bisect.bisect_right(C,B[i]))
print(ans)

Measured memory_bytes: 23232
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long s;
	int a[12]={0};
	cin>>s;
	int n=0;
	for(int i=0;;i++)
	{
		a[i]=s%10;
		n++;
		s/=10;
		if(s==0)break;
	}
	int m=1e4;
	for(int i=n-1;i>1;i--)
	{
		m=min(m,abs(a[i]*100+a[i-1]*10+a[i-2]-753));
	}
	cout<<"                                  "<<endl<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%2lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

bool ans;
int N;
char S[105];

int main(void) {
    scanf("%d", &N);
    scanf("%s", S);

    if (N%2 == 1) {
      No;
      return 0;
    }
    rep(i, 0, N/2) {
      if (S[i] != S[N/2+i]) {
        No;
        return 0;
      }
    }
    Yes;
    

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools

D, G = map(int, input().split())

pi = []
ci = []
score_i_c = []
score_i_h = []
for i in range(D):
    p_t, c_t = map(int, input().split())
    pi.append(p_t)
    ci.append(c_t)
    tmp = p_t * 100 * (i + 1) + c_t
    score_i_c.append((i,tmp,p_t))
    tmp = (p_t - 1) * 100 * (i + 1)
    score_i_h.append((i,tmp,p_t))

# 完全に解かなくても行ける場合
step1_list = []
for i,score,num in score_i_h:
    if score >= G:
        step1_list.append((i,score,num))

ans_list = []
if len(step1_list) > 0:
    min_i , _, _ = step1_list[-1]
    for i , score, num in step1_list:
        tmp_score = 0
        tmp_num = 0
        for i in range(pi[min_i]):
            if tmp_score >= G:
                break
            else:
                tmp_score += (min_i+1) * 100
                tmp_num  += 1
        ans_list.append(tmp_num)

#完全に解くケース
step1_list = []
for i in range(D):
    tmp = itertools.combinations(score_i_c, i+1)
    step1_list.extend(list(tmp))

# 合計がGを超える組み合わせを抽出
sum_list = []
for l in step1_list:
    numbers = []
    sum_score = 0
    sum_num = 0
    for i,score,num in l:
        numbers.append(i)
        sum_score += score
        sum_num += num

    if sum_score >= G:
        sum_list.append((numbers,sum_score,sum_num))
#
# print(step1_list)
# print(sum_list)

# min_numbers = []
# min_score = 0
# min_num = 10000
# for i,score,num in sum_list:
#     if num < min_num:
#         min_numbers = i
#         min_score = score
#         min_num = num

# print(min_numbers,min_score,min_num)

# min_i = min_numbers[-1]
for min_numbers,min_score,min_num in sum_list:
    for min_i in min_numbers:
        tmp_score = min_score - score_i_c[min_i][1]
        tmp_num = min_num - score_i_c[min_i][2]

        for i in range(pi[min_i]):
            if tmp_score >= G:
                break
            tmp_score += (min_i+1) * 100
            tmp_num  += 1

        ans_list.append(tmp_num)

# print(ans_list)

print(min(ans_list))


Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        char [] str = new char [w.length()];
        
        for(int i=0; i<w.length(); i++){
            str[i] = w.charAt(i);
        }
        
        Arrays.sort(str);
        char tmp = str[0];
        ArrayList <Integer> list = new ArrayList<>();
        int count = 1;
        boolean judge = true;
        
        for(int i=1; i<w.length(); i++){
            if(tmp == str[i]){
                count++;
            }else{
                list.add(count);
                count = 1;
                tmp = str[i];
        }
        }
        
        list.add(count);
        
        for(int i=0; i<list.size(); i++){
            if(list.get(i)%2 == 1){
                judge = false;
                break;
            }
        }
        
        if(judge) System.out.println("Yes");
        else System.out.println("No");
}

}

Measured memory_bytes: 35488
N = int(input())
A = [int(a) for a in input().split()]

dp = [0 for i in range(N+1)]
ball = [0 for b in range(N+1)]

if N % 2 == 0:
    for i in range(N//2):
        ball[-i-1] = A[-i-1]
    num = N//2
else:
    for i in range(N//2+1):
        ball[-i-1] = A[-i-1]
    num = N//2


while num >= 1:
    c = num
    mod = 0
    k = 1
    while c*k <= N:
        mod += ball[c*k]
        k += 1
    if mod % 2 == 0:
        if A[num-1] == 1:
            ball[num] += 1
    else:
        if A[num-1] == 0:
            ball[num] += 1
    num -= 1

M = sum(ball)
print(M)
for i in range(N+1):
    if ball[i] != 0:
        print(i)

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

int main()
{
	int k, x,min,max;
	scanf("%d%d", &k, &x);
	min = x - k + 1;
	max = x + k - 1;
	for (int i = min;i <= max;i++)printf("%d ", i);
	return 0;
}

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

using namespace std;

bool ehprimo(int z)
{
    if (z == 1)
        return false;

    for (int i = 2; i * i <= z; i++)
    {
        if (z%i == 0)
            return false;
    }
    return true;
}

int main()
{
    int x, prime = 0; cin >> x;
    int i = x;
    while(!ehprimo(x))
        x++;

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
import sys  # sys.exit()を使いたいので

n = int(input())
a = list(map(int, input().split()))
a.sort()  # 0があれば先頭に来ます

cur = 1  # 現在の数値
for x in a:
    cur *= x
    if cur > 10 ** 18:
    # 10**18を超えたので終了します
        print(-1)
        sys.exit()
print(cur)  # 10**18以下なので、出力します

Measured memory_bytes: 21520
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <climits>
using namespace std;

#define rep(i,beg,end)   for (int i=(beg);i<(end);i++)
#define rrep(i,beg,end)   for (int i=(beg);i>=(end);i--)
#define all(cont)           begin(cont), end(cont)
#define INFMAX                   LLONG_MAX
#define INFMIN                   LLONG_MIN
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef list<ll> li;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);

ll f(const vector<vi>& lights, const vi& odds, int nswitch, vi& sw)
{
    auto i = sw.size();
    if (i == nswitch) {
        rep(j, 0, lights.size())
        {
            auto l = lights[j];
            ll sum = 0;
            for (auto it = begin(l); it != end(l); it++) {
                sum += sw[*it - 1];
            }
            if (sum % 2 != odds[j]) return 0;
        }
        return 1;
    }
    else {
        ll cnt = 0;
        sw.push_back(0);
        rep(s, 0, 2)
        {
            sw[i] = s;
            cnt += f(lights, odds, nswitch, sw);
        }
        sw.pop_back();
        return cnt;
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n>>m;
    vector<vi> light;
    rep(i, 0, m)
    {
        int k;
        cin >> k;
        light.push_back(get_n_array(k));
    }
    vi odd = get_n_array(m);
    vi t;
    ll cnt = f(light, odd, n, t);
    cout << cnt << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int BUFF_MAX = 1024;
    char buf[BUFF_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i,a,b) for(int i=a; i<b; i++)

typedef vector<int> lang;
vector<lang> people;

int N,M,L;
bool tr[30][30];

bool check(vector<int>& ret)
{
	REP(i,0,people.size())
	{
		bool g=false;
		REP(j,0,people[i].size())
		REP(k,0,ret.size())
		{
			if(people[i][j]==ret[k]) g=true;
		}
		
		if(!g) return false;
	}

	bool v[30][30]={0};
	REP(i,0,ret.size())
	REP(j,0,ret.size())
		if(tr[ret[i]][ret[j]]) v[ret[i]][ret[j]]=1;
		
	REP(k,0,N)
	REP(y,0,N)
	REP(x,0,N)
		v[x][y]|=(v[x][k]&v[k][y]);

	REP(i,0,people.size())
	REP(j,i+1, people.size())
	{
		bool g=false;
		REP(k,0,people[i].size())
		REP(l,0,people[j].size())
		{
			if(v[people[i][k]][people[j][l]]) g=true;
		}
		if(!g) return false;
	}
	return true;
}

bool conb(int p, int l, int pv, vector<int>& ret)
{
	if(p==l) 
	{
		if(check(ret)) return true;
		return false;
	}
	REP(i,pv+1,N-(l-p-1))
	{
		ret.push_back(i);
		if(conb(p+1,l,i,ret)) return true;
		ret.pop_back();
	}
	return false;
}


int main()
{
	bool f=true;
	while(scanf("%d%d",&N,&M),(N||M))
	{
		if(!f) puts("");
		f=false; 
		
		REP(i,0,30)
		REP(j,0,30)
		{
			tr[i][j]=0;
			if(i==j) tr[j][i]=1;
			tr[i][i]=1;
			tr[j][j]=1;
		}
		
		char buf[30];
		people.clear();
		map<string, int> d;
		vector<string> rd;
		
		REP(i,0,N)
		{
			scanf("%s", buf);
			d.insert(make_pair(string(buf), i));
			rd.push_back(string(buf));
		}
		
		vector<lang> People;
		while(M--)
		{
			lang per;
			scanf("%d", &L);
			while(L--)
			{
				scanf("%s", buf);
				map<string, int>::iterator it=d.find(string(buf));
				per.push_back(it->second);
			}
			people.push_back(per);
		}
		
		REP(i,0,people.size())
		REP(j,0,people[i].size())
		REP(k,j+1,people[i].size())
		{
			tr[people[i][j]][people[i][k]]=1;
			tr[people[i][k]][people[i][j]]=1;
		}

		vector<int> ret;
		REP(i,1,6)
		{
			if(conb(0,i,-1,ret)) break;
		}
		
		if(ret.empty()) puts("Impossible");
		else
		{
			vector<string> ans;
			REP(i,0,ret.size())
				ans.push_back(rd[ret[i]]);
			
			sort(ans.begin(), ans.end());
			
			printf("%d\n", ans.size());
			REP(i,0,ans.size())
				puts(ans[i].c_str());
		}
	}
}

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

int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    int ia='a';
    for(int i=0;i<s.size();i++){
        if(s[i]==ia) ia++;
    }
    if(ia=='z'+1) cout<<"None"<<endl;
    else cout<<(char)ia<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define nmax 200005
using namespace std;
vector<int>g[nmax];
int n, x, y, h[nmax], u, v, wh;
int lastNode[nmax], big[nmax], ans;
bool onPath[nmax];
void dfs1(int nod, int hei, int lst = -1){
    lastNode[nod] = lst;
    h[nod] = hei;
    if (nod == u){
        int curr = nod;
        while (curr != -1){
            onPath[curr] = true;
            curr = lastNode[curr];
        }
    }
    for (auto x:g[nod]){
        if (x == lst){
            continue;
        }
        dfs1(x, hei+1, nod);
    }
}
void dfs2(int nod, int lst = -1){
    for (auto x:g[nod]){
        if (x == lst || !onPath[x]){
            continue;
        }
        if (h[x] > h[u]-h[x]){
            ans = max(ans, big[x]-1);
        }
        if (nod != u){
            dfs2(x, nod);
        }
    }
}
void dfs3(int nod, int lst = -1){
    int leaf = true;
    for (auto x:g[nod]){
        if (x == lst){
            continue;
        }
        leaf = false;
        dfs3(x, nod);
    }
    if (leaf){
        big[nod] = h[nod];
    } else {
        int maxx = -1;
        for (auto x:g[nod]){
            if (x == lst){
                continue;
            }
            maxx = max(maxx, big[x]);
        }
        big[nod] = maxx;
    }
}
int main()
{
    cin>>n>>u>>v;
    for (int i=1;i<n;++i){
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs1(v, 0);
    dfs3(v);
    dfs2(v);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 16128
#include<stdio.h>
#include<stdlib.h>
#define STACKSIZE 100

typedef struct {
  int items[STACKSIZE];
  int top;
} Stack;

void init( Stack *s);
void push( Stack *s, int i);
int pop( Stack *s);

int main(void)
{
  char s[11];
  int x, y;
  Stack stack;

  init(&stack);
  
  while ( scanf("%s", s) != EOF) {
    if ( s[0] == '+') {
      y = pop(&stack);
      x = pop(&stack);
      push( &stack, x+y);
    }else if ( s[0] == '-') {
      y = pop(&stack);
      x = pop(&stack);
      push( &stack, x-y);
    }else if ( s[0] == '*') {
      y = pop(&stack);
      x = pop(&stack);
      push( &stack, x*y);
    }else{
      push( &stack, atoi(s));
    }
  }

  printf("%d\n", pop(&stack));
  return 0;
}

void init( Stack *s) { s->top = 0;}
void push( Stack *s, int i) { s->items[s->top++] = i;}
int pop( Stack *s) { return s->items[--s->top];}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 1 << 30;
int dp[2010][2010], ub[4010][2010], uw[4010][2010];
int N, B[2010], W[2010];

int solve(){
    for(int i = 0; i <= 2 * N; i++){
        for(int j = 0; j <= N; j++){
            ub[i + 1][j] += ub[i][j];
            uw[i + 1][j] += uw[i][j];
        }
    }

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for(int i= 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            int dist = i + j + 1;
            int cost = dp[i][j] + ub[B[i + 1]][i + 1] + uw[B[i + 1]][j];
            dp[i + 1][j] = min(dp[i + 1][j], cost);
            cost = dp[i][j] + ub[W[j + 1]][i] + uw[W[j + 1]][j + 1];
            dp[i][j + 1] = min(dp[i][j + 1], cost);
        }
    }
    return dp[N][N];
}

void init(){
    cin >> N;
    for(int i = 1; i <= 2 * N; i++){
        char c;
        int idx;
        cin >> c >> idx;
        if(c == 'B'){
            B[idx] = i;
            for(int j = 0; j < idx; j++){
                ub[i][j]++;
            }
        }
        else{
            W[idx] = i;
            for(int j = 0; j < idx; j++){
                uw[i][j]++;
            }
        }
    }
}

int main(){
    init();
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 78976
_ = input()
line = input()

numbs = [int(v.strip()) for v in line.split()]

def get_status(numbs):
    for numb in numbs:
        if numb % 2 == 0 and (numb % 3 != 0 and numb % 5 != 0):
	        return "DENIED"
    return "APPROVED"


print(get_status(numbs))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

void solve(){
  string s;
  cin >> s;
  int n = 0;
  int m = 0;
  int siz = s.length();
  rep(i,siz){
    if(s[i]=='1') n++;
    else m++;
  }
  cout << 2*min(n,m) << endl;

}

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


Measured memory_bytes: 512
$stdin.each_line do |line|
  a , b , c , d , e , f = line.split.map{|i| i.to_f}
  x = (c*e - f*b)/(a*e - d*b).round(4)
  x = (x == 0) ? 0 : x
  y = (a*f - d*c)/(a*e - d*b).round(4)
  y = (y == 0) ? 0 : y
  printf("%.3f %.3f\n" , x , y)
end

Measured memory_bytes: 6188
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		String[] t = saori.nextHayami().split("");
		String[] s = saori.nextHayami().split("");
		int ans = 0;
		for(int i = 0;i < t.length;i++){
			if(!s[i].equals(t[i]))ans++;
		}
		System.out.println(ans);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 63556