akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAXN 200005 
#define getD(p) (p->d + p->tag)
#define INF (1e15)
#define LL long long
using namespace std;

int N,Q,A,B;
int x[MAXN];

//segment Tree
struct Node{
    int l,r;
    LL d, tag;
    Node *ls, *rs;
    
    void update(){
    	d = min(getD(ls), getD(rs));
	}
	
	void pushD(){
		if(!tag) return;
	    d = getD(this);
	    ls->tag += tag;
	    rs->tag += tag;
	    tag = 0;
	}
} pool[6*MAXN], *rt0, *rt1;

int top = 0;

Node* buildT(int l, int r){
    Node *p = pool + (++top);
    p->l = l; p->r = r;
    
    if(l==r){
    	p->d = INF;
    	return p;
	}
    
    int mid = (l+r)/2;
    p->ls = buildT(l, mid);
    p->rs = buildT(mid+1, r);
    
    p->update();
    return p;
}


void change(Node* p, int l, int r, int k){
    //cout<<"change: "<<p->l<<" "<<p->r<<" "<<l<<" "<<r<<endl;
    if(p->l==l && p->r==r){
        p->tag += k;
        return;
    }
    p->pushD();
    
    int mid = (p->l + p->r)/2;
    if(r <= mid) change(p->ls, l, r, k);
    else if(l>=mid+1) change(p->rs, l, r, k);
    else{
        change(p->ls, l, mid, k);
        change(p->rs, mid+1, r, k);
    }
    p->update();
    return;
}

void update(Node* p, int id, LL v){
	if(p->l==id && p->r==id){
        p->d = v;
        p->tag = 0;
        return;
    }
    p->pushD();
    
    int mid = (p->l + p->r)/2;
    if(id <= mid) update(p->ls, id, v);
    else update(p->rs, id, v);

    p->update();
    return;
}

LL query(Node* p, int l, int r){
    //cout<<"query: "<<p->l<<" "<<p->r<<" "<<l<<" "<<r<<endl;
    if(p->l==l && p->r==r){
        return getD(p);
    }
    p->pushD();
    
    int mid = (p->l + p->r)/2;
    if(r <= mid) return query(p->ls, l, r);
    else if(l>=mid+1) return query(p->rs, l, r);
    else{
        LL ans = INF;
        ans = min(ans, query(p->ls, l, mid));
        ans = min(ans, query(p->rs, mid+1, r));
        return ans;
    }
}
//segment Tree End

void debug(){
	cout<<"debug----------"<<endl;
	for(int j=1;j<=N;j++){
		cout<<query(rt0, j, j) + j<<" ";
	}
	cout<<endl;
}

int main(){
	
	cin>>N>>Q>>A>>B;
	for(int i=1;i<=Q;i++){
		cin>>x[i];
	}
	
	rt0 = buildT(1,N);
	rt1 = buildT(1,N);
	

	update(rt0, A, abs(B-x[1])-A); update(rt0, B, abs(A-x[1])-B);
	update(rt1, A, abs(B-x[1])+A); update(rt1, B, abs(A-x[1])+B);
	
	LL v0, v1;
	
	for(int i=2;i<=Q;i++){
		//debug();
		v0 = query(rt0, 1, x[i]) + x[i];
		v1 = query(rt1, x[i], N) - x[i];
		//cout<<"i = "<<i<<" "<<v0<<" "<<v1<<endl;
		
		change(rt0, 1, N, abs(x[i]-x[i-1]));
		change(rt1, 1, N, abs(x[i]-x[i-1]));
		
		update(rt0, x[i-1], min(v0, v1) - x[i-1]);
		update(rt1, x[i-1], min(v0, v1) + x[i-1]);
	}
	//debug();
	LL ans = 1e18;
	for(int j=1;j<=N;j++){
		ans = min(ans, query(rt0, j, j) + j);
		//ans = min(ans, query(rt1, j, j) - j);
	}

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


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;

    vector<vector<ll>> dp(3, vector<ll>(N, 0));
    REP(i,0,K) {
        if(T[i] == 's') dp[0][i] = R;
        else if(T[i] == 'p') dp[1][i] = S;
        else if(T[i] == 'r') dp[2][i] = P; 
    }

    REP(i,K,N) {
        REP(j,0,3) {
            REP(k,0,3) {
                if(j == k) continue;
                if(T[i] == 's' && k == 0)
                    dp[k][i] = MAX(dp[k][i],dp[j][i-K]+R);
                else if(T[i] == 'p' && k == 1)
                    dp[k][i] = MAX(dp[k][i],dp[j][i-K]+S);
                else if(T[i] == 'r' && k == 2)
                    dp[k][i] = MAX(dp[k][i],dp[j][i-K]+P);
                dp[k][i] = MAX(dp[k][i],dp[j][i-K]);
            }
        }
    }

    ll res = 0;
    REP(i,N-K,N) res += MAX(MAX(dp[0][i],dp[1][i]),dp[2][i]);
    _PR(res);

    return 0;
}

/*

*/

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(20, vector<int>(20, -1));//(i, j)にiさんのjさんに対する証言を記録
  rep(i, n) {
    int A;
    cin >> A;//iさんの証言の数
    rep(j, A) {
      int x, y;
      cin >> x >> y;//「xさんはyだ」という証言
      x--;
      a[i][x] = y;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    
    vector<int> d(n);//正直者には1をいれる
    rep(j, n) {
      if (i >> j & 1) {//もしjさんが正直者だったら
        d[j] = 1;
      }
    }
    
    
    bool flag = true;
    rep(j, n) {
      
      if (!d[j]) {//jさんは不親切だからなにを証言しててもいい
        continue;
      } else {//jさんは正直者。本当にそうかjさんの証言a[j][]を確かめる。
        for (int k = 0; k < a[j].size(); k++) {
          if (a[j][k] == -1) continue;//証言なし
          if (a[j][k] != d[k]) flag = false;//証言と不一致
        }
      }
      
    }
    
    if (flag) {//iをビット列にしたとき1だったひとは全員正直だった
      bitset<20> b(i);
      int B = b.count();
      ans = max(ans, B);
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	M1, D1 = getlist()
	M2, D2 = getlist()
	if M1 == M2:
		print(0)
	else:
		print(1)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string  s;
    cin >> s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        cout << 3 << endl;
    else if(s[0]=='R' && s[1]=='R' && s[2]=='S')
        cout << 2 << endl;
    else if(s[0]=='R' && s[1]=='S' && s[2]=='R')
        cout << 1 << endl;
    else if(s[0]=='S' && s[1]=='R' && s[2]=='R')
        cout << 2 << endl;
    else if(s[0]=='S' && s[1]=='R' && s[2]=='S')
        cout << 1 << endl;
    else if(s[0]=='S' && s[1]=='S' && s[2]=='R')
        cout << 1 << endl;
    else if(s[0]=='R' && s[1]=='S' && s[2]=='S')
        cout << 1 << endl;
    else 
        cout << 0 << endl;






    return 0;
}

Measured memory_bytes: 3620
A, B, C, X = [int(input()) for _ in range(4)]
ans = 0
for a in range(A+1):
  if a * 500 > X:
    break
  for b in range(B+1):
    if a * 500+b * 100 > X:
      break
    for c in range(C+1):
      if a*500+b*100+c*50 == X:
        ans += 1
      elif a*500+b*100+c*50 > X:
        break
print(ans)



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

int main(){
  string str;
  cin >> str;
  char a, b = ' ';
  int acount = 0;
  int bcount = 0;
  a = str[0];
  for(int i=1; i<4; i++){
    if(str[i] == a){
      acount++;
    }else if(b == ' '){
      b = str[i];
    }else if(str[i] == b){
      bcount++;
    }else{
      cout << "No" << endl;
      return 0;
    }
    if(acount > 2 || bcount > 2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

struct UnionFind {
    vector<int> p;
    UnionFind(int n) : p(n, -1) {};
    int root (int a) {
        if (p[a] < 0) return a;
        return p[a] = root(p[a]);
    }
    bool unite(int a, int b) {
        int roota = root(a);
        int rootb = root(b);
        if (roota == rootb) return false;
        //cout << size(roota) << " " << size(rootb) << endl;
        if (p[roota] > p[rootb]) {
            swap(roota, rootb);
        }
        p[roota] += p[rootb];
        p[rootb] = roota;
        return true;
    }
    bool same(int a, int b) {
        return root(a) == root(b);
    }
    int size (int a) {
        return -p[root(a)];
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uni(n);
    vector<int> connect_dim1_num(n, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++connect_dim1_num[a];
        ++connect_dim1_num[b];
        uni.unite(a, b);
    }
    vector<int> block_num(n);
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        if (uni.root(c) == uni.root(d)) {
            ++block_num[c];
            ++block_num[d];
        }
    }
    rep(i, n) {
        if (i != 0) cout << " ";
        cout << uni.size(i) - 1 - connect_dim1_num[i] - block_num[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4240
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct Tree {
	int N, diameter;
	vector<vector<pair<int, int> > > E;
	vector<int> d; // ある点からの距離, -1なら未探索を表す
	Tree(int n) :N(n), E(n), d(n) {};

	// 辺を追加する //
	void addPoint(int a, int b, int c) {
		E[a].push_back(make_pair(b, c));
		E[b].push_back(make_pair(a, c));
	}

	// 任意の節を始点として、幅優先で各節の距離を計算する(BFS) //
	void bfsDistance(int s) {
		queue<int> q;
		for (int i = 0; i < N; i++) d[i] = -1; // 距離計算用の初期化
		d[s] = 0;
		q.push(s);
		while (!q.empty()) {
			int cur = q.front(); q.pop();
			for (unsigned int i = 0; i < E[cur].size(); i++) {
				int next = E[cur][i].first;
				if (d[next] != -1) continue; // 探索済みはスキップ(BFS探索における親)
				d[next] = d[cur] + E[cur][i].second;
				q.push(next);
			}
		}
	}

	// 木の直径を求め、表示する //
	void solveDiameter() {
		int maxv, point;
		// ある節からの最大距離となる節を求める(直径の片側の節)
		bfsDistance(0);
		maxv = point = 0;
		for (int i = 0; i < N; i++) {
			if (maxv < d[i]) {
				maxv = d[i];
				point = i;
			}
		}

		// 直径の片側から最大の距離を求め、直径となる2つの節を決定する
		bfsDistance(point);
		maxv = 0;
		for (int i = 0; i < N; i++) {
			if (maxv < d[i]) maxv = d[i];
		}
		cout << maxv << endl;
	}
};

int main() {
	int n;
	cin >> n;
	Tree T(n);
	for (int i = 0; i < (n - 1); i++) {
		int s, t, w;
		cin >> s >> t >> w;
		T.addPoint(s, t, w);
	}

	T.solveDiameter();

	return 0;
}


Measured memory_bytes: 9796
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false);cerr << "compiled" << endl

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int A, B, M, a[100000], b[100000]; cin >> A >> B >> M;
  int amin = VERYBIG, bmin = VERYBIG;
  REP(i, A){
    cin >> a[i]; chmin(amin, a[i]);
  }
  REP(i, B) {
    cin >> b[i]; chmin(bmin, b[i]);
  }
  int ans = amin + bmin;
  REP(i, M){
    int x, y, c; cin >> x >> y >> c; x--; y--;
    chmin(ans, a[x]+b[y]-c);
  }
  cout << ans << endl;
}

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

int solve(int E){
    int ans = 1000000;
    int x;
    for (int y = 0; y*y <= E; ++y){
        for (int z = 0; z*z*z <= E; ++z){
            x = E - y*y - z*z*z;
            if (x >= 0)
                ans = min(ans, x+y+z);
        }
    }
    return ans;
}
    

int main(){
    int E;
    while (cin >> E && E>0) {
        cout << solve(E) << endl;
    }
}

Measured memory_bytes: 2996
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define N 100010
#define ll long long
#define pa(a, b) (data){a, b}
using namespace std;

struct data{ll x; int id;}t;
struct aa{ll a, b;}a[N];
int X, Y, Z, n, xx;
ll ans, x1, x2, x, y, z;

inline bool operator>(data a, data b){
	if(a.x!=b.x)return a.x>b.x;
	return a.id>b.id; //注意！！！
}
struct heap{
	priority_queue<data, vector<data>, greater<data> >a, b;
	void clear(){while(!a.empty())a.pop(); while(!b.empty())b.pop();}
	void ins(data x){a.push(x);}
	void del(data x){b.push(x);}
	int size(){return a.size()-b.size();}
	data top(){
		while(!b.empty()&&a.top().id==b.top().id){a.pop(); b.pop();}
		return a.top();
	}
}A, B, C;

inline bool cmp(aa a, aa b){return a.a>b.a;}

int main(){
	scanf("%d%d%d", &X, &Y, &Z); n=X+Y+Z;
	ans=0;
	for(int i=1; i<=n; i++){
		scanf("%lld%lld%lld", &x, &y, &z);
		ans+=x; a[i].a=y-x; a[i].b=z-y;
	}
	sort(a+1, a+1+n, cmp);
	A.clear(); B.clear(); C.clear();
	for(int i=1; i<=Y+Z; i++){ans+=a[i].a; C.ins(pa(a[i].a, i));}
	for(int i=1; i<=Y+Z; i++){
		if(A.size()<Z){ans+=a[i].b; A.ins(pa(a[i].b, i)); B.ins(pa(a[i].a+a[i].b, i)); C.del(pa(a[i].a, i));}
		else{
			t=A.top(); x=t.id;
			if(t.x<a[i].b){
				ans+=a[i].b-t.x;
				C.ins(pa(a[x].a, x)); A.del(pa(a[x].b, x)); B.del(pa(a[x].a+a[x].b, x));
				A.ins(pa(a[i].b, i)); B.ins(pa(a[i].a+a[i].b, i)); C.del(pa(a[i].a, i));
			}
		}
	}
	for(int i=Y+Z+1; i<=n; i++){
		y=a[i].a+a[i].b;
		x1=A.top().x+C.top().x; x2=B.top().x;
		if(x1<=x2){
			if(x1<=y){
				ans+=y-x1; x=A.top().id; xx=C.top().id;
				C.del(pa(a[xx].a, xx));
				C.ins(pa(a[x].a, x)); A.del(pa(a[x].b, x)); B.del(pa(a[x].a+a[x].b, x));
				A.ins(pa(a[i].b, i)); B.ins(pa(a[i].a+a[i].b, i));
			}
		}else{
			if(x2<=y){
				ans+=y-x2; x=B.top().id;
				A.del(pa(a[x].b, x)); B.del(pa(a[x].a+a[x].b, x));
				A.ins(pa(a[i].b, i)); B.ins(pa(a[i].a+a[i].b, i));
			}
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 13164
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
int main()
{
	char s[100];
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 0; i < n - 8; i++)
		printf("%c", s[i]);
	puts("");
	//system("pause");
}

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

table = []
for i in range(n):
  city, score = input().split()
  score = int(score)

  table.append([i+1, city, score])

sorted_table = sorted(table, key=lambda x:(x[1], -x[2]))

for i in range(n):
  print(sorted_table[i][0])


Measured memory_bytes: 3060
# https://atcoder.jp/contests/arc093/tasks/arc093_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

N = a_int()
A = [0] + ints() + [0]
d_nx = [abs(x - y) for x, y in zip(A, A[1:])]  # 一つとなりへ移動するための距離
# d_nx[i]はA[i]→A[i+1]までの距離
d_nnx = [abs(x - y) for x, y in zip(A, A[2:])]  # 2つ隣に移動するための距離
# d_nnx[i] はA[i]→A[i+2]までの距離
total = sum(d_nx)
ans = []
for i in range(N):
    ans.append(total - (d_nx[i] + d_nx[i + 1]) + d_nnx[i])
print(*ans, sep='\n')


Measured memory_bytes: 106788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
set <int> g[N];
vector <pair <int,int> > M;
bool used[N];
int n, m;

void dfs(int v) {
    used[v] = 1;
    for(int f : g[v])
        if(!used[f])
            dfs(f);
}
bool check() {
    bool cnt = 1;
    for(int i = 1; i <= n; ++i)
        cnt &= used[i];
    return cnt;
}
void solve(){
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        int a, b;
        cin >> a >> b;
        M.pb({a, b});
        g[a].ins(b);
        g[b].ins(a);
    }
    int ans = 0;

    for(auto cur : M){
        for(int i = 1; i <= n; ++i)
            used[i] = 0;
        g[cur.X].erase(cur.Y);
        g[cur.Y].erase(cur.X);
        dfs(1);
        ans += check();
        g[cur.X].ins(cur.Y);
        g[cur.Y].ins(cur.X);
    }
    cout << m - ans;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 13008
import copy
n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
pt=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[0]*m
for i in xrange(m):
    tmp=copy.deepcopy(t)
    tmp[pt[i][0]-1]=pt[i][1]
    for j in xrange(n):
        ans[i]+=tmp[j]
for i in xrange(m):
    print(ans[i])

Measured memory_bytes: 2692
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  int a[n+1]={0};
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  int ans = 1e18;
  for(int i=0;i<=101;i++){
    int cur = 0;
    for(int j=1;j<=n;j++){
      cur+=(i-a[j])*(i-a[j]);
    }
    ans = min(ans,cur);
  }
  cout << ans << endl;
  


return 0;
}
///....


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] price_list = new int[n];
		for(int i = 0; i < n; i++) {
			price_list[i] = sc.nextInt();
		}
		System.out.println(getMaxProfit(price_list));
		sc.close();
	}

	public static int getMaxProfit(int[] p) {
		int minv = p[0];
		int maxv = p[1] - p[0];
		for(int j = 1; j < p.length; j++) {
			if(maxv < p[j] - minv) {
				maxv = p[j] - minv;
			}
			if(minv > p[j]) {
				minv = p[j];
			}
		}
		return maxv;
	}
}


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

#define max 305

double p[max][max][max];
double ev[max][max][max];

int main() {

	#ifdef tajir
		freopen("input.txt","r",stdin);
	#else
		//Online Judge
	#endif

	int n;
	
	cin >> n;

	int cnt[4] = { 0 };

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

		cnt[x]++;
	}

	p[cnt[1]][cnt[2]][cnt[3]] = 1;

	for(int c = n; c >= 0; --c) {
		for(int b = n; b >= 0; --b) {
			for(int a = n; a >= 0; --a) {
				if(a+b+c > n)	continue;

				int m = a+b+c;

				if(m == 0)	continue;

				double p_waste = (double)(n - m) / n;

				// S = p_waste + p_waste^2 + p_waste^3 + ...
				double ev_waste = p_waste / (1.0 - p_waste) + 1;	// S = r / (1-r)

				ev[a][b][c] += ev_waste * p[a][b][c];

				if(a >= 1) {
					double p_go = (double) a / (double) m;
					p[a-1][b][c] += p[a][b][c] * p_go;
					ev[a-1][b][c] += ev[a][b][c] * p_go;
				}
				if(b >= 1) {
					double p_go = (double) b / (double) m;
					p[a+1][b-1][c] += p[a][b][c] * p_go;
					ev[a+1][b-1][c] += ev[a][b][c] * p_go;
				}
				
				if(c >= 1) {
					double p_go = (double) c / (double) m;
					p[a][b+1][c-1] += p[a][b][c] * p_go;
					ev[a][b+1][c-1] += ev[a][b][c] * p_go;
				}
			}
		}
	}

	cout << fixed << setprecision(10) << ev[0][0][0] << endl;

	return 0;
}


Measured memory_bytes: 438528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    int n;
    cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]=1;
    }
    cout<<m.size()<<endl;
}

Measured memory_bytes: 19204
{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1136&lang=jp
?????????: Polygonal_Line_Search
-}
import Data.Complex
import Control.Applicative
import Control.Monad

data Zigzag = Zigzag [Complex Double] -- ????????????????????????

instance Eq Zigzag where
 a == b
  | foo a b = True
  | foo((zigzag . reverse . fromZigzag)a)  b = True
  | otherwise = False

foo a b = fromZigzag (normalize a) == fromZigzag(normalize b)

instance Show Zigzag where
 show a = "zigzag " ++ show (fromZigzag a)

zigzag :: [Complex Double] -> Zigzag
zigzag [] = undefined
zigzag (a:xs) = Zigzag $ map (subtract a) xs

normalize :: Zigzag -> Zigzag
normalize (Zigzag b) = Zigzag $ map (/signum(head b)) b

fromZigzag :: Zigzag -> [Complex Double]
fromZigzag (Zigzag a) = 0:a

main = do
 n <- read <$> getLine
 unless (n==0) $ do
  zigzags <- replicateM (n+1) getZigzag
  let ans = tail{-0?????????-}. map fst . filter ((==head zigzags) . snd) $ zip [0..] zigzags --index?????£??????zigzag????????????????????????filter
  mapM_ print ans
  putStrLn "+++++"
  main

getZigzag :: IO Zigzag
getZigzag = do
 m <- read <$> getLine
 zigzag <$> replicateM m (fmap lire getLine)


lire :: String -> Complex Double
lire str = let[a,b] = map read $ words str in a:+b

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int x, k, d; cin >> x >> k >> d;
    __int128_t X = x, K = k, D = d;
    if(X + K * D <= 0) Out(-(x + k * d));
    else if(X - K * D >= 0) Out(x - k * d);
    else{
        __int128_t MM = X + K * D;
        __int128_t n = MM / (2 * D);
        __int128_t ans = min(llabs(MM - 2 * D * n), llabs(MM - 2 * D * (n + 1)));
        Out((int)ans);
    }

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n, a[3000];
ll dp[3001][3001];
ll rec(int l, int r){
	if(l == r) return 0;
	ll &res = dp[l][r];
	if(res > -1e18) return res;
	
	res = max(res, a[l] - rec(l + 1, r));
	res = max(res, a[r - 1] - rec(l, r - 1));
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n + 1) rep(j, n + 1) dp[i][j] = -1e18;
	cout << rec(0, n) << endl;
	
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


const int N = 1e5+2;
int mpe[N]={},mpo[N]={};

bool cmp1(int a,int b)
{
    return (mpe[a]>mpe[b]);
}
bool cmp2(int a,int b)
{
    return (mpo[a]>mpo[b]);
}
int main(int argv, char* argc[])
{
    FASTIO

    int n,ans;
    cin>>n;
    vii v(n);
    rep(i,n)
    cin>>v[i];

    vii e,o;
    e.pb(0),o.pb(0);


    for(int i=0;i<n;++i)
    {
        if(even(i))
        {
            if(mpe[v[i]]==0)
                e.pb(v[i]);
            ++mpe[v[i]];
        }
        else
        {
            if(mpo[v[i]]==0)
                o.pb(v[i]);
            ++mpo[v[i]];
        }
    }

    sort(all(e),cmp1);
    sort(all(o),cmp2);

    if(e[0]!=o[0])
    {
        ans = n - mpe[e[0]] - mpo[o[0]];
    }
    else
    {
        ans = n - max(mpe[e[0]]+mpo[o[1]],mpe[e[1]]+mpo[o[0]]);
    }
    cout<<ans<<"\n";


    return 0;
}



Measured memory_bytes: 2044
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
flag = False
if c > d:
    s[b - 1] = "#"
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = True
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b - 1, d + 1):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = False
        else:
            count = 0
else:
    for i in range(b, d):
        if last == "#" and s[i] == "#":
            flag = True
        last = s[i]
if not flag:
    print("Yes")
else:
    print("No")


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

using namespace std;

int bubbleSort(int a[], int n) {
    bool flag = true;
    int ans = 0;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; j--) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                flag = 1;
                ans++;
            }
        }
    }
    return ans;
}

int main() {
    int n, ans;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    ans = bubbleSort(a, n);
    for (int i = 0; i < n; i++) {
        if (i)
            printf(" %d", a[i]);
        else
            printf("%d", a[i]);
    }
    printf("\n%d\n", ans);
}


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

typedef long long ll;

const int inf = 1000000;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll>p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    ll total = 0;
    for (int i = 0; i < K; i++) {
        total += p[i];
    }
    cout << total << endl;
}


Measured memory_bytes: 3632
#include<iostream>
int main() {
	using namespace std;
	int len1, len2;
	cin >> len1;
	int* arr1 = new int[len1];
	for (int i = 0; i < len1; i++)
		cin >> arr1[i];
	cin >> len2;
	int* arr2 = new int[len2];
	for (int i = 0; i < len2; i++)
		cin >> arr2[i];
	int cnt = 0;
	for (int i = 0; i < len2; i++) {
		int l = 0;
		int r = len1-1;
		int m = (l + r) / 2;
		while (l < r) {
			if (arr1[m] == arr2[i]) {
				cnt++;
				break;
			}
			else if (arr1[m] < arr2[i]) {
				l = m+1;
				m = (l + r) / 2;
			}
			else {
				r = m - 1;
				m = (l + r) / 2;
			}
		}
		if (arr1[l] == arr1[r] && arr1[l] == arr2[i]&&l==r)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int[] d = new int[N];
		int sum=0;
		
		for(int i=0;i<d.length;i++) {
			d[i]=sc.nextInt();
		}
		
		for(int i=0;i<(d.length-1);i++) {
			for(int j=i+1;j<d.length;j++) {
				sum+=d[i]*d[j];
			}
		}
		
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 22608
import sys


def input():
    return sys.stdin.readline()[:-1]


n, m, p = map(int, input().split())
edge0 = []
d = [[] for i in range(n)]
r = [[] for i in range(n)]
for i in range(m):
    ai, bi, ci = map(int, input().split())
    edge0.append((bi-1,ai-1,-ci+p))
    d[ai-1] += [bi-1]
    r[bi-1] += [ai-1]

p0 = [False for i in range(n)]
p0[0] = True
from collections import deque
q = deque([0])
while len(q)>0:
    x = q.popleft()
    for y in d[x]:
        if not p0[y]:
            p0[y] = True
            q.append(y)
pn = [False for i in range(n)]
pn[n-1] = True
q = deque([n-1])
while len(q) > 0:
    x = q.popleft()
    for y in r[x]:
        if not pn[y] and p0[y]:
            pn[y] = True
            q.append(y)

edge = []
for e in edge0:
    if pn[e[1]] and pn[e[0]]:
        edge += [e]


dist = [float("inf") for i in range(n)]
dist[n-1] = 0
h = False
for i in range(n):
    updated = False
    for e in edge:
        if dist[e[1]] > dist[e[0]] + e[2] and p0[e[1]] and p0[e[0]]:
            dist[e[1]] = dist[e[0]] + e[2]
            updated = True
    if not updated:
        break
else:
    h = True

if h:
    print(-1)
else:
    print(max(0, -dist[0]))


Measured memory_bytes: 49136
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, M, K;
int pows [200000]; // of M-1
int fct [200000];

int modexp(int a, int e) {
    int ans = 1;
    int cur = a;
    while (e) {
        if (e&1) {ans = mul(ans, cur); e--;}
        e /= 2;
        cur = mul(cur,cur);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M >> K;
    pows[0] = 1;
    FOR(i, 1, N) pows[i] = mul(pows[i-1], M-1);
    fct[0] = 1;
    FOR(i, 1, N) fct[i] = mul(fct[i-1], i);

    int ans = 0;
    F0R(i,K+1) {
        ans = add(ans, mul(mul(fct[N-1], modexp(mul(fct[i], fct[N-1-i]), MOD-2)) ,mul(M, pows[N-i-1])));
    }

    cout << ans << '\n';
    // cout << modexp(3,4) << '\n';
}

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

int main() {
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int n; // <= 100
    cin >> n;

    vector<int> x(n), y(n);
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    int index = -1;
    // hが1以上の点を1点もとめる
    for (int i = 0; i < n; i++) {
        if(h[i] > 0) {
            index = i;
            break;
        }
    }

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            bool isTop = true;
            // 代表点と比較して中央の高さを決定
            int ch;
            if (index != -1) {
                ch = h[index] + abs(cx-x[index]) + abs(cy-y[index]);
            } else {
                ch = 1;
            }
            for (int i = 0; i < n; i++) {
                if (h[i] != max(ch - abs(cx-x[i]) - abs(cy-y[i]), 0)) {
                    isTop = false;
                    break;
                }
            }

            if(isTop) {
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> K;
	if (N>=K+K-1)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a = input()
    d = 0
    for a_i in a:
        d += int(a_i)
    if int(a) % d == 0:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    main()


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct edge{int to; ll cost;};

int main()
{
  string s; cin >> s;
  string t = "AKIHABARA";
  set<string> st;

  for(int bit = 0; bit < 1<<9; ++bit) {
    string res = "";
    rep(i, 9) {
      if(bit & 1<<i && t[i] == 'A') continue;
      res += t[i];
    }
    st.insert(res);
  }
  if(st.find(s) != st.end()) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
 
int main() {
int d; cin>>d;
if(d==24){
cout << "Christmas Eve" << endl;}
else if(d==23){
cout << "Christmas Eve Eve" << endl;}
else if ( d == 22){
cout << "Christmas Eve Eve Eve" << endl;}
else{
cout << "Christmas" << endl;}}

Measured memory_bytes: 3624
/*
 * atcoder/abc115_3rd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * L0     p   p       p   p
 * L1   b   p   b   b   p   b
 * L2 b           p           b
 */
int N; ll X;
ll rec(int n, ll x) {
  if (n==0) return 1;
  if (x<=1) return 0;
  ll all = (1LL<<(n+1)) - 3; // １つ低レベルの全パーツ数
  ll p   = (1LL<<n) - 1;     //               p数

  if (x <= all + 1) return rec(n-1, x-1);
  if (x == all + 2) return 1 + p;
  if (x <= 2 * all + 2) return 1 + p + rec(n-1, x - all - 2);
  return 1 + 2 * p;
}

void solve() {
  cin >> N >> X;
  cout << rec(N, X) << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int search(int *array, int n, int x) {
    for(int i = 0; i < n; i++) {
        if(array[i] == x) {
            return i;
        }
    }
    return -1;
}

int main(void) {
    int n;
    scanf("%d", &n);

    int *s = malloc(n * sizeof(int));
    if(s == NULL) {
        return 1;
    }

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

    int q;
    scanf("%d", &q);

    int *t = malloc(q * sizeof(int));
    if(t == NULL) {
        return 1;
    }

    for(int i = 0; i < q; i++) {
        scanf("%d", &t[i]);
    }

    int cnt = 0;
    for(int i = 0; i < q; i++) {
        if(search(s, n, t[i]) != -1) {
            cnt++;
        }
    }

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

    free(s);
    free(t);
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  if(Y/N-X/N>=1){
    cout << "OK";
  }
  else if(N==1){
    cout << "OK";
  }
  else if(X%N==0||Y%N==0){
    cout << "OK";
  }
  else{
    cout << "NG";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3636
N = gets.to_i
hen = gets.split(' ').map(&:to_i)
hen.sort!
 
triangle_total = 0
a = 0
 
while a < N - 2 do
    b = a + 1
 
    while b < N - 1 do 

        check_num = hen[a] + hen[b]
        
        if check_num <= hen[b + 1]
        elsif check_num > hen[N - 1]
            triangle_total = triangle_total + N - 1 - b
        else
            
            head = b + 1
            tail = N - 1
 
            while head <= tail
                center = (head + tail) / 2   
                
                if hen[center] >= check_num
                    tail = center - 1
                elsif hen[center] < check_num
                    if check_num <= hen[center + 1] 
                        triangle_total = triangle_total + center - b
                        break
                    else 
                        head = center + 1
                    end
                end

            end
 
        end
 
        b = b + 1
 
    end
    a = a + 1
 
end
 
p triangle_total

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

using ll = long long;

char c[8][8] = {};
int H, W, K;
vector<pair<int,int>> v;
bool row[8] = {}, col[8] = {};

ll check(int i) {
	if(i == W + H) {
		ll cnt=0;
		for(int i=0;i<H;i++) {
			if(row[i] == true) continue;
			for(int j=0;j<W;j++) {
				if(col[j] == true) continue;
				if(c[i][j] == '#') cnt++;
			}
		}
		if(cnt == K) return 1;
		else return 0;
	}
	ll ret = 0;
	if(v[i].second == -1) {
		row[v[i].first] = true;
		ret += check(i+1);
		row[v[i].first] = false;
		ret += check(i+1);
	} else {
		col[v[i].second] = true;
		ret += check(i+1);
		col[v[i].second] = false;
		ret += check(i+1);
	}
	return ret;
}

int main() {
	scanf("%d%d%d", &H, &W, &K);
	for(int i=0;i<H;i++) {
		scanf("%s", c[i]);
	}
	for(int i=0;i<H;i++) {
		v.push_back({i, -1});
	}
	for(int i=0;i<W;i++) {
		v.push_back({-1,i});
	}
	printf("%lld\n", check(0));
}

Measured memory_bytes: 3752
// 5/10 リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

    if (S.size() <= K) cout << S << endl;
    else cout << S.substr(0, K) << "..." << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
int c[maxn],v[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    rep(i,n) scanf("%d",&c[i]);
    rep(i,n) scanf("%d",&v[i]);
    rep(i,n)
    {
        if(c[i]>v[i]) ans+=(c[i]-v[i]);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256