akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

class Dice{
    public:
        Dice(vector<int> num_array)
            : aspect(num_array){
            }
        void roll_Dice(char c){
            if(c == 'S'){
                int temp = aspect[0]; 
                aspect[0] = aspect[4];
                aspect[4] = aspect[5];
                aspect[5] = aspect[1];
                aspect[1] = temp;
            }else if(c == 'E'){
                int temp = aspect[0];
                aspect[0] = aspect[3];
                aspect[3] = aspect[5];
                aspect[5] = aspect[2];
                aspect[2] = temp;
            }else if(c == 'W'){
                int temp = aspect[0];
                aspect[0] = aspect[2];
                aspect[2] = aspect[5];
                aspect[5] = aspect[3];
                aspect[3] = temp;
            }else if(c == 'N'){
                int temp = aspect[0];
                aspect[0] = aspect[1];
                aspect[1] = aspect[5];
                aspect[5] = aspect[4];
                aspect[4] = temp;
            }
        }
        void yow_dice(){
            int temp = aspect[1];
            aspect[1] = aspect[2];
            aspect[2] = aspect[4];
            aspect[4] = aspect[3];
            aspect[3] = temp;
        }
        int print_eyes(int a){
            return aspect[a];
        }
        int serch_eyes(int objective_eyes){
            for (int i = 0; i < aspect.size(); i++){
                if(aspect[i] == objective_eyes) return i;
            }
        }
    private:
        vector<int> aspect; // 0:upper 1:front 2:right side 3:left side 4: rear side 5: bottom 
};

int main(){

    // --- Dice input --- //    
    vector<int> num_array(6);
    for(int i=0;i < 6;i++){
        cin >> num_array[i];
    }
    Dice dice1(num_array);
    
    for(int i=0;i < 6;i++){
        cin >> num_array[i];
    }
    Dice dice2(num_array);
    int counter = 0;
    // --- 
    for(int i = 0;i < 6;i++){
        switch(i){
            case 1:
                dice2.roll_Dice('N');
                break;
            case 2:
                dice2.roll_Dice('W');
                break;
            case 3:
                dice2.roll_Dice('N');
                dice2.roll_Dice('N');
                break;
            case 4:
                dice2.roll_Dice('W');
                break;
            case 5:
                dice2.roll_Dice('S');
                break;
        }
        for(int j = 0;j < 4;j++){
            dice1.yow_dice();
            if(dice1.print_eyes(0) == dice2.print_eyes(0) && dice1.print_eyes(1) == dice2.print_eyes(1)&& dice1.print_eyes(2) == dice2.print_eyes(2)&& dice1.print_eyes(3) == dice2.print_eyes(3)&& dice1.print_eyes(4) == dice2.print_eyes(4)&& dice1.print_eyes(5) == dice2.print_eyes(5)){
                cout << "Yes\n";
                counter++ ;
                break;
            }
        }
        if(counter == 1) break;
    }
    
    if(counter == 0) cout << "No\n";
    return 0;
}
 



Measured memory_bytes: 3136
import sys
from io import StringIO
import unittest
import math

def resolve():
    s,c= map(int,input().split())

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
        
resolve()

Measured memory_bytes: 50668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

ll A[3001][3001];
ll dp[3001][3001][5];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    for(int i=1; i<=k; i++)
    {
        ll r,c,v;
        cin>>r>>c>>v;
        A[r][c]=v;
    }

    dp[0][0][0]=0;

    for(int i=1; i<=n; i++)
    for(int j=1; j<=m; j++)
    for(int z=0; z<4; z++)
    {
        dp[i][j][z]=max(dp[i][j-1][z], dp[i-1][j][z]);

        for(int lastRow=0; lastRow<4; lastRow++)
        dp[i][j][z] = max(dp[i-1][j][lastRow], dp[i][j][z]);

        if(z==1)dp[i][j][z] = max(dp[i][j][z], A[i][j] + max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3]}));
        if(z > 0)dp[i][j][z] = max(dp[i][j][z], dp[i][j-1][z-1] + A[i][j]);
    }

    cout<<max({dp[n][m][0],dp[n][m][1],dp[n][m][2],dp[n][m][3]});
}


Measured memory_bytes: 425624
def ans():
  N = int(input())
  xyh = [list(map(int,input().split())) for _ in range(N)]
  xyh = sorted(xyh, key = lambda x: -x[2])
  mx, my, mh = xyh[0]
  for Cx in range(101):
    for Cy in range(101):
      H = mh+abs(mx-Cx)+abs(my-Cy)
      if(all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x,y,h in xyh)):
        print(Cx, Cy, H)
        exit()
ans()

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

int main(){

	long long L0=2, L1=1, L2;
	int N;
	cin >> N;
	
	if(N==0) cout << 2;
	else if(N==1) cout << 1;
	else{
		for(int i=2; i<=N; i++){
			L2 = L1 + L0;
			L0 = L1;
			L1 = L2;
		}
		cout << L2;	
	}

	cout << endl;

	return 0;
}



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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N,M;
	cin>>N>>M;
    vector<ll> ans1(M),ans2(M);
    if(N%2==1){
        rep(i,M){
            ans1[i] = i+1;
            ans2[i] = 2*M-i;
        }
    }else{
        ll A = M/2;
        ll B = (M+1)/2;
        rep(i,A){
            ans1[i] = i+1;
            ans2[i] = 1+A*2-i;
        }
        rep(i,B){
            ans1[A+i] = 1+A*2+1+i;
            ans2[A+i] = 1+A*2+1+B*2-1-i;
            }
        }

    rep(i,M){
        cout<<ans1[i]<<" "<<ans2[i]<<"\n";
    }
	
	return 0;
}


Measured memory_bytes: 4400
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use smallvec::alloc::collections::BinaryHeap;
use std::cmp::Reverse;
use std::collections::HashMap;

fn main() {
    input! {
    n: usize,
    m: usize,
    py: [(usize, usize); m]
    }
    let mut q = vec![vec![]; n + 1];
    let mut map = HashMap::new();
    for i in 0..m {
        let (p, y) = py[i];
        q[p].push(y);
    }
    for i in 0..=n {
        q[i].sort();
        for j in 0..q[i].len() {
            map.insert((i, q[i][j]), i * 1000000 + j + 1);
        }
    }
    for i in 0..m {
        let (p, y) = py[i];
        let ans = map.get(&(p, y)).unwrap();
        println!("{:012}", ans);
    }
}


Measured memory_bytes: 15456
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

LL calc(vector<LL> as, int fps){
	LL fst = as[fps];
	as.erase(as.begin() + fps);

	LL res = 0;
	for(int z = 0; z < 2; ++z){
		deque<LL> dq(ALL(as));
		LL sum = 0;
		LL prv = fst;
		for(int c = 1; !dq.empty(); ++c){
			LL e;
			if(c & 1){
				e = dq.front();
				dq.pop_front();
			}
			else{
				e = dq.back();
				dq.pop_back();
			}
			sum += abs(e - prv);
			prv = e;
		}
		chmax(res, sum);
		reverse(ALL(as));
	}
	return res;
}

void mainmain(){
	int n;
	cin >> n;
	vector<LL> as(n);
	for(int i = 0; i < n; ++i){ cin >> as[i]; }
	sort(ALL(as));
	
	LL ans = 0;
	for(int i = max(n / 2 - 4, 0); i < min(n / 2 + 4, n - 1); ++i){
		LL t = calc(as, i);
		chmax(ans, t);
	}
	cout << ans << '\n';
}



}
int main() try{
	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 2696
#include <stdio.h>

int main(){
    //char型の配列を定義する
    //問題文の制約より、文字列の最大の長さは200000なので、
    //それが入れば良い
    char s[200010], t[2000010];
    
    //s,tに入力を代入する
    scanf("%s",s);
    scanf("%s",t);

    //異なる回数を格納する変数を定義する
    //ループ内で数を数えるときは、その格納先は先に定義しておく
    int ans = 0;

    //sのi文字目とtのi文字目が異なる回数を調べる
    //同様の処理を繰り返すのでforループを用いる

    //'\0'は終端文字である。終端文字は文字列の終わりを表す
    //よって、このループの継続条件は「文字列が終わるまで」となる
    for (int i = 0; s[i] != '\0';i++){
        //s[i]は文字列sのi文字目を表す
        if(s[i] != t[i]){
            //異なっているとき、ansをインクリメント(+1)する
            ans++;
        }
    }
    //答えを出力する
    printf("%d", ans);
}

Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,a,b;string s;char c;
    cin>>n>>m>>a>>b;
    cout<<max(a*b,n*m)<<endl;
    return 0;
}

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

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

 int N;

 void dfs(string s, char mx) {
   if (s.length() == N) {
     cout << s << endl;
   }
   else {
     for (char c = 'a'; c <= mx; c++) {
       if (c == mx) dfs(s + c, mx + 1);
       else dfs(s + c, mx);
     }
   }
 }

 int main() {
   cin >> N;
   dfs("", 'a');
 }


Measured memory_bytes: 1536
from math import ceil

A, B, C = map(int, input().split())

V = A * B * C

ans = 10 ** 9 ** 3
ans = min(ans, abs(ceil(A/2) * B * C - (A//2) * B * C))
ans = min(ans, abs(ceil(B/2) * A * C - (B//2) * A * C))
ans = min(ans, abs(ceil(C/2) * A * B - (C//2) * A * B))

print(ans)


Measured memory_bytes: 3060
N, M = map(int, input().split())
c_list = [[] for _ in range(N)]
e_list = list(map(int, input().split()))
for _ in range(M):
   a, b = map(lambda i: int(i) - 1, input().split())
   c_list[a].append(b)
   c_list[b].append(a)
ans = 0
for i, e in enumerate(e_list):
   for j in c_list[i]:
       if e <= e_list[j]:
           break
   else:
       ans += 1

print(ans)

Measured memory_bytes: 31092
import sys
def main():
    input = sys.stdin.readline
    K=int(input())
    N=50
    ans=[]
    m=K%N
    for i in range(N):
        t = K//N + (1 if i<m else 0)
        ans.append(N*(t+1) - (K-t) - 1)
    print(N)
    print(*ans)

if __name__ == '__main__':
    main()

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

int main(){
    string S;
    cin >> S;
    if (S.at(1) == 'R') cout << "ABC" << endl;
    if (S.at(1) == 'B') cout << "ARC" << endl;

    return 0;
}

Measured memory_bytes: 3624
def solve(t):
    n = len(t)
    p = [t[i] % 10 for i in range(n)]
    q = [(10 - p[i]) % 10 for i in range(n)]
    return sum(t) + sum(q) - max(q)
t = [int(input()) for i in range(5)]
print(solve(t))

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

int main(void) {
  int N, T;
  cin >> N >> T;
  int minc = 1e9;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) minc = min(minc, c);
  }
  cout << (minc == 1e9 ? "TLE" : to_string(minc)) << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))
a.sort()
a.reverse()

alice = []
bob = []

for i in range(n):
    if i % 2 == 0:
        alice.append(a[i])
    else:
        bob.append(a[i])

print(sum(alice) - sum(bob))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[1111][222];
signed main(){
  int n,m;
  while(cin>>n>>m,n){
    int x[m],y[m],t[m];
    char sl[m];
    for(int i=0;i<m;i++) cin>>x[i]>>y[i]>>t[i]>>sl[i];
    int r;
    cin>>r;
    int z[r];
    for(int i=0;i<r;i++) cin>>z[i];
    int INF=1LL<<55LL;
    int s[n][n],l[n][n];
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	s[i][j]=l[i][j]=INF*(i!=j);
    for(int i=0;i<m;i++){
      x[i]--;y[i]--;
      if(sl[i]=='S') s[x[i]][y[i]]=s[y[i]][x[i]]=min(s[x[i]][y[i]],t[i]);
      else l[x[i]][y[i]]=l[y[i]][x[i]]=min(l[x[i]][y[i]],t[i]);
    }
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  s[i][j]=min(s[i][j],s[i][k]+s[k][j]),
	    l[i][j]=min(l[i][j],l[i][k]+l[k][j]);
    for(int i=0;i<r;i++) z[i]--;
    for(int i=0;i<r;i++)
      for(int j=0;j<n;j++)
	dp[i][j]=INF;
    dp[0][z[0]]=0;
    for(int i=0;i<r-1;i++){
      for(int j=0;j<n;j++){
	dp[i+1][j]=min(dp[i+1][j],dp[i][j]+l[z[i]][z[i+1]]);
	for(int k=0;k<n;k++)
	  dp[i+1][k]=min(dp[i+1][k],dp[i][j]+l[z[i]][j]+s[j][k]+l[k][z[i+1]]);
      }
    }
    int ans=INF;
    for(int i=0;i<n;i++) ans=min(ans,dp[r-1][i]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5624
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  17:50-
//A 17:54 AC
bool solve(void){
	int n,i,j,k;cin>>n;
	if(n==0){return false;}
	vector<char>c(n);
	for(i=0;i<n;i++){cin>>c[i];}
	int num[26]={};
	for(i=0;i<n;i++){
		num[c[i]-'A']++;
		for(j=0;j<26;j++){
			bool ok=true;
			for(k=0;k<26;k++){
				if(j==k){continue;}
				if(num[j]<=num[k]+n-i-1){ok=false;break;}
			}
			if(ok){cout<<(char)('A'+j)<<" "<<i+1<<endl;return true;}
		}
	}
	cout<<"TIE"<<endl;
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> a(N); rep(i, N) cin >> a[i];
  vector<int> b(N + 1);
  for (int i = N; i >= 1; --i){
    int cnt = 0;
    for (int j = i; j <= N; j += i){
      if (b[j] == 1) cnt++;
    }
    if (cnt % 2 != a[i - 1]) b[i] = 1;
  }
  cout << count(b.begin(), b.end(), 1) << endl;
  rep(i, N + 1){
    if (b[i] == 1) cout << i << " ";
  }
  cout << endl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    string N; cin >> N;
    bool flag = false;
    rep(i, 3) if (N[i] == '7') flag = true;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

void main_()
{
    ll N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;

    auto NMlcm = N / __gcd(N, M) * M;
    auto Nstep = NMlcm / M;
    auto Mstep = NMlcm / N;

    for (ll i = 0; i < N / Nstep; ++i) {
        if (S[i * Nstep] != T[i * Mstep]) {
            cout << -1 << endl;
            return;
        }
    }

    cout << NMlcm << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

class Team{
public:
  int i,u,a,p;
  bool operator<(const Team &t)const{
    if(a!=t.a) return a>t.a;
    else if(p!=t.p) return p<t.p;
    else return i<t.i;
  }
};

int main(void){
  int n;
  while(cin>>n,n){
    vector<Team> teams;
    for(int i=0;i<n;++i){
      Team t;
      cin>>t.i>>t.u>>t.a>>t.p;
      teams.push_back(t);
    }
    sort(teams.begin(),teams.end());
    map<int,int> univ;
    vector<int> ans;
    for(int i=0;i<n;++i){
    	if(count(ans.begin(),ans.end(),teams[i].i))continue;
    	if(ans.size()<10){
    		if(univ[teams[i].u]<3){++univ[teams[i].u];ans.push_back(teams[i].i);i=0;}
    	}else if(ans.size()<20){
    		if(univ[teams[i].u]<2){++univ[teams[i].u];ans.push_back(teams[i].i);i=0;}
    	}else if(ans.size()<26){
    		if(univ[teams[i].u]==0){++univ[teams[i].u];ans.push_back(teams[i].i);i=0;}
    	}
    }
  	for(int i=0;i<ans.size();++i)cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long v = sc.nextLong();
    long b = sc.nextLong();
    long w = sc.nextLong();
    long t = sc.nextLong();
    long d = Math.abs(a - b);
    long d2 = (v - w) * t;
    System.out.println(d2 >= d ? "YES" : "NO");
  }
}


Measured memory_bytes: 35520
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N; cin >> N;
	vector<tuple<string, int, int>> p(N);
	for (int i = 0; i < N; ++i) {
		string a; int b;
		cin >> a >> b;
		p[i] = make_tuple(a, -b, i+1);
	}
	sort(p.begin(), p.end());
	for (auto t : p) {
		string x; int y; int i;
		tie(x, y, i) = t;
		//cout << x << " " << y << " " << i << endl
		cout << i << endl;
	}

}

Measured memory_bytes: 256
<?php
list($x,$y)=explode(" ",trim(fgets(STDIN)));
if($y%2==1){
  echo "No";
  exit;
}
$l=$x*2;
$r=$x*4;
if($y>=$l){
  if($y<=$r){
    echo "Yes";
    exit;
  }
}
echo "No";

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

inline int getDigit(int n) {
	return (int)ceil(log10(n));
}

/*
void call(int n){
	int i = 1;
CHECK_NUM:
	int x = i;
	if ( x % 3 == 0 ){
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if ( x % 10 == 3 ){
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if ( x ) goto INCLUDE3;
END_CHECK_NUM:
	if ( ++i <= n ) goto CHECK_NUM;

	cout << endl;
}
*/

int main() {
	int n;
	cin >> n;
	//call(n);

	for(int i = 1; i <= n; ++i) { 
		int x = i;
		if(x%3==0) {
			cout << " " << i;
			continue;
		}
		for(int j = 0; j < getDigit(i); ++j) {
			if(x%10==3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		}

	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    
      string s;
      cin >> s;
      if(s=="ARC")cout << "ABC\n";
      else cout << "ARC\n";
	return 0;
}




Measured memory_bytes: 3628
#include<bits/stdc++.h>
namespace lib
{
	#define ll long long
	#define ull unsigned long long
	#define rgi register int
	#define rgl register long long
	#define rgc register char
	const double pi=acos(-1); 
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 112
			char _num[_NUMLEN],_ch; int _f,_head; bool _useSTD;
		public:
			fastio() {_f=0,_head=0,_useSTD=0,SUF=_ch=' ';}
			char SUF;
			inline void ioSTD() {_useSTD=1; ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); }
			inline void gc(char & _c) {if(_useSTD)cin>>_c; else _c=getchar(); }
			inline void pc(char _c) {if(_useSTD)cout<<_c; else putchar(_c); }
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x; else{
					_x=0; 
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch); 
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch); 
					_f&&(_x=-_x,_f=0); 
				}return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cout<<_x<<SUF; else{
					_T _k; 
					if(_x==0) {pc('0'),pc(SUF);return *this;} if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k; while(_head>0) pc(_num[_head]),--_head;
					pc(SUF);
				}return *this; 
			}
			inline fastio & operator >> (char & _x) {gc(_x);return *this;}
			inline fastio & operator << (char _x) {pc(_x);return *this;}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define edn pc('\n')
	}io;
	inline void fileio(string _r,string _w) {if(_r[0]!='-')freopen(_r.c_str(),"r",stdin); if(_w[0]!='-')freopen(_w.c_str(),"w",stdout); }
	#define mem(_x,_set) memset(_x,_set,sizeof(_x))
}
using namespace lib;
// ----------------------------

// #define int ll
const int maxn=1000004;
const int mod=998244353,inf=1000000007;

char str[maxn];
int n, flag = 1;

signed main() 
{
	scanf("%s", str + 1);
	n = strlen(str + 1);
	for(int i = 1; i <= n; ++i) {
		if(i & 1) {
			if(str[i] != 'h') flag = 0;
		}
		else {
			if(str[i] != 'i') flag = 0;
		}
	}
	if(flag && n % 2 == 0) puts("Yes");
	else puts("No");
	return 0;
}

// ----------------------------
// by imzzy


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

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t d = c - a - b, p = 4 * a * b;
  if (d > 0 && p < d * d) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main() {
    int i,j,k,first,last,digits[10];
    int counter = 0;

    cin >> first >> last;
    
    for(i = first; i <= last; i++){
        j = i;
        k = 0;
        while(j > 0) {
            digits[k] = j % 10;
            
            j /= 10;
            k++;
        }

        if(digits[0] == digits[4] && digits[1] == digits[3]){
            counter++;
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import product

n = int(input())
xy = []
for i in range(n):
    a = int(input())
    temp = []
    for j in range(a):
        x, y = map(int, input().split())
        temp.append((x, y))
    xy.append(temp)

ans = 0
for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break

    else:
        ans = max(ans, sum(ts))

print(ans)

Measured memory_bytes: 3188
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>  
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<utility>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<vector>
#include<ctime>
#define INF 1000000000000000000ll
#define ll long long
#define max(x,y) (x>y?x:y)
#define min(x,y) (x>y?y:x) 
#define db double
#define EPS 1e-6
#define mod 12345678
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    register int x=0,f=1;register 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();}
    return x*f;
}
const int MAXN=200010;
int b[MAXN],c[MAXN];
int n,m,len,cnt;
struct wy
{
	int x,s;
	int friend operator <(wy a,wy b)
	{
		return a.x<b.x;
	}
}t[MAXN];
int lin[MAXN],ver[MAXN<<1],nex[MAXN<<1],e[MAXN<<1];
int vis[MAXN],s[MAXN];
inline void add(int x,int y,int z)
{
	ver[++len]=y;
	nex[len]=lin[x];
	lin[x]=len;
	e[len]=z;
}
inline int dfs(int x)
{
	vis[x]=1;
	int w=b[x];
	for(int i=lin[x];i;i=nex[i])
	{
		int tn=ver[i];
		if(vis[tn])continue;
		if(dfs(tn))
		{
			++cnt;w=w^1;
			s[e[i]]=1;
		}
	}
	return w;
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();m=read();
	for(int i=1;i<=n;++i)t[i]=(wy){read(),read()};
	sort(t+1,t+1+n);
	int ans=0;
	for(int i=1;i<=n+1;++i)
	{
		b[i]=ans^t[i].s;
		ans^=b[i];
		c[i]=t[i].x;
		//cout<<b[i]<<endl;
	}
	for(int i=1;i<=m;++i)
	{
		int x,y;
		x=read();y=read();
		x=lower_bound(c+1,c+1+n,x)-c;
		y=upper_bound(c+1,c+1+n,y)-c-1;
		//cout<<x<<' '<<y<<endl;
		if(x>y)continue;
		++y;add(x,y,i);add(y,x,i);
	}
	for(int i=1;i<=n;++i)
	{
		if(vis[i])continue;
		if(dfs(i)){puts("-1");return 0;}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=m;++i)if(s[i])printf("%d ",i);
	return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1,0);
    map<ll,ll> mp;
    mp[sum[0]]++;
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
        mp[sum[i+1]]++;
    }
    ll ans = 0;
    for(auto itr = mp.begin();itr != mp.end();itr++){
        ans += (*itr).second * ((*itr).second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
using namespace std;

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; i--)
#define rek(i,a,b) for (int i=(a),_##i=(b); i>=_##i; i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(b))
#pragma comment(linker, "/STACK:102400000,102400000")
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}

int x,y;

int main()
{
    while(scanf("%d",&x)==1)
    {
        if(x<1200) puts("ABC");else puts("ARC");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

long long int dp[101][100001] = { 0 };

int main()
{
	int n;
	long int wmax;
	cin >> n >> wmax;

	vector<int>w(n);
	vector<long long>v(n);
	rep(i, 0, n)cin >> w[i] >> v[i];

	
	rep(i,0,wmax+1)dp[0][i] = 0;
	rep(i, 0, n)
	{
		rep(j, 0, wmax+1)
		{
			if (j - w[i] >= 0)dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			else dp[i + 1][j] = dp[i][j];
		}
	}

	cout << dp[n][wmax] << endl;
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define FORl(i, a, b, c) for (ll i = (a); i <= (b); i += (c))
#define FORDl(i, a, b, c) for (ll i = (a); i >= (b); i -= (c))
using namespace std;
int n;
map<ll, ll> inp;
pll order[100005];
int sze[100005];

vector<int> edges[100005];
int sub[100005];
int dep[100005];
ll dfs (int u, int p) {
	ll s = dep[u];
	int sz = 1;
	for (auto v : edges[u]) {
		if (v == p) continue;
		dep[v] = dep[u] + 1;
		s += dfs(v, u);
		sz += sub[v];
	}
	sub[u] = sz;
	return s;
}
ll pos[100005];
int it = 0;
void dfs2 (int u, int p, ll sd) {
	pos[++it] = sd;
	for (auto v : edges[u]) {
		if (v == p) continue;
		dfs2(v, u, sd - sub[v] + (n - sub[v]));
	}
}
int main () {
	scanf("%d", &n);
	FOR(i, 1, n, 1) {
		ll t;
		scanf("%lld", &t);
		order[i] = {t, i};
		inp[t] = i;
		sze[i] = 1;
	}
	sort(order + 1, order + n + 1);
	vector<pii> elist;
	FORD(i, n, 2, 1) {
		auto u = order[i];
		int s = sze[u.se];
		ll nd = u.fi - (n - sze[u.se]) + sze[u.se];
		if (nd > u.fi || inp.find(nd) == inp.end() || inp[nd] == u.se) {
			printf("-1\n"); return 0;
		}
		int v = inp[nd];
		elist.pb({u.se, v});
		edges[u.se].pb(v); edges[v].pb(u.se);
		sze[v] += sze[u.se];
	}

	dep[1] = 0;
	ll sumd = dfs(1, -1);
	dfs2(1, -1, sumd);
	sort(pos + 1, pos + n + 1);
	FOR(i, 1, n, 1) {
		if (order[i].fi != pos[i]) {
			printf("-1\n"); return 0;
		}
	}

	for (auto e : elist) {
		printf("%d %d\n", e.fi, e.se);
	}
	return 0;
}

Measured memory_bytes: 25076
N,M = map(int,input().split())
one = []
nnn = []
for i in range(M):
    ai,bi = map(int,input().split())
    if ai == 1:
        one.append(bi)
    if bi == N:
        nnn.append(ai)
def bs_left(l, target): # l=sorted, target以上の値をもつ要素のうち一番左のindexを返す
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if l[mid] < target:
            low = mid+1
        else:
            high = mid
    if low == len(l):
        return -1
    return low
flag = False
if len(one) == 0 or len(nnn) == 0:
    pass
else:
    nnn.sort()
    for i in range(len(one)):
        if nnn[bs_left(nnn,one[i])] == one[i]:
            flag = True
            break

if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 59480
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int MAX = 1000005;
const int mod = 1000000007;
/* global variables */
// vector<int> cnt(MAX, 0);
vector<int> cnt(MAX, 0);
vector<int> p(MAX);
vector<int> a;
int N;
/* function */
int gcd(int a, int b) {
    return (a % b) ? gcd(b, a % b) : b;
}
void sieve() {
    // O(Nlog(logN))
    // p[i] = iの持つ最小の素因数を格納
    // ex) p[5] = 5, p[10] = 2
    for (int i = 0; i < MAX; i++) p[i] = i;

    for (int i = 2; i * i < MAX; i++) {
        if (p[i] == i) {
            for (int j = i + i; j < MAX; j += i) {
                if (p[j] == j) p[j] = i;
            }
        }
    }
}
map<int, int> factrization(int x) {
    // 前処理sieveを行っておく -> O(logx)
    map<int, int> ret;
    while (x != 1) {
        ret[p[x]]++;
        x /= p[x];
    }
    return ret;
}
bool isPc1() {
    for (int i = 0; i < N; i++) {
        cnt[a[i]]++;
    }
    vector<bool> isPrime(MAX, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i < MAX; i++) {
        int num = cnt[i];
        if (isPrime[i]) {
            for (int j = i + i; j < MAX; j += i) {
                isPrime[j] = false;
                num += cnt[j];
            }
        }
        if (num >= 2) return false;
    }
    return true;
}
bool isPc2() {
    // fast prime factrization
    sieve();
    for (int i = 0; i < N; i++) {
        for (auto q : factrization(a[i])) {
            cnt[q.first]++;
        }
    }
    for (int i = 2; i < MAX; i++) if (cnt[i] > 1) return false;
    return true;
}
bool isSc() {
    int ret = 0;
    for (int i = 0; i < N; i++) { ret = gcd(ret, a[i]); }
    if (ret == 1) return true;
    else return false;
}
/* main */
int main(){
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    // if (isPc1()) { cout << "pairwise coprime" << '\n'; }
    if (isPc2()) { cout << "pairwise coprime" << '\n'; }
    else if (isSc()) { cout << "setwise coprime" << '\n'; }
    else { cout << "not coprime" << '\n'; }
}

Measured memory_bytes: 14864
# k = 1 - nまでの k の和
def sigma1(n):
    return n * (n + 1) // 2

n = int(input())
dat = list(map(int, input().split()))
buf = [0] * (n+1)
cur = 0
import collections
pos = collections.defaultdict(list)

for i in range(0, n):
    cur += dat[i]
    pos[cur].append(i)
    buf[i+1] = cur

buf.sort()
#print(buf)
import collections
res = 0
c = collections.Counter(buf)
for k in c.keys():
    cnt = c[k]
    if cnt < 2:
        pass
    else:
        res += sigma1(cnt - 1)
print(res)


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> p(M);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)=make_pair(b,a);
  }
  sort(p.begin(),p.end());
  int Z=1,L=p.at(0).first;
  for(int i=1;i<M;i++){
    if(L<=p.at(i).second){
      L=p.at(i).first;
      Z++;
    }
  }
  cout<<Z<<endl;
}


Measured memory_bytes: 1024
import numpy as np
N, M = [int(str) for str in input().strip().split()]
cakes = np.array([[int(str) for str in input().strip().split()] for i in range(N)])

def calc_score(choised_cakes):
    return sum([abs(sum(para)) for para in choised_cakes.T])

signs_list = [[i, j, k] for i in (-1, 1) for j in (-1, 1) for k in (-1, 1)]

score_list = []
for signs in signs_list:
    sscores = np.dot(cakes, np.array(signs).T)
    sort_index = np.argsort(sscores)[::-1]
    sorted_cakes = cakes[sort_index]
    score_list.append(sum(np.dot(sorted_cakes[:M], np.array(signs).T)))

print(max(score_list))

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i=0; i<M; i++){
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x-1, y-1);
    }
    int ans = 0;
    for(int i=0; i<N; i++) if(uf.find(i) == i) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n-1);
	rep(i, n-1) {
		cin >> b[i];
	}
	a[0] = b[0];

	rep(i, n-1) {
		if (i == n - 2) {
			a[n - 1] = b[n - 2];
			break;
		}
		if (b[i] < b[i + 1]) {
			a[i + 1] = b[i];
		}
		else {
			a[i + 1] = b[i + 1];
		}
	}
	ll sum(0);
	rep(i, n) {
		sum += a[i];
	}
	cout << sum;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
ans = 0
while True:
    if a == b and b == c:
        break
    a, b, c = sorted([a, b, c])
    if a == b:
        a += 1
        b += 1
    else:
        a += 2
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define pii pair<int, int>

using namespace std;

int n, h[100005], dp[100005];
void solve()
{
    cin >> n;
    for (size_t i = 0; i < n; i++)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1];
}

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

Measured memory_bytes: 5224
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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 ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

V<bool> visited;
vvll edges;
ll n, k;
ll ans = 1;

void dfs(ll i, ll c1, ll c2) {
  if (visited[i]) return;
  ans = ans * (k-c1-c2) % MOD;
  visited[i] = true;
  REP(toi, edges[i].size()) {
    ll to = edges[i][toi];
    if (visited[to]) continue;
    dfs(to, 1, c1++);
  }
}

int main() {
  cin >> n >> k;
  visited.resize(n, false);
  edges.resize(n);
  REP(i, n-1) {
    ll a, b; cin >> a >> b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }
  dfs(0, 0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  cout<<fixed;
  cout<<setprecision(10);
  vector<double>v;
  for(int i = 0 ; i < n ; i++ ){
  	double temp;cin>>temp;v.push_back(temp);
  }
 
  vector<vector<double> > dp(n+1,vector<double>(n+1,0.0));
    dp[0][0]=1;
  for(int i = 1 ; i <= n ; i++ ){
  		for(int j = 0 ; j<=i;j++){
          if(j==0) dp[i][j]=dp[i-1][j]*(1-v[i-1]);
            else
              dp[i][j]=dp[i-1][j]*(1-v[i-1])+dp[i-1][j-1]*(v[i-1]);
          }
          
        
  }
 double ans=0.0;
  for(int i = n ; i>(n/2) ;i--)ans+=dp[n][i];
  cout<<ans;
  
}

Measured memory_bytes: 73736
#include<iostream>

using namespace std;

int main(){
    long long N;
    cin >> N;
    long long x;
    long long dp[N + 1] = {0};
    for(long long i = 0; i < N - 1; i++){
        cin >> x;
        dp[x]++;
    }
    for(long long i = 1; i <= N; i++){
        cout << dp[i] << endl;
    }
    return 0;
}

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

int main(){
	int A, B, n = 1;
	cin >> A >> B;
	
	while(n <= 1250){
		if((8*n/100) == A && n/10 == B){
			cout << n << endl;
			return 0;
		}
		else n++;
	}
	
	cout << "-1" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static final long MODVAL = 998244353L;
    static Set<Long> lunluns = new HashSet<>();
    static long ketas[] = {
            0L, 1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L, 10000000000L, 100000000000L, 1000000000000L, 10000000000000L,
    };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        for(int i=0; i<10; i++) {
            addLunlun(i, 1, i);
        }
//        System.out.println(lunluns.size());
        List<Long> ll = new ArrayList<>();
        for(Long l : lunluns) {
            ll.add(l);
        }
        Collections.sort(ll);
        System.out.println(ll.get(K-1));
//        for(Long l : lunluns) {
//            System.out.println(l);
//        }
//        long hoge = sc.nextLong();
//        isRunrun(hoge);
//        try(
//                FileWriter fw = new FileWriter("data.txt");
//                PrintWriter pw = new PrintWriter(new BufferedWriter(fw));
//        ) {
//            long target = 0L;
//            while(K>0) {
//                if(K%10000==0) {
//                    pw.println();
//                }
//                target++;
//                if(isRunrun(target)) {
//                    pw.print(String.format("%dL,", target));
//                    K--;
//                    continue;
//                }
//            }
//        } catch(IOException ie) {
//        }

    }

    public static void addLunlun(long target, int keta, int lead) {
        if(target>3234566667L) return;
        if(keta > 10) return;
        if(lead>0) {
            addLunlun(target + ketas[keta+1] * (lead-1), keta+1, lead-1);
        }
        addLunlun(target+ketas[keta+1]*lead, keta+1, lead);
        if(lead<9) {
            addLunlun(target+ketas[keta+1]*(lead+1), keta+1, lead+1);
        }
        if(0L!=target) lunluns.add(target);
    }

    public static boolean isRunrun(long target) {
        int before = -1;
        while(target>0) {
            int tmp = (int)(target%10L);
            if(before!=-1 && (Math.abs(before-tmp)>1)) return false;
            before=tmp;
            target/=10;
        }
        return true;
    }

}


Measured memory_bytes: 36732
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	fs := make([][]int, n)

	for i := 0; i < n; i++ {
		fs[i] = make([]int, 10)
		for j := 0; j < 10; j++ {
			fs[i][j] = scanInt()
		}
		// fmt.Println(fs[i])
	}

	ps := make([][]int, n)

	for i := 0; i < n; i++ {
		ps[i] = make([]int, 11)
		for j := 0; j < 11; j++ {
			ps[i][j] = scanInt()
		}
		// fmt.Println(ps[i])
	}

	ans := -n*10000000

	for i := 1; i < 1024; i++ {
		cnt := make([]int, n)
		for j := 0; j < 11; j++ {
			if i & (1<<uint(j))!=0 {
				for k := 0; k < n; k++ {
					if fs[k][j]==1 {
						cnt[k]++
					}
				}
			}
		}

		profit := 0

		for j := 0; j < n; j++ {
			profit += ps[j][cnt[j]]
		}

		// fmt.Println(cnt,profit)

		if ans<profit {
			ans=profit
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int L;
    String[] S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.L = sc.nextInt();
        S = new String[N];
        for (int i=0; i<N; i++) {
        	S[i] = sc.next();
        }
    }
    
    //解答処理
    private String solve() {
    	Arrays.sort(S);
    	
        String answer = null;
        StringBuilder sb = new StringBuilder(); 
        for (int i=0; i<N; i++) {
        	StringBuilder tmp = new StringBuilder(S[i]);
        	sb.append(tmp);
        }
        
        answer = sb.toString();
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 37668
#include<stdio.h>
int main()
{
    int n,x,y,z,a;
    scanf("%d",&n);
    x=n/100;
    a=n%100;
    y=a/10;
    z=a%10;
    if(x*100+y*10+z==z*100+y*10+x)
        printf("Yes\n");
    else
        printf("No\n",n);
    return 0;
}


Measured memory_bytes: 128