akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int N,L;
	vector<string> vs;
	string answer="";
	scanf("%d %d",&N,&L);
	vs.resize(N);
	for(int i=0;i<N;i++){
		char cs[128];
		scanf("%s",cs);
		vs[i]=string(cs);
	}
	sort(vs.begin(),vs.end());
	for(int i=0;i<N;i++) answer+=vs[i];
	puts(answer.c_str());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	i64 sum = 0;
	std::vector<i64> a(n);
	for(int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		
		sum += a[i];
	}
	
	i64 tmp = 0, ans = 1LL << 60;
	for(int i = 0; i < n - 1; i++) {
		tmp += a[i];
		sum -= a[i];
		
		ans = std::min(ans, std::abs(tmp - sum));
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#define NDEBUG

#include <cassert>
#include <cstdlib>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

typedef int type;
constexpr type INIT = (1 << 28);

class segment_tree {
private:
	int n;
	vector<type> value;
	vector<type> lazy;

	static inline type function(type a, type b) {
		return min(a, b);
	}

	void evaluate(int k, int number_of_children) {
		if(lazy[k] == 0) return;
		if(number_of_children > 1) {
			lazy[k * 2 + 1] += lazy[k];
			lazy[k * 2 + 2] += lazy[k];
		}

		value[k] += lazy[k];
		lazy[k] = 0;
	}

	void add(int a, int b, type v, int k, int l, int r) {
		if(r <= a || b <= l) return;
		if(a <= l && r <= b) {
			lazy[k] += v;
		}
		else {
			const int m = (l + r) / 2;
			evaluate(k, r - l);
			add(a, b, v, k * 2 + 1, l, m);
			add(a, b, v, k * 2 + 2, m, r);
			value[k] = function(query(l, m, k * 2 + 1, l, m), query(m, r, k * 2 + 2, m, r));
		}
	}

	type query(int a, int b, int k, int l, int r) {
		if(r <= a || b <= l) return INIT;
		evaluate(k, r - l);
		if(a <= l && r <= b) return value[k];

		const int m = (l + r) / 2;
		const type vl = query(a, b, k * 2 + 1, l, m);
		const type vr = query(a, b, k * 2 + 2, m, r);
		return function(vl, vr);
	}

	int search(int a, int b, type v, int k, int l, int r) {
		if(r <= a || b <= l) return -1;
		evaluate(k, r - l);

		if(v < value[k]) return max(a, l);
		if(r - l == 1) return r;

		const int m = (l + r) / 2;
		const int r_idx = search(a, b, v, k * 2 + 2, m, r);
		if(r_idx != -1 && r_idx != m) return r_idx;
		const int l_idx = search(a, b, v, k * 2 + 1, l, m);
		return l_idx != -1 ? l_idx : m;
	}

public:
	segment_tree(int n_):n(1) {
		while(n < n_) n <<= 1;
		value.resize(2 * n - 1, INIT);
		lazy.resize(2 * n - 1, 0);
	}

	segment_tree(const vector<int> &a):n(1) {
		const int n_ = a.size();
		while(n < n_) n <<= 1;
		value.resize(2 * n - 1, INIT);
		lazy.resize(2 * n - 1, 0);

		for(int i = 0; i < n_; ++i) {
			value[i + n - 1] = a[i];
		}

		for(int i = n - 2; i >= 0; --i) {
			value[i] = function(value[2 * i + 1], value[2 * i + 2]);
		}
	}

	void add(int a, int b, type v) {
		add(a, b, v, 0, 0, n);
	}

	type query(int a, int b) {
		return query(a, b, 0, 0, n);
	}

	int search(int a, int b, type v) {
		return search(a, b, v, 0, 0, n);
	}
};

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

	int n, q;
	cin >> n >> q;

	string s;
	cin >> s;

	set<int> S;

	int sum = 0;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		if(s[i] == '(') {
			++sum;
		}
		else {
			--sum;
			S.insert(i);
		}

		a[i] = sum;
	}

	segment_tree seg(a);

	while(q--) {
		int p;
		cin >> p;
		--p;

		if(s[p] == '(') {
			s[p] = ')';
			S.insert(p);
			seg.add(p, n, -2);

 			const int res = *S.begin();
			assert(s[res] == ')');

			s[res] = '(';
			S.erase(res);
			seg.add(res, n, 2);

			cout << res + 1 << '\n';
		}
		else {
			s[p] = '(';
			S.erase(p);
			seg.add(p, n, 2);

			const int res = seg.search(0, p + 1, 1);
			assert(s[res] == '(');

			s[res] = ')';
			S.insert(res);
			seg.add(res, n, -2);

			cout << res + 1 << '\n';
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 17860
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
  int N, K;
  int min = (int)10e8;
  cin >> N >> K;

  vector<int> vx(N);

  for(int i = 0; i < N; i++){
    cin >> vx[i];
  }

  for(int i = 0; i < N - K + 1; i++){
    int left = vx[i];
    int right = vx[i+K-1];
    int num = 0;
    if(left <= 0 && right <= 0){
      num = -left;
    }
    else if(left <= 0 && right >= 0){
      if(-left < right){
        num = -left * 2 + right;
      }
      else{
        num = -left + right * 2;
      }
    }
    else if(left >= 0 && right >= 0){
      num = right;
    }
    if(num < min){
      min = num;
    }
    //cout << left << " " << right << " " << num << endl;
  }

  cout << min << endl;

}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> fruits(n);
    for (int i = 0; i < n; i++){
        cin >> fruits[i];
    }
    sort(fruits.begin(),fruits.end());
    int sum = 0;
    for (int i = 0; i < k; i++){
        sum += fruits[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3616
# coding: utf-8
# Your code here!
import math
Q=int(input())
for _ in range(Q):
    A,B = list(map(int,input().split()))
    if A<B:
        A,B=B,A
    S=A*B
    a=math.floor(math.sqrt(S-1))
    if a*a>S-1:
        a-=1
#    print(math.sqrt(A*B-1))
#    print('a A B',a,A,B)
    if A-B<=1:
        print(2*(B-1))
    elif a*(a+1) < S:
        print((B-1)+a+max(0,a-B))
    else:
        print((B-1)+a+max(0,a-B-1))






Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int total = 0;
        for(int i =0; i<m; i++) {
            total += sc.nextInt();
        }
        n -= total;
        if(n >= 0) System.out.println(n);
        else System.out.println(-1);
    }
}

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

int main(){
	int a,b,c,d,k;
	cin >> a >> b >> c >> d >> k;
	int s = a*60+b;
	int f = c*60+d;
	int ans = max(f-k-s, 0);
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
#include <stdio.h>
 
int main() {
 
    int t, AC=0, WA=0, TLE=0, RE=0;
    char str[105];
 
    scanf("%d", &t);
    while(t--) {
        scanf("%s", str);
        if(str[0] == 'A') {
            AC++;
        } else if(str[0] == 'W') {
            WA++;
        } else if(str[0] == 'T') {
            TLE++;
        } else if(str[0] == 'R') {
            RE++;
        }
    }
 
    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TLE);
    printf("RE x %d\n", RE);
 
    return 0;
}

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

#define ll   	long long
#define pb	    push_back
#define F   	first
#define S	    second
#define B   	begin()
#define E	    end()
#define FASTIO   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


using namespace std ;


const int BIG = 1e5 + 7 ;
int l[BIG] , r[BIG] ;
pair < int , int > p[BIG] ;
int rep[BIG];
bool cmp ( pair < int , int > x , pair < int , int > y )
{
    return x.S > y.S ;
}
int main()
{
    FASTIO
    int n , m ;
    cin >> n >> m ;
    vector < int > a ;
    for ( int i = 0 ; i < n ; i++ )
    {
        int x ;
        cin >> x ;
        a.pb(x);
    }

    for ( int i = 0 ; i < m ; i++ )
        cin >> p[i].F >> p[i].S ;

    sort ( p , p + m , cmp ) ;
    sort ( a.B , a.E ) ;
    int start = 0 , sum = 0 ;
    for ( int i = 0 ; i < m ; i++ )
    {
        if ( sum > n ) break ;
        int cnt = 0 ;
        for ( int j = start ; j < n ; j++ )
        {
            if ( a[j] >= p[i].S || cnt == p[i].F ) break ;
            a[j] = p[i].S ;
            start = j + 1 ;
            cnt++;
            sum++;
        }
    }
    ll ans = 0 ;
    for ( int i = 0 ; i < n ; i++ ) ans += a[i] ;
    cout << ans ;
    return 0 ;
}



Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

vector< pair<int,int> > leaf_to_root(const vector<int> &u,const vector<int> &v,const int root){
	// return <parent,child>
	int yet = 1000000000;
	vector<int> d(u.size()+1,yet);
	vector< pair<int,int> > res;
	queue<int> Q;
	Q.push(root);
	d[root] = 0;
	vector< vector<int> > G(u.size()+1);
	for(int i=0;i<u.size();i++){
		G[u[i]].push_back(v[i]);
		G[v[i]].push_back(u[i]);
	}
	while( Q.size() ){
		int now = Q.front();
		Q.pop();
		for(auto nex:G[now]){
			if(d[nex]!=yet)continue;
			d[nex] = d[now] + 1;
			Q.push(nex);
			res.push_back( make_pair(now,nex) );
		}
	}
	reverse(res.begin(), res.end());
	return res;
}


int main(){


	int N;
	ll ans=1,K,MOD=1000000007;
	cin >> N >> K;
	vector<int> x(N-1),y(N-1);
	FOR(i,0,N-1) cin >> x[i] >> y[i];
	FOR(i,0,N-1) x[i]--,y[i]--;

	vector< vector<int> > G(N);
	for(int i=0;i<N-1;i++){
		G[x[i]].push_back(y[i]);
		G[y[i]].push_back(x[i]);
	}
	vector< map<int,int> > ma(N);
	for(int i=0;i<N;i++){
		for(int j=0;j<G[i].size();j++){
			ma[ i ][ G[i][j] ] = j;
		}
	}

	auto route = leaf_to_root(x,y,0);
	ans = K;
	vector<int> cnt(N,0);
	reverse(route.begin(),route.end());
	for(auto a:route){
		int p = a.first;
		int c = a.second;
		ll count = K - cnt[p] - 1;
		cnt[p]++;cnt[c]++;
		( ans *= count ) %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 28792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());
// greatest common divisor
long long gcd(long long a, long long b) {
  if (a==0 || b==0) return a+b;
  long long r = 1;
  while (r != 0) {
    r = a%b; a = b; b = r;
  }
  return a;
}

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


class DDisjointSetOfCommonDivisors {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll a, b; cin >> a >> b;
      ll gd = gcd(a, b);
      set<ll> st;
      st.insert(1);
      for(ll i=2; i*i<=gd; i++) {
        while (gd%i==0) {
          st.insert(i);
          gd/=i;
        }
      }
      st.insert(gd);
      cout << st.size() << endl;
    }
};

signed main() {
  DDisjointSetOfCommonDivisors solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説(’・ω・‘)
int main() {
    int n;
    cin >> n;
    vector<int> b(n,0);
    b[0] = INF;
    rep(i,n-1)cin >> b[i+1];
    vector<int> c(n+1,0);
    int ans = 0;
    rep(i,n){
        if(i != n-1)
        {
            c[i] = min(b[i],b[i+1]);
            ans += c[i];
        }else{
            c[i] = b[i];
            ans += c[i];
        }
    }
    cout << ans << endl;
    int sum=0;
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

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

  if(s == "SUN"){
    cout << 7 << endl;
  }
  else if(s == "MON"){
    cout << 6 << endl;
  }
  else if(s == "TUE"){
    cout << 5 << endl;
  }
  else  if(s == "WED"){
    cout << 4 << endl;
  }
  else  if(s == "THU"){
    cout << 3 << endl;
  }
  else  if(s == "FRI"){
    cout << 2 << endl;
  }
  else  if(s == "SAT"){
    cout << 1 << endl;
  }


  return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s;cin>>s;
    string ans="";
    for (auto i:s){
        if (i=='0'){
            ans+="0";
        }else if (i=='1'){
            ans+="1";
        }else {
            if (ans.size()>0){
                ans=ans.substr(0,ans.size()-1);
            }
        }
    }cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 256
string = input()
r_cnt = 0
l_cnt = 0
flg = False
ans = [0 for _ in range(len(string))]
for i, s in enumerate(string):
    if s == "R":
        if flg:
            ans[pos - 1] += l_cnt // 2
            ans[pos] += (l_cnt + 1) // 2
            l_cnt = 0
            flg = False
        r_cnt += 1
    else:
        if not flg:
            pos = i
            ans[i - 1] += (r_cnt + 1) // 2
            ans[i] += r_cnt // 2
            r_cnt = 0
            flg = True
        l_cnt += 1
ans[pos - 1] += l_cnt // 2
ans[pos] += (l_cnt + 1) // 2

print(*ans)

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

// 昇順ソートされたvector aの中でxより大きい数が最初に出てくる場所
int BinarySearch(vector<int> a, int x) {
	int n = a.size();
	int r = 0, l = n;
	int center;
	while (l - r > 1) {
		center = (r + l) / 2;
		if (a[center] > x) l = center;
		else r = center;
	}
	if (a[r] > x) return r;
	return l;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	// as[i], bs[i]は各段で、i番目の祭壇について取り得る下の段の祭壇の数
	// bsum[i]はbs[i]～bs[n-1]までの総和
	// 答えはasの総和
	vector<long long> as(n), bs(n), bsum(n);

	// にぶたん
	for (int i = 0; i < n; i++) {
		bs[i] = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
		// bs[i] = n - BinarySearch(c, b[i]);
	}
	
	bsum[n - 1] = bs[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		bsum[i] = bsum[i + 1] + bs[i];
	}

	for (int i = 0; i < n; i++) {
		int p = (upper_bound(b.begin(), b.end(), a[i]) - b.begin());
		//int p = BinarySearch(b, a[i]);
		if (p < n) {
			as[i] = bsum[p];
		}
		else
		{
			as[i] = 0;
		}
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += as[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    int ans=0;
    int i=0;
    while(i<n){
        ans++;
        i+=k;
        if(i>=n) break; 
        i--;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    REP(i, N) {
        cin >> P[i];
        P[i]--;
    }
    REP(i, N) { cin >> C[i]; }
    int maxv = -1e12;
    REP(i, N) {
        int now = i, sum = 0, cnt = 0;
        // 最低1回は移動する
        do {
            int next = P[now];
            sum += C[next];
            now = next;
            maxv = max(maxv, sum);
            cnt++;
        } while (cnt < K && now != i);
        int len = cnt, loopsum = sum;
        if (cnt < K) {
            int nloop = (K - cnt) / len;
            nloop = max(0LL, nloop - 1);
            sum += nloop * loopsum;
            maxv = max(sum, maxv);
            cnt += nloop * len;
        }
        while (cnt < K) {
            int next = P[now];
            sum += C[next];
            now = next;
            maxv = max(maxv, sum);
            cnt++;
        }
    }
    cout << maxv << endl;

    return 0;
}


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

int main() {
	ll n, ans = 0;
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		ll x = n / i;
		ans += i * x * (x + 1) /2;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	int a[3][3];
	bool hit[3][3]={};
	rep(i,3)rep(j,3)cin>>a[i][j];
	int n;
	
	cin >> n;
	int b[n];
	rep(i,n){
		cin >> b[i];
		rep(j,3){
			rep(k,3){
				hit[j][k] = hit[j][k] || b[i]==a[j][k];
			}
		}
	}
	int ans=0;
	rep(i,3){
		int count=0;
		rep(j,3){
			if(hit[i][j])count++;
          
		}
		if(count==3)ans++;
	}
	rep(i,3){
		int count=0;
		rep(j,3){
			if(hit[j][i])count++;
		}
		if(count==3)ans++;
	}
	if(hit[0][0]&&hit[1][1]&&hit[2][2])ans++;
	if(hit[2][0]&&hit[1][1]&&hit[0][2])ans++;
	if(ans>0)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

typedef pair<int, int> PII;
#define x first
#define y second
typedef long long LL;
const LL p = 998244353;
const int N = 200010;
int n, tree[1 << 19];
LL f[N];
PII a[N];

void update(int x, int t) {
	x += 1 << 18;
	while (x) {
		tree[x] = max(tree[x], t);
		x /= 2;
	}
}

int calc(int l, int r) {
	int a = 0;
	l += 1 << 18;
	r += 1 << 18;
	while (l <= r) {
		a = max({ a,tree[l],tree[r] });
		l = (l + 1) / 2;
		r = (r - 1) / 2;
	}
	return a;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;
	sort(a, a + n);
	for (int i = n - 1; i >= 0; i--) update(i, max(i, calc(i, lower_bound(a, a + n, make_pair(a[i].first + a[i].second, -1)) - a - 1)));
	f[0] = 1;
	for (int i = 0; i < n; i++) f[i + 1] += f[i], f[i + 1] %= p, f[tree[i + (1 << 18)] + 1] += f[i], f[tree[i + (1 << 18)] + 1] %= p;
	cout << f[n] << endl;
	return 0;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    string S;
    cin >> S;
    string ans;
    if (S.size() <= K) ans = S;
    else ans = S.substr(0,K) + "...";
    cout << ans << "\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <math.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++)

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

template <class T>
inline bool chmin(T& a, T b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P;

template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);
    // N-1個の最大公約数の最大値を求めればいい

    //left[i]はa.at(0)からa.at(i-1)(i番目)までの最大公約数
    vector<int> left(N + 1, a.at(0));
    rep(i, N)
    {
        left.at(i + 1) = GCD<int>(left.at(i), a.at(i));
    }
    vector<int> right(N + 1, a.at(N - 1));
    rep(i, N)
    {
        right.at(i + 1) = GCD<int>(right.at(i), a.at(N - 1 - i));
    }

    int max = -INF_32;

    chmax(max, right.at(N - 1));
    chmax(max, left.at(N - 1));
    for (int i = 1; i < N - 1; i++) {
        chmax(max, GCD<int>(left.at(i), right.at(N - i - 1)));
    }

    cout
        << max << endl;
}


Measured memory_bytes: 1408
/*input
2 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, w; cin >> h >> w;
    if(h == 1 || w == 1) cout << 1;
    else cout << (h * w)/2 + ((h * w) & 1);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

#define ll long long

ll read()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

inline void out (int x)
{
	if (x>9) out(x/10);
	putchar (x%10+'0');
}

void doing ()
{
	int n;
	n=read();
	int a,b,c;
	a=n/100;
	b=n/10;
	c=n%10;
	if (a==c)
	{
		puts("Yes");
	}
	else puts("No");
}

int main ()
{
	//freopen("xx.in","r",stdin);
	//freopen("xx.out","w",stdout);
	doing ();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  string s;
  int cnt = 0;
  cin >> s;
  for (size_t i = 0; i < 3; i++)
  {
    if (s[i] == '1') cnt++;
  }
  cout << cnt << endl;  
  return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(pair<long long int, long long int> x, pair<long long int, long long int> y){
	return x.first + x.second < y.first + y.second;
}
int main(){
	long long int n;
	scanf("%lld", &n);
	pair<long long int, long long int> a[n];
	for (long long int i = 0; i < n; i++){
		scanf("%lld %lld", &a[i].first, &a[i].second);
	}
	sort(a, a + n, cmp);
	long long int dp[n][n + 1], ans;
	for (long long int i = 0; i < n; i++){
		for (long long int j = 1; j <= n; j++){
			dp[i][j] = 999999999999999999;
		}
	}
	dp[0][1] = a[0].second;
	for (long long int i = 1; i < n; i++){
		for (long long int j = 1; j <= i + 1; j++){
			dp[i][j] = dp[i - 1][j];
			if (dp[i - 1][j - 1] <= a[i].first){
				dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + a[i].second);
			}	
		}
	}
	for (long long int j = 1; j <= n; j++){
		if (dp[n - 1][j] != 999999999999999999){
			ans = j;
		}
	}
	printf("%lld\n", ans);
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int[] a = new int[n];

		for ( int i = 0 ; i < n ; i++ ) {
			a[i] = sc1.nextInt();
		}

		Arrays.sort(a);

		int min = a[0];
		int max = a[n-1];

		int ans = max - min;

		System.out.println(ans);

		sc1.close();

	}

}

Measured memory_bytes: 22228
import copy
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(min(100,k)):
  L1=[0]*(n+2)
  if i!=0:
    a=L2[1:n+1]
  for j in range(n):
    L1[max(j-a[j],0)]+=1
    L1[min(j+a[j],n)+1]-=1
  L2=[0]
  for i in range(n+2):
    L2.append(L2[-1]+L1[i])
a=L2[1:n+1]
for i in range(len(a)):
  a[i]=str(a[i])
print(' '.join(a))

Measured memory_bytes: 185352
#include<stdio.h>
#include<stdlib.h>
typedef struct{
    int a;
    int b;
}number_t;
int t_comp(const void* a,const void* b){return ((number_t*)a)->a-((number_t*)b)->a;}
int main(void)
{
    int n;
    number_t num[100000];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&num[i].a);
        num[i].b=i+1;
    }
    qsort(num,n,sizeof(number_t),t_comp);
    for(int i=0;i<n;i++){
        printf("%d ",num[i].b);
    }
    return 0;
}

Measured memory_bytes: 1660
L = [int(i) for i in input().split()]

min_root = []
for i in L:
    for j in L:
        if i != j:
            min_root.append(i+j)
        else:
            continue
            
if len(min_root) > 0:
    print(min(min_root))
else:
    print(L[0]+L[1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define LL __int128
#define ll long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PII pair<int, int>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[maxn], b[maxn];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> a[i];
    for(int i = 1; i <= n; i ++) cin >> b[i];
    reverse(b + 1, b + n + 1);
    int ok = 0;
    for(int i = 1; i <= n; i ++){
        if(a[i] != b[i]) continue;
        int f = 0;
        for(int j = 1; j <= n; j ++){
            if(a[i] != b[j] && a[j] != b[i]){
                f = 1;
                swap(b[i], b[j]);
                break;
            }
        }
        if(!f){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i <= n; i ++){
        if(i != 1)cout << " ";
        cout << b[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
	int h,w,i,j;
	
	refrain:
	cin>>h;
	cin>>w;
	if(h==0&&w==0) return 0;
	
	for(i=0;i<h;i++){
		if(i%2==0){
			for(j=0;j<w;j++){
				if(j%2==0) cout<<"#";
				else cout<<".";
			}
		}
		else{
			for(j=0;j<w;j++){
				if(j%2==0) cout<<".";
				else cout<<"#";
			}
		}
		cout<<endl;
	}
	cout<<endl;
	
	goto refrain;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
	int N;cin>>N;
	cout<<N*(N-1)/2<<endl;
}

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

int main() {
  int N, M; cin >> N >> M;

  int S[M];
  string C[M];
  for (int i = 0; i < M; i++) {
    cin >> S[i] >> C[i];
    S[i]--;
  }

  string stringNum;
  bool flg = true;
  int ans = -1;

  string left, right;

  int num = 0;
  if (N == 2) num += 10;
  if (N == 3) num += 100;

  for (; num < 1000; num++){
//    cout << num << endl;
    stringNum = to_string(num);
    for (int i = 0; i < M; i++) {
      left = stringNum[S[i]];
      right = C[i];
      if (left != right) flg = false;

//      cout << "left:" << left << " right:" << right << endl;
    }

    if (flg) {
      ans = num;
      break;
    } else {
      flg = true;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    if (S.size() <= 3) {
        No;
        return 0;
    }

    if (S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') {
        Yes;
    } else {
        No;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
vector<string> split(const string &str, char sep){
    std::vector<std::string> v;
    auto first = str.begin();
    while(first != str.end()){
        auto last = first;
        while(last != str.end() && *last != sep) ++last;
        v.push_back(std::string(first,last));
        if(last!=str.end()) ++last;
        first=last;
    }
    return v;
}
long long ai,ao,at,aj,al,as,az;
long long ans;
int main(){
    cin>>ai>>ao>>at>>aj>>al>>as>>az;
    ans=ao;
    int x=min({ai,aj,al});
    rep(i,min(10,x+1)){
        ans=max(ans,ao+i*3+((ai-i)/2)*2+((aj-i)/2)*2+((al-i)/2)*2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, A, B;
    std::cin >> N >> A >> B;

    if (std::abs(A - B) % 2 == 0) {
        std::cout << "Alice" << std::endl;
    } else {
        std::cout << "Borys" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char Array[21][21];
bool Visited[21][21];
queue<pair<int,pair<int,int> > > Q;

void Initialize( int H , int W ){
    for( int i = 1 ; i <= H ; ++i ){
        for( int j = 1 ; j <= W ; ++j )
            Visited[i][j] = false;
    }
}

int bfs( int H , int W , int r , int c ){
    int d , Ans = 0;
    pair<int,pair<int,int> > P;
    Q.push( make_pair( 0 , make_pair( r , c ) ) );

    while( !Q.empty() ){
        P = Q.front();
        Q.pop();
        d = P.first;
        r = P.second.first;
        c = P.second.second;
        if( Visited[r][c] == true ) continue;
        Visited[r][c] = true;
        Ans = max( Ans , d );

        if( r - 1 >= 1 && Visited[r - 1][c] == false && Array[r - 1][c] == '.' ) 
            Q.push( make_pair( d + 1 , make_pair( r - 1 , c ) ) );
        if( r + 1 <= H && Visited[r + 1][c] == false && Array[r + 1][c] == '.' )
            Q.push( make_pair( d + 1 , make_pair( r + 1 , c ) ) );
        if( c - 1 >= 1 && Visited[r][c - 1] == false && Array[r][c - 1] == '.' )
            Q.push( make_pair( d + 1 , make_pair( r , c - 1 ) ) );
        if( c + 1 <= W && Visited[r][c + 1] == false && Array[r][c + 1] == '.' ) 
            Q.push( make_pair( d + 1 , make_pair( r , c + 1 ) ) );
    }

    return Ans;
}

int FindMaximumMoves( int H , int W ){
    int i , j , Ans = 0;

    for( i = 1 ; i <= H ; ++i ){
        for( j = 1 ; j <= W ; ++j ){
            if( Array[i][j] == '#' ) continue;
            Initialize( H , W );
            Ans = max( Ans , bfs( H , W , i , j ) );
        }
    }

    return Ans;
}

int main(){
    int H , W , i , j;
    char ch;
    scanf( "%d%d" , &H , &W );
    
    for( i = 1 ; i <= H ; ++i ){
        for( j = 1 ; j <= W ; ++j ){
            scanf( "%c" , &ch );

            while( ch != '.' && ch != '#' )
                scanf( "%c" , &ch );

            Array[i][j] = ch;
        }
    }

    printf( "%d\n" , FindMaximumMoves( H , W ) );
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ALDS1_1D{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var R = sr.Next<int>(N);

            var res = int.MinValue;
            var left = R[0];
            for(var i = 1; i < N; i++){
                res = Math.Max(res, R[i] - left);
                left = Math.Min(left, R[i]);
            }

            Console.WriteLine(res);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }
    }
}

Measured memory_bytes: 11284
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;



vector<lld> p[MAXN];
lld dist[MAXN] = {};

void dfs(lld x,lld d)
{
	int s = p[x].size();
	for(int i = 0; i < s; i++)
	{
		if (dist[p[x][i]] < 0)
		{
			dist[p[x][i]] = d + 1;
			dfs(p[x][i],d+1);
		}
	}
}

int main()
{
	lld n;

	cin >> n;
	lld a = 0,b = 0;
	for(int i = 0; i < n-1; i++)
	{
		cin >> a >> b;

		p[a-1].push_back(b-1);
		p[b-1].push_back(a-1);
	}

	for(int i = 0; i < n; i++)
	{
		dist[i] = -1;
	}

	dist[0] = 0;
	dfs(0,0);

	lld d_0[MAXN] = {};

	for(int i = 0; i < n; i++)
	{
		d_0[i] = dist[i];
	}


	for(int i = 0; i < n; i++)
	{
		dist[i] = -1;
	}

	dist[n-1] = 0;
	dfs(n-1,0);

	lld fennec = 0,snuke = 0;

	for(int i = 0; i < n; i++)
	{
		// printf("d_0[%d] = %lld   ", i,d_0[i]);
		// printf("dist[%d] = %lld\n", i,dist[i]);
		if (d_0[i] <= dist[i])
		{
			fennec++;
		}else
		{
			snuke++;
		}
	}

	if (fennec > snuke)
	{
		cout << "Fennec" << endl;
	}else
	{
		cout << "Snuke" << endl;
	}

	return 0;
}

Measured memory_bytes: 11904
#include<stdio.h>
int main(){
	double ax,ay,bx,by,cx,cy,dx,dy;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy)){
		if(
		((ax-cx)*(by-ay)+(ay-cy)*(ax-bx))*
		((ax-cx)*(dy-ay)+(ay-cy)*(ax-dx))<=0&&
		((bx-dx)*(ay-by)+(by-dy)*(bx-ax))*
		((bx-dx)*(cy-by)+(by-dy)*(bx-cx))<=0)printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
L = LIST()

L.sort(reverse=True)
ans = 0
for i in range(1, N*2, 2):
    ans += L[i]
print(ans)


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

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

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vint v(26,INF);
	rep(i,n){
		string s;
		cin>>s;
		vint tmp(26,0);
		rep(j,s.size()){
			tmp[s[j]-'a']++;
		}
		rep(j,26){
			mins(v[j], tmp[j]);
		}
	}
	rep(i,26){
		rep(j,v[i]){
			cout<<char('a'+i);
		}
	}
	cout<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int X[110000];
int Y[110000];
pair<pair<int,int>,int >p[110000];
long long ans[110000];
int sz[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d",X+i,Y+i);
		p[i]=make_pair(make_pair(Y[i],X[i]),i);
	}
	std::sort(p,p+b);
	for(int i=0;i<b;i++){
		int t=p[i].first.second;
		int u=++sz[p[i].first.second];
		ans[p[i].second]=(long long)t*1000000+u;
	}
	for(int i=0;i<b;i++){
		printf("%012lld\n",ans[i]);
	}
}

Measured memory_bytes: 5376
# ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
  a = c.dup
  (0..n-1).each do |i|
    (n-1).downto(i+1) do |j|
      if a[j][1].to_i < a[j-1][1].to_i
        a[j], a[j-1] = a[j-1], a[j]
      end
    end
  end
  return a
end

def selectionSort(c, n)
  a = c.dup
  (0..n-1).each do |i|
    minj = i
    (i..n-1).each do |j|
      if a[j][1].to_i < a[minj][1].to_i then
        minj = j
      end
    end
    a[i], a[minj] = a[minj], a[i]
  end
  return a
end
bubble = bubbleSort(a, n)
selection = selectionSort(a, n)
puts bubble.join(" ")
puts "Stable"
puts selection.join(" ")
if bubble == selection then
  puts "Stable"
else
  puts "Not stable"
end

Measured memory_bytes: 8804
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  999999999;



//n以下の素数のvector配列をprimeに格納する。
//エラトステネスの篩
void eratos(vector<ll>& prime,int n){
  bool used[n+10];
  fill(used,used+n+2,false);
  for(int i=2;i<=n;i++){
    if(!used[i]){
      prime.push_back(i);
      int j=i;
      while(j<=n){
        used[j]=true;
        j+=i;
      }
    }
  }
}
int main(){
  vector<ll> prime;
  int N,sn;
  cin>>N;
  sn=sqrt(N);
  eratos(prime,sn);
  cout<<N<<":";
  REP(i,prime.size()){
    while(N%prime[i]==0){
      cout<<" "<<prime[i];
      N=N/prime[i];
    }
  }
  if(N!=1)cout<<" "<<N;
  cout<<endl;
}



Measured memory_bytes: 3232
S = input()[::-1]
 
cnt = [0] * 2019
cnt[0] = 1
total = 0
x = 1
ans = 0
 
for a in S:
    total += int(a) * x
    total %= 2019
    cnt[total] += 1
    x = x*10
    x %= 2019
 
for i in range(2019):
    ans += cnt[i]*(cnt[i]-1)//2
 
print(ans)


Measured memory_bytes: 9312
#include <stdio.h>
#include <math.h>
int PrimeNumbers(int b);
int cnt=0;
int main(void){
	int a,b,i;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&b);
		PrimeNumbers(b);
	}
	printf("%d\n",cnt);
	return 0;
}

int PrimeNumbers(int b){
	int c,j;
	if(b==2){
		cnt++;
		return 0;
	}
	if(b<2 || b%2==0)
		return 0;
	c = sqrt(b);
	for(j=3;j<=c;j+=2){
		if(b%j==0)
			return 0;
	}
	cnt++;
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

int main(int argc, char **argv)
{
        int a, b;
        std::cin >> a >> b;
        if(a <= 5){
                printf("0\n");
        }else if(a <= 12){
                printf("%d\n", b >> 1);
        }else
                printf("%d\n", b);
        
        return 0;
}


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

void solve(){
  int N;
  int ans=0;
  cin>>N;
  vector<int> V,C;
  for(int i=0; i<N; i++){
    int k;
    cin >> k;
    V.push_back(k);
  }
   for(int i=0; i<N; i++){
    int l;
    cin >> l;
    C.push_back(l);
  }

  for(int i=0; i<N; i++){
    if(V[i]-C[i]>0){
    ans=ans+V[i]-C[i];
    }
  }

   cout << ans << endl;
}

int main(){
  solve();
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    while(1){
        if(n%10==7){
            cout<<"Yes"<<endl;
            return 0;
        }
        n=n/10;
        if(n==0){
            break;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int h,w,dx[]={1,0,-1,0},dy[]={0,1,0,-1},ch[50][50],ansb,answ,nx,ny,ok;
string s[50];
char cnt;
queue<P> que;
void ini(void){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ch[i][j]=0;
        }
    }
}
int main(void){
    while(1){
    cin>>w>>h;
    ansb=0,answ=0;
    if(h==0&&w==0)return 0;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ok=1;
            ini();
            cnt='N';
            if(s[i][j]!='.')continue;
            que.push({i,j});
            ch[i][j]=1;
            while(que.size()){
                P q=que.front();
                que.pop();
                for(int k=0;k<4;k++){
                    nx=q.F+dx[k],ny=q.S+dy[k];
                    if(0<=nx&&nx<h&&0<=ny&&ny<w&&ch[nx][ny]==0){
                        if(s[nx][ny]=='.'){
                            que.push({nx,ny});
                            ch[nx][ny]=1;
                        }
                        if(s[nx][ny]=='W'){
                            if(cnt=='B')ok=0;
                            else if(cnt=='N')cnt='W';
                        }
                        if(s[nx][ny]=='B'){
                            if(cnt=='W')ok=0;
                            else if(cnt=='N')cnt='B';
                        }
                    }
                }
            }
            if(ok){
                if(cnt=='B')ansb++;
                if(cnt=='W')answ++;
            }
        }
        
    }
    cout<<ansb<<" "<<answ<<endl;
    }
}



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

int main() {
	int n,i;
	cin >> n;
	char s;
	for (i = 0;i < n &&s !='Y' ;i++) {
		cin >> s;
	}
	if (i >= n-1 )cout << "Three" << endl;
	else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 3010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int flag[N][N], dp[N][N] ;
char s1[N], s2[N] ;
void LCS() {
    clr(dp) ; clr(flag) ;
    int n = strlen(s1), m = strlen(s2) ;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
        if (s1[i - 1] == s2[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1, flag[i][j] = 0 ;
        else if (dp[i - 1][j] >= dp[i][j - 1]) dp[i][j] = dp[i - 1][j], flag[i][j] = 1 ;
        else dp[i][j] = dp[i][j - 1], flag[i][j] = -1 ;
    }
}
void PrintLCS(int i, int j) {
    if (i == 0 || j == 0) return ;
    if (flag[i][j] == 0) {
        PrintLCS(i - 1,j - 1) ;
        cout << s1[i - 1] ;
    }
    else if (flag[i][j] == 1) PrintLCS(i - 1, j) ;
    else PrintLCS(i, j - 1) ;
}
int main(){
    cin >> s1 >> s2 ;
    LCS() ;
    PrintLCS(strlen(s1), strlen(s2)) ;
    return 0 ;
}


/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


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

int findSumOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  int sum = findSumOfDigits(n);
  if( n % sum == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256