akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>


int main() {


    int N;
    std::cin >> N;

    int A;
    int x, y;
    std::vector<std::vector<std::tuple<int, int>>> As;
    for (int i = 0; i < N; ++i) {
        std::cin >> A;
        std::vector<std::tuple<int, int>> ts;
        for (int j = 0; j < A; ++j) {
            std::cin >> x >> y;
            ts.emplace_back(x, y);
        }
        As.push_back(ts);
    }
    int mHonest = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        int honest = 0;
        int unkind = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                honest = honest | (1 << i);
                for (std::tuple<int, int> kv : As[i]) {
                    if (std::get<1>(kv) == 1) {
                        honest = honest | (1 << (std::get<0>(kv) - 1));
                    } else {
                        unkind = unkind | (1 << (std::get<0>(kv) - 1));
                    }
                }
            } else {
                unkind = unkind | (1 << i);
            }
        }
        if (__builtin_popcount(honest & unkind) == 0) {
            mHonest = std::max(mHonest, __builtin_popcount(honest));
        }
    }

    std::cout << mHonest << "\n";

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

         Scanner sc = new Scanner(System.in);

            int a = sc.nextInt();
            int b = sc.nextInt();
            int area = a*b;
            int length = 2*a + 2*b;
        System.out.println(area + " " +length);
    }
}



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

namespace AtCoder
{
    public static class program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var j = N % 10;
            switch (j)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    Console.WriteLine("hon");
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
            }
        }
    }
}

Measured memory_bytes: 27532
n,m=map(int,input().split())
k=[list(map(int,input().split())) for i in range(n)]
k.sort(key=lambda x: x[0])
cnt=0
#print(k[0][1:])
for i in k[0][1:]:
    #print(i)
    c=0
    for j in range(n):
        if i in k[j][1:]:
            c+=1
    #print(c)
    if c==n:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
fn main() {
    let pqr = read_vec::<usize>();

    let mut mi = usize::max_value();
    for i in 0..2 {
        for j in i+1..3 {
            let sum = pqr[i] + pqr[j];
            if mi > sum {
                mi = sum;
            }
        }
    }
    println!("{}", mi);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const int MOD = 1000000007LL;

ll dp[100005][13];

signed main() {
  IOS
  string s;
  cin >> s;
  
  dp[0][0] = 1;

  REP(i, s.size()){
    int l = s.size() - i - 1;
    if (s.at(i) == '?'){
      REP(j, 13){
        REP(k, 10){
          dp[i + 1][(10 * j + k) % 13] += dp[i][j] % MOD;
        }
      }
    }
    else {
      int k = (int)(s.at(i) - '0');
      REP(j, 13){
        dp[i + 1][(10 * j + k) % 13] += dp[i][j] % MOD;
      }
    }
  }
  cout << dp[s.size()][5] % MOD << endl;
}


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

using namespace std;

int main()
{
  int n, d;
  cin >> n >> d;

  vector< vector< int > > p(n, vector< int >(d));
  for(auto &&s : p) {
    for(auto &&t : s) {
      cin >> t;
    }
  }

  int cnt = 0;
  for(int i = 0; i < n - 1; i++) {
    for(int j = i + 1; j < n; j++) {
      int sum = 0;
      for(int k = 0; k < d; k++) {
        sum +=
            (p.at(i).at(k) - p.at(j).at(k)) * (p.at(i).at(k) - p.at(j).at(k));
      }
      int dist = (int)sqrt(sum);
      if(sum == dist * dist) {
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
W,H,N = map(int,input().split())

x_m,x_M,y_m,y_M = 0, W, 0, H

for i in range(N):
    x,y,A = map(int,input().split())
    if A == 1:
        x_m = max(x, x_m)
    if A == 2:
        x_M = min(x, x_M)
    if A == 3:
        y_m = max(y, y_m)
    if A == 4:
        y_M = min(y, y_M)

print(max(0, x_M - x_m) * max(0, y_M - y_m))

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

long long L[87];

long long solve(int x)
{
	if(L[x])return L[x];
	
	if(x == 0)return L[x] = 2;
	if(x == 1)return L[x] = 1;
	return L[x] = solve(x - 1) + solve(x - 2);
}

int main() {
	int N;cin>>N;
	cout<<solve(N)<<endl;
	
	return 0;
}

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

ll mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n;
  cin >> n;
  set<string> s;
  while (n--) {
    string x;
    cin >> x;
    s.insert(x);
  }
  cout << sz(s);

  return 0;
}


Measured memory_bytes: 19144
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,d,x,y;
    cin>>n>>d;
    int ans=0;
    while(cin>>x>>y)
        if(x*x+y*y<=d*d)
            ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
def main():
    n, m = [int(e) for e in input().split()]
    H = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(m)]

    W = [0] * n
    for ab in AB:
        a, b = ab
        ha, hb = H[a - 1], H[b - 1]
        if ha > hb:
            W[b - 1] = 1

        elif ha < hb:
            W[a - 1] = 1

        else:
            W[a - 1] = 1
            W[b - 1] = 1

    print(W.count(0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 93432
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, L; cin >> n >> L;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int knot = -1;
  for (int i = 0; i < n - 1; i++) {
  	if (a[i] + a[i + 1] >= L) {
      knot = i + 1;
      break;
    }
  }
  if (knot == -1) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for (int i = 1; i < knot; i++) cout << i << endl;
  for (int i = n - 1; i > knot; i--) cout << i << endl;
  cout << knot << endl;
}

Measured memory_bytes: 3740
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();

		List<String> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			list.add(sc.next());
		}

		Collections.sort(list);
		for (String string : list) {
			System.out.print(string);
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  char ch; ch = getchar();
  ++ch; putchar(ch);

  return 0;
}

Measured memory_bytes: 256
import fractions
def lcm_list(List):
    ans=List[0]
    for i in range(1,len(List)):
        ans=ans*List[i] // fractions.gcd(ans,List[i])
    return(ans)

N=int(input())
T=[int(input()) for i in range(N)]

print(lcm_list(T))

Measured memory_bytes: 5052
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    rep(i,n){
        if(i!=k-1) cout<<s[i];
        else{
            if(s[i]=='A') cout<<'a';
            else if(s[i]=='B') cout<<'b';
            else cout<<'c';
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Ankit Raj, NIT Agartala
 */
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define MAX_RANGE 10000007
#define BOOST ios_base::sync_with_stdio(0) 
#define NITRO cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main()
{
	BOOST;
	NITRO;
	//clock_t t1,t2;
	//t1 = clock();
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	*/ 
	//Main Code
	int n;
	cin>>n;
	vector<lld>A(n);
	vector<lld>B(n);
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
	}
	for(int j=0;j<n;j++)
	{
		cin>>B[j];
	}
	int ct = 0;
	lld sum = 0;
	vector<lld>sorted_diff;
	for(int i=0;i<n;i++)
	{
		if(A[i]<B[i])
		{
			ct++;
			sum += abs(A[i]-B[i]);
		}
		sorted_diff.pb(A[i]-B[i]);
	}
	//cout<<sum<<" "<<ct<<"\n";
	sort(sorted_diff.begin(),sorted_diff.end());
	//reverse(sorted_diff.begin(),sorted_diff.end());
	lld new_sum = 0;
	for(int j = sorted_diff.size()-1;j>=0;j--)
	{
		if(new_sum<sum)
		{
			ct++;
			new_sum += sorted_diff[j];
			//cout<<new_sum<<" "<<ct<<"\n";
		}
		else if(new_sum>=sum)
		{
			break;
		}
	}
	if(ct>n)
	{
		cout<<"-1"<<"\n";
	}
	else
	{
		cout<<ct<<"\n";
	}
	//t2 = clock();
	//float diff = (float)t2 - (float)t1;
	//float execution_time = diff/CLOCKS_PER_SEC;
	//cout<<"\n"<<execution_time;
	//system("pause");
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char m[4];
	int i,j,n,a1=0,b1=0,c1=0;
	scanf("%s",m);
	for(i=0;i<3;i++)
	{
		if(m[i]=='a')
		{
			a1++;
		}
		if(m[i]=='b')
		{
			b1++;
		}
		if(m[i]=='c')
		{
			c1++;
		}
	}
	if(a1==1&&b1==1&&c1==1)
		printf("Yes");
	else
		printf("No");
} 

Measured memory_bytes: 256
N,D = list(map(int,input().split()))

pos = []
for i in range(N):
    X, Y = list(map(int,input().split()))
    pos.append([X,Y])

cnt = 0
D = D*D
for i in pos:
    if i[0]*i[0] + i[1] * i[1] <= D:
        cnt+=1

print(cnt)

Measured memory_bytes: 39056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> cnt(5);
	rep(i,n){
		string s;cin >> s;
		if(s.at(0) == 'M') cnt.at(0)++;
		if(s.at(0) == 'A') cnt.at(1)++;
		if(s.at(0) == 'R') cnt.at(2)++;
		if(s.at(0) == 'C') cnt.at(3)++;
		if(s.at(0) == 'H') cnt.at(4)++;
	}
	ll ans = 0;
	rep(i,5){
		for(int j = i + 1; j < 5; j++){
			for(int k = j + 1; k < 5; k++){
				ans += cnt.at(i) * cnt.at(j) * cnt.at(k);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100010,Mod=1e9+7;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
int dp[N][15];
int main()
{
  string s;
  cin>>s;
  if(s[0]!='?') dp[0][s[0]-'0']++;
  else for(int i=0;i<10;i++) dp[0][i]=1;
  for(int i=1;i<s.size();i++)
  {
    if(s[i]!='?') for(int j=0;j<13;j++) dp[i][(j*10+(s[i]-'0'))%13]=(dp[i][(j*10+(s[i]-'0'))%13]+dp[i-1][j])%Mod;
    else for(int j=0;j<13;j++) for(int k=0;k<10;k++) dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%Mod;
  }
  int n=s.size()-1;
  cout<<dp[n][5]<<endl;
  return 0;
}


Measured memory_bytes: 6272
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
 
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
 
using namespace std;
typedef long long LL;

int dp[10000000L+2] = {0};
int p[10000000+2] = {0};
 
long long N;
vector<LL> PR;
 
void PINIT(long long n){
	for(int i=2; i<=n; i++){
		if(p[i] > 0) continue;
		for(int j=2; i*j <= n; j++){
			p[i*j]++;
		}
	}
	for(int i=2; i<=n; i++){
		if(p[i] == 0){
			dp[i] = 2;
			PR.push_back((long long)i);
		}
	}
}
 
LL f(int x){
	if(x == 1) return 1;
	if(dp[x] > 0) return dp[x];
 
	LL ret = 1, p;
	for(int i=0; i<PR.size(); i++){
		if((x % PR[i]) == 0){
			p = PR[i];
			break;
		}
	}
	int e = 1;
	int tmp = x;
	while(true){
		tmp = tmp / p;
		if((tmp % p) !=0){
			break;
		}
		e++;
	}
	ret = f(tmp) * (e + 1);
	dp[x] = ret;
	return ret;
}
 
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	PINIT(N);
	long long ans = 0;
	for(int k=1; k<=N; k++){
		ans += (long long) (k * f(k));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 86688
STDIN.each_line do |line|
  a, b, c, d, e, f = line.split.map(&:to_f)
  det = a * e - b * d
  a1, b1, d1, e1 = e/det, -b/det, -d/det, a/det
  x, y = a1 * c + b1 * f, d1 * c + e1 * f
  printf "%.3f %.3f\n", x, y
end


Measured memory_bytes: 6884
# AtCoder Beginner Contest 126
# https://atcoder.jp/contests/abc126
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    d = [[] for _ in range(N)]
    #uvw = ii2nnn(N-1)
    #for u, v, w in uvw:
    for _ in range(N-1):
        u, v, w = i2nn()
        b = w % 2 == 0
        d[u-1].append((v-1, b))
        d[v-1].append((u-1, b))
    nn = [-1 for _ in range(N)]
    nn[0] = 0
    def main2(src):
        links = d[src]
        c = nn[src]
        for dst, b in links:
            if nn[dst] == -1:
                nn[dst] = c if b else 1-c
                main2(dst)
    #main2(0)
    que = [0]
    que2 = []
    while True:
        if len(que) == 0:
            break
        que2 = []
        for src in que:
            links = d[src]
            c = nn[src]
            for dst, b in links:
                if nn[dst] == -1:
                    nn[dst] = c if b else 1-c
                    que2.append(dst)
        que = que2
    for n in nn:
        print(n)

main()


Measured memory_bytes: 72864
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0043
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			String s = sc.next();
			int[] hist = new int[10];
			fill(hist, 0);
			for (int i = 0; i < s.length(); i++) hist[(s.charAt(i) - '0')]++;
			
			boolean[] ok = new boolean[10];
			int iter = 0;
			int[] res = new int[9];
			fill(ok, false);
			
			for (int i = 1; i <= 9; i++) {
				if (hist[i] >= 4) continue;
				hist[i]++;
				for (int j = 1; j <= 9; j++) {
					if (hist[j] >= 2) {
						hist[j] -= 2;
						if (dfs(hist, 0)) {
							ok[i] |= true;
						}
						hist[j] += 2;
					}
				}
				hist[i]--;
				if (ok[i])
					res[iter++] = i;
			}
			
			if (iter == 0) {
				System.out.println(0);
			} else {
				for (int i = 0; i < iter - 1; i++) {
					System.out.print(res[i] + " ");
				}
				System.out.println(res[iter - 1]);
			}
		}
	}	
	
	public static boolean dfs(int[] hist, int cnt) {
		if (cnt >= 4) return true;
		
		boolean ret = false;
		for (int i = 1; i <= 9; i++) {
			if (hist[i] >= 3) {
				hist[i] -= 3;
				ret |= dfs(hist, cnt + 1);
				hist[i] += 3;
			}
			
			if (i <= 7 && hist[i] > 0 && hist[i + 1] > 0 && hist[i + 2] > 0) {
				hist[i] -= 1; hist[i + 1] -= 1; hist[i + 2] -= 1;
				ret |= dfs(hist, cnt + 1);
				hist[i] += 1; hist[i + 1] += 1; hist[i + 2] += 1;
			}
		}
		return ret;
	}
}

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

int N, M;
// 画像A, テンプレート画像B
char A[50][50], B[50][50];

bool check(int y, int x){
    for(int i=0;i<M;i++){
        for(int j=0;j<M;j++){
            if(A[y+i][x+j] != B[i][j])
                return false;
        }
    }
    return true;
}
 
int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)
            cin >> A[i][j];
    for(int i=0;i<M;i++)
        for(int j=0;j<M;j++)
            cin >> B[i][j];
    
    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            if( check(i, j) ){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

const int p[25] = {2, 3, 5, 7, 11, 13,
    17, 19, 23, 29, 31, 37, 41, 43,
    47, 53, 59, 61, 67, 71, 73, 79,
    83, 89, 97};
 
int main() {
    int N; cin >> N;
 
    int cnt[25];
    fill(cnt, cnt + 25, 0);
    for (int n = 1; n <= N; ++n) {
        int m = n;
        for (int i = 0; i < 25; ++i) {
            while (m % p[i] == 0) {
                ++cnt[i];
                m /= p[i];
            }
        }
    }
 
    int ans = 0;
    for (int i = 0; i < 25; ++i) {
        for (int j = 0; j < 25; ++j) {
            for (int k = j + 1; k < 25; ++k) {
                if (i == j || k == i) continue;
                if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ++ans;
            }
        }
    }
 
    for (int i = 0; i < 25; ++i) {
        for (int j = 0; j < 25; ++j) {
            if (i == j) continue;
            if (cnt[i] >= 4 && cnt[j] >= 14) ++ans;
            if (cnt[i] >= 2 && cnt[j] >= 24) ++ans;
        }
    }
 
    for (int i = 0; i < 25; ++i) {
        if (cnt[i] >= 74) ++ans;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define pi acos(-1)

typedef long long ll;
const ll M = 1e9+7;
const int sz = 500010;


int main(){
    double n; cin >> n;
    cout << setprecision(10) << (2.0*pi*n) << endl;
    return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    int c=max(a,b)-min(a,b);
    return c;
}
int gcd(int a,int b){//最大公約数
    int c=a%b;
    while(true){
	if(c==0) break;
	a=b;
	b=c;
	c=a%b;
    }
    return b;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(int i=3;i<=sqrtNum;i+=2){
	if(num%i==0){
	    return false;
	}
    }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	
bool q[100];
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d=0,e,f,g=0;
    cin>>a>>b;
    for(int i=0;i<b;i++){
	cin>>c;
	q[c]=true;
    }
    while(true){
	e=a+g;
	f=0;
	while(true){
	    if(e==0) break;
	    if(q[e%10]==1){
		f=1;
		break;
	    }
	    e/=10;
	}
	if(!f){
	    d=a+g;
	    break;
	}
	g++;
    }
    cout<<d<<"\n";
}

	    


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
#define INF (1ll<<50)
int main(){
	int C[16];
	int n,m;
	while(cin >> n >> m && n){
		for(int i = 0 ; i < m ; i++) cin >> C[i];
		long long dp[2][256];
		for(int i = 0 ; i < 2 ; i++)
			for(int j = 0 ; j < 256 ; j++)
				dp[i][j] = INF;
		dp[0][128] = 0;
		
		for(int j = 1 ; j <= n ; j++){
			int x; cin >> x;
			for(int i = 0 ; i < 256 ; i++) dp[j&1][i] = INF;
			for(int i = 0 ; i < 256 ; i++){
				for(int k = 0 ; k < m ; k++){
					int y = i + C[k];
					y = min(y,255); y = max(0,y);
					dp[j&1][y] = min(dp[j&1][y],dp[j&1^1][i] + (y-x)*(y-x) );
				}
			}
		}
		cout << *min_element(dp[n&1],dp[n&1]+256) << endl;
	}
}

Measured memory_bytes: 880
/**
 *   Author:  Wasi Ur Rahman
 *   FROM RMSTU
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n = 5;
	int ans = 0;
	int x;
	for(int i = 0;i<n;i++){
        cin >> x;
        if(x == 0){
            cout << i+1 << endl;
            return 0;
        }
	}
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N;
bool ex[5001][5001];

bool in(int x, int y) {
	return 0 <= x && x <= 5000 && 0 <= y && y <= 5000;
}

int main() {

	while (true)
	{
		cin >> N;

		if (N == 0) break;

		int x[5000], y[5000];
		

		for (int i = 0; i <= 5000; i++) {
			for (int j = 0; j <= 5000; j++) {
				ex[i][j] = false;
			}
		}
		

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

			ex[x[i]][y[i]] = true;
		}

		int ans2 = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				int dx = x[j] - x[i];
				int dy = y[j] - y[i];

				int kx = -dy;
				int ky = dx;

				if (in(x[i] + kx, y[i] + ky)&& in(x[j] + kx, y[j] + ky) && ex[x[i] + kx][ y[i] + ky] == true && ex[x[j] + kx][ y[j] + ky] == true) {
					ans2 = max(ans2, dx*dx + dy*dy);
				}

				kx = dy;
				ky = -dx;

				if (in(x[i] + kx, y[i] + ky) && in(x[j] + kx, y[j] + ky) && ex[x[i] + kx][ y[i] + ky] == true && ex[x[j] + kx][y[j] + ky] == true) {
					ans2 = max(ans2, dx*dx + dy*dy);
				}
			}
		}

		cout << ans2 << endl;
	}


	return 0;
}




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

#define INF (1e9)
#define INF_LL (1e17)

using LL = long long;
using ULL = unsigned long long;

using namespace std;

#define mod 1000000007

#define MAX_N 100005

int N;
LL A[MAX_N];

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

LL solve()
{
  LL ret = 1;
  stack<int> Stack;
  for (int i = 0; i < N; i++) {
    Stack.push(A[i]);
    LL k = Stack.size();
    if(A[i] < 2*k-1){
      Stack.pop();
      ret *= k;
      ret %= mod;
    }
  }
  for (LL i = 1; i <= Stack.size(); i++) {
    ret *= i;
    ret %= mod;
  }

  return ret;
}

int main()
{
  input();

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll 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 rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  ll r = 0;
  ll g = 0;
  ll b = 0;
  ll ans = 1;
  cin >> n;
  ll a;
  rep(i,n){
    cin >> a;
    ll co = 0;
    if(r==a){
      co++;
      if(co==1) r++;
    }
    if(g==a){
      co++;
      if(co==1) g++;
    }
    if(b==a){
      co++;
      if(co==1) b++;
    }
    ans = ans * co % mod;
  }
  pri(ans);
  return 0;
}


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




int main() {
  int h,w,K;
  cin>>h>>w>>K;
  
  vector<string> c(h, string(w,'.'));
  for(int i=0; i<h; i++){
    string si; cin>>si;
    c[i]=si;
  }
  
  
  // 行,列の選び方パターン
  vector<vector<bool> > hchoice(pow(2,h),vector<bool>(h,0));
  vector<vector<bool> > wchoice(pow(2,w),vector<bool>(w,0));
  for(int i=0; i<pow(2,h); i++){
    int temp=i;
    for(int j=0; j<h; j++){
      hchoice[i][j]=temp%2; temp/=2;
    }
  }
  for(int i=0; i<pow(2,w); i++){
    int temp=i;
    for(int j=0; j<w; j++){
      wchoice[i][j]=temp%2; temp/=2;
    }
  }
  
  
  int res=0;
  for(int i=0; i<hchoice.size(); i++){
    for(int j=0; j<wchoice.size(); j++){
      int cnti=0;
      for(int p=0; p<h; p++){
        if(!hchoice[i][p]){
          for(int q=0; q<w; q++){
            if(!wchoice[j][q]){
              cnti+=(c[p][q]=='#');
            }
          }
        }
      }
      res+=(cnti==K);
    }
  }
  
  cout<<res<<endl;
  
}


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int q;
  cin >> q;
  REP(i, q){
    ll a, b;
    cin >> a >> b;
    ll c = a*b-1;
    ll s = (ll)pow(c, 0.5);
    while(s*s > c) s--;
    ll ans = s + (c / (s+1));
    ll k = -1, l;
    if(a != 1) k = c/(a-1);
    l = c/(a+1);
    if((b-1) != l) ans--;
    if(k == b) ans--;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int d[n][2];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&d[i][0], &d[i][1]);
	}
	bool flag = false;
	for (int i = 0; i < n-2; ++i)
	{
		if((d[i][0]==d[i][1]) && (d[i+1][0]==d[i+1][1]) && (d[i+2][0]==d[i+2][1]))
		{
			flag = true;
			break;
		}
	}
	if(flag)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

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

int a, b, q;
int s[100002];
int t[100002];
int x[100000];

signed main() {
	int i;
	
	cin >> a >> b >> q;
	rep(i, a) cin >> s[i]; s[a] = 1e+15; s[a+1] = -1e+15; a += 2;
	rep(i, b) cin >> t[i]; t[b] = 1e+15; t[b+1] = -1e+15; b += 2;
	sort(s, s + a);
	sort(t, t + b);
	
	rep(i, q) cin >> x[i];
	
	rep(i, q) {
		int rs = lower_bound(s, s + a, x[i]) - s;
		int rt = lower_bound(t, t + b, x[i]) - t;
		int ls = rs - 1;
		int lt = rt - 1;
		rs = s[rs];
		rt = t[rt];
		ls = s[ls];
		lt = t[lt];
		
		int d1 = max(rs, rt) - x[i];	//右
		int d2 = x[i] - min(ls, lt);	//左
		
		//神社 -- x -- 寺
		int d3 = 2 * (x[i] - ls) + (rt - x[i]);
		int d4 = 2 * (rt - x[i]) + (x[i] - ls);
		
		//寺 -- x -- 神社
		int d5 = 2 * (x[i] - lt) + (rs - x[i]);
		int d6 = 2 * (rs - x[i]) + (x[i] - lt);
		
		int d = min({d1, d2, d3, d4, d5, d6});
		cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
def main():
    n, s = int(input()), input()

    c_lst = []
    for i in range(n):
        s1, s2 = set(s[:i]), set(s[i:])
        c_lst.append(len(s1&s2))

    print(max(c_lst))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    #bitDP
    N,M = MI()
    money_box = []
    for i in range(M):
        a,_ = MI()
        c=LI()
        bit=0
        for d in c:
            bit += 1<<(d-1)
        money_box.append((a,bit))
    
    bit_max = 1<<N
    dp =[inf]*bit_max
    dp[0] = 0
    for bit_set in range(bit_max):
        for i,(money,bit) in enumerate(money_box):
            before = bit_set-(bit_set&bit)
            dp[bit_set] = min(dp[bit_set],dp[before]+money)
    ans = dp[-1]
    if dp[-1]==inf:
        print(-1)
    else:
        print(dp[-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 42988
N,M = map(int,input().split())
A = []
for i in range(1,M+1):
    if i*i>M:break
    if M%i==0:
        A.append(i)
        A.append(M//i)
A.sort()
for a in A:
    if a>=N:
        print(M//a)
        break

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.JSC_2019_qual
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            bool odd = n % 2 == 1;
            int[,] levels = new int[n, n];
            for(int i = 0; i < n; i++)
            {
                int delta = 2;
                int start = 1;
                int level = 1;
                while (start < n)
                {
                    for (int j = 0; i+start + j * delta < n; j++)
                    {
                        levels[i, i+start+j*delta] = level;
                    }
                    delta *= 2;
                    start *= 2;
                    level++;
                }
            }

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    Write(levels[i, j]);
                    if (j < n -1) Write(" ");
                }
                WriteLine();
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 14176
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;
const ld PI = 3.14159265358979;

int main(){
  ld a,b; cin>>a>>b;
  ld h,m; cin>>h>>m;
  ld d = (h / 12.0 + m / 60.0 / 12.0) * 2.0 * PI;
  ld e = m / 60.0 * 2.0 * PI;
  ld ai = d-e;
  ai = min(ai, 2.00 * PI - ai);
  //ai /= .00; ai *= PI;

  cout.precision(16);
  cout<<sqrt(a*a+b*b-2*a*b*cos(ai))<<endl;
}

Measured memory_bytes: 4164
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}

module Main where

import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.List
import Control.Applicative
import Control.Monad
import Data.Char
import Data.Maybe
import qualified Data.Map.Lazy as M

main :: IO ()
main = do
  input <- T.getLine
  print $ solve input

solve :: T.Text -> Int
solve order = baseValue + toppinValue * toppingNum
  where
    toppingNum = T.foldl (\temp t -> if t == 'o' then temp + 1 else temp) 0 order
    baseValue = 700
    toppinValue = 100


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

const int N = 1e5 + 5;

int n, par[N], a[N], b[N];
vector < pair<int,int> > va, vb;

int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]);  }
void join(int p, int q) { par[anc(p)] = anc(q); }

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

    cin >> n;
    for (int i = 1; i <= n; ++i) par[i] = i;
    for (int i = 1; i <= n; ++i) cin >> a[i], va.push_back({a[i], i});
    for (int i = 1; i <= n; ++i) cin >> b[i], vb.push_back({b[i], i});
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());

    for (int i = 0; i < n; ++i) {
        if (va[i].first <= vb[i].first) {
            join(va[i].second, vb[i].second);
        } else {
            cout << "No\n";
            return 0;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= n; ++i) cnt += (i == anc(i));

    if (cnt > 1) {
        cout << "Yes\n"; return 0;
    }

    for (int i = 0; i + 1 < n; ++i) {
        if (va[i+1].first <= vb[i].first) {
            cout << "Yes\n"; return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 4724
#include <iostream>
using namespace std;
int main()
{
	int a , b , c;

	cin >> a >> b >> c;

	if((a + b) == c  || (b + c) == a || (c + a) == b) 
	{

		cout << "Yes" << endl;
	}else{

		cout << "No" << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

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

  int x[10], y[10];
  vector<int> route;
  int route_sum = 1;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    route.push_back(i);
    route_sum *= i + 1;
  }

  double sum = 0.0;
  do {
    for (int i = 0; i < n - 1; i++) {
      sum += sqrt(pow(x[route[i]] - x[route[i+1]], 2) + pow(y[route[i]] - y[route[i+1]], 2));
    }
  } while(next_permutation(route.begin(), route.end()));

  cout << setprecision(8) << sum / route_sum << endl;
}

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

int main() {
    int n,m;
    cin>>n>>m;
    vector<int> p(m),y(m);
    vector<vector<int>> a(n);
    rep(i,m) {
        cin>>p[i]>>y[i];
        p[i]--;
    }
    rep(i,m) {
        a[p[i]].push_back(y[i]);
    }
    rep(i,n) {
        sort(a[i].begin(),a[i].end());
    }
    rep(i,m) {
        int temp=p[i];
        printf("%06d",temp+1);
        int id=lower_bound(a[temp].begin(),a[temp].end(),y[i])-a[temp].begin();
        printf("%06d\n",id+1);
    }
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll x, y;
  cin >> x >> y;
  print(x + y / 2);
}

Measured memory_bytes: 256
import Data.List

ans :: String -> String -> String
ans [] _ = "Yes"
ans _ [] = "No"
ans pat@(p:ps) text@(t:ts) = if isPrefixOf pat text
                             then "Yes"
                             else ans pat ts

main = do
  s <- getLine
  p <- getLine
  let s' = s ++ s
      o  = ans p s'
  putStrLn o

Measured memory_bytes: 3512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	static int n;
	static int[] a;
	static int[] memo;
	static final int INF =(int) 1e9;

	static int solve(int n) {

		if (n < 0)
			return INF;

		if (n == 0)
			return 0;

		if (memo[n] != -1)
			return memo[n];

		int x = (int) Math.abs(a[n] - a[n - 1]);
		int y = INF;
		
		if (n >= 2)
			y = Math.abs(a[n] - a[n - 2]);

		return memo[n] = Math.min(x + solve(n - 1), y + solve(n - 2));
	}

	public static void main(String[] args) throws NumberFormatException, IOException {

		n = input.nextInt();
		a = new int[n];
		memo = new int[n + 10];
		Arrays.fill(memo, -1);

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

		System.out.println(solve(n - 1));

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}
}


Measured memory_bytes: 45276
#include <stdio.h>
#include<math.h>

int main(int argc, const char * argv[]) {
    int n,i,money=100000;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        money=money*1.05;
        if(money%1000!=0)
            money=ceil(money/1000+1)*1000;
    }
    
        printf("%d\n",money);
    return 0;
}

Measured memory_bytes: 592
#include<stdio.h>

int main()
{
  int N, A[100];
  int result;
  int i, j, k;

  //Read N and Sets
  scanf("%d", &N);
  for(i=0; i<N; i++)scanf("%d", &A[i]);

  //Begin Bubble Sort
  result=0;
  for(i=0; i<N; i++)
    {
      for(j=1; j<N; j++)
	{
	  //if A[j]<A[j+1], change;
	  if(A[j]<A[j-1])
	    {
	      k=A[j];
	      A[j]=A[j-1];
	      A[j-1]=k;
	      result++;
	    }
	}
    }

  //print
  for(i=0; i<N; i++)
    {
      if(i!=N-1)printf("%d ", A[i]);
      else printf("%d", A[i]);;
    }
  printf("\n%d\n", result);



  return 0;
}

Measured memory_bytes: 0
n = gets.to_i
a = gets.split(' ').map(&:to_i)

a_sort = a.sort.reverse

alice = 0
bob = 0

n.times {|i|
  if i.even?
    alice += a_sort[i]
    next
  end

  bob += a_sort[i]
}

puts alice - bob

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a != b && a != c && b != c)
	{
		cout << 3 << endl;
	}
	else if ((a == b && a != c) || (b == c && b != a) || (c == a && c != b))
	{
		cout << 2 << endl;
	}
	else
	{
		cout << 1 << endl;
	}
}


Measured memory_bytes: 256
def main():
    from heapq import heappush, heappop
    N = int(input())
    ans = ["Fennec", "Snuke"]
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = (int(i)-1 for i in input().split())
        edge[a].append((1, b))
        edge[b].append((1, a))

    def dijkstra(s):
        """ 始点sから各頂点への最短距離 O((|E|+|V|)log|V|) """
        d = [10**8]*N
        used = [True] * N  # True:未確定
        d[s] = 0
        used[s] = False
        edges = []
        for e in edge[s]:
            heappush(edges, e)
        while len(edges):
            c, v = heappop(edges)
            if not used[v]:
                continue
            d[v] = c
            used[v] = False
            for nexc, nexv in edge[v]:
                if used[nexv]:
                    heappush(edges, (nexc+c, nexv))
        return d

    d_s = dijkstra(0)
    d_g = dijkstra(N-1)
    # print(d_s, d_g, sep="\n")
    get = [0, 0]
    for s, g in zip(d_s, d_g):
        if s <= g:
            get[0] += 1
        else:
            get[1] += 1
    if get[0] > get[1]:
        print(ans[0])
    else:
        # マスの数同じならsnuke win
        print(ans[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 87916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <set>

using namespace std;

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int> > se(26);

    for (int i = 0; i < n; i++) {
        char c = s[i];
        se[c-'a'].insert(i+1);
    }

    for (int k = 0; k < q; k++) {
        int x;  cin >> x;
        if (x == 1) {
            int i;  char c; cin >> i >> c;
            se[s[i-1]-'a'].erase(i);
            s[i-1] = c;
            se[c-'a'].insert(i);
        }
        if (x == 2) {
            int ans = 0;
            int l, r;   cin >> l >> r;
            for (int j = 0; j < 26; j++) {
                if (se[j].empty())
                    continue;
                auto ite = se[j].lower_bound(l);
                int x = *ite;
                if (l <= x && x <= r)
                    ans++;
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24196
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
int N;
bool so[55556];
std::vector<int> ans;
int main(){
    std::cin>>N;
    so[1]=true;
    for(int i=2;i<=55555;i++){
        if(!so[i]){
            int e=i+i;
            while(e<=55555){
                so[e]=true;
                e+=i;
            }
        }
    }
    for(int i=3;i<=55555;i+=10){
        if(!so[i])ans.push_back(i);
    }
    for(int i=0;i<N;i++){
        std::cout<<ans[i]<<(i<N-1?" ":"\n");
    }
    return 0;
}


Measured memory_bytes: 256
bitcoin = 380000.0

n = int(input())
input_list = []
yen_sum = 0
for i in range(n):
    aaa = str(input())
    in_ = aaa.split(" ")
    x = float(in_[0])
    u = str(in_[1])
    if u=="JPY":
      yen_sum+=x
    else:
      yen_sum += bitcoin*x
print(yen_sum)

Measured memory_bytes: 3060