akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int a[100];
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        a[x]++;
        a[y]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  
  ll a,s;

  cin>>a>>s;
  if(a<s)
    cout<<0;
    else
        cout<<10;
  


  


    




    
    return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;

Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
  if(T[u].r != NIL) calcDepth(T[u].r,p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 3304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 50

int N, A;
int x[50];

ll dp[51][51][3010];

int main() {
  cin >> N >> A;
  rep(i,N) cin >> x[i];

  dp[0][0][0] = 1;
  rep(i,N) rep(j,N) rep(k,2500) if (dp[i][j][k]) {
    dp[i+1][j][k] += dp[i][j][k];
    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
  }

  ll ans=0;
  for (int i = 1; i < N+1; ++i) ans += dp[N][i][i*A];
  cout << ans << endl;
}


Measured memory_bytes: 58240
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#define N 100100
typedef long long ll;
using namespace std;
int main()
{
    char a,b;
    cin>>a>>b;
    if (a<b)
        cout << "<" << endl;
    else if (a>b)
        cout << ">" << endl;
    else
        cout << "=" << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
from functools import lru_cache
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))


@lru_cache(maxsize=None)
def gcd(a, b):
    if (b == 0):
        return a
    else:
        return gcd(b, a % b)


ans = a[0]

for i in a[1:]:
    ans = gcd(ans, i)

print(ans)

Measured memory_bytes: 62648
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


  
int main(){
    ll k,s;
    cin>>k>>s;
    ll ans = 0;
    
    for(ll i = 0; i<=k; i++){
        for(ll j = i; j<=k; j++){
            for(ll h = j; h<=k; h++){
                if(i+j+h == s){
                    if (i==j && j==h){
                        ans++;
                    }else if (i==j || j==h || i==h){
                        ans+=3;
                    }else{
                        ans+=6;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
 
    
    



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

int main() {
	
	int n = 0;
	int a = 0;
	int b = 0;
	
	cin >> n >> a >> b ;
	
	int expenses = n * a;
	int cost  = b;
	int res = min(expenses,cost);
	
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, m, ai;
	int i;

	scanf("%d%d", &n, &m);
	
	/* 宿題の種類ごとにかかる日数を引いていく */
	for (i = 0; i < m; i++)
	{
		scanf("%d", &ai);
		n -= ai;
	}

	if (n >= 0)
	{
		printf("%d\n", n);
	}
	else
	{
		printf("-1\n");
	}

	return 0;
}

Measured memory_bytes: 1732
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] ={ 1,0,-1,0 };
int dy[4] ={ 0,1,0,-1 };

int N, K, h[100000];

signed main() {
	cin >> N >> K;
	rep(i, N) cin >> h[i];

	int ans = 0;
	rep(i, N){
		if(h[i] >= K) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef string str;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vint num(n,0) ;
  REP(i,n-1){
    int a ;
    cin >> a ;
    num[a-1]++ ;
  }
  REP(i,n){
    cout << num[i] <<endl ;
  }
  
  
  
  return 0 ;
}


Measured memory_bytes: 3992
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int[]freq=new int[n];
        for(int i=0;i<n-1;i++)
            freq[ni()-1]++;
        for(int i=0;i<n;i++)
            pn(freq[i]);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj =true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

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

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 56440
main :: IO ()
main = do
    s <- getLine
    putStrLn $ if solve s then "YES" else "NO"

solve :: String -> Bool
solve "AKIHABARA" = True
solve s | length s > 9 = False
        | otherwise    = or $ map solve $ insertA s
    
bisects :: String -> [(String, String)]
bisects xs = [ splitAt i xs | i <- [0 .. length xs] ]

insertA :: String -> [String]
insertA s = map (\(x, y) -> x ++ "A" ++ y) $ bisects s

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

vvi to, ot;
vb seen_1, seen_n, ok;

void dfs(int v) {
    seen_1[v] = true;
    for (int u : to[v]) {
        if (seen_1[u]) continue;
        dfs(u);
    }
}

void rdfs(int v) {
    seen_n[v] = true;
    for (int u : ot[v]) {
        if (seen_n[u]) continue;
        rdfs(u);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, m, p;
    cin >> n >> m >> p;
    vector<tuple<int, int, int>> edges; 
    to.resize(n);
    ot.resize(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c -= p;
        c = -c;
        edges.eb(a, b, c);
        to[a].pb(b);
        ot[b].pb(a);
    }
    seen_1.resize(n, false);
    seen_n.resize(n, false);
    ok.resize(n, false);
    dfs(0);
    rdfs(n-1);
    rep(i, n) ok[i] = (seen_1[i] && seen_n[i]);

    bool negloop = false;
    vi d(n, INF);
    d[0] = 0;
    for (int t = 0; ; ++t) {
        bool update = false;
        rep(i, m) {
            int from = get<0>(edges[i]);
            int to = get<1>(edges[i]);
            int w = get<2>(edges[i]);
            if (!(ok[from] && ok[to])) continue;
            if (chmin(d[to], d[from] + w)) update = true;
        }
        if (!update) break;
        if (t == n-1) {
            negloop = true;
            break;
        }
    }
    if (negloop) cout << -1 << endl;
    else cout << max(0, -d[n-1]) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
const ll MOD=1e9+7;
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
using namespace std;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    if(abs(n-m)<2){
        ans=1;
       if(n>m){
           rep(i,1,n+1){
               ans*=i;
               ans%=MOD;
               if(i<=m)ans*=i;
               ans%=MOD;
           }
       }
       else{
           rep(i,1,m+1){
               ans*=i;
               ans%=MOD;
               if(i<=n)ans*=i;
               ans%=MOD;
           }
       }
        if(!abs(n-m))ans*=2;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 256
// AOJ 0023
#include<iostream>
#include<cmath>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const long double EPS = 1e-10;

long double sq(long double x) {
  return x * x;
}

long double abs(long double x) {
  return (x > 0 ? x : -x);
}
/*
bool eq(long double x, long double y) {
  return abs(x - y) < EPS;
}*/

long double dist(long double xa, long double ya, long double xb, long double yb) {
  return sq(xa - xb) + sq(ya - yb);
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    long double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    long double d = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
    
    if (ra - rb > d + EPS) {
      cout << 2 << endl;
    } else if (rb - ra > d + EPS) {
      cout << -2 << endl;
    } else if (d > ra + rb + EPS) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
}

Measured memory_bytes: 1232
// sandeep_007	

#include <bits/stdc++.h>
 
using namespace std;
 
#define PI acos(-1)
#define mod 1000000007
#define ll long long
#define nitro std::ios_base::sync_with_stdio (false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define vi vector < int >
#define INV 333333336

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b){
    return (a.second < b.second);
}

inline ll mx(ll a,ll b){
	if(a > b) return a;
	else return b;	
}

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

ll power(ll x,ll y,ll p){
    ll res = 1;   
    x = x % p;    
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; 
        x = (x*x) % p; 
    }
    return res;
}

int main(){
	nitro;

	#ifdef DBG
		freopen("in","r",stdin);
	#endif
	
	string s;
	cin >> s;
	int c = 0;
	for(int i=0;i<3;i++){
		if(s[i] == '1') c++;	
	}
	cout << c << "\n";
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  
  string az;
  for (int i = 0; i < w + 2; i++) az += '#';
  cout << az << endl;
  for (int i = 0; i < h; i++) {
    cin >> s.at(i);
    cout << '#' << s.at(i) << '#' << endl;
  }
  cout << az << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]

int main(){

long long n;
cin>>n;

if(n>=30)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

int find(int x){
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}


int main(){
    int N,M,K; cin >> N >> M >> K;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= M; j++){
            int check = i*(M-j) + (N-i)*j;
            if (check == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#dequeでappendとappendleftを管理
from collections import deque

def inc(y, x):
	return 0 <= y < H and 0 <= x < W

H, W = map(int, input().split())
Sy, Sx = map(int, input().split())
Gy, Gx = map(int, input().split())
"""
a = [[] for i in range(h)]
for i in range(h):
    a[i] = input()
"""
a = [input() for i in range(H)]

DH = [1, 0, -1, 0]
DW = [0, 1, 0, -1]

#同じ大きさの行列を作って最短路をメモする発想がなかった
visit = [[-1 for i in range(W)] for j in range(H)]
visit[Sy-1][Sx-1]=0 #sy-1, sx-1に注意
deq = deque([(Sy-1, Sx-1)])

while deq:
    h, w = deq.pop()
    for dh, dw in zip(DH, DW):
        x = w+dw; y=h+dh
        if inc(y, x)==False or a[y][x]=='#':
            continue
        if visit[y][x]==-1 or visit[y][x]>visit[h][w]:
            visit[y][x] = visit[h][w]
            deq.append((y,x))
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if inc(h+dh, w+dw)==False or a[h+dh][w+dw]=='#':
                continue
            if visit[h+dh][w+dw]==-1: 
                visit[h+dh][w+dw] = visit[h][w]+1
                deq.appendleft((h+dh, w+dw))
if visit[Gy-1][Gx-1] == 1e8:
    print(-1)
else:
    print(visit[Gy-1][Gx-1])

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

int main(){
    int n; cin >> n;
    int M;
    M=((1000-1)/3)*200+((1000-1)-((1000-1)/3)-1)*195+1;
    for(int i;i<n;i++){
        int y,m,d; cin >> y >> m >> d;
        int days=((y-1)/3)*200+((y-1)-((y-1)/3)-1)*195;
        if(y%3!=0){
            for(int j=1;j<m;j++){
                if(j%2==1){
                    days+=20;
                }else if(j%2==0){
                    days+=19;
                }
            }
        }else if(y%3==0){
            days+=20*(m-1);
        }
        days+=d;
        //cout << "days:" << days << endl;
        cout << M-days << endl;
    }
}


Measured memory_bytes: 3080
h, w = map(int, input().split())
a = [ list(map(int, input().split())) for _ in range(h) ]

ans = []
for i in range(h):
    for j in range(w - 1):
        if a[i][j] % 2 == 1:
            ans.append([i + 1, j + 1, i + 1, j + 2])
            a[i][j + 1] += 1
            #a[i][j] -= 1

for i in range(h - 1):
    if a[i][w - 1] % 2 == 1:
        ans.append([i + 1, w, i + 2, w])
        a[i + 1][w - 1] += 1
        #a[i][w - 1] -= 1

print(len(ans))

for x in ans:
    print(x[0], x[1], x[2], x[3])

Measured memory_bytes: 30276
from functools import reduce

N, K = map(int, input().split())
A = list(map(int, input().split()))
Ap = [a for a in A if a>0]
Am = [a for a in A if a<0]
mod = 10**9+7
if len(Ap) + len(Am) < K:
    print(0)
    exit()
if len(Ap) + len(Am) == K:
    if 0 in A and len(Am) % 2:
        print(0)
    else:
        ans = reduce(lambda a, b: a * b % mod, Ap+Am, 1)
        print(ans)
    exit()
Ap.sort(reverse=True)
Am.sort()
if len(Ap) == 0:
    if K%2:
        if 0 in A:
            ans = 0
        else:
            ans = reduce(lambda a, b: a*b%mod, Am[-K:], 1)
    else:
        ans = reduce(lambda a, b: a*b%mod, Am[:K], 1)
    print(ans)
    exit()

idx_Am = 0
n = 0
ans = 1
for idx_Ap, ap in enumerate(Ap+[0]):
    while idx_Am < len(Am) and n < K and -Am[idx_Am] > ap:
        ans = ans * Am[idx_Am] % mod
        idx_Am += 1
        n += 1
    if n == K:
        break
    n += 1
    idx_Ap += 1
    ans = ans * ap % mod
    if n == K:
        break
else:
    assert False
if idx_Am % 2 == 0:
    print(ans)
else:
    if idx_Ap == len(Ap) or (idx_Am != len(Am) and idx_Ap > 0 and Am[idx_Am] * Am[idx_Am-1] > Ap[idx_Ap] * Ap[idx_Ap-1]):
        ans = ans * Am[idx_Am] * pow(Ap[idx_Ap-1], mod-2, mod) % mod
    else:
        ans = ans * Ap[idx_Ap] * pow(Am[idx_Am-1], mod-2, mod) % mod
    print(ans)


Measured memory_bytes: 32456
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
using namespace std;
bool flag[2500];
int main() {
	int n;
	cin >> n;
	vector<int> buf(n);
	int prev[3] = { 0,0,0 };
	for (auto &n : buf) {
		cin >> n;
		flag[n] = flag[prev[0] * 10 + n] =flag[prev[1]*10+n] = true;
		if (prev[2] * 10 + n < 2500) flag[prev[2] * 10 + n] = true;
		prev[2] = prev[1] * 10 + n;
		prev[1] = prev[0] * 10 + n;
		prev[0] = n;
	}
	int i = 0;
	for (; flag[i]; i++);
	cout << i << endl;
}

Measured memory_bytes: 3108
#include<string.h>

#include<stdio.h>

int main(void)

{

int i,sum=0;

int flag=0;

char x[1002];

scanf ("%s",x);

do{

for(i=0;i<1002;i++){

if(x[i]==0){

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

break;

}

else{

sum +=x[i]-0x30;

}

}

sum=0;

scanf("%s",x);

}

while(x[0]!=0x30);

return 0;

}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

struct obj {
    int work;
    int limit;
};

bool cmp(const obj &a, const obj &b)
{
    return a.limit < b.limit;
}

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

	vector<obj> list(N);
	obj item;
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> item.work >> item.limit;
		list[i] = item;
	}

	sort(list.begin(), list.end(), cmp);

	int sum = 0;
	bool result = true;
	for (obj item: list)
	{
		sum += item.work;
		if (sum > item.limit)
		{
			result = false;
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var sum = 0
    val a = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }
    for (i in 0 until n) {
        if (a[i] > b[i]) {
            sum += a[i] - b[i]
        }
    }
    println(sum)
}


Measured memory_bytes: 35988
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X,T;
  cin>>N>>X>>T;
  //cout<<fixed<<setprecision(10);
  int ans=N/X*T;
  if(N%X!=0)ans+=T;
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  if(c-a-b<=1) ans+=c;
  else ans+=a+b+1;
  ans+=b;
  co(ans);
  
  return 0;
}

Measured memory_bytes: 256
using System;

namespace Atcoder001
{
    class Program
    {
        static void Main(string[] args)
        {
            int kingaku = int.Parse(Console.ReadLine());

            int tmp = 0;
            if(kingaku % 1000 == 0)
            {
                tmp = 1000;
            }
            else
            {
                tmp = kingaku % 1000;
            }

            Console.WriteLine(1000 - tmp);
        }
    }
}

Measured memory_bytes: 27456
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

int n,m,q,scc,gp[10005];
bool vis[10005],vis2[10005];
vector<int>G[10005],R[10005],ts;

void dfs(int u) {
	vis[u]=1;
	for (int v:G[u])
		if (!vis[v]) dfs(v);
	ts.pb(u);
}

void dfs2(int u,int k) {
	vis2[u]=1;
	gp[u]=k;
	for (int v:R[u])
		if (!vis2[v]) dfs2(v,k);
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v; cin>>u>>v;
		G[u].pb(v);
		R[v].pb(u);
	}
	for (int i=0;i<n;i++)
		if (!vis[i]) dfs(i);
	for (auto it=ts.rbegin();it!=ts.rend();it++)
		if (!vis2[*it]) dfs2(*it,scc++);
	cin>>q;
	for (int i=0;i<q;i++) {
		int u,v; cin>>u>>v;
		cout<<(gp[u]==gp[v])<<'\n';
	}
}


Measured memory_bytes: 4848
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define ll long long
#define chushihua(x,y) memset(x,y,sizeof x)
using namespace std;
const int MAXX = 100000 + 10;
const double PI = 3.14159265358979323846;
const ll mod = 1000000007;
int main() {
	int t;
	ll n, m;
	cin >> t;
	while (t--) {
		scanf("%I64d%I64d", &n, &m);
		ll sum = n * m;
		ll  ans = (int)sqrt(sum);
		if ( ans*ans == sum) {
			if (n == m)
				cout << (ans - 1) * 2 << endl;
			else
				cout << (ans - 1) * 2 - 1 << endl;
		}
		else if (ans*(ans+1)<sum){
			cout << ans * 2-1 << endl;
		}
		else {
			cout << (ans - 1) *2  << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 384
# 貪欲+山登り(2点交換+1点更新)
import time
import random

d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]

# 貪欲法による初期解の構築
T = []
L = [-1 for j in range(26)]
for i in range(d):
    max_diff = -10**7
    arg_max = 0
    for j in range(26):
        memo = L[j]
        L[j] = i
        diff = S[i][j] - sum([C[k] * (i - L[k]) for k in range(26)])
        if diff > max_diff:
            max_diff = diff
            arg_max = j
        L[j] = memo
    T.append(arg_max)
    L[arg_max] = i


def calc_score(T):
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    score = 0
    for i in range(d):
        score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        score -= C[j] * (dd - X[j])
    return score


score = calc_score(T)
start = time.time()
while True:
    now = time.time()
    if now - start > 1.8:
        break
    # 1点更新
    i = random.choice(range(d))
    j = random.choice(range(26))
    memo = T[i]
    T[i] = j
    new_score = calc_score(T)
    T[i] = memo
    if new_score > score:
        T[i] = j
        score = new_score
    # 2点交換
    i0 = random.choice(range(d))
    z = random.choice(range(10))
    i1 = i0 - z if i0 > z else i0 + z
    T[i0], T[i1] = T[i1], T[i0]
    new_score = calc_score(T)
    T[i0], T[i1] = T[i1], T[i0]
    if new_score > score:
        T[i0], T[i1] = T[i1], T[i0]
        score = new_score
    # 2点交換
    i0 = random.choice(range(d))
    z = random.choice(range(10))
    i1 = i0 - z if i0 > z else i0 + z
    T[i0], T[i1] = T[i1], T[i0]
    new_score = calc_score(T)
    T[i0], T[i1] = T[i1], T[i0]
    if new_score > score:
        T[i0], T[i1] = T[i1], T[i0]
        score = new_score
for t in T:
    print(t + 1)


Measured memory_bytes: 100268
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,a,b,c,d;std::string s;
    std::cin>>n>>a>>b>>c>>d>>s;
    a--,b--,c--,d--;
    auto can_reach=[&](lint x,lint y){
        while(x<y){
            if(s.at(x+1)=='.')x++;
            else{
                if(x==y-1||s.at(x+2)=='#')return false;
                x+=2;
            }
        }
        assert(x==y);
        return true;
    };
    if(!can_reach(a,c)||!can_reach(b,d)){
        std::cout<<"No"<<'\n';
        return 0;
    }
    if(c<d){
        assert(a<b&&b<c&&c<d||a<c&&c<b&&b<d);
        std::cout<<"Yes"<<'\n';
        return 0;
    }
    assert(a<b&&b<d&&d<c);
    for(lint i=b;i<=d;i++){
        if(s.substr(i-1,3)=="..."){
            std::cout<<"Yes"<<'\n';
            return 0;
        }
    }
    std::cout<<"No"<<'\n';
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong X;
  cin >> X;

  int ans = 0;
  llong money = 100;
  while (money < X) {
    money *= 1.01;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    string ans = "Three";

    for (int i = 0; i < N; i++){
        string S;
        cin >> S;
        if (S == "Y") {
        ans = "Four";
        break;
        }
    }
    cout << ans << endl;
}

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

const long long m=6e5,mod=2e9;
typedef long long ll;


int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long h,n;
    cin>>h>>n;
    long long dam[n+1],mana[n+1];

    for (long long  i = 0; i < n; i++)
    {
        cin>>dam[i]>>mana[i];
    }
    long long minmana[h+1];
    for (long long  i = 0; i <= h; i++)
    {
        minmana[i]= INT_MAX;
    }
    for (long long i = 0; i <= h ; i++)
    {
        for (long long  j = 0; j < n; j++)
        {
            long long temp;
            if (dam[j]>=i)
            {
                temp = mana[j];
            }else
            {
                temp = mana[j] + minmana[i-dam[j]];
            }
            if (temp< minmana[i])       
            {
                minmana[i]=temp;
            }
            
            
        }
        
    }
    
    cout<<minmana[h]<<endl;
    

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int x,y;
  cin>>x>>y;
  if(x % y == 0){
    cout<<-1<<endl;
    return 0;
  }

  cout<<x<<endl;
  
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s,t;
    cin>>s;
    map<string,int> mp;
    mp[s]++;
    t=s;
    bool maki=true;
    for(int i=1;i<n;i++){
    	cin>>s;
    	if(mp[s]==1){
    		maki=false;
    	}
    	if(t[t.length()-1]!=s[0]){
    		maki=false;
    	}
    	mp[s]++;
    	t=s;
    }
    if(maki){
    	cout << "Yes" <<endl;
    }
    else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
//=======================================
// abc143a
//
//  2019/10/19
//=======================================

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

int main(int argc, char* argv[])
{
	cin.tie(0);
  ios::sync_with_stdio(false);

  int a, b; cin >> a >> b;

  int c=a-2*b;

  if(c<0) cout << "0" << endl;
  else cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int digit(int x)
{
  int i;
  for(i=1; x/=10; i++)
    ;
  return i;
}

int main()
{
  int a, b;

  while(scanf("%d %d", &a, &b) != EOF)
    printf("%d\n", digit(a+b));

  return 0;
}

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

int main() {
	int N, Q, ansL, ansR, L, R;
	string S;
	static pair<char, char> A[200000];
	cin >> N >> Q >> S;
	for (int i = 0; i < Q; i++) {
		cin >> A[i].first >> A[i].second;
	}
	L = 0, R = N;
	while (R - L > 0) {
		int mid = (L + R) / 2, G = mid;
		bool check = true;
		for (int i = 0; i < Q; i++) {
			if (S[G] == A[i].first) {
				if (A[i].second == 'L') G--;
				else G++;
			}
			if (G < 0) {
				check = false;
				break;
			}
			if (G >= N) {
				break;
			}
		}
		if (check) R = mid;
		else L = mid + 1;
	}
	ansL = R;
	L = 0, R = N;
	while (R - L > 0) {
		int mid = (L + R) / 2, G = mid;
		bool check = true;
		for (int i = 0; i < Q; i++) {
			if (S[G] == A[i].first) {
				if (A[i].second == 'L') G--;
				else G++;
			}
			if (G >= N) {
				check = false;
				break;
			}
			if (G < 0) {
				break;
			}
		}
		if (check) L = mid + 1;
		else R = mid;
	}
	ansR = L;
	cout << ansR - ansL;
}

Measured memory_bytes: 900
n = int(input())
A = list(map(int, input().split()))

rgb = [0, 0, 0]
ans = 1
for a in A:
    if a not in rgb:
        print(0)
        break
    ans = (ans * rgb.count(a)) % 1000000007
    idx = rgb.index(a)
    rgb[idx] += 1
else:
    print(ans)


Measured memory_bytes: 14396
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int,int> >vec;
int n, W, v[100000], w[100000], m[100000];
int dp[100000];
int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i] >> m[i];
		int cnt = 1;
		while (m[i] > 0) {
			if (cnt > m[i]) { vec.push_back(make_pair(m[i]*v[i], m[i] * w[i])); break; }
			vec.push_back(make_pair(cnt*v[i], cnt*w[i])); m[i] -= cnt;
			cnt *= 2;
		}
	}
	for (int i = 0; i < vec.size(); i++) {
		for (int j = W; j >= vec[i].second; j--) {
			dp[j] = max(dp[j], dp[j - vec[i].second] + vec[i].first);
		}
	}
	int maxn = 0; for (int i = 0; i <= W; i++)maxn = max(maxn, dp[i]);
	cout << maxn << endl;
	return 0;
}

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

int main(){

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

    if(a==b&&b==c) cout<<1<<endl;
    else if(a!=b&&b!=c&&c!=a) cout<<3<<endl;
    else cout<<2<<endl;









    return 0;
}

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

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

  bool isok = false;
  if(a == b + c){
    isok = true;
  }else if(b == a + c){
    isok = true;
  }else if(c == b + a){
    isok = true;
  }

  std::cout << (isok ? "Yes" : "No") << std::endl;

}


Measured memory_bytes: 256
import math
if __name__ == "__main__":
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            tmp = math.gcd(i,j)
            for k in range(1,n+1):
                ans += math.gcd(tmp,k)

    print(ans)


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

vector<ll> a;
set<ll> s;

int main(void)
{
  ll n;
  ll a1;
  cin >> n;
  REP(i, n) {
    cin >> a1;
    a.push_back(a1 - 1);
  }
  ll st = 0;
  ll cnt = 0;
  while(1) {
    //    cout << cnt << ":" << st << endl;
    if(s.count(st)==1) {
      cout << -1 << endl;
      return 0;
    }
    if(st == 1) {
      cout << cnt << endl;
      return 0;
    }
    cnt ++;
    s.insert(st);
    st = a[st];
  }
}


Measured memory_bytes: 5748
h,w = map(int,input().split())
si = [input() for i in range(h)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1 for _ in range(n+1)]
 
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
 
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
ki = UnionFind(h*w)

vx = [0,1,0,-1]
vy = [1,0,-1,0]

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            #print(i,j,i,j)
            for k in range(4):
                ny = i + vy[k]
                nx = j + vx[k]
                if ny >= 0 and ny < h and nx >= 0 and nx < w:
                    #print(ny,nx)
                    if si[ny][nx] == '.':
                        #print(i,j,ny,nx)
                        #print(ki.same_check(i*w+j,ny*w+nx))
                        if ki.same_check(i*w+j,ny*w+nx) == True:
                            continue
                        #print(i,j,k)
                        ki.union(i*w+j,ny*w+nx)
                        #print(ki.par)
ans = 0
#exit()


#print(ki.size)
#print(ki.par)
li = [0]*(h*w+1)

for i in range(h):
    for j in range(w):
        #print(ki.find(i*w+j),1111111)
        ki.find(i*w+j)
        """
        if si[i][j] == '.':
            li[ki.find(i*w+h)] += 1
            print(ki.find(i*w+h))
        """
#print(ki.par)
for i in range(h):
    for j in range(w):
        if si[i][j] == '.':
            li[ki.par[i*w+j]] += 1
            #print(ki.par[i*w+h],ki.par)
#print(li)
#print(ki.par)

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            #print(ki.size[i*w+j])
            #print(i,j)
            #tmp = 
            #print(ki.find(i*w+j))
            ans += li[ki.find(i*w+j)]
            #print(ans,i,j)
            
print(ans)

Measured memory_bytes: 67464
//ITP 1_6_A
#include <iostream>
using namespace std;

int  main(){
    int num[101], n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> num[i];
    }
    for(int i=n-1; i>=0; i--){
        cout << num[i];
        if(i>0)
            cout << " ";
    }
    cout << endl;
    return 0;
}



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

string s;
deque<int> d;

long long int dp[60][60][2][2];
bool use[60][60][2][2];

inline long long int dfs(int lef, int rig, bool up, bool dw){
	if (lef > rig)return 1;
	if (use[lef][rig][up][dw])return dp[lef][rig][up][dw];
	dp[lef][rig][up][dw] = 0;
	use[lef][rig][up][dw] = true;
	for (int L = 0; L < 10; L++){
		for (int R = 0; R < 10; R++){
			if (lef == 0 && L == 0)continue;
			if (lef == rig&&L != R)continue;
			int cur_L = L;
			if (dw){
				cur_L--;
			}
			bool nex_dw = false;
			if (cur_L < R){
				nex_dw = true;
				while(cur_L<R)cur_L += 10;
			}
			if (cur_L - R != d[rig]){
				continue;
			}
			for (int nex_up = 0; nex_up < 2; nex_up++){
				int cur_R = R;
				if (nex_up){
					cur_R--;
				}
				bool up_load = false;
				if (cur_R < L){
					up_load = true;
					cur_R += 10;
				}
				if (up_load&&up == false){
					continue;
				}
				if (up_load == false && up){
					continue;
				}
				if (cur_R - L != d[lef])continue;
				if (lef == rig){
					if (nex_dw != up)continue;
					if (dw != nex_up)continue;
				}
				if (lef + 1 == rig){
					if (nex_up != nex_dw)continue;
				}
				dp[lef][rig][up][dw]+=dfs(lef + 1, rig - 1, nex_up, nex_dw);
			}
		}
	}	
	return dp[lef][rig][up][dw];
}
int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		d.push_back(s[i] - '0');
	}
	long long int ans = 0;
	for (int i = s.size(); i < 50; i++){
		while (d.size() < i){
			d.push_front(0);
		}
		memset(use, false, sizeof(use));
		ans += dfs(0, i - 1, false, false);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
// Target Expert 
 
/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 6.08.19
 */
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;
 
 
//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
 
#else
#define deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif
 
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
 
const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;
 
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
 
 
const int N = 1e5 + 5;
int n,k;
int a[N];
int cache[N];
 
 
 
 
 
int dp(int stone){
 
 
 
	if(cache[stone]!=-1)
		return cache[stone];
	cache[stone]=0;
	fr(i,0,n){
		if(stone-a[i]<0)
			break;
		cache[stone]|=(dp(stone-a[i])==0);
	}
	return cache[stone];
 
 
 
}
 
 
 
 
void solve(){
 
 
	cin>>n>>k;
	fr(i,0,n) cin>>a[i];
	memset(cache,-1,sizeof(cache));
 
	if(dp(k)) cout<<"First";
	else cout<<"Second";
 
 
}
 
 
 
 
signed main() {
	fio;
	
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}
 
	
	return 0;
}

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

int main(){
    ll T[2], A[2], B[2];
    rep(i,0, 2) cin >> T[i];
    rep(i,0, 2) cin >> A[i];
    rep(i,0, 2) cin >> B[i];
    ll t1 = T[0] * A[0] - T[0] * B[0];
    ll t2 =  T[1] * A[1] - T[1] * B[1];
    ll ans;

    ll sum = t1 + t2;
    if(sum == 0){
        cout << "infinity" << endl;
        return 0;
    }else if(t1 < 0 &&  sum < 0){
        cout << 0 << endl;
        return 0;
    }else if(t1 > 0 &&  sum > 0){
        cout << 0 << endl;
        return 0;
    }else{
        ll cnt = llabs(t1) / llabs(sum);
        ans = cnt * 2;
        if(llabs(t1) % llabs(sum) == 0){
            ans--;
        }
        ans++;
        cout << ans << endl;
    }


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))


typedef long long lint;

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

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	lint n; cin >> n;
	lint i_= 1;
	repi_(i, 1, n) {
		i_ = (i_ * i) % 1000000007;
	}
	co(i_);
	gc();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14
char H[M][L];
int getChar(char ch){
 if(ch=='A')return 1;
 else if(ch=='C')return 2;
 else if(ch=='G')return 3;
 else if(ch=='T')return 4;
 else return 0;
}
long long getKey(char str[]){
 long long sum=0,p=1,i;
 for(i=0;i<strlen(str);i++){
  sum+=p*(getChar(str[i]));
  p*=5;
 }
 return sum;
}
int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}
int find(char str[]){
 long long key,i,h;
 key=getKey(str);
 for(i=0;;i++){
  h=(h1(key)+i*h2(key))%M;
  if(strcmp(H[h],str)==0)return 1;
  else if(strlen(H[h])==0)return 0;
 }
 return 0;
}
int insert(char str[]){
 long long key,i,h;
 key=getKey(str);
 for(i=0;;i++){
  h=(h1(key)+i*h2(key))%M;
  if(strcmp(H[h],str)==0)return 1;
  else if(strlen(H[h])==0){
   strcpy(H[h],str);
   return 0;
  }
 }
 return 0;
}
int main(){
 int i,n,h;
 char str[L],com[9];
 for(i=0;i<M;i++)H[i][0]='\0';
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%s %s",com,str);
  if(com[0]=='i')insert(str);
  else {
   if(find(str))printf("yes\n");
   else printf("no\n");
  }
 }
 return 0;
}


Measured memory_bytes: 16956