akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = k;
  rep(i, n - 1) ans *= (k - 1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<long long> A(N), B(N+1); for (auto& a : A) cin >> a;
    sort(begin(A), end(A));
    for (int i = 1; i < N+1; i++) B[i] = B[i-1] + A[i-1];
    for (int i = N; i > 0; i--) {
        if (A[i-1] > B[i-1] * 2) {
            cout << N + 1 - i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c,d,e;
   cin >>a>>b;
   c=max(a-b,a+b);
   d=max(a+b,a*b);
   e=max(c,d);
   cout<<e<<endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0, j; i < n; ++i)
    {
        scanf("%d", &j);
    }
    printf("%d\n", n == k ? 1 : (n - k - 1) / (k - 1) + 2);
}


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

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

    if (N == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        int A, B;
        cin >> A >> B;
        cout << A+B << endl;
    }

    return 0;
}

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

int CEIL(int a, int b) {return (a - 1) / b + 1;}

int main(){

	int N, M;
	int X[100];
	cin >> N;

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

	cin >> M;
	int buf;
	for(int i = 0; i < M; i++){
		cin >> buf;
		if(X[buf-1] == 2019) continue;
		if(buf-1 != N - 1)
			if(X[buf-1] + 1 == X[buf]) continue;
		X[buf-1]++;
	}
	
	for(int i = 0; i< N; i++){
		cout << X[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
    public static int gcd(int a, int b) {
        if(a < b) return gcd(b,a);
        if(b == 0) return a;
        return gcd(b,a%b);
    }

    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer N = Integer.parseInt(scanner.next());
        Integer[] a = new Integer[N];

        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(scanner.next());
        }

        Integer res = a[0];
        for (int i = 0; i < N; i++) {
            res = gcd(res, a[i]);
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 46884
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9;

int howManyTwoIncluded(int num){
	if( num == 0) return 0;
	if( num % 2 == 1) return 0;
	return howManyTwoIncluded(num/2) + 1;
}

int main()
{
	int n;
	unsigned long long int ans = 0;
	cin>>n;
	rep(i,n){
		int num;
		cin>>num;
		ans += howManyTwoIncluded(num);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    int N,M;
    cin >> N >> M;
    string S;
    cin >> S;
    lint p[N+10]={};
    p[0]=1;
    rep(i,N+5) p[i+1]=(p[i]*10)%M;
    lint sum[N]={};
    lint cnt[M+50]={};
    lint ans=0;
    lint base=0;
    if(M==2){
        rep(i,N) if((S[i]-'0')%2==0) ans+=i+1;
        cout << ans << endl;
        return 0;
    }
    if(M==5){
        rep(i,N) if((S[i]-'0')%5==0) ans+=i+1;
        cout << ans << endl;
        return 0;
    }
    sum[0]=(S[N-1]-'0')%M;
    cnt[sum[0]]++;
    for(int i=1;i<N;i++){
        sum[i]=(sum[i-1]+p[i]*(S[N-1-i]-'0'))%M;
        cnt[sum[i]]++;
    }
    for(int i=0;i<N;i++){
        ans+=cnt[base];
        lint minus=(p[i]*(S[N-1-i]-'0'))%M;
        base=(base+minus+M)%M;
        cnt[sum[i]]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;


int main(void) {
  ll n;
  V w;
  // このプログラムでは辺の長さも保持する
  VV adj_lists;
  VV adj_dist;
  stack<ll> dfs_stack;

  cin >> n;
  adj_lists = VV(n);
  adj_dist = VV(n);
  for(ll i=0; i<n-1; i++) {
    ll u, v, wt;
    cin >> u >> v >> wt;

    // ここでは0-indexに予め変換している
    adj_lists[u-1].push_back(v-1);
    adj_dist[u-1].push_back(wt);
    adj_lists[v-1].push_back(u-1);
    adj_dist[v-1].push_back(wt);
  }

  // 探索済みか？
  V is_visited(n, 0);
  // 探索開始点からの距離は偶数か？
  V is_even(n, 0);
  // 探索開始点からの距離
  stack<ll> dist;

  // 深さ優先探索
  dfs_stack.push(0);
  dist.push(0);
  while(!dfs_stack.empty()) {
    ll s_node = dfs_stack.top(); dfs_stack.pop();
    ll c_dist = dist.top(); dist.pop();

    //debug
    //cout << "Node: " << s_node << ", c_dist: " << c_dist << endl;

    // 距離は偶数？
    if((c_dist & 0b1) == 0) {
      is_even[s_node] = 1;
    } // else is_even[s_node] = 0

    // ノード探索終わり
    is_visited[s_node] = 1;

    // 隣接していてかつ未探索なノードをスタックに積む
    for(ll i=0; i<adj_lists[s_node].size(); i++) {
      ll adj_node = adj_lists[s_node][i];
      if(is_visited[adj_node] == 0) {
        dfs_stack.push(adj_node);
        // 距離の計算もやる
        dist.push(c_dist + adj_dist[s_node][i]);
      }
    }
  }

  // 出力
  for(auto itr=is_even.begin(); itr!=is_even.end(); itr++) {
    cout << *itr << endl;
  }

  return 0;
}


Measured memory_bytes: 13952
#include <stdio.h>

int main(void)
{
  int N;
  scanf("%d",&N);
  
  int A;
  int result = 1;	//0だと失敗
  
  for (int i = 0; i < N; i++)
  {
    scanf("%d",&A);
    if (A%2==0&&(A%3!=0&&A%5!=0))
    {
      result = 0;
      break;
    }
  }
  
  if (result) printf("APPROVED");
  else printf("DENIED");
  
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

llong N;
vector<llong> C, memo;
vector<vector<llong>> pos;

llong dp(int now){
	if(now == N)
		return 1ll;
	if(memo[now] != -1)
		return memo[now];

	llong ret = 0;
	for(int i = pos[C[now]].size()-1; i >= 0 && pos[C[now]][i] >= now; i--){
		(ret += dp(pos[C[now]][i]+1)) %= mod;
	}

	return memo[now] = ret;
}

int main(){
	cin >> N;

	pos.resize(int(2e5)+1);
	llong in;
	for(int i = 0; i < N; i++){
		cin >> in;
		if(C.size() == 0 || C[(int)C.size()-1] != in){
			C.push_back(in);
			pos[in].push_back(C.size()-1);
		}
	}
	cerr << endl;

	N = C.size();
	// memo.resize(N,-1);

	// cout << dp(0) << endl;

	vector<llong> many(int(2e5)+1,0);
	many[C[C.size()-1]]++;
	for(int i = N-2; i >= 0; i--){
		many[C[i]] += many[C[i+1]];
		many[C[i]] %= mod;
	}

	cout << many[C[0]] << endl;

	return 0;
}

Measured memory_bytes: 14320
s = list(input())
ans = "AC"

if s[0] == "A" and "C" in s[2:-1] and s.count("C") == 1 and s[1].islower():
    for i in range(3, len(s)):
        if not s[i].islower() and s[i] != "C":
            ans = "WA"
            break
else:
    ans = "WA"

print(ans)

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

using namespace std;

int n, ans = 0;

int Func(int a);

int main()
{
    cin >> n;
    for (int i = 1; i < n; i++)
    {
	ans += Func(i);
    }
    cout << ans << endl;
    return 0;
}

int Func(int a)
{
    int re = 0;
    for (int i = 1; i <= floor(sqrt(a)); i++)
    {
	if (a % i == 0)
	{
	    re++;
	}
    }
    if (floor(sqrt(a)) == ceil(sqrt(a)))
    {
	return re * 2 - 1;
    }
    return re * 2;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a+b) >= c ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

struct Info{
	char mark,dist;
	int num;
};


int main(){

	char TRUMP[2],dealer;
	char buf[4];
	Info cards[4][13],work[4];
	for(int i = 0; i < 13; i++){
		cards[0][i].dist = 'N';
		cards[1][i].dist = 'E';
		cards[2][i].dist = 'S';
		cards[3][i].dist = 'W';
	}


	int ns,ew;

	while(true){
		scanf("%s",TRUMP);
		if(TRUMP[0] == '#')break;

		for(int i = 0;i < 4; i++){
			for(int k = 0; k < 13; k++){
				scanf("%s",buf);
				if(buf[0] == 'T'){
					cards[i][k].num = 10;
					cards[i][k].mark = buf[1];
				}else if(buf[0] == 'J'){
					cards[i][k].num = 11;
					cards[i][k].mark = buf[1];
				}else if(buf[0] == 'Q'){
					cards[i][k].num = 12;
					cards[i][k].mark = buf[1];
				}else if(buf[0] == 'K'){
					cards[i][k].num = 13;
					cards[i][k].mark = buf[1];
				}else if(buf[0] == 'A'){
					cards[i][k].num = 14;
					cards[i][k].mark = buf[1];
				}else{
					cards[i][k].num = buf[0] - '0';
					cards[i][k].mark = buf[1];
				}
			}
		}

		ns = 0,ew = 0;

		dealer = cards[0][0].mark;
		for(int i = 0; i < 13; i++){
			for(int k = 0; k < 4; k++){
				work[k] = cards[k][i];
			}

			for(int k = 1; k <= 3; k++){
				for(int p = 3; p >= k; p--){
					if(dealer == TRUMP[0]){
						if(work[p].mark ==dealer && work[p-1].mark != dealer){
							swap(work[p],work[p-1]);
						}else if(work[p].mark == dealer && work[p-1].mark == dealer && work[p].num > work[p-1].num){
							swap(work[p],work[p-1]);
						}
					}else{ //dealer != TRUMP[0]
						if(work[p].mark != TRUMP[0] && work[p-1].mark != TRUMP[0] && ((work[p].mark == dealer && work[p-1].mark != dealer) ||
								(work[p].mark == dealer && work[p-1].mark == dealer && work[p].num > work[p-1].num))){
							swap(work[p],work[p-1]);
						}else if(work[p].mark == TRUMP[0] && work[p-1].mark != TRUMP[0]){
							swap(work[p],work[p-1]);
						}else if(work[p].mark == TRUMP[0] && work[p-1].mark == TRUMP[0]&& work[p].num > work[p-1].num){
							swap(work[p],work[p-1]);
						}
					}
				}
			}
			switch(work[0].dist){
			case 'N':
				if(i <= 11){
					dealer = cards[0][i+1].mark;
				}
				ns++;
				break;
			case 'S':
				if(i <= 11){
					dealer = cards[2][i+1].mark;
				}
				ns++;
				break;
			case 'E':
				if(i <= 11){
					dealer = cards[1][i+1].mark;
				}
				ew++;
				break;
			case 'W':
				if(i <= 11){
					dealer = cards[3][i+1].mark;
				}
				ew++;
				break;
			}
		}

		if(ns > ew){
			printf("NS %d\n",ns-6);
		}else{
			printf("EW %d\n",ew-6);
		}
	}
    return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

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


Measured memory_bytes: 3592
#include <iostream>
#include<queue>
using namespace std;
const int MAXn=10000;
const int INFTY=1<<21;

int n,col[MAXn],d[MAXn];
vector<pair<int,int>> Q[MAXn];

void dijkstra(int s)
{
	priority_queue<pair<int,int>> PQ;//weight,id
	for(int i=0;i<n;i++)
	{
		d[i]=INFTY;
		col[i]=0;
	}
	d[s]=0;
	PQ.push(make_pair(0,s));
	col[s]=1;
	
	while(!PQ.empty())
	{
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<Q[u].size();j++)
		{
			int v=Q[u][j].first;
			if(col[v]==2)continue;
			if(d[u]+Q[u][j].second<d[v])
			{
				d[v]=d[u]+Q[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}
	
	for(int i=0;i<n;i++)cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
	
	return;
}

int main() {
	cin>>n;int id,k,c,v;
	for(int i=0;i<n;i++)
	{
		cin>>id>>k;
		for(int j=0;j<k;j++)
		{
			cin>>v>>c;
			Q[id].push_back(make_pair(v,c));
		}
	}
	dijkstra(0);
	return 0;
}

Measured memory_bytes: 8004
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
template<typename T>
T mypow(T k, int n){
  T result=1;
  REP(i,n)
    result*=k;
  return result;
}
ll s(ll a){
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}

ll a[100000];
int main(){ _;
  int K;cin>>K;
  int index=0;
  for(int k=1;k<1000;k++){
    while(index!=0&&a[index-1]*s(k)>k*s(a[index-1])){
      index--;
    }
    a[index]=k;
    index++;
  }
  for(int i=1;i<=12;i++){
    for(ll j=100;j<1000;j++){
      ll k=(j+1LL)*mypow(10LL,i)-1LL;
      while(index!=0&&a[index-1]*s(k)>k*s(a[index-1])){
	index--;
      }
      if(a[index-1]!=k){
	a[index]=k;
	index++;
      }
    }
  }
  REP(i,K)
    cout<<a[i]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int a, b, c;
    int divide, cnt = 0;
 
    scanf("%d %d %d", &a, &b, &c);
    for (divide = a; divide <= b; divide++){
        if (c % divide == 0){
            cnt++;
        }
    }
    printf("%d\n", cnt);
 
    return 0;
}
 

 

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

int main()
{
    int n, d;
    int res = 0;
    cin >> n >> d;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (sqrt(x*x + y*y) <= d) res++;
    }
    cout << res << endl;
    return 0;
}

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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var N = int.Parse(buffer[0]);
            var M = int.Parse(buffer[1]);
            var X = int.Parse(buffer[2]);

            int[,] list = new int[N, M + 1];
            for (int i = 0; i < N; i++)
            {
                foreach (var (v, j) in Console.ReadLine().Split().Select((v, j) => (v, j)))
                    list[i, j] = int.Parse(v);
            }

            int min = int.MaxValue;
            for (int i = 1; i < 1 << N; i++)
            {
                var index = new List<int>();
                for (int j = 0; j < N; j++)
                {
                    if ((i & (1 << j)) == 0)
                        continue;
                    index.Add(j);
                }

                int[] skill = new int[M + 1];

                foreach (var v in index)
                {
                    for (int k = 0; k < M + 1; k++)
                        skill[k] += list[v, k];
                }

                bool _break = false;
                foreach (var v in skill.Skip(1))
                {
                    if (v < X)
                    {
                        _break = true;
                        break;
                    }
                }

                if (!_break && min > skill.First())
                    min = skill.First();
            }

            if (min == int.MaxValue)
                Console.WriteLine("-1");
            else
                Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 29296
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

/*
Нас по звукам узнавай:
Ня Кавай, Ня Кавай
Мы орем на весь трамвай:
Ня Кавай
Никогда не забывай:
Ня Кавай, Ня Кавай
Лучше к нам не приставай
Ня Кавай
*/

string s;
ll a, b, c;

int main()
{
	/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	*/
	cin >> s;
	ll add = 1;
	for (ll i = s.size() - 1; i >= 0; i--)
	{
		if (s[i] == '?')
		{
			a = a * 3 + b;
			b = b * 3 + c;
			c = c * 3 + add;
			add = (add * 3) % mod;
		}
		if (s[i] == 'A')
			a += b;
		if (s[i] == 'B')
			b += c;
		if (s[i] == 'C')
			c += add;
		a %= mod;
		b %= mod;
		c %= mod;
	}
	cout << a;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
using namespace std;

int W, H;

bool compare(const string& s1, const string& s2){
  if(s1.size() != s2.size()) return !(s1.size() > s2.size());
  else return !(s1 > s2);
}

string adjust(string s){
  if(s.size() == 1) return s;
  bool f = false;
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] != '0') f = true;
  }
  if(!f) return "0";
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] == '0') continue;
    else return s.substr(i);
  }
}

int main(){
  while(cin >> W >> H){
    if(W == 0 && H == 0) break;
    vector<string> vec;
    char field[71][71];
    string dp[71][71];
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cin >> field[i][j];
      }
    }
    string ans = "";
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(!isdigit(field[i][j])) continue;
	if(i == 0 && j == 0) dp[i][j] = field[i][j];
	else if(i == 0) dp[i][j] = dp[i][j-1] + field[i][j];
	else if(j == 0)	dp[i][j] = dp[i-1][j] + field[i][j];
	else dp[i][j] = max(dp[i][j-1]+field[i][j], dp[i-1][j]+field[i][j], compare);
	vec.push_back(dp[i][j]);
      }
    }
    for(int i = 0 ; i < vec.size() ; i++){
      vec[i] = adjust(vec[i]);
      ans = max(ans, vec[i], compare);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1468
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
Factorial_list = [1,1]
for i in range(N-2):
    Factorial_list.append(Factorial_list[-1]*(i+2))
Factorial_list.reverse()
P_cnt = [0 for i in range(N)]
Q_cnt = [0 for i in range(N)]
for i in range(N):
    cnt = 0
    for j in range(i+1,N):
        if P[i]>P[j]:
            cnt+=1
    P_cnt[i]=cnt
for i in range(N):
    cnt = 0
    for j in range(i+1,N):
        if Q[i]>Q[j]:
            cnt+=1
    Q_cnt[i]=cnt
a = 0
b = 0
for i in range(N):
    a+=P_cnt[i]*Factorial_list[i]
    b+=Q_cnt[i]*Factorial_list[i]
if a-b>=0:
    print(a-b)
else:
    print(b-a)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		long x = in.nextLong();
		long y = in.nextLong();
		int count = 0;
		while (x <= y) {
			x *= 2;
			count++;
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 23636
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    int n;
    cin>>n;
    bool ok=1;
    vi vec(n);
    rep(i,n){
        cin>>vec[i];
        if(vec[i]%2==0){
            ok&=(vec[i]%3==0 or vec[i]%5==0);
        }
    }
    if(ok) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 256
n,k=map(int,input().split())
P=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(n):
    dp[i+1]+=dp[i]+P[i]
ans=0
for i in range(n-k+1):
    ans=max(ans,dp[i+k]-dp[i])
print((ans+k)/2)
    

Measured memory_bytes: 71792
#include<stdio.h>
#define pi 3.1415926535897932
int main()
{
    double r,area,circumference;
    scanf("%lf",&r);
    area=pi*r*r;
    circumference=2*pi*r;
    printf("%lf %lf\n",area,circumference);
    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int64_t k;
    cin >> k;

    s += '*';
    int64_t l1 = 0;
    while (s[l1] == '1') l1++;

    cout << (k <= l1 ? '1' : s[l1]) << endl;
}


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

vector<int> a;

bool check(int x) {
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] == x) {
			return true;
		}
	}
	return false;
}

int main()
{
	int x, y, p;
	
	cin >> x >> y;
	for (int i = 0; i < y; ++i) {
		cin >> p;
		a.push_back(p);
	}
	if (y == 0) {
		cout << x;
		return 0;
	}
	int i = 0;
	while (true) {
		if (!check(x - i)) {
			cout << x - i;
			break;
		}
		if (!check(x + i)) {
			cout << x + i;
			break;
		}
		i += 1;
	}

	return 0;
}

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

int main(){
  int sum=0,max=0;
  bool a=false;
  string s; cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      a=true;
      if(a){
        sum++;
        if(sum>max){max=sum;}
        a=false;
      }
    }
     else{
       sum=0;
     }
    }
   
  cout<<max<<endl;
      return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  //declare function
  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var cols = inputs[0].split(' ').map(Number);
  //main
  var result = function(a, b, c) {
    var count = 0;
    for (var i = a; i <= b; i++) {
      if (c % i === 0) {
        count++;
      }
    }
    return count;
  }(cols[0], cols[1], cols[2]);

  //display
  console.log(result);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15588
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 < _ >> ( ) } ; ( $ 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" ) } ; }

fn main() {
    input! {
        mut s: chars
    }
    for i in 0..s.len() {
        if s[i] == ',' {
            s[i] = ' ';
        }
    }
    println!("{}", s .iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
sl = sorted(s)
sm = sum(sl)
if sm%10 == 0:
    for i in range(n):
        if (sm - sl[i])%10 != 0:
            sm -= sl[i]
            break
if sm%10 == 0:
    print(0)
else:
    print(sm)

Measured memory_bytes: 3060
while 1:
    h,m,s=map(int,raw_input().split())
    if h==-1:
        break
    t=h*3600+m*60+s
    ans1=7200-t
    ans2=ans1*3
    print "%02d:%02d:%02d"%(ans1/3600,(ans1%3600)/60,ans1%60)
    print "%02d:%02d:%02d"%(ans2/3600,(ans2%3600)/60,ans2%60)
exit()

Measured memory_bytes: 6240
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main()
{
  int n,m;
  scanf("%d",&n);
  static char s[300][310];
  static bool b[300][310];
  for(int i=0;i<n;i++){
    scanf("%s",s[i]);
    for(int j=0;j<n;j++){
      b[i][j]=(s[i][j]=='1'); 
    }
  }
  queue<int> Q;
  Q.push(0);
  vector<int> d(n,-1);
  d[0]=0;
  bool F=true;
  while(!Q.empty()&&F){
    int i=Q.front();
    Q.pop();
    for(int j=0;j<n;j++){
      if(!b[i][j])
	continue;
      if(d[j]==-1){
	d[j]=1-d[i];
	Q.push(j);
      }
      else if(d[j]!=1-d[i]){
	F=false;
	break;
      }
    }
  }
  if(!F){
    puts("-1");
  }
  else{
    int INF=n+10;
    int D[310][310];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	D[i][j]=(i==j?0:b[i][j]?1:INF);
      }
    }
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++){
	  D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
	}
    int L=0;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	L=max(L,D[j][k]);
      }
    }
    printf("%d\n",L+1);
  }
  return 0;
}


Measured memory_bytes: 640
N  = input()
if N[0]==N[1]==N[2] and N[0]!=N[3]:
    print('Yes')
elif N[0]!= N[3] and N[1]==N[2]==N[3]:
    print('Yes')
elif N[0]==N[1]==N[2]==N[3]:
    print('Yes')
else :
    print('No')
    

Measured memory_bytes: 3060
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin >> n;

	map<string, ll> mp;

	ll max = 0;
	REP(i, n) {
		string s;
		cin >> s;
		mp[s]++;
		chmax(max, mp[s]);
	}

	for (auto i : mp) {
		if (i.second == max) cout << i.first << endl;
	}

	return 0;
}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
string divide[4]={"dream","dreamer","erase","eraser"};
int main(){
    string S;
    cin>>S;

    reverse(S.begin(),S.end());
    for(int i=0;i<4;i++){
        reverse(divide[i].begin(),divide[i].end());
    }

    bool can=true;
    for(int i=0;i<S.size();){
        bool can2=false;
        for(int j=0;j<4;j++){
            string d=divide[j];
            if(S.substr(i,d.size())==d){
                can2=true;
                i=i+d.size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    if(can)cout<<"YES";
    else cout<<"NO";
    return 0;
}

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


int main(){

    string s;
    cin >> s;
    int ans = 0;
    if (s == "SUN") ans = 7;
    else if (s == "SAT") ans = 1;
    else if (s == "FRI") ans = 2;
    else if (s == "THU") ans = 3;
    else if (s == "WED") ans = 4;
    else if (s == "TUE") ans = 5;
    else if (s == "MON") ans = 6;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N ;
  vector <int> A(N);
  for (int i=0 ; i <N ; i++){
  cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int sum=0 ;
  for (int i=N-1 ; i>=0 ; i--){
    sum += ( A.at(i) ) * ((N-i)%2==1 ? 1 : -1 ) ;  
}
  cout << sum << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

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

        sc.close();

        int sum = 0;

        for (int i = 1; i <= n; i++) {
            int num = solve(i);
            if (num >= a && num <= b) {
                sum += i;
            }
        }

        System.out.println(sum);

    }

    private static int solve(int num) {
        int sum = 0;
        while (num != 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mp make_pair
#define pb push_back
#define size(type) ((char *)(&type+1)-(char*)(&type))
#include <bits/stdc++.h> 
using namespace std; 
  

 
int main() {
 
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x,y;
    if(a<0 and b<0 and c<0 and d<0){
    	x=min(a,b);
    	y=min(c,d);
    	ll sum=x*y;
    	cout<<sum<<endl;
    }

    else if(a<0 and b<0 and c<0){
    	x=min(a,b);
    	y=c;
    	ll sum=x*y;
    	cout<<sum<<endl;

    }
    else if(a<0 and b<0 and d<0){
    	x=min(a,b);
    	y=d;
    	ll sum=x*y;
    	cout<<sum<<endl;
    	
    }
    else if(b<0 and c<0 and d<0){
    	x=min(c,d);
    	y=b;
    	ll sum=x*y;
    	cout<<sum<<endl;
    	
    }
    else if(a<0 and c<0 and d<0){
    	x=min(c,d);
    	y=a;
    	ll sum=x*y;
    	cout<<sum<<endl;
    	
    }
    
    else if(a<0 and b<0){
     x=min(c,d);
     y=max(a,b);
     cout<<x*y<<"\n";


    }
    
   
    else if(c<0 and d<0){
    	x=min(a,b);
    	y=max(c,d);
    	cout<<x*y<<"\n";

    }
    else if(a<0 and c<0 ){
    	ll sum=a*c;
    	x=max(a,b);
    	y=max(c,d);
    	ll sum1=x*y;
    	cout<<max(sum,sum1)<<"\n";

    }
    else if(a<0 and d<0 ){
    	ll sum=a*d;
    	x=max(a,b);
    	y=max(c,d);
    	ll sum1=x*y;
    	cout<<max(sum,sum1)<<"\n";
    	
    }
    else if(b<0 and c<0 ){
    	ll sum=b*c;
    	x=max(a,b);
    	y=max(c,d);
    	ll sum1=x*y;
    	cout<<max(sum,sum1)<<"\n";
    	
    }
    else if(b<0 and d<0 ){
    	ll sum=b*d;
    	x=max(a,b);
    	y=max(c,d);
    	ll sum1=x*y;
    	cout<<max(sum,sum1)<<"\n";
    	
    }
    else{
    	ll sum1=max(a,b);
    	ll sum2=max(c,d);
    	ll result=sum1*sum2;
    	cout<<result;
    }

   
}

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

main() {
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, (int)(upper_bound(a.begin(), a.end(), a[i] + 2) - lower_bound(a.begin(), a.end(), a[i])));
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}


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

    int N; ll K; cin >> N >> K;
    vei A(N); rep(i,N) cin >> A[i];

    ll cnt = 0LL, cnt2 = 0LL;
    rep(i,N-1) repk(j,i+1,N) {
        if(A[i] > A[j]) cnt++;
    } 
    rep(i,N) rep(j,N) if(A[j] > A[i]) cnt2++;

    ll res = cnt * K; res %= mod;
    ll res2 = cnt2 * ( ( K * (K - 1) / 2 ) % mod ); res2 %= mod;
    ll ans = (res + res2) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def comb_init(max, mod)
  fac = Array.new(max)
  finv = Array.new(max)
  inv = Array.new(max)
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  (2...max).each do |i|
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod / i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
  end
  { fac: fac, finv: finv, mod: mod }
end

def comb(n, k, context)
  return 0 if n < k
  return 0 if n < 0 || k < 0
  fac = context[:fac]
  finv = context[:finv]
  mod = context[:mod]
  fac[n] * (finv[k] * finv[n - k] % mod) % mod
end

N = gets.to_i
table = Hash.new { 0 }
s_list = N.times.map { gets.chomp.chars }
s_list.each do |s|
  table[s.sort] += 1
end

ans = 0
context = comb_init(N + 10, 67280421310721 )
table.each do |k, v|
  next if v == 0
  ans += comb(v, 2, context)
end
puts ans


Measured memory_bytes: 100732
#include<stdio.h>
int main()
{
  int n,k,i,sum=1;
  scanf("%d%d",&n,&k);
  for(i=1;i<=n;i++)
  {
      if(sum*2>sum+k) sum+=k;
      else sum*=2;
  }printf("%d\n",sum);
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#define maxn 5010
#define maxint 0x7fffffff/2
using namespace std;
double pi=3.1415926;
int main() {
	int n;
	cin>>n;
	double r=double(1.0*n);
	printf("%.4lf",1.0*r*2.0*1.0*pi);
	return 0;
}


Measured memory_bytes: 3764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String result;
		if(s.charAt(0) == s.charAt(s.length() - 1)) {
			if(s.length()%2 == 0)
				result = "First";
			else
				result = "Second";
		} else {
			if(s.length()%2 == 0)
				result = "Second";
			else
				result = "First";
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 13740
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, p;
  string s;
  cin >> N;
  vector<pair<pair<string, int>, int>> rest(N);
  for(auto i = 0; i < N; i++) {
    cin >> s >> p;
    rest.at(i).first.first = s;
    rest.at(i).first.second = -p;
    rest.at(i).second = i + 1;
  }
  sort(rest.begin(), rest.end());
  for(auto i : rest) {
    cout << i.second << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

int cngPanel(vvi&f, int t){
	int p=f[0][0];
	queue<pii> q;
	q.emplace(0,0);
	while(!q.empty()){
		int x=q.front().fs;
		int y=q.front().sc;
		q.pop();
		f[y][x]=-1;
		vi v={1,0,-1,0,1};
		rep(i,4){
			int nx=x+v[i];
			int ny=y+v[i+1];
			if(min(nx,ny)<0 or nx==f[0].size() or ny==f.size())
				continue;
			if(f[ny][nx]==p){
				f[ny][nx]=-1;
				q.emplace(nx,ny);
			}
		}
	}
	int ret=0;
	for(auto&&l:f)for(auto&&i:l){
		if(i==-1){
			ret++;
			i=t;
		}
	}
	return ret;
}

int solve(vvi f, vi r){
	for(auto i:r){
		cngPanel(f,i);
	}
	return cngPanel(f,f[0][0]);
}


int main(){
	int h,w,c;
	while(cin>>h>>w>>c, h){
		int ans=0;
		vvi f(h,vi(w));
		for(auto &&l:f)for(auto &&i:l){
			cin>>i; i--;
		}
		rep(i,1296){
			ans=max(ans,solve(f,{i%6,i/6%6,i/36%6,i/216%6,c-1}));
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3148
n = int(input())
A = [int(i) for i in input().split()]
cnt = 0
bool = True
while bool:
    for i in range(n):
        if A[i] % 2 == 0:
            A[i] /= 2
        else:
            bool = False
            break
    if bool:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;

const int DMAX = 2e5+10;

inline int two(int n) { return 1 << n; }
inline int test(int n, int pos) { return (bool) (n & two(pos)); }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }

int n,ans;

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

    int x,y,i,nr=1;

    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x;
        if(x != nr)
           ans++;
        else
           nr++;
    }
    if(nr == 1)
        cout<<"-1\n";
    else
        cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a;
  for(int i = n%10; i != 0;n /= 10,  i = n%10)
    a.insert(a.begin(),(i == 1?9:1));
  for(int i = 0; i < a.size(); i++){
    cout << a[i];
  }
  cout << endl;
}


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

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

int isCorrect(int n,int m,int w,int *t){
	int i, now = 0;

	rep(i,n){
		int sum = 0;
		for(;now<m && sum+t[now]<=w;sum+=t[now],now++);
		if(now == m) return 1;
	}

	return 0;
}

int getMin(int sp,int m,int *t){
	int left=0,right=0,sum=0;
	int res = INT_MAX;

	for(;left<m;left++){
		if(left != 0) sum -= t[left-1];
		for(;right<m && sum<=sp;sum+=t[right],right++);
		if(sp < sum && sum < res) res = sum;
	}

	return res;
}

int main(void){
	int i,j,start,end;
	int n,m;
	int w,t[100];

	while(scanf("%d%d",&n,&m) && (n||m)){
		rep(i,m) scanf("%d",&t[i]);

		w = 0;
		rep(i,m) if(w < t[i]) w = t[i];
		while(1){
			if(isCorrect(n,m,w,t)) break;
			w = getMin(w,m,t);
		}
		printf("%d\n",w);
	}

	return 0;
}

Measured memory_bytes: 0
W, H, N = gets.split.map(&:to_i)

xmax = 0
xmin = W
ymax = 0
ymin = H

N.times do
  
  x, y, a = gets.split.map(&:to_i)
  
  if a == 1
    xmax = x if xmax < x
  elsif a == 2
    xmin = x if xmin > x
  elsif a == 3
    ymax = y if ymax < y
  else 
    ymin = y if ymin > y
  end
end

if xmax > xmin or ymax > ymin
  puts 0
else
  puts (xmin - xmax)*(ymin - ymax)
end

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

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

    int n,a,b;
    cin >> n>>a>>b;

    cout << (((b-a) % 2) ? "Borys" : "Alice") << '\n';
    return (0);
}


Measured memory_bytes: 3652
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }


fn main() {
    input!{
        X: usize,
    }
    println!(
        "{}",
        if X == 3 || X == 5 || X == 7 {
            "YES"
        } else {
            "NO"
        }
    )
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int main(){
  string s; cin >> s;
  if(s[1] == 'B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

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

const int MX = 13000, N = 85;
bitset<2*MX> pos[N][N];
int a[N][N], b[N][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin>>n>>m;

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


    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>b[i][j];


    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            int d = abs(a[i][j] - b[i][j]);
            if (i == 1 && j == 1)   pos[i][j][MX+d] = 1;
            if (i > 1)  pos[i][j] |= (pos[i-1][j] << d) | (pos[i-1][j] >> d);
            if (j > 1)  pos[i][j] |= (pos[i][j-1] << d) | (pos[i][j-1] >> d);

//            cout<<i<<" "<<j<<" "<<d<<" ---> ";
//            for (int x=0; x<2*MX; x++)
//                if (pos[i][j][x])   cout<<x-MX<<" "; cout<<endl;
        }
    }

    for (int i=0; i<MX; i++) {
        if (pos[n][m][MX + i] || pos[n][m][MX - i]) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 22400
<?php
    $slime_cnt = fgets(STDIN);
    $slimes = str_split(fgets(STDIN));

    $cnt = (int)$slime_cnt;
    for($i=0; $i<=$slime_cnt; $i++){
        if($slimes[$i] == $slimes[$i+1]){
            $cnt = $cnt -1;
        }
    }
    echo $cnt;
?>

Measured memory_bytes: 10872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string S;
	int X;
	int ans = INF;
	cin >> S;
	int len = S.size();
	for (int i = 0;i < len;i++)
		// cout << S[i] <<endl;
	for (int i = 2;i < len;i++){
		X = 100 * int(S[i - 2] - '0') + 10 * int(S[i - 1] - '0') + int(S[i]- '0');
		// cout << X <<endl;
		ans = min(ans,abs(753 - X));
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256