akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;
vector<int> g[111111];
int ans[111111] = {};
bool used[111111] = {};

signed main() {
    INCANT;
    int n, m, a, b, now;
    cin>>n>>m;
    for (int i = 0; i < m; i++) {
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans[1] = 0;
    used[1] = true;
    queue<int> q;
    q.push(1);
    while (!q.empty()) {
        now = q.front();
        q.pop();
        for (int p: g[now]) {
            if (!used[p]) {
                ans[p] = now;
                used[p] = true;
                q.push(p);
            }
        }
    }
    cout<<"Yes"<<endl;
    for (int i = 2; i <= n; i++) {
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
int main(){

  int sub[30]={0},i,log,no;

  for(i = 0; i < 28; i++){

    scanf("%d",&log);

    sub[log-1]=1;
    
  }
  
  for(i = 0; i < 30; i++){

    if(sub[i] == 0){

      printf("%d\n",i+1);

    }
    
  }

  return 0;
  
}

Measured memory_bytes: 596
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    if 0 in A:
        print(0)
        return

    mul = 1
    for a in A:
        mul *= a

        if mul > 1e18:
            print(-1)
            return

    print(mul)


main()

Measured memory_bytes: 21592
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String o = sc.next();
    String e = sc.next();

    if (o.length() == e.length()) {
      for (int i = 0; i < o.length(); i++) {
        System.out.print(o.charAt(i)+""+e.charAt(i));
      }
      System.out.println();
    } else if (o.length() - e.length() == 1) {
      for (int i = 0; i < e.length(); i++) {
        System.out.print(o.charAt(i)+""+e.charAt(i));
      }
      System.out.println(o.charAt(o.length()-1));
    }

  }

}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAX 2010
using namespace std;
int nums[MAX]={0};
int main(){
	int n,x,y;
	scanf("%d %d %d",&n,&x,&y);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int dis= abs(x-i)+abs(y-j)+1;
			dis=min(dis,j-i);
			nums[dis]+=1;
		}
	}
	for(int i=1;i<=n-1;i++){
		printf("%d\n",nums[i]);
	}
	return 0;
}

Measured memory_bytes: 3816
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <utility>
#include <cmath>
#include <stdlib.h> 
#include <stdio.h>
#include <iterator>
#include <chrono>
#include <iomanip>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <deque>
#include <stack>
#include <queue>
#include <fstream>
#include <limits>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <sstream>
#include <random>
#include <cassert>

using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n ; j++)
int INF = 1e9 + 7;


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

	long long x, k, d;
	cin >> x >> k >> d;
	if (x < 0) x = -x;
	if (x == 0) {
		if (k % 2 == 0) cout << 0;
		else cout << d;
		return 0;	
	}

	// determine if k * d > x
	if ((log(k) + log(d)) >= log(x)) {
		int steps = x / d;
		if (k % 2 == steps % 2) cout << abs(x % d);
		else cout << abs((x % d) - d);
	}
	else cout << x - k * d;
}




/*
C:\Users\User\Desktop\comp_programming\final_straw_after_this_im_switching_to_vs_code\final_straw_after_this_im_switching_to_vs_code.cpp
*/

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef double db;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define P 998244353
#define M 400000
int n, A, B; ll m;
int F[M], IF[M];

void gcd(int a,int b,int &x,int &y) {
  if(b==0){x=1,y=0;return;}
  gcd(b,a%b,y,x),y-=a/b*x;
}
int inv(int n) {
  int x,y;gcd(n,P,x,y);
  if(x<0)x+=P;return x;
}

int C(int n, int k) {
	return (ll)F[n]*IF[k]%P*IF[n-k]%P;
}

int main() {
	F[0]=1;for(int i=1;i<M;i++)F[i]=(ll)F[i-1]*i%P;
	IF[M-1]=inv(F[M-1]);for(int i=M-1;i;i--)IF[i-1]=(ll)IF[i]*i%P;
	cin >> n >> A >> B >> m;
	int S = 0;
	for (int i = 0; i <= n; i ++) {
		ll r = m-(ll)i*A;
		if (r < 0) continue;
		if (r%B != 0) continue;
		r /= B;
		if (r > n) continue;
		S = (S+(ll)C(n, i)*C(n, r)%P)%P;
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

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

    int aa = a%3;
    int bb = b%3;

    if(aa==0 || bb==0 || aa+bb==3){
        printf("Possible");
    }else{
        printf("Impossible");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 2000005;

int t[MAX_N];
int n,T;

int main()
{
	scanf("%d%d",&n,&T);
	rep(i,n){
		scanf("%d",&t[i]);
	}
    int nt=0;
    int to=t[0]+T;
    rep(i,n-1){
        if(to < t[i+1]){
            nt += t[i+1] - to;
        }
        to = t[i+1] + T;
	}
    printf("%d\n",t[n-1] + T - t[0] - nt);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=300000;
int a[maxn],b[maxn],sum[maxn];
bool cmp(const int &A,const int &B){
	return A>B;
}
int chkmin(int &A,const int &B){
	if(A<=B)
	{
		return 1;
	}
	else
	{
		A = B;
		return 0;
	}
	
}
int main(){
	int n;
	scanf("%d",&n);
	for(int k=1;k<=n;k++){
		scanf("%d",&a[k]);
		b[a[k]]++;
	}
	sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+b[i];
	for(int k=1;k<=n;k++){
		int ans=n/k;
		int left = 0,right = k-1;
		while(left<=right)
		{
			int mid = (left+right)/2;
			if(mid==0||(sum[mid]-sum[mid-1])>=(n-sum[mid])/(k-mid))
			{
				chkmin(ans,(n-sum[mid])/(k-mid));
				left = mid+1;
			}
			else
			{
				chkmin(ans,(n-sum[mid])/(k-mid));
				right = mid-1;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4352
N,P = map(int,input().split())

S = input()


if P not in [2,5]:

    dic = {}
    dic[0] = 1
    now = 0
    ans = 0

    loop = 0
    for i in range(N-1,-1,-1):
        now += int(S[i]) * pow(10,loop,P)
        now %= P
        if now in dic:
            ans += dic[now]
            dic[now] += 1
        else:
            dic[now] = 1
        loop += 1

    print (ans)

elif P == 2:

    ans = 0
    for i in range(N):

        if int(S[i]) % 2 == 0:
            ans += i+1

    print (ans)

else:

    ans = 0

    for i in range(N):

        if int(S[i]) % 5 == 0:
            ans += i+1

    print (ans)
    


Measured memory_bytes: 42700
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
    ll N;
    cin >> N;
    vl cnt(N+1,0);
    FOR(i,1,N+1){
        ll k=i;
        while(k<=N){
            cnt[k]++;
            k+=i;
        }
    }
    ll ans=0;
    FOR(i,1,N+1){
        ans+=cnt[i]*i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81400
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a[100005];
void solve() {
	int n;
	cin>>n;
	fr(i,1,n)
		cin>>a[i];
	int mini=*min_element(a+1,a+n+1),maxi=*max_element(a+1,a+n+1);
	if(mini==maxi&&(n-1==mini||n/2>=mini)) {
		cout<<"Yes"<<endl;
		return;
	} else if(mini+1==maxi) {
		int cnt=0;
		fr(i,1,n)
			if(a[i]==mini)
				cnt++;
		int distinct=cnt+(n-cnt)/2;
		if(distinct<maxi||maxi<1+cnt||cnt==n-1) {
			cout<<"No"<<endl;
		} else
			cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0)
        cout << fixed << setprecision(10) << (0.5) << endl;
    else
        cout << fixed << setprecision(10) << (double)(n + 1) / (double)(2 * n) << endl;

    return 0;
}

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

main(){
  string S,T;
  cin >> S >> T;
  
  int i,ans=0;
  for(i=0;i<3;i++){
    if (S[i]==T[i]){
      ans++;
    }
  }
  cout << ans << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,X,Y; cin>>N>>X>>Y;

    vector<int> K(N-1,0);
    X--; Y--;

    rep(i,0,N){
        rep(j,i+1,N){
            int idx=min(j-i,abs(i-X)+abs(j-Y)+1)-1;
            K.at(idx)++;
        }
    }

    for(auto k:K) cout<<k<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void ABC113C()
{
	string str1, str2;
	cin >> str1 >> str2;

	int N = stoi(str1);
	int M = stoi(str2);

	std::vector<std::vector<int> > yearVec(N);
	std::vector<int> pVec(M);
	std::vector<int> yVec(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> str1 >> str2;
		int p = stoi(str1);
		int y = stoi(str2);
		pVec[i] = p;
		yVec[i] = y;
		yearVec[p-1].push_back(y);
	}
	for (int i = 0; i < N; ++i)
	{
		sort(yearVec[i].begin(), yearVec[i].end());
	}

	for (int i = 0; i < M; ++i)
	{
		int p = pVec[i];
		int yOrder = std::distance(yearVec[p-1].cbegin(), std::lower_bound(yearVec[p-1].cbegin(), yearVec[p-1].cend(), yVec[i])) + 1;
		stringstream ss;
		ss << setw(6) << setfill('0') << p << setw(6) << setfill('0') << yOrder;
		cout << ss.str() << endl;
	}

}

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


Measured memory_bytes: 8704
n,a,b = map(int,input().split())
count = 0

for i in range(1,n+1):
    if(i < 10):
        if(a <= i <= b):
            count += i
    else:
        s = str(i)
        ary = list(map(int,s))
        if(a <= sum(ary) <= b):
            count += i

print(count)

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool flg = false;
    for (int i=0; i<B; i++) {
        if ((A*i)%B == C){
            flg = true;
        }
    }
    if (flg) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

public class P
{
    public int a { get; set; }
    public int b { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ps = new P[n];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            ps[i] = new P { a = a, b = b };
        }
        var ans = getAns(ps, n);
        Console.WriteLine(ans);
    }
    static  long getAns (P[] ps , int n)
    {
        var ps2 = ps.OrderByDescending(x => x.a + x.b).ToArray();
        var ans = 0L;
        for (int i = 0; i < n; i++)
            if (i % 2 == 0) ans += ps2[i].a;
            else ans -= ps2[i].b;
        return ans;
    }
}

Measured memory_bytes: 26564
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 * What a trick prob!
 */
public class Main{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        static int MOD = 1000000007;
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
//            ArrayList<Integer>E[] = new ArrayList[n];
//            for (int i = 0; i < n; i++){
//                E[i] = new ArrayList<>();
//            }
//            for (int i = 0; i < n - 1; i++){
//                int u = in.nextInt() - 1;
//                int v = in.nextInt() - 1;
//                E[u].add(v);
//                E[v].add(u);
//            }
            int a[] = new int[n];
            for (int i = 0; i < n; i++){
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            long result = a[n - 1];
            int cnt = n - 2;
            int i = n - 2;
            while (cnt > 0){
                if (cnt >= 2){
                    result += 2 * a[i];
                }
                else{
                    result += a[i];
                }
                i--;
                cnt -= 2;
            }
            out.println(result);
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 56196
#include<bits/stdc++.h>
using namespace std;
// 関節点、橋、lowlink
// lowlink
typedef pair<int,int> mypair;
void dfs(int v,int p,int &k,vector<int> &ord,vector<int> &low,vector<bool> &used,vector<vector<int> > &g,vector<mypair> &bridge,vector<int> &articulation){
	used[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	bool isarticulation = false;
	int cnt = 0;
	for(int i=0;i<g[v].size();i++){
		if(!used[g[v][i]]){
			cnt++;
			dfs(g[v][i],v,k,ord,low,used,g,bridge,articulation);
			low[v] = min(low[v],low[g[v][i]]);
			if(~p&&ord[v]<=low[g[v][i]])isarticulation = true;
			if(ord[v]<low[g[v][i]])bridge.push_back( mypair( min(v,g[v][i]), max(v,g[v][i]) ) ) ;
		}
		else if(g[v][i] != p){
			low[v] = min(low[v],ord[g[v][i]]);
		}
	}
	if(p==-1 &&cnt>1)isarticulation=true;
	if(isarticulation)articulation.push_back(v);
}

int main(){
	int v,e;
	cin>>v>>e;
	vector<vector<int> >g(v);
	vector<int> ord(v),low(v);
	vector<int> art;
	vector<mypair> bridge;
	vector<bool> used(v,false);
	int k=0;

	for(int i=0;i<e;i++){
	int s,t;
	cin>>s>>t;
	g[s].push_back(t);
	g[t].push_back(s);
	}

	for(int i=0;i<v;i++)if(!used[i])dfs(i,-1,k,ord,low,used,g,bridge,art);
	sort(art.begin(),art.end());
	sort(bridge.begin(),bridge.end());
	//関節点
	//cout<<art.size()<<endl;
	//for(int i=0;i<art.size();i++)cout<<art[i]<<endl;	
	//橋
	//cout<<bridge.size()<<endl;
	for(int i=0;i<bridge.size();i++)cout<<bridge[i].first<<' '<<bridge[i].second<<endl;
	return 0;
}



Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,a,b,c,d,x;
int main()
{
  for(cin>>n>>d>>x;i<n;i++){
    cin>>a;
    for(j=0;j<d;j+=a)c++;
  }
  cout<<c+x;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y,a,b,c,d,e,f;
    while (true){
    cin >> x;
    if(x==0){
        break;
    }
    a=(1000-x)/500;
    b=(1000-x-500*a)/100;
    c=(1000-x-500*a-100*b)/50;
    d=(1000-x-500*a-100*b-50*c)/10;
    e=(1000-x-500*a-100*b-50*c-10*d)/5;
    f=1000-x-500*a-100*b-50*c-10*d-5*e;
    y=a+b+c+d+e+f;
    

    
        cout <<y <<endl;
    }
    
}


Measured memory_bytes: 2988
N, K = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

dp = Array.new(N, Float::INFINITY)

dp[0] = 0

for i in 0..N-2
  for j in 1..[N-i-1, K].min
    c = dp[i] + (h[i+j] - h[i]).abs
    dp[i+j] = c if c < dp[i+j]
  end
end

puts dp.last


Measured memory_bytes: 12036
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

class cake {
public:
  int b, w, d;
  cake(int birth, int width, int depth)
    : b(birth), w(width), d(depth) {}
  bool operator<(const cake& r) const {
    if (b != r.b) return b < r.b;
    else return w*d < r.w*r.d;
  }
};

bool compare_area(const cake& r, const cake& l){
  return r.w*r.d < l.w*l.d;
}

int main(){
  vector<cake> C;
  int n, w, d, p, s;
  while(cin >> n >> w >> d && w && d){
    C.clear();
    C.push_back(cake(0, w, d));
    rep(i, n){
      cin >> p >> s;
      p--;
      sort(C.begin(), C.end());
      s = s % (C[p].w + C[p].d);
      if (s < C[p].w){
        C.push_back(cake(i+1, C[p].w-s, C[p].d));
        C[p] = cake(i+1, s, C[p].d);
      }
      else{
        s -= C[p].w;
        C.push_back(cake(i+1, C[p].w, C[p].d-s));
        C[p] = cake(i+1, C[p].w, s);
      }
    }
    sort(C.begin(), C.end(), compare_area);
    rep(i, n) cout << C[i].w*C[i].d << ' ';
    cout << C[n].w*C[n].d << endl;
  }
  
  return 0;
}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, m;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	
	set<int> mem; mem.insert(0);
	set<int> ds;

	for(int i=1; i<=m; i++){
		int j = n-i+1; // dist = j-i = n-2i+1
		if(n%2==0 && n-2*i+1<=n/2) j--;

		if(j<1 || n<j) return 24;
		if(mem.find(i-j) != mem.end()) return 42;
		if(ds.find(i) != ds.end() || ds.find(j) != ds.end()) return 12;
		ds.insert(i); ds.insert(j);
		mem.insert(i-j); mem.insert(n-(i-j));

		cout<<i<<' '<<j<<'\n';
	}

	return 0;
}


Measured memory_bytes: 20416
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

const int maxn = 2e5 + 20;
int n;
int a[maxn];
int main() {
	string s;
	cin >> n;
	cin  >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') a[i + 1] = 0;
		else a[i + 1] = 1;
	}
	int l = 1, r = n;
	int ans = 0;
	while (l < r) {
		if (a[l] == 1 && a[r] == 0) swap(a[l], a[r]), ans++, l++, r--;
		else if (a[l] == 1) r--;
		else l++;
	}
	cout << ans;
}


Measured memory_bytes: 4528
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll dp[85] = {};
  dp[0] = 1000;
  REP(i, 1, n)
  {
    dp[i] = dp[i - 1];
    rep(j, i)
    {
      ll t = dp[j] / a[j];
      chmax(dp[i], t * a[i] + (dp[j] - a[j] * t));
    }
  }
  cout << dp[n - 1] << "\n";
}

int main()
{
  init_main();
  solve();
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	if (a > b) {
		cout << "Alice" << endl;
	} else if (a < b) {
		cout << "Bob" << endl;
	} else {
		cout << "Draw" << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int k,i=0;
    cin>>k;
    string s;
    cin>>s;
    while(i<s.size() && i<k)
    {
        cout<<s[i];
        i++;
    }
    if(i<s.size())
    {
        cout<<"..."<<endl;
    }
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    LL ans = 0;
    REP1 (i, N)
    {
        if (i % 3 == 0 or i % 5 == 0)
            continue;
        ans += i;
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

int n;
string a, b;

int main() {

	cin >> n >> a >> b;

	for (int i = n; i >= 0; i--) {
		if (a.substr(n - i) == b.substr(0, i))
			return !printf("%d\n", 2 * n - i);
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <array>

#include <cstdio>

void printArray(int A[], int N) {
  for (auto i = 0; i < N; i++) {
    std::cout << (i != 0 ? " " : "") << A[i];
  }
  std::cout << std::endl; 
}

void insersionSort(int A[], int N) {
  int v, j;
  //  for (auto i = 1; i < N - 1; i++) {
  for (auto i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    printArray(A, N);
  }
}

int main() {
  int N;
  std::cin >> N;

  std::array<int, 100> A;
  for (auto i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }

  printArray(A.data(), N);
  insersionSort(A.data(), N);
}



Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int A = io.nextInt();
		int B = io.nextInt();
		int C = io.nextInt();
		
		int ab = Math.abs(A-B);
		int bc = Math.abs(B-C);
		int ca = Math.abs(C-A);
		
		int ans = 0;
		if(A%2==1 || B%2==1 || C%2==1){
			System.out.println(0); return;
		}
		if(ab==0 && bc==0 && ca==0){
			System.out.println(-1); return;
		}
		while(ab%2==0 && bc%2==0 && ca%2==0){
			ab /= 2;
			bc /= 2;
			ca /= 2;
			ans ++;
		}
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 21972
import math
from functools import reduce,lru_cache

K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def calc_temp_2(k):
    temp_2 = 0
    for j in range(1,k):
        for l in range(j+1,k):
            temp_2 += gcd(k, j, l) * 2
        temp_2 += gcd(k,j)
    return temp_2

@lru_cache(maxsize=None)
def dp(k):
    if k == 1:
        return 1
    else:
        temp_1 = sum([gcd(k, i) for i in range(1,k)])
        temp_2 = calc_temp_2(k)
        return dp(k-1) + k + temp_1 * 3 + temp_2 * 3

print(dp(K))

Measured memory_bytes: 9772
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  ll tmp=k;
  ll ans=1;
  while((n/tmp)!=0){
    ans++;
    tmp*=k;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long l,r,d,i,count;
    scanf("%lld%lld%lld", &l,&r,&d);
    count=0;
    for(i=l;i<=r;i++){
        if(i%d==0){
            count++;
        }
    }
    printf("%lld\n", count);
}


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

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

Measured memory_bytes: 3628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int,int> T;
const int inf=20000000;
int dp[21][200001];
int s[200001];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<21;i++)dp[i][0]=0;
  for(int i=0;i<n;i++){cin>>s[i];
  
    for(int j=0;j<21;j++){
      dp[j][i+1]=dp[j][i];
      if(s[i]>>j&1)dp[j][i+1]++;
    }
  }
  ll res=0LL;
  for(int i=0;i<n;i++){
    int tmp=inf;
    for(int j=0;j<21;j++){
      int t2;
      t2=(upper_bound(dp[j]+(i+1),dp[j]+(n+1),dp[j][i+1])-lower_bound(dp[j]+(i+1),dp[j]+(n+1),dp[j][i+1]));
      
      if(!(s[i]>>j&1))
      {

        t2+=upper_bound(dp[j]+(i+1),dp[j]+(n+1),dp[j][i+1]+1)-lower_bound(dp[j]+(i+1),dp[j]+(n+1),dp[j][i+1]+1);
      }
      tmp=min(tmp,t2);        
    }
    res+=(ll)tmp;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    set<int> kgm;
    int n, i, d;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> d;
        kgm.insert(d);
    }
    cout << kgm.size() << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long int n,k,min;
    cin>>n>>k;
    if(n%k==0){
    	cout<<0;
	}
	else{
		n%=k;
		do{
	    	min=n;
	    	n=abs(n-k);
		}while(n<min);
		cout<<min;
	}
    
//system("pause");
return 0;

}


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

int main() {
	int N, L[110];
	cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> L[i];
    }

    int res = 0;
    for (int i = 0; i < N-2; ++i){
        for (int j = i+1; j < N-1; ++j){
            for (int k = j+1; k < N; ++k){
                int a = L[i], b = L[j], c = L[k];
                if (a != b && b != c && c != a && a+b>c && b+c>a && c+a>b){
                    res++;
                }
            }   
        }
    }

    cout << res << endl; 
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; --a[i]; }
	int answer = 0;
	for(int i = 0; i < n; ++i){
		if(a[i] >= i){ continue; }
		if(a[a[i]] == i){ ++answer; }
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n,k; cin>>n>>k;
    int ans=1;
    rep(i,n){
        if(ans<k){
            ans*=2;
        }else{
            ans+=k;
        }
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int main(){

    float r;
    cin >> r;
    float ans;

    ans = 2*r*3.14159;

    cout << ans;

	return 0;
}

Measured memory_bytes: 3780
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *X = map(int, read().split())

    ans = INF
    for p in range(1, 101):
        tmp = 0
        for x in X:
            tmp += (x - p) ** 2
        if ans > tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 63484
// AOJ 2218: K Poker
// 2017.9.23 bal4u@uu
// ?????????????????????????????\????????????????????????????????????????????????
// 2017.11.22

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int d, s; } T;	// ??????????????± d:?????° s:?????????
T card[5];
int base[4][14];	// ?????¬???????????±
int rate[9];		// ??????????????±

int dcnt[14];		// ????????°????????????????????????
int scnt[4];		// ????????????????????????????????????
int tr['Z'];		// ????????¨

int cmp(T *a, T *b) { return a->d - b->d; }

int calc()
{
	int i, f, ans = 0;

	// ?????¬???
	for (i = 0; i < 5; i++)	ans += base[card[i].s][card[i].d];

	// ????????????????????¬????????????????????\
	if (card[0].d == 1) {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[8];
			if (card[i].s != card[0].s || card[i].d != 9+i) break;
		}
	}

	// ????????¬????????????????????\
//	if (card[0].d != 1) {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[7];
			if (card[i].s != card[0].s || card[i].d != card[0].d+i) break;
		}
//	}

	// ??????????????????
	for (i = 1; i <= 13; i++) if (dcnt[i] == 4) return ans * rate[6];

	// ???????????????
	f = 0;
	for (i = 1; i <= 13; i++) {
		if      (dcnt[i] == 3) f |= 1;
		else if (dcnt[i] == 2) f |= 2;
	}
	if (f == 3) return ans * rate[5];

	// ??????????????\
	for (i = 0; i < 4; i++) if (scnt[i] == 5) return ans * rate[4];

	// ????????¬??????
	if (card[0].d == 1) {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[3];
			if (card[i].d != 9+i) break;
		}
	}
//	else {
		for (i = 1; ; i++) {
			if (i == 5) return ans * rate[3];
			if (card[i].d != card[0].d+i) break;
		}
//	}

	// ??????????????????
	for (i = 1; i <= 13; i++) if (dcnt[i] == 3) return ans * rate[2];

	// ???????????¢ or ???????????¢
	f = 0;
	for (i = 1; i <= 13; i++) if (dcnt[i] == 2) f++;
	if (f == 2) return ans * rate[1];
	if (f == 1) return ans * rate[0];

	// ??????
	return 0;
}

char buf[200], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, j;
	int cno = 0;

	tr['S'] = 0, tr['C'] = 1,  tr['H'] = 2,  tr['D'] = 3;
	for (i = 2; i <= 9; i++) tr[i+'0'] = i;
	tr['A'] = 1, tr['T'] = 10, tr['J'] = 11, tr['Q'] = 12, tr['K'] = 13;

	while (fgets(p=buf, 10, stdin) != NULL) {
		n = getint();
		if (cno++) putchar('\n');		// ???????????±??????????????????

		for (i = 0; i < 4; i++) {
			fgets(p=buf, 200, stdin);
			for (j = 0; j < 13; j++) base[i][j+1] = getint(), p++;
		}
		fgets(p=buf, 200, stdin);
		for (i = 0; i < 9; i++) rate[i] = getint(), p++;
		while (n-- > 0) {
			fgets(p=buf, 200, stdin);
			for (i = 0; i < 5; i++) {	// ??????????????±
				card[i].d = tr[*p++], card[i].s = tr[*p], p += 2;
			}
			for (i = 0; i < 4; i++) qsort(card, 5, sizeof(T), cmp);  // ?????°??§???????????????
			memset(dcnt, 0, sizeof(dcnt)), memset(scnt, 0, sizeof(scnt));
			for (i = 0; i < 5; i++) {
				dcnt[card[i].d]++;		// ???????????°????????°???????¨?
				scnt[card[i].s]++;		// ???????????????????????°???????¨?
			}
			printf("%d\n", calc());
		}
	}
	return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    ll n; cin >> n;
    
    for(ll h=1; h<=3500; h++){
        for(ll w=1; w<=3500; w++){
            ll num = n*h*w;
            ll den = 4*h*w - n*w - n*h;
            if(den>0 && num%den==0){
                cout << h <<" "<< w <<" "<< num/den << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll N,X;
    cin >> N >> X;
    vector<ll> x(N);
    vector<ll> diff(N);
    ll min=1000000000;
    for(int i=0; i<N; i++){
        cin >> x.at(i);
        diff.at(i)=llabs(X-x.at(i));
        if(min>diff.at(i)){
            min=diff.at(i);
        }
    }
    
    int judge=0;
    for(int i=min; i>=1; i--){
        for(int j=0; j<N; j++){
            if(diff.at(j)%i!=0){
                judge=1;
                break;
            }
        }
        if(judge==0){
            cout << i << endl;
            break;
        }
        judge=0;
    }
}

Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const long long INF = 1e18;
using ll = long long;

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

struct Edge {
  ll to;
  ll cost;
};

using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

/* dijkstra(G,s,dis)
    入力：グラフ G, 開始点 s, 距離を格納する dis
    計算量：O(|E|log|V|)
    副作用：dis が書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<ll> &dis) {
  int N = G.size();
  dis.resize(N, INF);
  priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
  dis[s] = 0;
  pq.emplace(dis[s], s);
  while (!pq.empty()) {
    P p = pq.top();
    pq.pop();
    int v = p.second;
    if (dis[v] < p.first) {  // 最短距離で無ければ無視
      continue;
    }
    for (auto &e : G[v]) {
      if (dis[e.to] > dis[v] + e.cost) {  // 最短距離候補なら priority_queue に追加
        dis[e.to] = dis[v] + e.cost;
        pq.emplace(dis[e.to], e.to);
      }
    }
  }
}

int main() {
  ll V, E, r;
  cin >> V >> E >> r;

  Graph g;
  g.assign(V, vector<Edge>());  // numV点分の空要素を作成

  for (int i = 0; i < E; ++i) {
    ll s, t, d;
    cin >> s >> t >> d;
    Edge e = {t, d};
    g[s].emplace_back(e);
  }

  vector<ll> dis;

  dijkstra(g, r, dis);

  // for (auto hoge : g.L) {
  //   for (auto h : hoge) {
  //     cout << h.first << ", " << h.second << endl;
  //   }
  // }
  for (auto d : dis) {
    if (d == INF) {
      cout << "INF" << endl;
      continue;
    }
    cout << d << endl;
  }

  return 0;
}



Measured memory_bytes: 19528
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

// a^b
template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % 11;
    else
        return (tmp * tmp) % 11;
}

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

    string s;
    while (cin >> s, s != "0")
    {
        int n = s.length();
        vector<int> v(n + 1, 0);
        ll res = 0;
        map<ll, ll> mp;
        mp[0]++;
        for (int i = n - 1; i >= 0; i--)
        {
            v[i] = v[i + 1];
            v[i] += (s[i] - '0') * mypow(10, n - 1 - i);
            v[i] %= 11;

            if (s[i] != '0')
            {
                res += mp[v[i]];
            }
            mp[v[i]]++;
        }
        cout << res << endl;
    }
}



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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    int a, b;
    cin >> a >> b;
    cout << a/b << " " << a%b << " ";
    printf("%5f\n", (double)a/(double)b);
    return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int x, y; cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}


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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


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

    int count = 0;

    if (s[0] == 'R')count++;
    
    if (s[1] == 'R' && s[2]=='R') {
        count=count+2;
    }
    else if(s[1] == 'R' && s[2] != 'R'){
        count ++;

    }else if (s[1] != 'R' && s[2] != 'R' ){
       
    }
    else if (s[1] != 'R' && s[2] == 'R') {
        if (s[0] != 'R') count++;
    }
    
    std:: cout << count << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  float ans;
  if(n % 2 == 0) {
    ans = 0.50000000000000000000000;
    cout << ans << endl;
  }
  else {
    int odd = n / 2 + 1;
    ans = ((float)odd) / n;
    cout << ans << endl;
  }
}

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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<=(n);i++)

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int a,b;
    cin >> a >> b;
    if(a==1 && b==2 || b==1 && a==2) cout << 3 << endl;
    else if(a==1 && b==3 || a==3 && b==1) cout << 2 << endl;
    else if(a==2 && b==3 || a==3 && b==2) cout << 1 << endl;
    return 0;  
}



Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var S = Reader.String();
        int stack = 0, ans = 0;

        foreach (char c in S)
            if (c == 'S')
                stack++;
            else if (stack > 0)
                stack--;
            else
                ans++;

        ans += stack;

        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 4184