akhauriyash/Code-Regression huggingface dataset:
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

N,M=gets.split.map &:to_i
as=M.times.map{gets.split.map(&:to_i)}
tree=UnionFind.new(N)
for i in 0...M
    tree.unite(as[i][0]-1,as[i][1]-1)
end
puts (0...N).to_a.map{|x|tree.get_parent(x)}.uniq.size


Measured memory_bytes: 19892
#include<bits/stdc++.h>
using namespace std;
int main(){
char a,b;
cin>>a>>b;
if(a=='H'){
	if(b=='H')
	cout<<"H";
	else
	cout<<"D";}
else if (a=='D'){
		if(b=='H')
	cout<<"D";
	else
	cout<<"H";
}

return 0; 
}
	
	
	

Measured memory_bytes: 256
N = list(map(int,input()))
L = len(N)
ans0 = 0
ans1 = 100
for i in range(L):
    k = N[-i-1]
    ans0, ans1 = (min(ans0+k, ans1 + k+1),
                  min(ans0 + 10-k, ans1 + 9-k))
ans = min(ans0, ans1+1)
print(ans)

Measured memory_bytes: 120484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int f[10][10];

int main(){
    int n; 
    scanf("%d", &n);
    ll an = 0; 
    for(int i = 1; i<=min(n, 9); ++i){
        ++f[i][i];
    }
    for(int i = 11; i<=n; ++i){
       vector<int>x;
       int nm = i, d = 1; 
       while(nm){
         x.push_back(nm % 10);
         nm /= 10;
       }
       reverse(all(x));
       ++f[x[0]][x[x.size()-1]];
    }
    for(int i = 1; i<=n; ++i){
        int nm = i;
        vector<int>x;
        while(nm){ 
          x.push_back(nm % 10);
          nm /= 10;
        }  
        reverse(all(x));
        an += f[x.back()][x[0]];
    }  
    printf("%lld\n", an);
} 

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 400

int H, W;
string S[MAX];

int visit[MAX][MAX];
map<int, long long> mp;

int diri[4] = { -1, 1, 0, 0 };
int dirj[4] = { 0, 0, -1, 1 };

long long dfs( int i, int j, int cnt )
{
	if( visit[i][j] == cnt ) {
		return -1;
	}
	visit[i][j] = cnt;
	long long res = 0;
	for( int k = 0; k < 4; k++ ) {
		int ni = i + diri[k];
		int nj = j + dirj[k];
		if( ni < 0 || H -1 < ni || nj < 0 || W - 1 < nj ) {
			continue;
		}
		if( S[ni][nj] == S[i][j] ) {
			continue;
		}
		long long ret = dfs( ni, nj, cnt );
		if( ret >= 0 ) {
			res += ret;
			if( S[ni][nj] == '.' ) {
				res++;
			}
		}
	}
	mp[cnt] = res;
	return res;
}

int main() {
	cin >> H >> W;
	for( int i = 0; i < H; i++ ) {
		cin >> S[i];
	}

	long long ans = 0;
	int cnt = 1;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			if( mp[ visit[i][j] ] == 0 ) {
				if( S[i][j] == '.' ) {
					continue;
				}
				long long ret = dfs( i, j, cnt );
				if( ret >= 0 ) {
					ans += ret;
				}
				cnt++;
			}
			else if( S[i][j] == '#' ) {
				ans += mp[ visit[i][j] ];
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            //s = "atcoderregularcontest";
            string abc = "abcdefghijklmnopqrstuvwxyz";
            string ans = "None";
            for (int i = 0; i < abc.Length; i++)
            {
                if (s.IndexOf(abc[i]) == -1)
                {
                    ans = abc[i].ToString();
                    break;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();

        }


    }
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int w, h;
char field[21][21];
int s_to[11];
int dist[11][11];

int bfs(pair<int, int> s, pair<int, int> g) {
    int d[21][21] = {};
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            d[i][j] = inf;
        }
    }
    d[s.fi][s.se] = 0;
    queue<pair<int, int>> q;
    q.push(s);
    while (not q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        int dy[] = {1, 0, -1, 0};
        int dx[] = {0, -1, 0, 1};
        for (int i = 0; i < 4; i++) {
            int ny = p.fi + dy[i];
            int nx = p.se + dx[i];
            if (ny <  0 or ny == h or nx < 0 or nx == w) continue;
            if (field[ny][nx] == 'x') continue;
            if (d[p.fi][p.se] + 1 < d[ny][nx]) {
                d[ny][nx] = d[p.fi][p.se] + 1;
                q.push({ny, nx});
            }
        }
    }
    return d[g.fi][g.se];
}

int main() {
    vector<int> res;
    while (true) {
        cin >> w >> h;
        if (w == 0) break;
        pair<int, int> s;
        vector<pair<int, int>> v;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];    
                if (field[i][j] == '*') {
                    field[i][j] = '.';
                    v.emplace_back(i, j);
                }
                else if (field[i][j] == 'o') {
                    field[i][j] = '.';
                    s = {i, j};
                }
            }
        }
        bool check = false;
        for (int i = 0; i < (int)v.size(); i++) {
            s_to[i] = bfs(s, v[i]);
            if (s_to[i] == inf) {
                check = true;
                break;
            }
        }
        if (check) {
            res.push_back(-1);
            continue;
        }
        for (int i = 0; i < (int)v.size() - 1; i++) {
            for (int j = i + 1; j < (int)v.size(); j++) {
                dist[i][j] = dist[j][i] = bfs(v[i], v[j]);
            }
        }
        vector<int> indice(v.size());
        iota(all(indice), 0);
        int mi = inf;
        do {
            int sum = 0;
            sum += s_to[indice[0]];
            for (int i = 0; i < (int)indice.size() - 1; i++) {
                sum += dist[indice[i]][indice[i + 1]];
            }
            mi = min(mi, sum);
        } while (next_permutation(all(indice)));
        res.push_back(mi);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



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

struct data_t {
    int key;
    int value;
	int value_i;
};

bool cmp(const data_t& left, const data_t& right) {
    return (left.value + left.value_i == right.value + right.value_i)
	? (left.value_i > right.value_i)
	: (left.value + left.value_i > right.value + right.value_i);
}

int main(void){
	int n;
	struct data_t a[100000], b[100000];
	bool sed[100000] = {};
	long long int ans = 0;
	int t_a = 0, t_b = 0;
	
	cin >> n;
	for(int i = 0; i != n; i++){
		a[i].key = b[i].key = i;
		cin >> a[i].value >> b[i].value;
		a[i].value_i = b[i].value;
		b[i].value_i = a[i].value;
	}
	std::sort(a, a + n, cmp);
	std::sort(b, b + n, cmp);
	
	bool isturn_a = true;
	for(int i = 0; i != n; i++){
		if(isturn_a){
			while(sed[b[t_b].key]) t_b++;
//			cout << "A: " << b[t_b].value_i << endl;
			ans += b[t_b].value_i;
			sed[b[t_b].key] = true;
		}else{
			while(sed[a[t_a].key]) t_a++;
//			cout << "B: " << a[t_a].value_i << endl;
			ans -= a[t_a].value_i;
			sed[a[t_a].key] = true;
		}
		isturn_a = !isturn_a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10;
int n;
int ID[N];
LL X,GG;
LL B[N],L[N],R[N],G[N],S[N];
bool cmp(int a,int b) {
  return S[a]>S[b];
}
bool Check(LL m) {
  LL res=0,tmp=G[m/X];
  int t=m/X+1; m%=X;
  for(int i=t;i<=n;++i) {
    int id=ID[i];
    LL g=B[id]>=m?m*L[id]:B[id]*L[id]+(m-B[id])*R[id];
    res=max(res,tmp+g);
  }
  tmp+=S[ID[t]];
  for(int i=1;i<t;++i) {
    int id=ID[i];
    LL g=B[id]>=m?m*L[id]:B[id]*L[id]+(m-B[id])*R[id];
    res=max(res,tmp-S[id]+g);
  }
  return res>=GG;
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,X);
  for(int i=1;i<=n;++i) read(B[i],L[i],R[i]),S[i]=B[i]*L[i]+(X-B[i])*R[i],ID[i]=i,GG+=L[i]*B[i];
  sort(ID+1,ID+n+1,cmp);
  for(int i=1;i<=n;++i) G[i]=G[i-1]+S[ID[i]];
  LL l=0,r=X*n;
  while(l!=r) {
    LL mid=l+r>>1;
    if(Check(mid)) r=mid;
    else l=mid+1;
  }
  printf("%lld\n",l);
  return 0;
}



Measured memory_bytes: 4480
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    int[] a = new int[n+1];
    foreach (i; 0 .. m) {
        tmp = readln.split.to!(int[]);
        int l = tmp[0] - 1, r = tmp[1];
        ++a[l];
        --a[r];
    }
    foreach (i; 0 .. n) {
        a[i+1] += a[i];
    }
    a.count(m).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.typecons;

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

int main() {
  int a[5];
  int k;
  int f=0;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  cin>>k;
  for(int i=0;i<5;i++){
  for(int j=i+1;j<5;j++){
  if((a[j]-a[i])>k){
    f++;
  }
  }
  }
 if(f){
  cout<<":(";
 }
  else{
  cout<<"Yay!";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e7 * 100;

vector<ll> vec;
vector<bool> graph[2];

int main() {
    fastInp;

    ll n;
    cin >> n;
    vec.resize(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

    ll ans = INT64_MAX;
    for (int i = -100; i <= 100; i++) {
        ll cnt = 0;
        for (int j = 0; j < n; j++) {
            cnt += (vec[j] - i) * (vec[j] - i);
        }
        ans = min(ans, cnt);
    }

    cout << ans;
    return 0;
}



Measured memory_bytes: 256
S = input()
T = input()

s = len(S)
t = len(T)

ans = 0

for i in range(s - t + 1):
    c = 0
    for j in range(t):
        if S[i + j] == T[j]:
            c += 1
    ans = max(ans, c)

print(t - ans)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,N, a[101],pre =-1,ans=0;
    cin >> N;
    for (i = 0;i < N;i++)
    {
        cin >> a[i];
    }
    sort(a,a+N);
    for(i=0;i<N;i++)
    {
        if(a[i]>pre)
        {
            ans++;
            pre = a[i];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

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

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




const ll N=5e5+5;





int main()
{ 

IOS;

ll n,m,v,p;

cin>>n>>m>>v>>p;

vl a(n+1);

ll ans=p;

FOR(i,n)cin>>a[i+1];

sort(a.begin()+1,a.end(),greater<>());

ll l=p+1,r=n,mid;

while(l<=r){
  mid=(l+r)/2;

bool allowed=0;

if(a[mid]+m<a[p]){
  r=mid-1;
  continue;
}

ll votesleft=m*v-m*p;

if(votesleft<=0){
  ans=max(ans,mid);
  l=mid+1;
  continue;
}

ll c=0;

for(int i=p;i<=n;i++){
  if(i==mid)continue;
  c+=min(m,a[mid]+m-a[i]);
}

if(c>=votesleft){
  allowed=1;
}

if(allowed){
l=mid+1;
ans=max(ans,mid);
}
else r=mid-1;

}

cout<<ans;


//end_routine();

return 0;
 
}


Measured memory_bytes: 4012
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int a[N];

int main () {
    to_pray();
    
    int k;
    
    for (int i = 0; i < 5; ++ i)
    	cin >> a[i];
    cin >> k;
    
    for (int i = 4; i >= 1; -- i) {
    	for (int j = i - 1; j >= 0; -- j) {
    		int dis = a[i] - a[j];
    		if (dis > k)
    			return cout << ":(", 0;
    	}
    }
    
    cout << "Yay!\n";
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

string x;

void solve(){
    cin >> x;
    int n=x.length();
    stack<int> stack;
    //cout << "unko" << endl;
    int ans=0;
    rep(i,n){
        if (x[i]=='S') stack.push(1);
        if (x[i]=='T'){
            if (!stack.empty()) stack.pop();
            else ans+=1;
        }
        //cout << "unko" << endl;
    }
    cout << stack.size()+ans << endl;
}

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

Measured memory_bytes: 916
#ifndef _WIN32
#include<iostream>
#endif
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<string.h>
#include<map>
#include<utility>
#include<iomanip>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
typedef vector<string> VS;
VS wrap(VS v,char c) {
	int R = v.size(), C = v[0].size();
	VS ret(R + 2, string(C + 2, c));
	REP(i, R)REP(j, C)ret[i + 1][j + 1] = v[i][j];
	return ret;
}
const int dr[] = { 0,0,1,-1 };
const int dc[] = { 1,-1,0,0 };
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
int pos[20];
double h[20];
double in[20];
double w[20];
void f(int x,double &v,int l,int r) {
	if (r - l >= 2) {
		int mid = l + 1;
		FOR(i, l + 1, r)if (h[mid] < h[i])mid = i;
		if (x < mid) {
			f(x, v, l, mid); f(x, v, mid,r);
		}
		else {
			f(x, v, mid, r); f(x, v, l, mid);
		}
	}
	double hh = min(h[l], h[r]);
	if (in[l] >= hh)return;
	double vv = min((hh - in[l]) * (pos[r] - pos[l]), v);
	v -= vv;
	vv /= (pos[r] - pos[l]);
	FOR(i, l, r)in[i] += vv;
}

int main() {
	cout << fixed;
	cout << setprecision(10);
	int D; cin >> D;
	while (D--) {
		int N; cin >> N;
		pos[0] = 0;
		pos[N + 1] = 100;
		h[0] = 50;
		h[N + 1] = 50;
		REP(i, N) cin >> pos[i + 1] >> h[i + 1];
		REP(i, N + 1)w[i] = 0;
		int M; cin >> M;
		REP(i, M) {
			int p;
			double z; cin >> p >> z; z /= 30; 
			int id = upper_bound(pos, pos + N + 2, p) - pos - 1;

			w[id] += z;
		}
		cin >> M;
		while (M--) {
			int p, t;
			cin >> p >> t;
			REP(i, N+1)in[i] = 0;
			REP(i, N+1) {
				double v = w[i] * t;
				f(i, v, 0, N+1);
			}
			int id = upper_bound(pos, pos + N + 2, p) - pos - 1;
			cout << in[id] << endl;
		}
	}
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int longest_path(const vvi &adj) {
    int n = adj.size();
    vvi inv(n);
    for (int a = 0; a < n; a++) {
        for (auto b : adj[a]) {
            inv[b].push_back(a);
        }
    }
    vi len(n, -1);
    function<void(int)> set_len = [&](int v) {
        if (len[v] != -1) return;
        if (inv[v].empty()) {
            len[v] = 0;
            return;
        }
        i64 nax = 0;
        for (int u : inv[v]) {
            set_len(u);
            nax = max(nax, len[u]);
        }
        len[v] = nax + 1;
    };

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

    return *max_element(len.begin(), len.end());
}

int main() {
    int n, m;
    cin >> n >> m;
    vvi adj(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
    }
    cout << longest_path(adj) << endl;
}

Measured memory_bytes: 18048
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toInt).toMutableList()
    val bList = readLine()!!.split(" ").map(String::toInt).toMutableList()

    var count:Long = 0
    for (i in 0 until n) {
        val d = Math.min(aList[i], bList[i])
        count += d
        aList[i] -= d
        bList[i] -= d
        val d2 = Math.min(aList[i+1], bList[i])
        count += d2
        aList[i+1] -= d2
        bList[i] -= d2
    }
    println(count)
}

Measured memory_bytes: 85136
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

vector<int>leastPrimeFactor(int n)
{
    vector<int>least_prime(n);
    // Create a vector to store least primes.
    // Initialize all entries as 0.
    // We need to print 1 for 1.
    least_prime[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        // least_prime[i] == 0
        // means it i is prime
        if (least_prime[i] == 0)
        {
            // marking the prime number
            // as its own lpf
            least_prime[i] = i;

            // mark it as a divisor for all its
            // multiples if not already marked
            for (int j = 2*i; j <= n; j += i)
                if (least_prime[j] == 0)
                   least_prime[j] = i;
        }
    }
    return least_prime;
}
void printString(int n)
{
    char str[100]; // To store result (Excel column name)
    int i = 0; // To store current index in str which is result

    while (n > 0) {
        // Find remainder
        int rem = n % 26;

        // If remainder is 0, then a 'Z' must be there in output
        if (rem == 0) {
            str[i++] = 'z';
            n = (n / 26) - 1;
        }
        else // If remainder is non-zero
        {
            str[i++] = (rem - 1) + 'a';
            n = n / 26;
        }
    }
    str[i] = '\0';

    // Reverse the string and print result
    reverse(str, str + strlen(str));
    cout << str << endl;

    return;
}
void solve()
{
int n;
cin>>n;
printString(n);
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



Measured memory_bytes: 3668
s = range(1,14)
h = range(1,14)
c = range(1,14)
d = range(1,14)
n = int(raw_input())
for i in range(0,n):
    input_line = raw_input().split()
    mark = input_line[0]
    num = int(input_line[1])
    if mark == "S":
        s.remove(num)
    elif mark == "H":
        h.remove(num)
    elif mark == "C":
        c.remove(num)
    elif mark == "D":
        d.remove(num)
for i in s:
    print "S " + str(i)
for i in h:
    print "H " + str(i)
for i in c:
    print "C " + str(i)
for i in d:
    print "D " + str(i)

Measured memory_bytes: 6460
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

/*
ll GCD(ll a, ll b) {
	return b ? GCD(b, a%b) : a;
}

sort(a, a + N, greater<int>())   // descend
sort(a, a+N)                    //  ascend


** nCk
void comb(vector<vector <long long int > > &v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


** main内でnCn~nC0 生成 **
vector<vector<long long int> > v(n + 1, vector<long long int>(n + 1, 0));
	comb(v);


*/


int main() {
	int n;
	int d[110000];
	cin >> n;
	int s[110000];
	rep(i, 0, n) cin >> d[i];
	rep(i, 0, n) s[i] = d[i];

	sort(s, s+ n);


	int x = n / 2-1;
	int ans = s[n / 2 - 1];
	int ans1 = s[n / 2];
	int ans2 = ans1 - ans;
	cout << ans2;


}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ull,ull>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;
 
inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 305, p = 1e9+7;
inline void M(int &x) { if( x >= p ) x -= p; }
struct node{ int f[N][N]; } a[2][3];

struct edge{ int to1, to2, nxt; } e[N];
int head[N], cnt = 0;
inline void add(int x,int y,int z) { 
	e[++cnt].to1 = y, e[cnt].to2 = z, e[cnt].nxt = head[x], head[x] = cnt;
}

int main() {
	int n = read(), m = read(), l, r, x;
	rep(i,1,m) l = read(), r = read(), x = read(), add(r,l,x);
	
	int now = 0, pre = 1;
	a[now][0].f[0][0] = 1;
	rep(i,1,n) { 
		swap(now,pre);
		rep(k,0,i) { 
			rep(l,0,i) if( a[pre][0].f[k][l] ) { 
				M(a[now][0].f[k][l] += a[pre][0].f[k][l]);
				M(a[now][1].f[i-1][l] += a[pre][0].f[k][l]);
				M(a[now][2].f[i-1][k] += a[pre][0].f[k][l]);
				a[pre][0].f[k][l] = 0;
			}
		}
		rep(k,0,i) { 
			rep(l,0,i) if( a[pre][1].f[k][l] ) { 
				M(a[now][0].f[i-1][l] += a[pre][1].f[k][l]);
				M(a[now][1].f[k][l] += a[pre][1].f[k][l]);
				M(a[now][2].f[k][i-1] += a[pre][1].f[k][l]);
				a[pre][1].f[k][l] = 0;
			}
		}
		rep(k,0,i) { 
			rep(l,0,i) if( a[pre][2].f[k][l] ) { 
				M(a[now][0].f[l][i-1] += a[pre][2].f[k][l]);
				M(a[now][1].f[k][i-1] += a[pre][2].f[k][l]);
				M(a[now][2].f[k][l] += a[pre][2].f[k][l]);
				a[pre][2].f[k][l] = 0;
			}
		}
		rep(k,0,i) {
			rep(l,0,i) { 
				if( a[now][0].f[k][l] ) { 
					for(register int h = head[i]; h; h=e[h].nxt) { 
						int num = 1;
						if( e[h].to1 <= k ) num++;
						if( e[h].to1 <= l ) num++;
						if( num != e[h].to2 ) a[now][0].f[k][l] = 0;
					}
				}
				if( a[now][1].f[k][l] ) { 
					for(register int h = head[i]; h; h=e[h].nxt) { 
						int num = 1;
						if( e[h].to1 <= k ) num++;
						if( e[h].to1 <= l ) num++;
						if( num != e[h].to2 ) a[now][1].f[k][l] = 0;
					}
				}
				if( a[now][2].f[k][l] ) { 
					for(register int h = head[i]; h; h=e[h].nxt) { 
						int num = 1;
						if( e[h].to1 <= k ) num++;
						if( e[h].to1 <= l ) num++;
						if( num != e[h].to2 ) a[now][2].f[k][l] = 0;
					}
				}
			}
		}
	}
	int ans = 0;
	rep(i,0,2) rep(j,0,n) rep(k,0,n) M(ans += a[now][i].f[j][k]);
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,i;
    int x[2];
    cin >> a >> b >> x[0];
    for(i=0;i<10;i++){
      x[1]=a*x[0]-b;
      cout << x[1] << endl;
      x[0]=x[1];
    }
}

Measured memory_bytes: 256
/**
*    created: 02.08.2020 20:10:30
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s, t; cin >> s >> t;
    int n = s.size(), l = t.size();
    if (n < l) return 0;
    else {
        rep(i,n-l+1) {
            string tmp = s.substr(i,l);
            if (tmp == t) cout << i << endl;
        }
    }
    return 0;
}


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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  cout<<min({max(x,y)*2*c,min(x,y)*2*c+(x-min(x,y))*a+(y-min(x,y))*b,x*a+y*b})<<endl;
}

Measured memory_bytes: 256
n = int(input())
d1 = []
d2 = []
cnt = 0
flag = False

for i in range(n):
    a, b = map(int, input().split())
    d1.append(a)
    d2.append(b)

for i in range(n):
    if d1[i] == d2[i]:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True


if flag:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (e*c-b*f)/(a*e-b*d);
		double y = (-(d*c)+a*f)/(a*e-b*d);
		if (x==0) x = 0; if (y==0) y=0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

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

void p(int x){
  if ( x < 10 ) cout << 0;
  cout << x;
}
void print(int r){
  int h = r/3600; r %= 3600;
  int m = r/60; r %= 60;
  int s = r;
  p(h); cout << ":";
  p(m); cout << ":";
  p(s); cout << endl;
}

main(){
  int h, m, s, r;
  while(1){
    cin >> h >> m >> s;
    if ( h < 0 ) break;
    r = 7200 - (3600*h+60*m+s);
    print(r);print(r*3);
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc, const char * argv[]){
    int m[50], f[50], r[50];
    int i, n;
    
    i=1;
    
    scanf("%d %d %d",&m[i],&f[i],&r[i]);
    
    
    while(m[i]!=-1 || f[i]!=-1 || r[i]!=-1){
        i++;
        scanf("%d %d %d",&m[i],&f[i],&r[i]);
    }
    
    n=i-1;
    
    for(i=1;i<=n;i++){
        if(m[i]==-1 || f[i]==-1){
            printf("F\n");
        }
        else{
            if(m[i]+f[i]>=80){
                printf("A\n");
            }
            if(m[i]+f[i]>=65 && m[i]+f[i]<80){
                printf("B\n");
            }
            if(m[i]+f[i]>=50 && m[i]+f[i]<65){
                printf("C\n");
            }
            if(m[i]+f[i]>=30 && m[i]+f[i]<50){
                if(r[i]>=50){
                    printf("C\n");
                }
                if(r[i]<50){
                    printf("D\n");
                }
            }
            if(m[i]+f[i]<30){
                printf("F\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2104
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
static long help(long k){
	if(k<=1){return 1;}
	long x=help(k/2);
	return 2*x+1;
}
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       StringBuilder sb=new StringBuilder();
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int h=s.nextInt(),n=s.nextInt();
       int k=(int)Math.ceil((double)h/n);
        out.write(k+"");
        out.flush();
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,k;
ll mp[3005][3005];
ll dp[3005][3005][4];
ll dfs(int i,int j,int t)
{
    if(i<1||i>n||j<1||j>m||t>3) return -1e18;
    if(dp[i][j][t]!=-1) return dp[i][j][t];
   // printf("//%d %d %d\n",i,j,t);
    if(i==n&&j==m)
    {
        if(t<3) return mp[i][j];
        return 0;
    }
    ll ans=0;
    ans=max(ans,max(dfs(i+1,j,0),dfs(i,j+1,t)));
    ans=max(ans,mp[i][j]+dfs(i,j+1,t+1));
    if(t<3) ans=max(ans,mp[i][j]+dfs(i+1,j,0));

    return dp[i][j][t]=ans;
}
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    read(n),read(m),read(k);
    while(k--)
    {
        int x,y,v;
        read(x),read(y),read(v);
        mp[x][y]=v;
    }
    printf("%lld\n",dfs(1,1,0));
    return 0;
}
/*
1 4 4
1 1 1
1 2 2
1 3 3
1 4 4
*/


Measured memory_bytes: 356928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
const int pN=1e9 +7;
int main()
{	
	int n;
	cin>>n;
	int arr[n][3];
	forl(i,0,n)forl(j,0,3) cin>>arr[i][j];
	int dp[n][3];
	forl(i,1,n)forl(j,0,3)dp[i][j]=-1;
	forl(j,0,3)dp[0][j]=arr[0][j];
	forl(i,1,n)
	{
		forl(j,0,3)
		{
			forl(k,0,3)
			{
				if(k!=j)
				{
					dp[i][j]=max(dp[i][j],arr[i][j]+dp[i-1][k]);
				}
				 
			}
		}
	}

	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;;
}

Measured memory_bytes: 2560
import sys
N = int(input())
num_list = [int(x) for x in input().split()]
max_x = 0
max_list = [0]
for i in range(N-1):
  n = num_list[i]
  n_next = num_list[i+1]

  if n >= n_next:
    max_x += 1
    if i == N-2:
      max_list.append(max_x)
  else:
    max_list.append(max_x)
    max_x = 0
print(max(max_list))

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

int main(int argc, char *argv[])
{
  int n;
  int q;
  cin >> n >> q;
  string s;
  s.reserve(n);
  cin >> s;
  
  vector<int> res;
  vector<int> buf(n + 1);
  for (int i = n - 1; i >= 0; --i) {
    if (i < n - 1 && s[i] == 'A' && s[i + 1] == 'C') {
      buf[i] = buf[i + 1] + 1;
    } else {
      buf[i] = buf[i + 1];
    }
  }

  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;

    res.push_back(buf[l - 1] - buf[r - 1]);
  }

  for (int i = 0; i < q; i++) {
    cout << res[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

#define MAX_N 200000
int main(void) {

	ios::sync_with_stdio(false);

	int N;		cin >> N;
	int A[MAX_N + 1];
	long long sum = 0;
	for(int i = 1 ; i <= N ; i++){
		cin >> A[i];
        A[i] -= i;
    }

	sort(A + 1 , A + 1 + N);
  	ll medi, ans = 0; 
	if(N % 2 == 0)	medi = (A[N / 2] + A[N / 2 + 1]) / 2;
  	else medi = A[N / 2 + 1];
	for(int i = 1 ; i <= N ; i++)
		ans += abs(A[i] - medi);

	SCOUT(ans) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	int rem = a%k;

	if(k+a-rem<=b||rem==0){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int a,b;cin>>a>>b;

  if((a+b)%2==0){
    cout<<(a+b)/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }

 

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        if(a>k){
            System.out.println(String.format("%d %d",a-k,b));
        }
        
        else{
            System.out.println(String.format("%d %d",0,Math.max(b+a-k,0)));
        }
    }
}



Measured memory_bytes: 22868
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "bitset"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;
const long double EPS = 1e-7;

long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<pair<int,long long int>>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i.first] > depth[cn] + 1) {
				depth[i.first] = depth[cn] + 1;
				Q.push(i.first);
			}
		}
	}
	return;
}

void Search(vector<vector<pair<int, long long int>>>&edge, vector<int>&depth, vector<int>&center, vector<int>&child_sz, vector<int>&child_mx,int node) {
	for (auto i : edge[node]) {
		if (depth[i.first] > depth[node]) {
			Search(edge, depth, center, child_sz, child_mx, i.first);
			child_sz[node] += child_sz[i.first] + 1;
			child_mx[node] = max(child_mx[node], child_sz[i.first] + 1);
		}
	}
	if (child_mx[node] <= N / 2 && N - child_sz[node] - 1 <= N / 2) {
		center.push_back(node);
	}
	return;
}

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

	cin >> N;
	vector<vector<pair<int, long long int>>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R >> K;
		L--;
		R--;
		edge[L].push_back({ R,K });
		edge[R].push_back({ L,K });
	}
	vector<int>child_sz(N);
	vector<int>child_mx(N);
	vector<int>depth(N, MOD);
	vector<int>center;
	Calculate_Depth(edge, depth, 0);
	Search(edge, depth, center, child_sz, child_mx, 0);
	long long int ans = 0;
	for (auto i : center) {
//		cout << i << endl;
		int mx = child_mx[i];
		mx = max(mx, (int)N - 1 - child_sz[i]);
		vector<long long int>dis(N, MOD*MOD);
		dis[i] = 0;
		queue<int>Q;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto j : edge[cn]) {
				if (dis[j.first] > dis[cn] + j.second) {
					dis[j.first] = dis[cn] + j.second;
					Q.push(j.first);
				}
			}
		}
		if (mx * 2 == N) {
			long long int minus = MOD;
			for (auto j : center) {
				if (dis[j])minus = dis[j];
			}
			ans = max(ans, accumulate(dis.begin(), dis.end(), 0LL) * 2 - minus);
		}
		else {
			long long int minus = MOD;
			for (auto j : dis) {
				if (j)minus = min(minus, j);
			}
			ans = max(ans, accumulate(dis.begin(), dis.end(), 0LL) * 2 - minus);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17792
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int res = 0;
  char c;
  while (cin >> c) {
    if(c == '+') res++;
    if(c == '-') res--;
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<set>
#include<cmath>
#define ll long long
#define pb(c, n) c.push_back(n);
using namespace std;
int main()
{
    ll n, m;
    cin>>n>>m;
    cout<<m*n/__gcd(m, n);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n, k;
  cin >> n >> k;

  vector<ull> h;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    h.push(tmp);
  }

  ull result = 0;
  each(i, n) {
    if (k <= h[i]) {
      result++;
    }
  }

  cout << result << endl;

  return 0;
}


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

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

int main(){
    int n,v[60],c[60];
    cin>>n;
    rep(i,n) cin>>v[i];
    rep(i,n) cin>>c[i];
    int x[60];
    rep(i,n) x[i]=v[i]-c[i];
    sort(x,x+n);
    reverse(x,x+n);
    int s=0;
    for(int i=0;x[i]>0 && i<n;i++){
        s=s+x[i];
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
    int n,r;
    cin>>n>>r;
    if (n<=10)
    {
        cout<<r+100*(10-n);
    }
    else cout<<r;    
    return 0;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
l=array(N+1,0)
r=array(N+1,0)
S.each_with_index do|s,i|
  l[i+1]=l[i]+1 if s=="<"
end
N.times do|i|
    r[N-1-i]=r[N-i]+1 if S[N-1-i]==">"
end
ans=0
(N+1).times do|i|
  ans+=max(r[i],l[i])
end
puts ans

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

int main(){
    ll x; cin >> x;
    int ans=0;
    ll money=100;
    while(1){
        money*=1.01;
        ans++;
        //cout << money << endl;
        if(money>=x) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672