akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	string s;
	cin >> s;
	string t = "zyxwvutsrqponmlkjihgfedcba";
	if (s == t) {
		cout << -1 << endl;
	}
	else if (s.size() == t.size()) {
		drep(i, s.size()) {
			if (s[i] > s[i - 1]) {
				rep(j, i - 1) {
					cout << s[j];
				}
				drep(j, s.size()) {
					if (s[i - 1] < s[j]) {
						cout << s[j] << endl;
						return 0;
					}
				}
				break;
			}
			
		}
	}
	else {
		vint a(26, 0);
		rep(i, s.size()) {
			a[s[i] - 'a']++;
		}
		rep(i, 26) {
			if (a[i] == 0) {
				s += (char)('a' + i);
				break;
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, M = getNM()
dist = [[] for i in range(N + 1)]
for i in range(M):
    a, b = getNM()
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)

cnt = 0

pos = deque([[1 << 0, 0]])

while len(pos) > 0:
    s, v = pos.popleft()
    if s == (1 << N) - 1:
        cnt += 1
    for u in dist[v]:
        if s & (1 << u):
            continue
        pos.append([s | (1 << u), u])
print(cnt)

Measured memory_bytes: 65900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	vector<int> P;
	int N;
	cin >> N;
	int ans = 0;

	for(int i=1; i<=N; i++) {
		if(i < 10) {
			ans++;
		} else if(i < 100) {

		} else if(i < 1000) {
			ans++;
		} else if(i < 10000) {

		} else if(i < 100000){
			ans++;
		}
	}
	cout << ans;

	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
def selection_sort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if int(c[j][-1]) < int(c[minj][-1]):
                minj = j
        temp = c[i]
        c[i] = c[minj]
        c[minj] = temp
    return c


def bubble_sort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if int(c[j][-1]) < int(c[j-1][-1]):
                temp = c[j]
                c[j] = c[j-1]
                c[j-1] = temp
    return c


def is_stable(a, b):
    for i in range(len(a)):
        if a[i] != b[i]:
            print('Not stable')
            return
    print('Stable')


def main():
    n = int(input())
    nums = input().split(' ')
    bubble_nums = [i for i in nums]
    select_nums = [i for i in nums]
    bubble_nums = bubble_sort(bubble_nums, n)
    select_nums = selection_sort(select_nums, n)

    print(' '.join(bubble_nums))
    print('Stable')
    print(' '.join(select_nums))
    is_stable(bubble_nums, select_nums)


if __name__ == "__main__":
    main()



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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n-1;i++) cin>>a[i];
    ll cnt[n+1];
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<n-1;i++){
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        cout<<cnt[i];
        if(i < n) cout<<" ";
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6744
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  char color;
  for(int i = 0; i < N ; i++){
    scanf("%c",&color);
    if(color == 'Y'){
      printf("Four\n");
      return 0;
    }
  }
  printf("Three\n");
}

Measured memory_bytes: 128
x,k,d = map(int,input().split())
if abs(x) > k*d:
  if x > 0:
    print(abs(x-k*d))
  else:
    print(abs(x+k*d))
else:
  if x > 0:
    a = x-(x//d)*d
    if (k-x//d)%2 == 0:
      print(abs(a))
    else:
      print(abs(a-d))
  else:
    a = x+(-x//d)*d
    if (k-(-x//d))%2 == 0:
      print(abs(a))
    else:
      print(abs(a+d))


Measured memory_bytes: 61700
#include<iostream>
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  int g=0;
  int s;
  for(int i=1;i<=n;i++){
    cin>>s;
    g+=s;
  }
  if(h<=g){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
// 2015/06/02 Tazoe

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

class Proc{
public:
	string nam;
	int tim;
	Proc(){  nam = "";  tim = 0;  }
};

Proc Q[100001];


class Queue{
private:
	int fp;			// 先頭ポインタ
	int rp;			// 末尾ポインタ
public:
	Queue()			{  fp = 0;  rp = 0;  }
	int next(int p) const	{  return (p+1)%100001;  }
	bool isFull() const	{  return (next(rp)==fp);  }
	bool isEmpty() const	{  return (rp==fp);  }
	void enqueue(Proc d);
	Proc front();
        void dequeue();
};

void Queue::enqueue(Proc d)
{
	if(isFull())
		return;		// 満杯

	Q[rp] = d;
	rp = next(rp);		// キューにデータを追加する
}

Proc Queue::front()
{
	if(isEmpty()){
		Proc er;
		er.tim = -1;
		return er;	// 異常終了（空）
	}

	return Q[fp];		// 先頭のデータ
}

void Queue::dequeue()
{
	if(isEmpty())
		return;		// 空

	fp = next(fp);		// キューからデータを取り出す
}


int main()
{
	Queue que;

	int n, q;
	cin >> n >> q;

	for(int i=0; i<n; i++){
		Proc p;
		cin >> p.nam >> p.tim;

		que.enqueue(p);
	}

	int total_tim = 0;

	while(!que.isEmpty()){
		Proc p = que.front();  que.dequeue();

		if(p.tim<=q){
			total_tim += p.tim;

			cout << p.nam << ' ' << total_tim << endl;
		}
		else{
			total_tim += q;
			p.tim -= q;

			que.enqueue(p);
		}
	}

	return 0;
}

Measured memory_bytes: 5112
n=int(input())
a=list(map(int,input().split()))

adict={}
for i in a:
  if i not in adict:
    adict[i]=1
  else:
    adict[i]+=1

m=0
for i in adict:
  m+=adict[i]*(adict[i]-1)//2

for i in a:
  print(m-adict[i]+1)

Measured memory_bytes: 25644
#include<stdio.h>
typedef struct{
  char str[15];
  int people;
  int money;
}P;

int main(){
  int i,j,a,b;
  P class[9];

  for(i=0;i<9;i++){
    scanf("%s %d %d",class[i].str,&a,&b);
    class[i].money=a*200+b*300;
    class[i].people=a+b;
  }

  for(i=0;i<9;i++)printf("%s %d %d\n",class[i].str,class[i].people,class[i].money);

  return 0;
}

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

int main(){
 //erさんの提出結果をうつしました
  cin.tie(0); //cin高速化
  ios::sync_with_stdio(false); //cin高速化
  
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }
    char str = s[s.size()-1];
    s.pop_back();
    s = str + s;
  }
  
  cout<<"No"<<endl;     
  
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0, lim##__LINE__ = n; i < lim##__LINE__; ++i)
using C = std::complex<double>;

C projection(C p, C p1, C p2) {
    return C(((p-p1) / (p2-p1)).real(), 0.0) * (p2-p1) + p1;
}

void solve_CGL_1_A() {
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    C p1(x1,y1), p2(x2,y2);
    int q;
    std::cin >> q;
    rep(i,q) {
        int x, y;
        std::cin >> x >> y;
        C p = C(x,y);
        C res = projection(p, p1, p2);
        printf("%.20lf %.20lf\n", res.real(), res.imag());
    }
}

int main() {
    solve_CGL_1_A();
}



Measured memory_bytes: 3232
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26220
k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(l[k-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
vector<ll> v[100005];
bool vi[100005];
void dfs(ll so)
{
	vi[so] = true;
	for(auto u: v[so])
	{
		if(!vi[u]) dfs(u);
	}
}
int main()
{
    fast;
 
    ll n,m,i,j,ans=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
    	ll x,y;
    	cin>>x>>y;
    	v[x].pb(y);
    	v[y].pb(x);
    }
    for(i=1;i<=n;i++)
    {
    	if(!vi[i]) dfs(i),ans++;
    }
    cout<<ans-1;

}

Measured memory_bytes: 10384
#include<stdio.h>

  int main(void){

    int x,y;
    int i;

    scanf("%d %d",&x,&y);
 
    

    if( 1 <= x && x <= 12 && y <= 12 && x <= y){
      
      if( x != 2 && x != 4 && x != 6 && x != 9 && x != 11 && y != 2         && y != 4 && y != 6 && y != 9 && y != 11 ){
        
        printf("Yes");
      }
      else if( x == 4 || x == 6 || x == 9 || x == 11 && y == 4 || y              == 6 || y == 9 || y == 11 ){
        printf("Yes");
      }
      else if( x == 2 && y == 2 ){
        printf("Yes");
      } 
      else{
        printf("No");
      }
     }else{
      printf("error");
     }
    
  }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    string s;
    int a,b,c,d;
    cin >> s;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    if (a + b + c + d == 7) {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }else if (a + b - c + d == 7) {
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }else if (a + b - c - d == 7) {
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    }else if (a + b + c - d == 7) {
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }else if (a - b + c + d == 7) {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }else if (a - b - c + d == 7) {
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    }else if (a - b + c - d == 7) {
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    }else if (a - b - c - d == 7) {
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <algorithm>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明


// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }


// ll my_gcd(ll a, ll b){
// 	return (b==0) ? a : my_gcd(b, a%b);
// }


//  ll my_lcm(ll a, ll b){
//  	return a*b / my_gcd(a,b);
//  }


// ll factorial(ll a){
// 	ll ans = 1;
// 	for(ll i=a; i>0; i--){
// 		ans *= i;
// 	}
// 	return ans;
// }

int main(int argc, char *argv[]){
    int a, b;
    cin >> a >> b;
    if(a*b%2 == 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

	return 0;
}


Measured memory_bytes: 768
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long H[] = new long[N];
        for(int i = 0; i < N; i++){
            H[i] = sc.nextLong();
        }
        Arrays.sort(H);
        long ans = 0;
        if(N > K){
            for(int i = 0; i < (N-K); i++){
                ans += H[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62304
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int n; cin >> n;
    map<string, int> m;
    set<string> set_str;
    string s;
    int max_num = 1;
    for(int i=0; i<n; i++){
        cin >> s;
        m[s]++;
        if(m[s] == max_num){
            set_str.insert(s);
        }
        else if(m[s] > max_num){
            set_str.clear();
            set_str.insert(s);
        }
        max_num = max(max_num,m[s]);
    }

    set<string>::iterator itr = set_str.begin();
    while(itr != set_str.end()){
        cout << *itr << endl;
        itr++;
    }

    return 0;
        
}

Measured memory_bytes: 34776
#include<stdio.h>
#include<string.h>
int main()
{	
	int a,b,c,i,k,p,q;
	scanf("%d%d",&a,&b);
	char z[a][b];
	getchar();
	for(i=0;i<a;i++){
	for(p=0;p<b;p++)scanf("%c",&z[i][p]);
	getchar();}
	for(i=0;i<a-1;i++)
	for(p=0;p<a-1;p++)
	{
		if(strcmp(z[p],z[p+1])>0)
		for(q=0;q<b;q++)
		{
			c=z[p][q];
			z[p][q]=z[p+1][q];
			z[p+1][q]=c;
		}	
	}
	for(i=0;i<a;i++)
	for(p=0;p<b;p++)printf("%c",z[i][p]);
	printf("\n");
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

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

    ll ans = b+c;
    if(a+b < c) {
        ans -= c-(a+b)-1;
    }

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


Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(1, n - 1):
    sf = set(s[:i])
    sb = set(s[i:])
    cnt = 0
    for j in sf:
        if j in sb:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long

int main() {
	LL llMax = 1000000000000001, llN;
	scanf("%lld", &llN);
	//a = 97
	int iChar[20], iCnt = 0;
	llN--;
	while (iCnt < 20) {
		iChar[iCnt++] = llN % 26;
		if (llN < 26)
			break;
		llN -= (iChar[iCnt - 1] + 1);
		llN /= 26;
		//printf("%lld\n", llN);
	}
	while (iCnt-- > 0) {
		printf("%c", (char)(iChar[iCnt] + 97));
	}

	return 0;
}


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

vector<pair<int,int>> v[100005];
int ar[100005];

void DFS(int i){
	for(auto a:v[i])
		if(!ar[a.first])
			if(a.second&1) ar[a.first]=(ar[i]&1)+1,DFS(a.first);
			else ar[a.first]=ar[i],DFS(a.first);
}

int main(){
	int n;
	cin>>n;
	for(int i=0,l,r,w;i<n-1;i++)
		cin>>l>>r>>w,v[l].push_back({r,w}),v[r].push_back({l,w});
	ar[1]=1;
	DFS(1);
	for(int i=1;i<=n;i++)
		cout<<ar[i]-1<<'\n';
}

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

int change(char c);
int main(void){
  char roma[100];
  int suji[100];
  int answer,len;
  int i;
  while((scanf("%s",&*roma))!=EOF){
    answer=0;
    len=strlen(roma);
    for(i=0;i<len;i++){
      suji[i]=change(roma[i]);
    }
    if(len==1){
      answer=suji[0];
    }else{
      for(i=0;i<len-1;i++){
	if(suji[i]>=suji[i+1]){
	  answer+=suji[i];
	  //printf("%d\n",answer);
	}else{
	  answer-=suji[i];
	  //rintf("%d\n",answer);
	}
      }
      answer+=suji[len-1];
    }
    printf("%d\n",answer);
  }
  return 0;
}

int  change(char c){
  int a;
  if(c=='I'){
    a=1;
  }else if(c=='V'){
    a=5;
  }else if(c=='X'){
    a=10;
  }else if(c=='L'){
    a=50;
  }else if(c=='C'){
    a=100;
  }else if(c=='D'){
    a=500;
  }else if(c=='M'){
    a=1000;
  }
  return a;
}

Measured memory_bytes: 540
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll N;
    ll sum = 0;
    cin >> N;
    rep(i, 0, N) {
        ll a;
        cin >> a;
        sum += a;
    }
    cout << sum - N << endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


int main(void) {
	int64 N;
	cin >> N;
	double res = 0;
	REP(i, N) {
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY") res += x;
		else res += x*380000;
	}
	cout << fixed << setprecision(10) << res << endl;
}


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

#define N 200000

int n;
int a[N]; 
queue<int> btwPerson;

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

    sort(a, a+n, greater<int>());

    long kokochiyosa = 0;
    btwPerson.push(a[0]);
    for (int i = 1; i < n; i++){
        kokochiyosa += btwPerson.front();
        btwPerson.pop();
        btwPerson.push(a[i]);
        btwPerson.push(a[i]);
    }    

    cout << kokochiyosa << endl; 
    
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin>>h.at(i);
    for(int i=n-2;i>=0;i--){
        if(h.at(i+1)<h.at(i)){
            h.at(i)--;
            if(h.at(i+1)<h.at(i)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int N,a;
	scanf("%d",&N);
	a=N%10;
	if(a==2||a==4||a==5||a==7||a==9){
		printf("hon\n");
	}
	if(a==0||a==1||a==6||a==8){
		printf("pon\n");
	}
	if(a==3){
		printf("bon\n");
	}
	return 0;
}


Measured memory_bytes: 1580
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

Int func(Int a, Int b, Int c) {
  return (a - a / 2 * 2) * b * c;
}

int main() {
  Int A = lin();
  Int B = lin();
  Int C = lin();
  printf("%lld\n", min(func(A, B, C), min(func(B, A, C), func(C, A, B))));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;


void TorT()
{
  int n, a, b;
  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}


void cross9_9()
{
  int a, b;

  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


void calculate_circle()
{
  int r;

  cin >> r;
  cout << r * r << endl;
}


void SvsM()
{
  int hp, a;
  int atk_cnt, rest;

  cin >> hp >> a;
  atk_cnt = hp / a;
  if (hp % a) atk_cnt++;
  cout << atk_cnt << endl;
}
int main()
{
  //TorT();
  //cross9_9();
  //calculate_circle();
  SvsM();

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 205;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
ll a[MAXN], b[MAXN], bit[MAXN];
char s[MAXN];
void ins(ll x) {
	for (int i = 60; i >= 0; i--)
		if (x & bit[i]) {
			if (b[i] == 0) {
				b[i] = x;
				break;
			}
			x ^= b[i];
		}
}
bool query(ll x) {
	for (int i = 60; i >= 0; i--)
		if (x & bit[i]) x ^= b[i];
	return x == 0;
}
int main() {
	int T; read(T);
	while (T--) {
		int n; read(n);
		for (int i = 1; i <= n; i++)
			read(a[i]);
		scanf("\n%s", s + 1);
		for (int i = 0; i <= 60; i++)
			b[i] = 0, bit[i] = 1ll << i;
		bool win = false;
		for (int i = n; i >= 1; i--) {
			if (s[i] == '0') ins(a[i]);
			else win |= !query(a[i]);
		}
		if (win) puts("1");
		else puts("0");
	}
	return 0;
}


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

int solveProb(vector<int> &num_prob, vector<bool> &not_bonus, ll rest, int n){
  int num_prob_tmp;
  if(rest <= 0) return 0;
  if(not_bonus.at(n-1)) num_prob_tmp = num_prob.at(n-1);
  else num_prob_tmp = 0;
  ll tmp = rest - 100*n*num_prob_tmp;
  if(tmp > 0 && n > 1) return num_prob_tmp + solveProb(num_prob, not_bonus, tmp, n-1);
  return (rest+100*n-1)/(100*n);
}

int main(){
  int D;
  ll G;
  cin >> D >> G;
  vector<int> num_prob(D);
  vector<ll> point(D);
  rep(i, D){
    cin >> num_prob.at(i);
    cin >> point.at(i);
  }
  int ans = 1001;
  vector<bool> not_bonus(D);
  rep(i, pow(2, D)){
    ll rest = G;
    int num = 0;
    rep(j, D){
      int p = pow(2,j);
      if(i%p==0){
        not_bonus.at(j) = !not_bonus.at(j);
      }
      if(!not_bonus.at(j)){
        rest -= 100*(j+1)*num_prob.at(j) + point.at(j);
        num += num_prob.at(j);
      }
    }
    ans = min(ans,num+solveProb(num_prob, not_bonus, rest, D));
  }
  cout << ans << endl;
}


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

using namespace std;

#define out(v) cout<<v<<"\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);++i)
const int INF = 1e9+7;

using pii = pair<int, int>;

int N;
vector<int> d;
vector<vector<pii>> edge;

void get_distance(int s) {
  d.erase(all(d));
  d.resize(N, INF);
  d[s] = 0;
  queue<int> q; q.push(s);

  while (!q.empty()) {
    int from = q.front(); q.pop();
    for (const auto& e : edge[from]) {
      int to = e.first;
      if (d[to] == INF) {
        d[to] = d[from] + e.second;
        q.push(to);
      }
    }
  }
}
int get_farthest(int s) {
  get_distance(s);
  int max_i = s;
  rep(i, N) {
    if (d[i] == INF) continue;
    if (d[i] > d[max_i])
      max_i = i;
  }
  return max_i;
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> N;

  edge.resize(N, vector<pii>());
  rep(i, N-1) {
    int s, t, w;
    cin >> s >> t >> w;
    edge[s].emplace_back(t, w);
    edge[t].emplace_back(s, w);
  }
  int x = get_farthest(0);
  int y = get_farthest(x);
  out(d[y]);

  return 0;
}



Measured memory_bytes: 9720
n,k=map(int,input().split())

dot=[]
xxx=[]
yyy=[]

ans=float('inf')

for i in range(n):
  x,y=map(int,input().split())
  dot.append([x,y])
  xxx.append(x)
  yyy.append(y)

xxx.sort()
yyy.sort()

for sx in range(n):
  for sy in range(n):
    for gx in range(sx+1,n):
      for gy in range(sy+1,n):
        cnt=0
        for lst in dot:
          if xxx[sx]<=lst[0]<=xxx[gx]:
            if yyy[sy]<=lst[1]<=yyy[gy]:
              cnt+=1
      
        if cnt>=k:
          if xxx[sx]==xxx[gx] or yyy[sy]==yyy[gy]:
            continue
          ans=min(ans,(xxx[gx]-xxx[sx])*(yyy[gy]-yyy[sy]))


print(ans)

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

int main(){
  int N;
  string s[100];
  bool Four = false;
  
  cin >> N;
  rep(i, N){
    cin >> s[i];
    if(s[i] == "Y") Four = true;
  }

  if(Four){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>

#define LOP(N) for(int i=0; i<N; i++)
#define LOOP(i, N) for(int i=0; i<N; i++)
#define LOOP_s(i, start, end) for(int i=start; i<end; i++)

typedef long long ll;

using namespace std;


int main() {
    int N; cin >> N;
    vector<int> a1(N), a2(N);
    LOOP(i, N) cin >> a1[i];
    LOOP(i, N) cin >> a2[i];
    
    int c1=0, c2=0;
    LOOP(i, N) c2 += a2[i];
    
    int max = 0, count;
    LOOP(i, N) {
        c1 += a1[i];

        count = c1 + c2;
        if (max < count) max = count;
        // cout << c1 << " " << c2 << endl;
        
        c2 -= a2[i];
    }
    cout << max;
}


Measured memory_bytes: 256
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int c0 = 0;
    int c1 = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (stoi(s.substr(i, 1)) == 1) {
            c1++;
        } else {
            c0++;
        }
    }   
    if (c1 > c0) {
        cout << 2 * c0; 
    } else {
        cout << 2 * c1; 
    }   
}


Measured memory_bytes: 512
n = int(input())
t = [0]
x = [0]
y = [0]
result = "Yes"
for i in range(1,n+1):
    T,X,Y = map(int, input().split())
    t.append(T)
    x.append(X)
    y.append(Y)
for j in range(1,n+1):
    r = abs(x[j]-x[j-1]) + abs(y[j]-y[j-1])
    if r > abs(t[j]-t[j-1]) :
        result = "No"
    if (abs(t[j]-t[j-1]) - r)%2 != 0:
        result = "No"
print(result)


Measured memory_bytes: 11728
#include <stdio.h>
#define N_MAX 110

int main(){
    
    int N, A[N_MAX];
    
    //標準入力から読み込み
         scanf("%d", &N);
         for ( int i=0; i<N; i++ ){
             scanf("%d",&A[i]);
         }
    
         for ( int i=0; i<N; i++ ){
             if ( A[i] % 2 == 0 ){
                 if ( A[i] % 3 != 0 && A[i] % 5 != 0 ){
                     printf("DENIED\n");
                     return 0;
                 }
             }
         }
         
         printf("APPROVED\n");
         return 0;
}

Measured memory_bytes: 128
conds = (
    [lambda x: x <= 399, False],
    [lambda x: x <= 799, False],
    [lambda x: x <= 1199, False],
    [lambda x: x <= 1599, False],
    [lambda x: x <= 1999, False],
    [lambda x: x <= 2399, False],
    [lambda x: x <= 2799, False],
    [lambda x: x <= 3199, False],
)


def main():
    n = int(raw_input())
    xs = [int(x) for x in raw_input().split()]

    others = 0
    for x in xs:
        for cond in conds:
            if cond[0](x):
                cond[1] = True
                break
        else:
            others += 1

    s = sum(1 for c, t in conds if t)

    print s if s else 1,
    print s + others


main()

Measured memory_bytes: 28524
import math
from functools import reduce
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！


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

# print(gcd(100,20,10))

k = int(input().replace("\n",""))
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

print(ans)

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

int main() {
    string s;
    cin >> s;
    int roop = s.size() / 2;
    int ans = 0;
    for(int i = 0; i < roop; i++) {
        if(s[i] != s[s.size() - 1 - i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1e5+7;
typedef long long ll;
ll a[N],b[N],c[N],f[N][3];
int main()
{
    int n;scanf("%d",&n);
    for(int i = 1;i <= n;++i)
        scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
    memset(f,-0x3f,sizeof f);
    f[0][0] = 0,f[0][1] = 0,f[0][2] = 0;
    for(int i = 1;i <= n;++i)
    {
        f[i][0] = max(f[i - 1][1],f[i - 1][2]) + a[i];
        f[i][1] = max(f[i - 1][0],f[i - 1][2]) + b[i];
        f[i][2] = max(f[i - 1][0],f[i - 1][1]) + c[i];
    }
    cout << max(max(f[n][0],f[n][1]),f[n][2]);
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <queue>
#include <algorithm>
#define ll long long

using namespace std;

ll lunlun(ll n) {
	queue<ll> ll_queue;
	//initialise
	for (int i = 1; i <= 9; i++) {
		ll_queue.push(i);
	}
	while (n > 1) {
		ll curr = ll_queue.front();
		ll_queue.pop();
		if (curr % 10LL > 0) {
			ll_queue.push(10LL * curr + (curr % 10LL) - 1);
		}
		ll_queue.push(10LL * curr + (curr % 10LL));
		if (curr % 10LL < 9) {
			ll_queue.push(10LL * curr + (curr % 10LL) + 1);
		}
		n--;
	}
	return ll_queue.front();
}

int main() {
	int n;
	cin >> n;
	cout << lunlun(n);
}

Measured memory_bytes: 4828
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports, dead_code)]

use std::collections::{HashMap, BinaryHeap, BTreeMap};

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// 可愛い可愛い、お手製のライブラリ達
macro_rules! p {
    ($t:expr) => {
        println!("{}", $t);
    };
}
macro_rules! debug {
    ($t:expr) => {
        println!("{:?}", $t);
    };
}
fn gcd(a:usize, b:usize) -> usize {
    if b == 0 {return a};
    gcd(b, a % b)
}
fn lcm(a:usize, b:usize) -> usize {
    a / gcd(a, b) * b
}

use std::cmp::max;

// エントリーポイント
fn main() {
    input! {
        N:usize,
        A:[usize; N],
    }
    let mut numbers = vec![0; N + 1];
    for n in (1..N + 1).rev() {
        let mut xor = 0;
        let mut i = n + n;
        while i <= N {
            xor ^= numbers[i];
            i += n;
        }
        numbers[n] = A[n - 1] ^ xor;
    }
    let mut result = Vec::new();
    for (i, n) in numbers.iter().skip(1).enumerate() {
        if *n == 1usize {result.push(i + 1);}
    }
    p!(result.len());
    for r in result {
        p!(r);
    }
}


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




int main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<int> primes(1e6+5,1);   
    for(int i=2; i<1e6+5; ++i){
        for(int j=2; j*j<=i; ++j){
            if(i%j==0){
                primes[i]=j;
                break;
            }
        }
    }
    map<int,int> che;
    set<int> st;
    rep(i,n){
        int kari=a[i];
        st.clear();
        while(primes[kari]!=1){
            if(st.find(primes[kari])==st.end()){
                che[primes[kari]]++;
                st.insert(primes[kari]);
            }
            kari/=primes[kari];
        }
        if(kari!=1 && st.find(kari)==st.end()){
            che[kari]++;
        }
    }
    bool ok=true;
    for(auto &v: che){
        if(v.second>1){
            ok=false;
        }
    }
    if(ok){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    int kari=a[0];
    rep(i,n-1){
        kari=gcd(kari,a[i+1]);
    }
    if(kari==1){
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 14780
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>n>>m;
    while(n>0){
        n=n/m;
        x++;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include <complex>
#include <utility>
#include <vector>

using cmplx = std::complex<double>;
void fft(int N, std::vector<cmplx> &a, double dir)
{
    int i = 0;
    for (int j = 1; j < N - 1; j++) {
        for (int k = N >> 1; k > (i ^= k); k >>= 1);
        if (j < i) std::swap(a[i], a[j]);
    }

    std::vector<cmplx> zeta_pow(N);
    for (int i = 0; i < N; i++) {
        double theta = M_PI / N * i * dir;
        zeta_pow[i] = {cos(theta), sin(theta)};
    }

    for (int m = 1; m < N; m *= 2) {
        for (int y = 0; y < m; y++) {
            cmplx fac = zeta_pow[N / m * y];
            for (int x = 0; x < N; x += 2 * m) {
                int u = x + y;
                int v = x + y + m;
                cmplx s = a[u] + fac * a[v];
                cmplx t = a[u] - fac * a[v];
                a[u] = s;
                a[v] = t;
            }
        }
    }
}
template<typename T>
std::vector<cmplx> conv_cmplx(const std::vector<T> &a, const std::vector<T> &b)
{
    int N = 1;
    while (N < (int)a.size() + (int)b.size()) N *= 2;
    std::vector<cmplx> a_(N), b_(N);
    for (int i = 0; i < (int)a.size(); i++) a_[i] = a[i];
    for (int i = 0; i < (int)b.size(); i++) b_[i] = b[i];
    fft(N, a_, 1);
    fft(N, b_, 1);
    for (int i = 0; i < N; i++) a_[i] *= b_[i];
    fft(N, a_, -1);
    for (int i = 0; i < N; i++) a_[i] /= N;
    return a_;
}
template<typename T>
std::vector<long long int> fftconv(const std::vector<T> &a, const std::vector<T> &b)
{
    std::vector<cmplx> ans = conv_cmplx(a, b);
    std::vector<long long int> ret(ans.size());
    for (int i = 0; i < (int)ans.size(); i++) ret[i] = floor(ans[i].real() + 0.5);
    return ret;
}


#include <iostream>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed; }; } fast_ios_;


int main()
{
    int N;
    cin >> N;
    long long int M;
    cin >> M;
    vector<int> v(100001);
    while (N--) {
        int a;
        cin >> a;
        v[a]++;
    }
    vector<long long int> c = fftconv(v, v);
    long long int ret = 0;
    for (int i = (int)c.size() - 1; i >= 0; i--) {
        long long int d = min(M, c[i]);
        M -= d;
        ret += d * i;
    }
    cout << ret << endl;
}

Measured memory_bytes: 13056
import java.util.*;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        
        N = N % 500;
        
        if(A < N)
            System.out.println("No");
        else
            System.out.println("Yes");

    }
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    if(abs(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)

	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
N = int(input())
H = list(map(int, input().split()))
val = 0
ansList = []

for i in range(len(H) - 1) :
  if H[i] >= H[i + 1] :
    val += 1
    next
  else :
    ansList.append(val)
    val = 0
    next
    
ansList.append(val)

ans = max(ansList)
print(ans)

Measured memory_bytes: 14252
import sys

def main():
    N = int(input())
    t = []
    x = []
    y = []
    for i in range(N):
        ti, xi, yi = map(lambda i: int(i), input().split(' '))
        t.append(ti)
        x.append(xi)
        y.append(yi)
    current_t = 0
    current_point = [0, 0]
    for i in range(N):
        next_t = t[i]
        next_point = [x[i], y[i]]
        distance = abs(next_point[0] - current_point[0]) + abs(next_point[1] - current_point[1])
        time_diff = next_t - current_t
        if distance > time_diff:
            print('No')
            sys.exit()
        elif distance < time_diff:
            diff = time_diff - distance
            if diff % 2 == 1:
                print('No')
                sys.exit()
        current_t = t[i]
        current_point = [x[i], y[i]]
    print('Yes')

main()


Measured memory_bytes: 11840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int num = 1;
        for (int i = 0; i < n; i++) {
            if (num < k) {
                num += num;
            } else {
                num += k;
            }
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 24020
N,M,Q=gets.split(/ /).map(&:to_i)
a = []
b = []
c = []
d = []
1.upto(Q) {|i|
  a[i],b[i],c[i],d[i] = gets.split(/ /).map(&:to_i)
}

max = 0
1.upto(M).to_a.repeated_combination(N).each do |aseq|
  aseq.unshift(nil)
  score = 0
  1.upto(Q) {|i|
    score += d[i] if aseq[b[i]] - aseq[a[i]] == c[i]
  }
  max = score > max ? score : max
end
puts max


Measured memory_bytes: 15964
#include<iostream>
#include<string>
using namespace std;
int ans;
int w,h;
string map[40];
int vec[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
void move(int x,int y){
	ans++;
	map[x][y]='#';
	for(int i=0;i<4;i++){
		if((x+vec[i][0]>=0)&&(y+vec[i][1]>=0)&&(x+vec[i][0]<h)&&(y+vec[i][1]<w)){
			if(map[x+vec[i][0]][y+vec[i][1]]=='.'){
				move(x+vec[i][0],y+vec[i][1]);
			}
		}
	}
	return;
}

int main(){
	while(cin>>w>>h,w){
		ans=0;
		int fx,fy;
		for(int i=0;i<h;i++){
			cin>>map[i];
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]=='@'){
					fx=i;
					fy=j;
					break;
				}
			}
		}
		move(fx,fy);
		cout<<ans<<endl;
		
	}
}

Measured memory_bytes: 1212
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

void warshall_floyd(int V, vector< vector<long long> > &d) {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {

    int N;
    cin >> N;
    int A[N][N];

    rep(i,N) rep(j,N) cin >> A[i][j];

    vector< vector<long long> > g;
    rep(i,N) rep(j,N) {
        if (i == j) continue;
        vector<long long> e(3);
        e[0] = i; e[1] = j; e[2] = A[i][j];
        g.push_back(e);
    }

    vector< vector<long long> > d;
    rep(i,N) {
        vector<long long> e(N, INF);
        d.push_back(e);
    }
    rep(i,N) rep(j,N) d[i][j] = A[i][j];

    warshall_floyd(N, d);


    rep(i,N) rep(j,N) {
        if (A[i][j] != d[i][j]) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector< pair<int, P> > list;
    for(int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            list.push_back(make_pair(A[i][j], make_pair(i, j)));
        }
    }
    sort(list.begin(), list.end());
    
    long long ans = 0;

    rep(k,list.size()) {
        int i = list[k].second.first;
        int j = list[k].second.second;
        bool issame = false;
        rep(w,N) {
            if (w != i && w != j && d[i][j] == d[i][w] + d[w][j]) issame = true;
        }
        if (!issame) ans += list[k].first;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8112
# coding: utf-8
X,Y,A,B,C=map(int,input().split())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

EP=P[0:X]
EQ=Q[0:Y]

    # for i in range(X):
    #     EP.append(P[i])
        
    # for i in range(Y):
    #     EQ.append(Q[i])

EP.reverse()
EQ.reverse()

ans=sum(EP)+sum(EQ)

p=0
q=0

INF=10**12

EP.append(INF)
EQ.append(INF)

for i in range(C):
    if R[i]>EP[p] or R[i]>EQ[q]:
        if EP[p]<EQ[q]:
            ans+=R[i]
            ans-=EP[p]
            p+=1
        else:
            ans+=R[i]
            ans-=EQ[q]
            q+=1
    else:
        break

print(ans)




Measured memory_bytes: 22720
import std;

void main() {
    int n; scan(n);
    int m = n % 10;
    if (m == 3) writeln("bon");
    else if ([0, 1, 6, 8].canFind(m)) writeln("pon");
    else writeln("hon");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;


Measured memory_bytes: 3580