akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

VV<> G(200000);
V<bool> vis(200000, false);
V<> even, odd;

void dfs(int k, bool p = true){
    if(vis[k]) return;
    vis[k] = true;
    if(p) even.pb(k);
    else odd.pb(k);
    for(auto v: G[k]) dfs(v, !p);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    REP(i, n-1){
        int a, b; cin >> a >> b; a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(0);
    V<> ans(n);
    V<bool> used(n + 1, false);
    if(SZ(even) * 3 <= n){
        REPS(i, SZ(even)){
            ans[even[i-1]] = i * 3;
            used[i * 3] = true;
        }
        int j = 1;
        for(auto v:odd){
            while(used[j]) j++;
            ans[v] = j;
            used[j] = true;
        }
        goto END;
    }
    if(SZ(odd) * 3 <= n){
        REPS(i, SZ(odd)){
            ans[odd[i-1]] = i * 3;
            used[i * 3] = true;
        }
        int j = 1;
        for(auto v:even){
            while(used[j]) j++;
            ans[v] = j;
            used[j] = true;
        }
        goto END;
    }
	{
	int s = 0, t = 0;
    for(int i = 0; i * 3 + 1 <= n; i++){
        ans[odd[i]] = i * 3 + 1;
        used[i * 3 + 1] = true;
        s = i;
    }
    for(int i = 0; i * 3 + 2 <= n; i++){
        ans[even[i]] = i * 3 + 2;
        used[i * 3 + 1] = true;
        t = i;
    }
    int j = 1;
    for(int i = s + 1; i < SZ(odd); i++){
        ans[odd[i]] = 3 * j;
        j++;
    }
    for(int i = t + 1; i < SZ(even); i++){
        ans[even[i]] = 3 * j;
        j++;
    }
    }
    END:;
    REP(i, n) cout << ans[i] << " ";    
}

Measured memory_bytes: 22492
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n;
    cin>>n;
    int a[n];
    int b[n];
    f1(i,n) {
        cin>>a[i];
    }
    f1(i,n) {
        b[a[i]-1]=i+1;
    }

    f1(i,n) {
        cout<<b[i]<<" ";
    }
    en
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 4240
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
const int N=1e5+5;
char s[N];int a[N],n,res,t,cnt;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	fp(i,1,n)a[i]=s[i]-'0';
	t=0;
	fp(i,1,n)res+=(a[i]!=t),t^=1;
	t=1;
	fp(i,1,n)cnt+=(a[i]!=t),t^=1;
	cout<<min(res,cnt)<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ma, mb, a[41], b[41], c[41], dp[401][401], dpbuf[401][401];
ll max_cost = 4693;

int main() {
	cin >> n >> ma >> mb;
	for(ll items = 1; items <= n; items++){cin >> a[items] >> b[items] >> c[items];}
	for(ll i = 0; i <= 400; i++){for(ll j = 0; j <= 400; j++){dp[i][j] = max_cost;}}
	dp[0][0] = 0;
	
	ll imax = 0; ll jmax = 0;
	for(ll items = 1; items <= n; items++){
		for(ll i = 0; i <= 400; i++){for(ll j = 0; j <= 400; j++){dpbuf[i][j] = max_cost;}}
		
		imax += a[items];
		jmax += b[items];
		for(ll i = 0; i <= imax; i++){
			for(ll j = 0; j <= jmax; j++){
				if(i-a[items] >= 0 && j-b[items] >= 0){
					dpbuf[i][j] = min(dp[i-a[items]][j-b[items]]+c[items], dp[i][j]);
				}
				else{
					dpbuf[i][j] = dp[i][j];
				}
			}
		}
		
		for(ll i = 0; i <= imax; i++){for(ll j = 0; j <= jmax; j++){dp[i][j] = dpbuf[i][j];}}
	}
	
	ll min_cost = max_cost;
	for(ll x = 1; ma*x <= imax && mb*x <= jmax; x++){
		min_cost = min(dp[ma*x][mb*x], min_cost);
	}
	if(min_cost == max_cost){min_cost = -1;}
	//for(ll i = 0; i <= 10; i++){for(ll j = 0; j <= 20; j++){cout << dp[i][j] << " ";}cout << endl;}
	cout << min_cost << endl;
	return 0;
}

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

using namespace std;

int main(){
  	int n,k;
  	cin>>n>>k;
  	string s;
  	cin>>s;
    for(int i = 0;i<n;i++){
     	if(i == k-1){// it's k-1 since arrays/strings in c++ are 0-indexed(starts at 0)
        	cout<< (char)tolower(s[i]); 
        	//you need to change the type to char cuz otherwise it is treated as an int
        }else{
        	cout<< s[i]; 
        }
    }
	return 0;
}

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

const int maxn = 1000 + 5;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
char s[maxn][maxn];
bool v[maxn][maxn];
int d[maxn][maxn];

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) scanf("%s", s[i]);

    queue<pair<int, int>> q;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == '#') {
                v[i][j] = true;
                q.emplace(i, j);
            }
        }
    }

    while (!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();

        for (int i = 0; i < 4; ++i) {
            int a = x + dx[i], b = y + dy[i];
            if (a < 0 || a >= n || b < 0 || b >= m) continue;
            if (v[a][b]) continue;
            d[a][b] = d[x][y] + 1;
            v[a][b] = true;
            q.emplace(a, b);
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == '.')
                ans = max(ans, d[i][j]);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12304
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

long long a,b;

int main() {
  int n;
  string s;
  cin >> n >> s;
  bool flag = true;
  if(n % 2 == 1) {
    cout << "No" << endl;
  }else {
    for(int i = 0; i < n/2; i++) {
      if(s[i] != s[n/2+i]) flag = false;
    }
    if(flag) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    //freopen("circle.in" ,"r", stdin);
    //freopen("circle.out","w",stdout);
    int T=1;
    //scanf("%d",&T);
    while(T--){
        int N,Zero=0;
        scanf("%d",&N);
        map<long long,int> cnt;
        for(int i=1;i<=N;i++){
            long long A;
            scanf("%lld",&A);
            cnt[A]++;
            if(!A) Zero++;
        }
        if(Zero==N){
            puts("Yes");
            continue;
        }
        if(N%3!=0||cnt.size()>3||cnt.size()==1){
            puts("No");
            continue;
        }
        if(cnt.size()==2){
            puts(cnt[0]==N/3?"Yes":"No");
            continue;
        }
        int Sum=0;
        bool Ans=1;
        for(map<long long,int>::iterator it=cnt.begin();it!=cnt.end();it++){
            Sum^=it->first;
            if(it->second!=N/3){
                Ans=0;
                break;
            }
        }
        puts((Ans&&!Sum)?"Yes":"No");
    }
}


Measured memory_bytes: 5120
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, m;
  cin >> n >> m;
  vi s(m), c(m);
  rep(i, m) {
    cin >> s[i] >> c[i];
    s[i]--;
  }

  vi ans(n, -1);
  rep(i, m){
    if (n > 1 and s[i] == 0 and c[i] == 0){
      cout << -1 << endl;
      return 0;
    }
    if (ans[s[i]] != -1 and ans[s[i]] != c[i]){
      cout << -1 << endl;
      return 0;
    }

    if (ans[s[i]] == -1){
      ans[s[i]] = c[i];
    }
  }

  if (ans[0] == -1 and n > 1) ans[0] = 1;

  rep(i, n) if (ans[i] == -1) ans[i] = 0;
  rep(i, n) cout << ans[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i = 0; i , (n); ++i)
using ll = long long;
using namespace std;
int sum(int n) {
    if (n == 0) {
        return 0;
    }

    int s = sum(n - 1);
    return (s + n);
}
//int kaizyou(ll k) {
    //ll sum = 1;
    //for (int i = 1; i <= k; ++i)
    //{
      //  sum *= i;
      //  sum %= 1000000007;
    //}
    //return sum;
//}
int main() {
    int K;
    cin >> K;
    for (int i = 0;i < K; i++) {
        cout << "ACL";
    }
}


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

const ll MOD = 1e9 + 7;

ll fact(ll a) {
    ll res = 1;
    for(ll i = 2; i <= a; ++i) { res *= i; res %= MOD; }
    return res;
}

int main()
{
    ll N, M;
    cin >> N >> M;
    if(N == M) {
        ll res = fact(N)*fact(M)%MOD;
        res *= 2; res %= MOD;
        cout << res << endl;
        return 0;
    }

    ll dif = (N > M) ? N - M : M - N;
    if(dif == 1) {
        ll res = fact(N)*fact(M)%MOD;
        cout << res << endl;
        return 0;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,n,answer;
while(scanf("%d",&n)!=EOF){
answer=0;
for(a=0;(a<=n&&a<=9);a++){
for(b=0;(a+b<=n&&b<=9);b++){
for(c=0;(a+b+c<=35&&c<=9);c++){
if(((n-a-b-c)>=0)&&((n-a-b-c)<=9)){
answer+=1;
}
}
}
}
printf("%d\n",answer);
}
return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

bool c[1001];

int main() {
	int n;
	cin >> n;
	rep(i, 1001) {
		c[i] = false;
	}
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 14; j++) {
			c[i * 4 + j * 7] = true;
		}
	}
	if (c[n]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    sort(all(p),greater<>());
    sort(all(q),greater<>());
    sort(all(r),greater<>());

    vl cand1;
    rep(i,X)cand1.push_back(p[i]);
    rep(i,Y)cand1.push_back(q[i]);

    sort(all(cand1));
    ll sum=0;
    rep(i,X+Y)sum+=cand1[i];

    ll ans=sum;
    ll mi=min(X+Y,C);
    ll sumXY=0;
    ll sumC=0;
    rep(i,mi){
        sumXY+=cand1[i];
        sumC+=r[i];
        chmax(ans,sum+sumC-sumXY);
    }
    cout<<ans<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
}


Measured memory_bytes: 4724
input_lines = input().split()
N = int(input_lines[0])
x = int(input_lines[1])
input_lines = input().split()
list_a = []
for i in range(N):
    list_a.append(int(input_lines[i]))

list_a.sort()
max = 0
for i in range(N):
    current_candy = x
    current_child = 0
    for j in range(i,N):
        tmp = current_candy - list_a[j]
        if tmp >= 0:
            current_candy = tmp
            current_child += 1
    if tmp > 0:
        current_child -= 1
    if current_child >= max:
        max = current_child

print(max)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
struct UnionFind {
    vector<ll> par;
 
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
 
    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
 
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
 
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
 
    ll size(ll x) {
        return -par[root(x)];
    }
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> A(M), B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}

	ll ans = 0;

	for (int i = 0; i < M; i++) {
		UnionFind Uni(N);

		for (int j = 0; j < M; j++) {
			if (i != j && !Uni.issame(A[j], B[j]))
				Uni.merge(A[j], B[j]);
		}
		if(!Uni.issame(A[i], B[i])) ++ans;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){

	int k;
  char s[101];
  scanf("%d", &k);
	scanf("%s", s);
	int length = strlen(s);
	if (length <= k) {
		printf("%s\n", s);
	} else {
		for (int i = 0; i < k; i++) {
			printf("%c", s[i]);
		}
		printf("...\n");
	}

  return 0;
}

Measured memory_bytes: 1664
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
int main(){
	fastio;
	cin>>n;
	int h[n]; 
	forn(i,n) cin>>h[i];
	int dp[n];
	dp[0]=0;
	forsn(i,1,n){
		dp[i] = dp[i-1]+ abs(h[i]-h[i-1]);
		if(i>1) dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<ln;
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    rep(i, N-1) {
        if (A[i] + A[i+1] > X) {
            int diff = A[i] + A[i+1] - X;
            ans += diff;
            if (A[i+1] < diff) {
                diff -= A[i+1];
                A[i+1] = 0;
                A[i] -= diff;
            } else {
                A[i+1] -= diff;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
l, r = map(int, input().split())
z = 2020
for x in range(l, r + 1):
    for y in range(x + 1, r + 1):
        z = min(z, (x * y) % 2019)
        if z == 0:
            print(0)
            exit(0)
print(z)

Measured memory_bytes: 2940
#include<stdio.h>
#include<math.h>

typedef struct {
  double x, y;
}Point;

void kock(int n, Point p1, Point p2)
{
  if (n == 0)
    return;

  // p1, p2 から s, t, u を計算
  Point s, t, u;

  s.x = p1.x + (p2.x - p1.x)/3.0;
  s.y = p1.y + (p2.y - p1.y)/3.0;

  t.x = p1.x + 2.0*(p2.x - p1.x)/3.0;
  t.y = p1.y + 2.0*(p2.y - p1.y)/3.0;

  double dx = t.x - s.x;
  double dy = t.y - s.y;
  
  u.x = dx * cos(M_PI/3.0) - dy * sin(M_PI/3.0) + s.x;
  u.y = dx * sin(M_PI/3.0) + dy * cos(M_PI/3.0) + s.y;

  kock(n-1, p1, s);
  printf("%f %f\n", s.x, s.y);
  kock(n-1, s, u);
  printf("%f %f\n", u.x, u.y);
  kock(n-1, u, t);
  printf("%f %f\n", t.x, t.y);
  kock(n-1, t, p2);
}
  
int main(void)
{
  int n;
  Point p1, p2;

  p1.x = p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;
  
  scanf("%d", &n);
  printf("%f %f\n", p1.x, p1.y);
  kock(n, p1, p2);
  printf("%f %f\n", p2.x, p2.y);
  
  return 0;
}



Measured memory_bytes: 2084
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    while(sc.hasNext()){
      int n=sc.nextInt();
      TreeMap<Integer,Integer>map=new TreeMap<>();
      for(int i=0;i<n;i++){
        map.put(sc.nextInt(),i+1);
      }
      for(int i=0;i<n;i++){
        System.out.print(map.get(i+1)+" ");
      }
      System.out.println("");
    }
    sc.close();
  }
}

Measured memory_bytes: 73868
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
//---------------------------

ll a[MX];

int main(){
    fastio;
    ll n;
    cin>>n;
    map <ll,ll> m1;
    map <ll,ll> m2;
    vector <pair <ll,ll> > v1;
    vector <pair <ll,ll> > v2;
    f(i,0,n){
        cin>>a[i];
        if(i%2==0) m1[a[i]]++;
        else m2[a[i]]++;
    }
    for(auto xd : m1){
        v1.pb({xd.sc,xd.fs});
    }
    for(auto xd : m2){
        v2.pb({xd.sc,xd.fs});
    }
    rsor(v1);rsor(v2);
    if(v1.size() == 1 && v2.size() == 1){
        if(v1[0].sc == v2[0].sc) {cout<<n/2<<endl;return 0;}
        cout<<0<<endl;return 0;
    }
    if(v1.size() == 1 && v2.size() >= 2){
        if(v1[0].sc != v2[0].sc) {cout<<n/2-v2[0].fs<<endl;return 0;}
        else{
            cout<<n/2-v2[1].fs<<endl;return 0;
        }
    }
    if(v2.size() == 1 && v1.size() >= 2){
        if(v1[0].sc != v2[0].sc) {cout<<n/2-v1[0].fs<<endl;return 0;}
        else{
            cout<<n/2-v1[1].fs<<endl;return 0;
        }
    }

    if(v1[0].sc != v2[0].sc){
        cout<<n-v1[0].fs-v2[0].fs<<endl;return 0;
    }
    else{
        ll ans = min(n-v1[0].fs-v2[1].fs,n-v1[1].fs-v2[0].fs);
        cout<<ans<<endl;
        return 0;
    }





}






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

namespace AtCoder_AddSubMul
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> values = new List<int>();
            int ans;
            string str = Console.ReadLine();
            string[] words = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in words) {
                values.Add(int.Parse(s));
            }

            ans = values[0] + values[1];
            if (ans < values[0] - values[1]) {
                ans = values[0] - values[1];
            }
            if (ans < values[0] * values[1]) {
                ans = values[0] * values[1];
            }

            Console.WriteLine(ans);

        }
    }
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  vector<llong> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  llong K;
  cin >> K;
  cout << v[K-1] << endl;

  return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main(void){
  int a, b, c;
  int array[3];
  REP(i,3) cin >> array[i];
  bool flag = true;
  while (flag) {
    int sorted_index = 0;
    for (int i = 0; flag; i++) {
      flag = false;
      for (int j = 3 - 1; j >= i + 1; j--) {
        if (array[j] < array[j-1]) {
          swap(array[j], array[j - 1]);
          flag = true;
        }
      }
    }
  }

  REP(i, 3) {
    cout << array[i];
    if (i < 2) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
}


Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        int[] a = SpIntRead(' ');
        //long lcm = LCM(a[0],a[1]);
        //for (int i = 2; i < N; i++) {
        //    lcm = LCM(lcm,a[i]);
        //}
        long ans = 0;
        //for (int i = 0; i < N; i++) {
        //    ans += (lcm-1) % a[i];
        //}
        //ans = 0;
        for (int i = 0;i < N;i++) {
            ans += a[i] - 1;
        }
        Console.WriteLine(ans);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }

}


Measured memory_bytes: 13376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long l = in.nextInt();
        long r = in.nextInt();

        long min = Long.MAX_VALUE;
        for (long i = l; i <= Math.min(r, l + 2019) ; i++) {
            for (long j = l; j <= Math.min(r, l + 2019); j++) {
                if (i == j) continue;

                min = Math.min(min, (i * j) % 2019);
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
template< typename G >
struct LowLink {
  const G &g;
  vector< int > used, ord, low;
  vector< int > articulation;
  vector< pair< int, int > > bridge;
 
  LowLink(const G &g) : g(g) {}
 
  int dfs(int idx, int k, int par) {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];
    bool is_articulation = false;
    int cnt = 0;
    for(auto &to : g[idx]) {
      if(!used[to]) {
        ++cnt;
        k = dfs(to, k, idx);
        low[idx] = min(low[idx], low[to]);
        is_articulation |= ~par && low[to] >= ord[idx];
        if(ord[idx] < low[to]) bridge.emplace_back(minmax(idx, (int) to));
      } else if(to != par) {
        low[idx] = min(low[idx], ord[to]);
      }
    }
    is_articulation |= par == -1 && cnt > 1;
    if(is_articulation) articulation.push_back(idx);
    return k;
  }
 
  virtual void build() {
    used.assign(g.size(), 0);
    ord.assign(g.size(), 0);
    low.assign(g.size(), 0);
    int k = 0;
    for(int i = 0; i < g.size(); i++) {
      if(!used[i]) k = dfs(i, k, -1);
    }
  }
};


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> pathes(N + 1);
    for(int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
        pathes[b].push_back(a);
    }
    LowLink<vector<vector<int>>> lowlink(pathes);
    lowlink.build();
    cout << lowlink.bridge.size() << endl;
    return 0;
}


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

int main()
{
    int S, W;
    cin >> S >> W;
    if (S <= W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  int n;
  i64 x;
  cin >> n >> x;
  vector<i64> a, b;
  read_n(a, n);
  b = a;

  i64 ans = 1ll << 60;
  for (int k = 0; k <= n; ++k) {
    for (int i = 0; i < n; ++i) {
      b[i] = min(b[i], a[(n + i - k) % n]);
    }
    i64 s = k * x;
    for (int i = 0; i < n; ++i) s += b[i];
    ans = min(ans, s);
  }

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

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

using namespace std;

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

    int h, w, d;
    cin >> h >> w >> d;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            cout << "RYGB"[(((i + j) / d % 2)) | (((h * w + i - j) / d % 2) << 1)];
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int m[111111],ans;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        m[x]++;
    }
    int one=0;
    for(int i=0;i<111111;i++){
        if(m[i])ans++;
        if(m[i]>=2&&m[i]%2==0)one++;
    }
    if(one%2==0)cout<<ans<<endl;
    else cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p,it) for(t::iterator it=p.begin(),it!=p.end(),++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
using namespace std;

const int W=210,H = 210;
int block[W][H];
int ans;

int w,h,xs,ys,xg,yg,n,c,d,x,y;
void solve(int xi,int yi)
{
    if(xi==xg && yi==yg && block[xi][yi]==c){ ans = 1; return;}
    if(block[xi][yi] == 0) return;

    if(block[xi][yi] == c)
    {
        block[xi][yi] = 0;
        solve(xi-1, yi);
        solve(xi, yi-1);
        solve(xi+1, yi);
        solve(xi, yi+1);
    }
    block[xi][yi] = 0;
    return;
}

int main()
{
    while(cin >> w >> h )
    {
        memset(block,0,sizeof(int)*W*H);
        if(w==0 && h==0) break;
        ans = 0;
        cin >> xs >> ys;
        cin >> xg >> yg;
        cin >> n;
        REP(n)
        {
            cin >> c >> d >> x >> y;
            if(d == 1) //tate
            {
                block[x][y] = c;
                block[x][y+1] =c;
                block[x][y+2] = c;
                block[x][y+3] = c;
                block[x+1][y] = c;
                block[x+1][y+1] = c;
                block[x+1][y+2] = c;
                block[x+1][y+3] = c;
            }
            else
            {
                block[x][y] = c;
                block[x+1][y] = c;
                block[x+2][y] = c;
                block[x+3][y] = c;
                block[x][y+1] = c;
                block[x+1][y+1] = c;
                block[x+2][y+1] = c;
                block[x+3][y+1] = c;
            }
        }
        /*rep(j,h)
        {
            rep(i,w) cout << block[i+1][j+1] << " " ;
            cout << endl;
        }*/

        c = block[xs][ys];
        //cout << c  << " goal" << block[xg][yg]<< endl;
        solve(xs,ys);

        if(ans) cout << "OK" << endl;
        else cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

#define xyMAX 1001
#define qMAX 151

char x[xyMAX],y[xyMAX];

int lcs(char x[],char y[]){
  int m,n,i,j;
  int c[xyMAX][xyMAX];
  m = strlen(x);
  n = strlen(y);
  for(i=1; i<=m; i++) c[i][0] = 0;
  for(j=1; j<=n; j++) c[0][j] = 0;
  for(i=1; i<=m; i++){
    for(j=1; j<=n; j++){
      if(x[i-1] == y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j] >= c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  return c[m][n];

}


int main(){
  int i,j,num;
  scanf("%d",&num);
  for(i=0; i<num; i++){
    scanf("%s%s",x,y);
    printf("%d\n",lcs(x,y));
  }
  return 0;

}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	int n;
	cin >> n >> S;
	int count = 0;
	for(int i = 2; i < n; i++){
		if(S[i - 2] == 'A' && S[i - 1] == 'B' && S[i] == 'C'){
			count++;
		}
	}
	cout << count << endl;
}		




Measured memory_bytes: 3604
#include <stdio.h>
int main(void)
{
  int n,p,i,c[50],wan;
  while(scanf("%d %d",&n,&p)&&n+p){
    wan=p;
    for(i=0;i<n;i++)
      c[i]=0;
    while(1){
      for(i=0;i<n;i++){
	if(wan){
	  c[i]++;
	  wan--;
	}
	else{
	  wan=c[i];
	  c[i]=0;
	}
	if(c[i]==p)
	  goto END;
      }
    }
  END:
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 600
// okay so if you think that's how "chlamydia" is spelt then, um, here is a code about a dinosaur who likes a celebrity and has an STD, i guess
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;

void no() {
    cout << "Impossible" << endl;
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> occ(n, 0);
    rep(i, 0, n) {
        int x;
        cin >> x;
        occ[x]++;
    }
    per(i, 0, n) {
        if (occ[i]) {
            rep(j, 0, i + 1) {
                if (j * 2 - 1 == i) {
                    if (occ[j] != 2) no();
                }
                if (j * 2 < i) {
                    if (occ[j] > 0) no();
                } else if (j * 2 == i) {
                    if (occ[j] != 1) no();
                } else if (j * 2 > i) {
                    //cout << j << ": " << occ[j] << endl;
                    if (occ[j] <= 1) no();
                }
            }
            cout << "Possible" << endl;
            return 0;
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int ans = 0;
  vector<int> x(n);
  rep(i,n) {
    cin >> x[i];
    ans += min(x[i],(k-x[i])) * 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m,L=map(int,input().split())
    A=[[INF]*n for _ in range(n)]
    for _ in range(m):
        a,b,c=map(int,input().split())
        a-=1; b-=1
        A[a][b]=A[b][a]=c
    from itertools import product
    for k,i,j in product(range(n),repeat=3):
        A[i][j]=min(A[i][j],A[i][k]+A[k][j])
    B=[[INF]*n for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(A[i][j]<=L): B[i][j]=1
    for k,i,j in product(range(n),repeat=3):
        B[i][j]=min(B[i][j],B[i][k]+B[k][j])
    Q=int(input())
    for _ in range(Q):
        s,t=map(int,input().split())
        s-=1; t-=1
        print(B[s][t]-1 if(B[s][t]!=INF) else -1)
resolve()

Measured memory_bytes: 127964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  char a,b;
  cin >> a>>b;
 
  if(a<b) {
  cout << "<" << endl;
  }
   
  else if(a>b) {
  cout << ">" << endl;
  }
  
  else puts("=");
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;


int main(){
    set<int> S;
    int N;
    cin >> N;
    int d;
    rep(i, N){
        cin >> d;
        S.insert(d);
    }
    int ans = 0;
    set<int>::iterator ite;
    for (ite = S.begin(); ite != S.end(); ++ite) {
        ans++;
    }
    cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    string s;
    rep(i, 3)
    {
        cin >> s;
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;

int dist[100005][3];

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> to(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        to[a].push_back(b);
    }

    int sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;
    rep(i, n) {
        rep(j, 3) {
            dist[i][j] = INF;
        }
    }

    queue<pair<int, int>> q;

    q.push(make_pair(sv, 0));
    dist[sv][0] = 0;
    while(!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for(int u : to[v]) {

            int nl = (l+1)%3;

            if(dist[u][nl] != INF) {
                continue;
            }

            dist[u][nl] = dist[v][l] + 1;
            q.push(make_pair(u, nl));
        }
    }

    int ans = dist[tv][0];

    if(ans == INF) {
        ans = -1;
    }
    else {
        ans /= 3;
    }

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

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int h = a.back();
  int d=0;
  int idx = -1;
  rep(i,n-1) {
    if (d<min(h-a[i], a[i])) {
      idx = i;
      d = min(h-a[i], a[i]);
    }
  } 
  printf("%d %d\n", h, a[idx]);
  return 0;
}

Measured memory_bytes: 640
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String str = br.readLine();
            
            int result = 0;
            int kariResult = 0;
            for(int i=0; i<str.length(); i++){
                if(str.charAt(i) == 'R'){
                    kariResult++;
                    result = kariResult;
                }else{
                    kariResult = 0;
                }
            }
            
            System.out.println(result);
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32516
#include <iostream>
#include <cstdio>
#include <vector>

typedef long long ll;

using namespace std;

ll xorNumber(ll a) {
    if(a == 0) {
        return 0;
    } else if(a % 4 == 1) {
        return 1;
    } else if(a % 4 == 2) {
        return a + 1;
    } else if(a % 4 == 3) {
        return 0;
    } else if(a % 4 == 0) {
        return a;
    }
    return 0;
}

int main(int argc, const char * argv[]) {
    ll a = 0, b = 0;
    cin >> a >> b;
    
    if(a == 0) {
        cout << xorNumber(b) << endl;
    } else {
        cout << (xorNumber(a - 1) ^ xorNumber(b)) << endl;
    }
    
    return 0;
}

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

using namespace std;

bool between(int a, int b, int c){
        return a <= b && b <= c;
}

vector<string> split(const string &s, char c){
        vector<string> v;
        size_t prev = 0, cur;
        while((cur = s.find(c, prev)) != string::npos){
                v.push_back(s.substr(prev, cur - prev));
                prev = cur + 1;
        }
        v.push_back(s.substr(prev));
        return v;
}

int to_int(const string &s){
        return atoi(s.c_str());
}

struct Node {
        string name;
        int left, top, right, bottom;
        vector<Node> children;
};

struct Result {
        Node node;
        int p;
};

Result parse(const string &s, int p){
        Result r;
        ++p;
        size_t t = s.find('>', p);
        r.node.name = s.substr(p, t - p);
        p = t + 1;
        t = s.find('<', p);
        vector<string> loc = split(s.substr(p, t - p), ',');
        r.node.left = to_int(loc[0]);
        r.node.top = to_int(loc[1]);
        r.node.right = to_int(loc[2]);
        r.node.bottom = to_int(loc[3]);
        p = t;
        while(s[p + 1] != '/'){
                Result q = parse(s, p);
                r.node.children.push_back(q.node);
                p = q.p;
        }
        r.p = p + 3 + r.node.name.size();
        return r;
}

pair<string, int> solve(const Node &n, int x, int y){
        pair<string, int> r(n.name, n.children.size());
        for(int i = 0; i < n.children.size(); ++i){
                const Node &c = n.children[i];
                if(between(c.left, x, c.right) && between(c.top, y, c.bottom)){
                        r = solve(c, x, y);
                        break;
                }
        }
        return r;
}

int main(){
        while(true){
                int n;
                cin >> n;
                if(n == 0){ break; }
                string s;
                cin >> s;
                s = "<OUT OF MAIN PANEL>0,0,10000,10000" + s + "</OUT OF MAIN PANEL>";
                Node root = parse(s, 0).node;
                while(n--){
                        int x, y;
                        cin >> x >> y;
                        pair<string, int> answer = solve(root, x, y);
                        cout << answer.first << " " << answer.second << endl;
                }
        }
        return 0;
}

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

int main(void){
    int a,b,c;
    bool flag=false;
    cin>>a>>b>>c;

    if(a+b==c||b+c==a||a+c==b)
        flag=true;

    cout<<((flag)?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256