akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define P 998244353
#define M 200010

using namespace std;

typedef long long ll;

struct node {
    int x, y;
    node() {}
    node(int _1, int _2) {x = _1, y = _2;}
};

int n, D, S[1111][1111];

int A[2222][2222], B[2222][2222];

node X[M];

ll sqr(ll x) {
    return x * x;
}

ll getrg(int (*A)[2222], int l, int r, int u, int d) {
    if(l > r || u > d) return 0;
    int ans = A[r][d];
    if(l) ans -= A[l - 1][d];
    if(u) ans -= A[r][u - 1];
    if(l && u) ans += A[l - 1][u - 1];
    return ans;
}

bool check(ll x) {
    ll tmp1 = sqr(x / D), tmp2 = sqr(x / D + 1), tmp12 = (x / D) * (x / D + 1);
    memset(A, 0, sizeof A);
    memset(B, 0, sizeof B);
    for(int i = 0; i < D * 2; i++)
        for(int j = 0; j < D * 2; j++)
            if(S[i % D][j % D] > tmp2) return 0;
            else {if(S[i % D][j % D] > tmp12) B[i][j] = 1;if(S[i % D][j % D] > tmp1) A[i][j] = 1;}
    for(int i = 1; i < D * 2; i++) B[0][i] += B[0][i - 1], A[0][i] += A[0][i - 1], B[i][0] += B[i - 1][0], A[i][0] += A[i - 1][0];
    for(int i = 1; i < D * 2; i++)
        for(int j = 1; j < D * 2; j++) {
            A[i][j] += A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
            B[i][j] += B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1];
        }
    for(int i = D; i < D * 2; i++)
        for(int j = D; j < D * 2; j++) {
            int s = x % D;
            if(!getrg(B, i - D + 1, i - s, j - s + 1, j) && !getrg(B, i - s + 1, i, j - D + 1, j - s) && !getrg(A, i - D + 1, i - s, j - D + 1, j - s)) return 1;
        }
    return 0;
}

int main() {
    scanf("%d%d", &n, &D);
    for(int i = 1; i <= n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        X[i] = node(a, b);
        S[a % D][b % D]++;
    }
    int ans = 1e9 + 5;
    for(int l = 1, r = 1e9; l <= r; ) {
        int md = (l + r) / 2;
        if(check(md)) ans = md, r = md - 1;
        else l = md + 1;
    }
    printf("%d\n", ans - 1);
    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int h,w; cin >> h >> w;
  vector<string> c(h);
  rep(i,h) cin >> c[i];
  vector<string> out(2*h);

  for(int i = 0;i<h;i++) cout << c[i] << endl << c[i] << endl;
  
  return 0;
}


Measured memory_bytes: 3620
from itertools import combinations
import numpy as np
def main():
    n, m, x = map(int, input().split())
    lst = []
    for _ in range(n):
        tmp = list(map(int, input().split()))
        lst.append(tmp)
    
    bango = [i for i in range(n)]
    k = 1
    minkingaku = float('inf')
    flag = False
    while k <= n:
        combs = combinations(bango, k)
        for comb in combs:
            
            algo = np.zeros(m)
            kingaku = 0
            for c in comb:
                algo += np.array(lst[c][1:])
                kingaku += lst[c][0]
            
            if (algo >= x).all():
                flag = True
                if kingaku <= minkingaku:
                    minkingaku = kingaku
            

        k += 1
    if flag:
        print(minkingaku)
    else:
        print('-1')
main()

Measured memory_bytes: 27236
S = input()

ans = 0
for i in range(1, len(S) + 1):
    for j in range(len(S) + 1 - i):
        left = j - 1
        right = len(S) - j - i - 1
        edge = (2 ** max(0, left)) * (2 ** max(0, right))
        #print(int(S[j: j + i]) * (2 ** edge))
        ans += int(S[j:j + i]) * edge
print(ans)

Measured memory_bytes: 3060
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
cnt1=0
cnt2=0
for i in range(n):
  if arr[i]>=0:
    cnt1+=1
  if arr[i]<=0:
    cnt2+=1
if cnt1==n:
  ans=-arr[0]+sum(arr[1:])
  print(ans)
  tmp=arr[0]
  for i in range(2,n):
    print(tmp,arr[i])
    tmp=tmp-arr[i]
  print(arr[1],tmp)
elif cnt2==n:
  ans=arr[-1]
  for i in range(n-1):
    ans+=abs(arr[i])
  print(ans)
  tmp=arr[-1]
  for i in range(n-1):
    print(tmp,arr[i])
    tmp=tmp-arr[i]
else:
  pos=0
  for i in range(n-1):
    if arr[i]*arr[i+1]<=0:
      pos=i
      break
  pos=pos+1
  ans=0
  for i in range(n):
    ans+=abs(arr[i])
  print(ans)
  for i in range(pos+1,n):
    print(arr[0],arr[i])
    arr[0]=arr[0]-arr[i]
  for i in range(pos):
    print(arr[pos],arr[i])
    arr[pos]=arr[pos]-arr[i]

Measured memory_bytes: 61196
#include <stdio.h>

int main(){
  int x,y;
  scanf("%d %d",&x,&y);

  int i,flag=0;
  for(i=0;i<=x;i++){
    if(y-2*i==4*(x-i)){
      flag=1;
      break;
    }
  }

  if(flag==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2084
#include <cstdio>
#include <iostream>
#include <unordered_map>
#include <vector>

int main()
{
    int N;
    scanf("%d", &N);
    std::unordered_map<int, int> dict;
    int max = 0;
    int daburi = 0;
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (dict.find(tmp) == dict.end()) {
            dict[tmp] = 1;
        } else {
            dict.at(tmp) = 1 + dict.at(tmp);
        }
    }
    //    std::cout << "max " << dict.at(1) << std::endl;
    for (auto itr = dict.begin(); itr != dict.end(); ++itr) {
        daburi += itr->second - 1;
        max = std::max(max, itr->second);
        //       std::cout << itr->second << std::endl;
    }
    //  std::cout << "max " << max << std::endl;

    int ans = N - 2 * ((daburi + 1) / 2);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 4388
//
//  main.cpp
//  AGC029
//
//  Created by Hoshikawa Hiroaki on 2019/03/16.
//  Copyright © 2019年 Hoshikawa Hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    long place = 0;
    long count=0;
    long l=s.size();
    for (long i=0; i<l; i++) {
        if (s[i]=='W') {
            count+=i-place;
            place++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
bool vis[200001];
int ans[200001];
int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    int m = 2*n-1;
    if(x == 1 || x == m) printf("No\n");
    else{
        printf("Yes\n");
        if(n == 2){
            printf("1 2 3\n");
        }
        else{
            int mid = n;
            if(x == 2){
                ans[mid-1] = x+1;
                ans[mid] = x-1;
                ans[mid+1] = x;
                ans[mid+2] = x+2;
                vis[x-1] = vis[x] = vis[x+1] = vis[x+2] = 1;
            }
            else{
                ans[mid-1] = x-1;
                ans[mid] = x;
                ans[mid+1] = x+1;
                ans[mid+2] = x-2;
                vis[x-2] = vis[x-1] = vis[x] = vis[x+1] = 1;
            }

            int j = 1;
            for(int i=1;i<=m;i++){
                if(ans[i] != 0) continue;
                while(vis[j]) j++;
                vis[j] = 1;
                ans[i] = j;
            }
            for(int i=1;i<=m;i++) printf("%d ", ans[i]);
        }
    }
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <ctype.h>
int main(void){
	char a;
	
	while(1){
		scanf("%c",&a);
		if(a == '\n')break;
		if(a == tolower(a)){
			printf("%c",(char)toupper(a));
		}else{
			printf("%c",(char)tolower(a));
		}
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 524
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    count = 0
    ans = 0
    for a in input().rstrip().split(" "):
        a = int(a)
        if a == count + 1:
            count+= 1
        else:
            ans += 1

    if count == 0:
        print("-1")
    else:
        print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 82828
input = readlines()
# a, b = input.shift().chomp.split("\s").map{|x| x.to_i}

s = input.shift().chomp.split('')
t = input.shift().chomp.split('')

cnt = 0

s.each_with_index do |ws, i|
  cnt += 1 if ws == t[i]
end

puts cnt


Measured memory_bytes: 14388
while True:
    (H,W) = [int(x) for x in input().split()]
    if H == W == 0:
     break

    for h in range(H):
     for w in range(W):
      if h == 0 or h == H - 1:
       print("#", end="")
       if w == W - 1:
        print()
        break
      elif w == 0:
       print("#", end="")
      elif not w == 0 and not w == W - 1:
       print(".", end="")

      if w == W - 1:
       print("#")
       break

    print()

Measured memory_bytes: 6808
#include<iostream>
using namespace std;
int main(){

int a=0;
int b=0;
int c=0;

int amari[100000];

int ok=0;
int out=0;

int i=0;
int j=0;

cin>>a>>b>>c; 

for(i=1;i>0;i++){
        
	
	
	if(a*i%b==c){
		ok=1;
		break;
	}
	amari[i]=a*i%b;
	for(j=0;j<i;j++){
	if(amari[j]==amari[i]){
		out=1;
		break;
	}
	}
	if(out==1)break;

}

if(ok==1)cout<<"YES";
if(ok==0)cout<<"NO";

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll N, M;
    cin >> N >> M;

    for (int i = M/N; i >= 1; i--) {
        if (M % i == 0) {
            cout << i << endl;
            return;
        }
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000000;
ll dp[N];
ll h[N];
const int mx=1000000;
int main(){
    ll n;cin>>n;
   
     for(int i=0;i<n;i++){
        cin>>h[i];dp[i]=mx;
    }dp[0]=0;
     for(int i=1;i<n;i++){
       if(i==1){
           dp[i]=abs(h[i]-h[i-1]);
       }else{
           dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
       }
    }cout<<dp[n-1];
}

Measured memory_bytes: 5136
"use strict"

function main(input) {
  input = input.split('\n')
  const S = input[0]
  const K = parseInt(input[1], 10)

  let res = S.search(/[^1]+/)
  if (res >= 0 && res <= K - 1) console.log(S[res])
  else {
    console.log(1)
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

const int N = 210;

int n, x[N];
vector<int> dif;
int ans;
// for bipartite matching
vector<int> ver[2];
vector<int> g[N];
bool check[N];
int mx[N], my[N];

bool isprime(int x) {
	for (int i = 2; i * i <= x; ++i) if (x % i == 0) return false;
	return true;
}

bool dfs(int u) {
	if (!u) return true;
	for (int v : g[u]) if (!check[v]) {
		check[v] = 1;
		if (dfs(my[v])) {
			mx[u] = v; my[v] = u; return true;
		}
	}
	return false;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", x + i);
	for (int i = 1; i <= n; ++i) {
		if (!(i > 1 && x[i - 1] == x[i] - 1)) {
			dif.push_back(x[i]);
		}
		if (x[i + 1] != x[i] + 1) {
			dif.push_back(x[i] + 1);
		}
	}

	for (int i : dif) ver[i % 2].push_back(i);

	for (int i = 0; i < ver[0].size(); ++i) {
		for (int j = 0; j < ver[1].size(); ++j) {
			int dist = abs(ver[0][i] - ver[1][j]);
			if (dist <= 2) continue;
			if (isprime(dist)) {
				g[i + 1].push_back(j + 1);
			}
		}
	}

	// bipartite matching
	int sz = ver[0].size();
	int rem = sz, prev_rem = sz + 1;
	
	while(rem > 0 && rem < prev_rem) {
		prev_rem = rem;
		for (int i = 1; i <= sz; ++i) check[i] = false;
		for (int i = 1; i <= sz; ++i) if (!mx[i]) rem -= dfs(i);
	}

	for (int i = 1; i <= sz; ++i) if (mx[i]) ++ans;

	int v0 = ver[0].size() - ans;
	int v1 = ver[1].size() - ans;

	ans += 2 * (v0 / 2); v0 %= 2;
	ans += 2 * (v1 / 2); v1 %= 2;

	ans += (v0 == 1 && v1 == 1) * 3;

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

Measured memory_bytes: 256
def resolve():
    N = int(input())

    jobs = []
    for i in range(N):
        aa, bb = map(int, input().split())
        jobs.append([aa, bb])

    jobs.sort(key=lambda key: key[1])

    now = 0
    for job in jobs:
        now += job[0]
        limit = job[1]
        if now > limit:
            print('No')
            return

    print('Yes')


resolve()

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

using namespace std;
using ll = long long;
int N;

int main() {
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ll x = 1;
        while (i * (x + 1) <= N) { ++x; }

        ll tmp = (1 + x) * x / 2;
        ans += tmp * i;
    }
    cout << ans << endl;
}


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

using namespace std;

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

  string s;
  cin >> s;
  int ans = 0, n = s.size();
  for (int i = 0; i < n / 2; ++i) {
    ans += s[i] != s[n - i - 1];
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n, m;
	cin >> n >> m;
	V<int> s(m), c(m);
	REP(i, m) {
		cin >> s[i] >> c[i];
		s[i]--;
	}

	V<int> num(n, -1);
	REP(i, m) {
		if (num[s[i]] > 0 && num[s[i]] != c[i]) {
			col("-1");
			return 0;
		}
		num[s[i]] = c[i];
	}

	if (num[0] == 0 && n > 1) {
		col("-1");
		return 0;
	}
	if (num[0] == -1) {
		if (n == 1) {
			num[0] = 0;
		}
		else {
			num[0] = 1;
		}
	}

	RNG(i, 1, n) {
		if (num[i] == -1) {
			num[i] = 0;
		}
	}

	int ans = 0, x = 1;
	for (int i = n-1; i >= 0; i--) {
		ans += num[i] * x;
		x *= 10;
	}

	col(ans);
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N,ans=0;
  cin>>N;
  
  for(int i=1; i<=N; ++i){
    if(i%3!=0 && i%5!=0) ans+=i;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N=300010,mod=1e9+7;
long long ans=0;

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    
    //位运算每一位互不影响，同一位可以一起算
    //只有1与0进行异或时才得到1，因此这一位上1的数目乘0的数目就是异或为1的所有可能情况数
    for(int i=0;i<60;i++){
        long long x=0;
        for(int j=0;j<n;j++) if(a[j]>>i &1 ) x++;//统计每个数第i位的1
        long long now = x*(n-x) %mod;//每个数第i位的1的个数乘0的个数
        for(int j=0;j<i;j++) now = now*2%mod;//把权重移回去
        ans += now;
        ans %=mod;
        
    }
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 2560
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static final int MOD = 1000000007;
	static class State{
		int r;
		int b;
		public State(int r , int b) {
			this.r = r;
			this.b = b;
		}
		@Override
		public int hashCode() {
			return r + 100000 * b;
		}
		@Override
		public String toString() {
			return r + " "+ b;
		}
		@Override
		public boolean equals(Object obj) {
			State s2 = (State) obj;
			return this.r == s2.r && this.b == s2.b;
		}
	}
	static void add(Map<State, Integer> map , State s , int v){
		if(map.containsKey(s)){
			int vold = map.get(s);
			map.put(s, (vold + v) % MOD);
		}else{
			map.put(s, v);
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
		}
		Map<State, Integer> dp = new HashMap<State, Integer>();
		dp.put(new State(0 , 0), 1);
		for(int i = 0 ; i < N ; ++i){
			int Ai = A[i];
			Map<State, Integer> next = new HashMap<State, Integer>();
			for(State s : dp.keySet()){
//				System.out.println(s.r+" "+s.b);
				int v = dp.get(s);
				if(s.r == Ai){
					add(next, new State(s.r + 1, s.b) , v);
				}
				if(s.b == Ai){
					add(next, new State(s.r , s.b + 1) , v);					
				}
				int g = i - s.r - s.b;
				if(g == Ai){
					add(next, new State(s.r , s.b) , v);										
				}
			}
			dp = next;
//			System.out.println(dp);
//			System.out.println(i+" "+dp.size());
		}
		long S = 0;
		for(State s : dp.keySet()){
			S = (S + dp.get(s)) % MOD;
		}
		System.out.println(S);
	}
}


Measured memory_bytes: 65000
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long n,d[1000000],a=2000000001,b;
  cin>>n;
  d[0]=0;
  for(int i=1;i<=n;i++){
    cin>>d[i];
    d[i]+=d[i-1];
  }

  for(int i=1;i<n;i++){
    b=d[i]*2-d[n];
    if(b<0)
      b*=-1;
    if(a>b)
      a=b;
  }
  cout<<a<<endl;
    
  return(0);
}


Measured memory_bytes: 3200
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    map<int,int>mp;
    int ans=0;
    rep(i,n){
        int tiya; cin>>tiya;
        if(mp[tiya])mp[tiya]=0;
        else mp[tiya]=1;
    }
    for(auto itr:mp)if(itr.second)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 4864
def selection_rort(a, n):
    count = 0
    for i in range(n):
        
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[minj], a[i] = a[i], a[minj]
        if minj != i:
          count += 1
        
    return a, count

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

a, count = selection_rort(a, n)
print(" ".join(map(str,a)))
print(count)


Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 10;
   const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 179;
   const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << PI * (ld)r * 2.0;
}
/*

*/


Measured memory_bytes: 3804
import java.util.*;
public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            long c = sc.nextLong();
            long k = sc.nextLong();
            long[] t = new long[n];
            for(int i=0; i<n; i++) {
                    t[i] = sc.nextLong();
            }
            Arrays.sort(t);
            int bus = 0;
            for(int i=0; i<n;) {
                    int start = i;
                    while(i < n && t[i] - t[start] <= k && i - start < c) i++;
                    bus++;
            }
            sc.close();
            System.out.println(bus);
        }
}

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


int main() {
    int N,M;cin >> N >> M;
    vector<string> A(N);
    rep(i,N){
        string a;cin >> a;
        A.at(i) = a;
    }
    vector<string> B(M);
    rep(j,M){
        string b;cin >> b;
        B.at(j) = b;
    }

    bool flag = false;
    for (int j = 0;j <= N-M;j++){
        for (int i = 0;i <= N-M;i++){
            bool break_flag = false;
            for (int l = 0;l < M;l++){
                for (int k = 0;k < M;k++){
                    char a;a = A.at(j+l).at(i+k);
                    char b;b = B.at(l).at(k);
                    if (a != b){
                        break_flag = true;
                        break;
                    }
                }
                if (break_flag){
                    break;
                }
            }
            if (!break_flag){
                flag = true;
                break;
            }
            
        }
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

}       

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int a = sc.nextInt();
    int[] h = new int[n];
    double abs = 100000;
    int result = 1;
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
      double temperature = t - h[i] * 0.006;
      if (Math.abs(a - temperature) < abs) {
        abs = Math.abs(a - temperature);
        result = i + 1;
      }
    }
    System.out.println(result);
  }
}

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

int main() {
    int n; cin >> n;
    vector<string> s(n); for (int i = 0; i < n; ++i) cin >> s[i];

    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 9548
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      myout((int)Math.pow((int)Math.sqrt(N), 2));
	}
	//Method addition frame start



	//Method addition frame end
}


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

using namespace std;

int main()
{
	vector<int> v;
	for (int a; cin >> a;) {
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	int ans = v.back() - v.front();
	cout << ans << endl;
}


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

int n, k;
const int maxn = 1e5 + 5;
int odd[maxn];

int a[maxn], b[maxn];
int p[maxn];
int lower[maxn], upper[maxn];
vector<int> G[maxn];

bool dfs(int u, int fa){
    bool flag = true;
    for(auto v : G[u]){
        if(v == fa)
            continue;
        flag &= dfs(v, u);
    }
    if(!flag)
        return false;
    bool flag1 = false;
    bool flag0 = false;
    for(auto v : G[u]){
        if(v == fa)
            continue;
        if(odd[v] == 0)
            flag0 = true;
        if(odd[v] == 1)
            flag1 = true;
    }  
    if(flag1 and flag0)
        return false;
    if(p[u] == -1){
        if(flag1)
            odd[u] = 0;
        if(flag0)
            odd[u] = 1;
    }else{
        if(p[u] & 1){
            if(flag1)
                return false;
            odd[u] = 1;
        }else{
            if(flag0)
                return false;
            odd[u] = 0;
        }
    }
    int lo = -1e9;
    int up = 1e9;
    for(auto v : G[u]){
        if(v == fa)
            continue;
        lo = max(lower[v] - 1, lo);
        up = min(upper[v] + 1, up);
    }
    if(odd[u] == 1){
        if(lo % 2 == 0)
            lo++;
        if(up % 2 == 0)
            up--;
    }
    if(odd[u] == 0){
        if(lo % 2)
            lo++;
        if(up % 2)
            up--;
    }
    //cout << u << " " << lo << " " << up << endl;
    if(p[u] == -1){
        if(lo > up)
            return false;
        lower[u] = lo;
        upper[u] = up;
    }else{
        if(p[u] < lo or p[u] > up)
            return false;
        lower[u] = p[u];
        upper[u] = p[u];
    }
    return true;
}

void dfs1(int u, int fa, int val){
    if(p[u] != -1){
        for(auto v : G[u]){
            if(v == fa)
                continue;
            dfs1(v, u, p[u]);
        }
        return;
    }    
    vector<int> cand = {val + 1, val - 1};
    for(int i = 0;i < 2;i++){
        if(cand[i] >= lower[u] and cand[i] <= upper[u]){
            p[u] = cand[i];
            break;
        }
    }
    for(auto v : G[u]){
        if(v == fa)
            continue;
        dfs1(v, u, p[u]);
    }
}

int main(){
    cin >> n;
    for(int i = 1;i < n;i++){
        scanf("%d%d", &a[i], &b[i]);
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    } 
    cin >> k;
    memset(odd, -1, sizeof(odd));
    memset(p, -1, sizeof(p));
    for(int i = 1;i <= k;i++){
        int v, val;
        scanf("%d%d", &v, &val);
        p[v] = val;
    }
    for(int i = 1;i <= n;i++){
        if(p[i] == -1){
            lower[i] = -1e9;
            upper[i] = 1e9;
        }else{
            lower[i] = p[i];
            upper[i] = p[i];
        }  
    } 
    if(dfs(1, 1)){
        cout << "Yes" << endl;
        dfs1(1, 1, lower[1] - 1);
        for(int i = 1;i <= n;i++){
//            cout << i << " " << lower[i] << " " << upper[i] << endl;
            printf("%d\n", p[i]);
        }
    }else{
        cout << "No" << endl;
    }    
    return 0;
}


Measured memory_bytes: 19712
import math
r, b, g, n = map(int, input().split(' '))
ans = 0
# only r
r1 = int(math.ceil(n/r))
b1 = int(math.ceil(n/b))
g1 = int(math.ceil(n/g))

# print(r1, b1, g1)


for x in range(r1 + 1):
    for y in range(b1 + 1):
        tmp = n
        tmp -= x * r
        tmp -= y * b

        

        if tmp >= 0 and tmp % g == 0:
            ans += 1

        # print(x, y, tmp/g)

print(ans)


Measured memory_bytes: 40812
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  vector<ll> v[111111];
  ll ans=0;
  rep(i,n) {
    if(m-a[i].F>=0) v[m-a[i].F].pb(a[i].S);
  }
  priority_queue<ll> que;
  rrep(i,m) {
    rep(j,v[i].size()) que.push(v[i][j]);
    if(!que.empty()) {
      ll x=que.top();que.pop();
      ans+=x;
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void solve(){
    string str,str1;
    cin>>str>>str1;bool flag=true;
    for(int i=0;i<str.length();i++){
        if(str[i]!=str1[i]){
        flag=false;break;}
    }
    if(flag && str1.length()==str.length()+1)
    cout<<"Yes";
    else
    cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
  int Tc;
  int a[9],b[9];
  double acnt,bcnt;

  cin >> Tc;
  while(Tc--){
    for(int i = 0 ; i < 9 ; i++){
      cin >> a[i];
    }
    sort(a,a+9);
    for(int i = 0 ; i < 9 ; i++){
      cin >> b[i];
    }
    acnt = bcnt = 0;

    do{
      int aa = 0, bb = 0;
      for(int i = 0 ; i < 9 ; i++){
        if(a[i] > b[i]) aa += a[i] + b[i];
        else bb += a[i] + b[i];
      }
      if(aa > bb) acnt++;
      else bcnt++;
    }while(next_permutation(a,a+9));
   
    printf("%.6f %.6f\n",acnt/(acnt+bcnt),bcnt/(acnt+bcnt));
  }

  return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {

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

		int r = sc.nextInt();
		int d = sc.nextInt();
		long x = sc.nextInt();
		for (int i=0;i<10;i++) {
			x=r*x-d;
			System.out.println(x);
		}
	}
}


Measured memory_bytes: 21712
#!/usr/bin/env python3

from typing import Iterable


def main() -> None:
    N = ri()
    A = rmi()
    num = tuple(range(1, N + 1))
    cand = 0
    log = {}
    for i in range(0, N):
        if i + 1 - A[i] in log:
            cand += log[i + 1 - A[i]]
        if i + 1 + A[i] in log:
            log[i + 1 + A[i]] += 1
        else:
            log[i + 1 + A[i]] = 1
    w(cand)


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(list(map(str, data))))


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

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

    int n;cin>>n;
    vector<vector<char>> c(n,vector<char>(10,0));
    FOR(i,n){
        FOR(j,10){
            cin>>c[i][j];
        }
        sort(c[i].begin(),c[i].end());
    }
    sort(c.begin(),c.end());
    ll ret=0;
    int acum=1;
    for(int i=1;i<n;++i){
        if (c[i]==c[i-1]) ++acum;
        else{
            ret += (ll)acum*(acum-1)/2;
            acum=1;
        }
    }
    ret += (ll)acum*(acum-1)/2;
    cout << ret;
}



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

using namespace std;

#define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define FORD(i, m, n) for (int(i) = (m); (i) >= (n); (i)--)
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int a;
	cin >> a;
	int b=400;
	for(int i=8;i>0;i--){
		if(b<=a&&a<b+200){
			cout << i << endl;
			return 0;
		}
		b+=200;
	}

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //in
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  int flg = 0; //0; none 1: up, -1: down
  int cnt = 0;
  REP(i,n-1){
    if(flg > 0){
      if(a[i] > a[i+1]){
        //cnt++;
        flg = 0;
      }
    }
    else if(flg < 0){
      if(a[i] < a[i+1]){
        //cnt++;
        flg = 0;
      }
    }
    else if(flg == 0){ //flg == 0 
      if(a[i] < a[i+1]) {
        flg = 1; 
        cnt++;
      }
      else if(a[i] > a[i+1]){
        flg =  -1;
        cnt++;
      }
    }
    debug(flg);
    debug(cnt);
  }

  if(flg == 0) cnt++;
  cout << cnt << endl;


  //状態の判定用フラグと，カウンタの用意


  //out
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

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


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int x;
    cin >> x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

int64_t modinv(int64_t a, int64_t m)
{
  int64_t b = m, u = 1, v = 0;
  while (b)
  {
    int64_t t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

int64_t nCk(int64_t n, int64_t k)
{
  int64_t res = 1;
  for (int64_t i = 1; i <= k; i++)
  {
    res = ((res * (n - i + 1)) % MOD * modinv(i, MOD)) % MOD;
  }
  return res;
}

int main()
{
  int64_t X, Y, ans;
  cin >> X >> Y;
  if (Y > 2 * X || 2 * Y < X || (X + Y) % 3 != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  ans = nCk((X + Y) / 3, X - (X + Y) / 3);
  cout << ans % MOD << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

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

  int c; cin >> c;
  int d500 = c / 500;
  c -= d500*500;
  int d5 = c / 5;
  int sum = d500 * 1000 + d5 * 5;
  cout << sum;

  return 0;
}


Measured memory_bytes: 256
/*
[soundhound2018-summer-qual] D - Saving Snuuk
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;
const int MAX_M = 100000;
const ll X = 1e15;
const int MAX_V = MAX_N;
const ll INF = 1e18;

class Graph {
public:
    ll dist[MAX_V];
    vector<pli> g[MAX_V];  // cost, to
    void add_edge(int from, int to, ll cost);
    void dijkstra(int s);
};

void Graph::add_edge(int from, int to, ll cost) {
    g[from].push_back(pli(cost, to));
    return;
}

void Graph::dijkstra(int s) {
    priority_queue<pli, vector<pli>, greater<pli>> q;
    pli p, e;

    fill(dist, dist + MAX_V, INF);
    dist[s] = 0;
    q.push(pli(dist[s], s));
    while (!q.empty()) {
        p = q.top();
        q.pop();
        if (dist[p.second] < p.first) {
            continue;
        }
        for (int i = 0; i < (int)g[p.second].size(); i++) {
            e = g[p.second][i];
            if (dist[e.second] > dist[p.second] + e.first) {
                dist[e.second] = dist[p.second] + e.first;
                q.push(pli(dist[e.second], e.second));
            }
        }
    }
    return;
}

int N, M, S, T;
Graph g[2];

void solve() {
    g[0].dijkstra(S);
    g[1].dijkstra(T);

    vector<ll> ans(N + 1);
    ans[N] = -1;
    for (int i = N - 1; i >= 0; i--) {
        ans[i] = max(ans[i + 1], X - (g[0].dist[i] + g[1].dist[i]));
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    cin >> N >> M >> S >> T;
    S--;
    T--;
    for (int i = 0; i < M; i++) {
        int u, v, c[2];
        cin >> u >> v >> c[0] >> c[1];
        u--;
        v--;
        for (int p = 0; p < 2; p++) {
            g[p].add_edge(u, v, c[p]);
            g[p].add_edge(v, u, c[p]);
        }
    }

    solve();

    return 0;
}


Measured memory_bytes: 19140
#define MOD 1000000007

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

long pow(long a, long b) {
	if (b == 0) return 1;
	long c = pow(a, b / 2);
	if (b % 2) c = a * c % MOD * c % MOD;
	else c = c * c % MOD;
	return c;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<long> a(n + k, 1), b(n + k, 1);
	for (int i = 1; i < n + k; i++) {
		a[i] = a[i - 1] * i % MOD;
		b[i] = pow(a[i], MOD - 2);
	}
	cout << a[n + k - 1] * b[n] % MOD * b[k - 1] % MOD << endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    int n,as=0,fl=1 ; cin>>n ;
    if(n%2==0 || n%5==0){cout<<"-1"<<endl ; return 0 ; }
    for(int i=1 ; i <= 10000000 ; i++)
    {
        as=(as*10)+7 ; as%=n ;
        if(as==0){cout<<i<<endl ; fl=0 ; break ; }
    }
    if(fl) cout<<"-1"<<endl ;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main( void ) {
	int i, j, data[ 10 ], max, tmp;

	for ( i = 0; i < 10; i++ )
		scanf( "%d", data + i );

	for ( i = 0; i < 3; i++ ) {
		max = i;
		for ( j = 9; j > i; j-- )
			if ( data[ max ] < data[ j ] )
				max = j;

		tmp = data[ i ];
		printf( "%d\n", data[ i ] = data[ max ] );
		data[ max ] = tmp;
	}

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[1000];
  FOR(i,n){
    cin >> a[i];
  }

  int v=0,ans=0;

  FOR(i,n-1){
    if(a[i]==a[i+1]){
      if(v%2==0){
        ans++;
      }
      v++;
    }else{
      v=0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        // 文字数を取得
        int N = Integer.parseInt(line);
        
        List<List<Character>> list = new ArrayList<>();
        List<Character> chList = null;
        
        while(sc.hasNextLine()) {
            chList = new ArrayList<>();
            char[] ch = sc.nextLine().toCharArray();
            for(int i = 0; i < ch.length; i++) {
                chList.add(ch[i]);
            }
            
            list.add(chList);
        }
        
        //文字数分ループ
        int total = 0;
        char[] moji = new char[list.size()];
        for(int i = 0; i < N; i++) {
            // それぞれの文字をいれていく
            for(int j = 0; j < list.size(); j++) {
                moji[j] = list.get(j).get(i);
            }
            
            // moji のなかで一番多い文字を見つける
            Map<Character, Integer> map = new HashMap<>();
            for(int j = 0; j < moji.length; j++) {
                char c = moji[j];
                
                if(map.containsKey(c)) {
                    map.put(c, map.get(c) + 1);
                } else {
                    map.put(c, 1);
                }
            }
            
            int max = 0;
            for(char c : map.keySet()) {
                int tmp = map.get(c);
                
                if(max <= tmp) {
                    max = tmp;
                }
            }
            
            total += list.size() - max;
        }
        
        System.out.println(total);
        
        
    }
    
    
}


Measured memory_bytes: 23636
#include <stdio.h>
int main(void){
	int X,i,u,y,t,r,e,w;
	scanf("%d",&X);
	i=X%7;
	
	if(i==1){
	printf("fri\n");
	}
	else if(i==2){
	printf("sat\n");
	}
	else if(i==3){
	printf("sun\n");
	}
	else if(i==4){
	printf("mon\n");
	}
	else if(i==5){
	printf("tue\n");
	}
	else if(i==6){
	printf("wed\n");
	}
	else if(i==0){
	printf("thu\n");
	}
	return 0;
}


Measured memory_bytes: 2104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	a, b, c, d, e, f := getInt()*100, getInt()*100, getInt(), getInt(), getInt(), getInt()

	ws := make(map[int]bool)
	ss := make(map[int]bool)
	for i := 0; a*i <= f; i++ {
		for j := 0; a*i+b*j <= f; j++ {
			ws[a*i+b*j] = true
		}
	}
	for i := 0; c*i <= f; i++ {
		for j := 0; c*i+d*j <= f; j++ {
			ss[c*i+d*j] = true
		}
	}

	ansSw, ansS := 0, 0
	for w := range ws {
		for s := range ss {
			sw := s + w
			if sw > f {
				continue
			}
			if x := w / 100; s > x*e {
				continue
			}

			if s*ansSw >= ansS*sw {
				ansSw, ansS = sw, s
			}
		}
	}

	fmt.Fprintln(wr, ansSw, ansS)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 768