akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <string>
#include <iostream>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


ull p[1001];
const ull prime=1000000007;

// 文字列のrolling hashをコンストラクタに渡された素数と
// 渡された文字列により計算し、getRollingHashでそれを戻す
class RollingHash{
private:
    ull ary[1001];
    int N;// 文字列長
public:
  RollingHash(const string &str){
    N=str.size();
    // prime**iを計算
    // ハッシュ値を計算
    ary[0]=0;
    for(int i=1;i<=N;i++)
        ary[i]=ary[i-1]*prime+str[i-1];;
  }
    RollingHash(){}
  // 先頭をx,終端をyで指定し、その範囲のハッシュ値を取り出す
  ull getHash(const int x,const int y)const{
    return ary[y+1]-ary[x]*p[y-x+1];
  }
  // 自身の[x1,y1]の範囲でのハッシュ値と
  // rの[x2,y2]の範囲のでのハッシュ値が一致するか調べる
  bool isMatch(const int x1,const int y1,const int x2,const int y2,const RollingHash &r)const{
    return this->getHash(x1,y1)==r.getHash(x2,y2);
  }
};


int N;
string field[301];
RollingHash rhs[301];
RollingHash chs[301];

int main(){


    fastStream();
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> field[i];

    p[0]=1;
    for(int i=1;i<N+5;i++)
        p[i]=p[i-1]*prime;

    int ans = 0;
    for(int i = 0; i < N; i++)
        rhs[i] = RollingHash(field[i]);

    for(int A = 0; A < N; A++){

        for(int j = 0; j < N; j++){
            string s;
            for(int k = 0; k < N; k++)
                s += field[(k + A) % N][j];
            chs[j] = RollingHash(s);
        }
        
        {
            bool ok = true;
            for(int k = 0; k < N; k++){
                if(rhs[(k + A) % N].getHash(0, N-1) != chs[k].getHash(0, N-1)){
                    ok = false;
                }
            }
            ans += ok;
        }

        for(int B = 1; B < N; B++){
            bool ok = true;
            int idx = (N-B);
            for(int i = 0; i < N; i++){
                if(!(rhs[(i + A) % N].getHash(0, N-1-B) == chs[idx].getHash(B, N-1)
                     && rhs[(i + A) % N].getHash(N-B, N-1) == chs[idx].getHash(0, B-1))){
                    ok = false;
                    break;                    
                }
                idx++;
                if(idx >= N)idx -= N;
            }
            ans += ok;
        }
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	long long int n;
	long long int point = 0;
	

	cin >> n;
	vector<long long int >cost(n + 1,0);
	vector<long long int>a(n + 1);
	vector<long long int>b(n + 1);

	FOR(i, 1, n) {
		cin >> a[i];
	}
	a[0] = 0;

	FOR(i, 1, n) {
		point += abs(a[i] - a[i - 1]);
	}
	point += abs(0 - a[n]);

	FOR(i, 1, n-1) {
		b[i] = abs(a[i + 1] - a[i - 1]);
	}
	FOR(i, 1, n-1) {
		cost[i] = point + b[i] - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]);
	}
	cost[n] = point - abs(0 - a[n]) - abs(a[n] - a[n - 1]) + abs(0 - a[n - 1]);

	FOR(i, 1, n) {
		cout << cost[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
int dp[2][1<<21];
void Main() {
  int T,tt=1;
  R T;
  while(T--) {
    int n,m;
    cin >> m >> n;
    int w=m+1;
    int a[n][m];
    rep(i,n)rep(j,m) R a[i][j];
    int k=0,l=1;
    rep(t,1<<w)dp[0][t]=dp[1][t]=0;
    int ans=0;
    rep(i,n*m) {
      int x=i/m,y=i%m;
      rep(t,1<<w)dp[l][t]=0;
      rep(t,1<<w) {
        int s=t|(1<<w);s/=2;
        if(!((y&&(t&(1<<(w-1))))||(t&2))) {
          if(dp[l][s]<dp[k][t]+a[x][y]) dp[l][s]=dp[k][t]+a[x][y];
          if(ans<dp[l][s]) ans=dp[l][s];
        }
        if(dp[l][t/2]<dp[k][t]) dp[l][t/2]=dp[k][t];
      }
      k=l;l^=1;
    }
    cout << "Case " << tt++ << ": " << ans << endl;
  }
}

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


Measured memory_bytes: 17584
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()

    if A >= 13:
        print(B)
    elif A >= 6:
        print(B//2)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10040
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
X=[a,b,c,d,e]
p=min(X)
if n%p==0:
    cnt=n//p+4
else:
    cnt=n//p+5 
    
print(cnt)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc169/tasks/abc169_c
#include<bits/stdc++.h>
using namespace std;

int main() {
	long long a;
	string b;
	cin >> a >> b;
	b.erase(b.size()-3, 1);
	long long bb = stoi(b);
	//int bb = static_cast<int> (b*100);
	//double an = static_cast<double>(a*bb);
	//long long ans = a*bb;
	cout << (long long)(a*bb/100) << endl;
	return 0;
}


Measured memory_bytes: 3628
list = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())

for i in range(n):
    data = input().split()
    list[int(data[0])-1][int(data[1])-1][int(data[2])-1] += int(data[3])

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(f" {list[b][f][r]}", end="")
        print()
    if b < 3:
        print("####################")



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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if (min(B,D) - max(A,C) > 0) {
    cout << min(B,D) - max(A,C) << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;

}


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

#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PrintLn(X) cout << X << endl
int main(void)
{
	int H, W;
	cin >> H >> W;
	char ans[103][103] = {0};
	Rep(h, H){
		char str[103];
		cin >> str;
		ans[h + 1][0] = '#';
		Rep(w, W){
			ans[h + 1][w + 1] = str[w];
		}
		ans[h + 1][W + 1] = '#';
	}
	Rep(w, W + 2){
		ans[0][w] = '#';
		ans[H + 1][w] = '#';
	}
	Rep(h, H + 2){
		PrintLn(ans[h]);
	}
	return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
S=[[0 for _ in range(M)] for _ in range(2**N)]
cost=[]

for i in range(2**N):
    b=bin(i)[2:].zfill(N)
    t_cost=0
    for j in range(N):
        t_cost+=A[j][0]*int(b[j])
        for m in range(M):
            S[i][m]+=A[j][m+1]*int(b[j])
    
    if min(S[i])>=X:
        cost.append(t_cost)

if len(cost)==0:
    print(-1)
else:
    print(min(cost))

Measured memory_bytes: 85432
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  if(N<600)cout<<8<<endl;
  else if(N<800)cout<<7<<endl;
  else if(N<1000)cout<<6<<endl;
  else if(N<1200)cout<<5<<endl;
  else if(N<1400)cout<<4<<endl;
  else if(N<1600)cout<<3<<endl;
  else if(N<1800)cout<<2<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 3652
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int n;
	cin >> n;
	int x, ans = 0;
	for (int i = 1; i <= n; i++){
		cin >> x;
		if (i % 2 && x % 2)
			ans ++;
	}
	cout << ans;
}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int H, W, D;
  cin >> H >> W >> D;
  map<int, P> mp;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      int a;
      cin >> a;
      a--;
      mp[a] = P(x, y);
    }
  }
  dump(mp);
  map<int, vector<int>> co;
  for (int p = 0; p < H * W; p++) {
    int x1, y1, x2, y2;
    tie(x1, y1) = mp[p];
    if (p + D < H * W) {
      tie(x2, y2) = mp[p + D];
      co[p].push_back(abs(x1 - x2) + abs(y1 - y2));
    }
  }
  // ダブリングのテーブル
  for (int b = 0; b < 20; b++) {
    for (int p = 0; p < H * W; p++) {
      int n = p + D * (1 << b);
      if (n < H * W && b < co[n].size()) {
        co[p].push_back(co[p][b] + co[n][b]);
      }
    }
  }
  for (int p = 0; p < H * W; p++) {
    dump(p, co[p]);
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    int ans = 0;
    int n = (r - l) / D;
    for (int b = 19; 0 <= b; b--) {
      int p = (1 << b);
      if (p <= n && b < co[l].size()) {
        ans += co[l][b];
        n -= p;
        l += D * p;
        dump(b, p);
      }
    }
    while (l < r) {
      ans += co[l][0];
      l += D;
    }
    cout << ans << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 27136
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R, K, X, A, B, C;
ll ans;
string S;
ll a[100000000];
bool channel[31][200001];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll DP[1001][1001];
int main() {
	string t, b;
	cin >> t >> b;
	rep(i, 0, 1001) {
		DP[i][0] = 1;
	}
	rep(i, 1, t.size()+1) {
		rep(j, 1, b.size() + 1) {
			DP[i][j] = DP[i - 1][j];
			if (t[i - 1] == b[j-1]) {
				DP[i][j] += DP[i - 1][j - 1];
			}
			DP[i][j] %= mod;
		}
	}
	cout << DP[t.size()][b.size()] << endl;
	return 0;
}


Measured memory_bytes: 11040
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    students = [(As[i], i) for i in range(N)]
    students.sort()
    ans = ''
    for n, s in students:
        ans += ' ' + str(s + 1)
    print(ans.strip())


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll res = 0;
    if (a < k)
    {
        res += a * 1;
        if (a + b + c <= k)
            res -= c * 1;
        else
        {
            res -= (k - a - b) * 1;
        }
    }
    else
        res += k * 1;
    c(res);
}


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

int main(){
  int N;
  cin >> N;
  int count = 0;
  for(int i = 1; i <= N; i+=2){
    int count1 = 0;
      for(int j = 1; j <= i; j++){
        if(i%j == 0) count1++;
      }
    if(count1 == 8) count++;
  }
  cout << count << endl;
}
    


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    ll r, g;
    cin >> r >> g >> b;
    ll num = 100 * r + 10 * g + b;
    YN(num % 4 == 0)
}


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

#define endl '\n'

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

    int n; cin >> n;
    string s,t; cin >> s >> t;
    for (int i=0; i<n;i++) cout << s[i] << t[i];
    cout << endl;
}

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

ll solve() {
  ll x; cin >> x;
  ll cnt = x / 11;
  x = x % 11;
  if (x == 0) return 2 * cnt;
  if (x <= 6) return 2 * cnt + 1;
  return 2 * cnt + 2;
  
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << solve() << endl;

  return 0;
}



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

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

  for(int i=0;i <= n;i+=4){
    for(int j=0;j <= n;j+=7){
      if((i+j) == n){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;

    {
        for(ll i=1; i<n; i++)
            if(a[i-1] >= a[i])
                goto search;
        cout << 1 << endl;
        return 0;
    }
search:
    ll ok = 2*n, ng = 1;
    // ok以内で作れる
    while(abs(ok - ng) > 1) {
        vector<pair<ll,ll>> v;

        ll m = (ok + ng)/2;

        bool pass = true;
        for(ll i=1; i<n; i++) {
            if(a[i-1] < a[i])
                continue;

            v.erase(lower_bound(v.begin(), v.end(), pair<ll,ll>(a[i], 0)), v.end());
            ll pj = a[i];
            while(v.size()) {
                ll j, x;
                tie(j, x) = v.back();
                if(pj > j+1) {
                    v.push_back({pj-1, 1});
                    break;
                }
                if(x < m-1) {
                    v.back().second++;
                    break;
                }
                pj = j;
                v.pop_back();
            }
            if(!v.size()) {
                if(pj == 0) {
                    pass = false;
                    break;
                }
                v.push_back({pj-1, 1});
            }
        }
        (pass ? ok : ng) = m;
    }
    cout << ok << endl;
}


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

int main() {
    string s;
    cin>>s;
    int i=0;
    int n=s.length();
    int j=n-1;
    int f=0;
    while(i<j)
    {
        if (s[i++] != s[j--]) 
        { 
            f=1;
            break;
        } 
    }
    if(f==1)
    cout<<"No"<<endl;
    else
    {
        int x=0,y=0;
        int l=0;
        int h=((n-1)/2)-1;
        while(l<h)
       {
        if (s[l++] != s[h--]) 
        { 
            x=1;
            break;
        } 
      }
      int p=((n+3)/2)-1;
      int q=n-1;
      while(p<q)
       {
        if (s[p++] != s[q--]) 
        { 
            y=1;
            break;
        } 
      }
      if(x==1||y==1)
      cout<<"No"<<endl;
      else
      cout<<"Yes"<<endl;
    }
        

    // your code goes here
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    A,B = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    if 0<=A<6:
        print(0)
    elif 6<=A<=12:
        print(B//2)
    else:
        print(B)



if __name__ == "__main__":
    main()

Measured memory_bytes: 77484
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s,int v,vector<int>&d,whei(edge)&G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size();i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

int main() {
	llint n, m;
	cin >> n >> m;
	if (n % 3 == 0 || m % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	llint ans = min(n, m);
	rep(i, 1, n) {
		llint a = i * m;
		llint b = (n - i) * ((m + 1) / 2);
		llint c = (n - i) * (m / 2);
		ans = min(ans, max({ a,b,c }) - min({ a,b,c }));
	}
	swap(n, m);
	rep(i, 1, n) {
		llint a = i * m;
		llint b = (n - i) * ((m + 1) / 2);
		llint c = (n - i) * (m / 2);
		ans = min(ans, max({ a,b,c }) - min({ a,b,c }));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define ll long long

inline ll gcd(ll a, ll b){
    ll r;
    while(b){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}

int main(){
    ll n, x;
    scanf("%lld%lld", &n, &x);

    printf("%lld\n", 3*(n-gcd(n, x)));

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool judge(string s1,string s){
    int id = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == s1[id]){
            id++; 
        }
        if(id == 3)
            return 1;
    }
    return 0;
}
int main(){
    int n;
    cin >> n;
    string s,s1;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i <= 9; i++){
        for(int j = 0; j <= 9; j++){
            for(int k = 0; k <= 9;k++){
                s1 = to_string(i)+to_string(j)+to_string(k);
                if(judge(s1,s)){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
a, b, c = list(map(int, input().split()))
# x2, y2, x3, y3 = list(map(int, input().split()))
# x = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
# n, m = list(map(int, input().split()))
if a+b >= c-1:
    print(b+c)
else:
    print(b+(a+b+1))


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
const int MAX = 100003;

string a;

bool kakunin(int n, string s, char x,char y) {
	a[0] = x; a[1] = y;
	for (int i = 2; i < n; i++) {
		if ((a[i - 1] == 'S' && s[i - 1] == 'o') || (a[i - 1] == 'W' && s[i - 1] == 'x')) {
			a[i] = a[i - 2];
		}
		else if (a[i - 2] == 'S') { a[i] = 'W'; }
		else { a[i] = 'S'; }
	}
		bool flag1, flag2;
		if ((a[0] == 'S'&&s[0] =='o') || (a[0] == 'W' &&s[0] =='x')) { flag1 = (a[1]==a[n-1]); }
		else { flag1 = (a[1]!=a[n-1]); }
		if ((a[n - 1] == 'S'&& s[n - 1] == 'o') || (a[n - 1] == 'W'&&s[n - 1] == 'x')) { flag2 = (a[0] == a[n - 2]); }
		else { flag2 = (a[0] != a[n - 2]); }
		return flag1&&flag2;
	
}

int main() {
	int n; string s;
	cin >> n >> s;
	a = s;
	if (kakunin(n, s, 'S', 'S')) { cout << a << endl; return 0; }
	else if (kakunin(n, s, 'S', 'W')) { cout << a << endl; return 0; }
	else if (kakunin(n, s, 'W', 'S')) { cout << a << endl; return 0; }
	else if (kakunin(n, s, 'W', 'W')) { cout << a << endl; return 0; }
	cout << -1 << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer(new ConsoleInput(Console.In, ' '));
	}
	public static void Answer(ConsoleInput cin)
	{
			var N = cin.ReadInt;
			var val = N;
			while (true)
			{
				if (val % N != 0) { val*=N; continue; }
				else
				{
					if (val % 2 == 0){ WriteLine(val); return; }
					else { val*=2; }
				}
			}
	}
  
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

typedef long long ll;

int main() {
    string s;
    int K;
    cin >> s >> K;
    vector<string>a;
    set<string>b;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j <= K; j++) {
            string t = "";
            for (int k = 0; k < j; k++) {
                if (i+k < s.size()) {
                    t += s[i+k];
                }
            }
            if (t != "") {
                a.push_back(t);
            }
        }
    }
    
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++) {
        b.insert(a[i]);
    }
    
    auto itr = b.begin();
    int cnt = 1;
    while (cnt < K) {
        cnt++;
        itr++;
    }
    cout << *itr << endl;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const int T = 100001;

int main(){
  int N, C;
  cin >> N >> C;
  vector<int> s(N), t(N), c(N);
  REP(i, N) {
    cin >> s[i] >> t[i] >> c[i];
    --c[i];
  }

  vector<int> sch(T, 0);
  REP(k, C) {
    vector<int> sch_c(T, 0);
    REP(i, N) {
      if(c[i] != k) continue;
      sch_c[s[i]] += 1;
      sch_c[t[i]] -= 1;
    }
    REP(i, T - 1) sch_c[i + 1] += sch_c[i];
    REP(i, T - 1) {
      if(sch_c[i] == 0 && sch_c[i + 1] == 1) sch_c[i] = 1;
    }

    REP(i, T) sch[i] += sch_c[i];
  }

  int ret = 0;
  REP(i, T) ret = max(ret, sch[i]);

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 2176
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int A,B,C,X,Y,a,b,c,ans = INF;
    cin >> A >> B >> C >> X >> Y;

    C *= 2;

    rep(c, max(X,Y) + 1){
        a = 0;
        b = 0;
        if(c < X){
            a = X - c;
        }

        if(c < Y){
            b = Y - c;
        }

        ans = min(ans, c * C + a * A + B * b);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> hp(n);
    rep(i,n) cin >> hp[i];
    sort(all(hp));
    reverse(all(hp));
    ll ans = 0;
    for(int i = k; i < n; i++){
        ans += hp[i];
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def dfs(u=0, pu=-1):
        res = 1
        for cu in to[u]:
            if cu == pu: continue
            ret = dfs(cu, u)
            children_size[u].append(ret)
            res += ret
        return res

    md = 10 ** 9 + 7
    n = II()
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        to[a].append(b)
        to[b].append(a)
    #print(to)

    # 1/2をmodで表して、累乗を事前計算
    half = pow(2, md - 2, md)
    exp_half = [1, half]
    for _ in range(n):
        exp_half.append(exp_half[-1] * half % md)
    # print(exp_half)

    # 子の部分木のサイズ(要素数)をdfsで求める
    children_size = [[] for _ in range(n)]
    dfs()
    # print(children_size)

    # それぞれの頂点において、接続する部分木のうち
    # 2つ以上の部分木に黒が含まれる確率を求める
    # 余事象を利用(1-黒を含む部分木がない確率-黒を含む部分木が1つの確率)
    # (その頂点が白の確率)×(上記の確率)がその頂点が白で残る期待値なので和を求めれば答え
    ans = 0
    noblack = exp_half[n - 1]
    for cs in children_size:
        if not cs: continue
        sum_cs = sum(cs)
        if sum_cs != n - 1: cs.append(n - 1 - sum_cs)
        onlyone = 0
        for child_size in cs:
            onlyone += (1 - exp_half[child_size]) * exp_half[n - 1 - child_size]
        ans += (1 - noblack - onlyone) * half
        ans %= md
    print(ans)

main()


Measured memory_bytes: 221772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

    string s;
    cin >> s;
    for (char &c : s) {
        c = (c == '1' ? '9' : '1');
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll s,n,a[100000],x,y,m;
int32_t main(){
CODE_START;
cin >> n;
for(ll i=0;i<n;i++)
{
    cin >> a[i];
    s=s+a[i];
}
cin >> m;
for(ll i=0;i<m;i++)
{
    cin >> x;
    cin >> y;
    cout<<s-a[x-1]+y<<endl;
}
return 0;}



Measured memory_bytes: 256
n = int(input())
s = input()
t = input()
f = 0
m = 0
ind = 0
for i in range(1,n+1):
      if(s[n-i:]==t[:i]):
            f=1
            if (len(t[:i])>m):
                  m = len(t[:i])
                  ind = i

print(2*n-ind) if f==1 else print(2*n)


Measured memory_bytes: 9196
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);

        int cnt = 0;
        for (int i = n-1; i > n-k-1; i--) {
            if (i < 0)  break;
            cnt += l[i];
        }
        
        System.out.print(cnt);
    }
}


Measured memory_bytes: 21460
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  string s;
  cin >> s;
  if (s == "SUN")
    cout << 7 << endl;
  else if (s == "MON")
    cout << 6 << endl;
  else if (s == "TUE")
    cout << 5 << endl;
  else if (s == "WED")
    cout << 4 << endl;
  else if (s == "THU")
    cout << 3 << endl;
  else if (s == "FRI")
    cout << 2 << endl;
  else if (s == "SAT")
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int a[2010],mn[2010];
int main(){
	int i,j,n,x;
	long long s,ans=1e18;
	scanf("%d%d",&n,&x);
	for(i=0;i<n;++i)scanf("%d",a+i),mn[i]=a[i];
	for(i=0;i<n;++i){
		for(j=s=0;j<n;++j)s+=mn[j];
		ans=min(ans,s+1ll*x*i);
		for(j=0;j<n;++j)mn[j]=min(mn[j],a[(j-i-1+n)%n]);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
import sys

n, m, *lr = map(int, sys.stdin.read().split())
lr = zip(*[iter(lr)] * 2)

def main():
    cnt = [0] * (n + 1)
    for l, r in lr:
        cnt[l-1] += 1
        cnt[r] -= 1
    
    for i in range(n):
        cnt[i+1] += cnt[i]
    
    res = 0
    for i in range(n):
        res += (cnt[i] == m) & 1
    
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 25076
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll n, t; scanf("%lld %lld", &n, &t);
	ll sum = 0;
	ll mx = 0;
	for (int i = 0; i < n; i++) {
		ll h; scanf("%lld", &h);
		chmax(mx, h);
		ll cnt = t / mx;
		if (cnt * mx + h <= t) cnt++;
		cout << cnt + 1 << "\n";
		t = max(0LL, t - h);
	}
	return 0;

}



Measured memory_bytes: 3260
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int A,B,C;
	while(~scanf("%d%d%d",&A,&B,&C))
	{
		if(A==B)
		printf("%d\n",C);
		else if(B==C)
		printf("%d\n",A);
		else
		printf("%d\n",B);
	}
}

Measured memory_bytes: 128
#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() {
    ll n, tmp = 0, cnt = 1;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    for(int i = 0; i < n-1; i++) {
        if (a[i] < a[i + 1]) {
            if (tmp == -1) {
                cnt++;
                tmp = 0;
            } else {
                tmp = 1;
            }
        }

        if (a[i] > a[i + 1]) {
            if (tmp == 1) {
                cnt++;
                tmp = 0;
            } else {
                tmp = -1;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3924
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val y = sc.nextInt()
    println(problem170b(x, y))
}

fun problem170b(x: Int, y: Int): String {
    if (y % 4 == 0 || y % 4 == 2) {
        if (x * 4 >= y && x * 2 <= y) return "Yes"
    }
    return "No"
}

Measured memory_bytes: 36356
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N+1, 0);
    int64_t sum = 0;
    for (int64_t i=1; i<=N; i++) {
        cin >> vec.at(i);
        sum += abs(vec[i] - vec[i-1]);
    }

    sum += abs(vec[0] - vec[N]);
    for (int64_t i=1; i<=N; i++) {
        if (i < N) {
            cout << sum + abs(vec[i+1] - vec[i-1]) - abs(vec[i] - vec[i-1]) - abs(vec[i+1] - vec[i]) << endl;
        } else {
            cout << sum + abs(vec[0] - vec[i-1]) - abs(vec[i] - vec[i-1]) - abs(vec[0] - vec[i]) << endl;
        }
    }

    return 0;
}

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

ll powi(ll n, ll m) {
  ll ret = 1;
  while (m > 0) {
    ret *= n;
    m--;
  }
  return ret;
}

map<ll, ll> prime_fact(ll n) {
  map<ll, ll> m;
  for (ll p = 2; p * p <= n; p++) {
    if (n % p) continue;  // 素因数でない
    ll num = 0;
    while (!(n % p)) {  // 素因数で何回割れるかを計算する
      num++;
      n /= p;
    }
    m[p] = num;
  }
  if (n > 1) {  // n自身が素数のときは、素因数は自身のみ
    m[n] = 1;
  }

  return m;
}

int main() {
  ll n, p;
  cin >> n >> p;

  auto mp = prime_fact(p);
  ll ans = 1;
  for (auto np : mp) {
    if (np.second >= n) {
      ans *= powi(np.first, np.second / n);
    }
  }

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


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

int main(){
	
	int n;
	cin >> n;
	
	vector<vector<int>> speak(n, vector<int>(n,-1));
	rep(i,n){
		int a;
		cin >> a;
		rep(j,a){
			int x,y;
			cin >> x >> y;
			speak[i][--x] = y;
		}
	}
	
	int res = 0;
	rep(i,1<<n){
		vector<int> fact;
		int honest = 0;
		int num = i;
		rep(j,n){
			fact.push_back(num & 1);
			if(fact[j] == 1) honest++;
			num >>= 1;
		}
		
		bool dame = false;
		rep(j,n){
			if(fact[j] == 0) continue; // jの言うことはどうでもいい
			rep(k,n){
				if(speak[j][k] != -1 && speak[j][k] != fact[k]) dame = true; // 矛盾
			}
		}
		
		if(!dame) res = max(res,honest);
	}
	
	cout << res << endl;
	return 0;
}

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

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

	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == '1') {
			count++;
		}
	}

	cout << count << endl;
}





Measured memory_bytes: 3604
#include<stdio.h>
int main(void){
    int mon,dat,a[13],i,j,cnt;
    a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
    a[4]=a[6]=a[9]=a[11]=30;
    a[2]=29;
    while(scanf("%d%d",&mon,&dat),mon){
        cnt=3;
        for(i=1;i<=12;i++){
            for(j=1;j<=a[i];j++){
                cnt++;
                if(i==mon && j==dat)goto NEXT;
            }
        }
        NEXT:
        while(cnt>=7){
            cnt%=7;
        }
        if(cnt==1)printf("Monday\n");
        else if(cnt==2)printf("Tuesday\n");
        else if(cnt==3)printf("Wednesday\n");
        else if(cnt==4)printf("Thursday\n");
        else if(cnt==5)printf("Friday\n");
        else if(cnt==6)printf("Saturday\n");
        else if(cnt==0)printf("Sunday\n");
    }
    return 0;
}

Measured memory_bytes: 584
A=[c=0]*(2*D=86400)
gets.to_i.times{
	a,b=gets.split.map &:to_i
	c=(c+a)%D
	A[c]+=1
	A[c+D]+=1
	c=(c+b)%D
}
(D*2-1).times{|i|A[i+1]+=A[i]}
p D.times.map{|i|A[i+10801]-A[i]}.max

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

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int sum=0;
	rep(i,m){
		int a; scanf("%d",&a);
		sum+=a;
	}
	printf("%d\n",max(n-sum,-1));
	return 0;
}


Measured memory_bytes: 3828
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
man=0
cnt=0
while cnt<N:
    man+=b[a[cnt]-1]
    if cnt<N-1:
        
        if a[cnt+1]-a[cnt]==1:
            man+=c[a[cnt]-1]
    cnt+=1
print(man)    
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  string s, a;
  char c;
  ll k, ans=0, num=1, start=1, end, cnt=0;
  cin >> s >> k;end = s.size();
  if(s[0] == s[s.size()-1]){
    REP(i, s.size()-1){
      if(s[i] == s[i-1])start++;
      else break;
    }
    ans+=(start)/2;
    for(int i = s.size()-2; i >= 0; i--){
      if(s[i] == s[i+1])end--;
      else break;
    }
    ans+=(s.size()-end+1)/2;
    ans += ((start+s.size()-end+1)/2)*(k-1);
  }
  c=s[start-1];
  for(int i = start; i < end; i++){
    if(c == s[i])num++;
    else {
      cnt += num/2;
      num=1;c=s[i];
    }
  }
  cnt+=num/2;
  ans += cnt * k;
  if(s.size()==start)cout << (s.size()*k)/2;
  else cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, p; cin >> a >> p;
    cout << (3*a+p)/2 << endl;
}

Measured memory_bytes: 256
"use strict"
process.stdin.resume()
process.stdin.setEncoding('utf8')

let numArray = "";
let reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
})

reader.on('line', (line) => {
    numArray = line.split(' ');
})

reader.on('close', () => {
    let numA = Math.abs(numArray[0])
    let numB = Math.abs(numArray[1])
    let addNum = numA + numB
    
    if(addNum%2 == 0){
          console.log(addNum/2)
    }else{
          console.log('IMPOSSIBLE')
    }
})


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

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

  bool denied = false;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if((a % 2 == 0) && (a % 3 != 0) && (a % 5 != 0)){
      denied = true;
    }
  }

  if(denied){
    cout << "DENIED" << endl;
  }else{
    cout << "APPROVED" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
string s;

bool dfs(int n) {
  if (n == s.size()) return true;
  for (string i : divide) {
    if (n + i.size() <= s.size() && s.substr(n,i.size()) == i) {
      if (dfs(n + i.size())) return true;
    }
  }
  return false;
}

int main () {
  cin >> s;
  puts(dfs(0) ? "YES" : "NO");
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;
  cin>>n;
  vector<int> a(n-1);
  for(int i=0;i<n-1;i++){
    cin>>a[i];
  }int c=a[n-2];
  for(int i=n-2;i>0;i--){
    c+=min(a[i],a[i-1]);
  }
  cout<<c+a[0];
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<ll> v(n);cin >> v;
  sort(v.rbegin(), v.rend());
  ll ans = 0;
  for(int i = 1; i < n; ++i){
    ans += v[i/2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4840