akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char s[100001];
int main(void){
	int n=nextstr(s);
	puts((n%2==0)^(s[0]==s[n-1])?"Second":"First");
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#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
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(n-1,0));
    rep(i,n)rep(j,n-1) {cin>>a[i][j];a[i][j]--;}
    vector<int> now(n,0);
    vector<int> bat(n,false);
    int ans=-1;
    int cnt=1;
    while(cnt){
        cnt=0;
        bat.assign(n,false);
        rep(i,n){
            if(now[i]==n-1) continue;
            int op=a[i][now[i]];
            if(bat[op] || bat[i]) continue;
            if(a[ op ][ now[op] ] != i) continue;
            cnt ++;
            now[i] ++;
            now[op] ++;
            bat[i] =true;
            bat[op]=true;
        }
        ans ++;
    }
    rep(i,n){
        if(now[i]<n-1){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int N,M;
vint G[111111];

const int INF=1001001001;
int dist[111111][3];
signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
	}
	int S,T;
	cin>>S>>T;
	S--;T--;
	fill_n(*dist,111111*3,INF);
	dist[S][0]=0;
	queue<pint>que;
	que.emplace(S,0);
	while(que.size()){
		int v,p;
		tie(v,p)=que.front();
		que.pop();
		for(auto u:G[v]){
			int np=(p+1)%3;
			if(dist[u][np]!=INF)continue;
			dist[u][np]=dist[v][p]+1;
			que.emplace(u,np);
		}
	}

	if(dist[T][0]==INF)cout<<-1<<endl;
	else cout<<dist[T][0]/3<<endl;
	return 0;
}

Measured memory_bytes: 8576
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
    int N,K;cin>>N>>K;
    if(N%K==0){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 55;

int main()
{
	init();
	int n;
	int arr[N];
	ll sum = 0;
	cin >> n;
	lp(i, n)
		cin >> arr[i];
	lp(i, n){
		lpi(j, i+1, n){
			sum += arr[i] * arr[j];
		}
	}
	cout << sum;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    
    ll n;
    cin>>n;
    ll a[n+1],dp[n+1]={0};
    for(int i=1;i<=n;i++)
     cin>>a[i];
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        if(dp[i-1]+abs(a[i]-a[i-1])<dp[i-2]+abs(a[i]-a[i-2]))
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        else dp[i]=dp[i-2]+abs(a[i]-a[i-2]);
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	int cost;
	int manX;
	int manY;
	int cargoX;
	int cargoY;
	Data(int _c,int _mX,int _mY,int _cX,int _cY){
		cost = _c;
		manX = _mX;
		manY = _mY;
		cargoX = _cX;
		cargoY = _cY;
	}

	bool operator>(const Data& d) const{
		return cost > d.cost;
	}
};

int stage[7][7];
int cost[7][7][7][7];

int main(){

	//0: nothing (simply a floor tile)
	//1: a pillar
	//2: the cargo
	//3: the goal
	//4: the warehouseman (Mr. Schwarz)

	int mX;
	int mY;
	int cX;
	int cY;
	int w,h;
	while(~scanf("%d %d",&w,&h)){
		if(w==0 && h==0) break;
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				scanf("%d",&stage[y][x]);
				if(stage[y][x] == 2){
					cX = x;
					cY = y;
					stage[y][x] = 0;
				}
				else if(stage[y][x] == 4){
					mX = x;
					mY = y;
					stage[y][x] = 0;
				}
			}
		}


		memset(cost,INF,sizeof(cost));
		priority_queue<Data,vector<Data>,greater<Data> > que;
		que.push(Data(0,mX,mY,cX,cY));
		cost[mX][mY][cX][cY] = 0;

		int minval = INF;
		while(!que.empty()){
			Data d = que.top();
			que.pop();
			if(stage[d.cargoY][d.cargoX] == 3){
				minval = d.cost;
				break;
			}

			for(int i=0;i<4;i++){
				int dx = d.manX + tx[i];
				int dy = d.manY + ty[i];
				if(dx < 0 || dx >= w || dy < 0 || dy >= h) continue;
				if(stage[dy][dx] == 1) continue;

				if(dx == d.cargoX && dy == d.cargoY){
					int dcx = d.cargoX + tx[i];
					int dcy = d.cargoY + ty[i];
					if(dcx < 0 || dcx >= w || dcy < 0 || dcy >= h) continue;
					if(stage[dcy][dcx] == 1) continue;
					

					if(cost[dx][dy][dcx][dcy] <= d.cost + 1) continue;

					cost[dx][dy][dcx][dcy] = d.cost + 1;
					que.push(Data(d.cost+1,dx,dy,dcx,dcy));
					continue;
				}

				if(cost[dx][dy][d.cargoX][d.cargoY] <= d.cost) continue;
				cost[dx][dy][d.cargoX][d.cargoY] = d.cost;

				que.push(Data(d.cost,dx,dy,d.cargoX,d.cargoY));
			}
		}

		printf("%d\n",minval == INF ? -1 : minval);
	}
}

Measured memory_bytes: 1208
N = int(input())
S = [input() for i in range(N)]

count = 0
appeared = {}
for i in range(N):
    S[i] = "".join(sorted(list(S[i])))
    if S[i] in appeared:
        count += appeared[S[i]]
        appeared[S[i]] += 1
    else:
        appeared[S[i]] = 1
print(int(count))


Measured memory_bytes: 19472
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
    int A,B,C,D,E,K;
    cin >> A >> B >> C >> D >> E >> K;
    if(E-A>K){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
a = int(ns())
b = int(ns())
c = int(ns())
x = int(ns())

count = 0
for ai in range(a+1):
  if 500 * ai > x:
    break
  for bi in range(b+1):
    for ci in range(c+1):
      if 500 * ai + 100 * bi + 50 * ci == x:
        count += 1

print(count)

Measured memory_bytes: 39536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str[] = br.readLine().split("\\s+");
			int array[] = new int[str.length];

			for(int i = 0; i < str.length; i++){
				array[i] = Integer.parseInt(str[i]);
			}

			Dice dice = new Dice();
			dice.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);

			int Q = Integer.parseInt(br.readLine());

			String tmp_str[] = new String[2];
			int top_num,front_num;

			for(int loop = 0; loop < Q; loop++){

				tmp_str = br.readLine().split("\\s+");
				top_num = Integer.parseInt(tmp_str[0]);
				front_num = Integer.parseInt(tmp_str[1]);

				System.out.println(dice.query(top_num, front_num));
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Dice{

	private int number[];
	private int work[];
	private final String order = "NNNNWNNNWNNNENNNENNNWNNN";

	Dice(){
		number = new int[6];
		work = new int[6];
	}


	public void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	public int query(int top_num,int front_num){

		int save_data[] = new int[6];
		for(int i = 0; i < number.length; i++){
			save_data[i] = number[i];
		}

		int ret = -1;

		for(int i = 0; i < order.length(); i++){
			roll(order.charAt(i));
			if(number[0] == top_num && number[1] == front_num){
				ret = number[2];
				break;
			}
		}

		for(int i = 0; i < save_data.length; i++){
			number[i] = save_data[i];
		}

		return ret;
	}

	public int getTop(){
		return number[0];
	}

	public void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}
};



Measured memory_bytes: 24596
#include <cstdio>
#define ll long long
int main(){
	ll n, m;
	scanf("%lld %lld", &n, &m);
	if (n == 1 || m == 1){
		printf("1\n");
	}else{
		printf("%lld\n", (n * m) / 2 + (n * m) % 2);
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>ku(2*n);
	for (int i = 0; i < 2 * n; i++) {
		cin >> ku[i];
	}
	int count = 0;
	sort(ku.begin(), ku.end());
	for (int i = 0; i < n; i++) {
		count += min(ku[2 * i], ku[2 * i + 1]);
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back


const int maxn = 3e5+1;
int sum[maxn];
int n;
const int E = 'E';
int read()
{
  char ch;
  scanf(" %c", &ch);
  return ch == 'E';
}
int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    {
      sum[i] = read() + sum[i-1];
    }
  int ans = sum[n]-sum[1] + (1-1-sum[1-1]);
  for (int i = 1; i <= n; ++i)
    ans = min(ans, sum[n]-sum[i]+(i-1-sum[i-1]));
  printf("%d\n", ans);
}


Measured memory_bytes: 1408
import java.util.Scanner;

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

Scanner sc = new Scanner(System.in);

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

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

}
}


Measured memory_bytes: 26068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    string s;
    cin>>n>>s;
    bool dp1[10]={};
    bool dp2[10][10]={};
    bool dp3[10][10][10]={};
    for(int i=0;i<n;i++){
        int d=s[i]-'0';
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                dp3[j][k][d]|=dp2[j][k];
            }
        }
        for(int j=0;j<10;j++){
            dp2[j][d]|=dp1[j];
        }
        dp1[d]=true;
    }
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                if(dp3[i][j][k]){
                    ++ans;
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}

int main(){
    int i;
    //入力
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        if(b!=c){
            cout<<"Yes"<<endl;
        }else{
        cout<<"No"<<endl;
        }
    }else{
        if(b==c||a==c){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    //処理
    //出力
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))

vector<bool> ERATOSTENES(long long N) {
    vector<bool> array(N + 1, true);
    array[0] = array[1] = false;
    for (int i = 2; i <= N; i++) {
        if (array[i]) for (int j = 2 * i; j <= N; j += i) array[j] = false;
    }
    return array;
}

int main() {

    auto primes = ERATOSTENES(100050);
    vector<bool> goods(100040, false);
    for (int i = 1; i < 100030; i += 2) if (primes[i] && primes[(i + 1) / 2]) goods[i] = true;
    //for (auto x: goods) cout << x << " ";

    vector<int> pSum(100040, 0);
    for (int i = 0; i < 100028; i++) pSum[i + 1] = pSum[i] + goods[i];

    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        long long x, y;
        cin >> x >> y;
        cout << pSum[y+1] - pSum[x-1] <<endl;
    }

    return 0;
}




























Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int mod=1000000007;
int jc[200005]={1},ny[200005]={1};
int n,k; 
int Power(int x,int y,int mod) {
	int ret=1;
	while(y) {
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}
	return ret;
}
int C(int n,int m){
	return 1ll*jc[n]*ny[m]%mod*ny[n-m]%mod;
}
int F(int k){
	for(int i=1;i<=n;i++)jc[i]=1ll*jc[i-1]*i%mod,ny[i]=Power(jc[i],mod-2,mod);
	int ans=1;
	for(int i=1;i<=k;i++)ans=(ans+1ll*C(n,i)*C(n-1,i))%mod;
	return ans;
}
int main(){
	cin>>n>>k;
	if(k>=n-1)k=n-1;
	if(k==1)cout<<1ll*n*(n-1)%mod;
	else cout<<F(k)<<endl;
}

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

int main(void){
  int A, B, M;
  int a_idx, b_idx, c;
  int a_min = 100000, b_min=100000, min;
  scanf("%d%d%d", &A, &B, &M);

  int a[A];
  for(int i=0; i<A; i++) {
     std::cin >> a[i];
     if (a[i] <= a_min) {
       a_min = a[i];
     }
  }

  int b[B];
  for(int i=0; i<B; i++) {
    std::cin >> b[i];
    if (b[i] <= b_min) {
      b_min = b[i];
    }
  }

  min = a_min + b_min;

  for(int j=0; j<M; j++){
    std::cin >> a_idx >> b_idx >> c;
    if(a[a_idx-1] + b[b_idx-1] - c <= min){
      min = a[a_idx-1] + b[b_idx-1] - c;
    }
  }

  cout << min << endl;
  return 0;
}


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

#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    uint64_t A;
    string B;
    cin >> A >> B;

    uint64_t BB = 0;
    BB += (B[0] - '0') * 100;
    if (B.size() >= 3) BB += (B[2] - '0') * 10;
    if (B.size() >= 4) BB += B[3] - '0';

    uint64_t ans = A * BB / 100;

    cout << ans << endl;
}

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

int main(){

int X,N;
cin>>X>>N;
vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin>>p.at(i);
}//標準入力

vector<int> q(102-N);
int qref;
qref=0;
int mark=0;
for (int j = 0; j < 102-N;) {
    mark=0;
    for (int i = 0; i < N; i++) {
        if(p.at(i)==qref){
            mark=1;
            i=N;
        }
    }
    if(mark==0){
        q.at(j)=qref;
        j++;
    }
    qref++;
}//非p列の完成

int keep,end;
end=X;
for (int i = 0; i < 102-N; i++) {
    if(i==0){
        keep=0;
    }
    if(max(q.at(keep)-X,X-q.at(keep))>max(q.at(i)-X,X-q.at(i))){
        keep=i;
        
    }
    end=q.at(keep);
}

cout << end;

}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
    long long int i,MIN,MAX,SUM,N,A[1000000];

    MIN = 1000000;
    MAX = -1000000;
    SUM = 0;

    scanf("%lld",&N);

    for(i = 0; i < N; i++){
        scanf("%lld ",&A[i]);
        if(MIN > A[i])MIN = A[i];
        if(MAX < A[i])MAX = A[i];
        SUM += A[i];
    }

    printf("%lld %lld %lld\n",MIN,MAX,SUM);

return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
int Solve(int ,int);
int n;
int A[100];
int main(){
  int q,i,m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(Solve(0,m))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int Solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = (Solve(i+1,m) || Solve(i+1,m-A[i]));
  return res;
}



Measured memory_bytes: 2104
// AOJ??????????????°??????
// ITP1-1 XCube
// ??\???????????????3?????????????????????

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
	int a;	//??\???
	
	scanf("%d",&a);
	printf("%d\n",a*a*a);

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n, k; cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int cnt = a.size()-1;
  k--;
  cout << (cnt+k-1)/k << '\n';
  return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
P = -1
Q = -1
if N == 1:
	P = 1
elif N == 2:
	P = 0
else:
	P = N - 2
if M == 1:
	Q = 1
elif M == 2:
	Q = 0
else:
	Q = M - 2
print(P*Q)

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
#define INF (1 << 30)
typedef pair<int, int> P;

int s, d, m;           
vector<P> snack[1080];
int w, p, k;
int dp[10800];
int f;

int main(){
	while(~scanf("%d%d%d", &s, &d, &m)){
		int res = 0;
		int ans;
		for(int i = 0;i < s;i++){
			cin >> k;
			snack[i].clear();
			for(int j = 0;j < k;j++){
				cin >> w >> p;
				snack[i].push_back(P(w, p));
			}
		}
		fill(dp, dp + m + 10, -INF);
		dp[0] = 0;
		
		for(int i = 0;i < d;i++){
			cin >> f;
			for(int j = 0;j < snack[f].size();j++){
				w = snack[f][j].first;
				p = snack[f][j].second;				
				for(int k = m;k - p >= 0;k--){
					dp[k] = max(dp[k], dp[k-p] + w);
					res = max(res, dp[k]);
				}
			}
		}
		for(int i = m;i >= 0;i--){
			if(dp[i] == res)ans = i;
		}
		cout << res << " " << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1336
program arc066c
    use,intrinsic :: iso_fortran_env
    implicit none
        integer(int64):: n,i
        integer(int64), allocatable:: a(:), cnt(:), cnt_pred(:)

        read*, n
        allocate(a(n))
        allocate(cnt(0:n), cnt_pred(0:n), source=0_8)
        read*, a(:)

        if (mod(n,2_8) == 0) then
            cnt_pred(1:n:2) = 2
        else
            cnt_pred(0) = 1
            cnt_pred(2:n:2) = 2
        end if

        do i=1,n
            cnt(a(i))=cnt(a(i))+1
        end do

        do i=1,n
            if (cnt(i) /= cnt_pred(i)) then
                print'(i0)', 0
                stop
            end if
        end do

        print'(i0)', iterative_square(2_8,n/2,10**9+7_8)

contains
function iterative_square(a,n,md) result(ret)
    use,intrinsic :: iso_fortran_env
    integer(int64):: a,n,i,md,mul
    integer(int64):: ret

    ret = 1
    mul = a
    do i=1,bit_size(n)
        if (btest(n,i-1)) ret = mod(ret*mul,md)
        mul=mod(mul*mul,md)
    end do
end function
end program arc066c

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    double h = (double)H*30.0+30.0*M/60.0;
    double m = M*6;
    double si = max(h,m) - min(h,m);
    double ans = (double)A*A + B*B - 2.0*A*B*cos(PI*si/180.0);
    cout << fixed << setprecision(20) << sqrt(ans) << enld;
    return 0;
}


Measured memory_bytes: 4216
while(h,w=gets.split.map &:to_i)[0]>0
a=[]
b=[s=0]*w
h.times{|i|gets;a[i]=[]
w.times{|j|a[i]<<l=$_[j]<?.?0:(a[i][-1]||0)+1
m=b[j]+=l>0?1:0
l*m>s&&(1..m).each{|k|l>(t=a[i-k+1][j])&&l=t;l*m<s ?(break):s<l*k&&s=l*k}}}
p s
end

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

int N,A[200000],B[200000];

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N;i++){
		cin>>B[i];
	}
	reverse(B,B+N);
	int f=0;
	int b=N-1;
	for(int i=0;i<N;i++){
		if(A[i]==B[i]){
			if(B[f]!=A[i]&&A[f]!=B[i]){
				swap(B[f],B[i]);
				f++;
			}
			else{
				swap(B[b],B[i]);
				b--;
			}
		}
	}
	for(int i=0;i<N;i++){
		if(A[i]==B[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<N;i++){
		cout<<B[i];
		if(i!=N-1)cout<<' ';
	}
	cout<<endl;
}



Measured memory_bytes: 5192
#include<cstdio>
#include<cctype>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
int main(){
	char ch[15]={0}; scanf("%s",ch);
	if (ch[0]=='Y'&&ch[1]=='A'&&ch[2]=='K'&&ch[3]=='I') printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
import math
a = raw_input()
for i, b in enumerate(a.split()):
    if i==0:
        W=int(b)
    elif i==1:
        H=int(b)
    elif i==2:
        x=int(b)
    elif i==3:
        y=int(b)
    else:
        r=int(b)
if r<=x<=W-r and r<=y<=H-r:
    print 'Yes'
else:
    print 'No'

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b;
  cin >> a>>b;
  if(a*500 >= b) cout << "Yes" <<endl;
  else cout << "No" <<endl;
	return 0;
}


Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
int a,b,c;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    for (int i = 0; i < 5; ++i){
        int x;
        cin>>x;
        if (x==0){
            cout<<(i+1)<<"\n";
            return 0;
        }
    }

    return 0;
}






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

using namespace std;


template< typename T >
struct edge
{
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using Graph = vector< Edges< T > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
vector< T > dijkstra(Graph< T > &g, int s)
{
  const auto INF = numeric_limits< T >::max();
  vector< T > dist;
  dist.assign(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main()
{
  int V, E, S;
  scanf("%d %d %d", &V, &E, &S);
  Graph< int > g(V);
  for(int i = 0; i < E; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    g[x].emplace_back(y, z);
  }
  auto cost = dijkstra(g, S);
  for(int i = 0; i < V; i++) {
    if(cost[i] == numeric_limits< int >::max()) puts("INF");
    else printf("%d\n", cost[i]);
  }
}


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

class Magatro
{
    static void Main()
    {
        new Magatro().Solve();
    }
    
    public void Solve()
    {
        var s=Console.ReadLine();
        for(int i=0;i<s.Length;i+=2)
        {
            Console.Write(s[i]);
        }
        Console.WriteLine();
    }
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int max_num = max(max(A, B), C);
  int remaining = (A + B + C) - max_num;
  int diff_num = (max_num * 2) - remaining;

  int ans = 0;
  // 差が偶数の場合
  if (diff_num % 2 == 0) {
    ans = diff_num / 2;
  // 差が奇数の場合
  } else {
    max_num += 2;
    remaining += 1;
    diff_num = (max_num * 2) - remaining;
    ans = diff_num / 2;
  }

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


Measured memory_bytes: 3612
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	for i := 0; ; i++ {
		if math.Pow(float64(k), float64(i)) > float64(n) {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 512
def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = a[0]*b[1] - a[1]*b[0]
    if crs < 0 :
        return False
    else :
        return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) :
                break
            else :
                del phU[-2]
                if len(phU) == 2 :
                    break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) :
                break
            else :
                del phL[-2]
                if len(phL) == 2 :
                    break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33908
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

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

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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 <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n>>m;
	int a=max(n,m),b=min(n,m);int r = a%b;
	while(r!=0){
		a=b;b=r;r=a%b;
	}
	cout << (ll)n*m/b<<endl;
	return 0;
}


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

int main() {
	int n, k; cin >> n >> k;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	int cnt = 0; n--; k--;
	while (n > 0) {
		n -= k; cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
        long accum = 0;
        int res = 0;
        for (int i = 0; i < a.Length - 1; i++)
        {
            accum += a[i];
            if (a[i + 1] <= accum * 2) res++;
            else res = 0;
        }
        Console.WriteLine(res + 1);
    }
}


Measured memory_bytes: 30428
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
  stack<int> S;
  int a, b, c;
  string s;
  while (cin>>s) {
    if (s[0]=='+') {
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(a+b);
    } else if (s[0]=='-') {
      b=S.top();
      S.pop();
      a=S.top();
      S.pop();
      S.push(a-b);
    } else if (s[0]=='*') {
      a=S.top();
      S.pop();
      b=S.top();
      S.pop();
      S.push(a*b);
    } else {
      S.push(atoi(s.c_str()));
    }
  }
  cout<<S.top()<<endl;
  return 0;
}




Measured memory_bytes: 3172
#include <iostream>

using namespace std;

int main() {
   string s;
   cin >> s;
   
   if(s == "Sunny")
        cout << "Cloudy";
        
    else if (s == "Cloudy")
        cout << "Rainy";
        
    else
        cout << "Sunny";
   
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func count(n, k int) int64 {
	var ans int64
	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			for l := 1; l <= n; l++ {
				p, q, r := i+j, j+l, l+i
				if p%k == 0 && q%k == 0 && r%k == 0 {
					ans++
				}
			}
		}
	}
	return ans
}

func calc(n, k int) int64 {
	var ans, m int64
	if k > 2*n {
		return 0
	}
	if k%2 == 0 {
		x := n - k/2
		m = int64(x/k + 1)
		ans += m * m * m
	}
	m = int64(n / k)
	ans += m * m * m
	return ans
}

func main0() {
	defer stdout.Flush()
	for n := 1; n < 100; n++ {
		for k := 1; k < 100; k++ {
			if calc(n, k) != count(n, k) {
				eprintln(n, k)
			}

		}
	}
}

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	k := readInt()

	println(calc(n, k))
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
require 'prime'
q = gets.chomp.to_i
arr = []
l_min, r_max = 100001, 0
q.times do
  l, r = gets.chomp.split(' ').map(&:to_i)
  arr << [l, r]
  l_min = [l_min, l].min
  r_max = [r_max, r].max
end
sums = Array.new((r_max - l_min) + 1, 0)
sums[0] = l_min.prime? && ((l_min + 1) / 2).prime? ? 1 : 0
((l_min + 1)..r_max).each do |i|
  index = i - l_min
  if i.prime? && ((i + 1) / 2).prime?
    sums[index] = sums[index - 1] + 1
  else
    sums[index] = sums[index - 1]
  end
end
sums.unshift(0)
arr.each do |i|
  first = i[0] - l_min
  last = i[1] - l_min + 1
  puts sums[last] - sums[first]
end

Measured memory_bytes: 12924
function main(input) {
  var source = input[0];
  var target = input[1];
  
  var flag = false;
  for (var i = 0; i < source.length; i++) {
    var source = shift(source);
    if (source === target) {
      flag = true;
      break;
    }
  }

  console.log(flag ? 'Yes' : 'No');
}

const shift = (str) => {
  if (str.length === 0) {
    return "";
  }

  const tailHead = str.substr(-1);
  const heads = str.substr(0, str.length-1);

  return tailHead + heads;
};

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n'));


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

int main(){
   int n;
   cin >> n;
   vector<int> a(n);
   for(int i = 0; i < n; i++){
      cin >> a[i];
   }
   sort(a.rbegin(), a.rend());
   ll ans = 0;
   int t = n - 1;
   for(int i = 0; i < n; i++){
      int lim = 2;
      if(i== 0) lim = 1;
      for(int j = 0; j < lim; j++){
         if(t > 0){
            ans += a[i];
            t--;
         }
      }
   }

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

Measured memory_bytes: 4032
#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

queue<string> q;
map<string, int> m;
const int d[] = {1, -1, 4, -4};

void solve(){
	m["01234567"] = 1;
	q.push("01234567");
	while(!q.empty()){
		int t = 0;
		string res = q.front();
		q.pop();
		for(int i = 0; i < res.length(); i++)
			if(res[i] == '0') t = i;
		for(int i = 0; i < 4; i++){
			if(0 <= t + d[i] && t + d[i] < 8 &&
            !(t == 3 && i == 0) && !(t == 4 && i == 1)){
            	string u = res;
            	swap(u[t], u[t + d[i]]);
            	if(m[u] == 0){
            		q.push(u);
            		m[u] = m[res] + 1;
				}
			}
		}
	}	
}
int main(){
	solve();
	while(1){
		int k;
		string s;
		for(int i = 0 ;i < 8; i++){
			if(!(cin >> k)) return 0;
			s = s + char(k + '0');
		}
		cout << m[s] - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

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

    ll ans = 1;
    int Num[26]={};

    // aからzまでの文字の個数を数えるコード
    for(int i=0; i<N; i++){
        Num[S[i]-'a']++;
    }

    // range-based for loops
    for(int x : Num){
        ans *= x + 1;
        ans %= mod;
    }

    cout << ans-1;
    return 0;
}

Measured memory_bytes: 512
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

using namespace std;

int n;
int a[N];
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i];
		a[i] -= i;
	}
	sort (a + 1, a + 1 + n);
	ll m = (a[(n + 1) / 2]), ans = 0;
	rep(i, 1, n) ans += abs(a[i] - m);
	cout << ans;
	ioi
}


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

typedef long long ll;

const int MAX_N = 100000;
int p[MAX_N + 10];
int n, t;
ll ans;

int find(int a) {
    return p[a] == a ? a : find(p[a]);
}

void unite(int a, int b) {
    int pa = find(a), pb = find(b);
    if(pa != pb) p[pa] = pb;
}

int main() {
    while(scanf("%d%d", &n, &t) && n && t) {
        for(int i = 1; i < n; i++) {
            scanf("%d", &p[i+1]);
        }
        p[1] = 1;
        char op[3];
        int id;
        ans = 0;
        while(t--) {
            scanf("%s%d", op, &id);
            if(op[0] == 'M') {
                p[id] = id;
            } else {
                ans += (ll)find(id);
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3604
import bisect
from collections import deque
n = int(input())
c = deque()
for i in range(n):
    a = int(input())
    idx = bisect.bisect_left(c,a)
    if idx == 0:
        c.appendleft(a)
    else:
        c[idx-1] = a
print(len(c))

Measured memory_bytes: 7284
#include<stdio.h>
int main(void)
{
int A, B, C ,D;

scanf("%d %d %d %d", &A, &B, &C, &D);
int X = A * B;
int Y = C * D;
  if(X > Y){
    printf("%d", X);
  } else if(X < Y){
    printf("%d", Y);
  } else if(X == Y){
    printf("%d", X);
  }
  return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    S = readline() |> split |> parseMap
    H,W,A,B = S
    for i in 1:H
        if i <= B
            println("1"^A * "0"^(W-A))
        else
            println("0"^A * "1"^(W-A))
        end
    end
end

main()


Measured memory_bytes: 170800
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int size;
  cin >> size;
  vector<int> arr(size);
  for(int i = 0; i < size; i++){
    cin >> arr[i]; 
  }

  int res = 0;
  for(int i = 0; i < size; i++){
    if(arr[i] > 0 && arr[i] <= size && i + 1 == arr[arr[i] - 1]){
      res++;
      arr[i] = 0;
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 100001

int a[N];

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

int main()
{		
	int n, i, m = 0, t, c1 = 0, c2;
	
	n = read();
	for(i = 0; i < n; i++){
		a[i] = t = read();
		if(t > m) m = t;
	}
	for(i = 0; i < n; i++){
		t = a[i];
		if(t + 1 == m) c1++;
		else if(t != m){
			puts("No");
			return 0;
		}
	}
	if(!c1){
		if(m + 1 == n || m * 2 <= n) puts("Yes");
		else puts("No");
		return 0; 
	}
	c2 = n - c1;
	if(m <= c1 || c2 < (t = (m - c1) * 2) || t + c1 > n) puts("No");
	else puts("Yes");
	
			
	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    var n= readLine()!!.toInt()
    var ans=0
    for (i in 1..n){
        var tmp=0
        if (i%2==1) {
            for (j in 1..i) {
                if (i % j == 0) {
                    tmp++
                }
            }
        }
        if (tmp==8){
            ans++
        }
    }
    println(ans)
}

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

int main(){
    unsigned long long int X;
    cin >> X;
    unsigned long long int x=100;
    unsigned long long int ans=0;
    while(x < X){
        x += x/100;
        //x = floor(x);
        //cout << x << endl;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
typedef long long ll;
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin>>n>>k;
  ll a[n],ans=0;
  for(int i=0;i<n;i++)
  {
      cin>>a[i];

  }
  sort(a,a+n);
  for(int i=0;i<k;i++)
    ans=ans+a[i];
cout<<ans<<endl;
 return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(M);
  
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }
  
  int sum = std::accumulate(A.begin(), A.end(), 0 );
  if (N >= sum) {
    cout << N - sum << endl;
  }
  
  else {
    cout << "-1" << endl;
  }
  
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <cstdio>
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define nln cout << '\n'
#define ll long long int
#define INF (ll)1e+12
#define MAX 300100
#define mp(i, j) make_pair(i, j)
#define here cout  << "here";nln;
#define mul(a, b, mod) (((a % mod) * (b % mod)) % mod)
#define add(a, b, mod) (((a % mod) + (b % mod)) % mod)
#define inf 100000
#define M 1000000000LL

using namespace std;

ll a[300100];

int main()
{
    ll n, i, ans = 0;

    cin >> n;

    for(i = 0; i < 3*n; i++)cin >> a[i];

    sort(a, a+3*n);

    for(i = n; i < 3*n; i+= 2){
        ans += a[i];
    }

    cout << ans << endl;
}


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

int n;
int c[25], v[25];
int main(){
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		if (c[i] < v[i]) {
			ans += v[i] - c[i];
		}
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
N, K  = map(int, input().split())
ans = 0
num = 0
S = input()
a = S.split('1')
b = S.split('0')
ls = []
for x in a:
    if len(x) != 0:
        ls.append(len(x))
c = [0] + list(accumulate(ls))
ls_ = []
for x in b:
    if len(x) != 0:
        ls_.append(len(x))
d = [0] + list(accumulate(ls_))

if len(c)-1 <= K:
    print(N)
    sys.exit()

if len(c) == len(d):
    if S[0] == '0':
        d = [0] + d
        for x, y, u, t in zip(c, c[K:], d, d[K+1:]):
            ans = max(ans, y-x+t-u)
        print(ans)
    elif S[0] == '1':
        r = d[-1]
        d.append(r)
        for x, y, u, t in zip(c, c[K:], d, d[K+1:]):
            ans = max(ans, y-x+t-u)
        print(ans)
elif len(c) == len(d)+1:
    r = d[-1]
    d.append(r)
    d = [0] + d
    for x, y, u, t in zip(c, c[K:], d, d[K+1:]):
        ans = max(ans, y-x+t-u)
    print(ans)
elif len(c) == len(d)-1:
    for x, y, u, t in zip(c, c[K:], d, d[K+1:]):
        ans = max(ans, y-x+t-u)
    print(ans)

Measured memory_bytes: 9452