akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")

#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

signed main()
{
    #ifdef __APPLE__
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<"\n";
}


Measured memory_bytes: 3616
import java.io.*;
public class Main{
  public static void main(String args[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 25204
#include <bits/stdc++.h>
using namespace std;
int block; 
struct que { 
    int L, R;
    int ind; 
}; 
bool comp(que x, que y) 
{ 
    if (x.L/block != y.L/block) 
        return x.L/block < y.L/block; 
    return x.R < y.R; 
} 
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, q;
    cin>>n>>q;
    vector<int> a(n);
    for(int i = 0; i<n; i++) cin>>a[i], a[i]--;
    block = sqrt(n);
    vector<que> qs(q);
    for(int i = 0; i< q; i++) {
        cin>>qs[i].L>>qs[i].R;
        --qs[i].L, --qs[i].R;
        qs[i].ind = i;
    }
    sort(qs.begin(), qs.end(), comp);
    int cont[500000];
    fill(cont, cont+n, 0);
    int ans = 0;
    que cur = {0,0,0};
    vector<int> res(q);
    for(int i = 0; i< q; i++){
        int l = qs[i].L;
        int r = qs[i].R;
        while(cur.L > l){
            if(cont[a[cur.L-1]]++ == 0) ans++;
            --cur.L;
        }        
        while(cur.L < l){
            if(cont[a[cur.L]]-- == 1) ans--; 
            ++cur.L;
        }
        while(cur.R > r+1){
            if(cont[a[cur.R-1]]-- == 1) ans--;
            --cur.R;
        }
        while(cur.R <= r){
            if(cont[a[cur.R]]++ == 0) ans++;
            ++cur.R;
        }

        res[qs[i].ind] = ans;
    }
    for(auto i: res) cout<<i<<"\n";
}


Measured memory_bytes: 15484
#include <stdio.h>

#define NOT_FOUND -1
#define MAX 100001

int n, q;
int A[MAX], T[MAX];

int binarySearch(int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key)
      return mid;
    else if (key < A[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return NOT_FOUND;
}

int main() {
  scanf("%d", &n);
  int j;
  for (j = 0; j < n; j++) {
    scanf("%d", A + j);
  }
  scanf("%d", &q);
  int key, count = 0;
  while (q--) {
    scanf("%d", &key);
    if (binarySearch(key) != NOT_FOUND)
      count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 996
using System;
using System.Collections.Generic;

class Program
{
      public static int CountChar(string s, char c) {
    return s.Length - s.Replace(c.ToString(), "").Length;
  }
	static void Main(string[] args)
	{
        /*
		// 整数の入力
		int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
		// 文字列の入力
		string s = Console.ReadLine();
		//出力
		Console.WriteLine((a+b+c) + " " + s);
        */

        //System.Console.WriteLine(CountChar(Console.ReadLine(), '1'));

        int n = int.Parse(Console.ReadLine());
        SortedList<int, int> data = new SortedList<int, int>();
        for (int i = 0; i < n; i++){
            string[] d = Console.ReadLine().Split(' ');
            int r = int.Parse(d[0]);
            int p = int.Parse(d[1]);
            data.Add(r, p);
        }

        var num = 0;
        var index = 0;
        var point = 10000000000;
        KeyValuePair<int, int> pre = new KeyValuePair<int, int>();
        foreach (var d in data)
        {
            num += d.Key - index;
            index = d.Key;
            pre = d;
        }

        Console.WriteLine(num + pre.Value);
	}
}

Measured memory_bytes: 19404
#include <bits/stdc++.h>
using namespace std;
#define INF 1e7
string a,b;
int n;
pair<string,string> s[50];

string rep(string s1,string s2,string s3){
  string::size_type p = s1.find(s2);
  while(p!=string::npos){
    s1 = s1.replace(p,s2.size(),s3);
    p = s1.find(s2,p+s3.size());
  }
  return s1;
}


int rec(string ns,int d){
  if(ns.size()>b.size()) return INF;
  if(ns==b)return d;
  int res = INF;
  for(int i=0;i<n;i++){
    string ss = rep(ns,s[i].first,s[i].second);
    if(ss==ns) continue;
    res = min(res,rec(ss,d+1));
  }
  return res;
}

int main(){
  while(cin>>n && n){
    for(int i=0;i<n;i++)
      cin>>s[i].first>>s[i].second;
    cin>>a>>b;
    int ans = rec(a,0);
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 1e5 + 10;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

char ss[N];
int fa[N], v[N];

I int findfa(cr x) {return fa[x] == x ? x : fa[x] = findfa(fa[x]);}

int main() {
	scanf("%s", ss + 1);
	reg n = strlen(ss + 1);
	fo(i, 1, n) fa[i] = i, ss[i] -= 'a';
	fa[n + 1] = n + 1;
	reg m = read();
	fo(i, 1, m) {
		reg l = read(), r = read();
		fa[findfa(l)] = findfa(r + 1);
	} fo(i, 1, n + 1 >> 1) fa[findfa(i)] = findfa(n - i + 2);
	fo(i, 1, n + 1) v[i] = ss[i] - ss[i - 1];
	fo(i, 1, n + 1) if(fa[i] ^ i) v[findfa(i)] += v[i];
	fo(i, 1, n + 1) if(fa[i] == i && v[i] % 26) {puts("NO"); return 0;}
	puts("YES");
	return 0;
}



Measured memory_bytes: 1152
#include<stdio.h>
int main(){
int a[6],b[6],c[6],in_a,in_b,in_c,out_a,out_b,out_c,sum_a,sum_b,sum_c,ah,am,as,bh,bm,bs,ch,cm,cs;
scanf("%d %d %d %d %d %d\n%d %d %d %d %d %d\n%d %d %d %d %d %d\n",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&b[0],&b[1],&b[2],&b[3],&b[4],&b[5],&c[0],&c[1],&c[2],&c[3],&c[4],&c[5]);
in_a = a[0]*3600+a[1]*60+a[2];
in_b = b[0]*3600+b[1]*60+b[2];
in_c = c[0]*3600+c[1]*60+c[2];
out_a = a[3]*3600+a[4]*60+a[5];
out_b = b[3]*3600+b[4]*60+b[5];
out_c = c[3]*3600+c[4]*60+c[5];
sum_a = out_a - in_a;
sum_b = out_b - in_b;
sum_c = out_c - in_c;
ah=sum_a/3600;
am=(sum_a%3600)/60;
as=(sum_a%3600)%60;
bh=sum_b/3600;
bm=(sum_b%3600)/60;
bs=(sum_b%3600)%60;
ch=sum_c/3600;
cm=(sum_c%3600)/60;
cs=(sum_c%3600)%60;
printf("%d %d %d\n%d %d %d\n%d %d %d\n",ah,am,as,bh,bm,bs,ch,cm,cs);
return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vb vector< bool >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sort(a) sort(a.begin(),a.end())
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define moddd (1000*1000*1000+9)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
//cout<<fixed<<setprecision(15)<<ans;
 
template <typename T>
void printvec(vector<T>& vec){
	for(int i=0;i<vec.size();i++){
		cout<<vec[i]<<" ";
	}
	cout<<endl;
}

int main(){
	std::ios::sync_with_stdio(false); 
	int ttt=1;
	//cin>>ttt;
	while(ttt--){
		int n,i;
		cin>>n;
		vi arr(n),rarr(n+1,0);
		for(i=0;i<n;i++){
			cin>>arr[i];
			rarr[arr[i]]=i+1;
		}
		int maxx=0,curr=0;
		for(i=1;i<=n;i++){
			if(rarr[i]>rarr[i-1]) curr++;
			else curr=1;
			if(maxx<curr) maxx=curr;
		}
		cout<<n-maxx;
	}
	return 0;
} 
 


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	for(int i=0;i<X;i++){
		cin >> A[i];
	}
	for(int i=0;i<Y;i++){
		cin >> B[i];
	}
	for(int i=0;i<Z;i++){
		cin >> C[i];
	}
	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());
	vector<ll> ans;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			for(int k=0;k<Z;k++){
				if((i+1) * (j+1) * (k+1) > K) break;
				ans.push_back(A[i] + B[j] + C[k]);
			}
		}
	}
	sort(ans.rbegin(), ans.rend());
	for(int i=0;i<K;i++){
		cout << ans[i] << endl;
	}
}

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

int main() {
    int N,Q;cin >> N >> Q;
    string S;cin >> S;
    int V[N] = {};V[0] = 0;
    for (int i = 1;i < N;i++){
        int flag = 0;
        if (S[i] == 'C'){
            if (S[i - 1] == 'A') flag = 1;
        }
        if (flag == 0) V[i] = V[i - 1];
        else V[i] = V[i - 1] + 1;
    }

    for (int i = 0;i < Q;i++){
        int l,r;cin >> l >> r;
        cout << V[r - 1] - V[l - 1] << endl;
    }
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextLong());
		}
		Set<Integer> deta = new HashSet<>();
		Set<Integer> yoi = new HashSet<>();
		Set<Integer> warui = new HashSet<>();
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			deta.add(a);
			deta.add(b);
			if (list.get(a - 1) > list.get(b - 1)) {
				if (!warui.contains(a)) {
					yoi.add(a);

				}
				yoi.remove(b);
				warui.add(b);
			} else if (list.get(a - 1) < list.get(b - 1)) {
				if (!warui.contains(b)) {
					yoi.add(b);

				}
				yoi.remove(a);
				warui.add(a);
			} else {
				yoi.remove(b);
				yoi.remove(a);
				warui.add(a);
				warui.add(b);
			}
		}
		int count = n - deta.size();
		System.out.println(count + yoi.size());

		sc.close();
	}

}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b;
  cin >> a >> b;
  cout << a - b + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL rou(LL a,LL d){if((a*10/d)%10<5)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}

void gra(double* gx,double* gy,LL x1,LL y1,LL x2,LL y2,LL x3,LL y3){*gx=(x1+x2+x3)/3.0,*gy=(y1+y2+y3)/3.0;}
void out(double* ox,double* oy,LL x1,LL y1,LL x2,LL y2,LL x3,LL y3){LL a=x1*x1+y1*y1,b=x2*x2+y2*y2,c=x3*x3+y3*y3,d=x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);if(d==0)*ox=(MAX(x1,MAX(x2,x3))+MIN(x1,MIN(x2,x3)))/2.0,*oy=(MAX(y1,MAX(y2,y3))+MIN(y1,MIN(y2,y3)))/2.0;else *ox=(a*(y2-y3)+b*(y3-y1)+c*(y1-y2))/(2.0*d),*oy=(a*(x3-x2)+b*(x1-x3)+c*(x2-x1))/(2.0*d);}
void inn(double* ix,double* iy,LL x1,LL y1,LL x2,LL y2,LL x3,LL y3){double a=(x1-x3)*(x1-x3),b=(x2-x1)*(x2-x1),c=(x3-x2)*(x3-x2),d=(y1-y3)*(y1-y3),e=(y2-y1)*(y2-y1),f=(y3-y2)*(y3-y2),g=sqrt(c+f),h=sqrt(a+d),i=sqrt(b+e),j=g+h+i;if(x1==x2&&x2==x3&&y1==y2&&y2==y3)*ix=x1,*iy=y1;else *ix=(g*x1+h*x2+i*x3)/j,*iy=(g*y1+h*y2+i*y3)/j;}
void hoh(double* hx,double* hy,LL x1,LL y1,LL x2,LL y2,LL x3,LL y3){LL d=x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);if(d!=0)*hx=((x1*x2+y3*y3)*(y2-y1)+(x2*x3+y1*y1)*(y3-y2)+(x3*x1+y2*y2)*(y1-y3))/(double)d,*hy=((y1*y2+x3*x3)*(x1-x2)+(y2*y3+x1*x1)*(x2-x3)+(y3*y1+x2*x2)*(x3-x1))/(double)d;}
int dcmp(double a,double b,LL n){
  LL A=a*pow(10,n),B=b*pow(10,n);
  if(A>B)return 1;
  if(A<B)return -1;
  return 0;
}

int main(){
  LL N,i,j,k,l,flag;
  double ans=1000000.0,nx,ny,r;
  scanf("%lld",&N);
  LL x[N],y[N];
  FOR(i,0,N)scanf("%lld%lld",&x[i],&y[i]);
  FOR(i,0,N)FOR(j,i+1,N){
    flag=0;
    nx=(x[i]+x[j])/2.0,ny=(y[i]+y[j])/2.0;
    r=sqrt((nx-x[i])*(nx-x[i])+(ny-y[i])*(ny-y[i]));
    if(ans<=r)continue;
    FOR(l,0,N)if(r<sqrt((nx-x[l])*(nx-x[l])+(ny-y[l])*(ny-y[l])))flag=1;
    if(flag==0)ans=r;
  }
  FOR(i,0,N)FOR(j,i+1,N)FOR(k,j+1,N){
    flag=0;
    out(&nx,&ny,x[i],y[i],x[j],y[j],x[k],y[k]);
    r=sqrt((nx-x[i])*(nx-x[i])+(ny-y[i])*(ny-y[i]));
    if(ans<=r)continue;
    FOR(l,0,N)if(r<sqrt((nx-x[l])*(nx-x[l])+(ny-y[l])*(ny-y[l])))flag=1;
    if(flag==0)ans=r;
  }

  printf("%.16f\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 10000
 
int main(void){
  int i,c,sf,num,j,k,l;
  char n[11];
  int seq[11],ans[N];
  char hoge;
 
  for(i=0;;i++){
    c=scanf(" %s",n);
    if(c==EOF){
      break;
    }
 
    for(j=0;j<10;j++){
      seq[j]=n[j]-'0';
    }
 
    for(j=0;j<9;j++){
      for(k=0;k<9-j;k++){
        seq[k]=(seq[k]+seq[k+1])%10;
      }
    }
    ans[i]=seq[0];
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

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

// http://codeforces.com/contest/280/submission/3275327

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    // if (abs(a-b)<EPS) return 0;
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

double area(const G& g) {
  double A = 0;
  for (int i = 0; i < g.size(); ++i) {
    A += cross(g[i], next(g, i));
  }
  return abs(A/2);
}

int main(){
    int t = 1;
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        G g;
        for(int i=0;i<n;i++){
            int x, y;
            scanf("%d%d", &x, &y);
            g.emplace_back(x, y);
        }
        printf("%d %.1f\n", t++, area(g));
    }
    return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m; cin>>n>>m;
    int a,sum=0; for(int i=0;i<m;i++){
        cin>>a; sum+=a;
    }
    sum<=n?cout<<n-sum:cout<<"-1";
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int g = 0, p = 0, win = 0, lose = 0;
    rep(i, 0, s.size()) {
        if (p < g) {
            if (s[i] == 'g') {
                win++;
                p++;
            } else {
                p++;
            }
        } else {
            if (s[i] == 'p') {
                lose++;
            }
            g++;
        }
    }
    cout << win - lose << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 998244353
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

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

const int dx8[] = {-1, 0, 1, 0,1,1,-1,-1};
const int dy8[] = {0, -1, 0, 1,1,-1,1,-1};


//unordered_map<ll,ll> m1 ;
void solve()
{

   ll n ;
   cin >> n ;
   vector<ll> arr(n+1,1) ;
   for(ll i=1 ;i<=n ;i++)
   {
       for(ll j=i*2 ;j<=n;j+=i)
        arr[j]++;


   }
   ll ans=0 ;
   for(ll j=1 ;j<n;j++) ans+=arr[j];
   cout <<ans << endl;
 }


// cout << arr2[n-1]<< endl;





int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   solve();
}


Measured memory_bytes: 11084
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll f[N+1];
ll b[N+1];
ll finds(ll x){
    if(f[x]!=x)
        f[x]=finds(f[x]);
    return f[x];
}
void uni(ll x,ll y){
    ll x1=finds(x);
    ll y1=finds(y);
    ll a=min(x1,y1);
    ll b=max(x1,y1);
    f[b]=f[a];

}
int main(){
    for(int i=1; i<N; i++){
        f[i]=i;
    }
    int n,m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int x,y;
        cin>>x>>y;
        uni(x,y);
    }
    ll maxs=-99999;
    for(int i=1; i<=n; i++){
        b[finds(i)]++;
    }
    for(int i=1; i<=n; i++){
        maxs=max(maxs,b[i]);
    }
    cout<<maxs<<endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  K--;
  S[K] = S[K] - 'A' + 'a';
  cout << S << '\n';
  return 0;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

ans = 0
for delim1 in range(0, N + 1):
    for delim2 in range(delim1, N + 1):
        left = delim1
        middle = delim2 - delim1
        right = N - delim2
        if left % R == 0 and middle % G == 0 and right % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 41308
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program{
    public static void Main(){
        int a = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int b = int.Parse(Console.ReadLine());
        int[] B = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        string sa = "";
        string sb = "";
        for(int i=0; i<a; i++){
            sa += A[i].ToString();
        }
        for(int i=0; i<b; i++){
            sb += B[i].ToString();
        }
        int ans = String.Compare(sa,sb) < 0 ? 1 : 0;
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 25380
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];

    for (int i = n-2; i >= 0; --i) {
        if (h[i+1]<h[i]) h[i]--;
    }

    bool ok = true;

    rep(i,n-1) {
        if (h[i]>h[i+1]) ok=false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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); }

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

  int n;
  cin >> n;
  vector<P> v(n);
  rep(i, 0, n) {
    int x, l;
    cin >> x >> l;
    v[i] = make_pair(x - l, x + l);
  }
  sort(v.begin(), v.end());

  int ans = 0;
  P now = v[0];
  rep(i, 1, n) {
    if (v[i].first < now.second) {
      ans++;
      if (v[i].second < now.second) {
        now = v[i];
      }
    } else {
      now = v[i];
    }
  }

  cout << n - ans << endl;
}


Measured memory_bytes: 3928
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

struct UnionFind {
  // d[i] = 頂点番号iの親（の番号）
  // マイナスなら根（かつ、サイズ * -1 を示す（そうすると配列一つですむ））
  vector<int> d;

  // コンストラクタ
  // 頂点n個で初期化。最初は全部に根するので-1
  UnionFind(int n = 0) : d(n, -1) {}

  // 親の番号を返す
  int find(int x) {
    if (d[x] < 0) return x;  // 根ならそのまま頂点番号返す

    return d[x] = find(
               d[x]);  // 根じゃないなら親を返す（かつ計算量を削減のためメモ化する）
  }

  // 木と木をくっつける
  bool unite(int x, int y) {
    x = find(x);  // xの親の番号
    y = find(y);  // yの親の番号

    if (x == y) return false;  // 親が同じなら何もする必要はない

    // x のほうがサイズを大きくしたい
    if (-d[x] < -d[y]) swap(x, y);  // （*-1のサイズなので注意）

    // 小さいほうの木（y）を大きい方（x）にくっつける
    d[x] += d[y];
    d[y] = x;

    return true;
  }

  // 同じグループか
  bool same(int x, int y) { return find(x) == find(y); }

  // 頂点xのサイズ
  int size(int x) { return -d[find(x)]; }
};

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

  ll n, m;
  cin >> n >> m;
  vector<ll> x(m), y(m), z(m), a(n);
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i] >> z[i];
    x[i]--;
    y[i]--;
    a[x[i]]++;
    a[y[i]]++;
  }

  ll ans = count_if(all(a), [](ll v) { return v == 0; });

  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    uf.unite(x[i], y[i]);
  }

  set<ll> st;
  for (int i = 0; i < m; i++) {
    st.insert(uf.find(x[i]));
  }

  ans += st.size();

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M = 1e6 + 10;
int n, cnt, ans;
bool a[M],st[M];
int main()
{
    string s;
    cin>>s; n = s.length();
    for (int i = 0; i < n; i++)
        a[i] = s[i] - '0';
    for (int i = 0; i < n; i++)
    {
        if (cnt && (st[cnt-1] ^ a[i]) == 1)
            cnt--, ans += 2;
        else
            st[cnt++] = a[i];
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
n = gets.to_i
cnt = 0

(1..n).each do |i|
  a,b = gets.split(" ").map(&:to_i)

  if a == b
    cnt += 1
  else
    cnt = 0
  end
  
  if cnt == 3
    puts "Yes"
    exit
  end
  
end

puts "No"

Measured memory_bytes: 14372
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N;
    cin >> N;

    bool ok = false;

    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            int acc = i * 4 + j * 7;
            if (acc == N) {
                ok = true;
            }
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	vector<int> a(5);
	int k;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	sort(a.begin(), a.end());

	if (abs(a[4] - a[0]) > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
(function(stdin){
  var input = stdin.split("\n");
  var n = parseInt(input[0], 10);
  var a = input[1].split(" ");

  for (var i = 0; i < n; i++) {
    a[i] = parseInt(a[i], 10);
  }

  var ans = 1;
  var up = false;
  var down = false;
  for (var i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      up = true;
    }

    if (a[i] > a[i + 1]) {
      down = true;
    }

    if (up && down) {
      up = false;
      down = false;
      ans++;
    }
  }

  console.log(ans);
})(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17612
#include <cmath>
#include <climits> /* LLONG_MAX */

#include <string>
#include <vector>
#include <numeric> /* gcd, lcm, partial_sum, reduce*/
#include <iomanip> /* setprecision */
#include <iostream>
#include <algorithm>

using ll = long long; // c++11

const std::string ans[2] = { "No\n", "Yes\n" };

int main() {
    using namespace std;
    int n, m;
    cin >> n >> m;
    cout << ans[n == m] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 100010;
LL a[Maxn], n;
LL _max(LL x, LL y) { return x > y ? x : y; }
int main() {
	LL i, j, k;
	scanf("%lld", &n);
	for(i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sort(a+1, a+n+1);
	LL ans = 0;
	LL L = 1, R = n;
	while(R-L+1 > 3){
		ans += 2*(a[R]-a[L]);
		L++; R--;
	}
	if(R-L == 1) ans += a[R]-a[L];
	else ans += _max(a[R]+a[R-1]-2*a[L], 2*a[R]-a[L]-a[L+1]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int len_array;
    scanf("%d",&len_array);
    vector<int> int_array(len_array);
    for(int i = 0; i< len_array;i++){
        cin >> int_array[i];
    }
    vector<int>::iterator results = unique(int_array.begin(),int_array.end());
    
    for(vector<int>::iterator itr = int_array.begin();itr != results; itr++){
        cout << *itr;
        if(itr != results-1) cout << " ";
        else cout << "\n";
    }
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    string s;
    //int ans;

    int max = 0, combo = 0;

    cin>>s;

    REP(i,s.size())
    {
        switch (s[i])
        {
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            combo++;
            if (max < combo) 
                max = combo;
            break;
        default:
            combo = 0;
            break;
        }
    }
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
#include<cassert>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 10
#define INFTY (1 << 21)
map<string, int> M;

class Cube{
public:
  string f;
  Cube(){ f = "123456"; }
  void roll_left(){ roll(0, 2, 5, 3);}
  void roll_back(){ roll(0, 1, 5, 4);}
  void roll_right(){ rep(i, 3) roll_left(); }
  void roll_front(){ rep(i, 3) roll_back(); }
  void roll(int i, int j, int k, int l){
    char t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
};

class State{
public:
  int i, j, cost;
  Cube c;
  State(int i=0, int j=0, Cube c=Cube(), int cost=0): i(i), j(j), c(c), cost(cost){}
  bool operator < ( const State &s) const{ return cost > s.cost; }
};

int dijkstra(int H, int W, int G[MAX][MAX], int si, int sj, int gi, int gj){
  Cube s = Cube();
  bool visited[MAX][MAX][24];
  int d[MAX][MAX][24];
  priority_queue<State> PQ;

  rep(i, H) rep(j, W) rep(k, 24){
    visited[i][j][k] = false;
    d[i][j][k] = INFTY;
  }

  PQ.push(State(si, sj, s, 0));
  d[si][sj][M[s.f]] = 0;

  State u, v;
  while(!PQ.empty()){
    u = PQ.top(); PQ.pop();
    if ( u.i == gi && u.j == gj ) return u.cost;
    Cube cube = u.c;
    int c = M[cube.f];
    if ( visited[u.i][u.j][c] ) continue;
    visited[u.i][u.j][c] = true;

    int ni, nj;
    rep(r, 4){
      v = u;
      ni = u.i;
      nj = u.j;
      if ( r == 0 && u.j < W-1 ) { v.c.roll_right(); nj++; }
      if ( r == 1 && u.i >= 1 ) { v.c.roll_back(); ni--; }
      if ( r == 2 && u.j >= 1 ) { v.c.roll_left(); nj--; }
      if ( r == 3 && u.i < H-1) { v.c.roll_front(); ni++; }
      v.i = ni;
      v.j = nj;
      int cost = G[ni][nj] * (v.c.f[5]-'0') + u.cost;
      int nc = M[v.c.f];
      if ( d[ni][nj][nc] > cost ){
	d[ni][nj][nc] = cost;
	v.i = ni;
	v.j = nj;
	v.cost = cost;
	PQ.push(v);
      }
    }
  }
  return -1;
}

void init(){
  string t[24] = {"123456","135246","154326","142536","326154","365214","351624","312564","246135","263415","231645","214365","645231","653421","632541","624351","415263","456123","462513","421653","513462","536142","564312","541632"};
  rep(i, 24) M[t[i]] = i;
}

main(){
  init();
  int H, W, G[MAX][MAX], si, sj, gi, gj;
  while(1){
    cin >> H >> W;
    if ( H == 0 && W == 0 ) break;

    rep(i, H) rep(j, W) cin >> G[i][j];
    rep(i, H) rep(j, W) assert( 0 <= G[i][j] && G[i][j] <= 9 );
    cin >> si >> sj >> gi >> gj;
 
    cout << dijkstra(H, W, G, si, sj, gi, gj) << endl;
  }
}

Measured memory_bytes: 0
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) r1eturn cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e8, M = 1000007, P = 6151, sq = 1e3, lg = 60;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
	use_fast;
	int n, sum = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		for(int j = 1; j < i; j++) 
			sum += a[i] * a[j];
	}
	cout << sum << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int n,k;cin>>n>>k;
    int h[n];
    inpar0(h);
    int dp[n];
    for(int i=1;i<n;i++){
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=1;j<=k;j++){
            if(i+j<n)
            dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
        }
    }
//    showar0(dp)cout<<endl;
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
def check(dx, dy):
    cut_A = [[] for _ in range(M)]
    for i in range(dx, dx + M):
        for j in range(dy, dy + M):
            cut_A[i-dx].append(A[i][j])
    return cut_A == B

for dx in range(N-M+1):
    for dy in range(N-M+1):
        if check(dx, dy):
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] p=new int[n];
		for(int i=0;i<n;i++){
			p[i]=sc.nextInt();
		}
		int[] a=new int[n];
		int[] b=new int[n];
		for(int i=0;i<n;i++){
			a[i]=i+1;
			b[i]=n-i;
		}
		for(int i=0;i<n;i++){
			for(int j=p[i];j<=n;j++){
				a[j-1]+=i;
			}
			for(int j=1;j<=p[i];j++){
				b[j-1]+=i;
			}
		}
		
		for(int i=0;i<n-1;i++){
			System.out.print(a[i]+" ");
		}
		System.out.println(a[n-1]);
		for(int i=0;i<n-1;i++){
			System.out.print(b[i]+" ");
		}
		System.out.println(b[n-1]);
	}
	
}

Measured memory_bytes: 44564
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int L, H;
  while(cin>>L>>H,L){
    int S = (1<<L)-1;
    vector<int> ans;
    bool used[1000][10] = {};
    vector<string> vs(H);
    vector<int> hit(H);
    vector<int> brow(H);
    REP(i,H){
      cin>>vs[i]>>hit[i]>>brow[i];
      REP(j,vs[i].size())used[i][vs[i][j]-'0'] = true;
    }
    while(S < 1<<10){
      vector<int> digit;
      REP(i,10)if(S >> i & 1)digit.push_back(i);
      REP(i,H){
        int hb = 0;
        REP(j,10)if(used[i][j] && S >> j & 1)hb++;
        if(hit[i] + brow[i] != hb){
          goto NEXT;
        }
      }
      do{
        bool ok = true;
        REP(i,H){
          int h = 0;
          REP(j,L)if((vs[i][j]-'0') == digit[j])h++;
          if(hit[i] != h){
            ok = false;
            break;
          }
        }
        if(ok){
          if(ans.size() > 0){
            ans = vector<int>();
            goto OUTPUT;
          }else{
            ans = digit;
          }
        }
      }while(next_permutation(digit.begin(), digit.end()));
      NEXT:
      int x = S & -S, y = S + x;
      S = ((S & ~y) / x >> 1) | y;
    }
OUTPUT:
    if(ans.size() > 0) { REP(i,ans.size()){cout<<ans[i];} cout<<endl; }
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 936
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

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

int main()
{
	int N = 0;
	int i = 0, ans = 0;
	scanf("%d", &N);
	for (i = 1; i < 10; i++) {
		int j = 0;
		j = N/i;
		if (((i * j) == N) && (j < 10))  {
			ans++;
		} else {
		}
	}
	if (ans != 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	vector<int>a(100), b, c;
	int n;
	cin >> n;
	int sum;
	map<int, int>mp;
	iota(all(a), 1);
	b = c = a;
	for (auto aa : a)for (auto bb : b)for (auto cc : c) {
		sum = aa * aa + bb * bb + cc * cc + aa * bb + aa * cc + bb * cc;
		if (sum > 10000)break;
		mp[sum]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << mp[i] << endl;
	}
	//for (auto m : mp)cout << m.first << ":" << m.second << endl;
}


Measured memory_bytes: 4008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        String[] strList = {"eraser", "erase", "dreamer", "dream"};
        for (String str : strList) {
            S = S.replace(str, "");
            if (S.isEmpty()) {
                System.out.print("YES");
                return;
            }
        }

        System.out.print("NO");

//        Scanner sc = new Scanner(System.in);
//        String S = sc.next();
//
//        S = S.replaceAll("eraser", "-");
//        S = S.replaceAll("erase", "-");
//        S = S.replaceAll("dreamer", "-");
//        S = S.replaceAll("dream", "-");
//        S = S.replaceAll("-", "");
//        if (S.length() == 0)
//            System.out.println("YES");
//        else
//            System.out.println("NO");
    }
}

Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long S){
    int ue = S/100;
    int shita = S%100;
    bool YYMM = false;
    bool MMYY = false;
    if(1 <= ue && ue <= 12){
        MMYY = true;
    }else{
        MMYY = false;
    }
    if(1 <= shita && shita <= 12){
        YYMM = true;
    }else{
        YYMM = false;
    }

    if(MMYY&&YYMM){
        cout << "AMBIGUOUS" << endl;
        return;
    }
    if(MMYY&&!YYMM){
        cout << "MMYY" << endl;
        return;
    }
    if(!MMYY&&YYMM){
        cout << "YYMM" << endl;
        return;
    }
    if(!MMYY&&!YYMM){
        cout << "NA" << endl;
        return;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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; }

//nの素因数を配列に格納する関数
vector<pair<ll,ll>> prime_factorization(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2; p*p<=n; p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){num++; n/=p;}
        res.push_back(make_pair(p,num));
    }

    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}


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

    ll res=0;
    ll N; cin>>N;
    auto pf = prime_factorization(N);
    for(auto p : pf){
        ll e = p.second;
        ll tmp =0, cur =1;
        while(e>=cur) {e -= cur++, tmp++;}
        res+=tmp;
    }

    cout<<res<<endl;


}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
	char a[999999];
	int n;
	int i, j;
	int count;
	
	while (scanf("%d", &n) != EOF){
		count = 0;
		for (i = 0; i <= n; i++){
			a[i] = 1;
		}
		a[0] = a[1] = 0;
		
		for (i = 2; i <= n; i++){
			if (a[i] == 1){
				for (j = i * 2; j <= n; j += i){
					a[j] = 0;
				}
			}
		}
		
		for (i = 0; i <= n; i++){
			if (a[i] == 1){
				count++;
			}
		}
		
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 1568
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++){
            ans += sc.nextInt() - 1;
        }
        System.out.println(ans);
    }
}




Measured memory_bytes: 26024
MOD = int(1e9 + 7)

s = input()
digits = len(s)

cnt = 0
for i, c in enumerate(reversed(s)):
    if c == '?':
        continue
    n = int(c) * pow(10, i, 13) % 13
    cnt += n
# print(cnt)

before = [0] * 13
first_time = True
for i, c in enumerate(reversed(s)):
    if c != '?':
        continue
    if first_time:
        for j in range(10):
            n = j * pow(10, i, 13) % 13
            before[n] += 1
        first_time = False
        continue
    current = [0] * 13
    for j in range(10):
        n = j * pow(10, i, 13) % 13
        current[n] += 1
    after = [0] * 13
    for j in range(13):
        for k in range(13):
            after[j] += before[k] * current[(13 - k + j) % 13]
        after[j] %= MOD
    before = after

if first_time:
    if cnt % 13 == 5:
        print(1)
    else:
        print(0)
else:
    print(before[(5 - (cnt % 13)) % 13])


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string s;
	cin >> s;
	int len = 0;
	for(int i = 0; i < 3; i++) {
		if(s[i] == 'R' && len == 0) {
			len += 1;
		}
		else if(s[i] == 'R' && s[i - 1] == 'R') {
			len += 1;
		}
	}
	cout << len;
	return 0;
}

Measured memory_bytes: 3648