akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

long long H, W, K;
string S[15];

int main(){
	cin >> H >> W >> K;
	for(long long i = 0; i < H; i++) {
		cin >> S[i];
	}

	long long ans = LONG_MAX;
	for(long long hset = 0; hset < (1<<H); hset++) {
		//    hidx   , blockid
		map<long long, long long> toBlock;
		long long blockid = 0;
		for(long long i = 0; i < H; i++) {
			toBlock[i] = blockid;
			if((hset>>i) & 1) {
				blockid++;
			}
		}
		long long hnum = blockid;

		//for(auto item: toBlock) {
		//	cout << item.first << " -> " << item.second << endl;
		//}


		//blockid -> num
		map<long long, long long> blocknum;
		set<long long> wset;
		bool skip = false;

		for(long long w = 0; w < W; w++) {
			bool ng = false;
			for(long long h = 0; h < H; h++) {
				if(S[h][w] == '1') {
					blocknum[toBlock[h]]++;
					if(blocknum[toBlock[h]] > K) {
						ng = true;
					}
				}
			}
			if(ng) {
				if(w == 0 || wset.count(w-1) > 0) {
					skip = true;
					break;
				}
				wset.insert(w-1);
				blocknum.clear();
				w--;
				ng = false;
			}

		}
		if(!skip) {
			//cout << "ok" << endl;
			ans = min(ans, hnum + (long long)wset.size());
		} else {
			//cout << "ng" << endl;
		}
		//for(auto w: wset) {
		//	cout << "w = " << w << endl;
		//}
	
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
long long int x;cin>>x;
long long int y=0;
y=y+(x/500)*1000;
x=x-((x/500)*500);
y=y+(x/5)*5;
  
cout<<y<<"\n";  


  
  
 return 0;} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INFTY 1000000001

void merge(int[], int, int, int);
void mergeSort(int[], int, int);

int count=0;

int main()
{
  int n,i;
  int left,right,mid;
  int A[500000];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  left = 0;
  mid = i/2;
  right = i;

  mergeSort(A,left,right);
  
  for(i=0; i<n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[i],count);
  

  return 0;
}

void merge(int A[], int left, int mid, int right)
{
  int n1, n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;

  int L[n1];
  int R[n2];

  for(i=0; i<n1; i++)
    L[i] = A[left+i];

  for(i=0; i<n2; i++)
    R[i] = A[mid+i];

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      count++;
      A[k] = L[i];
      i += 1;
    }
    else {
      count++;
      A[k] = R[j];
      j += 1;
    }
  }
}

void mergeSort(int A[], int left, int right)
{
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 6468
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b, a%b);
}
signed main(){
    int n,k; cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    sort(all(a));
    if(a.back()<k){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    int t=gcd(a.front(),a.back());
    rep(i,n){
        t=gcd(a.at(i),t);
    }
    cout<<(k%t==0?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 1024
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	s := nextString()

	cnt := len(s)
	cnt = calc(cnt, s, 'A')

	s = reversed(s)
	cnt = calc(cnt, s, 'Z')
	fmt.Println(cnt)
}

func reversed(s string) string {
	r := make([]rune, len(s))
	j := 0
	for i := len(s) - 1; i >= 0; i-- {
		r[j] = rune(s[i])
		j++
	}
	return string(r)
}

func calc(cnt int, s string, c rune) int {
	for i := 0; rune(s[i]) != c || cnt < 0; i++ {
		cnt--
	}
	return cnt
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

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() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 2304
N,M=map(int,input().split())
A=[1 for _ in range(N)]
#Aはボールの個数
B=[0 for _ in range(N)]
#Bは箱に赤いボールが入っているか
ans=0
B[0]=1
for i in range(M):
  x,y=map(int,input().split())
  x-=1
  y-=1
  #インデックス値用
  if B[x]==1 and A[x]>=2:
    A[x]-=1
    A[y]+=1
    B[y]=1
  #取ってきた箱に赤が入っていて個数が二個以上
  #取ってきた箱にまだ赤が残る事がある
  elif B[x]==1 and A[x]==1:
    A[x]-=1
    A[y]+=1
    B[x]=0
    B[y]=1
  #取ってきた箱に赤が入っていて個数は一個
  #赤いボールは絶対に取り出される
  else:
    A[x]-=1
    A[y]+=1
  #白いボールの箱だけでのやり取りの時は個数の変化のみ
print(B.count(1))

Measured memory_bytes: 4784
N = int(input())
rate = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
p = [0] * 9

A = [int(a) for a in input().split(" ")]
A.sort()

j = 0
for i in range(len(A)):
  while j < 8:
    if rate[j] <= A[i] < rate[j + 1]:
      p[j] = 1
      break
    else:
      j += 1
  else:
    p[8] = len(A[i:])
    break

print(str(max([sum(p[:8]), 1])) + " " + str(sum(p)))
      

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

char a[1005][1005];
long long MOD=1000000007;
long long dp[1005][1005];

int h,w;

int main()

{
	
	cin>>h>>w;
	
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		cin>>a[i][j];
	}
	
	for(int i=h;i>0;i--)
	{
		for(int j=w;j>0;j--)
		{
			if(i == h && j == w)
			dp[i][j] = 1;
			
			else if(a[i][j] == '#')
			dp[i][j] = 0;
			
			else if(a[i][j] == '.')
			{
				if(i == h)
				dp[i][j] = dp[i][j+1];
				else if(j == w)
				dp[i][j] = dp[i+1][j];	
				else
				dp[i][j] = dp[i+1][j] + dp[i][j+1];	
			}
			
			
			dp[i][j] = dp[i][j] % MOD;
		}	
	}
	
	cout<<dp[1][1] % MOD;
	
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
template<class T> ostream& operator<<(ostream &o, const set<T> &v){o<<"[";for(auto t:v){o<<t<<",";}o<<"]";return o;}
template<class T,class U> ostream& operator<<(ostream &o, const map<T,U> &v){o<<"[";for(auto t:v){o<<t<<",";}o<<"]";return o;}

int rt[700*700];

void dfs(int v, const vector<vector<int>> &g, vector<bool> &c, vector<bool> &visited){
  visited[v] = true;
  for(auto to : g[v]) if(!visited[to]){
    c[to] = !c[v];
    dfs(to,g,c,visited);
  }
}

int main(){
  fill(rt, rt+650*650, -1);
  rep(i,605) rt[i*i] = i;
  int n,d[2];
  cin>>n>>d[0]>>d[1];

  vector<int> col(4*n*n,0);
  rep(k,2){
    vector<vector<int>> g(4*n*n);
    rep(i,2*n) rep(j,2*n){
      rep(ii,2*n){
        int di = abs(i - ii);
        int dj = d[k] - di*di;
        if(dj < 0 || rt[dj]==-1 || dj >= 601*601) continue;
        dj = rt[dj];
        int si = i*2*n + j;
        int ti = ii*2*n + j+dj;
        if(j+dj < 2*n) g[si].pb(ti);
        ti = ii*2*n + (j-dj);
        if(j-dj >= 0) g[si].pb(ti);
      }
    }
    vector<bool> c(4*n*n);
    vector<bool> visited(4*n*n, false);
    rep(i,4*n*n) if(!visited[i]){
      c[i] = true;
      dfs(i, g, c, visited);
    }

    rep(i,4*n*n) col[i] |= c[i]<<k;
  }

  vector<vector<int>> res(4);
  rep(i,4*n*n) res[col[i]].pb(i);

  int u = 0;
  rep(i,4) if(res[i].size() > res[u].size()) u = i;

  assert(res[u].size() >= n*n);

  rep(i,n*n) cout << res[u][i] % (2*n) << " " << res[u][i] / (2*n) << "\n";

  return 0;
}


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

using namespace std;

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

#define F first
#define S second

const int MAXN = 600 + 10;
const int MAXVAL = 1e6 + 10;

int n, d1, d2, sv[MAXVAL];
vector<pii> adj[MAXN][MAXN];
int col[2][MAXN][MAXN];

int distance(pii a, pii b){return (a.F-b.F)*(a.F-b.F) + (a.S-b.S)*(a.S-b.S);}

bool fit(int x, int y){return 0 <= x && x < 2*n && 0 <= y && y < 2*n;}

void addEdge(int x, int y, int xx, int yy){
	adj[x][y].push_back({xx, yy});
	adj[xx][yy].push_back({x, y});
}

int cnt[4], good=0;
void addEdges(int d){
	for (int i = 0; i < 2*n; i++)
		for (int j = 0; j < 2*n; j++)
			adj[i][j].clear();

	for (int i = 0; i < 2*n; i++)
		for (int j = 0; j < 2*n; j++)
			if (col[0][i][j] == good)
				for (int disX = 0; j - disX >= 0 || j+disX < 2*n; disX++){
					int rem = d - disX*disX;
					if (rem < 0 || sv[rem]==-1) continue;
					for (int ii = -1; ii <= 1; ii++)
						if (ii)
							for (int jj = -1; jj <= 1; jj++)
								if (jj) {
									pii u(i+sv[rem]*ii, j+disX*jj);
									if (!fit(u.F, u.S) || col[0][u.F][u.S] != good) continue;
									addEdge(i, j, i+sv[rem]*ii, j+disX*jj);
								}
				}
}

void dfs(int x, int y, int t, int c){
	if (col[t][x][y]) return;
	col[t][x][y] = c;
	cnt[c]++;
	for (auto u:adj[x][y])
		dfs(u.F, u.S, t, 3-c);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> d1 >> d2;
	memset(sv, -1, sizeof(sv));
	for (int i = 0; i*i < MAXVAL; i++) sv[i*i] = i;

	addEdges(d1);
	for (int i = 0; i < 2*n; i++)
		for (int j = 0; j < 2*n; j++)
			if (!col[0][i][j])
				dfs(i, j, 0, 2);
	if (cnt[1]>cnt[2])
		good = 1;
	else
		good = 2;

	addEdges(d2);
	cnt[1] = cnt[2] = 0;
	for (int i = 0; i < 2*n; i++)
		for (int j = 0; j < 2*n; j++)
			if (col[0][i][j] == good && !col[1][i][j])
				dfs(i, j, 1, 2);
	if (cnt[1]>cnt[2])
		good = 1;
	else
		good = 2;

	int rem = n*n;
	for (int i = 0; i < 2*n; i++)
		for (int j = 0; rem && j < 2*n; j++)
			if (col[1][i][j] == good) {
				rem--;
				cout << i << " " << j << "\n";
			}
	return 0;
}


Measured memory_bytes: 211328
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



int main() {
	int s;
	cin >> s;
	vector<bool> x(1000001);
	int a = s;
	x[a] = true;
	FOR(i, 2, 1000001) {
		if (a % 2 == 0) {
			a = a / 2;
		}
		else {
			a = a * 3+1;
		}
		if (x[a] == true) {
			cout << i << endl;
			return 0;
		}
		else {
			x[a] = true;
		}
	}
}




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


int main()
{
    map<int, int> cnt;
    int n;
    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;

    for ( auto u : cnt ) {
        if ( u.second >= u.first ) ans += ( u.second - u.first );
        else ans += u.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8116
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
int popcount(int x) {
	int ans=0;
	int tmp;
	while (x != 0) {
		tmp = x >> 2;
			tmp = tmp << 1;
			if (tmp == x) {
				ans++;
			}
			x >> 1;
	}
	return ans;

}
int main() {
	ll a, b;
	cin >> a >> b;
	ll ans = 1;
	ll count=0;
	while (ans < b) {

		ans += a-1;

		count++;
	}
	cout << count;
}
	


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;++i){
		cin>>arr[i];
	}
	ll maxl=1,curr=1;
	for(ll i=1;i<n;++i){
		if(arr[i-1]>=arr[i])
			curr++;
		else
			curr=1;
		maxl=max(curr,maxl);
	}
	cout<<maxl-1<<endl;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>x(n);
    ll ans=INF;
    rep(i,0,n){
        cin>>x.at(i);
    }
    rep(i,0,n-k+1){
        ans=min(ans,abs(x.at(i))+abs(x.at(i)-x.at(i+k-1)));
    }
    for(int i=n-1;i>=k-1;i--){
        ans=min(ans,abs(x.at(i))+abs(x.at(i)-x.at(i-k+1)));
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

bool is_prime(int k)
{
    for(int j=2;j*j<=k;j++){
        if(k%j==0) {
            return false;
        }
    }
    return true;
}

int main()
{
	stringstream ss;
    // 入力
    int T,X;
    cin>>T>>X;
    double ans=(double)T/X;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 300010;
int n, a[maxn];
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	read(n, a+1);
	int p = max_element(a+1, a+1+n) - a, j = 0;
	for(int i = 1;i <= n;++i){
		j = min(a[p]-a[i], a[i]) >= min(a[p]-a[j], a[j]) ? i : j;
	}
	cout << a[p] << ' ' << a[j] << '\n';
}

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

int counter;
vector<int> check(1000000,0);

int collatz(int n){
  counter ++;
  if (check[n-1] == 1) return counter;
  check[n-1] = 1;
  if (n%2 == 0) return collatz(n/2);
  else return collatz(3*n+1);
}

int main(){
  int s;
  cin >>s;
  counter = 0;
  cout << collatz(s) << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first 
#define s second 
using namespace std;
const int mod=1e9+7;
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
bool isprime(int n){ if(n==1) return false; for(int i=2;i<=sqrt(n);i++)	if(n%i==0) return false; return true;}

/*

*/



int solve()
{
	char c;
	cin>>c;
	if(c>='A'&&c<='Z') cout<<'A';
	else cout<<'a';
	return 0;
}

int32_t main()																																	
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


int main()
{
    int N, M, C;
    int A[30], B[30];
    cin >> N >> M >> C;
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++)
    {
        int t = C;
        for (int j = 0; j < M; j++)
        {
            cin >> A[j];
            t += A[j] * B[j];
        }
        if(t > 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  string S,T;
  cin>>S;
  cin>>T;

  int ans=0;
  for(int i=0;i<3;i++){
    if(S[i]==T[i]) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	int[] a;

	public long calc(int mode){
		long sum = 0;
		long cnt = 0;
		for (int i = 0; i < N; i++) {
			sum += a[i];
			if (i % 2 == mode) {
				if (sum <= 0) {
					cnt += 1 - sum;
					sum = 1;
				}
			} else {
				if (sum >= 0) {
					cnt += 1 + sum;
					sum = -1;
				}
			}
		}

		return cnt;
	}

	public void solve() {
		N = nextInt();
		a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = nextInt();
		}

		long ans = Math.min(calc(0),calc(1));
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 37128
function Main(arg) {
  var S = arg.split("\n")[0];

  var a = S.slice(0, (S.length - 1) / 2);
  var b = S.slice(((S.length + 3) / 2)-1).split("").reverse().join("");
  
  if (a !== b) {
    console.log("No");
    return;
  }

  if (a.length % 2 == 0) {
    var c = a.slice(0, (a.length) / 2);
    var d = a.slice(((a.length + 2) / 2)-1).split("").reverse().join("");
  }
  else {
    var c = a.slice(0, (a.length - 1) / 2);
    var d = a.slice(((a.length + 3) / 2)-1).split("").reverse().join("");    
  }
  
  if (c !== d) {
    console.log("No");
    return;
  }

  if (a !== b) {
    console.log("No");
    return;
  }
  
  console.log("Yes");
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import Data.Char
import Data.List

main = do
  input <- map digitToInt <$> getLine
  let f = [(+), (-)]
      func = [[a, b, c] | a <- f, b <- f, c <- f]
      fS = ["+", "-"]
      funcS = [[a, b, c] | a <- fS, b <- fS, c <- fS]
      n = map show input
  putStrLn $ (\x -> toString n (funcS !! x)) . head . elemIndices 7 . map (solve input) $ func

solve :: [Int] -> [Int -> Int -> Int] -> Int
solve (n:ns) [] = n
solve (n:m:ms) (f:fs) = solve ((f n m):ms) fs

toString :: [String] -> [String] -> String
toString n f = (n!!0) ++ (f!!0) ++ (n!!1) ++ (f!!1) ++ (n!!2) ++ (f!!2) ++ (n!!3) ++ "=7"


Measured memory_bytes: 380
#include <cstdio>
#include <cmath>
using namespace std;

#define sq(a) (a*a)

int main() {
  
  double x, h;

  while(scanf("%lf\n%lf", &x, &h) == 2 && x+h) {
    printf("%.6lf\n", sq(x)+ x * ( sqrt(sq(x/2)+sq(h)) ) * 2 );
  }
  
  return 0;
}

Measured memory_bytes: 1076
L,R=map(int,input().split())

Lw=L//2019
Rw=R//2019

if Lw < Rw :
    print(0)
else:
    ans=2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans= min(ans,i*j % 2019)
    print(ans)
    

Measured memory_bytes: 2940
#[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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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! {
        mut v: [i64; 3],
    }
    v.sort();
    let ans = v[2] * 10 + v[1] + v[0];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stack>

using namespace std;


int main(){
	stack<int> stk;
	int c;
	while (cin >> c){
		if (c == 0){
			cout << stk.top() << endl;
			stk.pop();
		}
		else{
			stk.push(c);
		}
	}
	return 0;

}

Measured memory_bytes: 1196
using System;

namespace Watch
{
    class Watch
    {
        static void Main()
        {
            int input = int.Parse(Console.ReadLine());
            int s = (input % 60) % 60;
            int m = input / 60;
            int h = m / 60;
            m = m % 60;
            Console.WriteLine(h + ":" + m + ":" + s);
            //Console.ReadKey();
        }
    }
}



Measured memory_bytes: 17944
def match(s,t):
  for i in range(m):
    if s[i]==t[i] or s[i]=='?':
      continue
    return False
  return True
s = list(input())
t = list(input())
n = len(s)
m = len(t)
i = n-m
found = False
while i >= 0:
  if match(s[i:i+m],t):
    found = True
    for j in range(i,i+m):
      s[j] = t[j-i]
    break
  i-=1
if found:
  for i in s:
    if i=='?':
      print('a',end='')
    else:
      print(i,end='')
  print()
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>


using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i- h*3600) / 60;
   s = i - h*3600 - m * 60;
   cout << h <<":" << m <<":" << s << endl; 
    
   return 0;
}


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

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

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> p(n);
	rep (i, 0, n)
		cin >> p[i];

	int max_v = *max_element(p.begin(), p.end());
	int sum = 0;
	for (int tmp : p)
		sum += tmp;

	cout << sum - (max_v / 2) << endl;

	return 0;
}


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

int *s;
int *t;
int n, q;

void solve(){
  int count = 0;
  for(int i = 0; i < q; i++){
    for(int j = 0; j < n; j++){
      if(s[j] == t[i]){
        count++;
        break;
      }
    }
  }
  cout << count << endl;
  return ;
}


int main(){
  cin >> n;
  s = new int[n];
  for(int i = 0; i < n; i++) cin >> s[i];
  cin >> q;
  t = new int[q];
  for(int i = 0; i < n; i++) cin >> t[i];
  solve();
  return 0;
}

Measured memory_bytes: 3132
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
reader.on('close', () => {
    // ここで出力する
    var n = Number(lines[0]);
    console.log((n + (n % 2)) / (2 * n));
    //for(var i =0; i<lines.length; i++){
    //  console.log(lines[i]);
    //}
});

Measured memory_bytes: 7628
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int n;
	ll m = 0;

	cin >> n;

	vector<ll> a(n+5);

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n/i;j++) {
			a[j*i]++;
		}
	}

	for (int i = 1; i <= n; i++) {
	//	cout << a[i] << endl;
		m += i*a[i];
	}

	cout << m << endl;

	return 0;
}

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

ll expo ( ll a, ll b ) {
    ll ret = 1;
    while(1) {
        if ( b == 0 ) break;
        if ( b % 2 == 1 ) {
            ret = ret * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

ll inv ( ll a ) {
    return expo(a, mod-2);
}

ll factorial ( ll a, ll b) {
    ll tmp_num = 1;
    while(1) {
        if ( b == 0 ) break;
        tmp_num = tmp_num * a % mod;
        --a;
        --b;
    }
    return tmp_num;
}

ll comb ( ll a, ll b ) {
    return factorial(a,b) * inv(factorial(b,b)) % mod; 
}

int main(){
    ll n, k;
    cin >> n >> k;
    for ( ll i = 1; i <= k; ++i ) {
        ll ans = 0;
        ans = comb(n-k+1LL, i) * comb(k-1LL, i-1LL) % mod;
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	for(auto &h:H)cin >> h;
	int ans=0,max=0;
	for(int i=0;i<N;i++){
		if(H[i]>=max){
			ans++;
			max=H[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL INF=1<<29;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    int n;
    cin>>n;
    LL a[100100];
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
        LL count1=0;
        LL su1=0;
            for(int j=0;j<n;++j){
                su1+=a[j];
                        if(j%2==0&&su1<=0){
                            count1+=-su1+1;
                            su1=1;
                        }
                        else if(j%2==1&&su1>=0){
                            count1+=su1+1;
                            su1=-1;
                        }
    }
        LL count2=0;
        LL su2=0;
            for(int j=0;j<n;++j){
                su2+=a[j];
                        if(j%2==0&&su2>=0){
                            count2+=su2+1;
                            su2=-1;
                        }
                        else if(j%2==1&&su2<=0){
                            count2+=-su2+1;
                            su2=1;
                        }
    }
    cout<<min(count1,count2)<<endl;
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int main() {
    int N; cin >> N;
    vector<pair<int, int>> ba(N);
    for (int i = 0; i < N; i++) {
        cin >> ba.at(i).second >> ba.at(i).first;
    }
    sort(ba.begin(), ba.end());
    ll now = 0;
    string ans = "Yes";
    for (int i = 0; i < N; i++) {
        now += ba.at(i).second;
        if (now > ba.at(i).first) {
            ans = "No";
            break;
        } 
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int N = 1110, mod = 1e9+7;
int n, m, dp[N][N];
char grid[N][N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			scanf(" %c", &grid[i][j]);
		}
	}

	dp[0][0] = 1;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (grid[i][j] == '.'){
				if (i - 1 >= 0 && j - 1 >= 0) dp[i][j] = (dp[i - 1][j]%mod + dp[i][j - 1]%mod)%mod;
				else if (i - 1 < 0 && j - 1 >= 0) dp[i][j] = dp[i][j - 1];
				else if (j - 1 < 0 && i - 1 >= 0) dp[i][j] = dp[i - 1][j];
			}
		}
	}

	printf("%d\n", dp[n-1][m-1]);

	return 0; 
}

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  vector<vector<Int> > v(n);
  for(Int i=0;i<q;i++){
    Int t,a,x;
    cin>>t>>a;
    if(!t) cin>>x;
    if(t==0) v[a].emplace_back(x);
    if(t==1){
      for(Int i=0;i<(Int)v[a].size();i++){
	if(i) cout<<" ";
	cout<<v[a][i];
      }
      cout<<endl;
    }
    if(t==2) v[a].clear();
  }
  return 0;
}



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

using namespace std;
typedef long long int ll;
const int N=3010;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);
	int i,j,n,m,dp[N][N];
	string s,t,ans="";
	fflush(stdin); cin>>s; n=s.length();
	fflush(stdin); cin>>t; m=t.length();
	for(i=0;i<=n;++i){
		for(j=0;j<=m;++j){
			if(i==0||j==0) dp[i][j]=0;
			else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	i=n; j=m;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){
			ans+=s[i-1];
			--i; --j;
		}
		else if(dp[i][j-1]>dp[i-1][j]) --j;
		else --i;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	
}

Measured memory_bytes: 38948
N = int(input())
A = list(map(int,input().split(" ")))
mod = 10**9+7

fact = 1
for i in range(2,N+1):
    fact *= i
    fact %= mod

rev = [ pow((i),mod-2,mod) for i in range(1,N+1) ]
for i in range(N-1):
    rev[i+1] += rev[i]

ans = 0
for i in range(N):
    ans += A[i] * (fact * (rev[i] + rev[N-1-i] - rev[0])) % mod
    ans %= mod

print(ans)



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

int main(){
	vector<int> v(5);
	for(int i=0;i<5;i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	cout << v[0];
	for(int i=1;i<5;i++){
		cout << " " << v[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1208
using System;
using System.Text;
using CompLib.Util;

public class Program
{
    private int N;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        // 合計 (N+1)*N/2

        int m = 0;
        StringBuilder sb = new StringBuilder();
        // N偶数
        // 合計がN+1になるペアをつなぐ
        if (N % 2 == 0)
        {
            int t = N + 1;
            for (int i = 1; i <= N; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    if (i + j == t) continue;
                    sb.AppendLine($"{i} {j}");
                    m++;
                }
            }
        }
        else
        {
            int t = N;
            for (int i = 1; i <= N - 1; i++)
            {
                for (int j = i + 1; j <= N; j++)
                {
                    if (i + j == t) continue;
                    sb.AppendLine($"{i} {j}");
                    m++;
                }
            }
        }

        Console.WriteLine(m);
        Console.Write(sb);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int par[100010], dep[100010];
vector<vector<int>> G;

int main(void){
    int N, M;
    cin >> N >> M;
    G.resize(N+1);
    for(int i=0; i<M; ++i){
        int A, B;
        cin >> A >> B;
        G[A].emplace_back(B);
        G[B].emplace_back(A);
    }
    deque<int> dq{1};
    dep[1]=0;
    for(int i=2; i<=N; ++i) dep[i]=1e6;
    while(!dq.empty()){
        int h=dq.front();
        dq.pop_front();
        for(int i=0; i<G[h].size(); ++i){
            if(dep[G[h][i]]>dep[h]+1){
                dq.emplace_back(G[h][i]);
                par[G[h][i]]=h;
                dep[G[h][i]]=dep[h]+1;
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=2; i<=N; ++i) cout << par[i] << endl;
    return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b-c && a-b+c && b+c-a){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    };
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s.size() % 2 == 1) {
		if (s.front() == s.back())cout << "Second" << endl;
		else cout << "First" << endl;
	}
	else {
		if (s.front() == s.back())cout << "First" << endl;
		else cout << "Second" << endl;
	}
	return 0;
}


Measured memory_bytes: 512
import qualified Data.Sequence as S

main :: IO ()
main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    let b = length a `rem` 2
    mapM_ print . fst $ foldl f (S.empty, b) a
  where
    f :: (S.Seq Int, Int) -> Int -> (S.Seq Int, Int)
    f (q,b) x
      | b == 0 = (q S.|> x, 1)
      | b == 1 = (x S.<| q, 0)


Measured memory_bytes: 154876
#include <iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

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



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e5 + 9;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	//map<int,int> m1;
    int n,tmp;
    cin >> n;
    vector<int> v1;
    for(int i=0; i < n; i++){
        cin >> tmp;
        //m1[tmp] += 1;
        v1.push_back(tmp);
    }
    sort(v1.begin(), v1.end());
    reverse(v1.begin(), v1.end());
    vector<int> v2;
    for(int i=0; i < v1.size(); i++){
        v2.push_back(v1[i]);
        if( i ) v2.push_back(v1[i]);
    }
    ll ans = 0;
    for(int i=0; i < n-1; i++) ans += v2[i];
    cout << ans;





}


Measured memory_bytes: 6092
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,l=1;cin>>n;
  cin.ignore();
  string s;cin>>s;
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1]) l++;
  }
  cout<<l<<endl;
}

Measured memory_bytes: 512
use std::collections::{HashMap, VecDeque};
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct Main {
    x: i32,
    y: i32,
    z: i32,
}
impl Main {
    fn invoke(&mut self) {
        println!("{} {} {}", self.z, self.x, self.y);
    }
}

fn main() {
    let x: i32 = read();
    let y: i32 = read();
    let z: i32 = read();

    Main { x: x, y: y, z: z }.invoke()
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, a, b, c, d;
string s;

bool check_reach(int start, int end) {
  for (int i = start; i <= end - 1; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') {
      return false;
    }
  }

  return true;
}

bool check_triple() {
  bool ret = false;
  for (int i = b; i <= d; ++i) {
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') ret = true;
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

  cin >> s;

  s = '!' + s + '!';

  if (!check_reach(a, c) || !check_reach(b, d)) {
    printf("No\n");
    return 0;
  }

  if (c < d) {
    printf("Yes\n");
    return 0;
  }

  if (check_triple()) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  string l;
  cin >> l;
  ll ans = 0;
  ll pat = 1;
  rep(i, l.size()) {
    if (i == l.size()-1) {
      if (l[i] == '1') {
        pat *= 3;
        pat %= mod;
      }
      ans += pat;
      ans %= mod;
      break;
    }
    if (l[i] == '1') {
      int digit = l.size()-i-1;
      ll ncom = 1;
      rep(j, digit/100) {
        ncom *= 886041711;
        ncom %= mod;
      }
      rep(j, digit%100) {
        ncom *= 3;
        ncom %= mod;
      }
      ncom *= pat;
      ncom %= mod;
      ans += ncom;
      ans %= mod;
      pat *= 2;
      pat %= mod;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    string s; cin >> s;
    int n = s.length();
    ll ans = 0;

    for (int i = 0; i < (1 << (n - 1)); i++) {
        ll sum = 0, a = s[0] - '0';
        for (int j = 0; j < n - 1; j++) {
            if (i & (1 << j)) {
                sum += a;
                a = 0;
            }
            a = a * 10 + s[j + 1] - '0';
        }
        sum += a;
        ans += sum;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	nums := make([]int, n)
	var lcm int
	var check int
	fmt.Scan(&nums[0])
	check = counter(nums[0])
	if nums[0]/2 > m {
		fmt.Println("0")
		return
	}
	if n > 1 {
		fmt.Scan(&nums[1])
		lcm = nums[0] * nums[1] / GCD(nums[0], nums[1])
		if counter(nums[1]) != check || nums[1]/2 > m {
			fmt.Println("0")
			return
		}
		for i := 2; i < n; i++ {
			fmt.Scan(&nums[i])
			lcm = LCM(lcm, nums[i])
			if counter(nums[i]) != check || nums[i]/2 > m {
				fmt.Println("0")
				return
			}
		}
	} else {
		lcm = nums[0]
	}
	min := lcm / 2
	if min > m || min < 0 {
		fmt.Println("0")
		return
	}
	result := (m-min)/lcm + 1
	fmt.Println(result)
}

func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func LCM(a, b int) int {
	result := a * b / GCD(a, b)

	return result
}

func counter(a int) int {
	result := 0
	for a%2 == 0 {
		result++
		a /= 2
	}
	return result
}


Measured memory_bytes: 5504
def counts(n, div1, div2)
  (n / div1) + (n / div2) - (n / div1.lcm(div2))
end

a, b, c, d = gets.split.map(&:to_i)

counts_a = (a - 1) - counts((a - 1), c, d)
counts_b = b - counts(b, c, d)

puts counts_b - counts_a


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

namespace ABC112A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int Num = Input.Int();
            if (Num == 1)
            {
                Console.WriteLine("Hello World");
                return;
            }

            int A = Input.Int();
            int B = Input.Int();
            Console.WriteLine(A + B);
        }
    }
    
    internal static class Input
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11092