akhauriyash/Code-Regression huggingface dataset:
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string s;
	std::cin >> s;
	
	auto first = std::find(s.begin(), s.end(), 'A');
	auto last  = std::find(s.rbegin(), s.rend(), 'Z').base();
	std::cout << (last - first) << "\n";
}


Measured memory_bytes: 640
#include <stdio.h>
 
int main(){
 
    int x,A,B,c,d;
    scanf("%d %d %d",&x,&A,&B);
    
    c = x >= A ? x - A : A - x;
    d = x >= B ? x - B : B - x;
    
    if(c<d) {
        printf("A\n");
    }
    else { 
        printf("B\n");
    }
 
  return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int a[100005];
int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		a[i + 1] = s[i] - 'a';//x==23
	} 
	int h = 1, b = s.size();
	int bb = 1;
	while (h < b) {
		if (a[h] == 23) {
			if (a[b] == 23) {
				h++;
				b--;
			} 
			else {
				while (a[h] == 23) {
					ans++;
					h++;
				}
				if (a[b] != a[h]) {
					bb = 0;
					break;
				}
				else {
					h++;
					b--;
				}
			}
		}
		else {
			if (a[b] == 23) {
				while (a[b] == 23) {
					ans++;
					b--;
				}
			}
			if (a[b] != a[h]) {
				bb = 0;
				break;
			}
			else {
				h++;
				b--;
			}
		}
	}
	if (bb)
		cout << ans;
	else cout <<-1;
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  for(int i=1;i<=9;i++){
    if(N%i==0 && N/i<10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(100000)
INF = float('inf')

K = int(sys.stdin.readline())

N = 50
ans = [a + K // N for a in range(N)]
for _ in range(K % N):
    min_a = min(ans)
    ans = [a + N if a == min_a else a - 1 for a in ans]
print(N)
print(*ans)


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    /**
     * 一番小さい要素つまり　1　から届く範囲を 1 に変えていくのが最適
     * 最初の 1 を含む範囲の選び方を全探索することに注意
     */
    int n,k; cin >> n >> k;
    int idx_1;
    vi a(n);
    rep(i,n) {
        cin >> a[i];
        if(a[i] == 1) idx_1 = i;
    }

    int left, right, ans = inf;
    for(int i = 0; i < k; ++i) {
        left = idx_1-k+1+i ,right = idx_1+i;
        int cnt = 1;
        for(; right < n-1; right += k-1) ++cnt;
        for(; left > 0; left -= k-1) ++cnt;
        chmin(ans, cnt);
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 640
use std::collections::BTreeMap;
use std::collections::BTreeSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

    let mut xlr = 0;
    let mut imap = BTreeMap::new();

    for i in 0..n {
        imap.insert(v[i], i);
    }

    let iter = imap.iter().rev();

    let mut iset = vec![0, 0, n+1, n+1];

    for (key, value) in iter {
        //println!("{:?}", iset);
        let index = match iset.as_slice().binary_search(&((*value)+1)) {
            Ok(v) => {v}
            Err(v) => {v}
        };
        let x = iset[index-1];
        let w = iset[index-2];
        let y = iset[index];
        let z = iset[index+1];

        xlr = xlr + ((x - w) * (y - (value+1)) + ((value+1) - x) * (z - y)) * key;

        iset.insert(index, (*value)+1);

        if key == &0 {
            break;
        }

    }

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

Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;

const int mn = 2e5 + 10;

long long n, ans, a[mn], l[mn], r[mn];

stack <int> sta;

int main () {
	ios::sync_with_stdio (false);
	
	cin >> n, a[0] = a[n + 1] = -inf;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	sta.push (0);
	
	for (int i = 1; i <= n; i++) {
		while (a[i] <= a[sta.top ()]) sta.pop ();
		l[i] = sta.top (), sta.push (i);
	}
	
	while (!sta.empty ()) sta.pop ();
	
	sta.push (n + 1);
	
	for (int i = n; i >= 1; i--) {
		while (a[i] < a[sta.top ()]) sta.pop ();
		r[i] = sta.top (), sta.push (i);
	}
	
	for (int i = 1; i <= n; i++)
		ans += a[i] * (i - l[i]) * (r[i] - i);
		
	cout << ans;
	
	return 0;
} 

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF 0x3f3f3f3f
#define MAX (1<<20)
#define MOD 1000000007
#define i64 long long
#define all(x) (x).begin() , (x).end()
#define sz(x) (int)(x).size()
#define ii pair<int, int>
#define fs first
#define sc second
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<ii>
#define vvii vector<vii>
#define lsb(x) ((x) & (-x))
#define gcd(x,y) __gcd((x),(y))

using namespace std;

int n;

int main(){_
    cin >> n;
    n %=10;
    if (n==2 || n==4 || n==5 || n==7 || n==9) cout << "hon"<< endl;
    else if (n==0 || n==1 || n==6 || n==8) cout << "pon"<< endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;


int main() {

	int n, m;

	cin >> n >> m;

	vector<pair<int, int>> a(m);

	REP(i, m) {
		cin >> a[i].first >> a[i].second;
		a[i].first--, a[i].second--;
	}

	std::sort(a.begin(), a.end(), [](pair<int, int> x, pair<int, int> y) {
		return x.second < y.second;
	});

	int ans = 0;
	int bef = -1;
	REP(i, m) {
		if (bef < a[i].first) {
			bef = a[i].second - 1;
			ans++;
		}
	}
	
	cout << ans NL;



	return 0;

}

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

int main(){
    unsigned long N, M;
    cin >> N >> M;
    deque<deque<bool>> edges(N, deque<bool>(N, true));
    for(unsigned long i = 0, a, b; i < M; ++i){
        cin >> a >> b;
        --a;
        --b;
        edges[a][b] = edges[b][a] = false;
    }
    vector<unsigned long> v(N);
    iota(v.begin(), v.end(), 0);
    unsigned long ans{0};
    do ans += [&]{
        for(unsigned long i = 1; i < N; ++i)if(edges[v[i - 1]][v[i]])return 0;
        return 1;
    }();
    while(next_permutation(v.begin() + 1, v.end()));
    cout << ans << endl;
    return 0;
}

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

long long gcd(long long a, long long b){
	if(a < b) return gcd(b, a);
  	long long r;
  	while ((r = a % b)) {
    	a = b;
    	b = r;
  	}
  	return b;
}

int main() {
	long long A, B, C, D;
	long long sum = 0;
	cin >> A >> B >> C >> D;
	long long lcm = (C * D) / gcd(C, D);
	if(A % C == 0){
		sum += B / C - A / C + 1;
	}
	if(A % C != 0){
		sum += B / C - A / C ;
	}
	if(A % D == 0){
		sum += B / D - A / D + 1;
	}
	if(A % D != 0){
		sum += B / D - A / D;
	}
	if(A % lcm == 0){
		sum -= (B / lcm - A / lcm + 1);
	}
	if(A % lcm != 0){
		sum -= (B / lcm - A / lcm);
	}
	cout << B - A + 1 - sum << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 ALLAH is Almighty....
*/
#include <bits/stdc++.h>

#define ll  long long
using namespace std;

const ll mx = 10e5 + 9;
ll n, m;
string st1, st2, st;
ll dp[ 3005 ][ 3005 ];


void solve( )
{
    cin >> st1 >> st2;
    n = st1.size();
    m = st2.size();

    for ( ll i = 0; i <= n; ++i )
        for ( ll j = 0; j <= m; ++j ) {
            if( i == 0 || j == 0 )
                dp[ i ][ j ] = 0;
            else if ( st1[ i - 1 ] == st2[ j - 1 ] )
                dp[ i ][ j ] = 1 + dp[ i - 1 ][ j - 1 ];
            else
                dp[ i ][ j ] = max( dp[ i - 1 ][ j ], dp[ i ][ j - 1 ] );
        }

    ll i = n, j = m;
    while (i && j ) {
        if ( dp[ i ][ j ] == dp[ i ][ j - 1 ] )
            j--;
        else if( dp[ i ][ j ] == dp[ i - 1 ][ j ] )
            i--;
        else {
            st = st2[ j - 1 ] + st;
            i--;
            j--;
        }
    }

    cout << st << endl;;
}

int main()         // Md. Inzamam-ul Haque
{
    solve();
}

/*
AGGTAB
GXTXAYB

abcde
bdgek
*/

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    for (int i = 1; i <= 3; ++i) {
        if ((n * m * i) & 1) {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = a*x + b*y;
    chmin(ans, max(x,y)*2*c);
    if(x < y) chmin(ans, x*2*c + (y-x)*b);
    else chmin(ans, (x-y)*a + y*2*c);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    string S;
    cin >> S;
    for (int bit = 0; bit < (1 << 3); ++bit) {
        int tmp = (int)(S[0] - '0');
        string ans = "";
        ans += S[0];
        rep(i, 3) {
            if (bit & (1 << i)) {
                tmp += (int)(S[i + 1] - '0');
                ans += "+";
            }
            else {
                tmp -= (int)(S[i + 1] - '0');
                ans += "-";
            }
            ans += S[i + 1];
        }
        if (tmp == 7) {
            cout << ans + "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int i,j;
  int n,a,b,c,x;
  int y[100]={};
  while(1){ 
    cin>>n>>a>>b>>c>>x;
    if(n+a+b+c==0)break;
    rep(i,n)
      cin>>y[i];
    int ans=0;
    i=0;
    while(1){
      if(x==y[i])i++;
      int next=(a*x+b)%c;
      x=next;
      if(i==n)break;
      ans++;
      if(ans>10000)break;
    }
    if(ans>10000)
      cout<<"-1"<<endl;
    else
      cout<<ans<<endl;
  }
}

Measured memory_bytes: 3036
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){}
void jury(){}
void solve(){
  int n = scan!int;
  int cnt;
  string ans = "No";
  foreach(_; 0 .. n){
    int a = scan!int, b = scan!int;
    if(a == b) cnt += 1;
    else cnt = 0;
    if(cnt >= 3) ans = "Yes";
  }
  ans.print;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    int num = stoi(a + b);
    string ans = "No";
    for (int i = 0; i <= 1000; i++) {
        if(i * i == num) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
TASK: <Task>
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define EPS 1e-9
#define ALL(x) (x).begin(),(x).end()
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define FOR(i,st,ed) for(int (i)=(st);(i)<(ed);(i)++)
typedef pair<int,int> PII;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long LL;

int N,M,T;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("xxx.in","r",stdin);
	//freopen("xxx.out","w",stdout);
	int i,j,k;
	string s;
	cin >> s;
	s[0]='2';
	s[1]='0';
	s[2]='1';
	s[3]='8';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
/*
ID: your_id_here
PROG: test
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define pis        pair<int,string>
#define vi         vector<int>
#define x         first
#define y         second
//#define max(a,b) a<b?b:a __builtin_popcount;
//#define min(a,b) a<b?a:b
const ll M  = 1e9+7 ;
const int N = 100100;
//////////////////////    Hi    ^_^  hack me if you can :P

int main()
{
    //freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
    //speed;
    int n;
    char x[100100];

    scanf("%s",x);
    n=strlen(x);
    printf(((n%2)^(x[0]!=x[n-1]))?"Second\n":"First\n");

    r0;
}

/*

freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}
Wj0944296025*
http://ideone.com/KrXO2S
*/
/*
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy){
    if(!m) {d=n; xx=1; yy=0;}
    else {gcd(m,n%m,d,yy,xx); yy-=xx*(n/m);}
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

*/


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3648
package main

import (
	"fmt"
	"sort"
	"strconv"
	"strings"
)

var num []int

func dfs(step int, s string) {
	if step >= 3 {
		if strings.Count(s, "3") > 0 && strings.Count(s, "5") > 0 && strings.Count(s, "7") > 0 {
			v, _ := strconv.Atoi(s)
			num = append(num, v)
		}
		if step == 9 {
			return
		}
	}
	for i := 0; i < len("357"); i++ {
		dfs(step+1, s+string("357"[i]))
	}
}

func main() {
	var N int
	fmt.Scan(&N)
	dfs(0, "")
	sort.Ints(num)
	// fmt.Println("len(num)", len(num), "num[0:10]", num[0:10])
	ans := 0
	for i := 0; i < len(num); i++ {
		if num[i] <= N {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int main(){ 
  ll x, y;
  cin >> x >> y;
  ll res  = 1e18;
  if (x <= y) res = y - x;
  if (-x <= y) res = min(res, y + x + 1);
  if (x <= -y) res = min(res, -y - x + 1);
  if (-x <= -y) res = min(res, -y + x + 2);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
r,c=map(int,raw_input().split())
a=[map(int,raw_input().split()) for i in range(r)]
b=[0 for i in range(c+1)]
for i in range(r):
    a[i].append(sum(a[i]))
    for j in range(c+1):
        b[j]+=a[i][j]
a.append(b)
l=""
for i in range(r+1):
    for j in range(c+1):
        print (a[i][j]),
    print


Measured memory_bytes: 4696
// Code for B - String Palindrome
#include <iostream>
#include <string>
using namespace std;

bool palindrome(string s) {
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    if ( s[i] != s[n - i - 1] ) {
      return false;
    }
  }

  return true;
}

string substr(string s, int x, int y) {
  return s.substr(x, y - x);
}

int main() {
  string s;
  int n;
  cin >> s;
  n = s.size();

  if (!palindrome(s)) {
    cout << "No" << endl;
    return 0;
  }

  if (!palindrome(substr(s, 0, (n - 1) / 2))) {
    cout << "No" << endl;
    return 0;
  }

  if (!palindrome(substr(s, (n + 3) / 2 - 1, n))) {
    cout << "No" << endl;
    return 0;
  }

	cout << "Yes" << endl;
	return 0;
}


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

int main(){
    int n, a;
    cin>>n>>a;
    n = n%500;
    if(n<=a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define inv(x) qpow(x,mod-2)
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=200010;
const LL mod=1e9+7;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n;
int fa[N],son[N];
int Max[N],dep[N],sz[N];
int bgn[N],nxt[N],to[N],e;
int Bgn[N],Nxt[N],To[N],E;
LL w[N][3],ans;
inline void add_edge(int u,int v){nxt[++e]=bgn[u],bgn[u]=e,to[e]=v;}
inline void Add(LL &x,LL y){x=x+y<mod?x+y:x+y-mod;}
inline LL qpow(LL a,LL b)
{
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
inline void dfs_dep(int u)
{
	Max[u]=dep[u]=dep[fa[u]]+1;
	sz[dep[u]]++;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		dfs_dep(v=to[i]);
		if(chkmax(Max[u],Max[v]))son[u]=v;
	}
}
inline void dfs_ans(int u)
{
	if(son[u])dfs_ans(son[u]),Bgn[u]=Bgn[son[u]];
	int len=0;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==son[u])continue;
		dfs_ans(v);
		for(int now=1,x=Bgn[u],y=Bgn[v];y;x=Nxt[x],y=Nxt[y],now++)
		{
			if(chkmax(len,now))Add(w[x][0],w[x][2]),w[x][2]=0;
			Add(w[y][0],w[y][2]),w[y][2]=0;
			w[x][2]=w[x][2]*(w[y][0]+w[y][1])%mod;
			Add(w[x][2],w[x][1]*w[y][1]%mod);
			w[x][1]=w[x][1]*w[y][0]%mod;
			Add(w[x][1],w[x][0]*w[y][1]%mod);
			w[x][0]=w[x][0]*w[y][0]%mod;
		}
	}
	Nxt[++E]=Bgn[u];Bgn[u]=E;w[E][0]=w[E][1]=1;
}
int main()
{
	file();
	read(n);n++;
	For(i,2,n)
	{
		read(fa[i]);fa[i]++;
		add_edge(fa[i],i);
	}
	dfs_dep(1);
	dfs_ans(1);
	for(int len=1,x=Bgn[1];x;x=Nxt[x],len++)Add(ans,w[x][1]*qpow(2,n-sz[len])%mod);
	printf("%lld\n",ans);
	return 0;
}


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

typedef long int lint;
typedef long long int llint;
#define rep(i, f, n) for (int (i) = (f); i < (n); i++)

const int money = 10000;

int main()
{
  int n;
  double y, b, r, t, o;
  while (cin >> n, n){
    cin >> y;
    double res = 0, num;
    rep(i, 0, n){
      cin >> b >> r >> t;
      if (t == 1){
        num = money * (1 + y * r / 100);
        if (res < num){
          res = num;
          o = b;
        }
      }
      else if (t == 2){
        num = money * pow(1 + r / 100, y);
        if (res < num){
          res = num;
          o = b;
        }
      } 
    }
    cout << o << endl;
  }
}

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

int main(){
	string str;
	cin >> str;
	int d[26] = {0};
	for(int e = 0; e < str.length(); e++){
		d[ str[e] - 'a']++;
	}

	for(auto e : d) if(e%2!=0) {cout << "No" << endl; return 0;}
//	for(auto e: d){cout << e << endl;}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (p.at(i) != i + 1) cnt++;
	}
	if (cnt <= 2) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf (1LL<<60)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, M; cin >> N >> M;
    vll a(M), b(M), c(M);
    rep(i, M) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--, c[i] = -c[i];

    vll dist(N, inf); dist[0] = 0;
    rep(_, N) rep(i, M) {
        if (dist[a[i]] == inf) continue;

        if (dist[b[i]] > dist[a[i]] + c[i]) dist[b[i]] = dist[a[i]] + c[i];
    }

    ll ans = dist[N-1];

    vector<bool> negative(N, false);
    rep(_, N) rep(i, M) {
        if (dist[a[i]] == inf) continue;

        if (dist[b[i]] > dist[a[i]] + c[i]) {
            negative[b[i]] = true;
            dist[b[i]] = dist[a[i]] + c[i];
        }

        if (negative[a[i]]) negative[b[i]] = true;
    }

    if (negative[N-1]) cout << "inf" << endl;
    else cout << -ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
a = list(map(int,input().split()))
L = [1]
La = [0] * n
La[0] = 1
tmp = a[0]
while True:
    L.append(tmp)
    if La[tmp-1] == 0:
        La[tmp-1] = 1
        tmp = a[tmp-1]
    else:        
        break
po = L.index(L[-1])
base = len(L) - po - 1
if po > m:
    ans = m
else:
    ans = (m - po) % base + L.index(L[-1])

print(L[ans])

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi l(n), r(n);
    l[0] = a[0]; r[n-1] = a[n-1];
    rep1(i, n-1) l[i] = gcd(l[i-1], a[i]);
    repr(i, n-1) r[i] = gcd(r[i+1], a[i]);
    int ans = 0;
    rep(i, n) {
        if (i==0) ans = max(ans, r[i+1]);
        else if (i==n-1) ans = max(ans, l[i-1]);
        else ans = max(ans, (int)gcd(l[i-1], r[i+1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4240
a = int(input())
b = int(input())
c = int(input())
total = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            sum_kozeni = i * 500 + j * 100 + k * 50  
            if sum_kozeni == total:
                count += 1
            elif sum_kozeni > total:
                break
print(count)

Measured memory_bytes: 9192
import java.util.Scanner;


	public class Main {
		
		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int m = sc.nextInt();
			boolean[] a = new boolean[n+1];
			long[] dp = new long[n+1];
			
			for(int i=0;i<m;i++) {
				a[sc.nextInt()] = true;
			}
			
			dp[0] = 1;
			
			for(int i=1;i<=n;i++) {
				if(a[i]) {
					continue;
				}else {
					dp[i]+=dp[i-1]%1000000007L;
					dp[i]%=1000000007L;
					
					if(i>=2) {
						dp[i]+=dp[i-2]%1000000007L;
						dp[i]%=1000000007L;
					}
				}
			}
			
			System.out.println(dp[n]);
	    }
		
	}
	


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
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(a >= b){a = b; return true;}return false;}


int main(void){
    string s;
    cin >> s;
    int a[4];
    a[0] = stoi(s.substr(0,1));
    a[1] = stoi(s.substr(1,1));
    a[2] = stoi(s.substr(2,1));
    a[3] = stoi(s.substr(3,1));
    for(int bit = 0; bit < (1<<3); bit++){
        int sum = a[0];
        string ans = to_string(a[0]); 
        for(int i = 0; i < 3; i++){
            if(bit&(1<<i)){
                sum += a[i+1];
                ans += '+';
            }else{
                sum -= a[i+1];
                ans += '-';
            }
            ans += to_string(a[i+1]);
        }
        if(sum == 7){
            ans += "=7";
            cout << ans << endl;
            return 0;
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int n,ans;
int dig (int x){
    int sum = 0;
    while(x>0){
        sum++;x/=10;
    }
    return sum;
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        if(dig(i)%2==1)ans++;
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split("");
    int ans = 0;
    for(int i=0; i<4; i++) {
      if(str[i].equals("+"))
        ans++;
      else
        ans--;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
#include<queue>
#include<vector>
#include<cstdio>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
  int a,b,c,ans;
  cin>>a>>b>>c;
  int big=max(a,max(b,c));
  ans=(big*3-a-b-c)/2;
  if((big*3-a-b-c)%2)
    ans+=2;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int x = 0;

    cin >> x ;

    if(x == 0)
    cout << 1 << endl;
    else
    cout << 0 << endl;
    
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
          string S;
          cin >> S;

          int ans=0;

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

          cout << ans << endl;

          return 0;
}


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

int GetDigit(ll x){
  int cnt = 0;
  while (x > 0) {
    x /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
  ll n;
  cin >> n;
  
  int ans = 100;

  for (ll i=1; i<= sqrt(n); i++){
    if (n%i == 0){
      ans = min(ans, GetDigit(n/i));
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<map>
#include<deque>
struct C{int r,i;
C(long r):r(r),i(0){}
C(int r,int i):r(r),i(i){}
C operator+(C a){return C(r+a.r,i+a.i);}
C operator-(C a){return C(r-a.r,i-a.i);}
C operator*(C a){return C(r*a.r-i*a.i,r*a.i+i*a.r);}
};
typedef std::pair<char,C>P;
typedef std::deque<P>D;
int F(C c){return (c.r<-10000||c.r>10000||c.i<-10000||c.i>10000);}
void Print(C c){printf("%d %di\n", c.r, c.i);}
int main()
{
	int i,j;
	char*p,*q,s[256];
	C a(0),b(0);
	while(scanf("%s",s)==1)
	{
		D d, t;
		for(p=s;*p;)
		{
			if(isdigit(*p))
			{
				d.push_back(P(0,strtol(p,&q,10)));
				p=q;
			}
			else
			{
				if(*p=='i')d.push_back(P(0,C(0,1)));
				else if(*p=='(')t.push_back(P(*p,0));
				else if(*p=='*')
				{
					while(t.size()&&t.back().first=='*')d.push_back(t.back()),t.pop_back();
					t.push_back(P(*p,0));
				}
				else if(*p==')')
				{
					while(t.back().first!='(')d.push_back(t.back()),t.pop_back();
					t.pop_back();
				}
				else
				{
					while(t.size()&&t.back().first!='(')d.push_back(t.back()),t.pop_back();
					t.push_back(P(*p,0));
				}
				++p;
			}
		}
		while(t.size())d.push_back(t.back()),t.pop_back();
		for(i=0; i<d.size(); ++i)
		{
			if(j=d[i].first)
			{
				b=t.back().second;t.pop_back();
				a=t.back().second;t.pop_back();
				if(F(a)||F(b))goto E;
				t.push_back(P(0,j=='+'?a+b:j=='-'?a-b: a*b));
			}
			else t.push_back(d[i]);
		}
		a=t.back().second;
		if(F(a))goto E;
		if(!a.i)printf("%d\n",a.r);
		else if(!a.r)printf("%di\n",a.i);
		else printf("%d%+di\n",a.r,a.i);
		continue;
		E:;
		puts("overflow");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
 
using namespace std;
 
int main(void) {
  string s, t;
  int cnt = 0;
  cin >> s;
  cin >> t;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    (int)(s.length());
    int n = s.length();
    int num = 0;
    for(int i=0;i<(n/2);i++){
        if(s[i]!=s[n-1-i]){
            num += 1;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
int n;
map<string, int> ans = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		string s; cin >> s;
		ans[s]++;
	}
	cout << "AC x " << ans["AC"] << "\n";
	cout << "WA x " << ans["WA"] << "\n";
	cout << "TLE x " << ans["TLE"] << "\n";
	cout << "RE x " << ans["RE"] << "\n";
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;

namespace ALDS1_3
{
    class Program
    {
        static void Main(string[] args)
        {
            var stack = new Stack<int>();
            foreach (var op in Console.ReadLine().Split())
            {
                int num;
                if (int.TryParse(op, out num))
                {
                    stack.Push(num);
                }
                else
                {
                    stack.Push(Calc(op, stack.Pop(), stack.Pop()));
                }
            }

            Console.WriteLine(stack.Pop());
        }

        private static int Calc(string operat, int operand1, int operand2)
        {
            switch (operat)
            {
                case "+":
                    return operand2 + operand1;
                case "-":
                    return operand2 - operand1;
                case "*":
                    return operand2 * operand1;
            }
            return 0;
        }

    }
}

Measured memory_bytes: 6012
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int ExGCD(int a, int b, int &x, int &y){
    int d=a;
    x=1; y=0;
    if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
    return d;
}

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >> b;
        int x,y,d;
        d = ExGCD(a, b, x, y);
        if(d <= 50000){
            printf("3\n0 0\n%d %d\n%d %d\n", a, b, abs(y), abs(x));
        }else{
            printf("4\n0 0\n%d %d\n%d %d\n%d %d\n", a-1, b, a/d, b/d, a, b-1);
        }
    }
    return 0;
}



Measured memory_bytes: 3188
N, T = map(int, input().split())
cost = float('inf')
FLAG = False

for i in range(N):
    c, t = map(int, input().split())
    
    if (t <= T):
        cost = min(cost, c)
        FLAG = True

if (FLAG):
    print(cost)
else:
    print('TLE')

Measured memory_bytes: 3060
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[][] position = new int[n][2];
		for (int i = 0; i < position.length; i++) {
			position[i][0] = sc.nextInt();
			position[i][1] = sc.nextInt();
		}
		
		int[][] cp = new int[m][2];
		for (int i = 0; i < cp.length; i++) {
			cp[i][0] = sc.nextInt();
			cp[i][1] = sc.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			int ans = 0;
			for (int j = 0; j < m; j++) {
				int distance = Math.abs(position[i][0] - cp[j][0]) + Math.abs(position[i][1] - cp[j][1]);
				if (distance < min) {
					min = distance;
					ans = j + 1;
				}
;			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21716
/*
 in the name of god

for good future keep working ;-)
ahj ++> JANI
*/
#include <bits/stdc++.h>
#define migmig ios::sync_with_stdio(false)
#define ll long long
#define BIG(N) const int N
#define pb push_back
#define go while(t--)
#define mp make_pair

using namespace std;
const int N = 1e5 + 10;
vector <int> v[N];
bool vis[N];
void dfs(int i){
	vis[i] = true;
	for(int j = 0 ; j < v[i].size() ; j++){
		if(!vis[v[i][j]]){
			dfs(v[i][j]);
		}
	}
}

int main(){
	int n ,m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x , y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x); 
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			ans ++;
			dfs(i);
		}
	}
	cout << ans -1 << endl;
}


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

int main(){
  int N;
  cin>>N;
  string S[N];
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S[i]==S[j]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int i=1;i<N;i++){
    int p=S[i-1].length()-1;
    if(!(S[i].substr(0,1)==S[i-1].substr(p,1))){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}

  


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    
    int n;
    cin>>n;
    
    ll a,b;
    
    vector<tuple<ll, ll, ll>> ab(n);
    
    for(int i=0; i<n; i++){
        cin >> a >> b;
        ab[i] = make_tuple(a+b, a, b);
    }
    
    sort(ab.rbegin(), ab.rend());
    
    ll ans = 0LL;
    
    for(int i=0; i<n; i++){
        if(i%2==0)
            ans += get<1>(ab[i]);
        else
            ans -= get<2>(ab[i]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 2560
N,M = gets.chomp.split.map(&:to_i)
conds = []
M.times do 
	conds << gets.chomp.split.map(&:to_i)
end
  
l,r = conds[0][0],conds[0][1]

conds.each{|cond|
  l = cond[0] if l < cond[0]
  r = cond[1] if r > cond[1]
}

result = r - l + 1
ans =  result > 0 ? result : 0
puts ans

Measured memory_bytes: 9596
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	ll n,i=1,ans=0,cnt=2;
	cin>>n;
	while(n>=i)
	{
		n-=i;
		i++;
		ans++;
	}
	// cout<<n<<" ";
	if(n==0)
		cout<<ans;
	else
		cout<<1+ans;
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [u64;n],
    }

    for i in 0..n - k {
        if a[i] >= a[i + k] {
            println!("No");
        } else {
            println!("Yes");
        }
    }
}


Measured memory_bytes: 5564