akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vvi used;
vvi G;
int n,m,go[3];
void dfs(int a,int b){
	a++;
	if(a==110)return ;
	rep(i,G[b].size()){
		int to=G[b][i];
		if(used[a][to])continue;
		used[a][to]=true;
		dfs(a,to);
	}
}
int main(){
	cin>>n>>m>>go[0]>>go[1]>>go[2];
	G=vvi(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
	}
	vector<vvi>po(n,vvi(3));
	rep(i,n){
		used=vvi(110,vi(n));
		used[0][i]=true;
		dfs(0,i);
		rep(j,3)rep(k,n)if(used[go[j]][k])po[i][j].pb(k);
	}
//	rep(i,n){
//		rep(j,3){rep(k,po[i][j].size())cout<<" "<<po[i][j][k];cout<<endl;}
//		cout<<endl;
//	}
	vi ok(n);
	ok[n-1]=true;
	rep(i,110){
		vi nok=ok;
		rep(j,n)if(ok[j]==0){
			bool H=true;
			rep(k,3){
				bool h=false;
				rep(l,po[j][k].size())if(ok[po[j][k][l]])h=true;
				if(!h)H=false;
			}
		//	cout<<i<<" "<<j<<" "<<H<<endl;
			if(H)nok[j]=true;
		}
		ok=nok;
		if(ok[0]){
			cout<<i+1<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 3272
main :: IO ()
main = do
  a <- readLn :: IO Int
  b <- readLn :: IO Int
  c <- readLn :: IO Int
  x <- readLn :: IO Int
  print $ length [True | i <- [0..a], j <- [0..b], k <- [0..c], 500 * i + 100 * j + 50 * k == x]

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define add(x,y) (e[++ee].nxt=lnk[x],e[lnk[x]=ee].to=y)
using namespace std;
int n,c[N+5],sz[N+5],Mx[N+5],s[N+5],d[N+5],fa[N+5];
int ee,lnk[N+5];struct edge {int to,nxt;}e[N<<1];
I void Walk(CI x,CI v)
{
	s[x]=1;for(RI i=lnk[x];i;i=e[i].nxt)
		e[i].to^fa[x]&&e[i].to<v&&(Walk(e[i].to,v),s[x]+=s[e[i].to]);
}
I void dfs1(CI x)
{
	RI i;for(sz[x]=1,Mx[x]=max(Mx[fa[x]],fa[x]),i=lnk[x];i;i=e[i].nxt)
		e[i].to^fa[x]&&(fa[e[i].to]=x,dfs1(e[i].to),sz[x]+=sz[e[i].to],d[x]+=d[e[i].to]);
	Mx[fa[x]]<x&&(Walk(x,Mx[x]),d[x]=-sz[x]),Mx[fa[fa[x]]]<fa[x]&&(d[x]+=sz[x]);
}
I void dfs2(CI x)
{
	fa[x]&&(Mx[fa[x]]<x?c[x]+=s[x]:Mx[fa[fa[x]]]<fa[x]&&(c[x]+=d[x]-s[x]),c[x]+=c[fa[x]]);
	for(RI i=lnk[x];i;i=e[i].nxt) e[i].to^fa[x]&&(dfs2(e[i].to),0);
}
int main()
{
	RI i,x,y;for(scanf("%d",&n),i=1;i^n;++i) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(dfs1(1),dfs2(1),i=2;i<=n;++i) printf("%d%c",c[i]," \n"[i==n]);return 0;
}

Measured memory_bytes: 34036
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long int n,a,b,low=0,mid,high=1e9,count=0,i;
        cin>>n>>a>>b;
        vector<long long int> v(n);
        for(int i=0;i<n;i++)
            cin>>v[i];
        while(low+1<high)
        {
            count=0;
            mid=(low+high)/2;
            for(int x=0;x<v.size();x++)
            {
                i=v[x];
                if(i>mid*b)
                    (i-mid*b)%(a-b)?count+=(i-mid*b)/(a-b)+1:count+=(i-mid*b)/(a-b);
            }
            if(count<=mid)
                high=mid;
            else
                low=mid;
        }
        cout<<high;
    }

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
  ll q,h,s,d;cin >>q>>h>>s>>d;
  ll n;cin >>n;n*=4;
  vector<ll>a={q*8,h*4,s*2,d};
  sort(all(a));
  ll ans=0;
  ans+=a[0]*(n/8);
//  cout <<ans <<endl;
  n%=8;
  ll now=INF;
    for (int i =0; i <=1; ++i) {
        for (int j = 0; j <=2; ++j) {
            for (int k = 0; k <=4; ++k) {
                for (int l = 0; l <=8; ++l) {
                    if(1*l+2*k+4*j+8*i!=n)continue;
                    now=min(q*l+h*k+s*j+d*i,now);
                }
            }
        }
    }
    ans+=now;
    cout <<ans <<endl;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
    
    int ap,bp,cp,t,n;
    char a[999],b[999],c[82];
    
    scanf("%d",&n);
    while (n--) {
        scanf("%s %s",a,b);
        ap = strlen(a);
        bp = strlen(b);
        c[cp=(ap>80 || bp>80)? 0:81]='\0';
        t=0;
        while ((t||ap||bp) && cp>0) {
            t +=(ap? a[--ap]-'0':0) + (bp? b[--bp]-'0':0);
            c[--cp] = t%10 + '0';
            t /=10;
        }
        if(cp>0) printf(&c[cp]);
        //        if(cp) printf(&c[cp]);???????????????OK.
        //        if(cp>0) printf("%s",&c[cp]);???????????????OK.
        else printf("overflow");
        printf("\n");
    }
    
    return 0;
    
}

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    int x;
    cin >> x;

    vector<int> d;
    int i = 1;
    while (i*i <= x) {
        int n, m;
        if (x % i == 0) {
            n = i;
            m = x / i;

            int a = n / 2;
            while (true) {
                int b = a - n;
                int a2 = a * a;
                int b2 = b * b;
                int a3 = a2 * a;
                int b3 = b2 * b;
                int a4 = a2 * a2;
                int b4 = b2 * b2;
                int f = a4+a3*b+a2*b2+a*b3+b4;
                if (f == m) {
                    cout << a << " " << b << endl;
                    return 0;
                }
                if (f > m) break;
                a++;
            }
        }
        i++;
    }


    return 0;
}



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

int main() {
    int cnt = 0;
    string s;
    cin >> s;
    
    string memo = "";
    memo += s.at(0);
    for (int i = 0; i < s.size(); i++)
    {
        if (memo.size() == 1)
        {
            if (s[i] == s[i+1])
            {
                memo = "";
                memo += s[i+1];
                memo += s[i+2];
                i++;
                cnt++;
            }
            else if (s[i] != s[i+1])
            {
                memo = "";
                memo += s[i+1];
                cnt++;
            }
        }
        else if (memo.size() == 2)
        {
            memo = "";
            memo += s[i+1];
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;
		for (int i = 0; i < h; i++) {
			for (int k = 0; k < w; k++) {
				if ((i+k)%2==0) {
					cout << '#';
				}
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
#  = list(map(int, input().split()))
#x = list(map(int, input().split()))
i = 1
l = []
while i*i <= n:
    if n%i==0:
        l.append(i)
        l.append(n//i)
    i+=1

l.sort()
a = l[len(l)//2]
b = l[len(l)//2-1]
print(a+b-2)
#print(l)

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> check0={0,0,1,1};
  vector<ll> check1={0,1,0,1};
  for(ll k=0;k<4;k++) {
    bool flag=true;
    vector<ll> ans(n,-1);
    ans[0]=check0[k];
    ans[1]=check1[k];
    for(ll i=1;i<=n;i++) {
      if(i==n-1) {
        if(s[i]=='o') {
          if(ans[i]) {
            if(ans[0]!=1-ans[i-1]) {
              flag=false;
            }
          }
          else {
            if(ans[0]!=ans[i-1]) {
              flag=false;
            }
          }
        }
        else {
          if(ans[i]) {
            if(ans[0]!=ans[i-1]) {
              flag=false;
            }
          }
          else {
            if(ans[0]!=1-ans[i-1]) {
              flag=false;
            }
          }
        }
      }
      else if(i==n) {
        if(s[0]=='o') {
          if(ans[0]) {
            if(ans[n-1]!=1-ans[1]) {
              flag=false;
            }
          }
          else {
            if(ans[n-1]!=ans[1]) {
              flag=false;
            }
          }
        }
        else {
          if(ans[0]) {
            if(ans[n-1]!=ans[1]) {
              flag=false;
            }
          }
          else {
            if(ans[n-1]!=1-ans[1]) {
              flag=false;
            }
          }
        }
      }
      else if(s[i]=='o') {
        if(ans[i]) {
          ans[i+1]=1-ans[i-1];
        }
        else {
          ans[i+1]=ans[i-1];
        }
      }
      else {
        if(ans[i]) {
          ans[i+1]=ans[i-1];
        }
        else {
          ans[i+1]=1-ans[i-1];
        }
      }
    }
    if(flag) {
      for(ll j=0;j<n;j++) {
        if(ans[j]) {
          cout << "W";
        }
        else {
          cout << "S";
        }
      }
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 1392
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	S := strings.Split(s, "")

	for i := 0; i < k; i++ {
		if S[i] != "1" {
			fmt.Println(S[i])
			break
		}
		if i == k-1 {
			fmt.Println(1)
		}
	}
}


Measured memory_bytes: 640
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    if(b==1)
        cout << 0 << endl;
    else
        cout << (b-2)/(a-1)+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,x,y;
  cin >> n >> x >> y;
  pr(min(x,y),max(0LL,(x+y)-n));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<cstdio>
    int a[5];
    int main()
    {
        for(int i=1;i<=4;i++)
        {
        	char c=getchar();
        	a[i]=c-'0';
    	}
    	for(int i=0;i<8;i++)
    	{
    		int ans=a[1];
    		for(int j=0;j<3;j++)
    		if(i&(1<<j)) ans+=a[j+2];
    		else ans-=a[j+2];
    		if(ans!=7) continue;
    		printf("%d",a[1]);
    		for(int j=0;j<3;j++)
    		{
    			if(i&(1<<j)) printf("+");
    			else printf("-");
    			printf("%d",a[j+2]);
    		}
    		return printf("=7"),0;
    	}
    	return 0;
    }

Measured memory_bytes: 128
h, w = map(lambda x: int(x)+2, input().split())
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

total = 0
for i in range(h):
    for j in range(w):
        if MAZE[i][j] == '.':
            total += 1

i, j = (1, 1)
INF = 10**18
dist = [[INF] * w for _ in range(h)]
dist[i][j] = 1
next_v = [(i, j)]
while next_v:
    i, j = next_v.pop()
    direction = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    for di, dj in direction:
        x, y = i+di, j+dj
        if MAZE[x][y] == "#":
            continue
        if dist[x][y] <= dist[i][j] + 1:
            continue
        dist[x][y] = dist[i][j] + 1
        next_v.append((x, y))

last = dist[h-2][w-2]
if last != INF:
    ans = total - last
else:
    ans = -1

print(ans)


Measured memory_bytes: 42860
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    list<int> li;
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        char s[20];
        int t;
        scanf("%s",s);
        if(s[6]==0) scanf("%d",&t);
        if(s[0]=='i') li.push_front(t);
        else if(s[6]==0)
        {
            for(list<int>::iterator it=li.begin();it!=li.end();++it)
                if(*it==t)
                {
                    li.erase(it);
                    break;
                }
        }
        else if(s[6]=='F') li.pop_front();
        else if(s[6]=='L') li.pop_back();
    }
    for(list<int>::iterator it=li.begin();it!=li.end();)
    {
        printf("%d",*it);
        printf("%c",(++it)==li.end()?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 34420
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


int main(){
    string s, t; cin >> s >> t;

    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());

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

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

int main(void) {

  int h1, m1, h2, m2, k, t;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

  t = ((h2*60+m2)-k) - (h1*60+m1);

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

  return 0;
}


Measured memory_bytes: 1736
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[100005],t[100005];
    ll n,m;
    scanf("%lld%lld",&n,&m);
    scanf("%s%s",s,t);
    // ll [n];
    if(s[0]!=t[0]){
        printf("-1\n");
        return 0;
    }
    ll g=gcd(n,m);
    rep(i,1,g){
        if(s[n/g*i]!=t[m/g*i]){
            printf("-1\n");
            return 0;
        }
    }

    
    printf("%lld\n",lcm(n,m) );
    return 0;
}


Measured memory_bytes: 384
L, R = map(int, input().split())
min = 2200
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i * j) % 2019 < min:
            min = (i * j) % 2019
            if min == 0:
                print(0)
                exit()
print(min)

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

int main(){
  char n[3];
  for(int i=0; i<3; i++){
    cin >> n[i];
  }
  if(n[0]==n[2]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  	const int C = 2000; int N, T, min_cost = C; cin >> N >> T;
  
  	for( int i = 0; i < N; i++ )
    {
      	int c, t; cin >> c >> t;
      
      	if ( t <= T and c < min_cost )
          	min_cost = c;
    }
  
  	if ( min_cost < C )
      	cout << min_cost;
  	else
      	cout << "TLE";
}

Measured memory_bytes: 256
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<int> nums;
	const int N = 1e6;
	for(int i=1;i<10;i++) nums.push_back(i);
	for(int i=0;i<nums.size() && nums.size()<N; i++){
		int cur = nums[i];
		for(int j=-1;j<2;j++){
			if(j==1 && cur%10==9) continue;
			if(j==-1 && cur%10==0) continue;
			nums.push_back((cur*10) + (cur%10+j));
		}
	}
	sort(nums.begin(),nums.end());
	int n;
	cin>>n;
	cout<<nums[n-1];
	return 0;
}



Measured memory_bytes: 10220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int counter = 0;
	for (int i = A; i <= B; ++i) {
		if (i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10) ++counter;
	}
	cout << counter << endl;
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll n;
	cin >>n;

	vector<ll> a(n+1);
	repn(i,n) cin >>a[i];

	for(ll i=n; i>0; i-=2){
		cout <<a[i]<<" ";
	}

	for(ll i=n%2+1; i<n; i+=2){
		cout <<a[i]<<" ";
	}

  
	

}


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

struct edge{ll from,to,cost;};
vector<bool> negative(1010,false);

bool Bellman_Ford(int s, int V, vector<ll>& dist, vector<edge>& G){
    fill(dist.begin(),dist.end(),INFL);
    dist[s] = 0;
    for(int loop = 0; loop < V*2; loop++){
        bool update = false;
        for(int i=0; i<int(G.size()); i++){
            edge e = G[i];
            if(dist[e.from] != INFL && dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                update = true;
                if(loop >= V){
                    negative[e.to] = true;
                }
                if(loop == 2*V-1){
                    return true;
                }
            } 
        }
        if(!update) break;
    }
    return false;
}

int main(){
    int V,E;
    cin >> V >> E;
    vector<ll> dist(V);
    vector<edge> G;
    rep(i,E){
        int a,b,c;
        cin >> a >> b >> c;
        --a; --b; c = -c;
        G.push_back(edge{a,b,c});
    }
    if(Bellman_Ford(0,V,dist,G) && negative[V-1]){
        cout << "inf" << endl;
    }else{
        cout << -dist[V-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
using namespace std;
 
 
 
int main() {
  int  A,B;
  cin >>  A>>B;
  int i,j,k, l=0;
  for (i=1 ;i<10;i++){
    for(j=0;j<10;j++){
      for(k=0;k<10;k++){
         int m=10000*i+1000*j+100*k+10*j+i;
        if (A<=m && m<=B){l++;}

      }
    }
  }

 cout<<l<<endl;


}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int count = 0;
  for(int i=0;;i++){
   if(N/K!=0){
    N/=K;
    count++;
   }
    else{
      break;
    }
  }
  cout<<count+1<<endl;
return 0;
}

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

string S;
size_t cur = 0;

bool isdigit(char a){
    if(a =='0' or a=='1' or a=='2' or a=='3' or a=='4' or a=='5' or a=='6' or a=='7' or a=='8' or a=='9'){
        return true;
    }
    else return false;
}

int digit(){
    int n = S[cur] - '0';
    cur = cur + 1;
    return n;
}

int number(){
    int n = digit();
    while(cur < S.size() && isdigit(S[cur]))
        n = n*10 + digit();
    return n;
}
int factor();

int term(){
    int a = factor();
    while(cur < S.size() && (S[cur] == '*'|| S[cur] == '/')){
        char op = S[cur];
        cur +=1;
        int b = factor();
        if(op == '*') a *= b;
        else a /= b;
    }
    return a;
}

int expression(){
    int a = term();
    while(S[cur] == '+'|| S[cur] == '-'){
        char op = S[cur];
        cur += 1;
        int b = term();
        if (op == '+') a += b;
        else a -= b;
    }
    return a;
}

int factor(){
    if (S[cur] !='(') return number();
    cur += 1;
    int n = expression();
    assert(S[cur] == ')');
    cur += 1;
    return n;
}

int main() {
    int N;
    cin >> N;
    for(int i=0; i<N; ++i){
        cur = 0;
        cin >> S;
        S.resize(S.size()-1);
        cout << expression() << endl;
    }
    return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll N = S.size();
  ll r= 0, b=0;
  rep(i, N){
    if(S[i]=='0')r++;
    else b++;
  }

  cout << min(r, b)*2;
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  long long x, y;
  std::cin >> x >> y;
  int count = 0;
  long long a = x;
  while (true) {
    if (a <= y) {
      ++count;
      a *= 2;
    } else {
      break;
    }
  }
  std::cout << count << std::endl;
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int h[2*100000]={};
    for(int i=1; i<= n;i++)
        cin >> h[i];
    bool res[100000+2];
    memset(res,true, sizeof(res));
    vector<pair <int, int> > v(m);
    for(int i =0; i < m; i++)
    {
        int x,y;
        cin >> x >> y;
        v[i] = make_pair(x,y);
    }
    for(int i = 0; i < m; i++)
    {
        if(h[v[i].first] <= h[v[i].second] && res[v[i].first] == true)
        {
            res[v[i].first] = false;
        }
         if(h[v[i].first] >= h[v[i].second] && res[v[i].second] == true)
        {
            res[v[i].second] = false;
        }
    }
    int ans = 0;
    for(int i =1; i <=n;i++)
    {
        if(res[i])
            ans++;
    }
    cout << ans;



}



Measured memory_bytes: 4844
#include<stdio.h> 
int main()
{
	int i, j;
	for(i = 1; i < 10; i++)
	{
		for(j = 1; j < 10; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
    }
	
	return 0;
}


Measured memory_bytes: 2020
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
#define outdicimal out << fixed << setprecision(10)//TODO 小数点以下の桁数の変更
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


class BBiteEating {
public:
	void solve(std::istream& in, std::ostream& out) {
	  int n,l;
	  in >> n >> l;
	  vec a(n);
	  int sum = 0;
	  FOR(i, 1, n + 1){
      a[i - 1] = l + i - 1;
      sum += a[i - 1];
	  }
    int min_t = INF;
	  int sub = 0;
	  REP(i, n){
	    int t = 0;
	    REP(j, n){
	      if(i != j) t += a[j];
	    }
	    t = abs(t - sum);
	    if(t < min_t){
        sub = a[i];
	      min_t = t;
	    }
	  }
	  int ans = 0;
	  ITR(itr,a){
	    ans += *itr;
	  }
	  out << ans - sub << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	BBiteEating solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int k = 0;
    for(int i = 0; i < m; i++){
        if(n % 2 == 0 && i >= n / 4) k = 1;
        cout << (i+1) << " " << (n - i - k) << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main(){

  string s;
  int appear_cnt[26][2]={0};
  int over_half;

  int char_num = 0;
  const int char_base = 'a';

  int a = 0, b = 0;

  cin >> s;

  int s_len=s.size();
  over_half = s_len / 2 + 1;

  for (int i = 0; i < s_len; i++)
  {
    char_num = (char)s[i] - char_base;
    
    if (appear_cnt[char_num][0]==0)
    {
      appear_cnt[char_num][1] = -3;
    }
    appear_cnt[char_num][0]++;

    if (i-appear_cnt[char_num][1]<=2) {
      a = i - 1;
      b = i + 1;
      appear_cnt[char_num][1] = i;      
      break;
    }
    else
    {
      appear_cnt[char_num][1] = i;
    }
  }

  if (a==0 && b!=0)
  {
    a = 1;
    b = appear_cnt[char_num][1] + 1;
  }

  if (a==0 || b==0)
  {
    cout << -1 << " " << " " << -1 << endl;
  } else 
  {
    //cout << s.substr(a, b-a+1) << endl;
    cout << a << " " << " " << b << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll R, G, B, N; cin >> R >> G >> B >> N;
    
    ll ans = 0;
    for (ll i = 0; i <= N / R; i++) {
        for (ll j = 0; j <= N / G; j++) {
            if (i * R + j * G > N) continue;
            ll rem = N - i * R - j * G;
            if (rem % B != 0) continue;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <cstring>
#include <regex>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    string s;
    cin >> s;
    rep(i, s.length()) {
        FOR(j, i, s.length()) {
            if (s.substr(0, i) + s.substr(j, s.length() - j) == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X,string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   cout<<lcs<<endl;
} 
  
/* Driver program to test above function */
int main() 
{ 
  string s,t;
  cin>>s>>t;
  int m = s.length(); 
  int n = t.length(); 
  lcs(s, t, m, n); 
  return 0; 
} 

Measured memory_bytes: 38780
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long


using namespace std;
const int N = 500077;
int n, m, k, l, r, d;
int ans[N];

int f(int x, int y, int z){
    return x * x + y * y + z * z + x * y + x * z + y * z;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int x = 1; x <= 350; x++){
        for (int y = 1; y <= 350; y++){
            for (int z = 1; z <= 350; z++){
                int res = f(x, y, z);
                if (res > n){
                    break;
                }
                else {
                    ans[res]++;
                }
            }
        }
    }

    for (int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }


}


Measured memory_bytes: 3656
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList = input[0].split(' ').map(x => parseInt(x, 10));

    var A = numList[0];
    var B = numList[1];

    var X = 0;
    for (var i = 0; i < 2; i++) {
        if (A > B) {
            X += A;
            A -= 1;
        } else {
            X += B;
            B -= 1;
        }
    }
    console.log(X);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

struct node{
  string name;
  int parent;
  vector<int> child;

  node(string s=""):name(s){ parent = -1; child.clear(); }

  void set_par(int a){ parent = a; }
  void add_child(int a){ child.push_back(a); }
};

vector<node> tree;
map<string,int> id;

inline bool is_par(string my, string your){
  int par = tree[id[my]].parent;
  if(par<0)return false;
  return tree[par].name == your;
}

inline bool is_child(string my, string your){
  for(int c : tree[ id[my] ].child){
    if(tree[c].name == your)return true;
  }
  return false;
}

inline bool is_sib(string my, string your){
  int par = tree[id[my]].parent;
  if(par<0)return false;
  return is_child(tree[par].name, your);
}

inline bool is_anc(string my, string your){
  if(my == your)return true;
  int par = tree[id[my]].parent;
  if(par<0)return false;
  return is_anc(tree[par].name, your);
}

inline bool is_des(string my, string your){
  if(my == your)return true;
  for(int c : tree[ id[my] ].child){
    if(is_des(tree[c].name,your))return true;
  }
  return false;  
}

int main(){
  int n,m;
  while(cin >> n >> m, n){
    stack< pair<int,int> > s;
    id.clear();
    tree.resize(n);

    cin.ignore();
    for(int i=0;i<n;i++){
      string name;
      getline(cin,name);
      //cout << name << endl;
      int indent = 0;
      while(name[indent]==' ')indent++;
      name = name.substr(indent);
      tree[i] = node(name);
      id[name] = i;

      while(s.size() && s.top().second+1 != indent)s.pop();
      if(s.size()){
	tree[i].set_par( s.top().first );
	tree[s.top().first].add_child(i);
      }
      s.push( make_pair(i,indent) );
    }

    /*
    for(int i=0;i<n;i++){
      cout << tree[i].name << endl;
      cout << tree[i].parent << endl;
      for(int c : tree[i].child)cout << c << " "; cout << endl;
    }
    */

    for(int i=0;i<m;i++){
      string my,your,query,dummy;
      cin >> your >> dummy >> dummy >> query >> dummy >> my;
      my = my.substr(0,my.size()-1);

      //cout << my << " " << your << " " << query << endl;

      bool f = false;
      if(query == "child")f = is_child(my,your);
      else if(query == "parent")f = is_par(my,your);
      else if(query == "sibling")f = is_sib(my,your);
      else if(query == "ancestor")f = is_anc(my,your);
      else f = is_des(my,your);

      if(f)cout << "True" << endl;
      else cout << "False" << endl;
    }
    cout << endl;
  }
}

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

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

    string T_1=T.substr(0,T.size()-1);

    if( S==T_1 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int M, K;
	std::cin >> M >> K;
	if (M == 0)
	{
		std::cout << (K == 0 ? "0 0" : "-1") << std::endl;
		return;
	}
	if (M == 1)
	{
		std::cout << (K == 0 ? "0 0 1 1" : "-1") << std::endl;
		return;
	}
	if (K == 0)
	{
		for (auto i : boost::irange(0, 1 << M))
		{
			std::cout << i << " " << i << " ";
		}
	}
	else if (K < (1 << M))
	{
		for (auto i : boost::irange(0, K))
		{
			std::cout << i << " ";
		}
		std::cout << K << " ";
		for (auto i : boost::irange(0, K) | adaptor::reversed)
		{
			std::cout << i << " ";
		}
		for (auto i : boost::irange(K + 1, 1 << M))
		{
			std::cout << i << " ";
		}
		std::cout << K << " ";
		for (auto i : boost::irange(K + 1, 1 << M) | adaptor::reversed)
		{
			std::cout << i << " ";
		}
	}
	else
	{
		std::cout << -1;
	}
	std::cout << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 1792
n = int( input() )
A = []
B = []

for i in range( n ):
  a, b = map( int, input().split() )
  A.append( a )
  B.append( b )

A = sorted( A )
B = sorted( B )

if n % 2 == 0:
  i = n // 2
  print(( B[ i ] + B[ i - 1 ] ) - ( A[ i ] + A [ i - 1 ] ) + 1 )
else:
  i = ( n + 1 ) // 2 - 1
  print( B[ i ] - A[ i ] + 1 )


Measured memory_bytes: 27108
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
MOD = 10 ** 9 + 7

for k, v in c.items():
    if v != 2:
        if N % 2 == 1 and k == 0:
            continue
        else:
            print("0")
            break
else:
    print(2 ** (N // 2) % MOD)


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

template <typename _tp> inline void read(_tp&x){
	char c11=getchar(),ob=0;x=0;
	while(c11!='-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;
}

const int N = 23;
int A[N],B[N],C;
int n,m;

int main(){
	read(n),read(m),read(C);
	for(int i=1;i<=m;++i) read(B[i]);
	int ans = 0;
	while(n--){
		ll res = C;
		for(int i=1;i<=m;++i)read(A[i]), res += (ll)A[i] * B[i];
		if(res > 0) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
t = input()[::-1]
sl, tl = len(s), len(t)
for i in range(sl - tl + 1):
    for j in range(tl):
        if s[i + j] != "?" and s[i + j] != t[j]:
            break
    else:
        print((s[:i] + t + s[i + tl:]).replace("?", "a")[::-1])
        break
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
def solve(n)
  res = 0
  1.upto(n) do |i|
    1.upto(n) do |j|
      1.upto(n) do |k|
        res += i.gcd(j).gcd(k)
      end
    end
  end
  res
end

puts solve(gets.to_s.to_i)

Measured memory_bytes: 14328
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<long long,long long>
#define reset(a,b) memset(a,b,sizeof a)
#define ll long long
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo 2*(idx),l,MID
#define tengen 2*idx+1,MID+1,r
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 200003
#define pc(x) putchar_unlocked(x);

int bit[mx],a[mx],n;
vector<int>ve;

void upd(int idx,int val){
	for(;idx<=n;idx+=idx&-idx)
		bit[idx]+=val;
}

int cari(int idx){
	int ret=0;
	for(;idx;idx-=idx&-idx)
		ret+=bit[idx];
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int jaw=1;
	for(int i=2;i<n;i++){
		if(min(a[i],a[n]-a[i])>min(a[jaw],a[n]-a[jaw]))
			jaw=i;
	}
	cout<<a[n]<<' '<<a[jaw]<<endl;
}

Measured memory_bytes: 640
a = []
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    a.append(a1)
    a.append(a2)
    a.append(a3)

l = [0]*9
n = int(input())

for i in range(n):
    b = int(input())
    for k in range(9):
        if a[k] == b:
            l[k] += 1
 
if l[0] == 1 and l[1] == 1 and l[2] == 1:
    print('Yes')
elif l[3] == 1 and l[4] == 1 and l[5] == 1:
    print('Yes')
elif l[6] == 1 and l[7] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[3] == 1 and l[6] == 1:
    print('Yes')
elif l[1] == 1 and l[4] == 1 and l[7] == 1:
    print('Yes')
elif l[2] == 1 and l[5] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[4] == 1 and l[8] == 1:
    print('Yes')
elif l[2] == 1 and l[4] == 1 and l[6] == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int[] n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
			int k = sc.nextInt();
			System.out.println(n[k - 1]);
		}

	}

}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define ll long long
#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mo 1000000007
using namespace std;
vector<ll> initializeDiffArray(vector<ll>& A) 
{ 
	ll n = A.size(); 
	vector<ll> D(n + 1); 
	D[0] = A[0], D[n] = 0; 
	for (ll i = 1; i < n; i++) 
		D[i] = A[i] - A[i - 1]; 
	return D; 
} 
void update(vector<ll>& D, int l, int r, int x) 
{ 
	D[l] -= x; 
	D[r + 1] += x; 
} 
void printAns(vector<ll>& A, vector<ll>& D) 
{ 
	for (ll i = 0; i < A.size(); i++) { 
		if (i == 0) 
			A[i] = D[i]; 
		else
			A[i] = D[i] + A[i - 1]; 
		if(A[i]>0){
			cout<<"Yes\n";
		}else{
			cout<<"No\n";
		}
	} 
} 
int main(){
	FASTIO
	ll n,k,q;
	cin>>n>>k>>q;
	vector<ll> A;
	for(ll i=0;i<n;i++){
		A.push_back(k);
	}
	vector<ll> D = initializeDiffArray(A);
	ll pos;
	for(ll i=0;i<q;i++){
		cin>>pos;
		pos-=1;
		if(pos==0){
			update(D,1,n-1,1);
		}else if(pos==n-1){
			update(D,0,n-2,1);
		}else{
			update(D,0,pos-1,1);
			update(D,pos+1,n-1,1);
		}
	}
	printAns(A,D);
	return 0;
}


Measured memory_bytes: 2292
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll s;
    cin>>s;
    cout<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<1000000000-(s-1)%1000000000-1<<" "<<(s-1)/1000000000+1;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  for (int i=0;i<N;i++) {
    cin >> S.at(i);
  }
  
  int judge=0;
  for (int i=0;i<N;i++) {
    if (S.at(i) == 'Y') {
      judge = 1;
      cout << "Four" << endl;
      break;
    }
  }
  if (judge==0) {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        Calc calc = new Calc();
        List<string> ans = new List<string>();

        string str;
        while (!((str = Console.ReadLine()) == null))
        {
            List<double> input = str.Split(' ').Select(double.Parse).ToList();
            ans.Add(calc.JudgePointInTriangle(input));
        }

        foreach(string item in ans)
        {
            Console.WriteLine(item);
        }
    }

}
class Calc
{
    internal string JudgePointInTriangle(List<double> input)
    {
        string ans;

        double[] p1 = new double[2] { input[0], input[1] };
        double[] p2 = new double[2] { input[2], input[3] };
        double[] p3 = new double[2] { input[4], input[5] };
        double[] p = new double[2] { input[6], input[7] };

        double[] vector12 = { input[2] - input[0], input[3] - input[1] };
        double[] vector23 = { input[4] - input[2], input[5] - input[3] };
        double[] vector31 = { input[0] - input[4], input[1] - input[5] };
        double[] vector1p = { input[6] - input[0], input[7] - input[1] };
        double[] vector2p = { input[6] - input[2], input[7] - input[3] };
        double[] vector3p = { input[6] - input[4], input[7] - input[5] };

        double outer_product1 = OuterProduct(vector31, vector1p);
        double outer_product2 = OuterProduct(vector12, vector2p);
        double outer_product3 = OuterProduct(vector23, vector3p);

        if (outer_product1 < 0 && outer_product2 < 0 && outer_product3 < 0)
        {
            ans = "YES";
        }
        else if (outer_product1 > 0 && outer_product2 > 0 && outer_product3 > 0)
        {
            ans = "YES";
        }
        else
        {
            ans = "NO";
        }
        return ans;
    }

    internal double OuterProduct(double[] p1, double[] p)
    {
        double outer_product = p1[0] * p[1] - p1[1] * p[0];
        return outer_product;
    }

}


Measured memory_bytes: 16296
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S){
    cout << A-1 << " " << B << endl;
  }
  else if(U == T){
    cout << A << " " << B-1 <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
p_list = list(map(int, input().split()))
count = 0

for i in range(n-2):
    aim = p_list[i+1]
    tmp_list = [p_list[i], p_list[i + 1], p_list[i + 2]]
    tmp_list.sort()
    if tmp_list[1] == aim:
        count += 1

print(count)

Measured memory_bytes: 3060