akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<31)-1;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }

    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }

    ll find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl = find(a, b, 2*k+1, l, (l+r)/2);
        ll vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    LazySegmentTree seg(vector<int> (n,INF));
    while(q--){
    	int a,b,c,d;
    	cin>>a>>b>>c;
    	if(a){
    		cout << seg.find(b,c+1) << endl;
    	}else{
    		cin>>d;
    		seg.update(b,c+1,d);
    	}
    }
    return 0;
}



Measured memory_bytes: 5232
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		HashMap<Integer,Integer> aMap = new HashMap<>();

		for(int i = 1; i <= n; i++) {
			aMap.put(sc.nextInt(),i);
		}

		sc.close();

		for(int i = 1; i <= n; i++) {
			System.out.print(aMap.get(i) + " ");
		}

		System.out.println();


	}

}


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

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

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> b.at(i);
    }
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> c.at(i);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    long long ans = 0;

    for(int i = 0; i < n; i++){
        long long numA = lower_bound(a.begin(),a.end(),b.at(i)) - a.begin();
        long long numC = c.end() - upper_bound(c.begin(),c.end(),b.at(i));
        ans += numA * numC;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
int main() {
  int n; cin >>n;
  n*=2;
  double ans=n;
  ans*=3.1415;
  cout <<ans;
  return 0;
}

Measured memory_bytes: 3260
a, b, c=map(int, input().split())
l=[a,b,c]
for i in range(3):
    if l[i]==5:
        del l[i]
        break
s=len(l)
for i in range(s):
    if l[i]==5:
        del l[i]
        break
if l==[7]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    if s.contains("AC"){
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
using namespace std;
int list[1000000];
stringstream sss;
void dfs(string str,int max);
int main(){
  int n,max,no,cnt,j;
  string str,ss;
  cin >> n;
  while(n--){
    sss.str("");
    max = cnt = 0;
    cin >> str;
    for(int i=0;i < str.size();i++){
      if(str[i]=='['){
	cnt++;
	if(max<cnt)max=cnt;
      } else if(str[i]==']') cnt--;
      else {
	for(j=i;str[j]!=']';j++);
	ss = str.substr(i,j-i);
	no = atoi(ss.c_str());
	sss << (no/2+1);
	ss = sss.str();
	str.erase(i,j-i);
	str.insert(i,ss);
	i= i+ss.size()-1;
	sss.str("");
      }
    }
    dfs(str,max);
  }
}
void dfs(string str,int max){  //文字列,段階
  int len = 0,cnt,x,l = str.size(),j,sum = 0;
  string ss;
  for(x=cnt=0;cnt != max && x < l;x++){
    if(str[x]=='[') cnt++;
    else if(str[x]==']') cnt--;
  }
  if(x == l){
    dfs(str,max-1);
    return;
  }
  x--;
  for(int i=x,flg=0;i < l;i++){
    if(str[i]>='0' && str[i] <= '9'){
      for(j=i;str[j]!=']';j++);
      ss = str.substr(i,j-i);
      list[len] = atoi(ss.c_str());
      i = j,len++;
    } else if(str[i]==']') flg--;
    if(flg==-1){
      str.erase(x,i-x);
      break;
    }
  }
  sort(list,list + len);
  for(int i=0;i<len/2+1;i++) sum += list[i];
  sss << sum; ss = sss.str();
  str.insert(x,ss);
  sss.str("");
  if(max==2){
    l=str.size();
    for(int i=1;i<l-1;i++) cout << str[i];
    cout << endl;
    return;
  }
  dfs(str,max);
}

Measured memory_bytes: 6288
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int a,b,c,k,ans;
    cin>>a>>b>>c>>k;
	if(a>b){
		if(a>c)ans=a*pow(2,k)+b+c;
		else ans=a+b+c*pow(2,k);
	}else{
		if(b>c)ans=a+b*pow(2,k)+c;
		else ans=a+b+c*pow(2,k);
	}
	cout<<ans<<endl;
}


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

int main(){
  int s,w;
  cin >> s >> w;

  if(s <= w){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }


}


Measured memory_bytes: 3620
#include <stdio.h>

int main() {
	int N;
	char s[100], t[100];
	scanf("%d%s%s", &N, &s, &t);
	char str[200];
	for (int i = 0; i < 2 * N;i++) {
		if (i%2==0) {
			int r = i / 2;
			printf("%c",s[r]);
		}
		else {
			int R = (i - 1) / 2;
			printf("%c",t[R]);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
    string S; cin>>S;
    int N=S.size();
    char A=S[0],B=S[1];
    int cnt=0;
    string X;
    rep(i,0,N){
        if(S[i]==A||S[i]==B) X+=S[i];
        else cnt++;
    }
    if(cnt<=1){
        bool flag=1;
        rep(i,0,N){
            if(X[i]!=S[i%2]) flag=0;
        }
        if(flag){
            if(cnt==0) cout<<"Second"<<endl;
            else cout<<"First"<<endl;
            return 0;
        }
    }
    if(S[0]==S[N-1]){
        if(N%2==0) cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else{
        if(N%2==0) cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int par[100000];//親
int ran[100000];//木の深さ
//初期化
void init(int N){
  FOR(i,0,N){
    par[i]=i;
    ran[i]=0;
  }
}
//木の根を求める
int find(int X){
  if(par[X]==X){
    return X;
  }else{
    return par[X]=find(par[X]);
  }
}
//Xの属する集合とYの属する集合を併合
void unite(int X,int Y){
  X=find(X);
  Y=find(Y);
  if(X==Y){
    return;
  }
  if(ran[X]<ran[Y]){
    par[X]=Y;
  }else{
    par[Y]=X;
    if(ran[X]==ran[Y]){
      ran[X]++;
    }
  }
}
//XとYが同じ集合に属するか否か
bool same(int X,int Y){
  return  find(X)==find(Y);
}
//
int N,M,K;
set<int> S[100000];
int main(){
	cin>>N>>M;
	FOR(i,0,N){
		cin>>K;
		FOR(j,0,K){
			int l;
			cin>>l;
			l--;
			S[l].insert(i);
		}
	}
	init(N);
	FOR(i,0,M){
		set<int>::iterator it=S[i].begin();
		if(it==S[i].end()){
			continue;
		}
		int num=*it;
		it++;
		while(it!=S[i].end()){
			unite(num,*it);
			num=*it;
			it++;
		}
	}
	FOR(i,0,N-1){
		if(!same(i,i+1)){
			YES(0);
			return 0;
		}
	}
	YES(1);
	return 0;
}


Measured memory_bytes: 10496
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

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

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

#define INF 1e9
int N, K;
const int maxN=100100;
int h[maxN];
long long dp[maxN];


int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    fill(dp, dp+N,INF);
    dp[0] =0;
    for(int i=0;i<N-1;i++){
        for(int j=1;j<=K;j++){
            chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
        
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
signed main(){
 int a,b,c,d,z=0;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes\n";
  }else{
  if(abs(a-b)<=d){
    z++;
  }
  if(z==1){
    if(abs(b-c)<=d){
      cout<<"Yes\n";
    }else{
      cout<<"No\n";
    }
  }else{
      cout<<"No\n";
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  if (abs(a - b) > f)
    cout << ":(";
  else if (abs(a - c) > f)
    cout << ":(";
  else if (abs(a - d) > f)
    cout << ":(";
  else if (abs(a - e) > f)
    cout << ":(";
  else if (abs(b - c) > f)
    cout << ":(";
  else if (abs(b - d) > f)
    cout << ":(";
  else if (abs(b - e) > f)
    cout << ":(";
  else if (abs(c - d) > f)
    cout << ":(";
  else if (abs(c - e) > f)
    cout << ":(";
  else if (abs(d - e) > f)
    cout << ":(";
  else
    cout << "Yay!";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main(void) {
	
	int A, B, C;
	cin >> A >> B >> C;
	
	if ( (A+B) >= C ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
#import numpy as np
#import collections
#import math

#f = open('./input_B.txt')
#
#f.readline()
#int(f.readline())
#map(int, f.readline().split())
#list(map(int, f.readline().split()))

#input()
N=int(input())
#map(int, input().split())
#list(map(int, input().split()))

N = str(N)

S=0
for i in range(len(N)):
   S+=int(N[i])

if S%9==0:
    ans="Yes"
else:
    ans = "No"
    
print(ans)

Measured memory_bytes: 70904
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	while (true)
	{
		int a, b, c;
		char op;

		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')
			break;

		switch (op)
		{
		case '+':
			c = a + b;
			break;

		case '-':
			c = a - b;
			break;

		case '*':
			c = a * b;
			break;

		case '/':
			c = a / b;
			break;

		}

		printf("%d\n", c);
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
#define CIN(n) int n; cin>>(n);
int main()
{
	CIN(n);
	int s = 0;
	unsigned long long int a[10001];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		
		while (a[i] % 2 == 0) {
			a[i] = a[i] / 2;
			s++;
		}
	}
	cout << s;
}

Measured memory_bytes: 384
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	vector<ll> a(n);
	cin >> a;
	bool ch = true;
	ll choice[50] = {};
	while(ch){
		ll count = 0;
		REP(i, n) choice[i] = 0;
		REP(i, n){
			if(a[i] >= n){
				ll op = (a[i]-(n-1)+(n-1))/n;
				count += op;
				ans += op;
				choice[i] = op;
				//cout << a[i] << "->" << a[i] - op * n;
				a[i] -= op * n;
			}
		}
		ch = false;
		REP(i, n){
			a[i] += count - choice[i];
			//cout << a[i] << " ";
			if(a[i]>= n) ch = true;
		}
		//cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>

int main(void) {
  int a,b;
  char op;
  int i = 0;

  while (1) {
    scanf("%d %c %d", &a, &op, &b);

    if (op == '?') break;
    else if (op == '+') i = a + b;
    else if (op == '-') i = a - b;
    else if (op == '*') i = a * b;
    else if (op == '/') i = a / b;

    printf("%d\n", i);
  }
  return (0);
}



Measured memory_bytes: 2064
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int a[100],b[100],n,f[100],c[100];
int lowbit(int x)
{
	return x&(-x);
}
void add(int x)
{
	while(x<=n)
	{
		c[x]+=1;
		x+=lowbit(x);
	}
}
int pre(int x)
{
	int sum=0;
	while(x)
	{
		sum+=c[x];
		x-=lowbit(x);
	}
	return sum;
}
void init()
{
	f[0]=1;
	for(int i=1;i<=8;++i)
	{
		f[i]=f[i-1]*i;
	}
}
int cantor_exp(int p[],int len)
{
	int sum=0;
	for(int i=n;i>=1;--i)
	{
		int a=pre(p[i]);
		sum+=a*f[n-i];
		add(p[i]);
	}
	return sum;
}
int main()
{
	ios;
	cin>>n;
	init();
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;++i)
	{
		cin>>b[i];
	}
	int s1,s2;
	s1=cantor_exp(a,n);
	memset(c,0,sizeof c);
	s2=cantor_exp(b,n);
	cout<<abs(s1-s2)<<'\n';
}

Measured memory_bytes: 3600
package main

import (
	"fmt"
	"math"
)

func main()  {
	var s string
	fmt.Scan(&s)

	var c0, c1 int64
	for _, v := range s {
		if v == '0' {
			c0++
		} else {
			c1++
		}
	}
	if c0 == 0 || c1 == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(int64(2*math.Min(float64(c0), float64(c1))))
	}
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
int main(void){
    char S[205];
    scanf("%s", S);
    for(int ans=strlen(S)-2; ; ans-=2){
        if(!strncmp(S, S+ans/2, ans/2)){
            printf("%d\n", ans);
            return 0;
        }
    }
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n],y = new int[n];
        for(int i=0;i<n;i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        
        long ans = (long)4e18;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)for(int s=0;s<n;s++)
            for(int t=0;t<n;t++){
                int x1 = Math.min(Math.min(x[i], x[j]), Math.min(x[s], x[t]));
                int x2 = Math.max(Math.max(x[i], x[j]), Math.max(x[s], x[t]));
                int y1 = Math.min(Math.min(y[i], y[j]), Math.min(y[s], y[t]));
                int y2 = Math.max(Math.max(y[i], y[j]), Math.max(y[s], y[t]));
                int c=0;
                for(int u=0;u<n;u++){
            		if(x1<=x[u] && x[u]<=x2 && y1<=y[u] && y[u]<=y2)
            			c++;
                }
                if(c>=k)
                    ans=Math.min(ans, (long)(x2-x1) * (y2-y1));
            }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22364
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n,ans=0;
	cin >> n;
	for (int i = 1; i <= sqrt(n);i++) {
		if (ans<i) {
			ans = i;
		}
	}
	cout << ans*ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int a, b; cin >> a >> b;
	int sum = 6;
	cout << sum - (a + b) << endl;
	return;
}

int main() {
	solve();
  return 0;
}

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

using namespace std;

char mp[8][9];

int a[7][4][2] = {
	{{0, 0}, {0, 1}, {1, 0}, {1, 1}},
	{{0, 0}, {1, 0}, {2, 0}, {3, 0}},
	{{0, 0}, {0, 1}, {0, 2}, {0, 3}},
	{{0, 1}, {1, 0}, {1, 1}, {2, 0}},
	{{0, 0}, {0, 1}, {1, 1}, {1, 2}},
	{{0, 0}, {1, 0}, {1, 1}, {2, 1}},
	{{1, 0}, {1, 1}, {0, 1}, {0, 2}}
};

int main()
{
	int nyan;
	while (1) {
		for (int i = 0; i < 8; ++i) if (scanf("%s", mp[i]) == EOF) return 0;

		for (int i = 0; i < 8; ++i) for (int j = 0; j < 8; ++j) {
			for (int k = 0; k < 7; ++k) {
				int cnt = 0;

				for (int l = 0; l < 4; ++l) {
					int ny = i + a[k][l][0], nx = j + a[k][l][1];
					if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') continue;
					cnt++;
				}

				if (cnt == 4) {
					printf("%c\n", 'A' + k);
					goto nxt;
				}
			}
		}
		
nxt:;
	}
}

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

int main() {
vector<int>a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
cin>>n;
cout<<a.at(n-1);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"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 {
	n := readInt()
	return 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 minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func dist(a, b, c, d int) int {
	return absInt(a-c) + absInt(b-d)
}

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt()
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, m)
	d := make([]int, m)
	for i := 0; i < n; i++ {
		a[i] = readInt()
		b[i] = readInt()
	}
	for i := 0; i < m; i++ {
		c[i] = readInt()
		d[i] = readInt()
	}

	for i := 0; i < n; i++ {
		minv := math.MaxInt32
		minj := -1
		for j := 0; j < m; j++ {
			d := dist(a[i], b[i], c[j], d[j])
			if d < minv {
				minv = d
				minj = j
			}
		}
		println(minj + 1)
	}

}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n+1);
    rep1(i, n) cin >> a[i];
    vi b(n+1);
    rep1r(i, n) {
        int sum = 0;
        for (int j=i*2; j<=n; j+=i) sum ^= b[j];
        b[i] = sum ^ a[i];
    }
    vi ans;
    rep1(i, n) if (b[i] == 1) ans.pb(i);
    int m = sz(ans);
    cout << m << endl;
    rep(i, m) printf("%d%c", ans[i], (i<m-1?' ':'\n'));
    return 0;
}


Measured memory_bytes: 5316
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

def main():
    """ main """
    N = int(input())
    AS = list(map(int, input().split()))
    ans = AS[0]
    for i in range(1,N):
        ans = gcd(ans,AS[i])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15028
//--------------------------------------------------
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
int n, m;
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m;
}

int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    int start = 1, end = m + (m%2 == 0);
    forn(i, m/2){
        cout << start+i << " " << end-i << endl;
    }
    start = end+1, end = m*2+1;
    forns(i, m, m/2){
        cout << start+(i-m/2) << " " << end-(i-m/2) << endl;
    }

}


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

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,m; cin >> h >> w >> m;
  int br[300001];
  int bc[300001];
  int cntr[300001] = {};
  int cntc[300001] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    cin >> br[i] >> bc[i];
    ChangeMax(maxr,++cntr[br[i]]);
    ChangeMax(maxc,++cntc[bc[i]]);    
  }
  bitset<300001>r,c;
  int cr=0,cc=0,cntd=0;
  for(int i = max(w,h); i >= 1; --i){
    if(maxr == cntr[i])cr+=r[i] = 1;
    if(maxc == cntc[i])cc+=c[i] = 1;
  }
  cntd = cr*cc;
  for(int i = 0; i < m; ++i)
    cntd -= c[bc[i]]&r[br[i]];
  cout << maxr + maxc - (!cntd) << '\n';
}


Measured memory_bytes: 8372
use proconio::{fastout, input};
use std::collections::BTreeSet;

#[fastout]
fn main() {
    input! {s: String};
    let s: String = s;

    let mut v = Vec::new();

    for s_i in s.chars() {
        v.push(s_i);
    }
    let x = v.clone().len();

    v.sort();
    v.dedup();

    if x != v.len() {
        println!("no")
    } else {
        println!("yes")
    }
}


Measured memory_bytes: 2064
import java.util.*;

public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int k = Integer.parseInt(sc.next());
      int x = Integer.parseInt(sc.next());
      int min = x - k + 1;
      for (int i = 0;i < k * 2 -1;i++) {
        System.out.println(min);
        min += 1;
      }
    }
}

Measured memory_bytes: 23764
height, width = gets.split(' ').map(&:to_i)
board = Array.new(height).map{gets.chomp.split('')}

is_bomb = lambda{|x, y|
  (0...width).include?(x) &&
    (0...height).include?(y) &&
    board[y][x] == '#'
}
around = [
  [-1, -1], [0, -1], [1, -1],
  [-1,  0], [1,  0],
  [-1,  1], [0,  1], [1,  1]
]

puts board.map.with_index{|row, y|
  row.map.with_index{|c, x|
    if c == '.'
      around.count{|i, j| is_bomb.call(x+i, y+j)}.to_s
    else
      c
    end
  }.join('')
}.join("\n")


Measured memory_bytes: 3836
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  long long int n, w, dp[102][100010], v[110], x[110], ans=0;
  cin >> n >> w;
  for(int i=0;i<n;i++){
    cin >> x[i] >> v[i];
  }
  for (int i=0;i<=100000;i++)dp[0][i]=200000000000;
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=100000;j++){
      if(j>=v[i])dp[i+1][j]=min(dp[i][j-v[i]]+x[i], dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  for (int i=0;i<=100000;i++){
    if(dp[n][i]<=w)ans=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79872
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

ll c[100],val[100];
ll ar[100][100];

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

	ll n,m,x,y,i,j,k,v,mn = 1e18;

	cin >> n >> m >> x;

	for(i=0;i<n;++i)
	{
		cin >> c[i];
		for(j=1;j<=m;++j)
			cin >> ar[i][j];
	}

	for(i=0;i<(1<<n);++i)
	{
		v = 0;
		for(j=0;j<n;++j)
		{
			if((i>>j)&1ll)
			{
				v += c[j];
				for(k=1;k<=m;++k)
					val[k] += ar[j][k];
			}
		}
		y = x;
		for(k=1;k<=m;++k)
		{
			y = min(val[k],y);
			val[k] = 0;
		}
		if(y == x)
			mn = min(mn,v);
	}

	if(mn == 1e18)
		cout << -1 << "\n";
	else
		cout << mn << "\n";
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    for (int i = 0 ; i < s.size() ; i++)
        cout << 'x';
    cout << '\n';
}


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  }
  
  if (op == '-') {
    cout << A - B << endl;
  }
  
}

Measured memory_bytes: 3636
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int count_odd = 0;
    int count_ope = 0;

    while(count_odd == 0){
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 1){
                count_odd++;
            }
        }
        if(count_odd == 0){
            for(int i = 0; i < n; i++){
                a[i] = a[i] / 2;
            }
            count_ope++;
        }
    }
    printf("%d\n",count_ope);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			String line = sc.nextLine();
			if (line.equals("END OF INPUT")) break;
			int prev = -1;
			for (int i = 0; i < line.length(); ++i) {
				if (line.charAt(i) == ' ') {
					System.out.print(i - prev - 1);
					prev = i;
				}
			}
			System.out.println(line.length() - prev - 1);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>

void bob_sort(int data[], int n);

int main(void)
{
  int n, l[7], i, sum=0;
  
  scanf("%d", &n);
  
  for(i=0;i<n;i++)
  {
    scanf("%d", &l[i]);
  }
  
  bob_sort(l, n);
  
  for(i=n-2;i>=0;i--)
  {
    sum += l[i];
  }
  
  if(sum > l[n-1])
  {
    printf("Yes");
  }
  else
  {
    printf("No\n");
  }
}

void bob_sort(int data[], int n)
{
  int i, j, tmp;
  for(i=0;i<n-1;i++)
    {
      for(j=n-1;j>i;j--)
      {
	  if(data[j] <= data[j-1])
	    {
	      tmp = data[j-1];
	      data[j-1] = data[j];
	      data[j] = tmp;
        }
      }
    }
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
#偶数個しか正負反転できない
#小さい順に並べてマイナスは全部、境界は判定
S = sorted([[i,A[i]] for i in range(N)],key=lambda x: x[1])
judge = [False]*N
for j in range(0,N-1,2):
    if S[j][1]+S[j+1][1]<0:
        judge[S[j][0]] = True
        judge[S[j+1][0]] = True
for i in range(N-1):
    if judge[i]:
        A[i] *= -1
        A[i+1] *= -1
        judge[i+1] ^= True
print(sum(A))

Measured memory_bytes: 26060
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO"
#define YES cout << "YES"
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}

void solve(){

    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    if(k<a){
        cout<<k; return;
    }    

    if(k<=(a+b)){
        cout<<a;
        return;
    }

    ll ans=a;

    k=k-(a+b);

    cout<<ans-k;


    return ;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;
  sort(A.begin(), A.end(), greater<Int>());

  map<Int, Int> cnt;
  for(Int a:A) cnt[a]++;

  Int ans = 1;
  if(A[0] == 1 && N != 2) ans = 0;

  ans &= (Int)cnt.size() == A[0]/2 + 1;
  if(A[0] % 2 == 0) {
    ans &= cnt[A[0]/2] == 1;
    cnt.erase(A[0]/2);
  }
  if(A[0] % 2 == 1) {
    ans &= cnt[A[0]/2 + 1] == 2;
    cnt.erase(A[0]/2 + 1);
  }
  for(Int a:A) ans &= a >= (A[0] + 1) / 2;
  for(auto p:cnt){
    Int a, num; tie(a, num) = p;
    ans &= num >= 2;
  }

  cout<<(ans? "Possible":"Impossible")<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	if n%2==1 {
		fmt.Println(0)
	} else {
		cnt := 0
		b := 5
		for n/b != 0 {
			cnt+=n/b/2
			b*=5
		}

		fmt.Println(cnt)
	}
}


Measured memory_bytes: 640
use std::cmp;

const X: usize = 16;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut a: Vec<i64> = sc.vec(n);

    let suffix_dp = dp(&a);
    a.reverse();
    let prefix_dp = dp(&a);

    let mut ans = 1 << 60;
    for prefix_size in 0..(n + 1) {
        let suffix_size = n - prefix_size;
        let sum = if prefix_size == 0 {
            2 * suffix_dp[0][0]
        } else if suffix_size == 0 {
            2 * prefix_dp[0][0] + n
        } else {
            let p = prefix_dp[n - prefix_size][0];
            let s = suffix_dp[n - suffix_size][0];
            p * 2 + s * 2 + prefix_size
        };
        ans = cmp::min(ans, sum);
    }

    println!("{}", ans);
}

fn dp(a: &Vec<i64>) -> Vec<Vec<usize>> {
    let n = a.len();

    let mut dp = vec![vec![0; X]; n];
    for x in 0..X {
        dp[n - 1][x] = x;
    }
    for i in (0..(n - 1)).rev() {
        for x in 0..X {
            let mut cur = a[i];
            for _ in 0..x {
                cur *= 4;
            }
            let mut next_x = 0;
            let mut next = a[i + 1];
            while cur > next {
                next *= 4;
                next_x += 1;
            }
            if next_x < X {
                dp[i][x] = dp[i + 1][next_x] + x;
            } else {
                let remain_x = next_x - (X - 1);
                dp[i][x] = dp[i + 1][X - 1] + remain_x * (n - 1 - i) + x;
            }
        }
    }
    dp
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 67836
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;


ll N,ans;
ll A[200005];

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

	cin >> N;
	int max = 0;
	FOR(i, 0, N) {
		cin >> A[i];

		if (A[i] < max) {
			ans += max - A[i];

		}
		else max = A[i];

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{

    void solve(){
        string s;
        cin >> s;
        DBG(s.substr(0,4))
        if(s.substr(0,4)=="YAKI")cout << "Yes" <<"\n";
        else cout << "No"<<"\n";
    }
};

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

    Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll; 
int main() {
    ll n;
    cin >> n;
    map<string, int>m;
    for(int i=0;i<n;i++) {
        string s;
        cin >> s;

        m[s]++;
    }
    int maxFreq = -1;
    for(auto &x : m) {
        int f = x.second;
        maxFreq = max(maxFreq, f);
    }
    for(auto &x : m) {
        if(x.second == maxFreq) {
            cout << x.first << "\n";
        }
    }
}

Measured memory_bytes: 25216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int s[] = new int[m];
            for (int i = 0; i < m; i++) {
                int k = Integer.parseInt(in.next());

                for (int j = 0; j < k; j++) {
                    s[i] |= (1 << (Integer.parseInt(in.next()) - 1));
                }
            }
            int[] p = new int[m];
            for (int i = 0; i < m; i++) {
                p[i] = Integer.parseInt(in.next());
            }

            int ans = 0;
            for (int i = 0; i < (1 << n); i++) {
                int tot = 0;
                for (int j = 0; j < m; j++) {
                    int and = i & s[j];

                    int t = 0;
                    while (and > 0) {
                        and &= (and - 1);
                        t++;
                    }

                    if (t % 2 == p[j]) {
                        tot++;
                    }
                }

                if (tot == m) {
                    ans++;
                }
            }

            out.println(ans);

        }

    }
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

int score(int d, vector<int> &c, vector<vector<int>> &s, vector<int> &lt, int t, int sc) {
  int score = sc;
  score += s[d][t];
  lt[t] = d;
  rep(j, 26) score -= c[j]*(d-lt[j]);
  return score;
}

signed main() {
  int D; cin >> D;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];
  vector<int> t(D);
  rep(i, D) {
    cin >> t[i];
    t[i]--;
  }
  
  int sc = 0;
  vector<int> lt(26, -1);
  rep(i, D) {
    sc = score(i, c, s, lt, t[i], sc);
    cout << sc << endl;
  }
    

}

Measured memory_bytes: 3700