akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)

ll n, k;
vector<ll> bac(41, 0);

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

ll solve(vector<ll> &v)
{
    bac.assign(41, 0); //パケット

    ll res = 0;

    for (int i = 0; i < siz(v); i++)
    {
        ll p = v[i], cnt = 0;
        while (p > 0)
        {
            if (p % 2 == 1)
            {
                bac[cnt]++;
            }
            p /= 2;
            cnt++;
        }
    }

    ll ind = -1;
    for (int i = 0; i < 41; i++)
    {
        if (bac[i] >= k)
            ind = i;
    }

    if (ind >= 0)
    {
        vector<ll> next(0);
        ll x = modpow(2, ind);
        res += x;

        rep(i, siz(v))
        {
            ll p = v[i], cnt = 0;
            while (p > 0)
            {
                if (p % 2 == 1 && cnt==ind)
                {
                    next.pb(v[i] - x);
                }
                p /= 2;
                cnt++;
            }
        }
        res += solve(next);
    }

    return res;
}

signed main()
{
    cin >> n >> k;
    vector<ll> v(n + 1, 0), sub(0);
    rep(i, n)
    {
        cin >> v[i + 1];
        v[i + 1] += v[i];
    }

    for (int i = 0; i < n + 1; i++)
    {
        for (int j = i + 1; j < n + 1; j++)
        {
            sub.pb(v[j] - v[i]);
        }
    }

    cout << solve(sub) << endl;
}


Measured memory_bytes: 6128
import sys

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N , M = map(int, sys.stdin.readline().split())

    broken = [False for _ in range(N + 1)]
    for _ in range(M):
        broken[int(sys.stdin.readline())] = True

    L = [0] * (N + 1)
    L[0] = 1
    if not broken[1]:
        L[1] = 1
    for i in range(2, N + 1):
        if not broken[i]:
            L[i] = L[i - 1] + L[i - 2]
    print(L[N] % mod)



Measured memory_bytes: 460824
n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i)

Measured memory_bytes: 8072
# D - Coloring Edges on Tree
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = []
B = []

# 2次元配列で辺（頂点,遷移先の頂点）を管理する
D = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    D[a].append(b)
    D[b].append(a)
    A.append(a)
    B.append(b)

print(max([len(d) for d in D]))

C = {}

def dfs(node, par, col):
    cid = 1
    for chi in D[node]:
        if chi==par:
            continue
        else:
            if cid==col:
                cid += 1
            C[(node, chi)] = cid
            C[(chi, node)] = cid
            dfs(chi, node, cid)
            cid += 1

dfs(0,0,0)

for a, b in zip(A, B):
    print(C[(a,b)])

Measured memory_bytes: 80336
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

double X[10],Y[10];

double dist(int i,int j){
  double dx=X[i]-X[j];
  double dy=Y[i]-Y[j];
  return sqrt(dx*dx+dy*dy);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  rep(i,n) cin>>X[i+1]>>Y[i+1];
  
  vector<int> B(n);
  rep(i,n) B[i]=i+1;
  
  double sum=0.0;
  do{
    rep(i,n-1) sum+=dist(B[i],B[i+1]);
  }while(next_permutation(ALL(B)));
  
  double cnt=1;
  for(int i=2;i<=n;i++) cnt*=i;
  
  cout<< fixed << setprecision(15) << sum/cnt <<endl;

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> ans(4);
    rep(i, n) {
        string s;
        cin >> s;
        if (s == "AC") ans[0]++;
        else if (s == "WA") ans[1]++;
        else if (s == "TLE") ans[2]++;
        else if (s == "RE") ans[3]++;
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}

Measured memory_bytes: 3592
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return-1;
}
int main()
{   long long n;
    scanf("%lld",&n);
    long long d[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&d[i]);
    }
    if(d[0]>0){
        printf("0");
        return 0;
    }int tmp[100001]={0};
    qsort(d,n,sizeof(long long),compare);
    for(int i=0;i<n;i++){
        tmp[d[i]]++;
    }
    /*for(int i=1;i<=tmp[d[i]];i++){
        printf("%d ",tmp[i]);
    }*/
    if(tmp[0]>1){
        printf("0");
        return 0;
    }long long ans=1;
    for(int i=1;i<=d[n-1];i++){
        long long t=0;
        while(t<tmp[i]){
            t++;
            ans*=tmp[i-1];
            ans%=998244353;
        }
    }
    printf("%lld",ans%998244353);
    return 0;
}


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

const int MOD=(int)1e9+7;

int main(){
  string L;
  cin >> L;

  long long ans=0;
  long long ma=1;
  for(int i=0;i<L.size();i++){
    ans*=3;
    ans%=MOD;
    if(L.at(i)=='1'){
      ans+=ma;
      ma*=2;
      ans%=MOD;
      ma%=MOD;
    }
  }
  cout << (ans+ma)%MOD << endl;

	return 0;
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sh := nextInt()
	sm := nextInt()
	eh := nextInt()
	em := nextInt()
	k := nextInt()

	o := (eh-sh)*60 - sm + em

	fmt.Println(o - k)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1756
n = int(input())
dic = {}
for _ in range(n):
  a = int(input())
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1

ans = 0
for i in dic:
  if dic[i]%2 == 1:
    ans += 1
    
print(ans)
    


Measured memory_bytes: 15076
import java.io.*;
import java.util.*;
public class Main {
static long[][] memo;
static int H,W;
static char [][] grid;
static final long mod=1000000007;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   H=sc.nextInt();
	   W=sc.nextInt();
	   memo=new long[H][W];
	   for(long []a:memo)
		   Arrays.fill(a,-1);
	   grid=new char[H][W];
	   for(int i=0;i<H;i++)
		   grid[i]=sc.nextLine().toCharArray();
	   dp(0,0);
	   System.out.println(memo[0][0]);
	}
	static long dp(int i,int j) {
	if(i==H-1 && j==W-1)
		return 1;
	if(!valid(i,j))
		return 0;
	if(memo[i][j]!=-1)
		return memo[i][j];
	long down=dp(i+1,j)%mod;
	long right=dp(i,j+1)%mod;
	return memo[i][j]=(right+down)%mod;
	}
	static boolean valid(int i, int j) {
		return i>=0 && i<H && j>=0 && j<W && grid[i][j]=='.';
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0) {if(a<b) swap(a,b); a = a%b;}
  return max(a,b);
}

int main(){
 int n;
  cin >>n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int ans=0;
  bool up = 1;
  rep(i,n-1){
    if(up && h[i]>h[i+1]){
      up = 0;
      ans += h[i];
    }
    if(!up && h[i]<h[i+1]){
      up = 1;
      ans -= h[i];
    }
  }
  if(up) ans += h[n-1];

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


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

int main(){

  int n, s;

  while(cin >> n, n){
    int sum = 0;
    int max_s = -1, min_s = 10001;
    for(int i = 0; i < n; i++){
      cin >> s;
      min_s = min(min_s, s);
      max_s = max(max_s, s);
      sum += s;
    }
    sum = sum - max_s - min_s;
    sum /= (n - 2);
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3016
n,m = map(int,input().split())
j = [0]*n
w = [0]*n
wa = 0
ac = 0

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC' and j[p] == 0:
        ac += 1
        j[p] = 1
        wa += w[p]
    elif s == 'WA' and j[p] == 0:
        w[p] += 1

print(ac,wa)


Measured memory_bytes: 4596
n, m, x = [int(x) for x in input().split()]
c = []
a = []
count = 0

for i in range(n):
    tmp = [int(x) for x in input().split()]
    c.append(tmp.pop(0))
    a.append(tmp)

min = sum(c)+1

for i in range(1<<n):
    cost = 0
    skill = [0]*m
    for j in range(n):
        s = []
        if(i>>j&1):
            cost += c[j]
            for k in range(m):
                skill[k] += a[j][k]
    for s in skill:
        if(s < x):
            break
    else:
        if(cost < min):
            min = cost

if(min == sum(c)+1):
    print('-1')
else:
    print(min)


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


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

    string S;
    cin >> S;
    if (S == "Sunny"){
        cout << "Cloudy" << endl; 
    }
    else if (S == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 100000000
int main()
{
  string s,t,tmp;
  int sizes,sizet,ans=INF,c;
  cin >> s;
  cin >> t;
  sizes=s.length();
  sizet=t.length();
  rep(i,sizes-sizet+1){
    tmp=s.substr(i,sizet);
    c=0;
    rep(j,sizet){
      if(t[j]!=tmp[j]){
        c++;
      }
    }
    if(ans>c) ans=c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
double n;
double dp[330][330][330];//1 ,2 3  x通り
int main() {
 cin>>n;
 vin a(n);
  int x=0,y=0,z=0;
  rep(i,0,n){
  cin>>a[i];
   if(a[i]==1) x++;
   else if(a[i]==2) y++;
   else z++;
 }
  ////////////
  dp[0][0][0]=0;
  rep(k,0,n+1){
   rep(j,0,n+1){
     rep(i,0,n+1){         
      if(i+j+k==0) continue; 
       
       dp[i][j][k]=double(n/(i+j+k));
      if(i-1>=0) dp[i][j][k]+=dp[i-1][j][k]*i/(i+j+k);
      if(j-1>=0) dp[i][j][k]+=dp[i+1][j-1][k]*j/(i+j+k);
      if(k-1>=0) dp[i][j][k]+=dp[i][j+1][k-1]*k/(i+j+k);
     }
   }    
  }
  cout<<fixed<<setprecision(10);
  cout<<dp[x][y][z]<<endl;
}









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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=200005;
const int mod=1e9+7;
int n,tot;
int a[maxn],val[maxn],cnt[maxn],prod[maxn],iprod[maxn],inv[maxn],prv[maxn];

int quickpow(int x,int pow){
	int res=1;
	for(;pow;pow>>=1){
		if(pow&1)res=1LL*res*x%mod;
		x=1LL*x*x%mod;
	}
	return res;
}

class Fenwick{
public: 
	int t[maxn];
	void clear(){
		REP(i,n)t[i]=0;
	}
	void add(int v,int val){
		for(;v<=n;v+=(v&-v)){
			t[v]+=val;
			if(t[v]>=mod)t[v]-=mod;
		}
	}
	int sum(int v){
		int res=0;
		for(;v;v-=(v&-v)){
			res+=t[v];
			if(res>=mod)res-=mod;
		}
		return res;
	}
}Sum,Cnt;

int main(){
	scanf("%d",&n);
	inv[0]=inv[1]=1;
	for(int i=2;i<=n;i++)inv[i]=1LL*inv[mod%i]*(mod-mod/i)%mod;
	tot=1;
	REP(i,n){
		scanf("%d",&a[i]);
		cnt[a[i]]++; 
	}
	int s=0;
	for(int i=n;i>=1;i--){
		s+=cnt[i];
		val[i]=s-(n-i);
		if(val[i]<=0){
			puts("0");
			return 0;
		}
		tot=1LL*tot*val[i]%mod;
		val[i]=1LL*(val[i]-1)*inv[val[i]]%mod;
	}
	prod[0]=iprod[0]=1;
	int last=0;
	REP(i,n){
		int tmp=max(val[i],1);
		if(!val[i])last=i;
		prv[i]=last;
		prod[i]=1LL*prod[i-1]*tmp%mod;
		iprod[i]=1LL*iprod[i-1]*quickpow(tmp,mod-2)%mod;
	}
	int ans=0;
	REP(i,n){
		ans+=1LL*cnt[i]*(cnt[i]-1)/2%mod*tot%mod; 
		if(ans>=mod)ans-=mod;
	}
	if(ans&1)ans+=mod;
	ans/=2;
	REP(i,n){
		int cur=1LL*prod[a[i]]*(Sum.sum(a[i]-1)-Sum.sum(prv[a[i]]-1)+mod)%mod*tot%mod;
		if(cur&1)cur+=mod;
		cur/=2;
		ans+=cur;
		if(ans>=mod)ans-=mod;	
		Sum.add(a[i],iprod[a[i]]);
	}
	Sum.clear();
	for(int i=n;i>=1;i--){
		ans+=1LL*Cnt.sum(a[i]-1)*tot%mod;
		if(ans>=mod)ans-=mod;
		Cnt.add(a[i],1);
		int cur=1LL*prod[a[i]]*(Sum.sum(a[i]-1)-Sum.sum(prv[a[i]]-1)+mod)%mod*tot%mod;
		if(cur&1)cur+=mod;
		cur/=2;
		ans-=cur;
		if(ans<0)ans+=mod;
		Sum.add(a[i],iprod[a[i]]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>

using namespace std;

int a,b;

int main() {
   // freopen("test.in","r",stdin);
    cin >> a >> b;
    long long c = a + b;
    if (c>=10) cout << "error" << endl;
     else cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll s;
    cin >> s;
    ll x1 = 0, y1 = 0, x2 = 1000000000ll, y2 = 1, y3 = (s + x2 - 1) / x2, x3 = y3 * x2 - s;

    printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);


}


Measured memory_bytes: 3784
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	if (abs(k * d) <= abs(x)) {
		cout << abs(x) - abs(k * d) << endl;
		return 0;
	}
	if (k % 2 == 0) {
		cout << min(abs(abs(x) % (2 * d)), abs(2 * d - abs(x) % (2 * d))) << endl;
		return 0;
	}
	else {
		x = abs(x) - d;
		cout<< min(abs(abs(x) % (2 * d)), abs(2 * d - abs(x) % (2 * d)))<<endl;
		return 0;
	}
	
}


Measured memory_bytes: 3188
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

acc = [0] * (N + 2)
for i in range(N + 1):
    acc[i + 1] = acc[i] + abs(A[i + 1] - A[i])
for i in range(N):
    print(acc[i] - acc[0] + abs(A[i + 2] - A[i]) + acc[N + 1] - acc[i + 2])

Measured memory_bytes: 14176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, K;
    while(cin >> N >> K){
        vector<pair<int,int>> a(N);
        int m = 2*N;
        m = max(K+N, m);
        m = min(K+2*N-1, m);
        for(int i=0;i<N;i++){
            a[i] = make_pair(K+i, m);
            m++;
            if(m >= K+2*N) m -= N;
        }
        sort(a.begin(), a.end(), [&](pair<int,int> l, pair<int,int> r){return l.first+l.second < r.first+r.second;});
        bool ok = true;
        for(int i=0;i<N;i++){
            if(a[i].first+a[i].second > K+2*N+i) ok = false;
        }
        if(ok){
            for(int i=0;i<N;i++){
                cout << a[i].first << " " << a[i].second << " " << K+2*N+i << endl;
            }
        } else {
            cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 3072
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    c=0
    tmp=1
    for x in a:
        if x==tmp:
            c+=1
            tmp+=1
    print(N-c if tmp!=1 else -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72220
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n, m;
int s[5];
int c[5];

int main() {
    fastio();

    cin >> n >> m;
    forn(i, m) cin >> s[i] >> c[i];

    for (int i = 0; i < 1000; i++) {
        string t = to_string(i);
        if (t.size() != n) continue;

        bool ok = true;
        forn(i, m) {
            ok &= t[s[i] - 1] - '0' == c[i];
        }

        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		int a;
		long d=0;
		Scanner sc=new Scanner(System.in);
		a=sc.nextInt();
		int c=sc.nextInt();
		int b[]=new int[a];
		for(int i=0;i<a;i++)
		{
			b[i]=sc.nextInt();
		}
		Arrays.sort(b);
		if(a<c)
		{System.out.println("0");}
		else
		{
			for(int j=0;j<a-c;j++)
			{
				d+=b[j];
				
			}
			System.out.println(d);
		}
	}
}

Measured memory_bytes: 64564
N, M = map(int, input().split())

SC = []
for _ in range(M):
    s, c = map(int, input().split())
    SC.append([s, c])

for i in range(1000):
    str_i = str(i)
    if len(str_i) != N:
        continue

    for sc in SC:
        index = sc[0]-1

        if len(str_i) != N:
            break
        if str_i[index] != str(sc[1]):
            break
    else:
        print(i)
        exit(0)
print(-1)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;

struct item{
    int v;
    int w;
};

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

    item I[n];
    for (int i = 0; i < n; i++){
        cin >> I[i].v >> I[i].w;
    }

    int dp[n][11000];
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= w; j++){
            if (i == 0 && j == I[i].w) dp[i][j] = I[i].v;
            else if (j - I[i].w < 0 || j - I[i].w > w) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - I[i].w] + I[i].v);
        }
    }

    cout << dp[n - 1][w] << endl;
    return 0;
}


Measured memory_bytes: 7384
n = int(input())
A = [int(input()) for _ in range(n)]

ans = 0
if A[0] != 0:
  ans = -1
else:
  pre = 0
  for i in range(1,n):
    if A[i] == pre+1:
      ans += 1
      pre = A[i]
    elif A[i] == pre:
      ans += A[i]
    elif A[i] <= pre-1:
      ans += A[i]
      pre = A[i]
    else:
      ans = -1      
      break
      
print(ans)

Measured memory_bytes: 16968
#include <bits/stdc++.h>
#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 irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

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

  int n, m;
  cin >> n >> m;
  set<int> aset;
  rep(i, m) {
    int a;
    cin >> a;
    aset.insert(a);
  }
  vector<lint> dp(n + 1);
  dp[0] = 1;
  dp[1] = aset.find(1) == aset.end() ? 1 : 0;
  for (int i = 2; i <= n; ++i) {
    if (aset.find(i) == aset.end()) {
      dp[i] = dp[i - 1] + dp[i - 2];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
const int N=200009;
int n,a[N],last;
long long Ans;
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		int x=read();
		if (x>=i||x>last+1)
		{
			puts("-1");
			return 0;
		}
		if (x==last+1) Ans++;
		else Ans+=x;
		last=x;
	}
	printf("%lld\n",Ans);
	return 0;
}


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

int main() {
	long long int n, k;
	cin >> n >> k;
	long long int res = (n / k) * (n / k) * (n / k);
	if (k % 2 == 0) {
		long long int c = n / k;
		if (n / k * k + k / 2 <= n) {
			c++;
		}
		res += c * c * c;
	}
	cout << res << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b && b!=c && c!=a)
    {
        cout<<3;
    }
    else if(a==b && b!=c && c!=a||b==c && a!=b && c!=a||c==a && a!=b && b!=c)
    {
        cout<<2;
    }
    else
    {
        cout<<1;
    }

    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int n;cin>>n;
  ll ans = n + n*n + n*n*n;
  cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

template <typename T>
struct cumsum{
    vector<T> V;
    ll L;
    cumsum(vector<T> &v) : V(v){     
        L = V.size();
        for(int i=1;i<L;i++) V[i] += V[i-1];
    } 
    T query(int a, int b){
        if(a == b) return 0;
        T ret = V[b-1];
        if(a > 0) ret -= V[a-1];
        return ret;
    }
};

ll N;
string S;

int main(){
    cin >> N;
    cin >> S;
    vector<ll> v(N,0);
    for(int i=0;i<N;i++) if(S[i] == 'W') v[i]++;
    cumsum<ll> cs(v);
    ll ans = 1e18;
    for(int i=0;i<=N;i++){
        ll w = cs.query(0,i);
        ll r = N-i -cs.query(i,N);
        ans = min(ans, max(w,r));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    vector<set<int>> g(N+1);
    REP(i,M) {
        int a, b;
        cin >> a >> b;
        g[a].insert(b);
        g[b].insert(a);
    }

    vector<int> q;
    vector<int> ans(N+1);
    ans[0] = 1; ans[1] = 1;
    for(auto x:g[1]) {
        ans[x] = 1;
        q.push_back(x);

        g[1].erase(x);
        g[x].erase(1);
    }

    while(!q.empty()) {
        vector<int> tmp;
        swap(q,tmp);
        for (auto x:tmp) {
            for (auto y:g[x]){
                if (ans[y] == 0) {
                    ans[y] = x;
                    q.push_back(y);
                }
                g[x].erase(y);
                g[y].erase(x);
            }
        }
    }

    if(find(ALL(ans),0) == ans.end()) {
        OUT("Yes")
        FOR(i,2,N+1) OUT(ans[i])
    } else OUT("No")

    return 0;
}

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

typedef long double     lf;

using namespace std;

const lf EPS = 1e-9;

struct pt {
  lf x, y;
  pt( ) { }
  pt( lf x, lf y ) : x( x ), y ( y ) { }
};

inline lf x( pt P ) { return P.x; }
inline lf y( pt P ) { return P.y; }

istream& operator >> ( istream& in, pt& p ) {
  lf x,y; in >> x >> y;
  p = pt(x,y); return in;
}

ostream& operator << ( ostream& out, const pt& p ) {
  out << double(p.x) << " " << double(p.y);
  return out;
}

pt operator + ( const pt& A, const pt& B ) {
  return pt( x(A)+x(B), y(A)+y(B) );
}

pt operator - ( const pt& A, const pt& B ) {
  return pt( x(A)-x(B), y(A)-y(B) );
}


pt operator * ( const lf& B, const pt& A ) {
  return pt( x(A)*B, y(A)*B );
}

pt operator * ( const pt& A, const lf& B ) {
  return pt( x(A)*B, y(A)*B  );
}

inline lf dot( pt A, pt B ) {
  return x(A)*x(B) + y(A)*y(B);
}

inline lf norm( pt A ) {
  return x(A)*x(A) + y(A)*y(A);
}

inline lf abs( pt A ) {
  return sqrt( norm(A) );
}

inline lf dist ( pt A, pt B ) { return abs( B - A ); }

lf distToLine (pt p, pt A, pt B, pt &c) {
  lf u = dot( p-A , B-A ) / norm( B-A );
  c = A + u*( B-A );
  return dist( p , c );
}

pt refPoint(pt X, pt A, pt B) {
  pt aux; distToLine(X, A, B, aux);
  return X + lf(2.0)*(aux-X);
}

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

inline bool same ( lf a, lf b ) {
  return a+EPS > b && b+EPS > a;
}

inline lf cross( pt A, pt B ) {
  return x(A)*y(B) - y(A)*x(B);
}

///CHANGE
// 0  for collineal points ( angle = 0 )
// 1  for angle BAX counter clockwise
// -1 for angle BAX clockwise
inline int ccw (pt X, pt A, pt B) {
  lf c = cross( B-A, X-A );
  if( same( c, 0.0 ) ) { return 0; }
  if( c > EPS ) { return 1; }
  return -1;
}

///CHANGE
inline bool segContains ( pt X, pt A, pt B) {
  if ( !same ( 0, cross ( A-X, B-X ) ) ) return 0;
  return ( dot ( A-X, B-X ) < EPS );
}

pt p0,p1,p2;
int n;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);


  cin >> p0 >> p1 >> n;
  for( int i = 0; i < n; ++i ) {
    cin >> p2;
    lf c = ccw( p2, p0, p1 );
    if( c == 1 ) {
      cout << "COUNTER_CLOCKWISE\n";
    }
    else if( c == -1 ) {
      cout << "CLOCKWISE\n";
    }
    else {
      if( segContains( p2, p0, p1 ) ) {
        cout << "ON_SEGMENT\n";
      }
      else if( segContains( p0, p1, p2 ) ) {
        cout << "ONLINE_BACK\n";
      }
      else if( segContains( p1, p0, p2 ) ) {
        cout << "ONLINE_FRONT\n";
      }

    }
  }
}

Measured memory_bytes: 3280
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
#import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def prime_factorize1(N):
        """
        Nをくって、Nの素因数を格納したリストresを返す。
        リストの要素をすべて掛ければNになる"""
        res = []
        x = N
        y = 2
        while y*y <= x:
            while x % y == 0:
                res.append(y)
                x //= y
            y += 1
        if x > 1:
            res.append(x)
        return res

    n=int(input())
    mod=10**9+7
    ans=[]
    for i in range(1,n+1):
        ans.extend(prime_factorize1(i))
    ans=Counter(ans)
    cnt=1
    for j in ans.values():
        cnt*=(j+1)
    print(cnt%mod)





resolve()

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	
	sort(a,a + 3);
	
	if(a[0] + a[1] == a[2]) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long int ll;
#define loop(a,b) for(int i=a;i<b;i++)
#define say(a) cout<<a<<endl
#define say2(a,b) cout<<a<<" "<<b<<endl;
ll mod =1e9+7;
using namespace std;

int main()
{
   int n;
   scanf("%d",&n);
   double a[n+2],s=0;
   loop(0,n) {scanf("%lf",&a[i]);}
   sort(a,a+n);
   s=a[0]+a[1];
   s=s/2;
   loop(2,n) {s=(s+a[i])/2;}
   say(s);
}


Measured memory_bytes: 256
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if len(ss) > 1 else [ss]
def Is(): return _Is(I())
 
x = I()
print('Yes' if x >= 30 else 'No')

Measured memory_bytes: 27164
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a[101], res = 1<<30;

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	reps(i,-100,101) {
		int t = 0;
		rep(j,n) t += (i-a[j])*(i-a[j]);
		chmin(res, t);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,string> pip;
typedef vector<pip> vip;
const int inf=2*1e9+1;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	ll x=0,y=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		y+=a[i];
	}
	x+=a[0];
	y-=a[0];
	ll res=INF;
	for(int i=1;i<n;i++){
		res=min(res,abs(x-y));
		x+=a[i];
		y-=a[i];
	}
	cout<<res<<endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

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

	vector<int> l(m);
	vector<int> r(m);

	for (int i = 0; i < m; i++)
	{
		cin >> l[i] >> r[i];
	}


	int left = l[0];
	int right = r[0];

	for (int i = 1; i < m; i++)
	{
		if (left < l[i]) left = l[i];
		if (right > r[i]) right = r[i];
	}

	if (right - left + 1 < 0) cout << 0 << endl;
	else cout << right - left + 1 << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    if(N % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    rep(i, N / 2){
        if(S[i] != S[i + N / 2]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

int main() 
{
    int n, sum=0;
    cin >> n;
    for (int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        sum += x;
    }
    cout << sum - n;
    return 0;
}

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

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);

    int i = 0, s = 0, d = 0;
    for(i = 0; i < n-1; i += 2)
        s += a[i+1] - a[i];
    for(i = 1; i < n-1; i += 2)
        d += a[i+1] - a[i];    
    
    if(n&1) {
        s += a[n-1];
        d += a[0];
    }  
    else {
        d += a[n-1] - a[0];
    }
    
    cout << min(d,s) ;
    return 0;
}

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

int main(void)
{
  int h[100]={1},w[100]={1};
  int k=0;
  do{
    k = k+1;
    cin >> h[k] >> w[k];
  }while(h[k] != 0 && w[k] != 0);

  k=1;
  while(h[k] != 0 && w[k] != 0){
    for(int i=1; i<=h[k]; i++){
      for(int j=1; j<=w[k]; j++){
        cout << "#";
      };
      cout << endl;
    };
    k = k+1;
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<int>> d(N,vector<int>(D));
  rep(i,N){
    rep(j,D) cin>>d[i][j];
  }
  int ans=0;
  double ja=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ja=0;
      for(int k=0;k<D;k++){
        ja+=(d[i][k]-d[j][k])*(d[i][k]-d[j][k]);
      }
      ja=sqrt(ja);
      for(int k=1;k<=126;k++){
        if(ja==k){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;


vll calc(ll x){
  vll v;
  for (int l=0;l<100;l++){
    ll c=x%2;
    v.push_back(c);
    x/=2;
  }
  return v;
}


vll counter(vll x){
  ll N=x.size();
  vll cnt(100);
  for (int l=0;l<100;l++){
    cnt[l]=0;
  }
  for(ll i=0;i<N;i++){
    vll v=calc(x[i]);
    for(ll l=0;l<100;l++){
      cnt[l]+=v[l];
    }
  }
  
  return cnt;
}


int main(){
  ll N,K;cin>>N>>K;
  vll x;
  for(ll i=0;i<N;i++){
    ll a;cin>>a;
    x.push_back(a);
  }

  vll count=counter(x);
  vll bin_K=calc(K);

  ll X=0;
  int flag=0;
  for(int l=99;l>=0;l--){
    int X_l=0;
    if((flag==1)||(bin_K[l]==1)){
      if((N%2==1)&&(count[l]==N/2)){
        X+=pow(2,l);
        X_l=1;
      }
      else if(count[l]<N/2){
        X+=pow(2,l);
        X_l=1;
      }
    }

    if (X_l!=bin_K[l]){
      flag=1;
    }
  }

  ll ans=0;
  for (ll i=0;i<N;i++){
    ans+=X^x[i];
  }
  cout << ans;
  return 0;
}


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

const long long MAXN = 1e5 + 5;

long long dp[105][MAXN];
long long val[105][2];

long long N, W;

long long compute(long long pos, long long wt)
{
    if (pos == N or wt <= 0)
        return 0;

    if (dp[pos][wt] != -1)
        return dp[pos][wt];

    long long max_val = compute(pos + 1, wt);

    if (wt - val[pos][0] >= 0)
        max_val = max(max_val, val[pos][1] + compute(pos + 1, wt - val[pos][0]));

    return dp[pos][wt] = max_val;
}

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

    cin >> N >> W;

    memset(dp, -1LL, sizeof dp);

    for (long long i = 0; i < N; ++i)
        cin >> val[i][0] >> val[i][1];

    cout << compute(0, W) << '\n';

    return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)

int main(){
    string str;cin>>str;
    cout<<str.front()<<str.size()-2<<str.back()<<endl;
    return 0;
}



Measured memory_bytes: 384
n = int(input())
ns = map(int, input().split())
four = [0, 0, 0, 0]
for i in ns:
    four[i%4] += 1
if four[2] == 0 and n - 1 - 2*four[0] <= 0:
    print('Yes')
elif n - four[2] - 2*four[0] <= 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11096
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int c = stoi(a+b);
    int i ;
    for (i = 1; i < 1000; i++) {
        if (c == i*i) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  cout << (1000 - (n % 1000)) % 1000 << endl;
  return 0;
}

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

int main() {
	int x = 0, y = 0;
	int coin = 0;
	cin >> x >> y;

	if (x > y) {
		coin += x;
		x -= 1;
	}
	else {
		coin += y;
		y -= 1;
	}

	if (x > y) {
		coin += x;
		x -= 1;
	}
	else {
		coin += y;
		y -= 1;
	}
	cout << coin << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int R(int i,int S,int A,int C){
  if(i == 0) return S;
  return (A * R(i-1,S,A,C) + C) % 256;
}

int O(int* I,int i,int S,int A,int C){
  return (I[i] + R(i,S,A,C)) % 256;
}

double H(int* freq,int N){
  double sum = 0.0;
  for(int i=0;i<256;i++){
    if(freq[i] == 0) continue;
    sum += ((double)freq[i]/(double)N)*log((double)freq[i]/(double)N);
    // printf("%lf\n",sum);
    // printf("%lf\n",((double)freq[i]/(double)N)*log((double)freq[i]/(double)N));
  }
  return -sum;
}

int main(){
  int freq[256];
  int I[320];
  int N;

  while(~scanf("%d",&N)){
    if(N==0) break;

    for(int i=1;i<=N;i++){
      scanf("%d",I+i);
    }

    double min_H = 100000.0;
    int res_S = 0;
    int res_A = 0;
    int res_C = 0;
    for(int S=0;S<=15;S++){
      for(int A=0;A<=15;A++){
	for(int C=0;C<=15;C++){
	  memset(freq,0,sizeof(freq));
	  for(int i=1;i<=N;i++){
	    // printf("i=%d I[i]=%d S=%d A=%d C=%d O=%d\n",i,I[i],S,A,C,O(I,i,S,A,C));
	    freq[O(I,i,S,A,C)]++;
	  }
	  double tmp_H = H(freq,N);
	  if(min_H > tmp_H + EPS){
	    // printf("%lf\n",tmp_H);
	    min_H = tmp_H;
	    res_S = S;
	    res_A = A;
	    res_C = C;
	  }
	}
      }
    }
    printf("%d %d %d\n",res_S,res_A,res_C);
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    int kai=INF;
    rep(i,n){
        cin>>a[i];
        kai=min(kai,a[i]);
    }
    rep(i,n){
        if(a[i]==kai){
            cout<<i+1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3892