akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int a[100005],b[100005];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]]=i;
    }
    for(int i=1;i<=n;i++) printf("%d ",b[i]);
    printf("\n");
}


Measured memory_bytes: 4552
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
l=len
s=sorted
a=1e9
for Y in set(A):
	C=s(sum((v[:l(v)-K+1]for v in(s(v)for k,v in groupby(A,lambda a:a>=Y)if k)if l(v)>=K),[]))
	if l(C)>=Q:a=min(a,C[Q-1]-Y)
print(a)

Measured memory_bytes: 3444
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();

		if (s.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	    scan.close();	
    }
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long int ll;
using namespace std;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int H,W,h,w;
cin>>H>>W;
cin>>h>>w;
int total=H*W-(h*W+w*H-h*w);
cout<<total<<endl;
//system("pause");
return 0;
}

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

max_t = 0
ans = 1

for i in range(2, n + 1, 2):
    t = 0
    j = i
    while j % 2 == 0:
        j //= 2
        t += 1
    else:
        if max_t < t:
            max_t = t
            ans = i
else:
    print(ans)

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
vector<ll> even, odd;
ll n, P, arr[51];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n >> P;
    bool odd = false;
    for(int i = 0; i < n; i ++){
        cin >> arr[i];
        if((arr[i] % 10ll) % 2ll == 1)odd = true;
    }
    if(!odd){
        if(P == 0){
            cout << (1LL << n) << endl;
//            return 0;
        }
        else{
            cout << 0 << endl;
        }
        return 0;

    }
    n --;
    cout << (1LL << n) << endl;
    return 0;
}


Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	string ans;

	while(1) {
		C -= B;
		if (C <= 0) {
			ans = "Yes";
			break;
		}

		A -= D;
		if (A <= 0) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;


int main(){
    int L,R,d; cin>>L>>R>>d;
    int ans = 0;
    for (int i=L; i<=R; i++){
        if (i%d == 0) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    
    int ans = 0;
    for(int i = 0; i < 3; ++i){
        if(s[i] == t[i])    ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
*    created: 27.06.2020 19:39:11
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#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 pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
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;}

signed main() {

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

    int n;
    cin >> n;
    int sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += a;
    }
    sum -= n;
    cout << sum << endl;
    return 0;
}

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


int main() {

    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 256
fn solve() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let k: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    let b: Vec<usize> = (0..m).map(|_| read::<usize>()).collect();
    let mut ac = vec![0];
    let mut bc = vec![0];
    for i in 0..n {
        ac.push(ac[i] + a[i]);
    }
    for i in 0..m {
        bc.push(bc[i] + b[i]);
    }
    // println!("{:?}", ac);
    // println!("{:?}", bc);
    let mut cur = m;
    let mut ans = 0;
    for i in 0..n + 1 {
        while ac[i] + bc[cur] > k && cur > 0 {
            cur -= 1;
        }
        if !(ac[i] + bc[cur] > k) {
            ans = max(ans, i + cur);
        }
    }
    println!("{}", ans);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 7388
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  char c;
  cin >> c;
  cout << char(c + 1) << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n,t,a;
	cin >>n >>t >>a;
	
	double mn = 1e50;
	int ans = 0;
	rep(i,n){
		int h;
		cin>>h;
		double w = t - (h * 0.006);
		double sa = abs(a - w);
		//dbg(sa);
		if(mn > sa){ ans = i; mn = sa;}
	}
	
	cout << ans +1 <<"\n";
}



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

ll gcd(ll p, ll q){ 
    while(q != 0){
        ll r=p%q;
        p=q;
        q=r;
    }
    return p;
}

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    cin>>a.at(0);
    rep(i,1,n){
        cin>>a.at(i);
        a.at(i)=gcd(a.at(i),a.at(i-1));
    }
    cout<<a.at(n-1)<<endl;
return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b;
    scanf("%d %d", &a, &b);
    if (a<b) {
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	int q,x[4],y[4];
	cin >> q;
	while(q--){
		for(int i=0;i<4;i++){
			cin >> x[i] >> y[i];
		}
		double t0,t1,a,b,c,d;
		a = x[3]-x[2]; b = x[0]-x[1];
		c = y[3]-y[2]; d = y[0]-y[1];
		t1 = (d*(x[0]-x[2])-b*(y[0]-y[2]))/(a*d-c*b);
		out(10) << (double)x[2]+(double)t1*(x[3]-x[2]) << " " << (double)y[2]+(double)t1*(y[3]-y[2]) << endl;
	}
}



Measured memory_bytes: 3284
#include <stdio.h>

int main()
{
    long long n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);

    
    if(a == b)
    {
        printf("1");
    }
    else if(a > b)
    {
        printf("0");
    }
    else
    {
        if(n == 1)
        {
            printf("0");
        }
        else
        {
            printf("%lld",(b - a) * (n - 2) + 1);
        }
    }
    printf("\n");
}

Measured memory_bytes: 128
/* ITP1_8_B */
#include <stdio.h>

#define MAX_DIGIT 1001
#define CONVERT 48

/* ??????????????????????????¢??° */
void init_array(char ch_array[]);
/* ???????????¶???????????????????????§?????????????????¢??° */
short is_continue(char ch_array[]);
/* ????????????????????¢??° */
short get_sum(char ch_array[]);
/* ??°????????°????????????????????¢??°*/
short convert_number(char target);

int main(void)
{
	char ch_array[MAX_DIGIT];
	
	short ii;
	
	while( 1 )
	{
		// ???????????????
		init_array(ch_array);
		
		// ??\????????????
		scanf("%s", ch_array);
		
		// ???????????¶?????§??????
		if(0 == is_continue(ch_array))
		{
			break;
		}
		
		// ???????????????????????????
		printf("%hd\n", get_sum(ch_array));
	}
	return 0;
}

/* ??????????????????????????¢??° */
void init_array(char ch_array[])
{
	short ii;
	for( ii = 0; ii < MAX_DIGIT; ii++ )
	{
		ch_array[ii] = '\0';
	}
}

/* ???????????¶???????????????????????§?????????????????¢??° */
short is_continue(char ch_array[]){
	if( '0' == ch_array[0] )
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

/* ???????????? */
short get_sum(char ch_array[])
{
	short ii = 0, sum = 0;
	while( 1 )
	{
		if( '\0' == ch_array[ii] )
		{
			break;
		}
		
		sum += convert_number(ch_array[ii]);
		
		ii++;
	}
	return sum;
}

short convert_number(char target)
{
	short ret_num = 0;
	
	if( '0' <= target && '9' >= target )
	{
		ret_num = (short)(target - CONVERT);
	}
	
	return ret_num;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'A') {
            if(i <= n-2 && s[i+1] == 'B') {
                if(i <= n-1 && s[i+2] == 'C') {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

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

const int maxn = 10000 + 5;
int n, x;
int mem[105];
int ans[maxn];

int solve()
{
	int i;
	for(i = 0; i <= n; i++)
	{
		if(i)
		{
			ans[i] = mem[i-1] + ans[i-1];
			if(ans[i] > x) break;
		}
		else ans[i] = 0;
	}
	return i;
}

int main()
{	
	scanf("%d %d", &n, &x);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &mem[i]);
	}
	printf("%d\n", solve());
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

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

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    vv grid(3);
    for (auto &g : grid)
        g = ga(3);
    ll n;
    cin >> n;

    while (n--) {
        ll b;
        cin >> b;
        for (ll i = 0; i < 3; i++) {
            for (ll j = 0; j < 3; j++) {
                if (grid[i][j] == b)
                    grid[i][j] = -1;
            }
        }
    }
    for (ll i = 0; i < 3; i++) {
        ll sum = 0, s = 0;
        for (ll j = 0; j < 3; j++) {
            sum += grid[i][j];
            s += grid[j][i];
        }
        if (sum == -3 || s == -3) {
            yes;
            return;
        }
    }
    ll s = 0, sum = 0;
    for (ll i = 0; i < 3; i++) {
        s += grid[i][i];
        sum += grid[i][2 - i];
    }
    yesno(s == -3 || sum == -3);
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int N, K, i, ans = 0;
	scanf("%lld%lld", &N, &K);
	for(i = 1; i <= N; i++){
		if((2 * i) % K == 0){
			ans += ((i + N) / K - i / K) * ((i + N) / K - i / K);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1 or (n>=2 and a[0]=='0'):
    print(-1)
else:
    if n==1 and a[0]=='.':
        a[0]='0'
    elif a[0]=='.':
        a[0]='1'
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

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

if(S.substr(0) == T.substr(0,S.size())){
    cout << "Yes" << endl;
}
else {
    cout << "No" << endl;
}

}

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

int main() {
  int A;
  int B;
  cin >> A;
  cin >> B;
  if (A != 1 && B != 1) {
    cout << 1 << endl;
  }
  else if (A != 2 && B != 2) {
    cout << 2 << endl;
  }
  else if (A != 3 && B != 3) {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    ll n, a, b, ans = 0;
    cin>>n>>a>>b;
    
    if((b-a) % 2 == 0) ans = (b-a)/2;
    
    else {
        if(b-1<=n-a){
            if(a == b-1) ans = min(b-1, n-a);
            
            else{
                ans += a-1;
                ans ++;
                ans += (b - (a-1) - 2) / 2;
            }
        }
        else{
            if(a == b-1) ans = min(b-1, n-a);
            
            else{
                ans += n-b;
                ans ++;
                ans += (n - (a + (n-b) + 1)) / 2;
            }
        }
        
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_d
from collections import Counter

def main():
    N = input()
    A = sorted(map(int, input().split(' ')))
    B = Counter(A)
    for a in A:
        if B[a] == 0:
            continue
        if B[a] > 1:
            B[a] = 0
        for i in range(2, A[-1] // a + 1):
            B[a * i] = 0
    print(Counter(B.values())[1])
    return

main()


Measured memory_bytes: 96764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = k; i < (int)(n); i++)
using ll = long long;

int main() {
    int a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int N;
        cin >> N;
        vector <int> a(N);
        rep(i,N){
                cin >> a[i];
        }
        vector <int> b(N,1);
        int res=-1;
        int flag=0;
        rep(i,N-1){
                if(a[i]==a[i+1]&&flag==1) {

                        b[res]++;
                        flag=1;
                }else if(a[i]==a[i+1]&&flag==0) {
                        res++;
                        b[res]++;
                        flag=1;
                }else{
                        flag=0;
                }

        }

        int i=0;
        int ans=0;
        while(b[i]!=1) {
                ans+=b[i]/2;
                i++;
        }

        cout <<  ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

vector<vector<int>> c(10, vector<int>(10));

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {      // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ///////////////////////////////////////
  int h, w;
  cin >> h >> w;
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  warshall_floyd(10);
  int g[h][w];
  int ans = 0;
  rep(i, h) rep(j, w) {
    cin >> g[i][j];
    if (g[i][j] == -1) continue;
    ans += c[g[i][j]][1];
  }
  /* rep(i, 10) {
    rep(j, 10) cout << c[i][j] << " ";
    cout << endl;
  } */
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<max(A*B,C*D)<<endl; 
  //system("pause");
  return 0;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

int main()
{
	speed;
	
	ll n;
	cin>>n;
	ll ans=0;
	ll a;
	for(ll i=0;i<n;i++)
	{
		cin>>a;
		ans+=a;
	}
	ans-=n;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <map>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m, k, i, j;
    string s;
    cin >> n >> s;;

    int tmp;
    vector<int> ans(n,0), west(n,0), east(n,0);
    for(i = 1; i < n; i++) {
        if (s[i-1] == 'W') {
            west[i] = west[i-1] + 1;
        } else {
            west[i] = west[i-1];
        }
    }

    for(i = n - 1 - 1; i >= 0; i--) {
        if(s[i+1] == 'E') {
            east[i] = east[i+1] + 1;
        } else {
            east[i] = east[i+1];
        }
    }

    rep(i,n) {
        ans[i] = west[i] + east[i];
    }

    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
    return 0;
}


Measured memory_bytes: 4228
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):                                                                                      
            if x - i * 500 - j * 100 - k * 50 == 0:
                ans += 1
            else:
                continue

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
vector<int> ans1,ans2;
int num=0;
inline void solve(i64 n){
	if(n==1){
		ans1.pb(num);
		ans2.pb(num);
		num++;
		return;
	}
	if(n&1){
		solve(n/2);
		ans1.pb(num);
		ans2.pb(num);num++;
	}else{
		solve(n-1);
		ans1.insert(ans1.begin(),num);
		ans2.pb(num);
		num++;
	}
}
int main(){
    i64 n;cin>>n;num=1;
    solve(n);
    printf("%d\n",ans1.size()*2);
    for(u32 i=0;i<ans1.size();i++)printf("%d ",ans1[i]);
    for(u32 i=0;i<ans2.size();i++)printf("%d ",ans2[i]);
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int keta = 0;
	int a = n;
	while (a > 0) {
		keta++;
		a /= 10;
	}
	int ans = 0;
	if (keta == 1)		ans = n;
	else if (keta == 2)	ans = 9;
	else if (keta == 3)	ans = n - 99 + 9;
	else if (keta == 4)	ans = 909;
	else if (keta == 5)	ans = n - 9999 + 909;
	else if (keta == 6) ans = 90909;
	else ans = 0;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

int main(void)
{
	string s; cin >> s;

	ll rl = 0;
	vector<ll> arl(size(s) + 1, 0);
	repr(i, size(s) - 1, -1)
	{
		if (s[i] == '>')
			rl++;
		else
			rl = 0;
		arl[i] = rl;
	}

	ll lr = 0;
	vector<ll> alr(size(s) + 1, 0);
	rep(i, 0, size(s))
	{
		if (s[i] == '<')
			lr++;
		else
			lr = 0;

		alr[i + 1] = lr;
	}

	vector<ll> ans(size(s) + 1, 0);
	rep(i, 0, size(ans))
		ans[i] = max(arl[i], alr[i]);

	ll sum = 0;
	each(e, ans)
		sum += e;

	cout << sum;
	return 0;
}


Measured memory_bytes: 12556
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
  int n;
  cin >> n;
  vi a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  REP(i, n - 1) a[i+1] += a[i];
  RREP(i, n - 1) b[i] += b[i+1];

  int ans = 0;
  REP(i, n) {
    ans = max(ans, a[i] + b[i]);
  }

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


Measured memory_bytes: 256
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	for(int i=0; i<tx-sx; ++i){
		cout << "R";
	}
	for(int i=0; i<ty-sy; ++i){
		cout << "U";
	}

	for(int i=0; i<tx-sx; ++i){
		cout << "L";
	}
	for(int i=0; i<ty-sy; ++i){
		cout << "D";
	}

	cout << "D";
	for(int i=0; i<=tx-sx; ++i){
		cout << "R";
	}
	for(int i=0; i<=ty-sy; ++i){
		cout << "U";
	}
	cout << "L";

	cout << "U";
	for(int i=0; i<=tx-sx; ++i){
		cout << "L";
	}
	for(int i=0; i<=ty-sy; ++i){
		cout << "D";
	}
	cout << "R";

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b,c;
	int tmp;

	scanf("%d %d %d", &a,&b,&c);
	
	if(a > b){
	    tmp = b;
	    b = a;
	    a = tmp;
	}
	if(b > c){
	    tmp = c;
	    c = b;
	    b = tmp;
	}
		if(a > b){
	    tmp = b;
	    b = a;
	    a = tmp;
	}
	printf("%d %d %d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define F first
#define S second


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll sum=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
            sum+=a[i]*a[j];
    }
    cout<<sum;
}


Measured memory_bytes: 256
while 1:
    k=input().split()
    H=int(k[0])
    W=int(k[1])
    if H==0 and W==0:
        break
    for i in range(H):
        msg=""
        if i==0 or i==H-1:
            for j in range(W):
                msg +="#"
            print(msg)
        else:
            msg="#"
            for j in range(W-2):
                msg +="."
            msg+="#"            
            print(msg)
    print("")


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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;


//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;

//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}




vi dx = {1, -1, 0,  0};
vi dy = {0, 0,  1, -1};
//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 
ll INF = 5e18;
ll A,B,C,D;
map <ll,ll> dp;
void min_self(long long& a, long long b) {
	a = min(a, b);
}


ll solve(ll n){
assert(n>=0);
if(n==0){
	return 0;
}
if(n==1){
	return D;
}

if(dp[n])return dp[n];

ll cost = n*D;
if(cost<0) cost = INF;

vector<int> arr = {2,3,5};
vector<ll> costs = {A,B,C};

// ll mini = INT_MAX
f(i,0,3){
	if(n%arr[i]==0){
		cost = min(cost,costs[i]+solve(n/arr[i]));
	}else{
        // ll down = n/arr[i]*arr[i];
        // cost = min(cost,costs[i]+D*(n-down)+solve(n/arr[i]));
		// ll up = down+arr[i];
        // cost = min(cost,costs[i]+D*(up-n)+solve(n/arr[i]+1));
        
        ll g = n/arr[i];
		ll up = n - g*arr[i];
		cost = min(cost,D*up + costs[i]+solve(n/arr[i]));
		ll d = (g+1)*arr[i]-n;
		cost = min(cost,D*d + costs[i]+solve(n/arr[i]+1));
	}
}

return dp[n] = cost;
}

void solve_test(){
ll n;
i1(n);

i2(A,B);
i2(C,D);

ll ans = solve(n);

dp.clear();
o1(ans);
return;
}

int main(){

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

int t,tt;
t=1;
i1(t);
if(google_contest)tt=1;

while(t--){

solve_test();

if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


Measured memory_bytes: 4456
// ------------------------------------
// Date:2018/ 3/ 6
// Problem:ABC 081 NotSoDiverse c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N, K;
  scanf("%d %d", &N, &K);
  vector< int > A(N);
  REP(i, N) {
    scanf("%d", &A[i]);
  }

  // d[i]{num(-1), value}
  vector< pair< int, int > > d;
  int cnt = 0;
  REP(i, N) {
    d.emplace_back(make_pair(i, 0));
  }
  REP(i, N) {
    if (A[i] > N) {
      --cnt;
    } else {
      d[A[i] - 1].second++;
    }
  }

  sort(ALL(d), [](pair< int, int > x, pair< int, int > y) { return x.second > y.second; });
  
  FOR(i, K, N) {
    cnt += d[i].second;
  }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

ll cnt[1000]={0};

void factoring(ll n) {
    ll i;
    for(i=2; i/2<=n; i++) {
        while(n%i==0) {
            cnt[i]++;
            cnt[i]%=MOD;
            n/=i;
        }
    }
}

int main(void) {
    ll n;
    cin >> n;
    ll i;
    ll ans=1;
    for(i=2; i<=n; i++) {
        factoring(i);
    }
    
    for(i=2; i<=n; i++) {
        if(cnt[i]==0) continue;
        ans=ans*(cnt[i]+1)%MOD;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
def main():
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            break

        else:
            cnt = 0
            while True:
                if n == 1:
                    break
                elif n % 2 == 0:
                    n /= 2
                    cnt += 1
                elif n % 2 != 0:
                    n = n * 3 + 1
                    cnt += 1
            print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7684
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    long A,B,C,K;

    private void solve() {
        A = nextLong();
        B = nextLong();
        C = nextLong();
        K = nextLong();

        long ans = 0;
        if (K % 2 == 1) {
            ans = B - A;
        } else {
            ans = A - B;
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 86400
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, n){
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a.begin(), a.end());
    rep(i, n) cout << a[i].second << " ";
    
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int main(){
  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  rep(i, N) cin >> H[i];
  sort(H.begin(), H.end());

  ll ans = 1000000000;
  rep(i, N-K+1) ans = min(ans, H[i+K-1]-H[i]);
  cout << ans << endl;
}


Measured memory_bytes: 4000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		
		int H = 0;
		int W = 0;
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String str = br.readLine();
			String[] num = str.split(" ");

			H = Integer.parseInt(num[0]);
			W = Integer.parseInt(num[1]);

			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W - 1; j++) {
					if (i == 0 || i == H - 1) {
						System.out.print("#");
					} else if (j == 0 || j == W - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println("#");
			}
		System.out.println();
		}
		
	}
}

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

const int N = 200020;
const int INF = (1LL << 31) - 1;
//Range Minimum Query

class RMQ{
    public:
        int n,dat[2*N-1];
    void init(int _n){
        n = 1;
        while(n < _n) n *= 2;
        fill(dat,dat + 2*n - 1, INF);
    }

    void update(int k,int a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    int query(int a,int b){ return query(a,b,0,0,n);}
    int query(int a,int b,int k,int l,int r){
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return dat[k];
        else {
            int vl = query(a,b,k*2+1,l,(l+r)/2);
            int vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};


int main(){
    int n,q; cin >> n >> q;
    RMQ rmq;
    rmq.init(n);
    while (q--){
        int x,y,z; cin >> x >> y >> z;
        if (x == 0) rmq.update(y,z);
        else cout << rmq.query(y,z+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4140
#include<stdio.h>
void swap(int x[],int i,int j){
    int tmp;
    
    tmp = x[i];
    x[i] = x[j];
    x[j] = tmp;
}

void qsort(int x[],int left,int right){
    int i,j;
    int pivot;
    
    i = left;
    j = right;
    pivot = x[(left + right) / 2];
    
    while(1){
        while(x[i] < pivot) i++;
        while(x[j] > pivot) j--;
        if(i >= j) break;
        swap(x,i,j);
        i++;
        j--;
    }
    
    if(left < i-1) qsort(x,left,i-1);
    if(right > j+1) qsort(x,j+1,right);
}
int main(){
    int i,k,n;
    int a[200000];
    int distance[200000];
    int ans = 0;
    
    scanf("%d %d",&k,&n);
    for(i = 0; i < n; i++) scanf("%d",&a[i]);
    
    for(i = 0; i < n-1; i++){
        distance[i] = (a[i+1]-a[i]);
    }
    distance[n-1] = k-a[i]+a[0];
    qsort(distance,0,n-1);
//    for(i = 0; i < n; i++) printf("%d\n",distance[i]);
    
    
//    for(i = 0; i < n; i++) printf("%d\n",distance[i]);
    
    for(i = 0; i < n-1; i++){
        ans += distance[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int u = scanner.nextInt() - 1;
		int v = scanner.nextInt() - 1;
		List<Integer>[] adjacencyList = new List[n];
		for (int i = 0; i < n; i++) {
			adjacencyList[i] = new ArrayList<Integer>();
		}
		for (int i = 0, a, b; i < n - 1; i++) {
			a = scanner.nextInt() - 1;
			b = scanner.nextInt() - 1;
			adjacencyList[a].add(b);
			adjacencyList[b].add(a);
		}
		int[] takahashi = new int[n];
		int[] aoki = new int[n];
		for (int i = 0; i < n; i++) {
			takahashi[i] = -1;
			aoki[i] = -1;
		}
		takahashi[u] = 0;
		aoki[v] = 0;
		dfs(adjacencyList, u, takahashi);
		dfs(adjacencyList, v, aoki);
		int max = 0;
		for (int i = 0; i < n; i++) {
			if (takahashi[i] < aoki[i] && max < aoki[i] - 1)
				max = aoki[i] - 1;
		}
		System.out.println(max);
	}

	static void dfs(List<Integer>[] g, int v, int[] distance) {
		for (int nv : g[v]) {
			if (distance[nv] < 0) {
				distance[nv] = distance[v] + 1;
				dfs(g, nv, distance);
			}
		}
	}

}


Measured memory_bytes: 108596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll n=s.size();
    vector<string>ans;
    for(ll i=0;i<n;i++){
        string sumple=s.substr(i,1);
        ans.push_back(sumple);
        ll j=1;
        while(j<5){
            if(i+j>n-1) break;
            sumple.push_back(s[i+j]);
            ans.push_back(sumple);
            j++;
        }
    }
    sort(ans.begin(),ans.end());
    for(ll i=1;i<ans.size();i++){
        if(ans[i]==ans[i-1]){
            ans[i-1]="zzzzzz";
        }
    }
    sort(ans.begin(),ans.end());
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main()
{
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> V(N);
    for (int i = 0; i < N;++i){
        int c, t;
        cin >> c >> t;
        V[i] = make_pair(c, t);
    }
    sort(V.begin(), V.end());

    int ans = -1;
    for (int i = 0; i < N; ++i)
    {
        if(V[i].second <= T){
            ans = V[i].first;
            break;
        }
    }
    if( ans != -1){
        cout << ans << endl;
    }else{
        cout << "TLE" << endl;
    }

    return 0;
}

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

int N, freq[101], x, total = 0;

int main () {
    cin >> N;
    for (int i=1; i<=N; i++) {
        cin >> x;
        freq[x] = 1;
    }
    for (int i = 1; i<= 100 ;i++) {
        total += freq[i];
    }
    cout << total << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    long long ans = 0;
    for(;;){
        bool end = true;
        for(int i=0; i<n; ++i){
            if(a[i] >= n){
                long long x = a[i] / n;
                for(int j=0; j<n; ++j)
                    a[j] += x;
                a[i] -= x * (n + 1);
                ans += x;
                end = false;
            }
        }
        if(end)
            break;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/



int main()
{
	while (1) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a == 0 && b == 0 && c == 0 && d == 0) {
			return 0;
		} else {
			ll t = b*c;
			if (t <= a) {
				cout << 0 << endl;
			} else {
				ans = (t - a + d - 1) / d;
				cout << ans << endl;
			}
		}
	}
}

Measured memory_bytes: 3160
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define cerr cout
#define F first
#define S second
#define fori(i,a,b) for (i = a; i < b; ++i)
#define ford(i,a,b) for(i = a; i>=b;--i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int(x.size())
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fill(a, x) memset(a, x, sizeof(a))
#define INF 1000000000
#define MOD 1000000007
#define SMOD 998244353
#define endl "\n"
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
const ll N = 100043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n - k], fact[k]));
}

void solve()
{
    ll n;
    cin >> n;
    ll a[n], i, j, k;
    fori(i, 0, n)
        cin >> a[i];
    ll cnt=0;
    fori(i, 0, n)
    {
        fori(j, i+1, n)
        {
            fori(k, j+1, n)
            {
                if((a[i]+a[j])>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && (a[i]+a[k])>a[j] && (a[j]+a[k])>a[i])
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin >> t;
    for(int i=1; i<=t; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

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

vector<long long> weightmemo(2011, - 1);
long long weight(long long i, long long r, long long d) {
  if (weightmemo.at(i) == - 1) weightmemo.at(i) = r * weight(i - 1, r, d) - d;
  return weightmemo.at(i);
}

int main() {
  long long r, d;
  cin >> r >> d >> weightmemo.at(2000);
  for (int i = 2001; i <= 2010; i++) cout << weight(i, r, d) << endl;
}

Measured memory_bytes: 256