akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int mo=1000000007;
const int N=5005;
int n,m,P[N],IP[N];
int f[N][N],g[N][N];
int main(){
	P[0]=IP[0]=1;
	For(i,1,N-1) P[i]=2ll*P[i-1]%mo;
	For(i,1,N-1) IP[i]=1ll*IP[i-1]*(mo+1)/2%mo;
	scanf("%d%d",&n,&m);
	For(i,1,m) f[0][i]=1;
	For(i,1,n){
		For(j,1,m) g[i-1][j]=(g[i-1][j-1]+1ll*f[i-1][j]*j%mo*IP[j])%mo;
		For(j,1,m) f[i][j]=(1ll*f[i-1][j]*(j+1)%mo+1ll*g[i-1][j-1]*P[j-1])%mo; 
	}
	//cout<<f[1][2]<<' '<<f[2][2]<<' '<<f[3][2]<<endl;
	printf("%d\n",f[n][m]);
}
/*
21? 12
2?1
?21

*/

Measured memory_bytes: 199296
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;

int dp[2][3000];

struct P{
	P():x(-1), y(-1){}
	P(int x, int y):x(x), y(y){}
	int x, y;
};

int main(){
	int n, m;
	while(cin >> n >> m && n|m){
		for(int i = 0; i < 2; i++){
			fill(dp[i], dp[i]+3000, 1<<29);
		}
		vector<vector<P> > num(3000, vector<P>(0, P()));
		P s, g;
		int maxc = 0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				string tmp;
				cin >> tmp;
				if(tmp == "S"){
					s.x = j; s.y = i;
				}else if(tmp == "G"){
					g.x = j; g.y = i;
				}else if(tmp != "."){
					num[atoi(tmp.c_str())].push_back(P(j, i));
					maxc = max(maxc, atoi(tmp.c_str()));
				}
			}
		}
		num[0].push_back(s);
		num[maxc+1].push_back(g);
		bool f = false;
		fill(dp[f&1], dp[f&1]+3000, 0);
		for(int i = 0; i < maxc+1; i++){
			fill(dp[(f+1)&1], dp[(f+1)&1]+3000, 1<<29);
			for(int j = 0; j < num[i].size(); j++){
				for(int k = 0; k < num[i+1].size(); k++){
					dp[(f+1)&1][k] = min(dp[(f+1)&1][k], dp[f&1][j] + abs(num[i][j].x-num[i+1][k].x) + abs(num[i][j].y-num[i+1][k].y));
				}
			}
			f = (f+1)&1;
		}
		cout << dp[f&1][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1376
#include <iostream>

int main()
{
  int a,b,c;
  std::cin >> a >> b >> c;
  if (a==b && a != c)
    std::cout << "Yes" << std::endl;
  else if (a == c && a != b)
    std::cout << "Yes" << std::endl;
  else if (b == c && b != a)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}


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

cnt_list = [0 for _ in range(N)]

for i in range(1, N):
    if Hs[i-1] >= Hs[i]:
        cnt_list[i] = cnt_list[i-1] + 1
    else:
        cnt_list[i] = 0

print(max(cnt_list))

Measured memory_bytes: 14224
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;

const double EPS = 1e-6;

struct Building{
	int x, y;
	Building(){
		x = -1; y = -1;
	}
};

struct Edge{
	int to;
	double cost;
	Edge(){}
	Edge(const int &_to, const double &_cost){
		to = _to; cost = _cost;
	}
};

struct Data{
	int n;
	double cost;
	Data(){}
	Data(const int &_n, const double &_cost){
		n = _n; cost = _cost;
	}
	bool operator < (const Data &a) const{
		return cost > a.cost;
	}
};

double GetDistance(const Building &b1, const Building &b2){
	double dx = b1.x - b2.x, dy = b1.y - b2.y;
	return sqrt(dx*dx + dy*dy);
}

vector<Edge> e[1000];
Building v[1000];
priority_queue<Data> pq;

int main(){
	int N, M, B, S, G;

	while(cin >> N, N){
		for(int i = 0; i < 1000; i++) e[i].clear();

		for(int i = 0; i < N; i++){
			cin >> B; B--;
			cin >> v[B].x >> v[B].y;
		}

		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				if(v[i].x == -1 || v[j].x == -1 || i == j) continue;
				double dist = GetDistance(v[i], v[j]);
				if(dist <= 50){
					e[i].push_back( Edge(j, dist) );
					e[j].push_back( Edge(i, dist) );
				}
			}
		}

		cin >> M;
		for(int j = 0; j < M; j++){
			cin >> S >> G; S--; G--;

			Data pq_top;
			pq.push( Data(S, 0) );
			double memo[1000];
			fill_n(memo, 1000, -1);
			bool na = true;

			while( !pq.empty() ){
				pq_top = pq.top(); pq.pop();
			
				if(memo[pq_top.n] > -0.5) continue;
				memo[pq_top.n] = pq_top.cost;
				if(pq_top.n == G){
					na = false; break;
				}

				for(int i = 0; i < e[pq_top.n].size(); i++){
					pq.push( Data( e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost ) );
				}
			}
			while( !pq.empty() ) pq.pop();

			if(na){
				puts("NA"); continue;
			}

			stack<int> ans;
			while(true){
				ans.push(G);
				if(G == S) break;
				for(int i = 0; i < e[G].size(); i++){
					if( abs(memo[G] - memo[ e[G][i].to ] - e[G][i].cost) < EPS){
						G = e[G][i].to; break;
					}
				}
			}
		
			printf("%d", ans.top()+1 ); ans.pop();
			while( !ans.empty() ){
				printf(" %d", ans.top()+1 ); ans.pop();
			}puts("");
		}
	}
	return 0;
}

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

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	for(int i=0;i<n;i++) cin >> a[i];
  
  	vector<int> rev(n);
  	for(int i=0;i<n;i++) rev[a[i]-1] = i+1;
  	for(int i=0;i<n;i++) cout << rev[i]<<endl;
  return 0;
}

Measured memory_bytes: 1664
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = M;
    for(int aa = 1; aa < n; aa++){
        int a = aa, b = n - a;
        int cand = 0;
        while(a){ cand += a % 10; a /= 10; }
        while(b){ cand += b % 10; b /= 10; }
        // printd(a, b, cand);
        ans = min(ans, cand);
    }
    cout << ans << '\n';
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var a = ReadLine();

            if('A' <= a[0] && a[0] <= 'Z')
            {
                WriteLine("A");
            }
            else
            {
                WriteLine("a");
            }
        }
    }
}


Measured memory_bytes: 17340
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;
  vector<int> V(N);for(int i=0;i<N;i++)cin>>V[i];
  
  
  //左からa個, 右からb個とり. 負になるものをできる限り捨てる a+b<N
  int max=0;
  for(int l=0;l<=min(N,K);l++){
    for(int r=0;r<=min(N,K)-l;r++){
      vector<int> tmp;
      for(int i=0;i<l;i++)tmp.push_back(V[i]);
      for(int i=0;i<r;i++)tmp.push_back(V[N-1-i]);
      sort(tmp.begin(),tmp.end());
      int sum=0;
      for(int i=0;i<tmp.size();i++){
        if(tmp[i]>0 || i>=(K-l-r)){
          //小さい順に見て, K回を超えたものは捨てられない 少しでも価値があればとっておきたい
          sum+=tmp[i];
        }
      }
      if(max<sum)max=sum;
    }
  }
  
  cout<<max;
}

Measured memory_bytes: 256
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]

min=700
for dish in itertools.permutations(l, 5):
    index=1
    sum=dish[0]
    while index < len(dish):
        if sum%10==0:
            sum+=dish[index]
        else:
            sum = ((sum//10)+1)*10
            sum += dish[index]
        index+=1
    if sum < min:
        min = sum
print(min)

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

typedef unsigned long long int ll;


int main () {

    //for (ll tc = 1; tc <= 10000; tc++){
    ll n; cin >> n;

    ll start = 0;
    ll tmp = 1;
    ll t = 1;
    while(tmp <= n) {
        start++;
        t *= 26;
        tmp = tmp + t;
    }
    //cout << tmp << endl;
    string ans = "";
    for (int i = start; i > 0; i--) {
        ll a = 1;
        ll prev = 1;
        for (int j = 0; j < (i - 1); j++) {
            a *= 26;
            prev = prev + a;
        }
        prev -= a;
        ll c = (n - prev) / a;
        if (i == 1) {
            c = n;
        }
        if (c > 26) {
            c = 26;
        }
        //cout << "n=" << n << " a=" << a << " c=" << c << endl;
        ans = ans + (char)(c - 1 + 'a');
        n = n - c * a;
    }
    cout << ans << endl;
    //}
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin >> s;
	int len = s.length();
	if(s[len - 1] == 's')
	{
		cout << s << "es" << endl;
	}
	else
		cout << s << "s" << endl;
	return 0;
}


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

import sys

def main():
    h1,m1,h2,m2,k = map(int,input().split())
    start=h2*60+m2
    end=h1*60+m1
    time=start-end
    if time > 0:
        print(time-k)
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a;
  cin >> N;
  vector<int> vec;
   for (int i = 0; i < N; i++)
  {
      cin >> a;
      vec.push_back(a);
  }
  sort(vec.begin(),vec.end(),std::greater<int>());
  int sum = 0;
  int sign = 1;

  for(auto iter = vec.begin(); iter != vec.end(); ++iter) {
      sum += sign * *iter;
      sign *= -1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
q,h,s,d=map(int,input().split())
n=int(input())
ans=int(0)
q*=4
h*=2
if n%2==1:
    ans+=min([q,h,s])
    n-=1

n//=2
ans+=n*min([2*q,2*h,2*s,d])
print(int(ans))

Measured memory_bytes: 3064
using System;

namespace abc153_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            //モンスタークラスのコンストラクタに渡す
            monster mst = new monster(long.Parse(str1[0]));
            string[] str2 = Console.ReadLine().Split(' ');
            //int型の配列を作って、各スキルを入れる予定。
            int[] a = new int[int.Parse(str1[1])];
            for (int i = 0; i < int.Parse(str1[1]); ++i)
            {
                a[i] = int.Parse(str2[i]);
            }
            //アライグマのクラスを作成して、アライグマのスキル数と各スキルのダメージを渡す。
            raccoon arai = new raccoon(int.Parse(str1[1]),a);

            fight match = new fight();
            if (match.winLose(mst, arai))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
    class fight
    {
        public Boolean winLose(monster a,raccoon b)
        {
            long allDamage = 0;
            for(int i = 0; i < b.skill; ++i)
            {
                allDamage += b.skillNo[i];
            }
            
            return allDamage >= a.hp ? true : false;
        }
    }
    /// <summary>
    /// モンスタークラス
    /// </summary>
    class monster
    {
        public long hp;
        public monster(long h)
        {
            this.hp = h;
        }
    }
    /// <summary>
    /// アライグマクラス
    /// </summary>
    class raccoon
    {
        public int skill;
        public int[] skillNo;
        public raccoon(int s, int[] sn)
        {
            this.skill = s;
            this.skillNo = sn;
        }
    }
}

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

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

  int ma = max(a,max(b,c));
  int mi = min(a,min(a,b));
  int md = a+b+c-ma-mi;
  int cnt = 0;

  if (ma-1 > mi) {
    cnt += (ma - mi)/2;
    mi += (ma - mi)/2 * 2;
  }
  if (ma-1 > md) {
    cnt += (ma-md)/2;
    md += (ma-md)/2 * 2;
  }

  int ans = 0;
  if (ma == md && md == mi) ans = cnt;
  else if (ma != mi && mi == md) ans = cnt+1;
  else ans = cnt + 2;

  cout << ans << endl;
}


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


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

  vector<bool> a(n,false);
  
  REP(i,n){
    if((i+1) == p[i]) a[i] = true;
  }

  int cnt = 0;
  ll ans = 0;
  REP(i,n){
    if(a[i]){
      cnt++;
    }
    if(a[i] == false){

      ans += (cnt+1)/2;
      cnt = 0;
    }
  }

  if(cnt != 0) ans += (cnt+1)/2;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3792
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素


int main() {
    int N;
    cin >> N;
    int a = N%10;
    if(a==3)
        cout << "bon" << endl;
    else if (a==0 or a==1 or a==6 or a==8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/operators.hpp>
using namespace std;

template<u_int32_t P>
struct IntMod : boost::totally_ordered<IntMod<P>, boost::integer_arithmetic<IntMod<P>>> {
    int64_t value;
    IntMod(const int64_t& value) : value(value < 0 ? value % P + value : value % P) {}
    bool operator==(const IntMod<P>& other) const { return value == other.value; }
    bool operator<(const IntMod<P>& other) const { return value < other.value; }
    IntMod<P>& operator+=(const IntMod<P>& other) {
        value = (value + other.value) % P;
        return *this;
    }
    IntMod<P>& operator-=(const IntMod<P>& other) {
        value = (value - other.value) % P;
        if (value < 0) {
            value += P;
        }
        return *this;
    }
    IntMod<P>& operator*=(const IntMod<P>& other) {
        value = (value * other.value) % P;
        return *this;
    }
    IntMod<P>& operator/=(const IntMod<P>& other) {
        value *= other.inverse();
        return *this;
    }
    IntMod<P> inverse() {
        int64_t a = value, b = P, u = 1, v = 0;
        while (b) {
            int64_t t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= P;
        if (u < 0) {
            u += P;
        }
        return u;
    }
    IntMod<P> pow(u_int32_t n) {
        IntMod<P> res = 1, a = value;
        while (n > 0) {
            if (n & 1) {
                res *= a;
            }
            a *= a;
            n >>= 1;
        }
        return res;
    }
    IntMod<P> combination(u_int32_t k) {
        IntMod<P> nf = 1, kf = 1;
        for (int64_t n = value; k > 0; n--, k--) {
            nf *= n;
            kf *= k;
        }
        nf *= kf.inverse();
        return nf;
    }
};
template<u_int32_t P>
ostream& operator<<(ostream& out, IntMod<P> m) {
    out << m.value;
    return out;
}

using MInt = IntMod<1000000007>;

int main() {
    u_int32_t n, a, b;
    cin >> n >> a >> b;
    cout << (MInt(2).pow(n) - MInt(n).combination(a)- MInt(n).combination(b) - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b, tmp;
    for(;;){
      a = sc.nextInt();
      b = sc.nextInt();
      if(b < a){
        tmp = a;
        a = b;
        b = tmp;
      }

      if(b != 0){
        System.out.println(a + " " + b);
      }else{
        break;
      }
    }  

/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 27292
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            char[] s = Console.ReadLine().ToCharArray();
            char[] t = Console.ReadLine().ToCharArray();

            if (Judge(s,t))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool Judge(char[] list1, char[] list2)
        {
            for(int i =0; i<list1.Length; i++)
            {
                if(ArrayJudge(list1,list2))
                {
                    return true;
                }
                char tmp = list1[0];
                for (int j=0; j<list1.Length-1; j++)
                {
                    list1[j] = list1[j + 1];
                }
                list1[list1.Length - 1] = tmp;
            }
            return false;
        }
        static bool ArrayJudge(char[] list1,char[] list2)
        {
            for(int i=0;i<list1.Length; i++)
            {
                if(list1[i]!=list2[i])
                {
                    return false;
                }
            }
            return true;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long MIN =pow(10,8);
    long long n, ans=0;
    cin >> n;
    long long P[n];
    for(int i=0;i<n;i++){
       cin >> P[i];
    }
    for(int i=0;i<n;i++){
        if(P[i]<MIN){
            ans++;
        }
        MIN = min(P[i],MIN);
    }
   
   
   cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    val a = Array(N) { sc.nextInt() }
    var ans = Int.MAX_VALUE
    for (k in a.min()!!..a.max()!!) {
        var cnt = 0
        for (ai in a) {
            cnt += pow((ai - k), 2)
        }
        ans = Math.min(ans, cnt)
    }
    println(ans)
}

fun pow(a: Int, b: Int): Int {
    var result = 1
    for (i in 0 until b) {
        result *= a
    }
    return result
}


Measured memory_bytes: 36084
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string s, t = "";
  cin >> s;
  for(char c: s){
    if(c == '0')t += "0";
    else if(c == '1')t += "1";
    else t = t.size() > 0 ? t.substr(0, t.size()-1) : "";
  }
  cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
def rectangle(n, hs):
  stack = [] #高さと位置を格納
  ans = 0
  for i, h in enumerate(hs):
    j = i
    while stack and stack[-1][0] > h:
      pre_h, j = stack.pop()
      ans = max(ans, (i - j) * pre_h)

    if not stack or stack[-1][0] < h:
      stack.append((h, j))

  ans = max(ans, max((n-j) * h2 for h2, j in stack))

  return ans

H, W = map(int, input().split())

#ここでリストを固定化しておかないと値を受け付けてくれない
hist = [0] * W
result = 0
for _ in range(H):
  ht = list(map(int, input().split()))
  hist = list(map(lambda pre, cur: (pre+1) * (cur ^ 1), hist, ht))
  result = max(result, rectangle(W, hist))
print(result)


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

long long gcd(long long a,long long b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

int main(){
  long long int n;
  cin >>n;
  long long int a[n],b[n+1],c[n+1];
  
  for(long long int i=0;i<n;i++)cin >>a[i];
  b[0]=0;
  c[0]=0;
  b[1]=a[0];
  c[1]=a[n-1];
  for(long long int i=1;i<n-1;i++){
    b[i+1]=gcd(b[i],a[i]);
  }
  for(long long int i=1;i<n-1;i++){
    c[i+1]=gcd(c[i],a[n-1-i]);
  }
  long long int ans=0;
  
  for(long long int i=0;i<n;i++){
    long long int temp=0;
    
    if(i==0)temp=c[n-1];
    
    else if(i==n-1)temp=b[n-1];
    
    else temp=gcd(b[i],c[n-1-i]);
   
    ans=max(ans,temp);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){

    int n;
    cin >> n;
    ll x[n];
    ll xx[n];
    
    inrep(n,x);
    rep(i,0,n)xx[i] = x[i];
    sort(xx,xx+n);

    int a = xx[n/2 - 1], b = xx[n/2];
   
    rep(i,0,n){
	if(x[i] <= a)P(b);
	else P(a);
	
    }
    return  0;
}


Measured memory_bytes: 5248
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;

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

 			int a [] = new int [3];
 			 a[0] = in.nextInt();
 			  a[1] = in.nextInt();
 			   a[2] = in.nextInt();
 			  int temp = a[0];
 			  a[0]=a[1];
 			  a[1]=temp;
 			  int tem = a[2];
 			  a[2]=a[0];
 			  a[0]=tem;
 			  System.out.print(a[0]+" "+a[1]+" "+a[2]);
 		
 	}


}

Measured memory_bytes: 25044
#include<stdio.h>

int main(){
    int H,W;
    for(int i=0;i<1000000;i++){
        scanf("%d%d",&H,&W);
        if(H==0&&W==0)  break;
        for(int n=0;n<H;n++){
            for(int m=0;m<W;m++){
                if(n % 2==0){
                    if(m % 2==0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else{
                    if(m%2==0){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1972
N,K = list(map(int,input().split()))
X = list(map(int,input().split()))
ans = 10**10

for i in range(N-K+1):
    #S = X[i:i+K]
    #print(S,S[0],S[-1])
    mi = X[i]
    ma = X[i+K-1]
    #print(mi,ma)
    if ma<=0:
        ans = min(ans ,abs(mi))
    elif  mi>0:
        ans = min(ans ,ma)
    elif  mi<0 and ma>0:
        if abs(mi) > ma :
            ans = min(ans,abs(mi) + 2*ma)
        else :
            ans = min(ans,abs(mi)*2 + ma)

print(ans)

Measured memory_bytes: 20192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
      	sc.nextLine();
		String s=sc.nextLine();
		char[] c=s.toCharArray();
		int[] r=new int[n+1];
		for(int i=0;i<n;i++){
			if(c[i]=='R'){
				r[i+1]=r[i]+1;
			}else{
				r[i+1]=r[i];
			}
		}
		int min=n;
		int cost;
		int r2w;
		int w2r;
		for(int i=0;i<=n;i++){
			r2w=r[n]-r[i];
			w2r=i-r[i];
			if(r2w<w2r){
				cost=w2r;
			}else{
				cost=r2w;
			}			
			if(cost<min){
				min=cost;
			}
		}		
		System.out.println(min);
	}
}

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

int main() {
  int n;
  string ans="Yes";
  cin >> n;
  vector<string> w(n);
  for(int i=0;i<n;i++) cin >> w[i];
  for(int i=0;i<n-1;i++) {
    if(w.at(i).at(w.at(i).size()-1)!=w.at(i+1).at(0)) ans="No";
  };
  sort(w.begin(),w.end());
  for(int i=0;i<n-1;i++) {
    if(w.at(i)==w.at(i+1)) ans="No";
  };

  cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> L >> M >> R >> K;
	if (R >= L) {
		cout << "NO\n";
		return 0;
	}
	if (abs(N - M) <= K * (L - R)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    ll N,A,B; cin>>N>>A>>B;
    if((B-A)%2==0){
        cout<<(B-A)/2<<endl;
        return 0;
    }
    //cout<<min(B-1,N-A)<<endl;
    ll ans=INF;
    // Aが1にいくとき
    ans=(A-1)+1+(B-A-1)/2;

    ans=min(ans,(N-B)+1+(B-A-1)/2);
    cout<<ans<<endl;
    return 0;
}


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

double square_sum(double x, double y){
    return std::abs((x*x)+(y*y));
}

int fac(int n){
    if(n==1) return 1;
    return n*fac(n-1);
}

int main(){
    int n;
    double dist = 0;
    std::cin >> n;
    std::vector<std::pair<int,int>> d;
    d.resize(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> d[i].first >> d[i].second;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            dist += sqrt(square_sum(d[i].first-d[j].first,
                    d[i].second-d[j].second));
        }
    }
    printf("%.7f",dist*2/n);
}

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

int main(){

	int a,b,GCD,LCM,c;

	while(cin>>a>>b){

		if(a>b){
			c=b;
		}
		else{
			c=a;
		}

		for(int i=1;i<=(c/2+1);i++){
			if(b%i==0 && a%i==0){
				GCD = i;
			}
		}
		if(b%a==0 || a%b==0){
			GCD = c;
		}
		LCM=a/GCD*b;
		cout<<GCD<<" "<<LCM<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n,x=map(int,input().split())
def b(j):
    return 2**(j+2)-3
def p(j):
    return 2**(j+1)-1
def f(n,x):
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=b(n-1)+1:
        return f(n-1,x-1)
    elif x==b(n-1)+2:
        return p(n-1)+1
    elif 2+b(n-1)<x<=2*b(n-1)+2:
        return p(n-1)+1+f(n-1,x-b(n-1)-2)
    else:
        return 2*p(n-1)+1
print(f(n,x))

Measured memory_bytes: 3064
#include<stdio.h>
long long a[100005];
long long ans;
main(){
	int n,k;scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(register int i=1;i<n;i++){
		if(a[i]+a[i+1]>k){
			ans+=a[i]+a[i+1]-k;
			if(a[i]<=k)
				a[i+1]-=a[i]-k+a[i+1];
			else{
				a[i+1]=0;
				a[i]=k;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

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

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile(" ");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 179084
import sys
from math import sqrt, floor

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

a, b, k = map(int, sys.stdin.readline().split())

def main():
    g = gcd(a, b)
    cand = set()
    for i in range(1, floor(sqrt(g)) + 1):
        if not g % i:
            cand.add(i)
            cand.add(g // i)

    return sorted(cand)[-k]

if __name__ == '__main__':
    ans = main()
    print(ans)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    /**
     * O(NlogN)っぽい制限時間
     * でも
     * 二分探索でもないし
     * 貪欲かすごく分岐の少ないDP?
     *
     */

    i32 n, k, c; cin >> n >> k >> c;
    string s; cin >> s;
    /**
     * 解説AC...
     * 前から詰めると、最速で働ける日が決まる。
     * 後ろから詰めると、ぎりぎりで間に合う働く日が決まる
     * これで働く日があり得る範囲が求まるので、これが1日しかない物はその日しか働けない
     * 自然に発想できる気がしない。これが無能...
     */

    vi early_workday(k, -1), lazy_workday(k, -1);
    for(i32 i = 0, id = 0; i < n && id < k; ++i) {
        if(s[i] == 'o') {
            early_workday[id] = i;
            ++id;
            i += c;
        }
        if(id >= k) break;
    }
    for(i32 i = n-1, id = k-1; i >= 0 && id >= 0; --i) {
        if(s[i] == 'o') {
            lazy_workday[id] = i;
            --id;
            i -= c;
        }
    }

    minheap<i32> hp;
    for(i32 i = 0; i < k; ++i) {
        if(early_workday[i] == lazy_workday[i] && early_workday[i] != -1) hp.push(early_workday[i]);
    }

    while(hp.size()) {
        cout << hp.top() + 1 << '\n';
        hp.pop();
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 8600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX / 2;

int main() {
    int N; cin >> N;
    vector<int> v(N);
    pair<int, int> ma=make_pair(-INF, -1), mi=make_pair(INF,-1);
    for (int i = 0; i < N; i++)
    {    
        cin >> v[i];
        if(ma.first<v[i]){
            ma = make_pair(v[i], i);
        }
        if(mi.first>v[i]){
            mi = make_pair(v[i], i);
        }        
    }

    if(abs(ma.first)>=abs(mi.first)){
        cout << 2 * (N-1) << endl;
        for (int i = 0; i < N; i++)
        {
            if(i==ma.second) continue;
            cout << ma.second+1 << " " << i+1 << '\n';
        }
        for (int i = 1; i < N; i++)
        {
            cout << i << " " << i + 1 << '\n';
        }
    } else {
        cout << 2 * (N-1) << endl;
        for (int i = 0; i < N; i++)
        {
            if(i==mi.second) continue;
            cout << mi.second+1 << " " << i+1 << '\n';
        }
        for (int i = N; i > 1; i--)
        {
            cout << i << " " << i -1 << '\n';
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

long long n, k[100005], l[100005], sum, ksum, lsum, dis[100005], ans, mon, di;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		ksum += k[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
		lsum += l[i];
		if (l[i] <= k[i]) { ++sum; }
		dis[i] = (k[i] - l[i]);
	}
	if (ksum < lsum) {
		cout << -1 << endl;
		return 0;
	}
	if (sum == n) {
		cout << 0 << endl;
		return 0;
	}
	sort(dis, dis + n);
	for (int i = 0; i < n; ++i) {
		if (dis[i] < 0) {
			++ans;
			mon -= dis[i];
		}
		else { break; }
	}
	reverse(dis, dis + n);
	for (int i = 0; i < n; ++i) {
		di += dis[i];
		++ans;
		if (di >= mon) { break; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
INF = 10000000000

def merge(A, left, mid, right):
  L = A[left:mid] + [INF]
  R = A[mid:right] + [INF]
  i, j = 0, 0
  global count
  for k in range(left, right):
    if L[i] <= R[j]:
        A[k] = L[i]
        i += 1
    else:
        A[k] = R[j]
        j += 1
    count += 1

def merge_sort(A, left, right):
    if (left + 1) < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
merge_sort(A, 0, n)

print(*A)
print(count)


Measured memory_bytes: 63692
def reverse(x):
  if x[::-1]==x:
    return True
  else:
    return False

def main(s):
  l=len(s)//2
  x1=s[:l]
  x2=s[l+1:]
  if reverse(s) and reverse(x1) and reverse(x2):
    print("Yes")
  else:
    print("No")
    
if __name__=='__main__':
  main(input())
  

Measured memory_bytes: 38256
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[-1] < y[0]:
        print("No War")
else:
        print("War")

Measured memory_bytes: 3060
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back

#define endl '\n'
#define inf (lli)2000000000000
#define MOD (lli)1000000007
#define MAXN 100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	int a,b;
	cin >> a >> b;
	a = a *b;
	a&1 ? cout << "Odd" : cout << "Even";
	return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  lint aa1 = a1 * t1, aa2 = a2 * t2, bb1 = b1 * t1, bb2 = b2 * t2;
  if (aa1 + aa2 == bb1 + bb2) {
    cout << "infinity" << endl;
    return 0;
  }
  if (aa1 + aa2 < bb1 + bb2) {
    swap(aa1, bb1);
    swap(aa2, bb2);
  }
  if (aa1 > bb1) {
    cout << 0 << endl;
    return 0;
  }
  lint cnt = 0;
  lint d1 = aa1 - bb1, d2 = aa1 + aa2 - bb1 - bb2;
  cnt += -d1 / d2;
  cnt += -d1 / d2 + 1;
  if (d1 % d2 == 0) --cnt;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long n, m, l;
    cin >> n >> m >> l;

    long a[n][m] = {};
    long b[m][l] = {};
    long c[n][l] = {};

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

    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            for(int k = 0; k < l; k++){
                c[i][k] += a[i][j]*b[j][k];
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < l - 1; j++){
            cout << c[i][j] << " ";
        }
        cout << c[i][l - 1] << endl;
    }
}


Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    ull h;
    cin>>h;
    ull spl=0;
    ull count=1;
    while(h>1){
        h/=2;
        spl+=2*count;
        count*=2;
        //cout<<h<<endl;
    }
    cout<<spl+1<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;
const int MX = 1e5+8;
const int MOD = 1e9+7;
int n;
ll dp[MX][20];
ll ten[MX];
string s;

ll solve(int x,int y){
    if(x == n){
        if(y == 5)
            return 1;
        return 0;
    }
    ll &res = dp[x][y];
    if(res != -1)
        return res;
    if(s[x] != '?'){
        ll num = s[x]-'0';
        return res = solve(x+1,(y + num*ten[n-x-1]%13 ) %13);
    }
    res = 0;
    for(int i=0 ; i<=9 ; ++i){
        res = (res + solve(x+1,(i*ten[n-x-1]%13 + y )%13))%MOD;
    }
    return res;
}
int main(){
    cin >> s;
    ten[0] = 1;
    n = s.length();
    for(int i=1 ; i <= n ; ++i)
        ten[i] = (ten[i-1]*10)%13;
    memset(dp,-1,sizeof(dp));
    cout << solve(0,0) << "\n";
}

Measured memory_bytes: 24704
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long lint;

char buf[1 << 17];

inline char read()
{
	static int idx = 1 << 17;
	if (idx == 1 << 17)
	{
		fread(buf, 1, 1 << 17, stdin);
		idx = 0;
	}
	return buf[idx++];
}
inline int readInt()
{
	int sum = 0, flg = 1;
	char now = read();

	while (now == 10 || now == 32) now = read();
	if (now == '-') flg = -1, now = read();
	while (now >= 48 && now <= 57)
	{
		sum = sum * 10 + now - 48;
		now = read();
	}

	return flg * sum;
}
int main()
{
	int n = readInt();

	lint arr[200001];
	for (int i = 0; i < n; ++i)
	{
		arr[i] = readInt();
		if (i) arr[i] += arr[i - 1];
	}

	sort(arr, arr + n);

	lint ans = arr[0] == 0;
	int cnt = 1;

	for (int i = 1; i < n; ++i)
	{
		ans += !arr[i];

		if (arr[i] == arr[i - 1]) ++cnt;
		else ans += (lint)cnt * (cnt - 1) / 2, cnt = 1;
	}

	printf("%lld", ans + (lint)cnt * (cnt - 1) / 2);

	return 0;
}

Measured memory_bytes: 1792
function Main(input) {
  input = input.split("\n");
  const K = Number.parseInt(input[0]);
  const S = input[1];

  if (S.length <= K){
    console.log(S);
  } else {
    console.log(S.slice(0, K) + '...');
  }

}

// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29432
using System;

namespace AOJ.Volume3
{
    public class Rectangle
    {
        public static int Main()
        {
            var input = Console.ReadLine().Split(' ');
            var len = new int[4];
            for(int i = 0; i < 4; i++) { len[i] = int.Parse(input[i]); }

            Array.Sort(len);
            if(len[0]==len[1] && len[2] == len[3]) { Console.WriteLine("yes"); }
            else { Console.WriteLine("no"); }

            return 0;
        }
    }
}

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

using namespace std;

typedef long long ll;

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

signed main() {
	
	ll n, k, q;

	cin >> n >> k >> q;

	vector<ll>a(q);
	vector<ll>b(n, 0);

	rep(i, q) { 
		cin >> a[i];
		a[i]--;
		b[a[i]]++;
	}

	ll mid = q - k + 1;

	if (k - q > 0) {
		rep(i, n)cout << "Yes" << endl;
		return 0;
	}
	else {
		rep(i, n) {
			if (b[i] - mid >= 0) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2176
from collections import defaultdict

n, m = map(int, input().strip().split())
data = [list(map(int, input().strip().split())) for _ in range(m)]

prefectures = defaultdict(list)
for idx, (p, y) in enumerate(data):
    prefectures[p].append([idx, y, None])


for pref in prefectures:
    prefectures[pref].sort(key=lambda r: r[1])
    rows = prefectures[pref]
    for x, row in enumerate(rows):
        id = "{:06d}{:06d}".format(pref, x + 1)
        row[2] = id

all_list = []
for pref in prefectures.values():
    all_list.extend(pref)

all_list = sorted(all_list, key=lambda r: r[0])


for r in all_list:
    print(r[2])


Measured memory_bytes: 62952