akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ABC125_B
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            List<int> vList = new List<int>();
            List<int> cList = new List<int>();
            string[] input = Console.ReadLine().Split();
            for(int i = 0; i < n; i++) {
                vList.Add(int.Parse(input[i]));
            }
            input = Console.ReadLine().Split();
            for (int i = 0; i < n; i++) {
                cList.Add(int.Parse(input[i]));
            }

            int sum = 0;
            for(int i = 0; i < n; i++) {
                if (vList[i] - cList[i] > 0)
                    sum += vList[i] - cList[i];
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char s[101],keyence[] = "keyence";
    int i,j,k;
    char *res;
    scanf("%s",s);

    int len = strlen(s);
    for (i = 0; i < len; i++)
    {
        k = 0;
        for (j = 0; j < i; j++)
        {
            if(s[j] == keyence[k])k++;
        }
        if(k != i)
        {
            continue;
        }
        for (j = len - 7 + i; j < len; j++)
        {
            if(s[j] == keyence[k])k++;
        }
        if(k == 7)break;
    }
    printf("%s\n",i == len ? "NO" : "YES");
}

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

using namespace std;

int main() {
	int n;

	cin >> n;

	int A[n];

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

	if (prev_permutation(A, A + n)) {
		for (int i = 0; i < n; i++) {
			if (i == 0)	cout << A[i];
			else cout << " " << A[i];
 		}
		cout << endl;
	}
	next_permutation(A, A + n);

	for (int i = 0; i < n; i++) {
		if (i == 0)	cout << A[i];
		else cout << " " << A[i];
	}
	cout << endl;

	if (next_permutation(A, A + n)) {
		for (int i = 0; i < n; i++) {
			if (i == 0)	cout << A[i];
			else cout << " " << A[i];
		}
		cout << endl;
	}
}




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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); ++i){
    if(i== 3){
      cout << '8';
    }else{
      cout << s[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int n, m, b, i, j, x, y, s, g;
vector <pair <int, int> > map(1000);
vector <int> from(1000, 1001);

double dist(int mi, int j) {
  double d =  sqrt(1.0 * (map[j].first - map[mi].first) * (map[j].first - map[mi].first) + (map[j].second - map[mi].second) * (map[j].second - map[mi].second));
  if(d <= 50) return d;
  else        return 100000000;
} 

double dik(){
  int f[1000] = {};
  int mi = s;
  vector <int> cost(1000, 100000000);
  cost[mi] = 0;
  
  for(i = 0; i < 1000; i++) {
    f[mi] = 1;
    
    for(j = 0; j < 1000; j++)
      if(!f[j] && map[j].first != 100000000 && cost[j] > cost[mi] + dist(mi, j)) {
        cost[j] = cost[mi] + dist(mi, j);
        from[j] = mi;
      }
    int min = 200000000;
    for(j = 0; j < 1000; j++)
      if(!f[j] && min > cost[j]) min = cost[mi = j];
  }
  return cost[g];

}


int main(){
  while(cin >> n, n != 0) {
    for(i = 0; i < 1000; i++) {
      map[i].first = 100000000; map[i].second = 100000000;
    }
    
    while(n--){
      cin >> b >> x >> y;  b--;  x--;  y--;
      map[b].first = x; map[b].second = y;
    }
    
    cin >> m;
    while(m--) {
      cin >> s >> g; s--; g--;
      int ans[1000] = {};
      for(i = 0; i < 1000; i++) from[i] = 1001;
      if(dik() != 100000000) {
	
	for(i = g,j = 0; i < 1000; j++){
	  ans[j] = from[i] + 1;
	  i = from[i];
	}
	//	cout << ans[0] << ' ' << ans[1]  <<' '<< ans[2]  << ' ' << ans[3] << endl;
	for(i = j - 2; i >= 0; i--)  cout << ans[i] << ' ';
	cout << g + 1 << endl;
      }
      
      else cout << "NA" << endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1220
mod = 10 ** 9 + 7

N = int(input())
A = [(int(input()), False) for _ in range(N)]
B = [(int(input()), True) for _ in range(N)]

C = sorted(A + B)

res = 1
cnt = 0
for _, ab in C:
    delta = 1 if ab else -1
    if cnt != 0 and (cnt > 0) != ab:
        res *= abs(cnt)
        res %= mod
    cnt += delta

print(res)

Measured memory_bytes: 29248
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define f first
#define s second
signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0,z;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,zz=0,d=0,val=0;
    
    string a,b,c;
   
    cin>>a;
     n = a.length();
    b = a.substr(0, ((n-1)/2));
    c = a.substr((n+1)/2 , (n-1)/2);
    
    
    
    string bb,cc,aa;
    bb=b;
    reverse(bb.begin() , bb.end());
    cc = c;
    reverse(cc.begin() , cc.end());
    
    aa = a;
    reverse(aa.begin() , aa.end());
    
    if(a==aa && b==bb && c==cc)
    {
        cout<<"Yes"<<endl;
    }
    
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);
        int N = Integer.parseInt(SC.next());

        if((N & 1) == 1)
        N += 1;
        System.out.println(N/2);
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 22356
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, k] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

let a = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const res = _ => {
  const d = k - 1
  const l = n - 1
  return Math.ceil(l / d)
}

console.log(res())


Measured memory_bytes: 16716
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    bool flag = abs(x - a) > abs(x - b) ? 0 : 1;
    if(flag) {
        cout << 'A' << endl;
    }
    else {
        cout << 'B' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
int main(void){

    char str[3000];
    char *tok;
    int m,n;
    int i1,i2,i3,i4,i44;
    int gn,gm,sn,sm;
    int fin=0;
    int nn,nm;
    int a[1000][1000];
    int b[8000][2]; //searching list
    int c[8000][2]; //next searching list
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    m=strtol(tok,NULL,10);
    tok=strtok(NULL," ");
    n=strtol(tok,NULL,10);
    //printf("m=%d,n=%d",m,n);
  
	printf("%f",((float)m)/((float)n));
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
int A,B,C,D;
scanf("%d %d %d %d",&A,&B,&C,&D);
int x=(A+D-1)/D;
int y=(C+B-1)/B;
if(x>=y){
    printf("Yes\n");
}else{
    printf("No\n");
}
return 0;
}

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

int main() {
  ll e;

  while(cin >> e && e>0){
    ll ans = 1e9;
    //cout << e << endl;
    for(ll z=0; (z*z*z)<=e; z++){
      for(ll y=0; y*y+(z*z*z)<=e; y++){
        //cout << z*z*z <<endl;
        ll x = e-y*y-(z*z*z);
        //cout << x <<" "<< y <<" "<< z<<endl;
        ans = min(y+z+x, ans);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3000
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int r, s, p;
string t;
string tv;

int pointer(char c) {
  if(c == 'r') {
    return p;
  } else if(c == 's') {
    return r;
  } else {
    return s;
  }
}

char win(char c) {
  if(c == 'r') {
    return 'p';
  } else if(c == 's') {
    return 'r';
  } else {
    return 's';
  }
}

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

  cin >> n >> k >> r >> s >> p >> t;

  int ans = 0;
  REP(i, n) {
    if(i < k) {
      ans += pointer(t[i]);
      tv.push_back(win(t[i]));
    } else {
      char w = win(t[i]);
      if(w == tv[i - k]) {
        tv.push_back('n');
      } else {
        ans += pointer(t[i]);
        tv.push_back(w);
      }
    }
  }

  cout << ans << endl;
}


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

int main() {
	// your code goes here
	double t,x;
	cin>>t>>x;
	double ans;
	ans=t/x;
	// cout<<ans<<endl;
	cout << fixed << showpoint;
    cout << setprecision(10);
    cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.d = [-1] * n

    def find(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]


N, M, K = map(int, input().split())
NMAX = 100005
deg = [0] * NMAX
to = [[] for _ in range(NMAX)]
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)
anss = []
for i in range(N):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    anss.append(ans)
print(" ".join(map(str, anss)))



Measured memory_bytes: 117024
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define LL long long
#define pb push_back
#define make_pair
#define maxn 110
#define Pii pair<int,int>
using namespace std;
int mmp[maxn][maxn];
int n,m,k;
int c[10010];
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++){
		scanf("%d",&c[i]);
	}
	int now=1;
	for(int i=1;i<=n;i++){
		if(i%2==1){
			for(int j=1;j<=m;j++){
				if(c[now]>0){
					c[now]--;
					mmp[i][j]=now;
					if(c[now]==0) now++;
				}		
			}
		}
		else{
			for(int j=m;j>=1;j--){
				if(c[now]>0){
					c[now]--;
					mmp[i][j]=now;
					if(c[now]==0) now++;
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			printf("%d%s",mmp[i][j],j==m?"\n":" ");
		}
	}
	return 0;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class CSyntheticKadomatsu {
    int N, A, B, C;
    int l[8];
public:
    int dfs(int cur, int a, int b, int c) {
        if (cur == N) {
            return min(a, min(b, c)) > 0 ? abs(a - A) + abs(b - B) + abs(c  - C) - 30 : INF;
        }
        int ans = INF;
        ans = min(ans, dfs(cur+1, a+l[cur], b, c) + 10);
        ans = min(ans, dfs(cur+1, a, b+l[cur], c) + 10);
        ans = min(ans, dfs(cur+1, a, b, c+l[cur]) + 10);
        ans = min(ans, dfs(cur+1, a, b, c));
        return ans;
    }
	void solve(std::istream& in, std::ostream& out) {
        in >> N >> A >> B >> C;
        REP(i, N) in >> l[i];
        out << dfs(0, 0, 0, 0) << '\n';
	}
};


int main() {
	CSyntheticKadomatsu solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main (void)
{
	char W[11] ;
    char T[1001] ;
    char END[12] = "END_OF_TEXT";		//??????????????¨
    
    int counter = 0;       				//???????????°
    int i = 0 ;	
    int j = 0 ;						//???????????°
    
    scanf("%s", W);						//??¢????????????W???????´?
    
    for(i = 0 ; W[i] != '\0' ; i++)
    {
    	W[i] = tolower(W[i]);       	//W????°??????????
    }

	/*????????????????????????????????????*/
    
    while(1)
    {
    	scanf("%s", T);					//T????¬?????????????????´?
        if(strcmp(T,END)==0)     		//T???END_OF_TEXT??§????????´???
        {
        	break;                      //?????????????????????
        }
        
        for(j = 0 ; T[j] != '\0' ; j++)
    	{
    		T[j] = tolower(T[j]);       	//T????°??????????
   		}
        
        if(strcmp(W,T)==0)
        {
        	counter++;
        }
    }
    
    printf("%d\n",counter);				//???????????¨???

    return 0;

}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    set<int> s;
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        s.insert(x);
        mp[x]++;
    }
    vector<int> a;
    for (int si : s) a.push_back(si);
    int cnt = 0;
    int len = a.size();
    for (int i = 0; i < len - 2; i++) {
        for (int j = i+1; j < len-1; j++) {
            for (int k = j+1; k < len; k++) {
                int s = a[i], t = a[j], u = a[k];
                if ((abs(s - t) < u) && (u < (s + t))) {
                    cnt += mp[s] * mp[t] * mp[u];
                }
            }
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

a,b = inputIL()

if a<=b:
  print(a)
else:
  print(a-1)


Measured memory_bytes: 63980
import java.util.*;
import java.util.stream.*;

/**
 * Permutation Oddness
 * P={p1, p2, ..., pn} 1,2,...,n の順列
 * d(P) = sum(|i-pi|, 1<=i<=n)
 * d(A)=k となる A の個数
 */
public class Main {
	Scanner sc;
	int N;
	int K;
	long[][][] dp;

//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	/**
	 * アルゴリズム本体
	 */
	private void calc() {
		long mod = 1000000007L;
		dp = new long[N+1][N+1][K+1];
		dp[0][0][0]=1;
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <=i; j++) {
				for (int k = 2*j; k <= K; k++) {
					if (j > 0) dp[i][j][k] = dp[i-1][j-1][k-2*j];
					dp[i][j][k] = (dp[i][j][k] + (2*j + 1) * dp[i-1][j][k-2*j]) % mod;
					if (j < N) dp[i][j][k] = (dp[i][j][k] + (j+1)*(j+1)*dp[i-1][j+1][k-2*j]) % mod;
				}
			}
		}
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	private void input() {
		N = sc.nextInt();
		K = sc.nextInt();
	}
	
	private void output() {
		out(dp[N][0][K]);
	}
	
//======
// main
//
	public static void main(String[] args) {
		Main m = new Main();
		m.input();
		m.calc();
		m.output();
	}

}

Measured memory_bytes: 85900
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	ll k;
	cin >> k;
	ll a = 7;
	ll keta = 1;
	rep(i, 10000000)
	{
		a = a % k;
		if (a == 0)
		{
			cout << i + 1 << endl;
			return 0;
		}
		keta = (keta * 10) % k;
		a += (7 * keta) % k;
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;

}



Measured memory_bytes: 256
MODE = "stdio"
require 'matrix'

tmp = Array.new

class Integer
  def divisor_list2
    return [1] if self == 1
    (1..Math.sqrt(self).to_i).select do |i|
      self%i == 0
    end.map {|e| [e, self/e]}.flatten.uniq.sort
  end
end

if(defined? MODE)
  tmp = STDIN.read.split("\n")
else
  iotmp = "\
  46979
  ".split("\n")
  iotmp.each{|s|
    tmp << s.strip
  }
end


class Time
  def initialize(time)
    @time = time
  end
  def hour
    @time/3600
  end
  def min
    @time%3600/60
  end
  def sec
    @time%3600%60
  end
  def display
    print hour,":",min,":",sec,"\n"
  end
end




sec = tmp[0].to_i

tm = Time.new(sec)

tm.display

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

int main(){
  long long X,Y;
  X=0;
  Y=0;
  cin>>X>>Y;
  if(X%Y==0){
    cout<<-1<<endl;
    return 0;
  }
  
  while(X<=10'0000000000'00000000){
    if(X%Y!=0){
      cout<<X<<endl;
      return 0;
    }
    X=X+X;
  }
  cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;

#define NL '\n'
#define eps 1e-9
#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define pf push_front
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define _min3(a,b,c) min(a,min(b,c))
#define _max3(a,b,c) max(a,max(b,c))
#define _min4(a,b,c,d) min(min(a,b),min(c,d))
#define _max4(a,b,c,d) max(max(a,b),max(c,d))
#define _mem(ara, val) memset(ara,val,sizeof(ara))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define per(ii,aa,bb) for(ll (ii)=ll(aa)-1;(ii)>=(ll)(bb);--(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
#define count_one(a) __builtin_popcount(a)  
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)


//Debugging
#define D(x) cerr << #x << " = " << x << NL
#define DD(x,y) cerr << #x << " = " << x << "   " << #y << " = " << y << NL
#define DDD(x,y,z) cerr << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << NL

 
// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

int main(){
  _fastIO();
  ll a[3];
  ull cnt = 0;
  cin >> a[0] >> a[1] >> a[2];
  while(true){
  	sort(a, a+3);
  	if(a[0]%2!=0  || a[1]%2!=0 || a[2]%2!=0) {cout << cnt; exit(0);}
  	if(a[0] == a[1] && a[1] == a[2]) {cout << -1; exit(0);}
  	ll p = a[0]/2;
  	ll q = a[1]/2;
  	ll r = a[2]/2;
  	a[0] = r + q;
  	a[1] = p + r;
  	a[2] = q + p; 
  	cnt++;
  }
  _runtime();
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,w,n,x=0,y=0,vx=1,vy=0,num,cnt;
  cin >> h >> w >> n;
  int a,c[h][w];
  for(int i=0;i<n;i++){
    cin >> a;
    while(a!=0){
      a--;
      num = i+1;
      c[y][x]=i+1;
      x+=vx;
      y+=vy;
      if(x==w-1){
        if(vy==0){
          vx=0;
          vy=1;
        }else{
          vx=-1;
          vy=0;
        }
      }
      if(x==0){
        if(vy==0){
          vx=0;
          vy=1;
        }else{
          vx=1;
          vy=0;
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << c[i][j] <<" ";
    }
    cout << "\n";
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

struct bar {
	int h, p, q;
	bar(int th, int tp, int tq) {
		h = th;
		p = tp;
		q = tq;
	}
};
bool operator<(const bar& lhs, const bar& rhs) {
	return lhs.h < rhs.h;
}

int main() {
	int n, m, a;
	while(cin >> n >> m >> a, n||m||a) {
		vector<bar> bars;
		rep(i, m) {
			int h, p, q;
			cin >> h >> p >> q;
			bars.push_back(bar(h,p,q));
		}
		sort( bars.begin(), bars.end() );
		int pos[101];
		rep(i,101) pos[i] = i;
		rep(i, m) {
			swap( pos[bars[i].p], pos[bars[i].q] );
		}
		cout << pos[a] << endl;
	}
	return 0;
}

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

int     main() {
	string S;
	cin >>S;
	if ('A' != S.at(0)) {
		cout <<"WA" <<endl;
		return 0;
	}
	int C=0;
	for (int i=1; i<S.size(); i++) {
		if ('C'==S.at(i)) C++;
		else if ('a'>S.at(i)) {
			cout <<"WA" <<endl;
			return 0;
		} else if ('z'<S.at(i)) {
			cout <<"WA" <<endl;
			return 0;
		}
	}
	if ('C'==S.back()) {
		cout <<"WA" <<endl;
		return 0;
	}
	if ('C'==S.at(1)) {
		cout <<"WA" <<endl;
		return 0;
	}
	if (C != 1) {
		cout <<"WA" <<endl;
		return 0;
	}
	cout <<"AC" <<endl;
	return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,C;
vector<int> A,B;

ll dp[404][404];
ll sum[404][404];

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

int main(){
  cin>>N>>C;
  A.resize(N);
  B.resize(N);
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;++i) cin>>B[i];

  for(int i=0;i<N;i++){
    vector<ll> v;
    for(int j=A[i];j<=B[i];++j) v.push_back(1);
    for(int j=0;j<=C;j++){
      ll res=0;
      for(int k=0;k<v.size();k++){
        res=(res+v[k])%MOD;
        v[k]=(v[k]*(A[i]+k))%MOD;
      }
      sum[i][j]=res;
    }
  }

  dp[0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=C;j++){
      for(int k=0;j+k<=C;k++){
        ll tmp=dp[i][j]*sum[i][k]%MOD;
        add(dp[i+1][j+k],tmp);
      }
    }
  }

  cout<<dp[N][C]<<endl;

  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

ll a, b;

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

	cout << lcm(a,b) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        int AC=0,WA=0,TLE=0,RE=0;
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        for(int i=0 ; i<n ; i++){
            String x = scanner.nextLine();
            if(x.equals("AC")) AC++;
            else if(x.equals("WA")) WA++;
            else if(x.equals("TLE")) TLE++;
            else if(x.equals("RE")) RE++;
        }

        System.out.println("AC x " + AC);
        System.out.println("WA x " + WA);
        System.out.println("TLE x " + TLE);
        System.out.println("RE x " + RE);

    }

}


Measured memory_bytes: 60784
import numpy as np

"""
def divs(_n):
    n = _n
    r = int(np.sqrt(n))
    res = []
    
    for i in range(2, r+1, 1):
        buf = [0, 0]
        while n%i == 0:
            buf[0] = i
            buf[1] += 1
            n/=i
        if buf[0] != 0:
            res.append(buf)
    if len(res)==0:
        res.append([n, 1])
        
    return res


def has(lis, num, search_i):
    beki = -1
    index = -1
    for i in range(search_i, len(lis), 1):
        #print(type(i))
        if lis[i][0] == num:
            beki = lis[i][1]
            index = i
            break
    return (beki, index)


def common_divs(_a, _b):
    # len(a) <= len(b)
    if len(_a) > len(_b):
        a = _b
        b = _a
    else:
        a = _a
        b = _b

    common = []
    search_i = 0 # from this index, search e[0] in list b
    for e in a:
        beki, index = has(b, e[0], search_i)
        if beki > 0:
            common_e = [e[0], min(e[1], beki)]
            common.append(common_e)
            search_i = index + 1
    return common

def mult_all(c):
    res = 1
    for i in range(len(c)):
        res *= c[i][0]**c[i][1]
    return res


def main():
a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)
    divC = common_divs(divA, divB)
    
    #print ( divA, '\n', divB, '\n', divC, '\n')
    cnt = 1
    i = 0
    ans = mult_all(divC) 
    while(True):
        if cnt + divC[i][1] <= k:
            ans /= divC[i][0]**divC[i][1]
            cnt += divC[i][1]
        else:
            ans /= divC[i][0]**(k-cnt)
            break
        i += 1
        
    print(int(ans))

def main2():
    
main()    
"""

def divs(n):
    res = np.zeros(int(n/2))
    cnt = 0
    for i in range(n, 1, -1):
        if n%i == 0:
            res[cnt] = i
            cnt += 1
    return res[np.where(res>0)]


def main():
    a, b, k = map(int, input().split())
    divA = divs(a)
    divB = divs(b)

    cnt = 0
    ans = 1
    flag = False
    for i in range(len(divA)):
        if flag == True:
            break
        else:
            for j in range(len(divB)):
                if flag==False and divA[i]==divB[j]:
                    cnt += 1
                    if cnt == k:
                        ans = divA[i]
                        flag = True

    print(int(ans))
               
    
main()


Measured memory_bytes: 18132
<?php
$str = trim(fgets(STDIN));
$n = trim(fgets(STDIN));

for ($i = 0; $i < $n; $i++) {
  $line = explode(" ", trim(fgets(STDIN)));
  $order = $line[0];
  $a = $line[1];
  $len = $line[2] - $a + 1;

  if ($order == "print")
    echo substr($str, $a, $len) . "\n";
  elseif ($order == "reverse")
    $str = substr_replace(
      $str,
      strrev(substr($str, $a, $len)),
      $a,
      $len
    );
  else
    $str = substr_replace($str, $line[3], $a, $len);
}



Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int p,q,r;
    cin>>p>>q>>r;
    int ans = min(p+q,min(p+r,r+q));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[][] matrix_A = new int[n][m];
        int[] matrix_B = new int[m];
        int[] matrix_C = new int[n];
        for(int i = 0; i<n; i++){
            for(int j = 0;j<m;j++){
                int matrix_element = scan.nextInt();
                matrix_A[i][j] = matrix_element;
            }
        }
 
        for(int i=0;i<m;i++){
            int matrix_element2 = scan.nextInt();
            matrix_B[i] = matrix_element2;
        }
 
        for(int i = 0;i<n; i++){
            for(int j = 0; j<m; j++){
                matrix_C[i] += matrix_A[i][j] * matrix_B[j];
            }
        }
 
        for(int i = 0; i<matrix_C.length; i++){
            System.out.println(matrix_C[i]);
        }  
        scan.close();  
    }
}



Measured memory_bytes: 41036
while gets
  puts case $_.to_f.ceil
  when 0..48
    "light fly"
  when 49..51
    "fly"
  when 52..54
    "bantam"
  when 55..57
    "feather"
  when 58..60
    "light"
  when 61..64
    "light welter"
  when 65..69
    "welter"
  when 70..75
    "light middle"
  when 76..81
    "middle"
  when 82..91
    "light heavy"
  else
    "heavy"
  end
end

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

int main()
{
    int n, i, count=0;
    cin>>n;
    int arr[n], brr[n];

    for(i=0; i<n; i++)
    {
        cin>>arr[i];
        brr[i]=arr[i];
    }

    sort(brr, brr+n);

    for(i=0; i<n; i++)
    {
        if(arr[i] != brr[i])
            count++;
    }

    if(count == 0 || count == 2)
        cout<<"YES";
    else
        cout<<"NO";
}


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

int main()
{
  char s[1001], t[1001];
  scanf("%s", s);
  scanf("%s", t);
  
  int slen, tlen;
  slen = strlen(s);
  tlen = strlen(t);
  
  int matchCount, maxMatchCount = 0;
  int searchCount = slen - tlen + 1;
  for (int i = 0; i < searchCount; i++) {
    matchCount = 0;
    for (int j = 0; j < tlen; j++) {
      if (s[i + j] == t[j]) {
        matchCount++;
      }
    }
    
    if (matchCount > maxMatchCount) {
      maxMatchCount = matchCount;
    }
    
    if (maxMatchCount == tlen) {
      break;
    }
  }
  
  printf("%d\n", tlen - maxMatchCount);
  return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

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

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int n, a, b;
  while (scanf("%d%d%d", &n, &a, &b) == 3) {

    if ((b - a) % 2) {
      printf("Borys\n");
    } else {
      printf("Alice\n");
    }
  }

  return 0;
}


Measured memory_bytes: 256
x = int(input())

if x < 7 :
    print(1)
elif x < 12 :
    print(2)
elif x % 11 == 0 :
    print(x // 11 * 2)
elif x % 11 < 7 :
    print(x // 11 * 2 + 1)
else :
    print(x // 11 * 2 + 2) 

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll> > a(n);
  ll b;
  rep(i,n){
	cin >> b;
    a[i].first = b;
    a[i].second = i + 1;
  }

  sort(ALL(a));
  
  rep(i,n) cout << a[i].second <<' ';
    
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll r,g,b,n;
    cin>>r>>g>>b>>n;
    ll ans=0;
    for(ll i=0;i*r<=n;++i){
        for(ll j=0;j*g+i*r<=n;++j){
            if((n-j*g-i*r)%b==0)
                ans++;
        }
    }
    cout<<ans<<endl;
}


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

#define ll long long

int main()
{
    ll i, n, k, x, l, m, r, count;

    cin >> n >> k;

    ll a[n];
    for(i=0; i<n; i+=1)
        cin >> a[i];

    l=1;
    r=1000000000;

    while(l<r-1)
    {
        // cout << l << " " << r << endl;
        m=(l+r)/2;

        count=0;
        for(i=0; i<n; i+=1)
        {
            if(a[i]>m)
            {
                count+=a[i]/m;
                if(a[i]%m==0)
                    count-=1;
            }
        }
        if(count<=k)
            r=m;
        else
            l=m;
        // cout << count << " :: " << k << endl;
    }

    // cout << l << " " << r << endl;

    m=l;
    count=0;
    for(i=0; i<n; i+=1)
    {
        if(a[i]>m)
        {
            count+=a[i]/m;
            if(a[i]%m==0)
                count-=1;
        }
    }
    // cout << count << " :: " << k << endl;
    if(count>k)
        m+=1;

    cout << m << endl;
}

Measured memory_bytes: 5124
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	//auto N = RD!long;
	
	long[][] c;
	foreach (i; 0..3)
	{
		c ~= RDR.split.to!(long[]);
	}

	bool ans = false;
	long[3] xs, ys;
	foreach (x0; 0..101)
	{
		xs[0] = x0;
		ys[0] = c[0][0] - xs[0];
		foreach (x1; 0..101)
		{
			xs[1] = x1;
			ys[1] = c[1][0] - xs[0];
			foreach (x2; 0..101)
			{
				bool ng = false;
				xs[2] = x2;
				ys[2] = c[2][0] - xs[0];
				foreach (i; 0..3)
				{
					foreach (j; 1..3)
					{
						if (c[i][j] != xs[j] + ys[i])
						{
							ng = true;
						}
					}
				}
				ans |= !ng;
			}
		}
	}
	
	writeln(ans ? "Yes" : "No");
	stdout.flush();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    set<int> num;
    for (int i = 0; i < 4; i++) {
        int t;
        cin>>t;
        num.insert(t);
    }
    
    if(num.count(1)&&num.count(4)&&num.count(7)&&num.count(9))puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;

int main()
{
	int i, j,a ,b;
	scanf("%d%d", &a, &b);
	if (a == b) printf("Yes");
	else printf("No");
}

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

int n;
int fact[10];
int used[10] = {0};
int A[10];
vector<int> v;
vector<int> num = {1,2,3,4,5,6,7,8,9};

void permutation(int n,int i){
	int c = n,t = i;
	for(int j=0;j<n;j++){
		if(c>0){
			v.push_back(num[t/fact[c-1]]);
			num.erase(num.begin()+t/fact[c-1]);
			t -= (t/fact[c-1])*fact[c-1];
			c--;
		}else{
			v.push_back(num[0]);
		}
	}
	num.clear();
	for(int j=0;j<n;j++){
		if(j!=n-1) cout << v[j] << " ";
		else cout << v[j] << endl;
		used[j] = 0;
		num.push_back(j+1);
	}
	v.clear();
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> A[i];
	for(int i=0;i<=n;i++){
		if(i==0) fact[i] = 1;
		else fact[i] = fact[i-1]*i;
	}
	int ord = 0,now = n-1;
	for(int i=0;i<n;i++){
		ord += fact[now]*(A[i]-1);
		for(int j=i+1;j<n;j++){
			if(A[j]>A[i]) A[j]--;
		}
		now--;
	}
	if(ord-1>=0) permutation(n,ord-1);
	permutation(n,ord);
	if(ord+1<fact[n]) permutation(n,ord+1);
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define INF 0x3f3f3f
#define PB push_back
#define F first
#define S second
#define FOR(i,k) for(int i=0; i<k; i++)
#define RFOR(i,k) for(int i=k; i>=0; i--)
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#define DEBUGV(x) cout<<#x<<": "; for(auto &d:x) cout<<d<<" "; cout<<endl
#define DEBUGM(x) for(auto &p:x) cout<<p.F<<":"<<p.S<<" "; cout<<endl;
#define OUT(x) cout<<(x)<<endl

using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<char,int> MC;
typedef map<int,int> MI;
typedef map<string,int> MS;

template<typename T, typename U> void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if(x < y) x = y; }
VPII neighbors = {{0,1}, {1,0}, {0,-1}, {-1,0}};
PII operator+(PII &l, PII &r) { return {l.F+r.F, l.S+r.S}; }
bool IsValid(PII p, int Y, int X) { 
  return p.F >=0 && p.F < Y && p.S >=0 && p.S < X; }
bool IsPrime(int n) {
  if (n <= 1)  return false;
  if (n <= 3)  return true;
  if (n%2 == 0 || n%3 == 0) return false;
  for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
      return false;
  return true;
}

int main() {
  int n,m,x;
  VI a;
  cin>>n>>m>>x;
  FOR(i,m) {
    int ai;
    cin>>ai;
    a.PB(ai);
  }
  
  int j=0;
  while(a[j] < x)
    j++;
  int res = min(j, (int)a.size()-j);
  OUT(res);
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
a, b = 0, 0
for s in S:
    if s == "a":
        if a+b < A+B:
            a += 1
            print("Yes")
        else:
            print("No")
    elif s == "b":
        if a+b < A+B and b < B:
            b += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
    

Measured memory_bytes: 4016
#include <cstdio>

#define R register
#define maxn 100010
struct Edge
{
	Edge *next;
	int to;
} *last[maxn], e[maxn << 1], *ecnt = e;
inline void link(R int a, R int b)
{
	*++ecnt = (Edge) {last[a], b}; last[a] = ecnt;
	*++ecnt = (Edge) {last[b], a}; last[b] = ecnt;
}
int dfs(R int x, R int fa)
{
	R int ans = 0;
	for (R Edge *iter = last[x]; iter; iter = iter -> next)
		if (iter -> to != fa)
			ans ^= (dfs(iter -> to, x) + 1);
	return ans;
}
int main()
{
	R int n; scanf("%d", &n);
	for (R int i = 1; i < n; ++i)
	{
		R int a, b; scanf("%d%d", &a, &b); link(a, b);
	}
	puts(dfs(1, 0) ? "Alice" : "Bob");
}

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

using namespace std;
const int N = 100010;
const int MOD = 1e9+7;
int _w;

int n, cnt[26];
char s[N];

int main() {
	_w = scanf( "%d", &n );
	_w = scanf( "%s", s+1 );
	for( int i = 1; i <= n; ++i )
		++cnt[s[i] - 'a'];
	int ans = 1;
	for( int i = 0; i < 26; ++i )
		ans = int(1LL * ans * (cnt[i] + 1) % MOD);
	ans = (ans - 1 + MOD) % MOD;
	cout << ans << endl;
	return 0;
}


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

int main() {
    int K,N,sum=0;
    cin >> K >> N;
    int max;

    vector<int> A(N);
    vector<int> B(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N-1; i++)
    {
        B[i] = abs(A[i+1] - A[i]);
        //cout << B[i] << endl;
    }

    B[N-1] = K - A[N-1] + A[0];
    //cout << B[N-1] << endl;
    max = B[0];
    for (int i = 0; i < N ; i++)
    {
        if (max < B[i])
            max = B[i];
    }
    for (int i = 0; i < N; i++)
    {
        sum = sum + B[i];
    }
    //cout << sum << endl;
    sum = sum - max;

    cout << sum << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,s[1010];
int main(){
	scanf("%d",&n); n<<=1;
	for(int i=1;i<=n;++i) scanf("%d",s+i);
	sort(s+1,s+1+n);
	for(int i=1;i<=n;i+=2) *s+=min(s[i],s[i+1]);
	printf("%d\n",*s);
}

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

int main(void){

  long n;
  scanf("%ld", &n);
  long mod = pow(10,9)+7;
  long power = 1;
  for (long i = 1; i <= n; i++) {
    power *= i;
    power %= mod;
  }
  printf("%ld\n", power);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        string s;
        int t;
        vector<string> sv(n);
        map<string,vector<int> > sn;
        map<string,double> ans;//効率
        for(int i=0;i<n;i++){
            cin>>s;
            sv[i]=s;
            for(int j=0;j<9;j++){
                cin>>t;
                sn[s].push_back(t);
            }
            int by=sn[s][5]+sn[s][4];
            sn[s].push_back(by*sn[s][8]);
            
            sn[s][9]+=sn[s][1];//時間
            sn[s][9]+=sn[s][2];//時間
            sn[s][9]+=sn[s][3];//時間
            sn[s].push_back(sn[s][8]*sn[s][7]*sn[s][6]-sn[s][0]);//もうけ
            ans[s]=(double)sn[s][10]/sn[s][9];//効率
        }
        vector<pair<double,string> > v(n);
        for(auto it=ans.begin();it!=ans.end();it++){
            int i = distance(ans.begin(), it);
            v[i].first=ans[sv[i]];
            v[i].second=sv[i];
            v[i].first*=-1;
            // cout<<v[i].first<<" "<<v[i].second<<endl;
        }
        sort(v.begin(),v.end());
        for(int i=0;i<n;i++){
            cout<<v[i].second<<endl;
        }
        cout<<"#"<<endl;
    }
    

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



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

#define int long long

signed main(){
    int n, ticket, ans = 0, x, one;
    cin >> n >> ticket;
    
    priority_queue <int> pq;
    
    for(int i = 1; i <= n; i++){
        cin >> x;
        pq.push(x);
    }
    
    while(ticket){
        one = pq.top();
        pq.pop();
        one/=2;
        pq.push(one);
        ticket--;
    }
    
    while(!pq.empty()){
        ans+=(pq.top());
        pq.pop();
    }
    
    cout << ans << '\n';
    
}




Measured memory_bytes: 1400