akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int n;
ll k, a[100010], b[100010];
vector<ll> cand;

void dfs(ll x, int i, bool smaller) {
    if (i == -1) {
        cand.push_back(x);
        return;
    }
    if (smaller) {
        dfs(x + (1 << i), i-1, true);
    } else {
        if (k & (1 << i)) {
            dfs(x + (1 << i), i-1, false);
            dfs(x, i-1, true);
        } else {
            dfs(x, i-1, false);
        }
    }
}

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i] >> b[i];

    dfs(0, 30, false);

    ll ans = -1;
    for (auto &bit: cand) {
        ll tmp = 0;
        rep(i, n) {
            bool ok = true;
            rep(j, 30) {
                if (!(bit & (1 << j)) && (a[i] & (1 << j))) ok = false;
            }
            if (ok) tmp += b[i];
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void)
{
	long int n,k;
	cin>>n>>k;
	long int r,s,p;
	cin>>r>>s>>p;
	char t[100010];
	cin>>t;
	long long int ans;
	ans = 0;
	int i;
	for(i = 0; i < n; i++){
		if(t[i] == 'r'){
			ans+=p;
			if(i+k<= n){
				if(t[i+k] == 'r') t[i+k] = 'o';
			}
		}
		else if(t[i] == 's'){
			ans+=r;
			if(i+k<=n){
				if(t[i+k] == 's') t[i+k] = 'o';
			}
		}
		else if(t[i] == 'p'){
			ans+=s;
			if(i+k <= n){
				if(t[i+k] =='p') t[i+k] = 'o';
			}
		}
	}
	printf("%lld\n",ans);
	//cout<<"t = "<<t<<endl;
	return 0;
}



Measured memory_bytes: 384
import sys
readline = sys.stdin.buffer.readline

import numpy as np

n = int(readline())
a = np.array(readline().split(), np.int64)

ai = np.argsort(a)[::-1]
a = a[ai]
ai += 1

dp = np.zeros(n + 1, np.int64)
for k, (i, e) in enumerate(zip(ai, a), 1):
    dp_new = dp.copy()

    add_left = e * np.abs(np.arange(1, k + 1) - i)
    dp_new[1:k+1] = np.maximum(dp_new[1:k+1], dp[:k] + add_left)

    add_right = e * np.abs(np.arange(n - k + 1, n + 1) - i)
    dp_new[:k] = np.maximum(dp_new[:k], dp[:k] + add_right)

    dp = dp_new

ans = dp.max()
print(ans)


Measured memory_bytes: 27808
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 2e18 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, ans = INF; cin >> n;

    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            long long j = n / i;
            ans = min(ans, i + j - 2);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3636
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			List<List<Pair>> cost = new ArrayList<List<Pair>>();
			List<List<Pair>> time = new ArrayList<List<Pair>>();
			for (int i = 0; i < m; i++) {
				cost.add(new ArrayList<Pair>());
				time.add(new ArrayList<Pair>());
			}
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				int c = scanner.nextInt();
				int d = scanner.nextInt();
				cost.get(a).add(new Pair(b, c));
				cost.get(b).add(new Pair(a, c));
				time.get(a).add(new Pair(b, d));
				time.get(b).add(new Pair(a, d));
			}
			int[][] costmap = new int[m][m];
			int[][] timemap = new int[m][m];
			for (int i = 0; i < m; i++) {
				slove(i, 0, cost, costmap[i]);
				slove(i, 0, time, timemap[i]);
			}
			int s = scanner.nextInt();
			for (int i = 0; i < s; i++) {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				int c = scanner.nextInt();
				if (c == 0) {
					System.out.println(costmap[a][b]);
				} else {
					System.out.println(timemap[a][b]);
				}
			}

		}

	}

	private void slove(int s, int g, List<List<Pair>> cost, int[] map) {
		Arrays.fill(map, 1 << 24);
		map[s] = 0;
		PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
		boolean[] color = new boolean[m];
		pq.add(new Pair(0, s));
		while (!pq.isEmpty()) {
			Pair pair = pq.poll();
			int a = pair.a;
			int b = pair.b;
			color[b] = true;
			if (map[b] < a)
				continue;
			for (int i = 0; i < cost.get(b).size(); i++) {
				int v = cost.get(b).get(i).b;
				int o = cost.get(b).get(i).a;
				if (color[o])
					continue;
				if (map[o] > v + a) {
					map[o] = v + a;
					pq.offer(new Pair(v + a, o));
				}
			}
		}

	}

	int n;
	int m;

	class Pair implements Comparable<Pair> {
		int a;
		int b;

		public Pair(int a, int b) {
			super();
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Pair o) {
			return this.a - o.a;
		}

	}

}

Measured memory_bytes: 94444
#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;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
     int n;cin >> n;
     vector<ll>a(n);
     for(int i = 0;i<n;i++) cin >> a[i];
     vector<ll>ans(n);
     for(int i = 0;i<n;i++){
        if(i&1) ans[0] -= a[i];
        else ans[0] += a[i];
     }
     for(int i = 1;i<n;i++){
        ans[i] = 2*a[i-1] - ans[i-1];
     }
     for(int i = 0;i<n;i++) cout << ans[i]<<' ';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define PI 3.14159265
	
int main(void){
	int x[100],y[100];
	double manh=0,euc=0,p_3=0,cheb=0;
	double temp;
	int num;
	cin>>num;
	for(int i=0;i<num;i++){
		cin>>x[i];
	}
	for(int i=0;i<num;i++){
		cin>>y[i];
	}
	for(int i=0;i<num;i++){
		temp = abs(x[i]-y[i]);
		manh += temp;
		euc += temp*temp;
		p_3 += temp*temp*temp;
		if(cheb < temp)
			cheb = temp; 
	}
	euc = pow(euc,1/2.0);
	p_3 = pow(p_3,1/3.0);

	cout.precision(8);
	cout<<fixed<<manh*1.0<<endl;
	cout.precision(8);
	cout<<fixed<<euc*1.0<<endl;
	cout.precision(8);
	cout<<fixed<<p_3*1.0<<endl;
	cout.precision(8);
	cout<<fixed<<cheb*1.0<<endl;
	return 0;
}

Measured memory_bytes: 1284
from collections import deque

N = int(input())
ans = 0
option = ["7","5","3"]
dq = deque()
for s in option:
    dq.append(s)

def judge(string):
    bit = [0]*3
    chenge = {"7":0, "5":1, "3":2}
    for s in string:
        bit[chenge[s]] = 1
    return all(bit)

while dq:
    n = dq.popleft()
    if int(n) <= N and judge(n):
        ans += 1
    if int(n) > N:
        continue
    for i,s in enumerate(option):
        dq.append(n+s)

print(ans)

Measured memory_bytes: 7540
//==========================================
// 🅐🅤🅣🅗🅞🅡: 🅐🅦🅚
//==========================================

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

void solve(){
	string s1, s2;
	cin >> s1>>s2;

	s2.pop_back();

	if( s1.compare(s2) == 0){
		cout << "Yes\n";
	}
	else cout << "No\n";
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 3612
N=int(input()) 
XL = [[int(i) for i in input().split()] for i in range(N)] 
rl = [[x[0]+x[1],x[0]-x[1]] for x in XL]
rl = sorted(rl)

p = rl[0][0]
cnt = 1
for x in rl:
  if x[1] >=p:
    cnt += 1
    p = x[0]
    
print(cnt)

Measured memory_bytes: 39008
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

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

		int count = 0,max = 0;
		for(int i=0;i<N;i++) {
			if(x[i] >= max) {
				max = x[i];
				count++;
			}
		}
		System.out.println(count);
	}

}

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

int main()
{
	long long N;
	cin >> N;

	long double a = 4;
	a /= N;
	int h = 0;
	int n = 0;
	int w = 0;
	for( int i = 1; i <= 3500; i++ ) {
		for( int j = 1; j <= 3500; j++ ) {
			if( (long double)1 / i + (long double)1 / j < a ) {
				h = i;
				n = j;
				long double ww = a - ((long double)1 / i + (long double)1 / j);
				w = (long double)1 / ww;
				if( w > 0 && (long double)1 / w + (long double)1 / h + (long double)1 / n == a ) break;
			}
		}
		if( w > 0 && (long double)1 / w + (long double)1 / h + (long double)1 / n == a ) break;
	}

	cout << h << " " << n << " " << w << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int w,h,n,x,y,a,i,o,q;
main(){
  for(cin>>w>>h>>n;i++<n;a-1?a-2?a-3?h=y<h?y:h:q=y>q?y:q:w=x<w?x:w:o=x>o?x:o)cin>>x>>y>>a;
  cout<<max(0,(w-o))*max(0,(h-q))<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int G[101][101];
bool Memo[101];
int d[101];
int f[101];
int count1;

void dfs(int i, int n) {
  if (Memo[i]) {
    count1++;
    d[i] = count1;
    Memo[i] = false;
    for (int j = 0; j < n; j++) {
      if (G[i][j] == 1) {
        dfs(j,n);
      }
    }
    count1++;
    f[i] = count1;
  }
}

int main() {
  int n;
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      G[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    int row,col;
    scanf("%d %d",&row,&col);
    for (int j = 0; j < col; j++) {
      int d;
      scanf("%d",&d);
      G[row - 1][d - 1] = 1;
    }
  }
  for (int i = 0; i < n; i++) Memo[i] = true;
  count1 = 0;
  for (int i = 0; i < n; i++) {
    if (Memo[i]) dfs(i,n);
  }
  for (int i = 0; i < n; i++) printf("%d %d %d\n",i+1,d[i],f[i]);
  return 0;
}



Measured memory_bytes: 3216
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
#include "stdlib.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())


int main(){
  string s;
  cin>>s;
  bool ans=true;
  if(SIZE(s)%2!=0){ans=false;}
  REP(i,SIZE(s)){
    if(i%2==0){
      if(s[i]!='h'){ans=false;}
    }
    else{
      if(s[i]!='i'){ans=false;}
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000005;
int n,a[N],f[N];
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)f[i]=f[i-1]+a[i];
	int ans=1;
	for (int i=n-1;i;i--)
		if (f[i]*2>=a[i+1])ans++;
		else break;
	printf("%lld\n",ans);	
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;

  int ans = 0;
  if (S[0] == T[0]) ans++;
  if (S[1] == T[1]) ans++;
  if (S[2] == T[2]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int x1,x2,y1,y2,x,y;
    cin>>x1>>y1>>x2>>y2;
    x=x2-x1;
    y=y2-y1;
    cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 基本的な演算
namespace BasicMath {
    // 絶対値を求める
    static UInt Abs(const Int a);

    // 絶対値を求める
    UInt Abs(const Int a) {
        return a > 0 ? a : -a;
    }
}
using namespace BasicMath;

int main(void) {
    UInt a, b, c, d;
    cin >> a >> b >> c >> d;
    if (Abs(b - a) <= d && Abs(c - b) <= d) {
        cout << "Yes" << endl;
    } else if (Abs(c - a) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3516
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

int main()
{
    int n,k;
    int a,b,c;

    cin>>n>>k;

    a=n/k;
    b=n%k;
    if(b==0)
    {
        cout<<"0";
    }
    else
        cout<<b-a+1;

    cout<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray().ToList();
            var shiftList = Shift(list, n).ToList();

            var dict = list.Select((ch, index) => new { ch, index })
                .ToDictionary(s => s.ch, s => shiftList[s.index]);

            var array = Console.ReadLine().ToCharArray().Select(s => dict[s]).ToArray();
            Console.WriteLine(new string(array));
        }

        private static IEnumerable<char> Shift(List<char> list, int n)
        {
            var count = list.Count;
            for (int i = 0; i < count; i++)
            {
                yield return i + n < count ? list[n + i] : list[n + i - count];
            }
        }
    }
}


Measured memory_bytes: 13536
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> pii;

int main(){
	int n, h1, m1, s1, h2, m2, s2;
	while(scanf("%d", &n), n){
		vector<pii> v;
		v.reserve(2 * n);

		for(int i = 0; i < n; ++i){
			scanf("%d:%d:%d%d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			v.push_back(pii(h1 * 3600 + m1 * 60 + s1, 1));
			v.push_back(pii(h2 * 3600 + m2 * 60 + s2, -1));
		}
		sort(v.begin(), v.end());
		
		int ans = 0;
		int t = 0;
		for(int i = 0; i < v.size(); ++i){
			t += v[i].second;
			ans = max(ans, t);
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1268
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<cstring>

using namespace std;

int main(){

    int N;

    cin >> N;

    if(N==1){
    	int first;
    	int second;
      cin >> first;
      cin >> second;

      cout << first + second << endl;
    }else{

    int a[2][N];

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

    int ans = 0;

    for(int i = 0;i < N;i++){
      int cnt = 0;
      for(int j = 0;j <=i;j++){
    	cnt += a[0][j];
      }
      for(int k = i;k <= N-1;k++){
    	cnt += a[1][k];
      }
      ans = max(ans,cnt);
    }

    cout << ans << endl;
    }

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n,q;cin>>n>>q;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> lim,ans;

    if(n%2==0){
        vector<ll> sume(n+1,0),sum(n+1,0);
        rep(i,n){
            if(i%2) sume[i+1]=sume[i]+a[i];
            else sume[i+1]=sume[i];
            sum[i+1]=sum[i]+a[i];
        }
        for(int k=1;k<n/2;k++){
            //後ろからk個を高橋君がとる
            ll num=(a[n-k-1]+a[n-2*k-1])/2;
            lim.push_back(num);
            ans.push_back(sum[n]-sum[n-k]+sume[n-2*k]);
        }
        reverse(ALL(lim));
        lim.push_back(LINF);
        ans.push_back(sum[n]-sum[n/2]);
        reverse(ALL(ans));
        // debug(lim);debug(ans);
        while(q--){
            ll x;cin>>x;
            int idx=lower_bound(ALL(lim),x)-lim.begin();
            cout<<ans[idx]<<endl;
        }
        return 0;
    }
    else{
        vector<ll> sumo(n+1,0),sum(n+1,0);
        rep(i,n){
            if(i%2==0) sumo[i+1]=sumo[i]+a[i];
            else    sumo[i+1]=sumo[i];
            sum[i+1]=sum[i]+a[i];
        }
        for(int k=1;k<=n/2;k++){
            ll num=(a[n-k-1]+a[n-2*k-1])/2;
            lim.push_back(num);
            ans.push_back(sum[n]-sum[n-k]+sumo[n-2*k]);
        }
        reverse(ALL(lim));
        lim.push_back(LINF);
        ans.push_back(sum[n]-sum[n/2]);
        reverse(ALL(ans));
        // debug(lim);debug(ans);
        while(q--){
            ll x;cin>>x;
            int idx=lower_bound(ALL(lim),x)-lim.begin();
            cout<<ans[idx]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

void print(vector<ll> &v) {
    for (ll l : v) cout << l << endl;
}

int main() {
    ll n;
    cin >> n;

    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }

    if (n == 4) {
        cout << "2 5 63 20" << endl;
        return 0;
    }

    if (n == 5) {
        cout << "2 5 20 30 63" << endl;
        return 0;
    }

    vector<ll> tmp;

    for (ll a = 2; tmp.size() < n; a++) {
        if (a % 2 == 0 || a % 3 == 0) tmp.push_back(a);
    }

    ll sum = accumulate(tmp.begin(), tmp.end(), 0ll);



//    if (sum % 6 == 0) {
//        print(tmp);
//        ret();
//    }


    ll add = sum % 6;

    if (add == 5) {
        tmp.erase(find(tmp.begin(), tmp.end(), 6 + 3));

        tmp.push_back(30000 - 2);

        print(tmp);
        ret();
    }

    if (add != 0) {
        ll fp = 6 + add;

        tmp.erase(find(tmp.begin(), tmp.end(), fp));
        tmp.push_back(30000);
    }
    print(tmp);


//    if (sum % 6 == 1) {
//
//        30000
//        ret();
//    }
//
//    __throw_runtime_error("konai");


}


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

int main(){
    string w;
    cin>>w;
    string t;
    int count=0;
    while(1){
        cin>>t;
        if(t=="END_OF_TEXT") break;
        else if(t==w) count++;
        else{
            int len=t.size();
            for(int i=0;i<len;i++){
                if(65<=t[i]&&t[i]<=90) t[i]+=32;
            }
            if(t==w) count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;
string A, B, C;

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

  cin >> N;
  cin >> A >> B >> C;

  int ans = 0;
  for (int i = 0; i < N; ++i) {
      if (A[i] == B[i] && B[i] == C[i]) {
          ans += 0;
      } else if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) {
          ans += 2;
      } else {
          ans += 1;
      }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
typedef long long LL;
typedef pair<int,int> pii;


void run_case() {
    LL n, k; cin >> n >> k;
    if(n < k) cout << min(abs(n-k), n);
    else {
        LL tmp = n%k;
        cout << min(tmp, abs(tmp-k));
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(10);
    run_case();
    cout.flush();
    return 0;
}


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

int main(void){
    int a, b;
    char buf[256];

    while(scanf("%d %d", &a, &b) != EOF) {
        sprintf(buf, "%d", a+b);
        printf("%d\n", strlen(buf));
    }
	return(0);
}

Measured memory_bytes: 1752
n = int(input())
t = []
p = [0, 0, 0]
while(n):
    a, b, c = input().split(' ')
    t.append([int(a), int(b), int(c)])
    n-=1
for i in t:
    while(p[0] < i[0]):
        p[0]+=1
        if i[1] > p[1]:
            p[1]+=1
        elif i[2] > p[2]:
            p[2]+=1
        elif i[1] < p[1]:
            p[1]-=1
        elif i[2] < p[2]:
            p[2]-=1
        else:
            p[1]-=1
    if p != i:
        print('No')
        exit()
print('Yes')

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

int main(){
    int num1,num2,num3,S[13],H[13],C[13],D[13];
    for(int i=0; i<13; i++){
        S[i]=i+1;
    }
    for(int i=0; i<13; i++){
        H[i]=i+1;
    }
    for(int i=0; i<13; i++){
        C[i]=i+1;
    }
    for(int i=0; i<13; i++){
        D[i]=i+1;
    }
    char word;
    cin >> num1;
    for (int i=0; i<num1; i++){
        cin >> word;
        if(word=='S'){
            cin >> num2;
            num3=num2-1;
            S[num3]=100;
        }
        else if(word=='H'){
            cin >> num2;
            num3=num2-1;
            H[num3]=100;
        }
        else if(word=='C'){
            cin >> num2;
            num3=num2-1;
            C[num3]=100;
        }
        else if(word=='D'){
            cin >> num2;
            num3=num2-1;
            D[num3]=100;
        }
    }
    for(int j=0; j<13; j++){
        if(S[j]!=100){
            cout << 'S' << " " << S[j] << endl;
        }
    }
    for(int j=0; j<13; j++){
        if(H[j]!=100){
            cout << 'H' << " " << H[j] << endl;
        }
    }
    for(int j=0; j<13; j++){
        if(C[j]!=100){
            cout << 'C' << " " << C[j] << endl;
        }
    }
    for(int j=0; j<13; j++){
        if(D[j]!=100){
            cout << 'D' << " " << D[j] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
int a[maxn];
int pre[maxn], nxt[maxn];
int main(void)
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int t; scanf("%d", &t);
		a[t]++;
	}
	int ans = 0;
	for (int i = 1; i <= 1e5; ++i) {
		a[i] += a[i - 1];
		if (a[i] == n - a[i])
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(int argc, char** argv) {
    char input[2];
    int i;

    i = scanf("%s", input);                                                                                 
    for (i = 0; i < 2; i++) {                                                                               
        if (input[i] == '9') {                                                                              
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> p(n);
	vector<int> q(n);
	FOR(i, 0, n - 1) {
		v[i] = i + 1;
	}
	FOR(i, 0, n - 1) {
		cin >> p[i];
	}
	FOR(i, 0, n - 1) {
		cin >> q[i];
	}

	int cnt = 0;
	int a, b;
	do{
		if (v == p) {
			a = cnt;
		}
		if (v == q) {
			b = cnt;
		}
		cnt++;
	} while (next_permutation(ALL(v)));

	pv(abs(a-b))
	return(0);
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = []
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))

A = np.array(A)
min_A = np.min(A)
print(int(np.ceil(N/min_A) + 5 - 1))


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

using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), c(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
		c[a[i]]++;
	}
	ll ans = 0;
	rep (i, n) {
		ll sel;
		if (c[i] % 2) sel = c[i] * ((c[i] - 1) / 2);
		else sel = (c[i] / 2) * (c[i] - 1);
		ans += sel;
	}
	rep (i, n) cout << ans - c[a[i]] + 1 << endl;
	return 0;
}


Measured memory_bytes: 6320
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
double n,k;
double dp[100002];
double func(ll score)
{
	if(score>=k)
	{
		return 1.0;
	}
	if(dp[score]!=0.0)
	{
		return dp[score];
	}
	// cout<<"2 ";
	dp[score]=func(2*score)/2.0;
	return dp[score];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    double ans=0;
    for (int i = 1; i <=n; ++i)
    {
    	// cout<<1/n<<'\n';
    	// cout<<n<<" ";
    	ans+=func(i)/n;
    	// cout<<'\n';
    }
    cout<<fixed<<setprecision(15)<<ans<<'\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
#define ll long long int
#define ull unsigned long long int
#define inf LONG_MAX;
using namespace std;
ll dp[100005], h[100005],n,k;
int main()
{
    fast_io
    for(int i=2;i<=100000;i++)
        dp[i]=inf;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
            if(i+j<=n)
                dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 5116
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };

//turn, mass, money -> e;
double dp[51][5010];
int x, y, z;

int main(void)
{
	while(cin >> x >> y >> z && x)
	{
		memset(dp, 0, sizeof(dp));
		vector<P> events(y + 1);
		vector<int> roulette(x);
		readAll(roulette);

		int maxmoney = 0;
		for (int i = 0; i < z; i++)
		{
			int n, e, a;
			cin >> n >> e >> a;
			events[n] = P(e, a);
			if(e == 2)
				maxmoney += a;
		}

		dp[0][0] = 1.;

		double mag = 1.0 / (double)x;

		for (int i = 0; i <= y; i++)
		{
			for (int j = i; j < y; j++)
			{
				for (int k = 0; k <= maxmoney; k++)
				{
					double exp = dp[j][k] * mag;
					for (int l = 0; l < x; l++)
					{
						int next = min(j + roulette[l], y);
						int money = k;
						int ev = events[next].first;
						int value = events[next].second;
						if(ev != 0)
						{
							if(ev == 1)
							{
								next = min(next + value, y);
							}
							if(ev == 2)
							{
								money += value;
							}
							if(ev == 3)
							{
								money = max(0, money - value);
							}
						}
						dp[next][money] += exp;
						dp[j][k] = 0;
					}
				}
			}
		}

		double result = 0;
		for (int k = 0; k <= 5000; k++)
		{
			result += dp[y][k] * k;
		}

		cout << (int)result << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function to find special numbers 
void divisibilityCheck(int arr[], int n) 
{ 

	// Storing all array elements in a hash 
	// and finding maximum element in the array 
	unordered_set<int> s; 
	int max_ele = INT_MIN; 
	for (int i = 0; i < n; i++) { 
		s.insert(arr[i]); 

		// Update the maximum element of the array 
		max_ele = max(max_ele, arr[i]); 
	} 

	// Traversing the array elements and storing the array 
	// multiples that are present in s in res 
	unordered_set<int> res; 
	for (int i = 0; i < n; i++) { 

		// Check for non-zero values only 
		if (arr[i] != 0) { 

			// Checking the factors of current element 
			for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) { 

				// If current factor is already part 
				// of the array then store it 
				if (s.find(j) != s.end()) 
					res.insert(j); 
			} 
		} 
	} 

	// For non-distinct elmments 
	// To store the frequency of elements 
	unordered_map<int, int> mp; 
	for (int i = 0; i < n; i++) 
		mp[arr[i]]++; 

	unordered_map<int, int>::iterator it; 
	vector<int> ans; 
	for (it = mp.begin(); it != mp.end(); it++) { 

		// If frequency is at least 2 
		if (it->second >= 2) { 
			if (res.find(it->first) == res.end()) { 

				// If frequency is greater than 1 and 
				// the number is not divisible by 
				// any other number 
				int val = it->second; 

				// Then we push the element number of 
				// times it is present in the vector 
				while (val--) 
					ans.push_back(it->first); 
			} 
		} 

		// If frequency is greater than 1 and the number 
		// is divisible by any other number 
		if (res.find(it->first) != res.end()) { 
			int val = it->second; 

			// Then we push the element number of 
			// times it is present in the vector 
			while (val--) 
				ans.push_back(it->first); 
		} 
	} 

	// Print the elements that are divisible by 
	// at least one other element from the array 
	cout<<n-ans.size();
} 

// Driver code 
int main() 
{ 
	int n;
	cin>>n;
	int arr[n];
	int i;
	for(i=0;i<n;i++)
		cin>>arr[i];
	// int arr[] = { 2, 3, 8, 6, 9, 10 }; 
	// int n = sizeof(arr) / sizeof(arr[0]); 

	divisibilityCheck(arr, n); 

	return 0; 
} 


Measured memory_bytes: 30616
n, m = map(int,input().split())
xs = [0]*m
pre = [0]*m
for x in range(m):
    xs[x] = list(list(map(int,input().split())) + [x] + [x])
xs.sort()

skip = 0
for p in range(1,n+1):
    cnt = 1
    flag = 0
    for x in range(skip,len(xs)):
        if xs[x][0] <= p:
            xs[x][3] = cnt
            cnt += 1
            skip += 1
        else:
            flag = 1
        if flag:
            break


for x in sorted(xs, key=lambda x:x[2]):
    print('{0:06d}'.format(x[0]) + '{0:06d}'.format(x[3]))


Measured memory_bytes: 37056
#include <stdio.h>
int main() {
	int n;
	int tmp;
	int max = -1000001;
	int min = 1000001;
	long long int sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d",&tmp);
		if (max <= tmp) {
			max = tmp;
		}
		if (tmp <= min) {
			min = tmp;
		}
		sum += tmp;
	}
	printf("%d %d %lld\n", min, max, sum);
	
}


Measured memory_bytes: 2124
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n +1 - i):
        k = n - i - j
        total = 10000 * i + 5000 * j + 1000 * k
        if total == y:
            print(i, j, k)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int n; cin >> n;
    cout << pow(2, floor(log2(n))) << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <limits.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;



int main()
{
	int K, N;
	cin >> K >> N;
	vi A(N);
	for (auto& i : A) cin >> i;

	int max_dist = 0;
	for (int i = 0; i < N - 1; i++)
	{
		max_dist = max(max_dist, A[i+1] - A[i]);
	}
	max_dist = max(max_dist, K + A[0] - A[N-1]);

	int ans = K - max_dist;
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a<b && b<c){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}


Measured memory_bytes: 26108
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_SIZE_MAX		2005									// 最大サイズ
#define D_WAY_CNT		2										// 方向数
#define D_WAY_RIGHT		0										// 方向 - 右
#define D_WAY_DOWN		1										// 方向 - 下

// 内部変数
static FILE *szpFpI;											// 入力
static int siW, siH;											// 幅・高さ
static char sc2Mass[D_SIZE_MAX][D_SIZE_MAX];					// マス[高さ][幅]
static int si3LCnt[D_SIZE_MAX][D_SIZE_MAX][D_WAY_CNT];			// 光数[高さ][幅][方向]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大値 - 取得
int
fGetMax(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	if (piVal1 > piVal2) {
		return piVal1;
	}
	else {
		return piVal2;
	}
}

// 光数 - セット
int
fSetLCnt(
	int piPx					// <I> 位置X
	, int piPy					// <I> 位置Y
	, int piWay					// <I> 方向
	, int piMx					// <I> 移動方向X
	, int piMy					// <I> 移動方向Y
	, int piLCnt				// <I> 光数
)
{
	// 範囲チェック
	if (piPx >= siW) {
		return piLCnt;
	}
	if (piPy >= siH) {
		return piLCnt;
	}

	// セット済
	if (si3LCnt[piPy][piPx][piWay] > 0) {
		return piLCnt;
	}

	// マス
	if (sc2Mass[piPy][piPx] != '.') {
		return piLCnt;
	}

	// 光数 - セット
	si3LCnt[piPy][piPx][piWay] = fSetLCnt(piPx + piMx, piPy + piMy, piWay, piMx, piMy, piLCnt + 1);

	return si3LCnt[piPy][piPx][piWay];
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 幅・高さ - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siH, &siW);

	// マス - 取得
	for (i = 0; i < siH; i++) {
		fgets(sc2Mass[i], sizeof(sc2Mass[0]), szpFpI);
	}

	// 光数 - セット
	int liMax = 0;
	for (i = 0; i < siH; i++) {
		for (j = 0; j < siW; j++) {
			fSetLCnt(j, i, D_WAY_RIGHT, 1, 0, 0);
			fSetLCnt(j, i, D_WAY_DOWN, 0, 1, 0);
			liMax = fGetMax(liMax, si3LCnt[i][j][D_WAY_RIGHT] + si3LCnt[i][j][D_WAY_DOWN]);
		}
	}

	return liMax - 1;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si3LCnt, 0, sizeof(si3LCnt));						// 光数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
using namespace std;

template<typename T>
vector<T>base_conversion(T n,T base){
  vector<T>res;
  while(abs(n)>=1){
    T x=n%base;
    n/=base;
    if(x<0){
      x+=abs(base);//余りが負となるのを補正
      n++;//余りを調整したので,商を調整
    }
    res.push_back(x);
  }
  if(res.empty())res.push_back(0);
  reverse(res.begin(),res.end());
  return res;
}


void solve(){
  ll n;
  cin>>n;
  for(auto d:base_conversion<ll>(n,-2LL))cout<<d;
  
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
using namespace std;

struct node{
	int a,b,c,d;
};
int n,m,q;
node arr[55];
vector<int> vec;
int ans=0;

int cal(){
	int sum=0;
	for(int i=0;i<q;i++){
		if(vec[arr[i].b-1]-vec[arr[i].a-1]==arr[i].c)sum+=arr[i].d;
	}
	return sum;
}

void rec(int i,int j){
	if(i==n){
		ans=max(ans,cal());
		return; 
	}
	for(int k=j;k<=m;k++){
		vec.push_back(k);
		rec(i+1,k);
		vec.pop_back();
	}
}

int main(){
  	cin>>n>>m>>q;
  	for(int i=0;i<q;i++){
      	cin>>arr[i].a>>arr[i].b>>arr[i].c>>arr[i].d;
    }
    rec(0,1);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N = 2e5 + 5, mod = 2019;
const ll inf=2e9;
void solve(){
    string s;
    cin>>s;
    int n=s.length();
    int p=1;
    int a=0;
    map<int, int> mp;
    mp[0]++;
    ll ans = 0;
    for(int i=n-1; i>=0; i--){
        int j = s[i] - '0';
        a += j * p;
        a = a % mod;
        p *= 10;
        p = p % mod;
        ans += mp[a];
        mp[a]++;
    }
    cout<<ans<<endl;
}

int main(){
    //#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	//#endif
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3748
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')[0].split(' ').map(n => Number(n))
  let ans = 0
  for (let i = 1; i * input[0] < input[2] + 0.5; i++) {
    ans += input[1]
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9420
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 0
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

// 00:28:00h
vector <vector <vector <double> > > dp (301, vector <vector <double> > (301, 
        vector <double> (301, -1)));

double solve (int a0, int a1, int a2, int a3)
{
    if (a1 < 0 || a2 < 0 || a3 < 0)
        return 0;
    if (a1 == 0 && a2 == 0 && a3 == 0)
        return 0;
    if (dp[a1][a2][a3] > -0.5)
        return dp[a1][a2][a3];
    double sum = a1 + a2 + a3;
    double p = (a3/sum)*solve (a0, a1, a2+1, a3-1);
    p += (a2/sum)*solve (a0, a1+1, a2-1, a3);
    p += (a1/sum)*solve (a0+1, a1-1, a2, a3);
    dd printf ("a0:% 3d, a1:% 3d, a2:% 3d, a3:% 3d, pb:% 3.4lf, ", a0, a1, a2, a3, p);
    p += (sum + a0)/sum;
    dd printf ("pa:% 3.4lf\n", p);
    return dp[a1][a2][a3] = p;
}

int main ()
{
    FASTIO;
    int i, j, n;
    cin >> n;
    vi A (4);
    for (i = 0; i < n; i++)
    {
        cin >> j;
        A[j]++;
    }
    dd trav (a, A)
        cout << a << ' ';
    dd cout << endl;
    printf ("%.10lf\n", solve (A[0], A[1], A[2], A[3]));

    return 0;
}



Measured memory_bytes: 217088
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rank = [0]*(n+1)

	def find(self, x):
		if self.root[x] < 0:
			return x
		else:
			self.root[x] = self.find(self.root[x])
			return self.root[x]
			
	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return 0
		elif self.rank[x] > self.rank[y]:
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

	def isSame(self, x, y):
		return self.find(x) == self.find(y) or x==y
		
def solve():
	n,m,*l=map(int,open(0).read().split())
	p=l[:n];xy=l[n:]
	ids=[0]*(n+1)
	for i in range(n):ids[p[i]]=i+1
	uf=UnionFind(n)
	for x,y in zip(*[iter(xy)]*2):uf.unite(x,y)
	print(sum(uf.isSame(i,ids[i])for i in range(1,n+1)))
	
if __name__=="__main__":solve()

Measured memory_bytes: 35324