akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 
const int N=400;
string s[N];
int h,w;
bool vis[N][N][2];
int dp[N][N][2];
void dfs(int i,int j,int k,int val){
	if(i>=h || j>=w) return;
	if(vis[i][j][k]==1 && dp[i][j][k]<=val) return;
	vis[i][j][k]=1;
	dp[i][j][k]=val;
	if(k==0 && s[i][j]=='#') dp[i][j][k]+=1; 
	// trace(i,j,k,val);
	if(i==h-1 && j==w-1) return;
	if(k==0){
		if(s[i][j]=='#') {
			dfs(i,j+1,1,val+1);
			dfs(i+1,j,1,val+1);
		}
		else {
			dfs(i,j+1,0,val);
			dfs(i+1,j,0,val);
		}
	}
	else{
		if(s[i][j]=='.') {
			dfs(i,j+1,0,val);
			dfs(i+1,j,0,val);
		}
		else {
			dfs(i,j+1,1,val);
			dfs(i+1,j,1,val);
		}
	}

}
int solve(){

	// int h,w;
	cin>>h>>w;	
	for(int i=0;i<N;i++) for(int j=0;j<N;j++) for(int k=0;k<2;k++)dp[i][j][k]=1e9;//dp[i][j][0]=dp[i][j][1]=1e9;
	// cout<<min(dp[h-1][w-1][0],dp[h-1][w-1][1]);
	inputarr(s,h);
	dfs(0,0,0,0);
	cout<<min(dp[h-1][w-1][0],dp[h-1][w-1][1]);


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
  int N;
  string s;
  cin>>s;
  N = s.size();
  int zeronum,minnum;
  for (int i = 0; i < N; i++) if (s[i] == '0') zeronum++;
  minnum = min(zeronum,N-zeronum);
  cout<<2*minnum<<endl;
  return 0;
}

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

int main(){
	string res = "AB";
	int n;
	cin >> n;

	if (n >= 1000){
		res += "D";
	}
	else{
		res += "C";
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

priority_queue<ll, vector<ll>, greater<ll>> l;
priority_queue<ll, vector<ll>, less<ll>> r;
vector<ll> a;
int n;
ll left_acc;
ll right_acc;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll ret = LLONG_MIN;
    cin >> n;
    for(int i = 0; i < 3 * n; i++)
    {
        ll t; cin >> t; a.push_back(t);
    }
    
    
    
    for(int i = 0; i < n - 1; i++)
    {
        l.push(a[i]);
        left_acc += a[i];
    }
    
    
    /////////
    vector<ll> least;
    for(int i = 0; i < n - 1; i++)
    {
        r.push(a[3 * n - 1 - i]);
        right_acc += a[3 * n - 1 - i];
    }
    
    for(int k = 2 * n; k >= n; k--)
    {
        r.push(a[k]);
        right_acc += a[k];
        while(r.size() > n)
        {
            right_acc -= r.top();
            r.pop();
        }
        least.push_back(right_acc);
    }
    /////////
    
    
    
    
    for(int k = n - 1; k < 2 * n; k++)
    {
        l.push(a[k]);
        left_acc += a[k];
        while(l.size() > n)
        {
            left_acc -= l.top();
            l.pop();
        }
        
        
        
        
        ret = max(ret, left_acc - least.back());
        least.pop_back();
    }
    
    
    cout << ret << endl;
    return 0;
}


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

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: i32,
        t: [i32; n],
        m: i32,
        pxs: [(usize, i32); m],
    }

    let s: i32 = t.iter().sum();
    for (p, x) in pxs {
        let before_num: i32 = t[p as usize - 1];
        println!("{}", s - before_num + x);
    }

} 


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
////////////////////
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    //A = 0; B = 75; C = 25; D = 100;
    int count = 0;
    
    for(int i = 0; i <= 100; i++){
        if(A < i && i <= B && C < i && i <= D) {
            count++;
        }
    }
    cout << count;
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	in(n, k);
	int ans = 1;
	rep(i, n)ans = min(ans * 2, ans + k);
	out(ans);
}

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

int main()
{
    int a, b, c;
    int sum = 0;

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

    for ( int i = 0; i < 100; ++i ) {
        sum += a;
        if ( sum % b == c ) {
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");

    return 0;
}


Measured memory_bytes: 256
//OPTIMIZATIONS
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
//#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//OPTIMIZATIONS
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long uu;
typedef long long int lll;
typedef unsigned long long int uuu;
using namespace std;

#define watch(x) cerr << "\n" \
					  << (#x) << " is " << (x) << endl
#define cel(x, y) 1 + ((x - 1) / y)
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;

/*
$alil03

URL: url

Solution Begins here
*/
string a, b;
int table[3004][3004] = {{0}};
int dp(int x, int y)
{
	if (table[x][y] != -1)
	{
		return table[x][y];
	}
	if (a[x - 1] == b[y - 1])
	{
		return table[x][y] = 1 + dp(x - 1, y - 1);
	}
	else
	{
		return table[x][y] = max(dp(x - 1, y), dp(x, y - 1));
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b;
	int len1 = a.length(), len2 = b.length();
	for (int i = 0; i <= len1; i++)
	{
		table[i][0] = 0;
	}
	for (int i = 0; i <= len2; i++)
	{
		table[0][i] = 0;
	}
	for (int i = 1; i <= len1; i++)
	{
		for (int j = 1; j <= len2; j++)
		{
			table[i][j] = -1;
		}
	}
	dp(len1, len2);
	int i = len1, j = len2;
	string final;
	while (true)
	{
		if (i == 0 || j == 0)
		{
			break;
		}
		if (a[i - 1] == b[j - 1])
		{
			final += a[i - 1];
			i--;
			j--;
		}
		else
		{
			if (max({table[i - 1][j - 1], table[i - 1][j], table[i][j - 1]}) == table[i - 1][j - 1])
			{
				i--;
				j--;
			}
			else if (max({table[i - 1][j - 1], table[i - 1][j], table[i][j - 1]}) == table[i - 1][j])
			{
				i--;
			}
			else if (max({table[i - 1][j - 1], table[i - 1][j], table[i][j - 1]}) == table[i][j - 1])
			{
				j--;
			}
		}
	}
	reverse(final.begin(), final.end());
	cout << final;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];

	vi ans(n);
	RREP(i, n) {
		bool done = false;
		RREP(j, v.size()) {
			if (v[j] == j + 1) {
				ans[i] = v[j];
				v.erase(v.begin() + j);
				done = true;
				break;
			}
		}
		if (!done) {
			cout << -1 << endl;
			return 0;
		}
	
	}
	REP(i, n)cout << ans[i] << endl;

}


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

using namespace std;

typedef long long ll;

int main()
{

    int n,cnt;
    char s[200];
    int a[200];
    cin>>n>>s;

    int c=1;
    int sum;
    int m=-1,ii=0;
    int q=0;
    set<char>v;
    for(int i=0;i<n;i++)
    {
        sum=0;
        v.clear();
        memset(a,0,sizeof(a));
        for(int j=0;j<c;j++)//j---c
        {
            for(int k=c;k<n;k++)//c--n
            {
                if(s[j]==s[k] && !a[k])
                {
                    a[j]=1,a[k]=1;
                    v.insert(s[j]);
                    sum++;
                    break;
                }
            }
        }
        int t=v.size();
        if(m<t)
        {
            m=t,ii=c;
        }
        c++;
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=1e6+10;
const int mod=1e9+7;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(i%2==0)
            continue;
        if(x%2)
            cnt++;
    }
    cout<<cnt<<'\n';






}


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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
   
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int result = 0;
	if(k<=(a+b)){
		result += k<=a?k:a;
		k=0;
	}
	else{
		result+=a;
		k-=(a+b);
	}
	if(k>0){
		result -= k;
	}
	cout<<result;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n; cin >> n;
  map<string, int> m;
  string s;
  for(int i=0; i<n; i++) {
    cin >> s;
    m[s]++;
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

    if(a == b && b==c){
        if(a==c){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int N;
    cin >> N;

    reps(h, 3500){
        reps(n, 3500){
            if(4 * h * n - N * n - N * h <= 0 || ((lint)N * h * n) % (4 * h * n - N * n - N * h) != 0){
                continue;
            }
            cout << h << " " << n << " " << ((lint)N * h * n) / (4 * h * n - N * n - N * h) << endl;
            return 0;
        }
    }

    cout << flush;

    return 0;
}

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
//map<int, int>::iterator itr; 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;t=1;
    while(t--){
        int n;cin>>n;
        int arr[n+1],a[1000001];
        for(int i=0;i<1000001;i++)
        a[i]=0;
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        arr[n]=0;
        sort(arr,arr+n);
        int c=1;
        for(int i=0;i<n;i++){
            if(arr[i]==arr[i+1]){
                c++;
            }
            else{
                int val=arr[i];
                while(val<1000001){
                    a[val]+=c;
                    val+=arr[i];
                }
                c=1;
            }
        }
        c=0;
        for(int i=0;i<n;i++){
            if(a[arr[i]]<2){
                c++;
            }
        }
        cout<<c;
    }
    return 0;
}


Measured memory_bytes: 8348
#include <iostream>
using namespace std;
const int V[] = {1000, 500, 100};

int main () {
    int A, B;
    while (cin >> A >> B, A || B) {
        int rem = B - A;
        int C[3];
        
        for (int i = 0; i < 3; i++) {
            C[i] = rem / V[i];
            rem = rem % V[i];
        }
        
        for (int i = 2; i >= 0; i--) {
            cout << C[i];
            if (i != 0) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int main() {
   ll a,b,x;
	cin >> a >> b >> x;
   ll ans=b/x-a/x;
	if(a%x==0)
   ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

MIN_ab = 999999

for a in range(1,N):
    a_sum = 0
    b_sum = 0
    for a_split in str(a):
        a_sum +=  int(a_split)
    for b_split in str(N-a):
        b_sum +=  int(b_split)
    if a_sum + b_sum < MIN_ab:
        MIN_ab = a_sum + b_sum
        
print(MIN_ab)


Measured memory_bytes: 2940
using System;
using System.Linq;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int[] res = new int[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = b.Length - 1; j >= 0; j--)
                {
                    if (b[j] == j + 1)
                    {
                        res[i] = b[j];
                        b = b.Where((e, k) => k != j).ToArray();
                        break;
                    }
                }
            }
            if (b.Length != 0)
            {
                Console.WriteLine(-1);
            }
            else
            {
                foreach (var item in res.Reverse())
                {
                    Console.WriteLine(item);
                }
            }
        }
    }
}


Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N, M = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    grid = [[int(x) for x in sys.stdin.readline().split()]
            for _ in range(M)]  # int grid

    logger.debug('{}'.format([]))

    d = dict()

    ret = [0 for _ in range(N)]

    for s, c in grid:
        if d.get(s, c) != c:
            print(-1)
            return

        d[s] = c

        ret[s - 1] = c

    if len(ret) == 1:
        print(ret[0])

    else:
        if ret[0] == 0:
            if d.get(1, None) == 0:
                print(-1)
            else:
                ret[0] = 1
                print(''.join([str(t) for t in ret]))
        else:
            print(''.join([str(t) for t in ret]))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
1 7
3 2
1 7"""
        output = """702"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 2
2 1
2 3"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3 1
1 0"""
        output = """-1"""
        self.assertIO(input, output)


Measured memory_bytes: 5648
# -*- coding: utf-8 -*-
N, Y = map(int, raw_input().split())

result = False
for i in range(0, N + 1):
  zan = Y - (i * 10000)
  for j in range(0, N + 1 - i):
    zan = Y - (i * 10000) - (j * 5000)
    zan_mai = N - i - j
    if zan_mai * 1000 == zan:
      print(str(i) + " " + str(j) + " " + str(zan_mai))
      result = True
      break
    if result:
      break
  if result:
    break

if not result:
  print("-1 -1 -1")

Measured memory_bytes: 2692
# -*- coding: utf-8 -*-
MAX = 100100


def main():
    n = int(''.join(input().split()))
    x = 1
    while True:
        x2 = pow(x, 2)
        if x2 > MAX:
            break
        if x2 == n:
            print('Yes')
            return
        x += 1
    print('No')


main()


Measured memory_bytes: 2940
l, r = [int(i) for i in input().split()]
if r - l >= 2018:
    print(0)
    exit()

mn = 2019
for i in range(l, r + 1):
    for j in range(l, r + 1):
        if i < j:    
            t = (i * j) % 2019
            mn = min(mn, t)

print(mn)


Measured memory_bytes: 2940
N, M = map(int, input().split())
maxL, minR = 0, N+1
for i in range(M):
  L, R = map(int, input().split())
  maxL = max(L, maxL)
  minR = min(R, minR)
ans = minR -maxL + 1
print(ans if ans>0 else 0)

Measured memory_bytes: 9136
#include<algorithm>//sort(all(変数),greater<型名>())で降順に,reverse()で逆に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,何文字)で文字列ゲット
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll n;  cin >> n;
  vll x(n+1),y(n+1),t(n+1);
  rep1(i,n){
    cin >> t[i] >> x[i] >> y[i];
  }
  t[0] = x[0] = y[0] = 0;

  bool flag = true;
  rep0(i,n){
    int time = t[i+1] - t[i];
    int d = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if(time < d or time%2 != d%2){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Yes";
  }else{
    cout << "No";
  }
  // return 0;
}


Measured memory_bytes: 2560
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define int ll
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int n; cin>>n;
    vector<int>v(n);
    vector<int>u(n);
    vector<int>g(n);
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>u[i];
    rep(i,n)cin>>g[i];
    sort(all(v));
    sort(all(u));
    sort(all(g));
    vector<int>usum(n,0);
    rep(i,n){
        int index=(int)(upper_bound(all(g),u[i])-g.begin());
        usum[i]=n-index;
    }
    for(int i=n-1;i>0;i--){
        if(i)usum[i-1]+=usum[i];
    }
    int ans=0;
    rep(i,n){
        int temp=(int)(upper_bound(all(u),v[i])-u.begin());
        if(temp>=n)continue;
        ans+=usum[temp];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
package main

import "fmt"

func main() {
	var N int
	var x, w float64
	var u string
	fmt.Scan(&N)

	for i := 0; i < N; i++ {
		fmt.Scan(&x, &u)
		if u == "JPY" {
			w += x
		} else {
			w += x / 1.0 * 380000.0
		}
	}
	fmt.Printf("%.8f", w)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = b;
    ans += min(c, a + b + 1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int ans = 0;
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < n; i++) {
            String s = in.ns();
            if(s.charAt(0)=='B' && s.charAt(s.length()-1)=='A') c++;
            else if(s.charAt(0)=='B') b++;
            else if(s.charAt(s.length()-1)=='A') a++;
            for (int j = 0; j < s.length()-1; j++) {
                if(s.charAt(j)=='A'&&s.charAt(j+1)=='B') ans++;
            }
        }
        if(c > 0){
            ans += c-1;
            if(a!=0 || b!=0) ans += 1+Math.min(a,b);
        }else{
            ans += Math.min(a,b);
        }
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 24916
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def F(A, B, x):
    return math.floor(A*x / B) - A*math.floor(x / B)
# def F1(A, B, x):
#     return math.floor(A*x / B)
# def F2(A, B, x):
#     return A*math.floor(x / B)

A, B, N = LI()

# import matplotlib.pyplot as plt
# plt.plot(range(1, N+1), [F(A, B, y) for y in range(1, N+1)])
# plt.plot(range(1, N+1), [F1(A, B, y) for y in range(1, N+1)])
# plt.plot(range(1, N+1), [F2(A, B, y) for y in range(1, N+1)])
# plt.show()

if N < B:
    print(F(A, B, N))
else:
    print(F(A, B, B-1))


Measured memory_bytes: 65648
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,mid;
char s[N];

struct dat {
	int l,r;
	dat() {}
	dat(int _l,int _r) {
		l=_l;r=_r;
		if(l<0) l+=2;
		if(r>mid) r-=2;
	}
	bool empty() {
		return l>r;
	}
} I[2],new_I[2];

bool check() {
	I[0]=dat(0,mid-(mid&1));
	I[1]=dat(1,mid-(mid&1^1));
	//cerr<<I[1].l<<' '<<I[1].r<<'\n';
	for(int i=1;i<=n;i++) {
		if(s[i]=='1') {
			new_I[0]=dat(I[1].l+1,I[1].r+1);
			new_I[1]=dat(I[0].l+1,I[0].r+1);
		}
		else if(s[i]=='0') {
			new_I[0]=dat(I[1].l-1,I[1].r-1);
			new_I[1]=dat(I[0].l-1,I[0].r-1);
		}
		else {
			new_I[0]=dat(I[1].l-1,I[1].r+1);
			new_I[1]=dat(I[0].l-1,I[0].r+1);
		}
		if(I[0].empty()) new_I[1]=dat(1,0);
		if(I[1].empty()) new_I[0]=dat(1,0);
		I[0]=new_I[0];I[1]=new_I[1];
		//cerr<<I[0].l<<' '<<I[0].r<<' '<<I[1].l<<' '<<I[1].r<<'\n';
		if(I[0].empty()&&I[1].empty()) return 0;
	}
	return 1;
}

int main() {
	scanf("%s",s+1);n=strlen(s+1);
	//mid=0;check();return 0;
	int l=0,r=n;
	while(l<r) {
		mid=(l+r)>>1;
		if(check()) r=mid;
		else l=mid+1;
	}
	cout<<l;
	return 0;
}


Measured memory_bytes: 4740
//void _(){
//    int n;
//    cin >> n;
//    vpll arr(n);
//    cin >> arr;
//    rep(i,1,n-1){
//        ll min_mult = max((arr[i-1].X+arr[i].X-1)/arr[i].X,(arr[i-1].Y+arr[i].Y-1)/arr[i].Y);
//        arr[i].X *= min_mult;
//        arr[i].Y *= min_mult;
//    }
//    print(arr[n-1].X+arr[n-1].Y);
//}
//
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
template <typename F, typename S> static
istream& operator>>(istream& stream, pair<F, S>& t){
    return stream >> t.first >> t.second;
}
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n;
    cin >> n;
    vpll arr(n);
    cin >> arr;
    rep(i,1,n-1){
        ll min_mult = max((arr[i-1].X+arr[i].X-1)/arr[i].X,(arr[i-1].Y+arr[i].Y-1)/arr[i].Y);
        arr[i].X *= min_mult;
        arr[i].Y *= min_mult;
    }
    print(arr[n-1].X+arr[n-1].Y);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

s = input_s
t = input_s

cnt = 0
s.length.times do |i|
  cnt += 1 if s[i] == t[i]
end
puts s.length - cnt


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

int main(){
  int n,i,j,count=0,temp;
  cin>>n;
  int a[n];
  for (i=0;i<n;i++)cin>>a[i];

  for (i=0;i<n;i++){
    for (j=n-1;j>i;j--){
      if (a[j]<a[j-1]){
        temp=a[j];
        a[j]=a[j-1];
        a[j-1]=temp;
        count++;
      }
    }
  }
  for (i=0;i<n;i++){
    if (i)cout<<' ';
    cout<<a[i];
  }
  cout<<endl;
  cout<<count<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    string s;

    cin >> s;

    if (s <= "2019/04/30") {
        cout << "Heisei";
    } else {
        cout << "TBD";
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
n = int(input())
dic1 = {}
for i in range(n):
    s = input()
    if s not in dic1.keys():
        dic1[s] = 1
    else:
        dic1[s] += 1
dic2 = sorted(dic1.items(), key=lambda j: j[1], reverse=True)

ans_ls = []
for k in range(len(dic2)):
    if dic2[k][1] != dic2[0][1]:
        break
    ans_ls.append(dic2[k][0])
ans_ls.sort()
for _ in ans_ls:
  	print(_)

Measured memory_bytes: 48308
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
/*swap 交換*/
void swap(llint *a, llint *b){llint c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
llint max2(llint a,llint b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
llint min2(llint a,llint b){return a>=b?b:a;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}
// 小大
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}


int main(void){
    llint i,j,ls,lt,mark=100,aa=0;
    char s[100],t[100];
    scanf("%s%s",s,t);
    ls = strlen(s);
    lt = strlen(t);
    for(i=ls-1-(lt-1);i>=0;i--){
        if(aa==1){
            for(j=0;j<lt;j++){
                if(s[i+j] == t[j] || (s[i+j]=='?' && t[j]=='a') ){
                }else{
                    break;
                }
            }
            if(j==lt){
                mark = i;
                break;
            }
        }
        if(aa==0){
            for(j=0;j<lt;j++){
                if(s[i+j] != t[j] && s[i+j] != '?') break;
            }
            if(j==lt){
                mark = i;
                aa++;
            }
        }
        
    }
    if(mark==100 || ls<lt){
        printf("UNRESTORABLE\n");
        return 0;
    }
    for(i=0;i<ls;i++){
        if(i==mark){
            // printf(" %lld ",i);
            for(j=0;j<lt;j++){
                printf("%c",t[j]);
                // s[i+j] = t[j];
            }
            i+=lt-1;
            continue;
        }
        if(s[i] == '?') s[i]= 'a';
        // printf(" %lld ",i);
        printf("%c",s[i]);
    }
    
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<s1[0]<<s2[1]<<s3[2]<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,c,r,h=0;
    cin>>x;
    c=x/500;
    r=x%500;
    h+=1000*c;
    c=r/5;
    h+=5*c;
    cout<<h;
    return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s;
    cin >> s;
    int a = 0;
    for(int i=0; i<4; i++){
        if(s[i] == '+') a++;
        else a--;
    }
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll powmod(ll x,ll n){
    if(n == 0)return 1;
    ll ans = powmod(x*x%MOD,n/2);
    if(n % 2)ans = ans * x % MOD;
    return ans;
}
ll divmod(ll a,ll b){
    return ((a%MOD) * (powmod(b,MOD-2)%MOD)) % MOD;
}
main(){
    int N;
    cin >> N;
    vector<ll> V(N),accu(N+1);
    rep(i,0,N)cin >> V[i];
    //accu[0] = divmod(1,N);
    rep(i,0,N)accu[i+1] = (accu[i] + divmod(1,i+1)) % MOD;
    ll ans = 0;
    ll all = 1;
    //rep(i,0,N)(all *= (i+1) ) %= MOD;
    rep(i,0,N){
        ll num = 0;
        /*
        if(i != 0)num = (num + accu[N-i] - accu[1] + MOD) % MOD;
        if(i != N-1)num = (num + accu[i+1] - accu[1] + MOD) % MOD;
        num = (num + accu[1]) % MOD;
        */
        num = (accu[N-i] + accu[i+1] - accu[1] + MOD) % MOD;
        num = (num * V[i]) % MOD;
        //num = (num * all) % MOD;
        ans = (ans + num) % MOD;
    }
    rep(i,0,N)ans = (ans * (i+1)) % MOD;
    cout << ans << endl;

}

Measured memory_bytes: 1792
readline = open(0).readline
writelines = open(1, 'w').writelines

Q = int(readline())
root = [None, None, None]
cursor = root[1] = [root, None, None]


def insert(x):
    global cursor
    cursor[0][1] = cursor[0] = cursor = [cursor[0], cursor, x]


def move(d):
    global cursor
    if d > 0:
        for _ in range(d):
            cursor = cursor[1]
    else:
        for _ in range(-d):
            cursor = cursor[0]


def erase():
    global cursor
    cursor[1][0] = cursor[0]
    cursor[0][1] = cursor = cursor[1]


C = [insert, move, erase].__getitem__
for q in range(Q):
    t, *a = map(int, readline().split())
    C(t)(*a)
root = root[1]
ans = []
while root[1]:
    ans.append("%d\n" % root[2])
    root = root[1]
writelines(ans)


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

int main(){
	int L;
	int M[12],N[12];
	while(1){
		cin >> L;
		if(L == 0) break;
		int money=0,cou=0;
		for(int i=0;i<12;i++){
			cin >> M[i] >> N[i];
		}
		for(int i=0;i<12;i++){
			money += M[i] - N[i];
			cou++;
			if(money >= L) break;
		}
		if(cou == 12 && money < L) cout << "NA" << endl;
		else cout << cou << endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ipair = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const int INF = 1001001001;

int c[10][1005];

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  rep(i, H) cin >> s[i];
  int ans = INF; 

  rep(div, 1<<(H-1)){
    int g = 0;
    vector<int> id(H);
    rep(i, H){
      id[i] = g;
      if(div>>i&1) ++g;
    }
    ++g;
    rep(i,g) rep(j, W) c[i][j] = 0;
    rep(i,H) rep(j, W) c[id[i]][j] += (s[i][j] - '0');

    int num = g-1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i, g) now[i] += c[i][j];
      rep(i, g) if(now[i] > K) return false;
      return true;
    };
    rep(j, W){
      if(!add(j)){
        num++;
        now = vector<int>(g);
        if(!add(j)){
          num = INF;
          break;
        }
      }
    }
    chmin(ans, num);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,m;
int a[110][110],b[110][110];
int dp[110][110][10010];
int main(){
    //ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
        scanf("%d",&b[i][j]);
        if(a[i][j]<b[i][j]) swap(a[i][j],b[i][j]);
    }
    memset(dp,0,sizeof(dp));
    dp[1][1][a[1][1]-b[1][1]]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i<n){
                for(int k=0;k<10010;k++) if(dp[i][j][k]){
                    int ret=abs(k+a[i+1][j]-b[i+1][j]);
                    if(ret>=0&&ret<10010){
                        dp[i+1][j][ret]=1;
                    }
                    ret=abs(k-a[i+1][j]+b[i+1][j]);
                    if(ret>=0&&ret<10010){
                        dp[i+1][j][ret]=1;
                    }        
                }
            }
            if(j<m){
                for(int k=0;k<10010;k++) if(dp[i][j][k]){
                    int ret=abs(k+a[i][j+1]-b[i][j+1]);
                    if(ret>=0&&ret<10010){
                        dp[i][j+1][ret]=1;
                    }
                    ret=abs(k-a[i][j+1]+b[i][j+1]);
                    if(ret>=0&&ret<10010){
                        dp[i][j+1][ret]=1;
                    }
                }
            }
        }
    }
    for(int k=0;k<10010;k++) if(dp[n][m][k]){
        printf("%d\n",k);
        return 0;
    }
    return 0;
}

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

#define rep(i,b) for(int i=0;i<(b);++i)
typedef pair<int,int> pii;
int h,w;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp[55][55][4];
vector<string> v;
bool check(int a,int b){
    if(0<=a&&a<h&&0<=b&&b<w) return true;
    return false;
}
int foo(int a,int b,int c){
    if(!check(a,b)) return 0;
    if(dp[a][b][c]>=0) return dp[a][b][c];
    dp[a][b][c]=0;
    int ret=0;
    if(v[a][b]=='G'){
        return dp[a][b][c]=1;
    }
    rep(k,4){
        int cc=(c-1+k+4)%4;
        if(v[a+dy[cc]][b+dx[cc]]!='#'){
            ret=foo(a+dy[cc],b+dx[cc],cc);
            break;
        }    
    }
    return dp[a][b][c]=ret;
}   

int main(){
    cin>>h>>w;
    v=vector<string>(h+2);
    rep(i,h) cin>>v[i+1];
    v[0]=v[h+1]=string(w+2,'#');
    rep(i,h){
        v[i+1]="#"+v[i+1]+"#";
    }
    h+=2;
    w+=2;
    char y[]="<^>v";
    pii pos;
    int vec;
    rep(i,h){
        rep(j,w){
            rep(k,4) if(v[i][j]==y[k]) pos=pii(i,j),vec=3-k,v[i][j]='.';
        }
    }
    rep(i,55) rep(j,55) rep(k,4) dp[i][j][k]=-1;
    foo(pos.first,pos.second,vec);
    set<pii> se;
    pii gg;
    rep(i,55){
        rep(j,55){
            if(check(i,j)&&v[i][j]=='G') gg=pii(i,j);
            rep(k,4){
                if(dp[i][j][k]==1) se.insert(pii(i,j));
            }
        }
    }
    if(se.find(gg)==se.end()) cout<<-1<<endl;
    else cout<<se.size()<<endl;
}

Measured memory_bytes: 1620
S = input()
Slist = []
for i in range(len(S)):
    Slist.append(ord(S[i]))
Slist = set(Slist)
i = 97
while i < 123:
    if i in Slist:
        i += 1
    else:
        print(chr(i))
        break
if i == 123:
    print('None')


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,k;
ll ans;
v3 dp;

int main(){
  cin >> n >> k;
  ll len = n*n*4+1;
  dp = v3(n+1,v2(n*n*4+1,vl(n+1)));
  dp[0][0][0] = 1;
  for(ll i = 1;i <= n;i++){
    for(ll j = 0;j < len;j++){
      for(ll l = 0;l <= i;l++){
        if(l+1 <= i) dp[i][(j-i-i+len)%len][l+1] += dp[i-1][j][l];
        dp[i][j][l] += dp[i-1][j][l];
        dp[i][j+i-i][l] += dp[i-1][j][l]*l;
        dp[i][j+i-i][l] += dp[i-1][j][l]*l;
        if(l-1 >= 0) dp[i][(j+i+i)%len][l-1] += dp[i-1][j][l]*l*l;
      }
    }
    for(ll j = 0;j < len;j++){
      for(ll l = 0;l <= i;l++){
        dp[i][j][l] %= mod;
      }
    }
  }
  cout << dp[n][k][0] << endl;
}


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

int main()
{
  int n,*a,count=0;
  int i,j,t,k,minj;

  
  scanf("%d",&n);

  a = (int *)malloc(n * sizeof(int));

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

  for(i=0;i<n;i++)
    {
      minj = i;
      for(j=i;j<n;j++)
	{
	  if(a[j] < a[minj])
	    {
	      minj = j;
	     
	    }
	  
	}
      if(i != minj)
	{
         t = a[minj];
	 k = a[i];
	 a[i] = t;
	 a[minj] = k;
	 count++;
	}
	
    }
   for(j=0;j<n;j++)
     {
       if (j != 0) printf(" ");
       printf("%d",a[j]);
     }
     printf("\n");
 
  printf("%d\n",count);
  
  return 0;
}



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

int tax(int p,int t){
return p+p*t/100;
}

int main(){
  int x,y,s;
 
for(int i=0;true;i++){
  cin >> x >> y >> s;
 if(x==0){
   break;
 }
 int a=0;
for(int j=1;j<s;j++){
  for(int k=s-1;j<=k&&k<=s;k--){
 if(tax(j,x)+tax(k,x)==s){
   if(tax(j,y)+tax(k,y)>a){
   a=tax(j,y)+tax(k,y);
   }   
  } 
  }   
}


  cout << a << endl;

}
}


Measured memory_bytes: 3080