akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
template<class Abel> struct UnionFind {
     vector<int> par;
     vector<int> rank;
     vector<Abel> diff_weight;
 
     UnionFind(int n = 1, Abel SUM_UNITY = 0) {
         init(n, SUM_UNITY);
     }
 
     void init(int n = 1, Abel SUM_UNITY = 0) {
         par.resize(n); rank.resize(n); diff_weight.resize(n);
         for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
     }
 
     int root(int x) {
         if (par[x] == x) {
             return x;
         }
         else {
             int r = root(par[x]);
             diff_weight[x] += diff_weight[par[x]];
             return par[x] = r;
         }
     }
 
     Abel weight(int x) {
         root(x);
         return diff_weight[x];
     }
 
     bool issame(int x, int y) {
         return root(x) == root(y);
     }
 
     bool merge(int x, int y, Abel w) {
         w += weight(x); w -= weight(y);
         x = root(x); y = root(y);
         if (x == y) return false;
         if (rank[x] < rank[y]) swap(x, y), w = -w;
         if (rank[x] == rank[y]) ++rank[x];
         par[y] = x;
         diff_weight[y] = w;
         return true;
     }
 
     Abel diff(int x, int y) {
         return weight(y) - weight(x);
     }
 };
int main() {
    ll n,m;
    std::cin >> n>>m;
    
    vector<ll> h(n);
    
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    vector<vector<ll>> edges(n);
    
    map<pair<ll,ll>,bool> ex;
    for (int i = 0; i < m; i++) {
        ll a,b;
        std::cin >> a>>b;
        
        a--;b--;
        if(ex[{a,b}])continue;
        edges[a].push_back(b);
        edges[b].push_back(a);
        ex[{a,b}] = true;
        ex[{b,a}] = true;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll ok = true;
        for (auto e : edges[i]) {
            if(h[i]<=h[e]){
                ok = false;
                break;
            }
        }
        if(ok)ans++;
    }
    std::cout << ans << std::endl;
    
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  if((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0){
    cout << "Possible" << endl;
  }
  
  else{
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    a = max(a - b, 0);
    int res = max(c - a, 0);
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#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 pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    ll n, ans = 1;
    cin >> n;
    vector<int> a(n), cnt(3, -1);
    rep(i, n){
        cin >> a.at(i);
        ll now = 0, first = true;
        rep(j, 3){
            if(a.at(i) - 1 == cnt.at(j)){
                now++;
                if(first){
                    cnt.at(j)++;
                    first = false;
                }
            }
        }
        ans = ans * now % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
program ABC050B
    implicit none
    integer(8)::N,P,X,i,M,result
    integer(8),dimension(100)::T
    read(5,*)N,(T(i),i=1,N),M
    result=sum(T(1:N))

    do i=1,M
        read(5,*)P,X
        print'(i0)',result+X-T(P)
    end do
end program ABC050B

Measured memory_bytes: 256
h, w, k = (int(x) for x in input().split())
C = [input() for _ in range(h)]

ans = 0
for hbit in range(1<<h):
    for wbit in range(1<<w):
        tmp = 0
        for i in range(h):
            if hbit & (1<<i):
                continue
            for j in range(w):
                if wbit & (1<<j):
                    continue
                elif C[i][j] == "#":
                    tmp += 1
        if tmp == k:
            ans += 1
print(ans)

Measured memory_bytes: 68336
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n, q;
const int N = 600000;
int ai[N], di[N], ok[N];
int main()
{
    scanf("%d%d", &n, &di[0]);
    for (int i = 1; i <= n; ++ i)
    {
        scanf("%d", &ai[i]);
        if (abs(di[i - 1] - ai[i]) < di[i - 1])
            di[i] = abs(di[i - 1] - ai[i]);
        else
            di[i] = di[i - 1];
    }
    LL dd = 0;
    for (int i = n; i; -- i)
    {
        if (di[i - 1] > dd) ok[i] = 1;
        if (ai[i] <= dd * 2 + 1) dd += ai[i];
    }
    scanf("%d", &q);
    while (q --)
    {
        int a;
        scanf("%d", &a);
        if (ok[a]) puts("YES"); else puts("NO");
    }
}


Measured memory_bytes: 8448
class Dice:
    def __init__(self, ary): # [top, front, right, left, back, bottom]
        self.__top = ary[0]
        self.__fro = ary[1]
        self.__rit = ary[2]
        self.__lft = ary[3]
        self.__bak = ary[4]
        self.__btm = ary[5]

    def turn_e(self): # 右に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__lft, self.__btm, self.__rit, self.__top

    def turn_s(self): # 手前に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__bak, self.__top, self.__fro, self.__btm

    def turn_w(self): # 左に転がる
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__rit, self.__top, self.__lft, self.__btm

    def turn_n(self): # 奥に転がる
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__fro, self.__btm, self.__bak, self.__top

    def spin_r(self): # 右回転 
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__bak, self.__rit, self.__fro, self.__lft

    def spin_l(self): # 左回転
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__fro, self.__lft, self.__bak, self.__rit

    def is_same_setting(self, ary): # 同じように置いているか
        if self.__top == ary[0] and self.__fro == ary[1] and self.__rit == ary[2] and \
            self.__lft == ary[3] and self.__bak == ary[4] and self.__btm == ary[5]:
            return True

    def is_same_dice(self, ary): # 回転させて同じダイスになるか
        is_same = False
        for _ in range(2):
            for _ in range(3):
                for _ in range(4):
                    if self.is_same_setting(ary):
                        is_same = True
                    self.spin_r()
                self.turn_n()
            self.spin_r()
            self.turn_s()
        return is_same

    def show_top(self): # 上面の値を表示
        return self.__top

surfaces = list(map(int,input().split()))
instructions = list(input())

dice = Dice(surfaces)

for inst in instructions:
    if inst == "E":
        dice.turn_e()
    if inst == "N":
        dice.turn_n()
    if inst == "S":
        dice.turn_s()
    if inst == "W":
        dice.turn_w()

print(dice.show_top())


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, X, T; 
  cin >> N >> X >> T;
  
  int ans;
  if(N / X * X == N){
    ans = N / X * T;
  }
  else{
    ans = (N / X + 1) * T;
  }
  cout << ans << endl;
}

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

int     main() {
        string S;
        cin >>S;
        vector<long> D(13, 0);
        vector<long> DD(13, 0);
        D.at(0)=1;
        int N=S.size();
        // Preset
        long ST=1;
        for (int i=0; i<N; i++) {
                for (int i=0; i<13; i++) DD.at(i)=0;
                if ('?'==S.at(N-1-i)) {
                        for (int j=0; j<10; j++) {
                                for (int k=0; k<13; k++) {
                                        DD.at((k+ST*j)%13) += D.at(k);
                                }
                        }
                } else {
                        int j=(S.at(N-1-i) - '0');
                        for (int k=0; k<13; k++) {
                                DD.at((k+ST*j)%13) += D.at(k);
                        }
                }
                D=DD;
                for (int i=0; i<13; i++) D.at(i) %= 1000000007;
                ST *=10;
                ST %=13;
        }
        cout << D.at(5) << endl;
        return 0;
};

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define takearr(a,n) int a[n];for(int i=0;i<n;i++)cin>>a[i]
#define rep(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define mods (1000*1000*1000)+7

int main()
{

  ll n,we;cin>>n>>we;
  ll w[n],v[n];ll sum=0;
  rep(i,n){cin>>w[i]>>v[i];sum+=v[i];}
  ll ans[n+1][sum+1];
  memset(ans,0,sizeof(ans));
  //ans[0][w[0]]=v[0];
  f(i,0,n)
    {
      f(j,0,sum)
        {
          if(i==0){ans[i][j]=LLONG_MAX;if(j==0)ans[i][j]=0;continue;}
          ans[i][j]=ans[i-1][j];
          if(j>=v[i-1])if(ans[i-1][j-v[i-1]]!=LLONG_MAX)ans[i][j]=min(ans[i][j],ans[i-1][j-v[i-1]]+w[i-1]);
         //cout<<ans[i][j]<<" ";
        }
        //cout<<endl;
    }
  ll anss=0;
  f(i,0,sum){if(ans[n][i]<=we)anss=max(anss,i);}
  cout<<anss<<endl;

}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    string S;
    cin >> S;
    bool A = false;
    bool B = false;
    for(char c : S){
        if(c == 'A') A = true;
        else if(c == 'B') B = true;
    }

    if(A && B) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 384
from collections import  Counter
N =int(input())

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

c = Counter(a)
new_c = Counter(a)
for key,val in c.items():
    new_c[key-1] +=val
    new_c[key+1] += val

print(new_c.most_common()[0][1])


Measured memory_bytes: 26844
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

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


void solve(){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll cnt1 = 0;
	for(ll i =0;i<n;i++){
		if(s[i]=='1')
			cnt1++;
	}
	// this is the initial cnt1s


	auto binpow =[](ll a,ll b,ll m){
		ll res  = 1;
		while(b>0){
			if(b&1)
				res = res*a%m;
			a=a*a%m;
			b>>=1;
		}
		return res;
	};
	ll rem[2];
	rem[0]  = rem[1] = 0;
	vector<ll> remans(n);
	for(ll i =0;i<n;i++){
		if(cnt1-1 !=0)
			rem[0] = (rem[0]+(s[i]-'0')*binpow(2,n-i-1,cnt1-1))%(cnt1-1);
		else
			rem[0] = -1;
		rem[1] = (rem[1]+(s[i]-'0')*binpow(2,n-i-1,cnt1+1))%(cnt1+1);
	}

	for(ll i =0;i<n;i++){
		if(s[i]=='0'){
			remans[i] = (rem[1] + binpow(2,n-i-1,cnt1+1))%(cnt1+1);
		}
		else{
			if(rem[0]!=-1)
			remans[i] = ((cnt1-1) + rem[0] -binpow(2,n-i-1,cnt1-1))%(cnt1-1);
			else
				remans[i] = -1;
		}
	}
	// dbg(remans);
	for(ll i =0;i<n;i++){
		if(remans[i]==-1){
			cout << 0 << endl;
			continue;
		}
		ll ans = 1;
		while(remans[i]>0){
			ll div  =__builtin_popcount(remans[i]);
			remans[i]%=div;
			ans++;
		}
		cout << ans << endl;
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;


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

    vector<P> xy;
    for (int i=0;i<N;i++) {
        int x,y; cin >> x >> y;
        xy.push_back(P(x,y));
    }

    vector<P> dist;
    map<P,int> cnt;
    for (int i=0;i<N;i++) {
        for (int j=0;j<N;j++) {
            if (i==j) continue;
            P vec = P(xy[i].first-xy[j].first, xy[i].second-xy[j].second);
            dist.push_back(vec);
            cnt[vec]++;
        }
    }

    int ans=0;
    for (int i=0;i<dist.size();i++) {
        ans=max(cnt[dist[i]], ans);
    }

    cout << N-ans << endl;

    return 0;
}

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

int main() {
  int n;
	cin >> n;
	vector<int> cards(n);
	for (int i = 0; i < n; i++) {
		cin >> cards[i];
	}
	sort(cards.begin(), cards.end(), greater<>());

	int a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			a += cards.at(i);
		} else {
			b += cards.at(i);
		}
	}

	cout << (a - b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int S,T;
  scanf("%d %d",&S,&T);
  printf("%.9f\n",(double)S*T/(S+T));
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

B = sorted(A, reverse=True)

C = [0] * N

i = 0
while(1):
    if i >= N:
        break
    for j in range(N):
        if A[j] == B[i]:
            C[i] = j
            if i != N-1 and B[i] == B[i+1]:
                i += 1
    i += 1

dp = [[0] * (N+1) for i in range(N+1)]
for i in range(N+1):
    for j in range(i+1):
        if j > 0 and i-j > 0:
            dp[j][i-j] = max([dp[j-1][i-j] + B[i-1] * abs(C[i-1] - (j-1)), dp[j][i-j-1] + B[i-1] * abs(C[i-1] - (N-1-(i-j-1)))])
        elif j == 0 and i-j > 0:
            dp[j][i-j] = dp[j][i-j-1] + B[i-1] * abs(C[i-1] - (N-1-(i-j-1)))
        elif i-j == 0 and j > 0:
            dp[j][i-j] = dp[j-1][i-j] + B[i-1] * abs(C[i-1] - (j-1))


ans = 0
for i in range(N+1):
    ans = max([ans, dp[i][N-i]])

print(ans)

Measured memory_bytes: 100652
from collections import defaultdict

n = int(input())
ch = ["A", "C", "G", "T"]
dic = {}
for i in range(4):
    for j in range(4):
        for k in range(4):
            dic[ch[i]+ch[j]+ch[k]] = 1
dic["AGC"] = 0
dic["GAC"] = 0
dic["ACG"] = 0

err = ["AGAC", "AGCC", "AGGC", "AGTC", "AAGC", "ACGC", "AGGC", "ATGC", ]

l = [dic]
for i in range(n-3):
    _dic = defaultdict(lambda: 0)
    for k, v in l[i].items():
        for j in range(4):
            s = k+ch[j]
            if s not in err:
                _dic[k[1:]+ch[j]] = (_dic[k[1:]+ch[j]]+v)%(10**9+7)
    _dic["AGC"] = 0
    _dic["GAC"] = 0
    _dic["ACG"] = 0
    l.append(_dic)

ans = 0
for v in l[n-3].values():
    ans = (ans+v)%(10**9+7)

print(ans)

Measured memory_bytes: 4080
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n, m, x = map(int, input().strip().split())
    books = []
    for i in range(n):
        c_temp, *A_temp = map(int, input().strip().split())
        books.append((c_temp, A_temp))
    eprint('books ', end=':\n')
    eprint(books)

    #
    ans = sys.maxsize
    for case in range(2 ** n):	 # 場合ループ # nは人とかモノとかの個数
        l_bin = list(map(int, (format(case, 'b').zfill(n))))
        # eprint('l_bin ',end=': ')
        # eprint(l_bin)

        # flag=0
        lvalue = [0 for _ in range(m)]
        cost = 0
        for index_object in range(n):	  # 人とかモノとかループ
            if l_bin[index_object] == 1:				   # その桁がyesだと仮定している場合
                cost += books[index_object][0]
                for j in range(m):
                    lvalue[j] += books[index_object][1][j]
                    
            else:								 # その桁がnoだと仮定している場合
                pass
        #
        suc_flag = 1
        for i in range(m):
            suc_flag *= (lvalue[i] >= x)
        if suc_flag:
            ans = min(ans, cost)
    if ans == sys.maxsize:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 79396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string S;
    cin >>S;
    ll ans=0;
    ll cnt = 0;
    rep(i,3){
        if(S[i]=='R'){
            cnt++;
        }else{
            cnt =0;
        }
        chmax(ans,cnt);
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3624
#include<list>
//#include<algorithm>
#include<iostream>
//#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int l,n;
  double m;
  char s[256],*t;
  while(fgets(s,256,stdin)!=0){
    l=atoi(strtok(s," "));
    list<int> r,q;
    for(n=0;(t=strtok(NULL," "))!=NULL;n++)
      r.push_back(atoi(t));
    r.sort();
    q.push_back(r.front());
    r.pop_front();
    for(;;){
      if(r.empty())
	break;
      q.push_front(r.back());
      r.pop_back();
      if(r.empty())
	break;
      q.push_back(r.back());
      r.pop_back();
      if(r.empty())
	break;
      q.push_front(r.front());
      r.pop_front();
      if(r.empty())
	break;
      q.push_back(r.front());
      r.pop_front();
    }
    m=0.0;
    list<int>::iterator it=q.begin();
    m+=*it;
    for(i=0;i<n-1;i++){
      int a,b;
      a=*it;
      it++;
      b=*it;
      m+=sqrt(a*b)*2;
    }
    m+=*it;
    if(m<=l)
      cout<<"OK"<<endl;
    else
      cout<<"NA"<<endl;
  }
  return 0;
}
/*
  int i,r[10];
  double l;
  cin>>r[0]>>r[1]>>r[2]>>r[3]>>r[4]>>r[5];
  l=0.0;
  l+=r[0];
  for(i=0;i<5;i++)
    l+=sqrt(r[i]*r[i+1])*2;
  l+=r[i];
  cout<<l<<endl;
  return 0;
}
*/

Measured memory_bytes: 0
import sys
import itertools
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    xy = [tuple(in_nn()) for _ in range(N)]

    if N == 1:
        print(1)
        exit()

    comb = itertools.combinations(range(N), 2)
    d = defaultdict(int)

    for i, j in comb:
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        xd = x2 - x1
        yd = y2 - y1
        d[(xd, yd)] += 1
        d[(-xd, -yd)] += 1

    ans = N - max(d.values())
    # print(d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9636
using System;

class Program
{
	static void Main(string[] args)
	{
		//入力数を分解して配置
		string[] input = Console.ReadLine().Split(' ');
		int A = int.Parse(input[0]);
		int B = int.Parse(input[1]);
		//出力
		if ((A * B)% 2 == 1)
		{
			Console.WriteLine("Odd");
		}
		else
		{
			Console.WriteLine("Even");
		}
	}
}

Measured memory_bytes: 27072
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll a[N] , b[N] , n ;
bool ok(ll x) {
	for (int i = 1 ; i <= 2 * n - 1 ; i ++) {
		if (a[i] >= x) b[i] = 1 ;
		else b[i] = 0 ;
	}
	for (int i = 0 ; i < n - 1 ; i ++) {
		if (b[n + i] == b[n + i + 1]) return b[i + n] ;
		if (b[n - i] == b[n - i - 1]) return b[n - i] ;
	}
	if (n % 2  == 0)return !b[n] ;
	else return b[n] ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n ;
    for (int i = 1;  i <= 2 * n - 1 ; i ++) cin >> a[i] ;
    ll h = 3 * n + 10 , l = -1 , m ;
    while (h - l > 1) {
    	m = (h + l) >> 1 ;
    	if (ok(m)) l= m ;
    	else h = m ;
	}
	//cout << ok(2) << endl;
	if (ok(l)) h = l;
	cout << h; 
    return (0) ;
}

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

int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

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

using namespace std;
typedef long long LL;

LL atmp,i,len,j,k,l,C[105][105]={0},n,p,t,tmp,odd=0,even=0;

void get_C(LL maxn)
{
    C[0][0] = 1;
    for(int i=1;i<=maxn;i++)
    {
        C[i][0] = 1;
        for(int j=1;j<=i;j++)
            C[i][j] = C[i-1][j]+C[i-1][j-1];
        //C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;
    }
}

int main()
{
    get_C(101);
    scanf("%d%d",&n,&p);
    for(i=0;i<n;i++){
        scanf("%d",&t);
        if(t%2)odd++;
        else even++;
    }
    tmp=1;
    for(i=0;i<even;i++)tmp=tmp<<1;
    atmp=0;
    if(p){
        t=1;
        while(t<=odd){
            atmp+=C[odd][t];
            t+=2;
        }

    }else{
        t=0;
        while(t<=odd){
            atmp+=C[odd][t];
            t+=2;
        }
    }
    printf("%lld",tmp*atmp);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
        #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 FORR(i, m, n) for(int i = m;i >= n;i--)
        #define SORT(v, n) sort(v, v+n);
        #define VSORT(v) sort(v.begin(), v.end());
        #define llong long long
        #define pb(a) push_back(a)
        #define INF 1000000000000000000LL
        #define MOD 1000000007
        using namespace std;
        typedef pair<int, int> P;
        typedef pair<llong, llong> LP;
        typedef pair<int, P> PP;
        typedef pair<llong, LP> LPP;
        //vector<tuple<long long, long long, long long>>vec;

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

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


        int main()
        {
            int n,m;
            cin >> n >> m;
            vector<string> a(n);
            REP(i, n) {
                cin >> a[i];
            }
            vector<string> b(m);
            REP(i, m) {
                cin >> b[i];
            }
            for (int i = 0; i < n - m + 1; i++) {
                if (a[i].substr(i, m) == b[0]) {
                    bool flg = true;
                    for (int j = i; j < m; j++) {
                        if (a[j].substr(i, m) != b[j]) {
                            flg = false;
                        }
                    }
                    if (flg) { cout << "Yes" << endl; return 0; }
                }
            }
            cout << "No" << endl;
            return 0;
        }

Measured memory_bytes: 256
compute s e []     = s ++ (reverse e)
compute s e (l:ls) =  if l!!0 == "1"
                      then compute e s ls
                      else if l!!1 == "1"
                           then compute (l!!2 ++ s) e ls
                           else compute s (l!!2 ++ e) ls

main = do
  s <- getLine
  q <- getLine
  ls <- lines <$> getContents
  let qs = map words $ ls
  putStrLn $ compute s "" qs

Measured memory_bytes: 103036
A,B = map(int,input().split())

from fractions import gcd

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

if gcd(A,B)==1:
  temp = 0
else:
  temp = 1

print(len(factorization(gcd(A,B)))+temp)

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

// dp[i]:i文字目を先頭とした場合の，Sの部分文字列でない最短の文字列の長さ
int nex[202020][26],dp[202020],ne[26];
// ta[i]:i文字目を先頭とした場合の，遷移先(2文字目)のアルファベット(0~25=a~z)
int ta[202020];

int main(){
  string S; cin>>S;
  int N=S.length();
  rep(i,26) ne[i]=N+1;
  for(int i=N;i>=0;i--){
    dp[i]=202020;
    // aから貪欲に遷移先を選ぶ
    rep(j,26){
      nex[i][j]=ne[j];
      int x=dp[ne[j]];
      if(x<dp[i]){
        dp[i]=x;
        ta[i]=j;
      }
    }
    dp[i]++;
    if(i) ne[S[i-1]-'a']=i;
  }

  string ans="";
  int cur=0;
  while(cur!=N+1){
    ans+=('a'+ta[cur]);
    cur=nex[cur][ta[cur]];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 22404
#include <bits/stdc++.h>
using namespace std;
int main(){
   int a;
   cin>>a;
   int f=0;
   int g=0;
   pair<int,int> b[1000];
   for(int i=0;i<a;i++){
       cin>>b[i].first;
   }
   for(int i=0;i<a;i++){
       cin>>b[i].second;
   }
   for(int i=0;i<a;i++){
       if(b[i].first>b[i].second){
           f=f+b[i].first;
           g=g+b[i].second;
       }
   }
   cout<<f-g<<endl;
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y
def primes(n):
    P = [2]
    for L in range(3, n):
        isP = True
        for L2 in P:
            isP = isP and L%L2
            if not isP: break
        if isP: P.append(L)
    return P


N,M=LI()
As = LI()
Bs = list(map(lambda x: -x, As))
heapq.heapify(Bs)

for i in range(M):
    v = heapq.heappop(Bs)
    heapq.heappush(Bs, -(-v // 2))

print(-sum(Bs))


Measured memory_bytes: 73196
n,m=map(int,input().split())
flg=[False for i in range(n)]
flg[0]=True
t=[1 for i in range(n)]
tmp=1
for i in range(m):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    t[x]-=1
    t[y]+=1
    if flg[x]:
        flg[y]=True
        if t[x]==1 and len(flg)==1:
            flg[x]=False

    if t[x]==0:
        flg[x]=False
ans=0
for i in range(n):
    if flg[i]:
        ans+=1
print(ans)

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

int main(){
    int a ;
    string s;
    cin >> a >> s ;
    if (a >= 3200)
    {
        cout << s << endl ;
    }else
    {
        cout << "red" << endl ;
    }
    
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m,x = map(int,input().split())
clist = []
alist = []
ans = 10**20
for i in range(n):
    ca = list(map(int,input().split()))
    c = ca[0]
    a = ca[1:]
    clist.append(c)
    alist.append(a)

for i in range(2**n):
    y = 0
    rikai = [0]*m
    bi = bin(i)[2:].zfill(n)
    for j in range(n):
        if bi[j] == '1':
            y += clist[j]
            for k in range(m):
                rikai[k] += alist[j][k]
    for j in range(m):
        if rikai[j] < x:
            break
    else:
        ans = min(ans,y)
if ans == 10**20:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9248
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String compare = "CODEFESTIVAL2016";
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		String compared = sc.nextLine();
		System.out.println(needtochange(compare,compared));
	}
	public static int needtochange(String s1,String s2)
	{
		int sum = 0;
		for(int i=0;i<s1.length();i++)
		{
			if(s1.charAt(i) != s2.charAt(i))
				sum++;
		}
		return sum;
	}
}


Measured memory_bytes: 9684
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    int[] s = new int[m];
    int[] c = new int[m];


    for (int i = 0; i < m; i++) {
      s[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }

    TreeMap<Integer,Integer> mp = new TreeMap<Integer,Integer>();

    for (int i = 0; i < m; i++) {
      if (mp.containsKey(s[i])) {
        int k = mp.get(s[i]);
        if (k != c[i]) {
          System.out.println(-1);
          return;
        }
      }
      mp.put(s[i],c[i]);
    }

    String h = "";

    for (int i = 1; i <= n; i++) {
      Integer x = mp.get(i);
      if (x == null) {
        if (i == 1 && n != 1) {
          h += "1";
        } else {
          h += "0";
        }
      } else {
        h += String.valueOf(x);
      }
    }

    if (h.length() > 1 && h.charAt(0) == '0') {
      System.out.println(-1);
    } else {
      System.out.println(h);
    }

  }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  int ans=0;
  
  for(int i=1;i<sqrt(n)+1;i++){
    for(int j=i; j<n; j++){
      if(i*j<n){
        if(i==j) ans++;
        else ans+=2;
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3692
#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 rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(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))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
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 int mod = 1000000007;
const double EPS = 1e-9;
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;}

// s = "aabbbc" -> [[a,2],[b,3],[c,1]]
vector<pair<char,int>> rle (string s) {
  vector<pair<char,int>> res;
  int n = (int)s.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && s[j] == s[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(s[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  string s;
  cin >> s;
  int n = sz(s);

  auto t = rle(s);
  int pos = 0;
  vi ans(n);
  rep(i,sz(t)) {
    if (i%2==1) continue;
    pos += t[i].se;

    int nr = t[i].se;
    int nl = t[i+1].se;
    // RL
    int R = nr-nr/2 +nl/2;
    int L = nr/2 + nl-nl/2;

    ans[pos-1] = R;
    ans[pos] = L;
    pos += t[i+1].se;
  }

  rep(i,n) {
    cout << ans[i] << "\n";
  }
  return 0;
}

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

int main(void) {
    int n,ans=1;
    cin>>n;
    vector<int> h(n);
    rep(i,n){cin>>h[i];}
    for(int i=1;i<n+1;i++)
    {
        if(h[0]<=h[0+i]){
            ans++;
            h[0]=h[0+i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
main = do
    x <- readInt <$> getLine
    print $ solve x

readInt :: String -> Int
readInt = read

solve :: Int -> Int
solve x = solveInner x 100 0
solveInner :: Int -> Int -> Int -> Int
solveInner x balance year
    | x <= balance = year
    | otherwise    = solveInner x (floor $ (realToFrac balance) * 1.01) (year + 1)

Measured memory_bytes: 3852
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const string keyence = "keyence";

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

    string s;
    cin >> s;

    bool ret = false;
    for (int i = 0; i < 7; i++) {
        int p = 0;
        bool ans = true;

        for (int j = 0; j < i; j++) {
            if (s[j] != keyence[p]) {
                ans = false;
            }
            p++;
        }

        for (int j = s.size() + i - 7; j < s.size(); j++) {
            if (s[j] != keyence[p]) {
                ans = false;
            }
            p++;
        }

        if (ans) {
            ret = ans;
        }
    }

    if (ret) {
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int a[2][n];
  for (int i = 0; i < n; i++) {
    std::cin >> a[0][i];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> a[1][i];
  }
  int res = -1;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j <= i; j++) {
      sum += a[0][j];
    }
    for (int k = i; k < n; k++) {
      sum += a[1][k];
    }
    if (res < sum) {
      res = sum;
    }
  }
  std::cout << res << "\n";
  return 0;
}

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

int main() {
    
    int n;
    cin>>n;
    n%=10;
    
    if(n==2||n==4||n==5||n==7||n==9) cout<<"hon"<<endl;
    else if(n==1||n==6||n==8||n==0) cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>

int m[1209][1209], d[1209][1209];
char s[310];

int main() {
    int n;
    scanf("%d ", &n);

    int k = 26;
    for (int i = 0; i <= 4 * n + 2; i++)
        m[0][i] = ++k;
    for (int i = 0; i <= 4 * n + 2; i++)
        m[4 * n + 2][i] = ++k;
    for (int i = 1; i <= 4 * n + 1; i++)
        m[i][0] = ++k;
    for (int i = 1; i <= 4 * n + 1; i++)
        m[i][4 * n + 2] = ++k;

    for (int i = 2; i <= 2 * n; i += 2) {
        fgets(s, 305, stdin);
        for (int j = 2; j <= 2 * n; j += 2)
            m[i][j] = m[i][j + 2 * n] = m[i + 2 * n][j] = m[i + 2 * n][j + 2 * n] = s[j / 2 - 1] - 'a' + 1;
    }

    for (int i = 2; i <= 4 * n; i++) {
        for (int j = 2; j <= 4 * n; j++) {
            if ((i + j) % 2 == 0) {
                d[i][j] = 0;
                while (m[i + d[i][j] + 1][j - d[i][j] - 1] == m[i - d[i][j] - 1][j + d[i][j] + 1])
                    d[i][j]++;
            }
        }
    }

    int ans = 0;
    for (int i = 2; i <= 2 * n; i++) {
        for (int j = 2; j <= 2 * n; j++) {
            if (i % 2 == 0 && j % 2 == 0) {
                bool ok = 1;
                for (int p = 1; p < 2 * n && ok; p++) {
                    if (p < n)
                        ok &= (d[i + p][j + p] >= p);
                    else
                        ok &= (d[i + p][j + p] >= 2 * n - p);
                }
                ans += ok;
            }
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int n;
bool b[110][110];
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; ++i)
		for(int j=i+1; j<=n; ++j)
			b[i][j]=b[j][i]=1;
	if(n&1){
		for(int i=n-1; i>n/2; --i)
			b[i][n-i]=b[n-i][i]=0;
	}else{
		for(int i=n; i>n/2; --i)
			b[i][n-i+1]=b[n-i+1][i]=0;
	}
	int cnt=0;
	for(int i=1; i<=n; ++i)
		for(int j=i+1; j<=n; ++j)
			if(b[i][j])++cnt;
	printf("%d\n",cnt);
	for(int i=1; i<=n; ++i)
		for(int j=i+1; j<=n; ++j)
			if(b[i][j])printf("%d %d\n", i, j);
	return 0;
}

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

using namespace std;



int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main(){	
	int n;
	cin>>n;
	int a[20],x[20][20],y[20][20];
	for(int i = 1; i <= n; i++){
		cin>>a[i];
		for(int j = 1; j <= a[i]; j++){
			cin>>x[i][j]>>y[i][j];
		}
	}
	
	int ans = 0;
	for(int bits = 1; bits < (1 << n); bits++){
		bool flag = true; 
		for(int i = 1; i <= n; i++){
			if(!(bits & (1 << (i-1)))) continue;
			for(int j = 1; j <= a[i]; j++){
				if(((bits>>(x[i][j]-1)) & 1) ^ y[i][j]) flag = false;
			}
		}
		if(flag) ans = max(ans, counter(bits));
	}
	
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int aa;
  scanf("%d", &aa);
  long long int ab[aa], maa = 1e18, prd = 1, fg = 0, zer = 0;
  
  for (int i = 0; i < aa; i++) {
    scanf("%lld", &ab[i]);
    fg = (ab[i] > maa) ? 1 : fg;
    prd *= ab[i];
    (ab[i]) ? maa /= ab[i] : zer = 1;
  }

  (zer) ? puts("0") : ((fg) ? puts("-1") : printf("%lld\n", prd));
  return 0;
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    map<ll,ll> m;
    ll n,ans=0,x;
    cin>>n;
    for (ll i=1;i<=n;++i)
    {
        cin>>x;
        ans+=m[i-x];
        ++m[x+i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 26296
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X = int(input())
    if 400<=X<=599:
        print('8')
    elif 600<=X<=799:
        print('7')
    elif 800<=X<=999:
        print('6')
    elif 1000<=X<=1199:
        print('5')
    elif 1200<=X<=1399:
        print('4')
    elif 1400<=X<=1599:
        print('3')
    elif 1600<=X<=1799:
        print('2')
    else:
        print('1')

if __name__ == '__main__':
    main()



Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(void){
    vector<int> A(5);
    for(int i=0;i<5;i++){
        cin >> A[i];
    }
    
    int ans = 1e9;
    do{
        int tmp = 0;
        for(int i=0;i<4;i++){
            if(A[i] % 10 == 0){
                tmp += A[i];
            }else{
                tmp += (A[i]/10 + 1) * 10;
            }
        }
        tmp += A[4];
        ans = min(ans, tmp);
    }while(next_permutation(A.begin(), A.end()));
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1

using namespace std;

inline int mod(int n){ return (n%1000000007); }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  if(b == 1) return b;
  else return gcd(b, a%b);
}

int32_t main(){
	DESYNC;
	string s;
	string t;
	cin >> s >> t;
	if(s == t){
	  cout << "Yes"  << endl;
	  return 0;
	}
	for(int i=0; i<t.size(); i++){
	  string aux;
	  for(int j = i+1; j < t.size(); j++){
	    aux += t[j];
	  }
	  for(int j=0; j <= i; j++) aux += t[j];
	  if(s == aux){
	    cout << "Yes" << endl;
	    return 0;
	  }
	}
	cout << "No" << endl;  
}



Measured memory_bytes: 256
N, M = map ( int, input ( ).split ( ) )# N,Mを取得
#初期化
lists = [ ]
#listに要素を追加　後で並び変えるため並び替える前の順番を示すキーを第三要素に挿入しておく
for i in range ( M ):
    lists.append ( list ( map ( int, input ( ).split ( ) ) ) + [ i ] )
#第一要素に昇順で並び替えた後、第二要素で昇順に並び替える
lists.sort ( key=lambda x: x[ 1 ] )
lists.sort ( key=lambda x: x[ 0 ] )
# befは前回の第一要素　stateは第一要素での順位
bef = 0
state = 0
retstr = ''
triple = [ ]#第四要素に識別番号を追加したリストの初期化
for i in lists:
    if (i[ 0 ] != bef):
        bef = i[ 0 ]
        state = 1
        triple.append ( [ i[ 0 ], i[ 1 ], i[ 2 ], str ( i[ 0 ] ).rjust ( 6, '0' ) + str ( state ).rjust ( 6, '0' ) ] )
    else:
        state += 1
        triple.append ( [ i[ 0 ], i[ 1 ], i[ 2 ], str ( i[ 0 ] ).rjust ( 6, '0' ) + str ( state ).rjust ( 6, '0' ) ] )

triple.sort ( key=lambda x: x[ 2 ] )#第三要素で並び替えて、元の入力に対応した式ベンツ番号の順番に戻す
for i in triple:
    print ( i[ 3 ] )#識別番号の出力

Measured memory_bytes: 43040
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
int t[17][17];
int dp[64 * 1024];
int main() {
	string buf;
	while (getline(cin, buf), buf != ".") {
		vector<char> s;
		bool f = true;
		for (auto a : buf) {
			switch (a) {
			case '(':
			case '[':
				s.push_back(a);
				break;
			case ')':
				if (s.empty() || s.back() != '(') {
					f = false;
					break;
				}
				s.pop_back();
				break;
			case ']':
				if (s.empty() || s.back() != '[') {
					f = false;
					break;
				}
				s.pop_back();
				break;
			}
		}
		if (!s.empty())f = false;
		cout << (f ? "yes" : "no") << endl;
	}
	return 0;
}

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

using ll = long long int;

int n;
ll a[2005], dp[2005][2005];

ll rec(int l, int r, bool turn){
    if(l == r) return turn ? a[l] : 0;
    if(dp[l][r] != -1) return dp[l][r];
    ll res;
    if(turn){
        res = max(rec((l-1+n)%n,r,false)+a[l], rec(l,(r+1)%n,false)+a[r]);
    }else{
        if(a[l] > a[r]) res = rec((l-1+n)%n,r,true);
        else res = rec(l,(r+1)%n,true);
    }
    return dp[l][r] = res;
}

bool solve(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        fill(dp[i],dp[i]+n,-1);
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans, rec((i-1+n)%n,(i+1)%n,false)+a[i]);
    }
    cout << ans << endl;
    return true;
}

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



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

int main() {
    int n, ans = 1;
    string s;
    cin >> n >> s;
    char temp = s.at(0);
    rep(i, n - 1) {
        if(s.at(i + 1) != temp) ans++;
        temp = s.at(i + 1);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
  int n; cin>>n;
  int a[n];
  for(int i = 0; i < n; i++) cin>>a[i];
  int sum = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      sum += a[i]*a[j];
    }
  }
  cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;

int main() {
	cin >> N;
	map<string, LL>mp;
	LL tox = 0;
	for (int i = 0; i < N; i++) {
		string s;
		LL t;
		cin >> s >> t;
		tox += t;
		mp[s] = tox;
	}
	string X;
	cin >> X;
	cout << tox - mp[X] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

int main(){
	int n;
	cin >> n;
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int d1, d2;
		cin >> d1 >> d2;
		if(d1 == d2)
			cnt++;
		else
			cnt = 0;
			
		if(cnt == 3)
			return cout << "Yes" << endl, 0;		
	}
	
	
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632