akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, X;
    cin >> N >> X;
    vector<long long> m(N);
    REP(i, N) {
        cin >> m[i];
        X -= m[i];
    }
    long long r = *min_element(ALL(m));
    cout << N + X / r << endl;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

int powMod(int n, int p) {
  int res = 1;
  while (p) {
    if (p & 1) (res *= n) %= MOD;
    (n *= n) %= MOD;
    p >>= 1;
  }
  return res;
}
int invMod(int n) {
  return powMod(n, MOD - 2);
}

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

  int ans = powMod(2, n)-1;
  ans -= comb(n, a);
  ans -= comb(n, b);
  while(ans < 0) ans += MOD;
  cout << ans%MOD << endl;
  


  return 0;
}

Measured memory_bytes: 256
// abc136_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    int i = 0;
    vector<int> indices(S.size());
    vector<int> place;

    int idx = 0;
    while(i < S.size()){

        indices[i] = idx;
        while(S[i+1] == 'R'){
            i++;
            indices[i] = idx;
        }
        place.emplace_back(i);

        i++;
        indices[i] = idx;
        while(S[i+1] == 'L'){
            i++;
            indices[i] = idx;
        }

        i++;
        idx++;
    }

    vector<int> ans(S.size(), 0);
    REP(i, S.size()){
        int p = place[indices[i]];
        if (abs(i - p) % 2 == 0){
            ans[p]++;
        }else{
            ans[p+1]++;
        }
    }

    REP(i, S.size() - 1){
        cout << ans[i] << " ";
    }
    cout << ans[S.size() - 1] << endl;

    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int minv = N;
	for ( int i = 0; i <= N; i++ ) {
		int t = i;
		int cnt = 0;
		while ( t > 0 ) {
			cnt += t % 6;
			t /= 6;
		}
		t = N - i;
		while ( t > 0 ) {
			cnt += t % 9;
			t /= 9;
		}
		minv = min(minv, cnt);
	}

	cout << minv << endl;
	return ( 0 );
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

int s[100000];

int main()
{
	int N, K;
	while (scanf("%d%d", &N, &K), N | K)
	{
		for (int i = 0; i < K; ++i)
			scanf("%d", s + i);

		bool yes = true;
		while (N--)
		{
			for (int i = 0; i < K; ++i)
			{
				int b;
				scanf("%d", &b);
				s[i] -= b;
				if (s[i] < 0)
					yes = false;
			}
		}

		if (yes)
			puts("Yes");
		else
			puts("No");
	}

	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long lint;
int main(){
    int num;
    vector<int> in = {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};
    cin >> num;
    cout << in[num - 1] << endl;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  vector<vector<LL>> lun(0, vector<LL>(0));

  LL cnt = 0;

  while(true){
    lun.push_back(vector<LL>(0));
    if(lun.size()==1){
      FOR(i,1,10){
        lun[lun.size() - 1].push_back(i);
        cnt++;
        if(cnt==N){
          cout << i << endl;
          return 0;
        }
      }
    }else{
      REP(i,lun[lun.size()-2].size()){
        auto x = lun[lun.size() - 2][i];
        
        FOR(i,0,10){
          if(abs(x%10-i)<=1){
            LL y = x * 10 + i;
            lun[lun.size() - 1].push_back(y);
            cnt++;
            if(cnt==N){
              cout << y << endl;
              return 0;
            }
          }
        }
      }
    }
  }
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); ++i) {
    int c = (s[i] - 'A' + n) % 26;
    ans += c + 'A';
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
	int N, X;
	cin >> N >> X;
	int current = 0;
	int ans = 1;
	rep(i, N){
		int L;
		cin >> L;
		current += L;
		if (current <= X) ans++;
		else break;
	}	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s;
int ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]>'5')
		{
			ans+='9'-s[i]+1;
			if(i==0)ans++;
			else s[i-1]++;
		}
		else if(s[i]=='5'&&i!=0)
		{
			if(s[i-1]>'4')
			{
				ans+=5;
				s[i-1]++;
			}
			else ans+=5;
		}
		else ans+=s[i]-'0';
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1948
#include<stdio.h>


#define rep( i ,end ) for( int i = 0 ; i < end ; ++i )

#define CityN 10
#define INF 1000000

void Init( int NODE[ CityN ][ CityN ] ,int N )
{
	rep( i ,N )
	{
		rep( j ,N )
		{
			NODE[ i ][ j ] = ( i == j ) ? 0 : INF ;
		}
	}
}

int min( int a ,int b )
{
	return a > b ? b : a ;
}

int max( int a ,int b )
{
	return a > b ? a : b ;
}


int Node[ CityN ][ CityN ] ;

int main( void )
{
	int N ,n ,a ,b ,cost ;
	do
	{
		scanf( "%d" ,&N ) ;

		if( N == 0 )
		{
			return 0 ;
		}

		n = 0 ;
		Init( Node ,CityN ) ;

		rep( i ,N )
		{
			scanf( "%d %d %d" ,&a ,&b ,&cost ) ;
			
			Node[ a ][ b ] = Node[ b ][ a ] = cost ;

			n = max( n ,max( a ,b ) ) ;
		}

		N = n + 1 ;

		rep( k ,N )
		{
			rep( i ,N )
			{
				rep( j ,N )
				{
					Node[ i ][ j ] = min( Node[ i ][ j ] ,Node[ i ][ k ] + Node[ k ][ j ] ) ;
				}
			}
		}

		int Min = INF ,V ;
		rep( i ,N )
		{
			int sum = 0 ;

			rep( j ,N )
			{
				sum += Node[ i ][ j ] ;
			}

			if( Min > sum )
			{
				V = i ;
				
				Min = sum ;
			}
		}

		printf( "%d %d\n" ,V ,Min ) ;

	}while( 1 ) ;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  long long h, w;
  bool result = false;

  cin >> h >> w;

  char a[h][w];

  for (int i = 0; i < h; i++)
  {
    for (int l = 0; l < w; l++)
    {
      cin >> a[i][l];
    }
  }

  for (int i = 1; i < h - 1; i++)
  {
    for (int l = 1; l < w - 1; l++)
    {
      if (a[i][l] == '#')
      {
        if (!(a[i][l] == a[i][l - 1] ||
                a[i][l] == a[i][l + 1] ||
                  a[i][l] == a[i - 1][l] ||
                    a[i][l] == a[i + 1][l]))
        {
          cout << "No" << endl;
          exit(0);
        }
      }
    }
  }

  cout << "Yes" << endl;

}

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

int main(){
  int a,b;
  cin >> a >> b;
  a=(a+11)%13;
  b=(b+11)%13;
  if(a>b){
    cout << "Alice" << endl;
  }else if(a<b){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
}

Measured memory_bytes: 256
import sys
l = sys.stdin.readline().strip()
N, M, K = map(int, l.split())
comb_quick = {}
mod = 998244353
C = [1]
for i in range(1, (N-1) // 2 + 1):
    next = C[-1] * (N-i) * pow(i, mod-2, mod)
    C.append(next % mod)
 
res = 0
 
for x in range(K+1):
    crt =  (pow(M-1, N-x-1, mod) * M) % mod 
    crt %= mod
    #print("start")
    idx = min(x, N-1-x)
    crt *= C[idx]
    #print("end")
    crt %= mod
    res += crt
    res %= mod
 
print(res)

Measured memory_bytes: 78780
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string.h>
#include <vector>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

int n,K;

bool dp[100001];

int main(){
	IOS;
	
	cin >> n >> K;
	int a[n];
	for(int i=0; i < n ; ++i){
		cin >> a[i];
	}

	for(int i=0;i<=K ; ++i){
		for(int j = 0;j<n ; ++j){
			if(i>=a[j] &&  !dp[i-a[j]]){
				dp[i] = true;
			}
		}
	}
	if(dp[K]){
		cout << "First" << endl;
	}
	else{
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
  string s;cin >> s;
  int n=s.size();
  ll dp[n+1][2];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(int i=0;i<n;i++){
      int p=s[i]-'0';
      if(p){
          dp[i+1][0]+=dp[i][0]*2;
          dp[i+1][1]+=dp[i][1]*3+dp[i][0];
      }
      else{
          dp[i+1][0]+=dp[i][0];
          dp[i+1][1]+=dp[i][1]*3;
      }
      dp[i+1][0]%=mod;
      dp[i+1][1]%=mod;
  }
  cout << (dp[n][0]+dp[n][1])%mod << endl;
}

Measured memory_bytes: 2048
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> X(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> X.at(i);
    }

    ll countMin = 10000000;
    for (ll i = 1; i <= 100; i++)
    {
        ll count = 0;
        for (ll j = 0; j < N; j++)
        {
            count += (X.at(j) - i) * (X.at(j) - i);
        }
        countMin = min(count, countMin);
    }

    cout << countMin << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K = inputIL()

if N%K == 0:
  print(0)
else:
  print(1)

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

int gcd(int x,int y){
    int r;
    if (x < y){
        swap(x,y);
    }
    while(y>0){
        r = x%y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    int x,y,ans;
    cin >> x >> y;
    ans = gcd(x,y);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[10005];
int32_t main(){
	int n,ans=0;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		while(!(ar[i]&1)){
			ans++;
			ar[i]/=2;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 384
#include<stdio.h>
const int SIZE=100;
int data[SIZE]={0};
int sp=0;
int size(){
  return sp;
}
int empty(){
  return sp<=0;
}
int isfull(){
  return sp>=SIZE;
}
int top(){
  return data[sp-1];
}
void pop(){
  sp--;
}
void push(int v){
  data[sp]=v;
  sp++;
}
int main(){
  int k,n;
  for(k=0;k<100;k++){
    scanf("%d",&n);
    if(empty()&&n==0)break;
    if(!empty()&&n==0){
      printf("%d\n",top());
      pop();
    }else if(!isfull()){
      push(n);
    }
  }
  return 0;
}

Measured memory_bytes: 2552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(100), y(100), a(100);
    rep(i, n) {
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }
    int maxx, maxy, minx, miny;
    maxx = w; maxy = h;
    minx = 0; miny = 0;
    rep(i, n) {
        if(a.at(i) == 1) minx = max(minx, x.at(i));
        else if(a.at(i) == 2) maxx = min(maxx, x.at(i));
        else if(a.at(i) == 3) miny = max(miny, y.at(i));
        else maxy = min(maxy, y.at(i));
    }
    int dx, dy;
    dx = max(0, maxx - minx);
    dy = max(0, maxy - miny);
    cout << dx * dy << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	s := readLine()
	l := len(s)

	indexes := []int{}
	before := ""
	for i:=0; i<l ;  {
		j:=1
		for ; j+i<l+1; j++ {
			c := s[i:i+j]
			log.Printf("c: %+v", c)

			if before == c {
				log.Printf("equal to before")
				continue
			}

			indexes = append(indexes, i)
			before = c
			break
		}

		i = i + j
	}

	log.Printf("indexes: %+v", indexes)
	fmt.Printf("%d", len(indexes))
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
int a1[10];
bool ok(long long int a)
{
    while(a)
    {
int        c=a%10;
        if(a1[c]==1)
            return false;
        a=a/10;
    }
    return true;
}
int main()
{

    long long int a,b,c,d,i,j,k,l;
    cin>>a>>b;
    memset(a1,0,sizeof(a1));
    for(i=0;i<b;i++)
    {
        cin>>c;
        a1[c]=1;

    }
    i=a;
    while(1)
    {
        if(ok(i)==true)
        {
            cout<<i;
            return 0;
        }
        i++;
    }


}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int N,M;
    cin >> N >> M;
    vector<int> rules(N+1,-1);
    bool failCheck = false;
    REP(_,M) {
        int s,c;
        cin >> s >> c;

        // 先頭に0は禁止
        if (s==1 && c==0) {
            failCheck = true;
        }

        if (rules[s] == -1) {
            rules[s] = c;
            continue;
        }

        // コリジョン
        if (rules[s] != c) {
            cout << -1 << endl;
            return;
        }
    }

    // 先頭が0でも良い場合
    if (failCheck) {
        if (rules[1] == 0 && N == 1) cout << 0 << endl;
        else cout << -1 << endl;
        return;
    }

    // maybe last case
    if (N == 1 && M == 0) {
        cout << 0 << endl;
        return;
    }

    REP(i,N) {
        //　最小
        auto mini = (i == 0) ? 1 : 0;
        // 制約があるならそれを使う
        cout << ( (rules[i+1] != -1) ? rules[i+1] : mini);
    }
    cout << endl;
}

int main() {
    solve();
    return 0;
}


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

int main() {
    long long T, a, b, c, d;
    cin >> T;
    while (T--) {
        cin >> a >> b >> c >> d;
        if (b > a || b > d) { printf("No\n"); continue; }
        long long g = __gcd(b, d);
        printf("%s\n", (a - (a - c - 1) / g * g - b) >= 0 ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    string s;
    cin >> s;
    bool a=false,b=false;
    rep(i,s.length()){
        if(s[i]=='C'){
            a = true;
        }
        if(s[i]=='F'&&a==true){
            b = true;
        }
    }
    if(a==true && b == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	
	int A, B, M; cin >> A >> B >> M;
	vector<int> a(A);
	vector<int> b(B);

	REP(i,A) cin >> a[i];
	REP(i,B) cin >> b[i];

	vector<int> x(M);
	vector<int> y(M);
	vector<int> c(M);

	REP(i,M) cin >> x[i] >> y[i] >> c[i];

	int ans = INF;
	REP(i,M){
		int g = x[i] - 1;
		int f = y[i] - 1;
		ans = min(ans, a[g]+b[f] - c[i]);
	}

	SORT(a);
	SORT(b);

	ans = min(ans, a.front() + b.front());
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
const int inf=(int)1e9;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};

int a[100001];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;// if the problem is interactive , please coment out 
  //FILE *stream2;
  stream1=freopen("in","r",stdin);// if the problem is interactive , please coment out 
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int now=0;
  int diff;
  for(int i=0;i<n;i++){
    if(i==0){
      now=a[i];
      diff=min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2-(a[n-1]-a[i])));
    }else{
      if(diff>min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2-(a[n-1]-a[i])))){
        now=a[i];
        diff=min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2-(a[n-1]-a[i])));
      }
    }
  }
  cout<<a[n-1]<<" "<<now<<endl;
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);// if the problem is interactive , please coment out 
  //fclose(stream2);
#endif
  return 0;
}






Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(a[1]-a[0])
for i in range(n-2):
  dp[i+2]=min(dp[i+1] + abs(a[i+2]-a[i+1]), dp[i] + abs(a[i+2]-a[i]))
  
print(dp[n-1])




Measured memory_bytes: 13980
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func power(_ a: Int, _ b: Int) -> Int {
    var ans = 1
    for _ in 1...b {
        ans *= a
    }
    return ans
}

func main() {
    let patterns = [
        [0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0],
        [0, 1, 0, 0, 0, 0],
        [1, 1, 0, 0, 0, 0],
        [0, 0, 1, 0, 0, 0],
        [1, 0, 1, 0, 0, 0],
        [0, 1, 1, 0, 0, 0],
        [1, 1, 1, 0, 0, 0],
        [0, 0, 0, 1, 0, 0],
        [1, 0, 0, 1, 0, 0],
        [0, 1, 0, 1, 0, 0],
        [1, 1, 0, 1, 0, 0],
        [0, 0, 1, 1, 0, 0],
        [1, 0, 1, 1, 0, 0],
        [0, 1, 1, 1, 0, 0],
        [1, 1, 1, 1, 0, 0],
        [0, 0, 0, 0, 1, 0],
        [1, 0, 0, 0, 1, 0],
        [0, 1, 0, 0, 1, 0],
        [1, 1, 0, 0, 1, 0],
        [0, 0, 1, 0, 1, 0],
        [1, 0, 1, 0, 1, 0],
        [0, 1, 1, 0, 1, 0],
        [1, 1, 1, 0, 1, 0],
        [0, 0, 0, 1, 1, 0],
        [1, 0, 0, 1, 1, 0],
        [0, 1, 0, 1, 1, 0],
        [1, 1, 0, 1, 1, 0],
        [0, 0, 1, 1, 1, 0],
        [1, 0, 1, 1, 1, 0],
        [0, 1, 1, 1, 1, 0],
        [1, 1, 1, 1, 1, 0],
        [0, 0, 0, 0, 0, 1],
        [1, 0, 0, 0, 0, 1],
        [0, 1, 0, 0, 0, 1],
        [1, 1, 0, 0, 0, 1],
        [0, 0, 1, 0, 0, 1],
        [1, 0, 1, 0, 0, 1],
        [0, 1, 1, 0, 0, 1],
        [1, 1, 1, 0, 0, 1],
        [0, 0, 0, 1, 0, 1],
        [1, 0, 0, 1, 0, 1],
        [0, 1, 0, 1, 0, 1],
        [1, 1, 0, 1, 0, 1],
        [0, 0, 1, 1, 0, 1],
        [1, 0, 1, 1, 0, 1],
        [0, 1, 1, 1, 0, 1],
        [1, 1, 1, 1, 0, 1],
        [0, 0, 0, 0, 1, 1],
        [1, 0, 0, 0, 1, 1],
        [0, 1, 0, 0, 1, 1],
        [1, 1, 0, 0, 1, 1],
        [0, 0, 1, 0, 1, 1],
        [1, 0, 1, 0, 1, 1],
        [0, 1, 1, 0, 1, 1],
        [1, 1, 1, 0, 1, 1],
        [0, 0, 0, 1, 1, 1],
        [1, 0, 0, 1, 1, 1],
        [0, 1, 0, 1, 1, 1],
        [1, 1, 0, 1, 1, 1],
        [0, 0, 1, 1, 1, 1],
        [1, 0, 1, 1, 1, 1],
        [0, 1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1, 1],
    ]
    
    let line = readInts()
    let h = line[0]
    let w = line[1]
    let k = line[2]
    var cs: [[String]] = []
    for _ in 1...h {
        let c = Array(readLine()!).map { String($0) }
        cs.append(c)
    }
    
    var ans = 0
    for i in 0..<power(2, h) {
        let h_pattern = patterns[i]
        for j in 0..<power(2, w) {
            let w_pattern = patterns[j]
            var black_count = 0
            for u in 0..<h {
                for v in 0..<w {
                    if h_pattern[u] == 0 && w_pattern[v] == 0 && cs[u][v] == "#" {
                        black_count += 1
                    }
                }
            }
            if black_count == k {
                ans += 1
            }
        }
    }
    
    print(ans)
}

main()


Measured memory_bytes: 8276
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

template<typename V>
size_t KMP(const V &Search,const V &Word){
    size_t i=2,j=0;
    std::vector<int> Table(Search.size());
    Table[0]=-1;Table[1]=0;
    while(i<Word.size()){
        if(Word[i-1]==Word[j]){
            Table[i]=j+1;
            ++i;++j;
        }
        else if(j>0) j=Table[j];
        else{
            Table[i]=0;
            ++i;
        }
    }
    i=0;j=0;
    while(j+i<Search.size()){
        if(Word[i]==Search[j+i]){
            ++i;
            if(i==Word.size()) return j;
        }
        else{
            j+=i-Table[i];
            if(i>0) i=Table[i];
        }
    }
    return Search.size();
}

template<class V> 
vector<int> Zalgo(V s){
    vector<int> A(s.size(),0);
    A[0]=s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
        while (i+j < s.size() && s[j] == s[i+j]) ++j;
        A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < s.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
    }
    return A;
}

int main(){
    int N;cin>>N;
    vector<int> A(N),B(N);
    REP(i,N) cin>>A[i];
    REP(i,N) cin>>B[i];
    vector<int> C(2*N),D(N);
    REP(i,N){
        C[i+N]=C[i]=A[i]^A[(i+1)%N];
        D[i]=B[i]^B[(i+1)%N];
    }
    int ini=KMP(C,D);
    if(ini==2*N) return 0;
    ini%=N;
    vector<int> S(N);
    REP(i,N) S[i]=C[i+ini];
    C=Zalgo(S);
    cout<<ini<<" "<<(A[ini]^B[0])<<endl;
    rep(i,1,N) if(C[i]==N-i){
        if(C[N-i]==i) cout<<ini+i<<" "<<(A[(ini+i)%N]^B[0])<<endl;
    }
}


Measured memory_bytes: 8136
#include <stdio.h>

using namespace std;
long long int x,i;
int main(){
  scanf("%lld",&x);
  i=(x/11)*2;
  if (x%11==0){}
  else if (x%11<=6){i+=1ll;}
  else {i+=2ll;}
  printf("%lld\n", i);
}


Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int a[]={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;cin>>k;
	cout<<a[k-1];
}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e18;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=1e6+10;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,u,v,h;
    ll x,a,b,c,d,y,w,z,k;
    cin >> n >> k;
    vi pp(n+1), vv(n+1);
    for(int i=1; i<=n; i++){
        cin >> pp[i];
    }
    for(int i=1; i<=n; i++){
        cin >> vv[i];
    }
    vvll dp(n+1);
    
    auto f = [&](int id){
        int n=(int)dp[id].size();
        for(int i=1; i<n; i++){
            dp[id][i]+=dp[id][i-1];
        }
        ll ans;
        if(k>n){
            m=k%n;
            ans=0;
            for(int i=0; i<m; i++){
                ans=max(ans,dp[id][i]);
            }
            ans=max({mx(dp[id]),(k/n)*dp[id][n-1]+ans,(k/n-1)*dp[id][n-1]+mx(dp[id])});
        }
        else{
            ans=dp[id][0];
            for(int i=0; i<k; i++){
                ans=max(ans,dp[id][i]);
            }
        }
        return ans;
    };
    for(int i=1; i<=n; i++){
        int st=i;
        vi vis(n+1,-1);
        while(true){
            if(~vis[st]){
                break;
            }
            else{
                vis[st]=1;
                st=pp[st];
                dp[i].pb(vv[st]);
            }
        }
    }
    a=-1e18;
    for(int i=1; i<=n; i++){
        a=max(a,f(i));
    }
    cout << a << el;
    
    return 0;
}



Measured memory_bytes: 218612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
string a;
signed main()
{
	cin>>a;
	a.erase(a.begin()+(a.size()-8),a.begin()+a.size());
	cout<<a;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n, k] <- readInt
  xys <- map toPair <$> readIntegers n
  print $ solve xys k

solve xys k = minimum $ concat [f xys lr ud k | lr <- leftAndRight, ud <- upAndDown]
  where
    leftAndRight = [(fst $ x' V.! i, fst $ x' V.! j) | i <- [0 .. length x' - 1], j <- [i .. length x' - 1], i < j]
    upAndDown = [(snd $ y' V.! i, snd $ y' V.! j) | i <- [0 .. length y' - 1], j <- [i .. length y' - 1], i < j]
    x' = V.fromList $ sortBy (\(a, _) (b, _) -> a `compare` b) xys
    y' = V.fromList $ sortBy (\(_, a) (_, b) -> a `compare` b) xys

f xys (l, r) (d, u) k =
  let m = length $ filter (\(x, y) -> l <= x && x <= r && d <= y && y <= u) xys
   in [(r - l) * (u - d) | m >= k]

Measured memory_bytes: 2428
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(365)]

now = [0]*26
for i in range(365):
    no = -1
    score = -10**10
    for j in range(26):
        count = s[i][j]
        for k in range(26):
            if j == k:
                continue
            count -= (i+1-now[k])*c[k]
        if count > score:
            no = j
            score = count
    print(no+1)
    now[no] = i
    
    


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

typedef complex<double> P;

const double EPS = 1e-8;
typedef complex<double> P;

struct Circle {
  P c;
  double r;
  Circle() {}
  Circle(P c, double r) : c(c), r(r) {}
};

double dot  (P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }

//??????????????????????????\????????????
vector<P> tangent(Circle c, P p){
  vector<P> res;
  double a = abs(p - c.c);
  if(a < c.r - EPS);
  else if(a < c.r + EPS) res.push_back(p);
  else {
    double b = sqrt(a*a-c.r*c.r);
    double psi = arg(p - c.c);
    double phi = M_PI - acos(b/a);
    res.push_back(p + b * P(cos(psi+phi), sin(psi+phi)));
    res.push_back(p + b * P(cos(psi-phi), sin(psi-phi)));
  }
  return res;
}


double pa(double a){
  return M_PI * a / 180.0;
}

double ga(double a){
  return a/M_PI*180.0;
}

double ra(double a){
  if( a < EPS ) return 2.0 * M_PI + a;  
  return a;
}

double sa(double a,double b){
  return a < b ? a+2*M_PI - b : a - b;
}

//w*r = v , r = v/w
bool check( P ps, double v, double s, double w, bool rf){
  Circle c = Circle( P( 0,0 ), v/w );
  vector<P> rp = tangent( c, ps );
  for(int i=0;i<(int)rp.size();i++){
    double a = ra(arg(rp[i])), b = ra(arg(ps)), c = s;
    if( rf ){ 
      if( sa( a, b ) > M_PI ) continue;
      double k = sa( a, c );
      if( abs( ps - rp[i] )/v < k/w ) return true;
    } else {
      if( sa( b, a ) > M_PI ) continue;
      double k = sa( c, a );
      if( abs( ps - rp[i] )/v < k/w ) return true;
    }
  }
  return false;
}


double solve(P ps, double s, double w ){
  double a = ra(arg(ps));
  bool rf = (sa( a, s ) < sa( s, a ));//true:???????¨????false:????¨?
  double st = 0.0, ed = w*abs(ps);  
  for(int i=0;i<100;i++){
    double v = (st + ed)/2.0;
    if( check( ps, v, s, w, rf ) ) ed = v;
    else st = v;
  }
  return st;
}

int main(){
  int x,y,s,w;
  scanf("%d%d%d%d",&x,&y,&s,&w);
  printf("%.9lf\n",solve(P(x,y),pa(s),pa(w)));
}

Measured memory_bytes: 1308
s=input()
#一文字だけ削除するのめんどい
#文字列はイミュータブルだからか
#下のURLで色々方法みれる
if s[0]=="A" and s[2:-1].count("C")==1 and s[1:].replace("C","").islower():
    print("AC")
else:
    print("WA")




#http://myprogramming.hatenablog.com/entry/2017/07/23/191308


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
  int a;
  scanf("%d", &a);
  if(a < 105)
    printf("0");
  else if(a < 135)
    printf("1");
  else if(a < 165)
    printf("2");
  else if(a < 189)
    printf("3");
  else if(a < 195)
    printf("4");
  else
    printf("5");
  return 0;
  
}

Measured memory_bytes: 128
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	Int N; std::cin >> N;
	std::vector<Int> a(N);
	std::vector<Int> is_odd(N); //奇数かどうか
	bool ans = false;
	rep(i, N) {
		std::cin >> a[i];
		is_odd[i] = (bool)(a[i] % 2);
		if (is_odd[i])ans = true;
	}

	if (ans)std::cout << "first";
	else std::cout << "second";



}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 1792
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m;
int cnt[101101];
int done[101110];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  cin >> n >> m;
  int ac = 0, pen = 0;
  for(int i=1;i<=m;i++){
    int p;
    string s;
    cin >> p >> s;
    if(s=="AC"){
      if(!done[p]){
      pen+=cnt[p];
      done[p]=1;
      ac++;
    }
    }
    else {
      if(!done[p])
      cnt[p]++;
    }
  }
  cout << ac << " " << pen << endl;
  

return 0;
}
///....


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	bool a[n][10];
	int cost[n][11];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 10; j++)
			cin >> a[i][j];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 11; j++)
			cin >> cost[i][j];
	}
	ll ans = -2e18;
	for (int mask = 1; mask < (1 << 10); mask++)
	{
		ll val = 0;
		for (int i = 0; i < n; i++)
		{
			int ind = 0;
			for (int j = 0; j  < 10; j++)
			{
				if ((mask >> j & 1) && a[i][j])
					ind++;
			}
			val += cost[i][ind];
		}
		ans = max(ans, val);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
 
int main(void){
   int a,b,t;
   std::cin >> a>>b>>t;
   std::cout << (t)/a*b << std::endl;
   
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int n;
    cin >> n;
    set<string>st;
    string temp;
    for(int i=0;i<n;++i){
        cin >> temp;
        st.insert(temp);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 19120
N=int(input())
A=list(map(int, input().split()))
SUM=0
ct=0
for i in range(N):
    SUM+=abs(A[i])
    if A[i]<0:
        ct+=1

if ct%2==0:
    print(SUM)
if ct%2==1:
    a=abs(A[0])
    for i in range(N):
        if a>=abs(A[i]):
            a=abs(A[i])
    print(SUM-2*a)

Measured memory_bytes: 14224
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int {
	sc.Scan()
	val, _ := strconv.Atoi(sc.Text())
	return val
}

func main() {
	n := nextLine()

	R := make([]int, n)
	for i := 0; i < n; i++ {
		R[i] = nextLine()
	}

	r_min := R[0]
	d_max := R[1] - R[0]
	for i := 1; i < n; i++ {
		if R[i]-r_min > d_max {
			d_max = R[i] - r_min
		}

		if R[i] < r_min {
			r_min = R[i]
		}
	}

	fmt.Println(d_max)
}



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

signed main(){
  int X;
  cin>>X;
  if(X<1200)cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
}

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

int main() {
  char c,d;
  cin >> c >> d;
  if(c<d){
    cout << '<' << endl;
  }
  else if(c>d){
    cout << '>' << endl;
  }else{
    cout << '=' << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  int N,M,ans=0;
  cin>>N>>M;
  vector<pair<int,vector<int>>> k(M);
  vector<int> p(M);
  for(int i=0;i<M;i++){
    cin>>k[i].first;
    for(int j=0;j<k[i].first;j++){
      int a;
      cin>>a;
      k[i].second.push_back(a);
    }
  }
  for(int i=0;i<M;i++) cin>>p[i];

  for(int i=0;i<(1<<10);i++){
    bitset<10> b(i);
    if(i>=pow(2,N)) break;
    int CNT=0;
    for(int j=0;j<M;j++){
      int cnt=0;
      for(int l=0;l<k[j].first;l++){
        if(b.test(k[j].second[l]-1)) cnt++;
      }
      if(cnt%2==p[j]) CNT++;
    }
    if(CNT==M) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int mod=1e9+7;
LL dp[5005][5005];
int main(){
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    dp[0][0]=1;
    LL ans=0;
    for(int i = 1;i<=(n+m-1)/(k-1)+10;i++){
        LL sum=0;
        for(int j=0;j<=n;j++){
            sum+=dp[i-1][j];
            sum%=mod;
            dp[i][j]=sum;
            if(j>=k-1){
                sum-=dp[i-1][j-k+1];
                sum=(sum%mod+mod)%mod;
            }
            int xx=i*(k-1)-j;
            if(n%(k-1)==j%(k-1)&&j<=n&&xx%(k-1)==(m-1)%(k-1)&&xx<=m-1&&j){
                ans=((ans+dp[i][j]-dp[i-1][j])%mod+mod)%mod;
               // printf("%d %d %d\n",i,j,dp[i][j]-dp[i-1][j]);
            }
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 156928