akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let vs = scan!(usize; n);

    let mut visited = vec![false; n];
    let mut count = 0;
    let mut i = 0usize;
    while i != 1 {
        i = vs[i] - 1;
        if visited[i] {
            break;
        }
        count += 1;
        visited[i] = true;
    }

    if i == 1 {
        println!("{}", count)
    } else {
        println!("-1")
    }
}


Measured memory_bytes: 4476
from math import sin,cos,pi,sqrt
a,b,h,m=map(int,input().split())
m_rad=m/60*2*pi
h_rad=(h*60+m)/720*2*pi
h_x=a*cos(h_rad)
h_y=a*sin(h_rad)
m_x=b*cos(m_rad)
m_y=b*sin(m_rad)
print(sqrt((h_x-m_x)**2+(h_y-m_y)**2))

Measured memory_bytes: 9572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A>B && A>C){
    cout << B*C/2 << endl;
  }
  else if (B>A && B>C){
    cout << A*C/2 << endl;
  }
  else if (C>B && C>A){
    cout << B*A/2 << endl;
  }
}
  

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3624
S = input()

total = 0

for m in range(1 << (len(S) - 1)):
  acm = ''
  for i, s in enumerate(S):
    acm += s
    if 1 << i & m:
      total += int(acm)
      acm = ''
  else:
    if acm:
      total += int(acm)

print(total)      

Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////


signed main(){
int a[3];rep(i,3)cin>>a[i];sort(a, a+3);
if(a[0] == a[1] && a[1] != a[2]){
  cout << "Yes" << endl;
}else if(a[0] != a[1] && a[1] == a[2]){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, long long L, std::vector<std::string> S){
    SORT(S);
    REP(i,N){
        cout<<S[i];
    }
    cout<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, L, std::move(S));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int z = 0;
  int M = 0;
  for (int i = 0; i < N; i++)
    {
      int x, y;
      cin >> x >> y;
      if ( x == y){
        z += 1;
        if ( z == 3 ){
          M += 1;
        }
      }
      else{
        z = 0;
      }
      
      
    }
  if ( M > 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,m,t,k,a[262144],r=0,l;
    double d;
    char s[262144];
    scanf("%s",s);
    l=strlen(s);
    for(i=0;i<l-1;i++){
        if(s[i]==s[i+1]){printf("%d %d\n",i+1,i+2);return 0;}
    }
    for(i=0;i<l-2;i++){
        if(s[i]==s[i+2]){printf("%d %d\n",i+1,i+3);return 0;}
    }
    printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 256
#coding: utf-8

a=gets.chomp
i=0
f=0
co=Array.new(26,0)
while(i<a.length)
	co[a[i].ord-"a".ord]+=1
	i+=1
end
i=0
while(i<26)
	unless(co[i]%2==0)
		f+=1
	end
	i+=1
end
unless(f==0)
	puts("No")
else
	puts("Yes")
end


Measured memory_bytes: 1788
n, d = map(int, input().split())
xs = list()
for i in range(n):
    x = list(map(int, input().split()))
    xs.append(x)


def is_valid(k):
    for i in range(200):
        m = i ** 2
        if k == m:
            return True
        elif k < m:
            return False
    
    return False


ans = 0
for i in range(n):
    for j in range(i + 1, n):
        s = 0
        for e in range(d):
            s += (xs[i][e] - xs[j][e]) ** 2
        if is_valid(s):
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
typedef struct Dice{
	int	f1;
	int	f2;
	int	f3;
	int	f4;
	int	f5;
	int	f6;
	int tmp;
}Dice;

int main(void)
{
	char roll;
	Dice D0;
	scanf("%d%d%d%d%d%d", &D0.f1, &D0.f2, &D0.f3, &D0.f4, &D0.f5, &D0.f6);
	while(scanf("%c", &roll) != EOF){
		switch(roll){
			case 'E':
				D0.tmp = D0.f1;
				D0.f1 = D0.f4;
				D0.f4 = D0.f6;
				D0.f6 = D0.f3;
				D0.f3 = D0.tmp;
				break;
			case 'N':
				D0.tmp = D0.f1;
				D0.f1 = D0.f2;
				D0.f2 = D0.f6;
				D0.f6 = D0.f5;
				D0.f5 = D0.tmp;
				break;
			case 'S':
				D0.tmp = D0.f1;
				D0.f1 = D0.f5;
				D0.f5 = D0.f6;
				D0.f6 = D0.f2;
				D0.f2 = D0.tmp;
				break;
			case 'W':
				D0.tmp = D0.f1;
				D0.f1 = D0.f3;
				D0.f3 = D0.f6;
				D0.f6 = D0.f4;
				D0.f4 = D0.tmp;
				break;
			default:
				break;
		}
	}
	printf("%d\n", D0.f1);
	return 0;
}

Measured memory_bytes: 596
from collections import defaultdict

V, E = map(int, input().split())
G = defaultdict(list)

for i in range(E):
    s, t = map(int, input().split())
    G[s].append(t)

visited = None
p = None
def dfs(v):
    visited[v] = True
    for k in G[v]:
        if k == p:
            print(1)
            exit()
        if not visited[k]: dfs(k)

for v in range(V):
    p = v
    visited = defaultdict(bool)
    dfs(v)
print(0)
    

Measured memory_bytes: 8096
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int main()
{
    FASTIO
    //   L(T)
    lli n;
    char a[10000], b[10000];
    cin >> a >> b;
    //    cin>>n;
    lli len1, len2;
    len1 = strlen(a);
    len2 = strlen(b);

    fw(i, 0, len1)
    {
        if (a[i] != b[i])
        {
            cout << "No\n";
            return 0;
        }
    }
    if (len1 + 1 == len2)
    {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";

    // cout << return 0;
}

Measured memory_bytes: 3660
#include	<bits/stdc++.h>
using	namespace	std;
typedef	long long ll;

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	int Q;
	cin >>S >>Q;
	string S0, S1;
	bool R=false;
	Rep0(i, Q) {
		int t;
		cin >>t;
		if (1==t) {
			R=!R;
		} else {
			int f;
			char c;
			cin >>f >>c;
			if (1==f) {
				if (!R)
					S0.push_back(c);
				else
					S1.push_back(c);
			} else {
				if (!R)
					S1.push_back(c);
				else
					S0.push_back(c);
			}
		}
	}
	if(!R) {
		Rev(S0);
		cout <<S0 <<S <<S1 <<endl;
	} else {
		Rev(S);
		Rev(S1);
		cout <<S1 <<S <<S0 <<endl;
	}
	return 0;
}



Measured memory_bytes: 1088
#include <stdio.h>

int main(){
long A,B;
  long small,big;
long LCM;
  int i;
  
  scanf("%ld %ld",&A,&B);
  if(A<B){
    small = A;
    big  = B;
  }else{
    small = B;
       big = A;
  }
  
 for(i = 1;i  <= big;i++){
    LCM = small * i;
    if(LCM%big == 0) break;
  }
  
  printf("%ld\n",LCM);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	cin >> n;
	int h, t, w;
	for (int i = 1; i < 3600; i++) {
		for (int j = 2; j < 3600; j++) {
			if ((4 * i * j - n * (i + j)) > 0 && (n * i * j) % (4 * i * j - n * (i + j)) == 0) {
				w = (n * i * j) / (4 * i * j - n * (i + j));
				h = i, t = j;
				cout << h << " " << t << " " << w << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  ll x;
  cin >> x;
  ll start = 100;
  int need = 0;
  while(start < x) {
    need++;
    start = start * 0.01 + start;
  }
  cout << need << endl;
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}
void solve() {
    ll n;
    cin >> n;
    vl d = divisor(n);
    sort(all(d));
    ll ans = 0;
    each(e, d) {
        if (n % e == 0 && prime_factor(e).size() == 1) {
            n /= e;
            ans++;
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
int i,j,h,w;
char str[101][101];
scanf("%d %d",&h,&w);
for(i=1;i<=h;i++)
{
        scanf("%s",&str[i][1]);
    
}
i=1;
j=1;
while(i<=w+2){
    printf("#");
    i++;
}
printf("\n");
for(i=1;i<=h;i++)
{
    printf("#");
    for(j=1;j<=w;j++)
    {
        printf("%c",str[i][j]);
    }
    printf("#\n");
}
i=1;
while(i<=w+2){
    printf("#");
    i++;
}
}

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n), b(n);
	ll rem = 0;
	REPU(i, 0, n) cin >> a[i];
	REPU(i, 0, n) {
		cin >> b[i];
		rem += a[i] - b[i];
		b[i] = a[i] - b[i];
	}
	if (rem < 0) {
		puts("-1"); return 0;
	}

	int ans = 0;
	if (rem > 0) {
		sort(ALL(b));
		int i = 0, j = n - 1;
		rem = 0;
		while (i <= j && b[i] < 0) {
			if (b[i] + rem >= 0) {
				ans++;
				rem += b[i++];
			}
			else {
				rem += b[j--];
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

void solve()
{
	int H;
	cin >> H;
	vector<int> heap(H);
	for (int i = 0; i < H; ++i)
	{
		cin >> heap[i];
	}
	for (int i = 0; i < H; ++i)
	{
		cout << "node " << i + 1 << ": key = " << heap[i] << ", ";
		if ((i - 1) / 2.0 >= 0)
		{
			cout << "parent key = " << heap[(i - 1) / 2] << ", ";
		}
		if (i * 2 + 1 < H)
		{
			cout << "left key = " << heap[i * 2 + 1] << ", ";
		}
		if (i * 2 + 2 < H)
		{
			cout << "right key = " << heap[i * 2 + 2] << ", ";
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 1196
def prime?(n)
  return true if n == 2
  return false if n.even?
  3.step(Math.sqrt(n), 2) {|i| return false if n.modulo(i).zero? }
  return true
end

n = gets.to_i
numbers = []
n.times { numbers << gets.to_i }
result = numbers.select { |i| prime?(i) }
puts result.size

Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  int x,n;
  cin >> x >> n;

  int work[102];
  rep(i,102){
    work[i] = 0;
  }

  rep(i,n){
    int p;
    cin >> p;
    work[p]++;
  }

  int ans = -1;
  for(int i=x;i<102;i++){
    if(work[i] == 0){
      ans = i;
      break;
    }
  }

  for(int i=x;-1<i;i--){
    if(work[i] == 0 && x-i <= ans-x){
      ans = i;
    }
  }

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


Measured memory_bytes: 3624
#include<cstdio>
int lowbit(int x) {
	return x & -x;
}
int main() {
	int N; scanf("%d", &N);
	if( lowbit(N) == N ) {
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=2;i<N;i+=2) {
		printf("1 %d\n1 %d\n", i, i+1);
		printf("%d %d\n%d %d\n", i, i+1+N, i+N, i+1);
	}
	if( N % 2 == 0 ) {
		int p = lowbit(N);
		printf("%d %d\n", p+1, N);
		printf("%d %d\n", N-p, 2*N);
	}
	printf("%d %d\n", 1 + N, 2 + N);
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

int main() {
  ll n;
  cin >> n;
  ll a = 0;
  ll b = 0;
  vector<bool> used(8,false);
  REP(i,n){
    ll tmp = 1;
    FOR(j,1,n-i) tmp*=j;
    ll pi;
    cin >> pi;
    ll pid = 0;
    REP(j,pi){
      if(!used[j]) pid++;
    }
    tmp *= pid-1;
    a += tmp;
    used[pi-1] = true;
  }
  REP(i,n) used[i] = false;
  REP(i,n){
    ll tmp = 1;
    FOR(j,1,n-i) tmp*=j;
    ll pi;
    cin >> pi;
    ll pid = 0;
    REP(j,pi){
      if(!used[j]) pid++;
    }
    tmp *= pid-1;
    b += tmp;
    used[pi-1] = true;
  }
  ll ans = abs(a-b);
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<complex>
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
template<class T> T at(vector<T> v, int i) {return v[i % v.size()];}

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;
const D PI = acos(-1);

// 比較関数
int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}
namespace std {
  bool operator<(P a, P b) {return sig(a.X, b.X) ? a.X < b.X : a.Y < b.Y;}
}

// 平方根
D sr(D a) {return sqrt(max(a, (D)0));}

// 内積
D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// 外積
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// 線分のベクトル
P vec(L a) {return a.b - a.a;}

// 有向角度
D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

// 射影
P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.a + proj(vec(l), p - l.a);}

// 円
struct C{P c; D r;};

// 交点
pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(x - c.c));
  return make_pair(x - y, x + y);
}

// 円と多角形の共通部分面積
D aCTnc(D r, P p1, P p2) {return sig(abs((p1 + p2) / (D)2), r) <= 0 ? det(p1, p2) / 2 : r * r * arg(0, p1, p2) / 2;}
D aCT(D r, P p1, P p2) {
  if (!sig(r) || near(0, p1) || near(0, p2) || near(p1, p2)) return 0;
  pair<P, P> pp = pCL((C){0, r}, (L){p1, p2});
  if ((p1 < pp.first) != (pp.first < p2) && (p1 < pp.second) != (pp.second < p2)) return aCTnc(r, p1, p2);
  return aCTnc(r, p1, pp.first) + aCTnc(r, pp.first, pp.second) + aCTnc(r, pp.second, p2);
}
D aCPol(C c, Pol pol) {D res = 0; rep (i, pol.size()) res += aCT(c.r, pol[i] - c.c, at(pol, i + 1) - c.c); return res;}

int main() {
  int n, r;
  cin >> n >> r;
  Pol pol(n);
  rep (i, n) cin >> pol[i].X >> pol[i].Y;
  D res = 0;
  for (int i = 1; i < r; i += 2) res += (2 * i + 1) * PI - (aCPol((C){0, (D)i + 1}, pol) - aCPol((C){0, (D)i}, pol));
  for (int i = 0; i < r; i += 2) res += aCPol((C){0, (D)i + 1}, pol) - aCPol((C){0, (D)i}, pol);
  printf("%.12Lf\n", res);
  return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

struct UnionFind {
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) { }
  bool unionSet(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};

//UnionFind arr(n);で０～n-1バラバラが生成
//arr.findSet(x,y)同じ集合か
//arr.size(x)xが属す要素の個数
//arr.unionSet(x,y)xが属す集合とyが属す集合をマージ
//arr.root(x)
int main()
{
ll n,k,l;
cin >> n>>k>>l;
UnionFind road(n);
rep(i, k){
    ll p,q;
    cin >> p>>q;
    road.unionSet(p-1,q-1);
}
UnionFind rail(n);
rep(i, l){
    ll p,q;
    cin >> p>>q;
    rail.unionSet(p-1,q-1);
}
map<pair<ll,ll>,ll> m{};
rep(i,n){
    m[{road.root(i),rail.root(i)}]+=1;
}
rep(i,n){
    cout << m[{road.root(i),rail.root(i)}]<<" ";
}
cout <<  endl;
return 0;
}


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

using namespace std;
using ll = long long;



int main()
{
    string s; cin >> s;
    for(auto &i: s)i -= '0';
    int f = (s[0] * 10 + s[1]);
    int b = (s[2] * 10 + s[3]);
    // cout << f << b << endl;
    if(f == 0) {

        if(b == 0 || b > 12) cout << "NA" << endl;
        else cout << "YYMM" << endl;

    }else if(f <= 12) {

        if(b == 0 || b > 12) cout << "MMYY" << endl;
        else cout << "AMBIGUOUS" << endl;

    } else if(f > 12) {

        if(b == 0 || b > 12) cout << "NA" << endl;
        else cout << "YYMM" << endl;

    }

}

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


int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  cout << min(N % (A + B), A) + N / (A + B) * A << endl;
  return 0;
}


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

int main()
{
	//input
	int N, Y; cin >> N >> Y;
	//compute
	int x_r = -1, y_r = -1, z_r = -1;
	for (int x = 0; x <= N; x++){
		for (int y = 0; y + x <= N; y++){
			if(10*x + 5*y + N-x-y == Y / 1000) {
				x_r = x;
				y_r = y;
				z_r = N-x-y;
			}
		}
	}
	
	//output
cout << x_r << " " << y_r << " " << z_r << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int a,b;

	scanf("%d%d",&a,&b);

	if(a<=0&&b>=0)printf("Zero");
	else if(0<a)printf("Positive");
	else if(0>b){
		if((b-a+1)%2==0)printf("Positive");\
		else{printf("Negative");}
		}

	return 0;
}

Measured memory_bytes: 128
/**
*    author:  yuya1234
*    created: 26.06.2020 11:45:39
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;

    ll a1,a2,a3;

    if(x>y)
    {
        a1=c*x*2;
        a2=c*y*2+a*(x-y);
    }
    else
    {
        a1=c*y*2;
        a2=c*x*2+b*(y-x);
    }
    a3=a*x+y*b;

    ll ans;
    ans=min(a1,a2);
    cout<<min(ans,a3)<<endl;
    

    return 0;
}

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

namespace Solution
{
    public struct Request
    {
        public int first;
        public int second;
    }

    public struct Problem
    {
        public int island;
        public int request;
        public List<Request> requests;
    }

    public class Parser
    {
        public static Problem Parse(List<string> lines)
        {
            var info = lines[0].Split(' ');
            var island = int.Parse(info[0]);
            var request = int.Parse(info[1]);

            var requests = new List<Request>();
            foreach (var line in lines.Skip(1))
            {
                var split = line.Split(' ');
                var req = new Request()
                {
                    first = int.Parse(split[0]),
                    second = int.Parse(split[1])
                };
                requests.Add(req);
            }

            return new Problem()
            {
                island = island,
                request = request,
                requests = requests
            };
        }
    }

    public class Solution
    {
        Problem problem;

        public Solution(Problem problem)
        {
            this.problem = problem;
        }

        public int Solve()
        {
            var bridge = 0;
            var requests = this.problem.requests.OrderBy(r => r.second).ToArray();
            while (requests.Length > 0)
            {
                var position = requests[0].second;
                bridge += 1;
                requests = requests.Where(r => r.first >= position).ToArray();
            }
            return bridge;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var lines = new List<string>();
            while (true)
            {
                var line = Console.ReadLine();
                if (line == null)
                {
                    break;
                }
                lines.Add(line);
            }
            var problem = Parser.Parse(lines);
            var solution = new Solution(problem);
            Console.WriteLine(solution.Solve());
        }
    }
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;cin>>n;

    cout<<(n+1)/2<<"\n";

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    bool flag = false;
    rep(i, 26) rep(j, 15) if(N == 4*i+7*j) flag = true;
    if(flag) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

long a[220000];
long b[220000];

int main() {
	int m, n, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) break;
		ans = max(ans, int(i + (lower_bound(b, b + m + 1, k - a[i] + 1) - b)) - 1);
	}
	cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

vector<ll> v[510000];

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0) cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;

    return 0;
}

Measured memory_bytes: 12160
import sys
N = int(input())
W = [input() for i in range(N)]

for i in range (0,N):
  for j in range (i+1,N):
    if W[i] == W[j]:
      print("No")
      sys.exit()
for i in range (0,N-1):
  if W[i][-1] != W[i+1][0]:
    print("No")
    sys.exit()
print("Yes")


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, t; cin >> n >> t;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> mi(n), ma(n);
  mi[0] = a[0]; ma[n - 1] = a[n - 1];
  for (int i = 1; i < n; i++) {
    mi[i] = min(mi[i - 1], a[i]);
    ma[n - 1 - i] = max(ma[n - i], a[n - 1 - i]);
  }
  vector<int> dif(n);
  for (int i = 0; i < n - 1; i++) dif[i] = ma[i + 1] - mi[i];
  int m = *max_element(dif.begin(), dif.end());
  int res = 0;
  dif.push_back(-1);
  for (int i = 0; i < n; i++) res += dif[i] == m and dif[i + 1] != m;
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
    int a, b, count;
    int i, j, k;
    while(1){
    count =0;    
    scanf("%d%d", &a, &b);
    if(a==0 && b==0)break;
    else{
    for(i=1;i<=a;i++){
        for(j=i+1;j<=a;j++){
            for(k=j+1;k<=a;k++){
                if(i+j+k ==b)
                    count++;
            }
        }
    }}
    printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void){
	char in[256];
	fgets(in, 255, stdin);
	int len = strlen(in) - 1;
	in[len] = '\0';
	for(int i=0; i<len; ++i){
		in[i] = toupper(in[i]);
	}
	puts(in);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    for (int i = m / n; i > 0; i--) {
        if(m % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [[i]+list(map(int, input().split())) for i in range(M)]

PY = sorted(PY, key=lambda x: (x[1], x[2]))
cur = [0 for _ in range(N)]
ans_list = []
for i in range(M):
    ans = '0'*(6-len(str(PY[i][1]))) + str(PY[i][1])
    cur[PY[i][1]-1] += 1
    ans += '0'*(6-len(str(cur[PY[i][1]-1]))) + str(cur[PY[i][1]-1])
    ans_list.append([PY[i][0], ans])

ans_list = sorted(ans_list, key=lambda x: x[0])
for i, v in enumerate(ans_list):
    print(v[1])


Measured memory_bytes: 43396
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0)cout << "Even";
	else cout << "Odd";


	return 0;
}





Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var sa, sb, sc string
	fmt.Scan(&sa, &sb, &sc)

	s := sa[0:1]
	for {
		switch s {
		case "a":
			if len(sa) == 0 {
				fmt.Println("A")
				return
			}
			s = sa[0:1]
			sa = sa[1:]
		case "b":
			if len(sb) == 0 {
				fmt.Println("B")
				return
			}
			s = sb[0:1]
			sb = sb[1:]
		case "c":
			if len(sc) == 0 {
				fmt.Println("C")
				return
			}
			s = sc[0:1]
			sc = sc[1:]
		}
	}
}


Measured memory_bytes: 512
import java.util.Scanner

// [(a,b,c) | abc<=k]をソート (リファクタリング)
object Main {
  def read(): (Int, Int, Int, Int, IndexedSeq[Long], IndexedSeq[Long], IndexedSeq[Long]) = {
    val sc = new Scanner(System.in)
    val n1, n2, n3, k = sc.nextInt()
    val l1 = for (_ <- 0 until n1) yield sc.nextLong()
    val l2 = for (_ <- 0 until n2) yield sc.nextLong()
    val l3 = for (_ <- 0 until n3) yield sc.nextLong()
    (n1, n2, n3, k, l1, l2, l3)
  }


  def solve(n1: Int, n2: Int, n3: Int, k: Int, l1: IndexedSeq[Long], l2: IndexedSeq[Long], l3: IndexedSeq[Long]): IndexedSeq[Long] = {
    val indexListRequirementOfTopk: IndexedSeq[(Int, Int, Int)] = (for (i1 <- l1.indices; i2 <- l2.indices) yield {
      // [(i1,i2,i3) | i3<- l3.indices, (i1+1)*(i2+1)*(i3+1)<=k]を求めたい。
      // 愚直にfilterすると遅いので、i3 => (i1+1)*(i2+1)*(i3+1)の単調性を利用する
      def sub(i3: Int): List[Int] = {
        if (!l3.isDefinedAt(i3)) Nil
        else if ((i1 + 1) * (i2 + 1) * (i3 + 1) > k) Nil
        else i3 :: sub(i3 + 1) // 非末尾再帰
      }

      sub(0).map(i3 => (i1, i2, i3))
    }).flatten

    val sortedL1 = l1.sorted.reverse
    val sortedL2 = l2.sorted.reverse
    val sortedL3 = l3.sorted.reverse
    indexListRequirementOfTopk.map { case (i1, i2, i3) => sortedL1(i1) + sortedL2(i2) + sortedL3(i3) }.sorted.reverse.take(k)
  }

  def printResult(result: IndexedSeq[Long]) = {
    result.foreach(println)
  }


  def main(args: Array[String]): Unit = {
    val (n1, n2, n3, k, l1, l2, l3) = read()
    printResult(solve(n1, n2, n3, k, l1, l2, l3))
  }
}

Measured memory_bytes: 62596
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

ll dp[55][55][2555];
int main(void){
  ll n,a,t;
  cin>>n>>a;
  vector<ll> x;
  x.pb(0);
  for(int i=0;i<n;i++){
    cin>>t;
    x.pb(t);
  }

  for(ll j=0;j<=n;j++){
    for(ll k=0;k<=n;k++){
      for(ll s=0;s<=n*50;s++){
        if((j==0)&&(k==0)&&(s==0)) dp[j][k][s]=1;
        else if((j>=1)&&(s<x[j])) dp[j][k][s]=dp[j-1][k][s];
        else if((j>=1)&&(k>=1)&&(s>=x[j])) dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
        else dp[j][k][s]=0;
      }
    }
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=dp[n][i][i*a];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 57472
#include<stdio.h>

int main(){
  int N, K, x, i, d;
  
  scanf("%d", &N);
  scanf("%d", &K);
  
  for (i = 0; i < N; i++){
    scanf("%d", &x);
    if(x <= K/2){
      d += x;
    } else {
      d += K - x;
    }
  }
  
  printf("%d\n", 2*d);
  
  return 0;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;
const int mod = 1e9 + 7;

using namespace std;

int main(void) {
	int a, b; cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <set>

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

  std::set<int> x;
  x.insert(s);
  int i = 1;
  while (true) {
    int n = (s%2>0? 3*s+1:s/2);
    // fprintf(stderr, "%d\n", n);
    if (x.count(n))
      return !printf("%d\n", ++i);

    s = n;
    x.insert(s);
    ++i;
  }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool flag = true;
  while (a > 0 && c > 0) {
    if (flag) {
      c -= b;  
    } else {
      a -= d;
    }
    flag ^= 1;
  }
  if (a > 0) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

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

using namespace std;

const int NS = (int)2e5+4;
int N;
char arr[NS];

int main(){
    scanf("%d", &N); scanf("%s", arr+1);
    int A = 0, B = 0, ans = (int)1e9;
    for(int i=1;i<=N;++i) if(arr[i]!='#') ++B;
    ans = min(ans, B);
    for(int i=1;i<=N;++i){
        if(arr[i]=='#') ++A;
        if(arr[i]=='.') --B;
        ans = min(ans, A+B);
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

const int P = 1000000007;

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

	if(n == 0) {
		cout << 0 << '\n';
		exit(0);
	}	

	long long x = 1;
	for(int i = 0; i < n; ++i) {
		x = x * 10 % P;
	}

	long long y = 2;
	for(int i = 0; i < n; ++i) {
		y = y * 9 % P;
	}

	long long z = 1;
	for(int i = 0; i < n; ++i) {
		z = z * 8 % P;
	}

	cout << (x - y + z + P) % P << '\n';

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    string t;cin>>t;
    int s=t.size();
    if(s==2){
        if(t.at(0)==t.at(1))cout<<1<<' '<<2<<endl;
        else cout<<-1<<' '<<-1<<endl;
    }
    else{
        bool ans=true;
        rep(i,s-3){
            char c1=t.at(i);char c2=t.at(i+1);char c3=t.at(i+2);
            if(c1==c2){cout<<i+1<<' '<<i+2<<endl;ans=false;break;}
            else if(c2==c3){cout<<i+2<<' '<<i+3<<endl;ans=false;break;}
            else if(c1==c3){cout<<i+1<<' '<<i+3<<endl;ans=false;break;}
        }
        if(ans)cout<<-1<<' '<<-1<<endl;
    }
}

Measured memory_bytes: 512
def main():
    a = int(input())
    ans = num2alpha(a)
    print(ans)

def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define M 200005
int a[M];
int main(){
	int n,now=0,l=1;ll ans=0;
	scanf("%d",&n);
	for(int r=1;r<=n;r++){
		scanf("%d",&a[r]);
		while((a[r]^now)!=a[r]+now)now^=a[l++];
		now^=a[r];
		ans+=r-l+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    static const double mypi = 3.141592653589793;
    double thetaA,thetaB,dx,dy,d;
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    
    thetaA = mypi * (H+(M/60))/6;
    thetaB = mypi * M/30;
    double Ax = sin(thetaA)*A,
           Bx = sin(thetaB)*B,
           Ay = cos(thetaA)*A,
           By = cos(thetaB)*B;
    dx = Ax-Bx;
    dy = Ay-By;
    d = sqrt(dx*dx + dy*dy);
    cout << fixed << setprecision(10);
    cout << d << '\n';
    return 0;
}

Measured memory_bytes: 4108
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
 
using namespace std;
 
int W , N ;
int dp[1024][1024];
int w[1024] , v[1024],O;
char cn;

int main ()
{
  int cont = 1;
  while(cin >> W >> N){
    
    for(int i = 0; i < N; i++)
      cin >> v[i] >> cn >> w[i] ;
    
    for(int i = N-1; i >= 0; i--)
      {
        for(int j = 0; j <= W; j++)
	  {
            if( j < w[i]) dp[i][j] = dp[i+1][j];
            else dp[i][j] = max( dp[i+1][j] , dp[i+1][j-w[i]]+v[i] );
	  }
      }
    for(int i = 0; i <=W; i++)
      if(dp[0][i]==dp[0][W]){
	O = i;
	break;
      }
    cout << "Case " << cont <<':' <<endl;
    cout << dp[0][W] << endl << O <<endl;
    //cout << << endl;
    /*  
    for(int i = 0; i < 10 ; i++)
      {       
	for(int j = 0; j <= 50; j++)
	  printf("%3d", dp[i][j]);
        puts("");
      }    
      }*/
    cont++;
  }
}

Measured memory_bytes: 0