akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Data{
	Data(){
		index = 0;
	}
	void add(int data){
		wrong_data[index] = data;
		index++;
	}

	int wrong_data[10],index;
};

int main(){

	int n,table[10][10],check[10][10];
	Data tmp_check[10];

	scanf("%d",&n);

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

		for(int k = 1; k <= 9; k++){
			for(int p = 1; p <= 9; p++){
				scanf("%d",&table[k][p]);
				check[k][p] = 0;
			}
		}

		for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;


		for(int col = 1; col <= 9; col++){
			for(int row = 1; row <= 9; row++){
				tmp_check[table[row][col]].add(row);
			}

			for(int k = 1; k <= 9; k++){
				if(tmp_check[k].index > 1){
					for(int p = 0; p < tmp_check[k].index; p++){
						check[tmp_check[k].wrong_data[p]][col]++;
					}
				}
			}

			for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;
		}

		for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;

		for(int row = 1; row <= 9; row++){
			for(int col = 1; col <= 9; col++){
				tmp_check[table[row][col]].add(col);
			}

			for(int k = 1; k <= 9; k++){
				if(tmp_check[k].index > 1){
					for(int p = 0; p < tmp_check[k].index; p++){
						check[row][tmp_check[k].wrong_data[p]]++;
					}
				}
			}

			for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;
		}

		for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;


		for(int row = 1; row <= 7; row+= 3){
			for(int col = 1; col <= 7; col += 3){

				for(int k = 0; k < 3; k++){
					for(int p = 0; p < 3; p++){
						tmp_check[table[row+k][col+p]].add(10*(row+k)+col+p);
					}
				}

				for(int k = 1; k <= 9; k++){
					if(tmp_check[k].index > 1){
						for(int p = 0; p < tmp_check[k].index; p++){
							check[tmp_check[k].wrong_data[p]/10][tmp_check[k].wrong_data[p]%10]++;
						}
					}
				}

				for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;
			}
		}

		if(i > 0)printf("\n");

		for(int row = 1; row <= 9; row++){
			for(int col = 1; col <= 9; col++){
				if(check[row][col] >= 1){
					printf("*%d",table[row][col]);
				}else{
					printf(" %d",table[row][col]);
				}
			}
			printf("\n");
		}

	}

    return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    int k; cin >> k;
    string a;
    cin >> a;
    lol len = a.length();
    if(len <= k)
        cout << a << endl;
    else
    {
        REP(i, k)
        {
            cout << a[i];
        }
        cout << "..." << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
const int N=100*1000;
const int mod=1e9+7;
 
int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}
 
//#define int int64_t
int a[N+2];
 
int32_t  main(){
	IOS;
  for(int i=1;i<=5;++i)cin>>a[i];
  int k;cin>>k;
  for(int i=1;i<=5;++i){
    for(int j=i+1;j<=5;++j){
      if(abs(a[i]-a[j])>k){
        cout<<":(\n";
        return 0;
      }
    }
  }
  cout<<"Yay!\n";
 
  return 0;
}



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

double angle(double a,double b){
	double p = a/(abs(a)+abs(b));
	if (b<0){
		return p-1;
	}else{
		return 1-p;
	}
}

bool com(pair<double,double> a,pair<double,double> b){
	return atan2(a.first,a.second) < atan2(b.first,b.second);
}

int main(){
	int n;cin>>n;
	vector<pair<double,double>> vecs(n);
	for(int i=0;i<n;++i){
		double a;double b;
		cin>>a>>b;
		vecs[i] = {a,b};
	}
	sort(vecs.begin(),vecs.end(),com);
    /*
	for(auto i:vecs){
		cout<<i.first<<" "<<i.second<<endl;
	}
    */
	double result = 0;
	for(int i=0;i<n;++i){
		pair<double,double> pr = {0.0, 0.0};
		for(int j=0;j<n;++j){
			pr.first += vecs[(i+j)%n].first;
			pr.second += vecs[(i+j)%n].second;
            result = max(result,sqrt(pr.first*pr.first + pr.second*pr.second));
		}
	}
	cout<<setprecision (30)<<result<<endl;
	return 0;
}

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

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

int Num[4];
char op[3];
void solve(){
    for (int bit = 0; bit < (1 << 3); bit++){
        int sum = Num[0];
        for (int i = 0; i < 3; i++){
            if(bit & (1<<i)){
                op[i] = '+';
                sum += Num[i+1];
            }else{
                op[i] = '-';
                sum -= Num[i+1];
            }
        }
        if(sum==7){
            break;
        }
    }
    printf("%d%c%d%c%d%c%d=7",Num[0],op[0],Num[1],op[1],Num[2],op[2],Num[3]);
}

int main(){
    int S;
    scanf("%d",&S);
    Num[0] = S/1000;
    Num[1] = S%1000/100;
    Num[2] = S%100/10;
    Num[3] = S%10;
    solve();
}

Measured memory_bytes: 256
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> a >> b;
  cout << max(0ll, a - b * 2);
}

Measured memory_bytes: 2304
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

int N, X, Y;

struct MyStruct
{
	int no;
	vector<int>list;
	int kyori = -1;
};

struct MyStruct2
{
	vector<int>list;
};

vector<MyStruct>stlist(20000);
vector<int>flag(20000, 999999);
vector<int>flag2(20000, 0);
vector<int>flag5(20000, 999999);
vector<vector<bool>>flag4(2005, vector<bool>(2005, false));


int func(int index, int kyori, int moto) {

	if (flag[index] <= kyori) {
		return 0;
	}

	flag[index] = kyori;
	////if (flag4[index][moto] == false || flag4[moto][index] == false) {
	//if (flag4[index][moto] == false ) {
	//	flag2[kyori]++;
	//	flag4[index][moto] = true;
	//	//flag4[moto][index] = true;
	//}
	//else {
	//	return 0;
	//}
	

	for (int i = 0; i < stlist[index].list.size(); i++) {
		func(stlist[index].list[i], kyori + 1, moto);
	}


	return 0;
}



signed main() {

	cin >> N >> X >> Y;
	X--; Y--;

	for (int i = 0; i < N - 1; i++) {
		stlist[i].list.push_back(i + 1);
	}

	for (int i = N - 1; i > 0; i--) {
		stlist[i].list.push_back(i - 1);
	}

	stlist[X].list.push_back(Y);
	stlist[Y].list.push_back(X);
	vector<int>flag3(20000, 0);

	for (int i = 0; i < N; i++) {
		//func(0, 0);
		func(i, 0, i);
		//flag = flag3;
		for (int j = 0; j < N; j++) {
			flag3[flag[j]]++;
		}
		flag = flag5;
	}

	for (int i = 1; i < N; i++) {
		cout << flag3[i] / 2 << endl;
	}


	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++)cin >> data.at(i);
  sort(data.begin(), data.end());
  int flag = 1;
  for(int i = 0; i < N - 1; i++){
    if(data.at(i) == data.at(i + 1)){
      flag = 0;
    }
  }
  cout << (flag?"YES":"NO") << endl;
  return 0;
}

Measured memory_bytes: 1024
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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

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")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input! {
        N: usize,
        s: [chars; N],
    }
    let mut count = 0;
    let mut count2 = (0usize, 0usize, 0usize);
    for ind in 0..N {
        let las = s[ind].len() - 1;
        if s[ind][0] == 'B' && s[ind][las] == 'A' { count2.0 += 1; }
        else if s[ind][0] == 'B' { count2.1 += 1; }
        else if s[ind][las] == 'A' { count2.2 += 1; }
        for ii in 0..las {
            if s[ind][ii] == 'A' && s[ind][ii+1] == 'B' 
            { count += 1; }
        } 
    }
    if count2.2 == 0 && count2.1 == 0{
        count += count2.0.saturating_sub(1);
    } else if count2.2 == 0 {
        count += count2.0;
    } else if count2.1 == 0 {
        count += count2.0;
    } else {
        count += count2.0 + 1;
        count += cmp::min(count2.2-1, count2.1-1);
    }
    println!("{}", count)
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main()
{
 	int n;
  int arr[100005];
  cin >> n;int i;
  for (i=0;i < n; i++)
    	cin >> arr[i];
  int dp[100005];
  dp[0]=0;
  dp[1] = abs(arr[1] - arr[0]);
  for ( i=2; i <= n; i++)
  {
    dp[i] = min( dp[i-1] + abs( arr[i]-arr[i-1]),dp[i-2] + abs(arr[i]-arr[i-2])); 
  }
  cout << dp[n-1];
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

const int MAX_BIT = 100;

int main() {
    ll n, k;
    cin >> n >> k;
    bitset<MAX_BIT> kbit = bitset<MAX_BIT>(k);
    vector<bitset<MAX_BIT> > abits(n);
    rep(i, n) {
        ll in; cin >> in;
        abits[i] = bitset<MAX_BIT>(in);
    }

    bool enable1 = false;
    bool always = false;
    ll ans = 0;
    for(int i = MAX_BIT - 1; i >= 0; i--) {
        if (kbit[i] == 1) enable1 = true;

        ll count0 = 0; ll count1 = 0;
        for(bitset<MAX_BIT> abit: abits) {
            if (abit[i] == 0) count0++;
            else count1++;
        }

        if (count0 > count1 && (enable1 | always)) {
            ans += powl(2, i) * count0;
            enable1 = false;
        }
        else {
            ans += powl(2, i) * count1;
            if (enable1) always = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#define LLINF 1000000000000000000LL

using namespace std;
typedef long long ll;

int myupper_bound(vector<ll>& v, ll x)
{
  int lb = 0, ub = v.size() - 1;
  while (abs(ub - lb) > 1) {
    int mid = (lb + ub) / 2;
    if (v[mid] <= x) lb = mid;
    else ub = mid;
  }
  return ub;
}

int main()
{
  int A, B; cin >> A >> B;
  int Q; cin >> Q;
  vector<ll> s(1, -LLINF), t(1, -LLINF);
  for (int i = 0; i < A; i++) {
    ll si; cin >> si;
    s.push_back(si);
  }
  s.push_back(LLINF);
  for (int i = 0; i < B; i++) {
    ll ti; cin >> ti;
    t.push_back(ti);
  }
  t.push_back(LLINF);

  for (int q = 0; q < Q; q++) {
    ll x; cin >> x;
    int su = myupper_bound(s, x);
    int tu = myupper_bound(t, x);
    cerr << "[" << su << ", " << tu << "]" << endl;
    ll ans = LLINF;
    for (int i = su - 1; i <= su; i++) {
      for (int j = tu - 1; j <= tu; j++) {
        ll d1 = abs(s[i] - x) + abs(t[j] - s[i]);
        ll d2 = abs(t[j] - x) + abs(s[i] - t[j]);
        ans = min({ans, d1, d2});
      }
    }
    cerr << " -> ";
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

using int64 = long long;


const int mod = 1e9 + 7;

int main() {
  int N, A[21][21];
  cin >> N;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  vector< int64 > dp(1 << N);
  dp[0] = 1;
  vector< int > pop[22];
  for(int i = 0; i < (1 << N); i++) {
    pop[__builtin_popcount(i)].emplace_back(i);
  }
  for(int i = 0; i < N; i++) {
    for(auto &p : pop[i]) {
      for(int k = 0; k < N; k++) {
        if((p >> k) & 1) continue;
        if(A[i][k] == 0) continue;
        (dp[p | (1 << k)] += dp[p]) %= mod;
      }
    }
  }

  cout << dp.back() << endl;

}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n, p;
    cin >> n >> p;

    string s;
    cin >> s;
    if (p == 2 || p == 5) {
        li res = 0;
        rin{
            if ((s[i] - '0') % p == 0) {
                res += i + 1;
            }
        }
        cout << res << endl;
        return 0;
    }
    map<li, li> cnt;
    cnt[0] = 1;
    li now = 0;
    li ju = 1;
    li res = 0;
    for (li i = n - 1; i >= 0; i--) {
        now = (now + (s[i] - '0') * ju) % p;
        res += cnt[now];
        cnt[now]++;
        ju = ju * 10 % p;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 4152
n = gets.to_i
@s = gets.chomp

@h = Hash.new{|h, k| h[k] = []}
@s.each_char.with_index(1){|c, i| @h[c] << i}
@s = " " + @s

def update(i, c)
  d = @s[i]
  return if c == d
  @s[i] = c
  @h[d].delete_at(@h[d].bsearch_index{|x| x >= i})
  @h[c].insert((@h[c].bsearch_index{|x| x >= i} || -1), i)
end

gets
readlines.each do |x|
    a, b, c = x.chomp.split
    b = b.to_i

    if a == '1'
        update(b, c)
    else
        c = c.to_i
        puts @h.each_value.count {|e| (e.bsearch{|x| x >= b} or n+1) <= c}
    end
end


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

int main(){
	int Num;
	cin >> Num;
	if(Num<1 && 81<Num){
		cout << "No" << endl;
		return 0;
	}
	
	int i=1;
	for(i=1; i<10; i++){
		if(Num%i==0){
			int N=Num/i;
			if(N<10){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

signed main() {
  int n, X;
  cin >> n >> X;
  vi diff, x;
  REP(i, n) { x.PB(read()); }
  x.PB(X);
  sort(ALL(x));
  int ans = 0;
  FOR(i, 1, n + 1) { ans = gcd(ans, x[i] - x[i - 1]); }
  print(ans);
}


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

int main() {

    int n;
    cin >> n;
    
    int rem = 0;
    while (n > 0) {
        rem = n % 10;
        n = n / 10;
        if (rem == 7) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3624
nk = input()
N = int(nk[:nk.index(" ")])
K = int(nk[nk.index(" ")+1:])
ans = N - K

if ans<0:
	ans*=-1
	if ans>N:
		ans = N
else:
	ans = N - K*(N//K)
	if (ans-K)*-1<ans:
		ans = (ans-K)*-1
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int a[3];
signed main() {
	rep(i,3){
		cin>>a[i];
	}
	sort(a,a+3);
	if(a[0]+a[1]==a[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> x(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> x.at(i).at(j);
    }
  }
  int c = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int p2 = 0;
      for (int k = 0; k < D; k++) {
        p2 += (x.at(i).at(k)-x.at(j).at(k)) * (x.at(i).at(k)-x.at(j).at(k));
      }
      double p = sqrt(p2);
      int pp = sqrt(p2);
      if (p == pp) {
        c++;
      }
    }
  }
  cout << c <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef struct node {
        int parent;
        int childs;
        int leftChild;
        int rightSib;

        node();
} node;

node::node()
        :parent(-1), childs(0), leftChild(-1), rightSib(-1)
        {
        }

void insert(node tree[], int id, int child[], int childs)
{
        tree[id].leftChild = child[0];
        for (int i = 0; i < childs; i++) {
                tree[child[i]].parent = id;
                if (i < childs - 1) {
                        tree[child[i]].rightSib = child[i + 1];
                }
        }
}

int main()
{
        int n;
        cin >> n;
        node *tree = new node[n];
        int id, k;
        for (int i = 0; i < n; i++) {
                cin >> id >> k;
                tree[id].childs = k;
                if (k) {
                        int *c = new int[k];
                        for (int j = 0; j < k; j++) {
                                cin >> c[j];
                        }
                        insert(tree, id, c, k);
                        delete [] c;
                }
        }
        for (int i = 0; i < n; i++) {
                cout << "node " << i << ": ";
                cout << "parent = " << tree[i].parent << ", ";
                cout << "depth = ";
                int depth = 0, parent = tree[i].parent;
                while (parent != -1) {
                        parent = tree[parent].parent;
                        depth++;
                }
                cout << depth << ", ";
                if (tree[i].parent == -1) {
                        cout << "root, ";
                }
                else if (tree[i].leftChild != -1) {
                        cout << "internal node, ";
                }
                else {
                        cout << "leaf, ";
                }
                cout << "[";
                int child = tree[i].leftChild;
                int j = 0;
                for (int child = tree[i].leftChild; child != -1; child = tree[child].rightSib) {
                        cout << child;
                        if (j < tree[i].childs - 1) {
                                cout << ", ";
                        }
                        j++;
                }
                cout << "]" << endl;
        }
        delete [] tree;

        return 0;
}

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

int main(){
  int A;
  int B;
 int ans;
  cin >> A >>B;

  if(A>B){

if(A - B > 1){
ans = A+ (A-1);
}else{
ans = A+ B;
}

}else if(A<B){

if(B-A > 1){
ans = B + (B-1);
}else{
ans =A+B;
}
}else if(A ==B){
ans =A+B;
}

cout << ans;
}

Measured memory_bytes: 256
import sys
from collections import Counter


N=int(input())
A=list(map(int,input().split()))

for i in range(len(A)):
  A[i] = A[i] - 1

count = Counter(A)

for i in range(N):
  if count.get(i):
    print(count.get(i))
  else:
    print(0)
  

Measured memory_bytes: 34044
import java.util.Scanner;

public class Main{
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    }
}


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

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec){
    os << "[";
    for(int i=0;i<vec.size();i++){
        os << (i==0?"":" ") << vec[i];
    }
    os <<  "]";
    return os;
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int maxx = 0, minn = n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        maxx = max(maxx, a[i]);
        minn = min(minn, a[i]);
    }
    if(maxx - minn > 1){
        cout << "No" << endl;
    }
    else if(maxx - minn == 0){
        if(maxx == n-1 || maxx * 2 <= n){
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }
    else{
        int x = 0;
        for(int i=0;i<n;i++){
            if(a[i] == minn)
                x++;
        }
        int y = n - x;
        int col = maxx-x;
        if(col > 0 && col * 2 <= y){
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var dp = new long[n + 1];
        dp[0] = 2;  dp[1] = 1;
        for (int i = 2; i <= n; i++)
            dp[i] = dp[i - 2] + dp[i - 1];
        Console.WriteLine(dp[n]);
    }
}

Measured memory_bytes: 13140
{-# LANGUAGE BangPatterns      #-}

import Prelude as P
import Data.List
import Data.Vector.Unboxed as V hiding(sum,forM,forM_,map)
import Data.Array.Unboxed  as A
import Data.Array.MArray
import Data.Array.ST
import Control.Monad
import Control.Monad.ST

type P = Vector Double
type DP s = STUArray s (Int,Int) Double

setArr :: DP s -> P -> Int -> ST s ()
setArr dparr ps n = do
  let p i  = ps V.! (i-1)
      p_ i = 1-(p i)
  forM_ [1..n] $ \i -> writeArray dparr (0,i) $ (V.scanl (\x y -> x*(1-y)) 1 ps) V.! i
  forM_ [1..div (n-1) 2] $ \i -> do
    writeArray dparr (i,i)   $ (V.scanl (\x y -> x*y) 1 ps) V.! i

dp_i :: DP s -> P -> Int -> Int -> ST s ()
dp_i dparr ps k i = do
  let p i  = ps V.! (i-1)
      p_ i = 1-(p i)
  ek  <- readArray dparr (k,i-1)
  ek1 <- readArray dparr (k-1,i-1)
  writeArray dparr (k,i) $ ek*(p_ i) + ek1*(p i)

solve :: P -> Int -> ST s Double
solve ps n = do
  dparr <- newArray ((0,1),(div (n-1) 2,n)) 0
  setArr dparr ps n
  forM_ [1..div (n-1) 2] $ \k ->
   forM_ [k+1..n] $ \i -> dp_i dparr ps k i
  ans0 <- forM [0..div (n-1) 2] $ \k -> readArray dparr (k,n)
  return $ 1-(sum ans0)

main :: IO ()
main = do
  n <- read <$> getLine
  ps <- map read.words <$> getLine
  putStrLn $ show $ runST $ solve (V.fromList ps)  n

mod0 :: Int -> Int
mod0 n = mod n 1000000007


Measured memory_bytes: 37500
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
fun main() {
    val (n, m, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val aBooks = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
    val bBooks = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
    var bSum = bBooks.fold(0L){acc, b -> acc + b}
    var bPos = m - 1
    var aSum = 0L
    while (bPos >= 0 && bSum > k) {
        bSum -= bBooks[bPos--]
    }
    var max = bPos + 1
    for (aPos in aBooks.indices) {
        aSum += aBooks[aPos]
        if (aSum > k) break
        while (bPos >= 0 && aSum + bSum > k) {
            bSum -= bBooks[bPos--]
        }
        max = maxOf(max, aPos + bPos + 2)
    }
    println(max)
}


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

int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  long long k;
  cin >> k;
  
  if(abs(a-b) > 1000000000000000000) cout << "Unfair" << endl;
  else{
    if(k%2 == 1) cout << b-a << endl;
    else cout << a-b << endl;
  }
  
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
Ans = 0
for i in range(N):
    total = 0
    for j in range(N):
        if i == j:
            total += A1[j]+A2[j]
        elif i > j:
            total += A1[j]
        else:
            total += A2[j]
    Ans = max(Ans,total)
print(Ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
# define ll long long
# define inf 1e9+5
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
# define maxn 100005
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main(){
	ll n;
	cin>>n;
	ll m[maxn][3];
	for(ll i=0;i<n;i++)
	for(ll j=0;j<3;j++) cin>>m[i][j];
	
	ll dp[maxn][3];
	for(ll i=0;i<n;i++) for(ll j=0;j<3;j++) dp[i][j]=-inf;
	dp[0][0]=m[0][0];
	dp[0][1]=m[0][1];
	dp[0][2]=m[0][2];
	for(ll i=1;i<n;i++){
			
			dp[i][0]=max(dp[i-1][0],max(dp[i-1][1],dp[i-1][2])+m[i][0]);
			dp[i][1]=max(dp[i-1][1],max(dp[i-1][0],dp[i-1][2])+m[i][1]);
			dp[i][2]=max(dp[i-1][2],max(dp[i-1][0],dp[i-1][1])+m[i][2]);
			
			
			
			
		
		
		
		}
		cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
		//for(ll i=0;i<n;i++){
		// for(ll j=0;j<3;j++){ 
			 
		//	 cout<<dp[i][j]<<" ";
			 
		// }
		// cout<<"\n";
		 
	 //}
	
	
	
	
	
	
	
	
	return 0;
	}


Measured memory_bytes: 4992
n=int(input())
aa=list(map(int,input().split()))
le=1
st=0
se=10**24
for i in range(n+1):
    if(aa[i]>le):
        st=1
        break
    le-=aa[i]
    le*=2
if(st):
    print(-1)
else:
    ma=[0 for i in range(n+1)]
    ma[0]=1
    le=1
    for i in range(1,n+1):
        le*=2
        le=min(le,se)
        ma[i]=min((ma[i-1]-aa[i-1])*2,le)
    ma[n]=min(ma[n],aa[n])
    for i in range(n-1,-1,-1):
        ma[i]=min(ma[i],aa[i]+ma[i+1])
    print(sum(ma))
    


Measured memory_bytes: 85360
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, M = input_number_list()
    A = sum(input_number_list())
    ans = N - A
    print([ans, -1][ans < 0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 10060
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    string str;
    cin>>str;
    ll n;
    n=str.size();
    if(str[n-1]=='s')
    {
        str+="es";
    }
    else
    {
        str+='s';
    }
    cout<<str<<endl;
}


Measured memory_bytes: 3668
#include<iostream>
using namespace std;
int main()
{
    int train[10]={0},n,count=0,outTrain[10],trainCount=0;
    while(cin >> n){
        if(cin.eof())break;
        if(n){
            for(int i=count ; i!=0 ; i--){
                train[i]=train[i-1];
            }
            train[0]=n;
            count++;
        }
        else{
            outTrain[trainCount]=train[0];
            cout << train[0] << '\n';
            for(int i=0 ; i<count ; i++){
                train[i]=train[i+1];
            }
            train[count]=0;
            count--;
            trainCount++;
        }
    }
    return 0;
}

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


struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

using pint = pair<int,int>;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> p(M,pair<int,int>(0,0));
    for(int i = 0; i < M;i++){
        cin >> p[i].first >> p[i].second;
        p[i].first--,p[i].second--;
    }
    //for(int i = 0; i < M;i++)cout << p[i].first <<" "<< p[i].second<<endl;
    int ans = 0;
    for(int i = 0;i < M;i++){
        UnionFind uf(N);
        for(int j = 0;j < M;j++){
            
            if(i == j)continue;
            
            uf.merge(p[j].first,p[j].second);
            
        }
        
        set<int> judge;
        for(int j = 0;j < N;j++){
            //cout <<"##"<< uf.root(j) << endl;
            judge.insert(uf.root(j));
            
        }
        
        //cout << judge.size() << endl;
        if(judge.size()==2) ans++;
    
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
def covered?(ranges, max)
    a = ranges.sort
    return false if a[0][0] > 0
    l0, r0 = a.shift
    until a.empty?
        l, r = a.shift
        return false if r0 < l
        r0 = r if r > r0
    end
    return r0 >= max
end

n, w, h = gets.split.map &:to_i
x_ranges = []
y_ranges = []

n.times {
    x, y, r = gets.split.map &:to_i
    x_ranges << [x-r, x+r]
    y_ranges << [y-r, y+r]
}

if covered?(x_ranges, w) || covered?(y_ranges, h)
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 33692
#include<iostream>
using namespace std;
int main(){
  int i=0,end,size;
  string str;
  cin>>str;
  
  
  for(int i=0;i<str.size();i++){
    if(str[i]=='F'&&str[i+1]=='E'){
    if(str[i+2]=='S'&&str[i+3]=='T'){
    if(str[i+4]=='I'&&str[i+5]=='V'){
    if(str[i+6]=='A'&&str[i+7]=='L'){end=i;}
    }
    }
    }
  }
  for(int i=0;i<end;i++){
    cout<<str[i];
  }

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef pair<int, int> paii;
typedef long long ll;

int main()
{
	complex<double> z = complex<double>(0, 0);
	double r, tht = 0, dtht;
	char c;
	
	while(cin >> r >> c >> dtht, (r||dtht))
	{
		z += polar(r, tht*acos(-1.0)/180.0);
		tht += dtht;
	}
	
	cout << (int)z.imag() << endl;
	cout << (int)z.real() << endl;
	
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

int arr[111];
int n;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1; i<n; i++) cin >> arr[i];
	arr[n] = 1e9;
	int ans = 0;
	ans += arr[1];
	for(int i=1; i<n; i++) ans += min(arr[i], arr[i+1]);
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	string s;
	cin >> s;
	if(s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < s.size(); i+=2) {
		if(s[i] != 'h' || s[i+1] != 'i') {
			cout << "No" << endl;
			return 0;
		} 
	}
	cout << "Yes" << endl;
	return 0;
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp

def small_letter?(c)
  c.ord >= 97 && c.ord <= 122
end

def big_letter?(c)
  c.ord >= 65 && c.ord <= 90
end

a = s.chars.map do |c|
  case
  when small_letter?(c) then c.upcase
  when big_letter?(c) then c.downcase
  else c
  end
end

puts a.join

Measured memory_bytes: 6104
using System;

namespace abc157A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N % 2 == 1)
                Console.WriteLine(N / 2 + 1);
            else
                Console.WriteLine(N / 2);
        }
    }
}


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

using namespace std;


int main()
{
    string s;
    cin>>s;
    int len=s.size();
    string s1=s;
    reverse(s1.begin(),s1.end());
    string a,b;
    a=s.substr(0,(len-1)/2);
    b=s.substr(((len+3)/2-1),(len-3)/2+1);
    string a1=a,b1=b;
    reverse(a1.begin(),a1.end());
    reverse(b1.begin(),b1.end());
    if(s==s1&&a1==a&&b1==b)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

using namespace std;

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

const char dir[5] = "NESW";

int N, M, D, X, Y, JX[20], JY[20], P[21][21];

char c;

int main()
{
	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		X = 10; Y = 10;

		memset(P, 0, sizeof(P));

		P[X][Y] = 1;

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

		cin >> M;

		for (int i = 0; i < M; i++)
		{
			cin >> c >> D;

			for (int j = 0; j < 4; j++)
			{
				if (c == dir[j])
				{
					for (int k = 0; k < D; k++)
					{
						X += dx[j];
						Y += dy[j];

						P[X][Y] = 1;
					}
				}
			}
		}

		int A = 0;

		for (int i = 0; i < N; i++)
		{
			A += P[JX[i]][JY[i]];
		}

		printf("%s\n", A == N ? "Yes" : "No");
	}

	return 0;
}

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

int main()
{
  int n,count;
  while(cin>>n,n){
    count=0;
    n=1000-n;
    while(n>=500){count++;n-=500;}
    while(n>=100){count++;n-=100;}
    while(n>=50){count++;n-=50;}
    while(n>=10){count++;n-=10;}
    while(n>=5){count++;n-=5;}
    while(n>=1){count++;n-=1;}
    cout<<count<<endl;
  }
}

Measured memory_bytes: 0
from decimal import Decimal, ROUND_HALF_UP
N = int(input())

X = 100*N // 108
# X = int((X+0.5)//1)
if (X * 1.08)//1 == N:
    print(X)

else:
    if ((X+1)*1.08) // 1 == N:
        print(X+1)
    else:
        print(":(")


Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC";
	else
		cout << "ABC";
	cout << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include <iostream>


int main() {
    int n, x;
    scanf("%i %i", &n, &x);
    
    int l, a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%i", &l);
        a[i] = l;
    }
    
    int d = 0, count = 1;
    for (int i = 0; i < n; i++)
    {
        d += a[i];
        if (d > x)
        {
            break;
        }
        count++;
    }
    printf("%i\n", count);
    
    

    
    return 0;
}


Measured memory_bytes: 256