akhauriyash/Code-Regression huggingface dataset:
h,w=[int(i) for i in input().split()]
s=[]
count=0

#for i in range(h):
#    s.append(input())

c_org = [ [ 0 if c_org == "#" else -1 for c_org in input()] for r in range(h)]
 

#周囲をシャープ(というか-1)で囲む------------------------------
#c_org の左右を囲む
for i in range(h):
    c_org[i].append( -1)
    c_org[i].insert(0,-1)
    count=count+c_org[i].count(9999)
c_plus=[-1 for i in range(w+2)]
 
#上下も囲んだ配列をcとする
c=[]
c.append(c_plus)
for i in range(h):
    c.append(c_org[i])
c.append(c_plus)
#-------------------------------------------------------------------

aaaaa=0
for i in range(h):
  for j in range(w):
     if c[i+1][j+1]==0:
         if c[i+1][j+2]==0 or c[i+2][j+1]==0 or c[i][j+1]==0 or c[i+1][j]==0:
           pass
         else:
#           print(i+1, j+1)
           aaaaa=1
 


#for i in range(h):
#    print(c[i])

if aaaaa==1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 1000000007;
// const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


const int MAX_n = 200000;
int n, d[MAX_n];
const int MAX_m = 200000;
int m, t[MAX_m];



signed main(){
    ios::sync_with_stdio(0);


    priority_queue<int,vector<int>,greater<int> > que;
    priority_queue<int,vector<int>,greater<int> > que2;

    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> d[i];
        que.push(d[i]);
    }

    cin >> m;
    for(int i = 0;i < m;i++){
        cin >> t[i];
        que2.push(t[i]);
    }

    if(m>n){
        cout<< "NO\n";
        return 0;
    }

    while(que2.size() != 0){
        int q = que2.top();que2.pop();
        while(1){
            if(que.size()<=0){
                cout<< "NO\n";
                return 0;
            }
            if(q == que.top()){
                que.pop();
                break;
            }else{
                que.pop();
            }
        }
    }
    cout<< "YES\n";

    return 0;
}



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

int main() {
  int N, s1, s2, s3, s4;
  cin >> N;
  if ((N / 10) % 111 == 0 | (N % 1000) % 111 == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}

Measured memory_bytes: 3544
from itertools import combinations

n = int(input())
testimonies = []
for i in range(n):
    n_testimony = int(input())
    testimonies.append([list(map(int, input().split())) for _ in range(n_testimony)])


for i in range(0, n+1):
    for liers in combinations(list(range(0,n)), i):
        who_ishonest = [1] * n
        for lier in liers:
            who_ishonest[lier] = 0

        for j in range(n):
            if j in liers:
                continue
            
            for testimony in testimonies[j]:
                if who_ishonest[testimony[0]-1] != testimony[1]:
                    break
            else:
                continue
            break
        else:
            print(n-i)
            break
    else:
        continue
    break


Measured memory_bytes: 3064
#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 int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1; // cin >> tc;
    while (tc--)
    {
        int n,a,b;
        cin >>n>> a >> b;
        if((b-a)%2==0){
            cout << (b - a) / 2 << endl;
        }
        else{
            int ans = 1e18;
            int f = (n - b);
            int aa = a;
            aa += f;
            if((n-aa)%2==0){
                f += (n - aa) / 2;
            }
            else{
                aa++;
                f += (n - aa)/2+1;
            }
          
            ans = min(ans, f);
            
            f =a - 1;
            int bb = b;
            bb = bb - f;
            if((bb-1)%2==0){
                f += (bb - 1) / 2;
            }
            else{
                
                bb--;
                f += (bb - 1) / 2 + 1;
            }
        
            ans = min(ans, f);
             
            cout << ans << endl;

        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 2000500
using namespace std;
int n,m,fa[N],vis[N],D[N],C[N];
int gf(int x) {return fa[x]==x?x:fa[x]=gf(fa[x]);}
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
    n = rd(), m = rd();

    for (int i=1;i<=1000;i++) fa[i] = i;
    for (int _=1;_<=n;_++)  {
        int x, y,a,b,c,d;
        a = rd(), b = rd(), c = rd(), d = rd();
        x=!c?a:-c; x+=500;
        y=!d?-b:d; y+=500;
        fa[ gf(x) ] = gf(y);
        D[x]++, D[y]--, vis[x] = 1;
    }

    int flag = 1;
    for (int i=1;i<500;i++) D[i]>0 ? flag=0 :0;
    for (int i=501;i<=1000;i++) D[i]<0 ? flag=0 :0;
    for (int i=1;i<=1000;i++) vis[gf(i)] |= vis[i];
    for (int i=1;i<=1000;i++) if (D[i]) C[gf(i)] = 1;
    for (int i=1;i<=1000;i++) if (fa[i]==i && !C[i] && vis[i]) flag = 0;
    puts(flag?"YES":"NO");
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    vector<int> nxt(n);
    nxt[n-1] = -1;
    for (int i=n-2; i >= 0; i--){
        if (v[i+1] != 0) nxt[i] = i+1;
        else nxt[i] = nxt[i+1];
    }
    vector<bool> bt(20);
    int ans = 0;
    for (int i=0; i < n; i++){
        fill(bt.begin(), bt.end(), false);
        int here = nxt[i];
        if (v[i] != 0) here = i;
        while (true){
            if (here==-1){
                ans += n-i;
                break;
            }
            bool vyh = false;
            for (int j=0; j < 20; j++){
                int ba = (1<<j)&v[here];
                if (ba==0) continue;
                if (bt[j]) vyh = true;
                bt[j] = true;
            }
            if (vyh){
                ans += here-i;
                break;
            }
            here = nxt[here];
        }
    }
    cout << ans;
}


Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll x;
    cin >> x;
    if(x >= 30){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

#define rep(i,n) for(ll i=0, i##_cond=(n);i<i##_cond;++i)
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef vector<ll> vi;

const ll inf = 1ll<<62;

int main(){
#define int ll
  int n, m; cin >> n >> m;
  vi x(n), y(n), z(n); rep(i,n) cin >> x[i] >> y[i] >> z[i];

  int res = -inf;
  rep(i,2) rep(j,2) rep(k,2){
    vi tmp(n);
    rep(l,n) tmp[l] = pow(-1,i)*x[l] + pow(-1,j)*y[l] + pow(-1,k)*z[l];
    sort(rall(tmp));
    res = max(res, accumulate(tmp.begin(),tmp.begin()+m,0ll));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集

int S;
ll dp[2010];
ll rec(int n){
  if(n==0) return 1;
  if(dp[n] != -1) return dp[n];

  ll res = 0;
  for(int j=3; j<=S; j++){
    if(n-j < 0) break;
    res += rec(n-j);
    res %= MOD;
  }
  return dp[n] = res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  cin >> S;

  REP(i,2010) dp[i] = -1;
  cout << rec(S) << endl;
}

Measured memory_bytes: 3680
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
#define d read()
bool good[100010];
ll n,m,ans;
ll h[100010];
int main(){
	n=d,m=d;
	f(i,1,n)h[i]=d;
	f(i,1,m){
		ll x=d,y=d;
		if(h[x]>=h[y])good[y]=1;
		if(h[x]<=h[y])good[x]=1;
	}
	f(i,1,n)ans+=!good[i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4508
nk = input().split()
n = int(nk[0])
k = int(nk[1])
alist = [int(a) for a in input().split()]


bit_count = [{0: 0, 1: 0} for i in range(42)]
for i in range(42):
    for a in alist:
        b = a >> i
        b &= 1
        which = 0 if b == 1 else 1
        bit_count[i][which] += 1


def calc_pow_multiple(digit, selected):
    count = bit_count[digit][selected]
    ret = 1<<digit
    ret *= count
    return ret


def calc_maxsum(kk, digit):
    if digit < 0:
        return 0
    if kk == (1<<(digit + 1)) - 1:
        partsum_0 = calc_pow_multiple(digit, 0)
        partsum_1 = calc_pow_multiple(digit, 1)
        return max(partsum_0, partsum_1) + calc_maxsum(kk>>1, digit - 1)

    kkbit = kk >> digit
    kkbit &= 1

    if kkbit == 0:
        return calc_pow_multiple(digit, 0) + calc_maxsum(kk, digit - 1)

    sum_0 = calc_pow_multiple(digit, 0) + calc_maxsum((1<<digit) - 1, digit - 1)
    sum_1 = calc_pow_multiple(digit, 1) + calc_maxsum(kk, digit - 1)
    return max(sum_0, sum_1)


print(calc_maxsum(k, 41))


Measured memory_bytes: 69208
/* ex5_3 melo */
#include <stdio.h>
int main(void){
    int row_N,col_N,i,j;//整数の箱を４つ用意する
    char arrayc[100][100];//100*100の文字配列を用意
    int row_TorF[100], col_TorF[100];//黒があるかないか判定する文字列を列と行分用意
    scanf("%d %d",&row_N,&col_N);//行と列を代入
    for(i=0;i<row_N;i++){//二次元の文字配列を代入
        for(j=0;j<col_N;j++){
            scanf(" %c",&arrayc[i][j]);
        }
    }
    for(i=0;i<row_N;i++){//初期化
        row_TorF[i]=0;
    }
    for(j=0;j<col_N;j++){//初期化
        col_TorF[j]=0;
    }
    for(i=0;i<row_N;i++){//黒がある行と列を探す
        for(j=0;j<col_N;j++){
            if(arrayc[i][j]=='#'){
                row_TorF[i]=1;//i列には黒がある
                col_TorF[j]=1;//i行には黒がある
            }
        }
    }
    for(i=0;i<row_N;i++){//白いマスのみからなる列または行以外（黒があった列または行）を表示する
        for(j=0;j<col_N;j++){
            if(row_TorF[i]==1&&col_TorF[j]==1){
                printf("%c",arrayc[i][j]);
            }
        }
        if(row_TorF[i]==1){
                printf("\n");//1列分表示されたら改行する
        }
    }
    return 0;//正常終了
}

Measured memory_bytes: 1644
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        double ans = 0.0,last = (double)a[0];
        for(int i=1;i<n;i++){
            ans = (last+a[i])/(2+.0);
            last = ans;
        }
        out.println(ans);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21460
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 35980
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

int D;
vector<int> c(26);
vector<vector<int>> s;

struct Data{
	vector<int> t;
	vector<vector<int>> penalty;
	int score;
	
	Data(){
		t.resize(D,0);
		penalty.resize(D+1,vector<int>(26,0));
		score = 0;
	}
};

void init(){
	cin>>D;
	for(int i=0;i<26;i++)scanf("%d",&c[i]);
	
	s.resize(D,vector<int>(26));
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++)scanf("%d",&s[i][j]);
	}
}

void Print(Data &d){
	for(int i=0;i<D;i++)printf("%d\n",d.t[i]+1);
}

Data generate(vector<int> t){
	Data ret;
	ret.t = t;
	vector<int> last(26,0);
	for(int i=0;i<t.size();i++){
		int temp = t[i];
		ret.score += s[i][temp];
		last[temp] = i+1;
		
		for(int j=0;j<26;j++){
			ret.penalty[i+1][j] = ret.penalty[i][j] + c[j];
			if(temp==j)ret.penalty[i+1][j] = 0;
			ret.score -= ret.penalty[i+1][j];
		}
	}
	return ret;
}

int change(Data &d,int ind,int nv){
	int o_score = d.score;
	int ov = d.t[ind];
	d.score += s[ind][nv];
	d.score -= s[ind][ov];
	d.t[ind] = nv;
	for(int i=ind+1;i<=D;i++){
		d.score += d.penalty[i][nv];
		d.score += d.penalty[i][ov];
		if(i==ind+1){
			d.penalty[i][nv] = 0;
			d.penalty[i][ov] = d.penalty[i-1][ov] + c[ov];
		}
		else{
			if(d.penalty[i][nv]!=0){
				d.penalty[i][nv] = d.penalty[i-1][nv]+c[nv];
			}
			if(d.penalty[i][ov]!=0){
				d.penalty[i][ov] = d.penalty[i-1][ov]+c[ov];
			}
		}
		d.score -= d.penalty[i][nv];
		d.score -= d.penalty[i][ov];
	}
	
	return d.score - o_score;
}

int main(){
	
	init();
	
	vector<int> t(D);
	for(int i=0;i<D;i++){
		int maxi = -1;
		int ind = 0;
		for(int j=0;j<26;j++){
			if(maxi < s[i][j]){
				maxi = s[i][j];
				ind = j;
			}
		}
		t[i] = i%26;//ind;
	}
	Data d = generate(t);

	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			int temp = d.t[i];
			if(change(d,i,j)<0)change(d,i,temp);
		}
	}
	
	Print(d);
	
	return 0;
}

Measured memory_bytes: 3848
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      string S=Console.ReadLine();
      string ans1=S.Substring(0,(N/2));
      string ans2=S.Substring((N/2),(N/2));
      if((N>=2)&&(N%2==0)&&(ans1==ans2)){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
    }
    
  }

}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin >> n;
    int t[n];
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int p,x,save;
        cin >> p >> x;
        save = t[p-1];
        t[p-1] = x;
        int ans = 0;
        for(int j=0;j<n;j++){
            ans = ans + t[j];
        }
        cout << ans << endl;
        t[p-1] = save;
    }
}

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

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

int main() {
    int N,M;
    string S;

    cin>>S;

    if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



    return 0;
}


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

int main(){
  int N,K;
  int screen=1;
  cin >> N >>K;

  for(int i=0;i<N;i++){
    if(screen*2>=screen+K){
      screen += K;
    }
    else{
      screen *= 2;
    }
  }
  cout << screen <<endl;
}


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

using namespace std;

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

  bool b = true;
  vector<int> a(N, -1);
  for (int i = 0; i < M; ++i)
  {
    int s, c;
    cin >> s >> c;

    if (s == 1 && c == 0 && N != 1) b = false;

    if (a[s-1] <= -1)
    {
      a[s - 1] = c;
    }
    else
    {
      if (a[s - 1] != c) b = false;
    }
  }


  if (M == 0)
  {
    if (N == 1) cout << 0;
    else cout << 1 * pow(10, N-1);
    return 0;
  }

  if (b)
  {
    int sum = 0;
    for (int i = 0; i < N; ++i)
    {
      //cout << "a[i] : " << a[i] << endl;
      if (i == 0 && a[i] == -1)
      {
        sum += 1 * pow(10, N - (i + 1));
      }
      else if (a[i] == -1) sum += 0;
      else sum += a[i] * pow(10, N - (i+1));
    }
    cout << sum;
  }
  else
  {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d,e=0;
  scanf("%d %d %d",&a,&b,&c);
  e+=a+c;
  b--;
  for(int i=0; i<a; i++){
    scanf("%d",&d);
    e+=b/d;
  }
  printf("%d",e);
  return 0;}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
	string str;
	cin >> str;
 	if(str == "-") break;

	int m;
	cin >> m;
  	for(int i=0; i<m; i++){
	  string tmp=str;
	  str="";
	  int h;
	  cin >> h;
	  for(int j=h;j<(int)tmp.size();j++){
		str+=tmp[j];
	  }
	  for(int j=0;j<h;j++){
		str+=tmp[j];
	  }
	}
	cout << str << endl;
  }
  return 0;
}



Measured memory_bytes: 3156
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int MOD;

struct Matrix {
	vector<vector<long long> > val;
	Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
	void init(int n, int m, long long x = 0) { val.assign(n, vector<long long>(m, x)); }
	size_t size() const { return val.size(); }
	inline vector<long long>& operator [] (int i) { return val[i]; }
	inline Matrix operator * (Matrix other)const
	{
		Matrix R(val.size(), other[0].size());
		for (int i = 0; i != val.size(); ++i)
			for (int j = 0; j != other[0].size(); ++j)
				for (int k = 0; k != other.size(); ++k)
					R[i][j] = (R[i][j] + (val[i][k] * other[k][j]) % MOD) % MOD;
		return R;
	}
	void print()const
	{
		for (int i = 0; i != val.size(); i++)
		{
			for (int j = 0; j != val[i].size(); j++)
			{
				cout << val[i][j];
				if (j + 1 == val[i].size())
				{
					cout << endl;
				}
				else
				{
					cout << " ";
				}
			}
		}
	}
};

Matrix matpow(Matrix A, long long n) {
	Matrix R(A.size(), A.size());
	for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
	while (n > 0) {
		if (n & 1) R = R * A;
		A = A * A;
		n >>= 1;
	}
	return R;
}

long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

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

	int L, A, B;
	cin >> L >> A >> B >> MOD;

	int di[19] = { 0 };
	int dc[19] = { 0 };
	rep(i, 1, 19)
	{
		di[i] = min(((int)pow(10, i) - A + B - 1) / B, L);
		di[i] = max((int)0, di[i]);
		dc[i] = di[i] - di[i - 1];
	}

	Matrix ans(3, 1);
	ans[0][0] = 0, ans[1][0] = A % MOD, ans[2][0] = 1;
	rep(i, 1, 19)
	{
		if (dc[i] == 0)continue;
		Matrix res(3, 3);
		res[0][0] = (ll)pow(10, i) % MOD, res[0][1] = 1, res[0][2] = 0;
		res[1][0] = 0, res[1][1] = 1, res[1][2] = B % MOD;
		res[2][0] = 0, res[2][1] = 0, res[2][2] = 1;
		res = matpow(res, dc[i]);
		ans = res * ans;
	}

	cout << ans[0][0] % MOD << "\n";

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int ans=sc.nextInt();
			if(ans==0){
				break;
			}
			for(int i=0; i<9; i++){
				ans-=sc.nextInt();
			}
			println(""+ans);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

main(){
  int n,m,a[51],b[51],c[51],d[51];
  int min,hoge,ans;

  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    ans=1;
    for(int j=0;j<m;j++){
      if(j==0){
	min=abs(a[i]-c[j])+abs(b[i]-d[j]);
      }else{
	hoge=abs(a[i]-c[j])+abs(b[i]-d[j]);
	if(min>hoge){
	  min=hoge;
	  ans=j+1;
	}
      }
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
ls=len(s)+1
lt=len(t)+1
dp=[[0]*lt for _ in range(ls)]
for i in range(1,ls):
    for j in range(1,lt):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i][j-1],dp[i-1][j])
ans=""
i=ls-1
j=lt-1
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans = s[i-1] + ans
        i-=1
        j-=1
print(ans)

Measured memory_bytes: 112220
/*input
3 2
acp
ae
15 9
dnsusrayukuaiia
dujrunuma
6 3
abcdef
abc
*/
#include "bits/stdc++.h"
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
using namespace std;

const int MXN = 1e6 + 10;
int n, m;
string s, t;
int main() {
    cin >> n >> m;
    cin >> s;
    cin >> t;
    int g = __gcd(n, m);
    for (int i = 0, j = 0; i < n && j < m; i += n / g, j += m / g) {
    	if (s[i] != t[j])
    	{
    		puts("-1");
    		return 0;
    	}
    }
    cout << (long long)n * m / g << endl;
    return 0;
}



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

int main()
{
    int n, k; cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int h; cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n,m,s=0;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int t;
		cin>>t;
		s += t;
	}
	if(s>n)
		cout<<-1;
	else
		cout<<(n-s);
	return 0;
}


Measured memory_bytes: 3624
integer N,M
integer,allocatable::a(:),b(:)
integer Q,v,d
integer,allocatable::c(:),dp(:,:)
read*,N,M
allocate(a(M),B(M))
do i=1,M
  read*,a(i),b(i)
end do
read*,Q
allocate(c(Q))
allocate(DP(0:11,N))
DP=0
do i=1,Q
  read*,v,d,C(i)
  DP(D,V)=i
end do
do i=10,0,-1
  do j=1,N
    DP(i,j)=max(DP(i,j),DP(i+1,j))
  end do
  do j=1,M
    DP(i,a(j)) = max( DP(i,a(j)), DP(i+1,b(j)) )
	DP(i,b(j)) = max( DP(i,b(j)), DP(i+1,a(j)) )
  end do
end do
do i=1,N
  print"(i0)",C(DP(0,i))
end do
end

Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



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

  int c = a;
  if(b >= 100) c = (c * 1000) + b;
  else if (b >= 10) c = (c * 100) + b;
  else c = c * 10 + b;

  if(((int)sqrt(c) * (int)sqrt(c)) == c) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;

int num;

void dfs(int n, vector<vector<int>> &d, vector<int> &k, vector<int> &day) {
	if (k[n] == num - 1)
		return;
	int a = d[n][k[n]];
	if (k[a] == num - 1 || d[a][k[a]] != n)
		return;
	day[n] = max(day[n], day[a]) + 1;
	day[a] = day[n];
	k[n]++;
	k[a]++;
	dfs(n, d, k, day);
	dfs(a, d, k, day);
	return;
}


int main(void) {
	int i, j, ans = 0;
	cin >> num;
	vector<vector<int>> d(num, vector<int>(num - 1));
	vector<int> day(num, 0), k(num, 0);
	for (i = 0; i < num; i++) {
		for (j = 0; j < num - 1; j++) {
			scanf("%d", &d[i][j]);
			d[i][j]--;
		}
	}
	for (i = 0; i < num; i++)
		dfs(i, d, k, day);
	for (i = 0; i < num; i++) {
		if (k[i] < num - 1) {
			printf("-1\n");
			return 0;
		}
		ans = max(ans, day[i]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  vector<int>a(n+1);
  for(int i = 1;i<=n;i++) cin >> a[i];
  vector<bool>b(n+1);
  vector<int>p(n+1);
  vector<int>c(n+1);
  int j = 1;int g = 0;int t = 0;
  while(true){
    g++;
    if(b[j]==0) {b[j] = 1;p[j] = g;}
    else{t = g-p[j];break;}
    c[g] = j;
    if(g==k+1){cout << c[g]<<endl;return 0;}
    j = a[j]; 
  }
  int h = g - t - 1;
  int z = (k-h)%t;
  cout << c[h+1+z]<<endl;
  return 0;
}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    string s;
    cin >> s;
    bool c = false;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
        c = true;
    Yes(c);
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top+1];
}

int main() {
  int a, b;
  top = 0;
  char s[100];

  while( scanf("%s", s) != EOF ) {
    if ( s[0] == '+' ) {
      b = pop();
      a = pop();
      push(a + b);
    } else if ( s[0] == '-' ) {
      b = pop();
      a = pop();
      push(a - b);
    } else if ( s[0] == '*' ) {
      b = pop();
      a = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n", pop());

  return 0;
}


Measured memory_bytes: 2108
while True:
	m, l, r = map(int, input().split())
	if m == -1 and l == -1 and r == -1:
		exit(0)
	elif m == -1 or l == -1:
		print('F')
	elif m + l >= 80:
		print('A')
	elif 65 <= m + l < 80:
		print('B')
	elif 50 <= m + l < 65:
		print('C')
	elif 30 <= m + l < 50:
		if r >= 50:
			print('C')
		else:
			print('D')
	elif m + l < 30:
		print('F')



Measured memory_bytes: 5588
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define mp(a, b) make_pair(a, b)
const int inf = 1 << 28;

template<typename T> void chmin(T &t, T f){if(t > f)t = f;}

int n, m, c, s, g;

vector<vector<vector<int> > > dist, cost;
vector<int> mem;
vector<vector<pair<int, int> > > table;

void init(){
    dist.assign(c, vector<vector<int> >(n, vector<int>(n, inf)));
    cost.assign(c, vector<vector<int> >(n, vector<int>(n, inf)));
    mem.assign(n, inf);
    table.assign(c, vector<pair<int, int> >());
    rep(i, c)rep(j, n)dist[i][j][j] = cost[i][j][j] = 0;
}

void doWF(){
    rep(r, c)rep(k, n)rep(i, n)rep(j, n){
        chmin(dist[r][i][j], dist[r][i][k] + dist[r][k][j]);
    }
}

int calc(int r, int a, int b){
    if(cost[r][a][b] != inf)return cost[r][a][b];
    int res = 0, p = 0;
    for(auto& v: table[r]){
        if(dist[r][a][b] <= v.first){
            res += (dist[r][a][b] - p) * v.second;
            break;
        }
        else{
            res += (v.first - p) * v.second;
            p = v.first;
        }
    }
    return cost[r][a][b] = res;
}

int solve(){
    mem[s] = 0;
    priority_queue<pair<int, int> > q;
    for(q.emplace(0, s); !q.empty();){
        pair<int, int> p = q.top(); q.pop();
        if(p.second == g)return -p.first;
        rep(r, c)rep(u, n){
            if(dist[r][p.second][u] == inf)continue;
            int nc = calc(r, p.second, u) - p.first;
            if(mem[u] <= nc)continue;
            mem[u] = nc;
            q.emplace(-nc, u);
        }
    }
    return -1;
}

int main(){
    while(cin >> n >> m >> c >> s >> g, n|m|c|s|g){
        s--; g--;
        init();
        while(m--){
            int x, y, d, k;
            cin >> x >> y >> d >> k;
            x--; y--; k--;
            chmin(dist[k][x][y], d);
            dist[k][y][x] = dist[k][x][y];
        }
        doWF();
        rep(i, c){
            int p;
            cin >> p;
            table[i].assign(p, mp(inf, inf));
        }
        rep(i, c){
            rep(j, (int)table[i].size()-1)cin >> table[i][j].first;
            for(auto& v: table[i])cin >> v.second;
        }
        cout << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 3084
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			a = scanner.next();
			b = scanner.next();
			int p1 = a.length();
			int p2 = 0;
			int ans = 0;
			while (p1 != 0 || p2 != b.length()) {
				if (p1 != 0)
					p1--;
				else
					p2++;
				ans = Math.max(ans, slove(p1, p2));
			}
			System.out.println(ans);
		}

	}

	private int slove(int p1, int p2) {
		int res = 0;
		int tmp = 0;
		int leng = Math.min(a.length() - p1, b.length() - p2);
		for (int i = 0; i < leng; i++) {
			if (a.charAt(i + p1) == b.charAt(i + p2)) {
				tmp++;
				res = Math.max(res, tmp);
			} else {
				tmp = 0;
			}
		}
		return res;
	}

	String a;
	String b;
}

Measured memory_bytes: 21412
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
//		String s = sc.next();
		int n = sc.nextInt();

		Map<String, Integer> map = new HashMap<>();

		for(int i=0;i<n;i++) {
			String s = sc.next();
			if(!map.containsKey(s)) {
				map.put(s, 1);
			}else {
				int cnt = map.get(s) + 1;
				map.put(s,cnt);
			}
		}

		//TODO mapのキー,値でソートする方法
		int max = 0;
		ArrayList<String> ans = new ArrayList<>();

		for(Entry<String, Integer> m : map.entrySet()) {
			int val = m.getValue();
			if(val >= max) {
				max = val;
			}
		}

		for(Entry<String, Integer> m : map.entrySet()) {
			if(m.getValue() == max) {
				ans.add(m.getKey());
			}
		}

		Collections.sort(ans);

		for(String s:ans) {
			System.out.println(s);
		}

	}
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;

signed main()
{

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

    if (a >= k)
    {
        cout << k << endl;
        return 0;
    }
    else
    {
        k -= a;
        if (b >= k)
        {
            cout << a << endl;
            return 0;
        }
        else
        {
            k -= b;
            cout << a - k << endl;
            return 0;
        }
    }

    return 0;
}


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

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

    int n;
    cin >> n;

    map<int, vector<pair<int, int>>> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            mp[i].push_back({x, y});
        }
    }

    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        set<int> honest;
        for(int j = 0; j < n; j++){
            if(i >> j & 1){
                honest.insert(j);
            }
        }

        bool f = true;
        for(auto x: honest){
            for(int j = 0; j < mp[x].size(); j++){
                pair<int, int> p = mp[x][j];
                int human = p.first;
                int isHonest = p.second;
                if(isHonest){
                    if(honest.count(human));
                    else{
                        f = false;
                        break;
                    }
                }else{
                    if(honest.count(human)){
                        f = false;
                        break;
                    }
                }
            }
        }
        if(f) ans = max(ans, (int)honest.size());
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    int X[N];
    cins(X, X + N);
    lint ans = 1e18;
    for(int i = 0; i <= 100; i++){
        lint this_ans = 0;
        for(int j: X){
            this_ans += (i - j) * (i - j);
        }
        ans = min(ans, this_ans);
    }
    cout << ans << endl;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

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

int N;
int A[111111];
int B[111111];
int X[111111];

signed main() {
  cin >> N;
  int sumA = 0, sumB = 0;
  rep (i, N) {
    cin >> A[i];
    sumA += A[i];
  }
  vec<int> v;
  rep (i, N) {
    cin >> B[i];
    sumB += B[i];
  }

  if (sumA < sumB) {
    cout << -1 << endl;
    return 0;
  }

  int jiyu = sumA - sumB;

  rep (i, v.size()) {
    if (jiyu - v[i] >= 0) {
      jiyu -= v[i];
      B[i] = A[i];
    }
  }

  rep (i, N) {
    if (A[i] < B[i]) continue;
    v.push_back(abs(A[i] - B[i]));
  }
  sort(all(v));

  int cnt = 0;
  int sum = 0;
  rep (i, N) {
    sum += v[i];
    if (sum <= jiyu) {
      cnt++;
    } else {
      break;
    }
  }

  cout << N - cnt << endl;

  return 0;
}

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

int main() {
	int N, W[100], COUNT = 0, SUM = 0, ANS = 1145141919;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> W[i], SUM += W[i];
	for (int i = 0; i < N; i++) {
		ANS = min(ANS, abs(COUNT - (SUM - COUNT)));
		COUNT += W[i];
		ANS = min(ANS, abs(COUNT - (SUM - COUNT)));
	}
	cout << ANS;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,k,n) for(ll i=k;i<n;i++)
#define REPEACH(itr,k) for(auto itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    while(s!=""){
      string str=s.substr(0,5);
      string resare=s.substr(0,6);
      string remaerd=s.substr(0,7);
      if(remaerd=="remaerd"){
        s=s.substr(7,s.size()-6);
      }
      else if(resare=="resare"){
        s=s.substr(6,s.size()-5);
      }
      else if(str=="maerd"){
        s=s.substr(5,s.size()-4);
      }
      else if(str=="esare"){
        s=s.substr(5,s.size()-4);
      }
      else{
        cout << "NO" << endl;
        return 0;
      }
    }
    cout <<"YES" << endl;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	int k, i, w, h, n, gr = 0, cnt = 0;
	cin >> n >> w >> h;
	vector<pair<int, int>> s(n);
	vector<int> g(n, -1);
	for (i = 0; i < n; i++) {
		cin >> s[i].first >> s[i].second;
	}
	for (k = 0; k < n; k++) {
		if (g[k] == -1) {
			queue<pair<int, int>> bfs;
			g[k] = gr;
			bfs.push(s[k]);
			while (!bfs.empty()) {
				pair<int, int> p = bfs.front(); bfs.pop();
				for (i = k; i < n; i++) {
					if ((p.first == s[i].first || p.second == s[i].second) && g[i] == -1) {
						bfs.push(s[i]);
						g[i] = gr;
					}
				}
			}
			gr++;
		}
	}
	cnt += n - gr;
	cnt += (gr - 1) * 2;
	if (gr > 1) {
		for (i = 0; i < n; i++) {
			if (s[i].first == 1 || s[i].first == w
				|| s[i].second == 1 || s[i].second == h) break;
		}
		if (i == n) cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3288
n, m = map(int, input().split())
a, c = [], []
for i in range(m):
    c.append(i+1)
i = 0
while i < n:
    a = list(map(int, input().split()))[1:]
    for j in range(len(c)):
        if c[j] not in a:
            c[j] = 0
    i += 1
    a = []
print(len(c)-c.count(0))


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


int main(){
  int n,i;

  cin >> n;
  long max,min,sum=0;
  int a;
  if( n ==0 )return 0;

  for ( i = 0 ; i < n ; i++){
    cin >> a;
    sum = sum + a;
    if( i == 0)max=min=a;
    if ( max <= a){
      max = a;
    }
    if ( min >= a){
      min = a;
    }
  }
  
  cout << min << " " << max << " " << sum <<endl;
  


  return 0 ;
}

Measured memory_bytes: 1168
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int d = to_string(i).length();
        ans += d % 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
p4=p2=p1=0
for i in a:
    if i%4==0:
        p4 += 1
    elif i%2==0:
        p2 += 1
    else:
        p1 += 1

if p2==0 and p1<= p4+1:
    print('Yes')

elif p2==0 and p1> p4+1:
    print('No')

elif p1 <= p4:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,n,m,l,f,x,y,z; string s;
	ll k;
	cin >> s >> k;
	char ans;

	n = s.size();
	f = 0;

	rep(i, n){
		if(s[i] != '1'){
			f = i;
			break;
		}
	}

	if(f <= k-1){
		ans = s[f];
	}else{
		ans = '1';
	}

	cout << ans << endl;
}

Measured memory_bytes: 256