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

// int check(const vector<int> &list, int v) {
//   auto ite = find(list.begin(), list.end(), v);
//   if (ite != list.end()) {
//     // std::distanceで配列の位置を取得できます。
//     // std::cout << "exist at " << std::distance(list.begin(), ite) <<
//     // std::endl;
//     return distance(list.begin(), ite);
//   } else {
//     // std::cout << "not found." << std::endl;
//     return -1;
//   }
// }

// int main() {
//   int x, n, res;
//   int min = INT_MAX;

//   cin >> x >> n;

//   vector<int> p(n);
//   vector<int> q(100 - n);

//   for (int i = 0; i < n; i++) {
//     cin >> p.at(i);
//   }

//   int j = 0;
//   for (int i = 1; i <= 100; i++) {
//     if (check(p, i) != -1) continue;
//     q.at(j++) = i;
//     if (j == 100 - n) break;
//   }

//   // for (int i = 0; i < 100 - n; i++) {
//   //   cout << q.at(i) << " ";
//   // }

//   // cout << abs(5 - 10) << endl;

//   for (int i = 100 - n - 1; i >= 0; i--) {
//     if (min >= abs(q.at(i) - x)) {
//       min = abs(q.at(i) - x);
//       // cout << q.at(i) << " - " << x << endl;
//       // if (res > q.at(i)) {
//       res = q.at(i);
//       // }
//       // cout << res << " ";
//     }
//   }

//   cout << res << endl;
// }

#include <bits/stdc++.h>
using namespace std;

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

  vector<int> Ps(n);
  for (int i = 0; i < n; i++) {
    cin >> Ps.at(i);
  }

  vector<int> line(102, 0);
  for (int p : Ps) {
    line.at(p) = 1;
  }

  int L, R;
  for (int i = 0; i < 102; i++) {
    L = x - i;
    R = x + i;
    if (line.at(L) == 0) {
      cout << L << endl;
      break;
    }
    if (line.at(R) == 0) {
      cout << R << endl;
      break;
    }
  }
}

Measured memory_bytes: 3612
from sys import stdin
input = stdin.readline

from itertools import accumulate
from bisect import bisect_left

N, K = [int(i) for i in input().split()]

memo = [0] * 100010
for _ in range(N):
    a, b = [int(i) for i in input().split()]
    memo[a] += b

print(bisect_left(list(accumulate(memo)), K))

Measured memory_bytes: 10636
N, L = map(int,input().split())
ans = (N*(N+2*L-1))//2
flag = 0
for i in range(N):
    if L+i==0:
        flag = 1
if flag == 1:
    print(ans)
elif L<0:
    print(ans-(L+N-1))
else:
    print(ans-L)

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll S[200000];
	int N = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') N = N * 10 + c - '0';

	rep(i, N) {
		ll s = 1;
		while ((c = getchar_unlocked()) >= 'a') s = s * 26 + c - 'a';
		S[i] = s;
	}

	pakuri_sort(N, S);

	int kotae = 0;
	ll mae = -1;
	rep(i, N) {
		if (mae != S[i]) {
			kotae++;
			mae = S[i];
		}
	}

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


	Would you please return 0;
}

Measured memory_bytes: 4720
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = 0;
		String S[] = sc.next().split("");
		int s = S.length;
		for(int i=0;i<S.length/2;i++){
			if(S[i].equals(S[S.length-1-i])){
			}else{
				a++;
			}
		}
		sc.close();
		System.out.println(a);
	}
}


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

string to_str(char suit, int k) {
    stringstream ss;
    ss << suit << " " << k;
    return ss.str();
}

int main() {
    int n;
    cin >> n;
    map<string, bool> has;
    for (int i=0; i<n; ++i) {
        char suit;
        int k;
        cin >> suit >> k;
        has[to_str(suit, k)] = true;
    }
    for (int i=0; i<4; ++i) {
        for (int j=1; j<=13; ++j) {
            string card = to_str("SHCD"[i], j);
            if ( ! has[card]) {
                cout << card << endl;
            }
        }
    }
    return 0;
}


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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 1e6 + 10;
const int mod = 998244353;
const double pi = acos(-1);

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

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
  int b = 1;
  while (n)
  {
    if (n & 1)
      b = a * b % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return b;
}

class Prime_Number
{
public:
  int prime[maxn], s, v[maxn];
  void prime_init(int n)
  {
    for (int i = 2; i <= n; i++)
    {
      if (!v[i])
      {
        prime[s++] = i;
        for (int j = 1; j * i <= n; j++)
          v[i * j] = 1;
      }
    }
  }
};

void solve()
{
  int n, k, d;
  while (cin >> n >> k >> d)
  {
    if (n < 0)
      n = -n;
    if (n / d > k)
    {
      printf("%lld\n", n - k * d);
    }
    else
    {
      k-=n/d;
      int ans=n%d;
      if(k%2==0)
       printf("%lld\n",ans);
      else 
        printf("%lld\n",d-n%d);
    }
  }
}
signed main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;

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

        String S = scanner.next();

        long zero = 0;
        long one = 0;

        for(char c: S.toCharArray()){
            if(c == '0'){
                zero++;
            }else{
                one++;
            }
        }

        System.out.println(Math.min(zero, one) * 2);
    }
}


Measured memory_bytes: 25556
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#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)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5,P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
char s[N];int f[N],dp[2][5],n,m,res,t;
void solve1(){
	dp[0][0]=dp[0][3]=1,t=0;
	for(R int i=1;i<n;++i,t^=1){
		dp[t^1][0]=dp[t^1][1]=dp[t^1][2]=dp[t^1][3]=0;
		dp[t^1][0]=add(dp[t][0],dp[t][1]),
		dp[t^1][1]=dp[t][0],
		dp[t^1][2]=add(dp[t][2],dp[t][3]),
		dp[t^1][3]=dp[t][2];
	}
	res=add(dp[t][0],add(dp[t][1],dp[t][2]));
	printf("%d\n",res);
}
void solve2(){
	int lim=n,cur=0,las=m;
	while(s[las]=='R')--las;
	fd(i,las,1)if(s[i]=='B'){
		if(cur&1)cmin(lim,cur+1);
		cur=0;
	}else ++cur;
	cmin(lim,cur+1+(cur&1^1));
	f[0]=f[2]=1;
	for(R int i=4;i<=n;i+=2){
		f[i]=mul(f[i-2],2);
		if(i>=lim+2)f[i]=dec(f[i],f[i-(lim+2)]);
	}
	res=0;
	for(R int i=2;i<=lim;i+=2)upd(res,mul(f[n-i],i));
	printf("%d\n",res);
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d%s",&n,&m,s+1);
	if(s[1]=='B')fp(i,1,m)s[i]^='B'^'R';
	bool flag=0;
	fp(i,1,m)if(s[i]=='B'){flag=1;break;}
	if(!flag)solve1();else solve2();
	return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

int main(){
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong x[3][100005];
llong mem[4][100005];

llong dfs(llong i, llong b) {
    if (i == n) return 0;
    if (mem[b][i] != -1) return mem[b][i];

    llong res = 0;
    for (int k = 0; k < 3; k++) {
        if (k == b) continue;

        res = max(res, dfs(i + 1, k) + x[k][i]);
    }

    return mem[b][i] = res;
}

int main() {
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 100005; j++) {
            mem[i][j] = -1;
        }
    }
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[0][i];
        cin >> x[1][i];
        cin >> x[2][i];
    }

    cout << dfs(0, 3) << endl;    

    return 0;
}


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



int main()
{
    int N;
    int c=0;
    while(cin>>N)
    {
        if(N==0) break;
        vector<int> v(N);
        for(int c=0;c<N;c++) cin>>v[c];
        sort(v.begin(),v.end());
        int act = -1;
        int compte = 0;
        for(int c=0;c<N;c++)
        {
            if(v[c]!=act)
            {
                act=v[c];
                compte=1;
            }
            else compte++;
            if(compte > N/2)
            {
                cout<<v[c]<<endl;
                goto end;
            }
        }
        cout<<"NO COLOR"<<endl;
        end:;
    }
    return 0;
}

Measured memory_bytes: 6452
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	double a,b;cin>>a>>b;
	ll ok = LINF;
	ll ng = 0;
	for(int i = 1; i < 1000000; i++) {
		if (floor(double(i) * 0.08) == a && floor(double(i) * 0.10) == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

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

int main()
{
	int N, H,amx=0,mn;
	vector<int> b;

	cin >> N >> H;
	mn = N;
	b.resize(N);
	for (int i = 0; i < N; i++)
	{
		int ta, tb;
		cin >> ta >> tb;
		if (ta > amx)
			amx = ta;
		b.push_back(tb);

	}
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	mn = (H%amx == 0) ? H / amx : H / amx + 1;
	int tot = 0;
	for (int i = 0; i < N; i++)
	{
		int res = i + 1;
		tot += b[i];
		if (tot >= H)
		{
			if (mn > res)
				mn = res;
			break;
		}
		int h = H - tot;
		int n= (h%amx == 0) ? h / amx : h / amx + 1;
		if (mn > n+res)
			mn = n+res;
	}
	cout << mn << endl;
	return 0;
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long MOD = 1e9 + 7;

int main() {
    map<ll, ll> c;
    ll N, M, A, B;
    cin >> N >> M;
    rep(i, N) {
        cin >> A;
        c[A]++;
    }
    rep(i, M) {
        cin >> B >> A;
        c[A] += B;
    }
    ll sum = 0;
    int ch = 0;
    auto it = c.rbegin();
    for(; it != c.rend(); it++) {
        if(ch + it->second <= N) {
            sum += it->first * it->second;
            ch += it->second;
        } else {
            sum += it->first * (N - ch);
            break;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 16000
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))
b_acc = [0] + list((accumulate(b)))

ans = 0
bn = m

for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        break

    # rem >= 0 かつ、b_acc[0] = 0なので、bnはどんなに減っても0で必ず止まります。マイナスになってバグることはありません
    while b_acc[bn] > rem:
        bn -= 1
    ans = max(ans, an + bn)

print(ans)

Measured memory_bytes: 50592
#include <iostream>
#include <string>

using namespace std;

string solve(int x, int a, int b) {
    int t = -a + b;
    if (t <= 0) {
        return "delicious";
    } else if (t <= x) {
        return "safe";
    } else {
        return "dangerous";
    }
}

int main() {
    int x, a, b;

    cin >> x >> a >> b;

    cout << solve(x, a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())

if N<K:
    total=0
    for i in range(1,N+1):
        for j in range(1000):
            if i*2**j<K<=i*2**(j+1):
                total+=(1/N)*(1/2)**(j+1)
                break
elif N>=K:
    total=0
    for i in range(K,N+1):
        total+=(1/N)*1
    for i in range(1,K):
        for j in range(1000):
            if i*2**j<K<=i*2**(j+1):
                total+=(1/N)*(1/2)**(j+1)
                break   
print(total)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 10000000000000
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
ll m,n,row,col,k;
ll memo[105][100006];
ll cost[105],weight[105];
ll dp(int i, ll w)
{
  if(i  >= n)return 0;
  if(memo[i][w]!=-1)return memo[i][w];
  ll p1 = 0, p2 = 0;
  if(weight[i] + w <= m)p1 = cost[i] + dp(i+1,w+weight[i]);
  p2 = dp(i+1,w);
  memo[i][w] = max(p1,p2);
  return memo[i][w];
}
void solve()
{
  scanf("%lld%lld",&n,&m);
  for(int w=0;w<n;w++)scanf("%lld%lld",&weight[w],&cost[w]);
  memset(memo,-1,sizeof memo);
  ll ans = dp(0,0);
  printf("%lld\n",ans);


}
void test()
{
  int t;
  //scanf("%d",&t);
  t=1;
  for(int test=1;test<=t;test++)
  {
    //memset(memo,-1,sizeof memo);
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 82304
from fractions import gcd
def main():
    n = int(input())
    a = list(map(int, input().split()))
    left = [0]
    right = [0]
    for l in a[:-1]:
        g = gcd(left[-1], l)
        left.append(g)
    for r in a[n:0:-1]:
        g = gcd(right[-1], r)
        right.append(g)
    right.reverse()
    m = 0
    for i in range(n):
        m = max(m, gcd(left[i], right[i]))
    print(m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16700
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let s = readChars()
    let ok = Array.forall (fun c -> c = s.[0]) s
    if ok then "No" else "Yes"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;
mt19937_64 rng(58);
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    unordered_map<ll, int> right;

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        ll l = -a + i;
        ll r = -a + n - 1 - i;
        ans += right[a + n - 1 - i];
        right[r]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 23152
N = int(input())


# N以下の753数を全列挙
def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s + c)
  return ret
    
print(dfs('0'))


Measured memory_bytes: 2940
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] H = new int[N];
    int ans = 0;
    int count = 0;
    

    
    for(int i = 0;i < N;i++){
      H[i] = sc.nextInt();
    }
    
    int max = H[0];

    for(int i = 1;i < N;i++){
      for(int ii = 1;ii < i;ii++){
        
        max = Math.max(max,H[ii]);
      }
      if(max <= H[i]){
        count++;
      }
    }
    System.out.println(count+1);
	}
}

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

int n;
string s[10000];
string t;

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> s[i];
	cin >> t;
	
	int maxCnt = 0;		//Tの上にある語数の最大値
	int minCnt = n;		//Tの上にある語数の最小値
	
	for (i = 0; i < n; i++) {
		string s1, s2;	//s1…ありうる辞書順最小, s2…ありうる辞書順最大
		for (j = 0; j < s[i].length(); j++) {
			if (s[i][j] == '?') s1 += 'a';
			else s1 += s[i][j];
		}
		for (j = 0; j < s[i].length(); j++) {
			if (s[i][j] == '?') s2 += 'z';
			else s2 += s[i][j];
		}
		
		if (s1 <= t) {	//tの上に来る可能性があるか？
			maxCnt++;
		}
		if (s2 >= t) {	//tの下に来る可能性があるか？
			minCnt--;
		}
	}
	
	vector<int> ans;
	for (i = minCnt; i <= maxCnt; i++) {
		ans.push_back(i + 1);
	}
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i];
		if (i + 1 < ans.size()) cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 896
calc :: Int -> IO Int
calc init = do
    opStr <- getLine
    if opStr == "="
        then return init
        else do
            numStr <- getLine
            let n = read numStr :: Int
            let res = case opStr of
                           "+" -> init + n
                           "-" -> init - n
                           "*" -> init * n
                           "/" -> div init n
            calc res

main = do
    initStr <- getLine
    res <- calc (read initStr :: Int)
    print res



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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;

    int n, k;
    cin >> n >> k;

    vector<int> a;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;

        a.pb(x);
    }

    SORT(a);

    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += a[i];
    }
    cout << sum << endl;

    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 3e3 + 5, INF = 0x3f3f3f3f;
const int MOD = 998244353;

inline int add(int x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
	return x;
}

inline int sub(int x, int y) {
	x -= y;
	if (x < 0) x += MOD;
	return x;
}

inline int mul(int x, int y) {
	return ll(x) * y % MOD;
}

inline int inv(int x) {
	int y = MOD-2;
	int ret = 1;
	while(y) {
		if (y&1) ret = mul(ret, x);
		x = mul(x, x);
		y /= 2;
	}
	return ret;
}

inline int divi(int x, int y) {
	return mul(x, inv(y));
}

int n, k;
int a[MAXN];
int memo[MAXN][MAXN];
int pot;
int iv2;

int solve(int i, int sum) {
	if (sum < 0) return 0;
	if (i > n) return (!sum) * pot;
	int& ret = memo[i][sum];
	if (~ret) return ret;

	ret = solve(i+1, sum);
	ret = add(ret, mul(iv2, solve(i+1, sum - a[i])));
	return ret;
}


int main() {
	iv2 = inv(2);
	pot = 1;

	rd(n, k);
	for (int i = 1; i <= n; i++) {
		rd(a[i]);
		pot = mul(pot, 2);
	}

	memset(memo, -1, sizeof memo);
	printf("%d\n", solve(1, k));
}

Measured memory_bytes: 39232
# coding: utf-8
# Your code here!
L=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())


if A%C==0 and B%D==0:
    X=A//C
    Y=B//D
    X,Y=sorted([X,Y])
    print(L-Y)
elif A%C==0 and B%D!=0:
    X=A//C
    Y=(B//D)+1
    X,Y=sorted([X,Y])
    print(L-Y)
elif A%C!=0 and B%D==0:
    X=(A//C)+1
    Y=B//D
else:
    X=(A//C)+1
    Y=(B//D)+1
    X,Y=sorted([X,Y])
    print(int(L-Y))


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	
	while (1) {
		int n, m, p;
		int money = 0;
		int x[101] = {};

		cin >> n >> m >> p;
		if (n == 0 && m == 0 && p == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> x[i];
			money += x[i];
		}
		money *= (100 - p);
		if (x[m] == 0) {
			cout << 0 << endl;
		}
		else {
			cout << money / x[m] << endl;
		}
	}
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll a[4];
    rep(i,0,3){
        cin>>a[i];
    }
    if(a[0]!=a[2]){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  intervals <- forM [1..n] (\i -> do
    [a, b] <- map (read::String -> Int) . words <$> getLine
    return (a, b))
  print $ foldl (\acc (l, r) -> acc + r - l + 1) 0 intervals


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
using pii = pair<int,int>;
const int mx = 262144;

pii M[mx], S[mx];
int A[mx];
int n;

void dfs(int x){
    if(M[x].va) return;
    pii &m = M[x], &s = S[x];
    m = pii(A[x],x); s = pii(0,-1);
    if(!x) return;
    for(int i = 0; i < n; i++){
        if(x >> i & 1){
            int u = x ^ (1<<i);
            dfs(u);
            if(M[u].vb != M[x].vb && M[u].vb != S[x].vb){
                S[x] = max(S[x], M[u]);
                if(M[x] < S[x]) swap(M[x], S[x]);
            }
            if(S[u].vb != M[x].vb && S[u].vb != S[x].vb){
                S[x] = max(S[x], S[u]);
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    for(int i = 0; i < (1<<n); i++){
        cin >> A[i];
    }
    int msum = 0;
    for(int i = 1; i < (1<<n); i++){
        dfs(i);
        msum = max(msum, M[i].va + S[i].va);
        cout << msum << '\n';
    }
}


Measured memory_bytes: 8192
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
/*
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
*/

using namespace std;


int main()
{
    int n;
    cin >> n;
    int taro = 0, hanako = 0;
    
    for (int i = 0; i < n; i++)
    {
        string t, h;
        cin >> t >> h;
        if (t < h)
            hanako += 3;
        else if (t == h)
        {
            taro++;
            hanako++;
        }
        else
            taro += 3;
    }

    cout << taro << " " << hanako << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int x,y,z; cin >>x >> y >>z;
	cout <<(x-z)/(z+y)<<endl;
}


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

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::map<ll, ll> m0;
  std::map<ll, ll> m1;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    if (i % 2 == 0) m0[va[i]]++;
    else m1[va[i]]++;
  }


  
  std::vector< std::pair<ll, ll> > vp0;
  std::vector< std::pair<ll, ll> > vp1;
  for (auto p : m0) {
    vp0.push_back(std::make_pair(p.second, p.first));
  }
  for (auto p : m1) {
    vp1.push_back(std::make_pair(p.second, p.first));
  }
  std::sort(vp0.begin(), vp0.end(), std::greater<>());
  std::sort(vp1.begin(), vp1.end(), std::greater<>());

  ll ans = INF;
  if (vp0[0].second != vp1[0].second) {
    ans = N - vp0[0].first - vp1[0].first;
  } else {
    ll x0 = (vp0.size() == 1) ? 0 : vp0[1].first;
    ll x1 = (vp1.size() == 1) ? 0 : vp1[1].first;

    ll cnt1 = N - vp0[0].first - x1;
    ll cnt2 = N - x0           - vp1[0].first;
    ans = std::min(cnt1, cnt2);
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 9592
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t;
	rep(i, n) {
		cout << s.at(i) << t.at(i);
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int A, B, C;
    cin >> A >> B >> C;
    int endA = min(A, B+C);
    int trans = endA - B;
    cout << C-trans << endl;
 
    return 0;
}
 

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

int main(){

  int hen[3],n;
  cin>>n;
  while(n--){
  for(int i=0;i<3;i++)cin>>hen[i];
  sort(hen,hen+3);
  if(pow(hen[2],2)==(pow(hen[1],2)+pow(hen[0],2)))puts("YES");
  else puts("NO");
  }


  return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  vector<int> d(n);
  REP(i, n) cin >> d[i];
  sort(ALLr(d));
  int ans = 0, now = INF;
  REP(i, n){
    if(d[i] < now){
      now = d[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n, m, i;
  cin >> n >> m;

  int ans = 0;
  map<int, int> nos;

  while(m--){
    int s, c;
    cin >> s >> c;
    if((nos.find(s) != nos.end() && nos[s] != c) || (s == 1 && c == 0 && n != 1)){
        cout << -1 << endl;
        return 0;
    }
    nos[s] = c;
  }

  REP(i, 1, n + 1){
    if(i == 1){
        if(nos.find(i) == nos.end()){
            if(n == 1)
                ans = 0;
            else
                ans = 1;
        }
        else
            ans = nos[1];
    }
    else{
        if(nos.find(i) == nos.end())
            ans = ans * 10 + 0;
        else
            ans = ans * 10 + nos[i];
    }
  }

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


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

using ll = long long;
#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 INF 1e9


int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = INF;
  REP(i, max(X, Y) * 2+1){
    int a = max(0,X-i/2)*A, b = max(0,Y-i/2)*B;
    int cost = a + b + i * C;
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ev = ('01' * n)[:n]
od = ('10' * n)[:n]
ans = [0, 0]
for si, a, b in zip(s, ev, od):
    if si != a:
        ans[0] += 1
    elif si != b:
        ans[1] += 1
print(min(ans))


Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
signed main(){
  vector<int> c[10000];
  int a,b;
  int d,e,f;
  cin>>a>>b;
  for(int j=0;j<b;j++){
      cin>>d>>e;
      if(d==0){
	cin>>f;
	c[e].push_back(f);
      }
      if(d==1){
	for(int k=0;k<c[e].size();k++){
	  cout<<c[e][k];
	  if(k!=c[e].size()-1) cout<<" ";
	}
	cout<<"\n";
      }
      if(d==2) c[e].clear();
  }
}



Measured memory_bytes: 6084
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    r = 0
    if (a - 1) < (n - b):
        # aは卓1まで移動して1回勝利する
        r += a - 1 + 1
        # bはその間勝ち続ける
        b = b - r
        # あとは偶数のときと同じ
        print(((b - 1) // 2) + r)
    else:
        # bは卓nまで移動して1回負ける
        r += n - b + 1
        # aはその間勝ち続ける
        a = a + r
        # あとは偶数のときと同じ
        print(((n - a) // 2) + r)


Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;
using ll = long long;

int main() {
  ll N, A, t{}, ans{};
  cin >> N;
  map<ll, int> m;
  ++m[0];
  while (cin >> A) {
    t += A;
    ans += m[t]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
vector<array<ll,2>> adj[mxn];
bool vis[mxn];
ll ans=0,w,check;
ll dfs(int i, ll temp, int j){
    vis[i]=true;
    ll sum=0;
    for(auto x : adj[i]){
        if(!vis[x[0]]){
            if(temp+x[0]>=check*j){
                while(x[1]>=check){
                    ans++;
                    x[1]=x[1]/2;
                }
            }
            ll k=dfs(x[0],temp+x[1],j+1);
            sum=sum+k-x[1];
            if(k>=check*j){
               while(x[1]>=check){
                    ans++;
                    x[1]=x[1]/2;
                }
            }
            sum=sum+x[1];
        }
    }
    return sum;
}
int main(){
    int n;
    cin>>n;
    vector<int> vec,a,b;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.push_back(x);
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        b.push_back(x);
        vec.push_back(i+1);
    }
    int cnt=1;
    int x,y;
    x=y=0;
    while(next_permutation(vec.begin(),vec.end())){
        if(a==vec){
            x=cnt;
        }
        if(b==vec){
            y=cnt;
        }
        cnt++;
    }
    cout<<abs(x-y);
}



Measured memory_bytes: 15288
#include <cstdio>
#include <string>
#include <stack>

using namespace std;

int main() {
    char buf[1<<18];
    scanf("%s", buf);
    string X(buf);

    stack<char> s;
    for (char c: X) {
        if (c == 'S') {
            s.push(c);
        } else if (c == 'T') {
            if (!s.empty() && s.top()=='S') {
                s.pop();
            } else {
                s.push(c);
            }
        }
    }

    printf("%llu\n", s.size());
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main()
{
    int a, b, c, N, i;
    scanf("%d", &N);
    
    for(i = 0; i < N; i++)
    {
        scanf("%d %d %d", &a, &b, &c);
        if (a*a + b*b == c*c || c*c + b*b == a*a || a*a + c*c == b*b)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
            
    }
    return 0;
}



Measured memory_bytes: 2504
# include <stdio.h>

int main(){
  int n, k;
  int ans = 0;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++){
    int pos_x;
    scanf("%d", &pos_x);
    ans += (pos_x*2 < k)*2*pos_x + (pos_x*2 >= k)*2*(k-pos_x);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
    var s = input[0]-0;
    var list = input[1].split(" ").map(v=>v-0);
    var map = {};
    list.forEach(v=>{
        map[v] = map[v]?map[v]+1:1;
    });
    for(var i=1;i<=s;i++){
        console.log(map[i]||0);
    }
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 63328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A =sc.nextLong();
		long B =sc.nextLong();
		long K =sc.nextLong();
		
		long result1=Math.max(0,A-K);
		long result2=Math.max(0,Math.min(A+B-K,B));
		System.out.println(result1+" "+result2);
		
		
	}
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool cmp(pii x , pii y){
	return x.ff+x.ss>y.ff+y.ss;
}

bool cc(pii x , pii y){
	return x.ff-x.ss>y.ff-y.ss;
}

int32_t main() {
	aryan_pandeya();
	FIO;
 
	int n ;
	cin>>n ;
	pii a[n];
	for(int i = 0 ; i<n ; i++){
		cin>>a[i].ff>>a[i].ss;
	}
	sort(a,a+n,cmp);
	int op1 = abs(a[n-1].ff-a[0].ff)+abs(a[n-1].ss-a[0].ss);
	sort(a,a+n,cc);
	int op2 = abs(a[n-1].ff-a[0].ff)+abs(a[n-1].ss-a[0].ss);
	int ans = max(op1,op2);
	cout<<ans;

	return 0;
}


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

dp = [[0] * 3 for _ in range(n)]

for i in range(n):
    a,b,c = map(int,input().split())
    if i == 0:
        dp[0][0] = a
        dp[0][1] = b
        dp[0][2] = c
    else:
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c

print(max(dp[-1])) 


Measured memory_bytes: 60140
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n,k,l;
map<P,int> mp;

struct UnionFind {
	vector<int> data;
	UnionFind(int size):data(size,-1){}
	bool unite(int x,int y) {
		x=root(x),y=root(y);
		if(x!=y) {
			if(data[y]<data[x]) swap(x,y);
			data[x]+=data[y],data[y]=x;
		}
		return x!=y;
	}
	bool same(int x,int y) {
		return root(x)==root(y);
	}
	int root(int x) {
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

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

	cin>>n>>k>>l;
	UnionFind road(n);
	REP(i,k) {
		int a,b; cin>>a>>b;
		a--,b--;
		road.unite(a,b);
	}
	UnionFind train(n);
	REP(i,l) {
		int a,b; cin>>a>>b;
		a--,b--;
		train.unite(a,b);
	}
	REP(i,n) {
		mp[P(road.root(i),train.root(i))]++;
	}
	REP(i,n) {
		cout<<mp[P(road.root(i),train.root(i))]<<' ';
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 13568
a,b,k = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ali = set(make_divisors(a))
bli = set(make_divisors(b))
li = sorted(list(ali & bli))
print(li[-k])

Measured memory_bytes: 3188
#include<stdio.h>
#define n 5
int main()
{
    int a[n],i,ans;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==0)
            ans = i+1;
    }

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

    return 0;
}


Measured memory_bytes: 1720
di = {}
di["AC"] = 0
di["WA"] = 0
di["TLE"] = 0
di["RE"] = 0
n = int(input())
for i in range(n):
    di[input()] += 1
print("AC x",di["AC"])
print("WA x",di["WA"])
print("TLE x",di["TLE"])
print("RE x",di["RE"])

Measured memory_bytes: 74724
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//#define max(a,b) max((ll)a,(ll)b)
//#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  if(m == 0) return n;
  if(n == 0) return m;
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};


/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////



//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(2);
  
  lin(N);

  while(N > 0){
    N -= 1000;
  }
  cout << -N << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int D, N; cin >> D >> N;
  if(D==0){
    if(N==100){ 
      cout << 101 << endl;
      return 0;
    }
    else cout << N << endl;
    return 0;
  }
  if(D==1){
    if(N==100){
      cout << 10100 << endl;
      return 0;
    }
    else cout << N*100 << endl;
    return 0;
  }
  if(D==2){
    if(N==100){
      cout << 1010000 << endl;
      return 0;
    }
    else cout << N*10000 << endl;
    return 0;
  }
}

Measured memory_bytes: 256