akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair 
typedef pair<int, int> pii;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;

const int N = 2e5 + 10;

struct node {
	int a, b;
} x[N], t[N];
int n, q, b[N];
bool ans[N], st[N], vis[N];
vector<pii> G[N];
int get(int u) { return lower_bound(b + 1, b + n + 1, u) - b; }
int getl(int u) { return upper_bound(b + 1, b + n + 1, u) - b - 1; }
void link(int u, int v, int w) { G[u].pb(pii(v, w)); G[v].pb(pii(u, w)); }
int dfs(int u) {
	vis[u] = 1; int x = st[u];
	for(auto v : G[u]) if(!vis[v.fs]) {
		if(dfs(v.fs)) { ans[v.sc] = 1; x ^= 1; }
	}
	return x;
}
int main() {
	scanf("%d%d", &n, &q);
	for(int i = 1; i <= n; i ++) { scanf("%d%d", &x[i].a, &x[i].b); b[i] = x[i].a; }
	for(int i = 1; i <= q; i ++) scanf("%d%d", &t[i].a, &t[i].b);
	sort(b + 1, b + n + 1);
	for(int i = 1; i <= n; i ++) { x[i].a = get(x[i].a); st[x[i].a] = x[i].b; }
	for(int i = n + 1; i >= 1; i --) st[i] ^= st[i - 1];
	for(int i = 1; i <= q; i ++) link(get(t[i].a), 1 + getl(t[i].b), i);
	for(int i = 1; i <= n + 1; i ++) if(!vis[i]) {
		if(dfs(i)) { puts("-1"); return 0; }
	}
	int r = 0;
	for(int i = 1; i <= q; i ++) r += ans[i];
	printf("%d\n", r);
	for(int i = 1; i <= q; i ++) if(ans[i]) printf("%d ", i);
	return 0;
} 

Measured memory_bytes: 18560
def main():
    N,K = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    MOD = 10**9+7

    fact = [1] * (N+1) # 階乗を格納するリスト
    factinv = [1] * (N+1) # 階乗を格納するリスト
    # 毎回mod演算を行って計算量を削減しているのもポイント
    for i in range(N):
        fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
        factinv[i+1] = pow(fact[i+1], MOD-2, MOD) # MODを法とした逆元（フェルマーの小定理）
    def comb(n,k): # 組み合わせ(MOD)を返却する
        return fact[n] * factinv[n-k] * factinv[k] % MOD

    ans = 0
    # minX全てを計算
    for i in range(N-K+1):
        ans -= A[i]*comb(N-i-1,K-1)
        ans %= MOD

    A = A[::-1]
    # maxX全てを計算
    for i in range(N-K+1):
        ans += A[i]*comb(N-i-1,K-1)
        ans %= MOD

    print(ans)
main()


Measured memory_bytes: 15888
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            if(S.Substring(2,1) == S.Substring(3,1) && S.Substring(4,1) == S.Substring(5, 1))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 25784
c = []

def main():
    buf = input()
    buflist = buf.split()
    H = int(buflist[0])
    W = int(buflist[1])
    global c
    for i in range(10):
        buf = input()
        buflist = buf.split()
        c.append(list(map(int, buflist)))
    A = []
    for i in range(H):
        buf = input()
        buflist = buf.split()
        A.append(list(map(int, buflist)))
    cost_list = []
    for i in range(10):
        nlist = []
        for j in range(10):
            if j != 1:
                nlist.append(j)
        cost_list.append(min_cost_of(i, 1, 1, nlist, 0))
    number_count = []
    for i in range(10):
        i_count = 0
        for j in range(H):
            for k in range(W):
                if A[j][k] == i:
                    i_count += 1
        number_count.append(i_count)
    mp_needed = 0
    for i in range(10):
        mp_needed += cost_list[i] * number_count[i]
    print(mp_needed)

def min_cost_of(s, d, t, nlist, cost):
    if s == d or s == t:
        return cost
    else:
        minimum = c[s][d]
        for i in nlist:
            rlist = list(nlist)
            rlist.remove(i)
            result = min_cost_of(s, d, i, rlist, cost + c[i][t])
            if result < minimum:
                minimum = result
        return minimum

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
pair<int,int> operator+(pair<int,int> &l, pair<int,int> &r) {
  return {l.first+r.first, l.second+r.second}; }

int main() {
  string s;
  cin>>s;
  int price=700;
  for(auto c:s)
    if(c=='o')
      price+=100;
  cout<<price<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static boolean[][] map;

    public static int[][] move = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };

    public static void dfs(int i, int j) {
        map[i][j] = false;
        for (int k = 0; k < 4; k++) {
            int i2 = i + move[k][0];
            int j2 = j + move[k][1];
            if (0 <= i2 && i2 < 12 && 0 <= j2 && j2 < 12 && map[i2][j2])
                dfs(i2, j2);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            map = new boolean[12][12];
            for (int i = 0; i < 12; i++) {
                char[] s = sc.next().toCharArray();
                for (int j = 0; j < 12; j++) {
                    map[i][j] = s[j] == '1';
                }
            }
            int x = 0;
            for (int i = 0; i < 12; i++) {
                for (int j = 0; j < 12; j++) {
                    if (map[i][j]) {
                        dfs(i, j);
                        x++;
                    }
                }
            }
            System.out.println(x);
        }
    }
}


Measured memory_bytes: 26216
N = int(input())

A = []

for n in range(N):
    A.append([n, int(input())])
As = sorted(A, reverse=True, key=lambda x: x[1])

for n in range(N):
    i = 0    
    if n == 0:
        if A[0] == As[0]:
            print(As[1][1])
        else:           
            print(As[0][1])
    else:
        while i < n:
            if A[n] == As[i]:
                i+=1
                print(As[i][1])
                break

            elif A[n][1] > As[i][1]:
                    i += 1
            else:
                print(As[i][1])
                break


Measured memory_bytes: 41304
function Main(input) {
 	// 1行目がinput[0], 2行目がinput[1], …に入る
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);

   var old_t = 0;
   var old_x = 0;
   var old_y = 0;
  
   var result;
  
   for(var i=1;i<=N;i++){
      var tmp = input[i].split(" ");
      var t = parseInt(tmp[0], 10)
      var x = parseInt(tmp[1], 10)
      var y = parseInt(tmp[2], 10)
      
      var diff_t = t - old_t;
      var diff_x = x - old_x;
      var diff_y = y - old_y;
      
//	  console.log('diff %s %s %s',diff_t,diff_x,diff_y);
      
      var kyori = diff_t - (diff_x + diff_y);
     
//	  console.log('kyori %s',kyori);

      if(kyori < 0){
         result = "No";
      }else{  
	     result = kyori % 2 == 0 ? "Yes":"No"
      }
//	  console.log('result %s',result);
      
      if (result=="No"){
      	break;
      } 
      
      old_t = t;
      old_x = x;
      old_y = y;

   }
  
	//出力
	console.log('%s',result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 29164
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  ll a, b;
  cin >> a >> b;
  if (a == 1 || b == 1)
  {
    cout << 1 << endl;
  }
  else
  {
    cout << (a * b) / 2 + (a * b) % 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	int n;
	int a[15], x[15][16], y[15][16];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		for (int j = 0; j < a[i]; ++j)
			cin >> x[i][j] >> y[i][j];
	}
	int ans = 0;
	bitset<15> bits;
	for (int b = 0; b < (1 << n); ++b) {
		bool ok = true;
		bits |= b;

		for (int i = 0; i < n; ++i) {
			if (!bits[i]) continue;
			for (int j = 0; j < a[i]; ++j) {
				if (bits[x[i][j]-1] != y[i][j]) ok = false;
			}
		}
			if (ok) {
				ans = max(ans, (int)bits.count()); //cout << bits << endl;
			}
		
		bits &= 0;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
     
      while(true) {
          int a = sc.nextInt();
          String op = sc.next();
          int b = sc.nextInt();

	      if(op.equals("?")){
	    	  break;
	      }
	      else if(op.equals("+")) {
	          System.out.println(a+b);
	      }
	      else if(op.equals("-")) {
	          System.out.println(a-b);
	      }
	      else if(op.equals("*")) {
	          System.out.println(a*b);
	      }
	      else if(op.equals("/")) {
	          System.out.println(a/b);
	      }
      }
   }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

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

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, k ;
    cin >> a >> b >> c >> k ;
    int ans = 0 ;
    if(k<=a){
        ans = k ;
    }
    else if(k<=a+b){
        ans = a ;
    }
    else{
        ans = 2*a+b-k ;
    }

    cout << ans <<endl ;
    

    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
	int a,b,c,x,y;
	if(scanf("%d %d %d %d %d",&a, &b, &c, &x, &y)==EOF){return 0;}
	
	if (x <  y){
		int temp = x; x = y; y = temp;
		temp = a; a = b; b = temp;
	}
	//x > y;
	
	int total;
	if(a > c*2){
		total = c*x*2;
	}else if (a+b>c*2){
		total = a*(x-y) + c*y*2;
	}else{
		total = a*x + b*y;
	}
	
	printf("%d\n", total);
	return 0;
}



Measured memory_bytes: 1652
#include <stdio.h>

int main(void){
int a[3][10][4] = {0};
int i, j, k;
int n, p;
int b, f, r, v; /* b棟f階r番目の部屋にv人 [階][部屋][棟] */

scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d%d%d%d", &b, &f, &r, &v);

a[f-1][r-1][b-1] += v;
}

for(k=0; k<4; k++){
for(i=0; i<3; i++){
for(j=0; j<10; j++){
if(a[i][j][k] == 0){
printf(" 0");
}else{
printf(" %d", a[i][j][k]);
}
}
printf("\n");
}
if(k != 3){
printf("####################\n");
}
}

return 0;
}


Measured memory_bytes: 2048
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

d = ni()
c = na()
s = []

for i in range(d):
    ss = na()
    s.append(ss)

c = np.array(c) # 満足度の下がりやすさ
s = np.array(s) # i日目jコン
s_t = s.T # iコンj日目
last = np.zeros(26)

# 評価関数
# 得になった分+その日の満足度
# n: 日数, 
def eva(n, cc, ss):
    return (26-n)*cc + ss


for i in range(d): # i日目(0-indexed)
    last += 1 # 一日分追加
    tow = c * last # 満足下がる値 
    sc = -100000
    M = -1
    for j in range(26):
        k = eva(i, tow[j], s[i][j])
        if sc < k:
            sc = k
            M = j
    last[M] = 0
    print(M+1)


Measured memory_bytes: 27320
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}


int main(void){
    ll n,k,i;
    scanf("%lld%lld",&n,&k);
    ll h[n],dp[n],a,b;
    for(i=0;i<n;i++){
        scanf("%lld",&h[i]);
    }
    for(i=0;i<min2(k,n);i++){
        dp[i]=ABS(h[i]-h[0]);
    }
    for(i=k;i<n;i++){
        b=INF;
        for(ll j=0;j<k;j++){
            a=dp[i-k+j]+ABS(h[i]-h[i-k+j]);
            b=min2(b,a);
        }
        dp[i]=b;
    }
    printf("%lld\n",dp[n-1]);
    return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

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

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

	vector<ll> v(n, 0);

	rep(i, n-1) {
		int a;
		cin >> a;
		v[a-1]++;
	}
	
	rep(i, n) {
		cout << v[i] << endl;
	}
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;


int tests,current_case;


void message(int current_case) {
    //cerr<<"Case "<<current_case<<" solved!"<<endl;
    fprintf(stderr, "Case %d solved!\n", current_case);
}



int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n,a,b;

    tests=1;
    //scanf("%d", &tests);
    //cin>>tests;
    for(current_case=1;current_case<=tests;current_case++) {
        scanf("%d %d %d", &n, &a, &b);
        if(a>b || (n<=1 && a!=b)) printf("0\n");
        else printf("%lld\n", (n-2)*1ll*b-(n-2)*1ll*a+1);

        MESSAGE:
        message(current_case);
    }

    return 0;
}


Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
s = input()
State = "Yes"
for i in range(B-1,D-1):
    if s[i] == "#" and s[i+1] == "#":
        State = "No"
        break
if C < D:
    for i in range(A-1,C-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
elif State == "Yes":
    State = "No"
    for i in range(B-2,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            State = "Yes"
            break
    for i in range(D-1,C-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
    for i in range(A-1,B-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
print(State)

Measured memory_bytes: 3572
// F - LCS
#include <bits/stdc++.h>
using namespace std;

int dp[3001][3001];

int main(){
	string S,T; cin>>S>>T;
	int N = S.size(), M = T.size();
	S = "*" + S; T = "*" + T;

	for(int s=1; s<=N; s++)
		for(int t=1; t<=M; t++)
			dp[s][t] = max(max(dp[s][t-1], dp[s-1][t]), dp[s-1][t-1] + (S[s]==T[t]));

	string ans;
	while(N>0 && M>0){
		if(dp[N][M]==dp[N-1][M]) N--;
		else if(dp[N][M]==dp[N][M-1]) M--;
		else{
			ans = S[N] + ans;
			N--; M--;
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 35456
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  int N, L;
  cin >> N >> L;
  int chk = 1e9;

  int sum = 0, ans = 0;
  for (int i = 1; i <= N; i++) {
    sum += L+i-1;
  }


  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    for (int j = 1; j <= N; j++) {
      if(i == j) continue;
      cnt += L+j-1;
    }
    if(chk >= abs(sum-cnt)){
      chk = abs(sum-cnt);
      ans = cnt;
    }
  }

  cout << ans << endl;

  return 0;
}

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

void Main() {
  string s;
  R s;
  ll ans=0;
  rep(i,s.size()) ans+=s[i]-'0';
  rep(i,s.size()) {
    if(s[i]!='0') {
      string t=s.substr(0,i);
      t+=(char)(s[i]-1);
      REP(j,i+1,s.size()) t+='9';
      ll sum=0;
      rep(j,t.size()) sum+=t[j]-'0';
      ans=max(ans,sum);
    }
  }
  pr(ans);
}

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


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    bool f=false;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a;
        if(a%2) f=true;
    }
    if(f) {
        cout << "first" << endl;
    }
    else {
        cout << "second" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC081B_shiftonly
//
//  Created by 岡本 朋大 on 2019/05/29.
//  Copyright © 2019年 岡本　朋大. All rights reserved.
//

#include <iostream>
using namespace std;

int count(int a){
    int count = 0;
    while(a%2 == 0){
        count++;
        a = a/2;
    }
    return count;
}

int main() {
    int N;
    cin >> N;
    int A[210];
    for(int i = 0; i< N; i++) cin >> A[i];
    
    int M = count(A[0]);
    for(int j= 1; j < N; j++){
        int m = count(A[j]);
        if (m < M) M = m;
    }
    cout << M << endl;
    return 0;
}



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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string ans=":(";
rreps(i,1,n){
    if((int)floor(i*1.08)==n){
        ans=to_string(i);
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    return x*y/(T)GCD(x,y);
}
int main(){
    priority_queue<long long> pq;
    for(;;){
        string s; cin >> s;
        if (s == "end") break;
        if (s == "insert"){
            long long k; cin >> k;
            pq.push(k);
        } else {
            cout << pq.top() << endl;
            pq.pop();
        }
    }
}
  




Measured memory_bytes: 11224
words = lambda t : list(map(t, input().split()))
n = int(input())
a = set()
c = "#"
ans = True
for _ in range(n):
    s = input()
    if (c != "#" and c != s[0]) or (s in a):
        ans = False
        break
    a.add(s)
    c = s[-1]
if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38484
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){

            int n = Integer.parseInt(sc.next());
            int time = Integer.parseInt(sc.next());

            int beforeNum = 0;
            int notOyu = 0;

            for(int i = 0; i < n; i++){
                int num = Integer.parseInt(sc.next());
                if(i > 0 && num - beforeNum > time) notOyu += num - beforeNum - time;
                beforeNum = num;
            }

            System.out.println(beforeNum + time - notOyu);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 47144
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string s ; cin>>s;
    int c=0,ans=0;
    for (int i=0;i<3;i++){
        if (s[i]=='S') c=0;
        else c++;
        ans = max(ans,c);
    } 
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3628
from math import ceil

n = int(input())

a = [0] + [int(x) for x in input().split()]

c = [0 for i in a]

for i in range(n, 0, -1):
    # satisfy multiples of i
    curr = 0
    for j in range(i, n+1, i):
        curr += c[j]
    if curr % 2 != a[i]:
        c[i] = 1
    else:
        c[i] = 0


x = c.count(1)

print(x)

for i in range(len(c)):
    if c[i] == 1:
        print(i, end=' ')

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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

    int p3[13];
    p3[0]=1;
    rep(i,12) p3[i+1]=p3[i]*3;

    int now=0;
    while((p3[now+1]-1)/2<w) ++now;
    //printf("now= %d, lim=%d\n", now, (p3[now+1]-1)/2);

    string ans;

    rep(mask,p3[now+1])
    {
        //3^i??????????????????????????????
        vector<int> st(now+1);
        int t=mask;
        rep(i,now+1)
        {
            st[i]=t%3-1;
            t/=3;
        }

        if(st[now]==0) continue;

        int v=0;
        rep(i,now+1) v+=st[i]*p3[i];

        if(v==w)
        {
            ans.resize(now+1);
            rep(i,now+1)
            {
                if(st[i]==-1) ans[now-i]='-';
                else if(st[i]==1) ans[now-i]='+';
                else ans[now-i]='0';
            }
            break;
        }
    }

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

Measured memory_bytes: 3144
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctime>
using namespace std;

int N; vector<vector<int>> F,P;
void input()
{
    cin >> N;
    F.resize(N);
    P.resize(N);
    for (int i = 0; i < N; ++i){
        F[i].resize(10);
        P[i].resize(11);
    }
    for (int i = 0; i < N; ++i) for (int j = 0; j < 10; ++j) cin >> F[i][j];
    for (int i = 0; i < N; ++i) for (int j = 0; j < 11; ++j) cin >> P[i][j];
}

void solve()
{
    long long ans = -1e18;
    for (int op = 1; op < (1<<10); ++op){
        // cout << "open: " << op << endl;
        long long Psum = 0;
        for (int i = 0; i < N; ++i){
            int cnt = 0;
            for (int j = 0; j < 10; ++j){
                // int tmp = (op & (1<<j)) ? 1 : 0;
                // cout << tmp << " " << F[i][j] << " " << cnt << endl;
                if ((op & (1 << j)) && (F[i][j] == 1)) ++cnt;
            }
            // cout << endl;
            Psum += P[i][cnt];
        }
        // cout << Psum << endl << "---\n";
        ans = max(ans,Psum);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> p(n);
    for (auto&& pp : p) {
        cin >> pp;
    }

    int64_t s = 0;
    for (auto i : irange(0L, k)) {
        s += p[i];
    }
    int64_t m = s;
    for (auto i : irange(1L, n - k + 1)) {
        s += -p[i - 1] + p[i + k - 1];
        m = max(m, s);
    }

    cout << setprecision(10) << (m + k) / 2.0 << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
//Global
int x, y;
const int MAX_N = 20;
char maze[MAX_N][MAX_N+1];
const int INF = 1000000;
int X, Y;//"@"???????????????
int memo[MAX_N][MAX_N];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int counter;

void bsd(int a, int b) {
	maze[b][a] = '#';
	memo[b][a] = INF;
	counter++;
	for (int i = 0; i < 4; i++) {
		int nx = a + dx[i];
		int ny = b + dy[i];
		if (memo[ny][nx] == 0 && maze[ny][nx] == '.' && 0 <= nx && nx < x && 0 <= ny && ny < y) {
			bsd(nx, ny);
		}
	}

}



//solve
//??±???????????¢?´¢??§"@"??¨???????????£?????????"."????????°????±???????
void solve()
{
	//memo????????????
	//memset(memo,0, sizeof(memo));
	for (int i = 0; i < y; i++) {
		for (int j = 0; j < x; j++) {
			memo[i][j] = 0;
		}
	}

	//"@"??¨??£??\????????????  ??????  INF??§??????  ??????  ????????????????????£?????????????????????"."??§??????
	counter = 0;//"@"??????
	bsd(X, Y);


	cout << counter << endl;

}


//main
int main()
{
	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		//"W"??¨"."??¨"@"?????\???
		for (int i = 0; i < y; i++) {
			for (int j = 0; j < x; j++) {
				cin >> maze[i][j];
				if (maze[i][j] == '@') {
					X = j; Y = i;//@???????????????????¨????
				}
			}
		}
		solve();
	}
    return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<pair<i64, i64>> v;
    for(int i=0;i<n;++i){
        i64 a, b;
        cin >> a >> b;
        v.emplace_back(b, a);
    }
    sort(v.begin(), v.end());
    i64 cur = 0;
    bool ok = true;
    for(auto e: v){
        cur += e.second;
        if(cur > e.first){
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
const ll LINF = 0x1fffffffffffffff;
#define name3(_1,_2,_3,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) name3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define each(i,a) for(auto &i : a)
#define sum(a) accumulate(all(a), 0LL)
#define all(i) begin(i), end(i)
template<class T, class U> inline bool chmin(T &a, const U &b){ if(a > b) { a = b; return 1; } else return 0; }
template<class T, class U> inline bool chmax(T &a, const U &b){ if(a < b) { a = b; return 1; } else return 0; }


int main(){
    string s, t;
    cin >> s >> t;
    ll n=t.size(),m=s.size();
    vector<ll>a(n);
    ll at=-1;
    rep(n){
        at++;
        while(at<m&&s[at]!=t[i])at++;
        if(at==m)return!puts("no");
        a[i]=at;
    }
    reverse(all(s));
    reverse(all(t));
    at=-1;
    rep(n){
        at++;
        while(at<m&&s[at]!=t[i])at++;
        if(a[n-1-i]!=m-1-at)return!puts("no");
    }
    puts("yes");
}



Measured memory_bytes: 7912
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int n,r1[4001],g1[4001],b1[4001],d,a,i,j,b,aa,bb,aaa,bbb,p,q,r,max,min,e,f;
  long long x;
  char s[4001];
  scanf("%d",&n);
  scanf("%s",s);
  p=0;
  q=0;
  r=0;
  d=0;
  e=0;
  f=0;
  for(i=0;i<n+1;i++){
    b1[i]=0;
    r1[i]=0;
    g1[i]=0;
  }
  for(i=0;i<n;i++){
    if(s[i]=='R'){
      r1[p]=i;
      p=p+1;
    }
    else if(s[i]=='G'){
      g1[q]=i;
      q=q+1;
    }else{
      b1[i]=1;
      r=r+1;
    }
  }
  /*printf("%d %d %d\n",p,q,r);
    printf("%d %d %d\n",r1[6],g1[6],b1[1]);*/
  for(i=0;i<p;i++){
    for(j=0;j<q;j++){
      a=abs(r1[i]-g1[j]);
      if(r1[i]-g1[j]>0){
	max=r1[i];
	min=g1[j];
      }else{
	max=g1[j];
	min=r1[i];
      }
      if(max+a<n&&b1[max+a]==1){
	d=d+1;
      }
      if(min-a>=0&&b1[min-a]==1){
	e=e+1;
      }
      if(a%2==0&&b1[min+a/2]==1){
	f=f+1;
      }
    }
  }
  /*printf("%d %d %d\n",d,e,f);*/
  x= (long long)p*q*r-d-e-f;
  printf("%lld\n",x);
  return 0;
}



Measured memory_bytes: 1764
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<signal.h>
#include<unistd.h>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define ws wss
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void read(int &x)
{
	char ch;int fu=1;
	while ((ch=getchar())<=32);
	x=0;
	if (ch=='-') fu=-1;else x=ch-48;
	while ((ch=getchar())>32) x=x*10+ch-48;
	x*=fu;
}
template<class T> void upmax(T &a,T b) { if (a<b) a=b;}
template<class T> void upmin(T &a,T b) { if (a>b) a=b;}

//---------template--------------
const int N=210000,p=1000000007;
struct Edge{int y,ne;};
int n,num;
int d[N];
Edge e[N*2];int last[N];
void dfs(int i)
{
	for (int j=last[i];j;j=e[j].ne)
	if (d[e[j].y]==0)
	{
		d[e[j].y]=d[i]+1;
		dfs(e[j].y);
	}
}
void add(int x,int y){ e[++num]=(Edge){y,last[x]};last[x]=num;}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	d[1]=1;
	dfs(1);
	int q=1;
	for (int i=2;i<=n;i++) if (d[i]>d[q]) q=i;
	for (int i=1;i<=n;i++) d[i]=0;d[q]=1;
	dfs(q);
	int r=0;
	for (int i=1;i<=n;i++) r=max(r,d[i]);
	puts(r%3==2?"Second":"First");
}
/*
   0 1 2 3 4 5
   0 1 0 1 1 0
 */


Measured memory_bytes: 11392
#include<cstdio>
#include<iostream>
#define S 100

int main(void)
{
	int a[S];
	int i;
	int n,max,min,sum=0;
	
	for(;;)
	{
		max=0, min=1000,sum=0;
		
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
		}
		
		for(i=0; i<n; i++)
		{
			if(max<a[i]) max=a[i];
			if(min>a[i]) min=a[i];
		}
		
		for(i=0; i<n; i++)
		{
			sum+=a[i];
		}
		
		sum=sum-max-min;
		printf("%d\n",sum/(n-2));
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define ll long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=2e5+5;
const int M=1e9+7;

void solve()
{
	int n;
	cin>>n;
	int a[n];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i%2==0 && a[i]%2==1)
		ans++;
	}
	cout<<ans;
}

signed main()
{
	int t=1;
	// cin>>t;
	for(int tc=1;tc<=t;tc++)
	{
		solve();
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int main(){
    int N;
    while(cin >> N, N){
        vector<vector<bool> > c(21, vector<bool>(21));
        rep(i, N){
            int x, y;
            cin >> x >> y;
            c[y][x] = true;
        }
        int M, x = 10, y = 10;
        cin >> M;
        while(M--){
            char d; int l;
            cin >> d >> l;
            rep(i, 4)if("SWNE"[i] == d){
                while(l--){
                    x += dx[i]; y += dy[i];
                    if(!c[x][y])continue;
                    c[x][y] = false;
                    N--;
                }
            }
        }
        cout << (N? "No\n": "Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1156
import java.util.*;

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

        if (b - a + 1 <= 2 * k) {
            for (int i = a; i <= b; i++) {
                System.out.println(i);
            }
        } else {
            for (int i = a; i < a + k; i++) {
                System.out.println(i);
            }
            for (int i = b - k + 1; i <=b ; i++) {
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 36216
// c++include
#include <iostream>
#include <algorithm>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(ll i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	ll n, k;
	cin >> n >> k;
	
	vector<ll> cnt;
	cnt.reserve(100000 + 1);
	rpt(i, 100000 + 1) {
		cnt.push_back(0);
	}
	rpt(i, n) {
		ll a, b;
		cin >> a >> b;
		cnt[a] += b;
	}

	rpt(i, 100000 + 1) {
		if (cnt[i] == 0) {
			continue;
		}
		else {
			if (k <= cnt[i]) {
				cout << i;
				break;
			}
			else {
				k -= cnt[i];
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: u64,
        b: f64,
    }
    let int_b = (b * 100. + 0.5) as u64;
    let ans: u64 = a * int_b;
    let ans: u64 = ans / 100;

    println!("{}", ans)
}


Measured memory_bytes: 2224
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 a = n/k;
		System.out.println(Math.abs(a+n%k - a));
		
		
	}
}


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

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


void solve(long long X, long long A){
    ll a=0;
    (X<A)?a=0:a=10;
    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,taro_point = 0,hanako_point = 0,j;
    char taro_card[101],hanako_card[101];
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%s %s",taro_card,hanako_card);
        for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
        if(taro_card[j] == '\0'){
            if(hanako_card[j] == '\0'){
                taro_point += 1;
                hanako_point += 1;
            }else{
                hanako_point += 3;
            }
        }else if(hanako_card[j] == '\0'){
            taro_point += 3;
        }else if(hanako_card[j] > taro_card[j]){
            hanako_point += 3;
        }else{
            taro_point += 3;
        }
    }
    printf("%d %d\n",taro_point,hanako_point);
}


Measured memory_bytes: 2668
<?php
  
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($S) = explode(" ", trim(fgets(STDIN)));

  if($n%2!==0){
    echo "No";
    exit;
  }

  $a = substr($S, 0, $n/2);
  $b = substr($S, $n/2);

  echo $a == $b ? "Yes" : "No";

Measured memory_bytes: 4728
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1LL<<32
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;


int main(void) {
    ll h, w;
    cin >> h >> w;
    char a[100][100];
    ll i, j;
    set<ll> ch, cw;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            cin >> a[i][j];
        }
    }
    ll flag=0;
    for(i=0; i<h; i++) {
        flag=0;
        for(j=0; j<w; j++) {
            if(a[i][j]=='#') flag=1;
        }
        if(flag==0)
            ch.insert(i);
    }
    flag=0;
    for(j=0; j<w; j++) {
        flag=0;
        for(i=0; i<h; i++) {
            if(a[i][j]=='#') flag=1;
        }
        if(flag==0)
            cw.insert(j);
    }
    
    ll flag2=0;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            auto it1=ch.find(i);
            auto it2=cw.find(j);
            flag2=0;
            if(it1!=ch.end()) flag2=1;
            if(it1!=ch.end() || it2!=cw.end())
                continue;
            else cout << a[i][j];
        }
        if(flag2==1);
        else cout << endl;
    }
    
}


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

using namespace std;

int main (){
	int n,k;
	cin >> n >> k;
	// loose - false
	vector<bool> state(k+1);
	vector<int> num(n);
	for(int i=0; i<n; ++i) cin >> num[i];
	for(int i=0; i<=k; ++i){
		bool isWinning=false;
		for(int j : num){
			if(j<=i && !state[i-j]){
				isWinning=true;
				break;
			}
		}
		state[i]=isWinning;
	}
	if(state[k]) cout << "First";
	else cout << "Second";

	return 0;
}



Measured memory_bytes: 3632
def dot(a,b,m):
    c = [[0,0,0],[0,0,0],[0,0,0]]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                c[i][j] += a[i][k]*b[k][j]
                c[i][j] %= m
    return c
    
def powm(a,n,m):
    if n == 0:
        return [[1,0,0],[0,1,0],[0,0,1]]
    for i in range(3):
        for j in range(3):
            a[i][j] %= m
    r = powm(a,n//2,m)
    if n%2==0:
        return dot(r,r,m)
    else:
        return dot(dot(r,r,m),a,m)

L,A,B,M = map(int,input().split())

a = [[1,0,0],[0,1,0],[0,0,1]]
for d in range(1,19):
    C = min(max(0,(10**d-A-1)//B+1),L)-min(max(0,(10**(d-1)-A-1)//B+1),L)
    a = dot(powm([[pow(10,d,M),1,0],[0,1,B%M],[0,0,1]],C,M),a,M)
ans = (a[0][1]*A%M+a[0][2])%M
print(ans)

Measured memory_bytes: 42832
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 21 21:00:20 JST 2020
 **/

Int K = 1000003;
vector<Int> num(K);

int solve(const vector<int>& a) {
    int n = a.size();
    auto cur = a;
    REP(i, n - 1) {
        vector<int> nxt(n - i - 1);
        REP(j, n - i - 1) {
            nxt[j] = abs(cur[j] - cur[j + 1]);
        }
        cur = nxt;
    }
    assert(cur.size() == 1);
    return cur[0];
}

int answer(const vector<int>& a) {
    int n = a.size();
    bool one = false;
    REP(i, n) {
        if (a[i] == 1) one = true;
    }
    Int sum = 0, cur = 0;
    dump(a, one);
    REP(i, n) {
        sum += (cur == 0) * (one ? a[i] : a[i] / 2);
        sum %= 2;
        cur += num[n - 1 - i] - num[i + 1];
        dump(i, sum, cur);
        // assert(cur >= 0);
    }
    if (one) {
        return sum;
    } else {
        return sum ? 2 : 0;
    }
}

signed main() {
    REP(x, 1, K) {
        Int y = x;
        while (y % 2 == 0) {
            num[x]++;
            y /= 2;
        }
    }
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) {
        char c;
        cin >> c;
        a[i] = c - '1';
    }
    cout << answer(a) << endl;

    // int n = 10;
    // vector<int> cnt(3);
    // REP(S, (int)pow(3LL, n)) {
    //     Int T = S;
    //     vector<int> a(n);
    //     REP(i, n) {
    //         a[n - 1 - i] = T % 3;
    //         T /= 3;
    //     }
    //     int ans = solve(a);
    //     cnt[ans]++;
    //     if (ans != answer(a)) {
    //         cerr << "NO!!" << endl;
    //         dump(a, ans, answer(a));
    //         return 0;
    //     }

    //     // assert(ans == answer(a));
    //     // if (ans == 2) dump(a);
    //     // reverse(a.begin(), a.end());
    //     // assert(ans == solve(a));
    // }
    // dump(cnt);
    // // dump(solve(a));
}


Measured memory_bytes: 12032
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };




int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	int res = 0;
	int right = 0;
	int pre = 0;
	int zerocnt = 0;
	rep(left, 0, n) {
		if (left != 0) {
			if (s[left] == '1' && s[left - 1] == '0')zerocnt--;
		}
		while (right < n) {
			if (right == 0) {
				if (s[0] == '0') {
					pre = 0;
					zerocnt++;
				}
				else pre = 1;
				right++;
			}
			else {
				if (pre == 0) {
					if (s[right] == '0') {
						++right;
						pre = 0;
					}
					else {
						++right;
						pre = 1;
					}
				}
				else {
					if (s[right] == '1') {
						++right;
						pre = 1;
					}
					else {
						if (zerocnt == k)break;
						else {
							++right;
							++zerocnt;
							pre = 0;
						}
					}
				}
			}
		}
		res = max(res, right - left);
		if (right == left) {
			++right;
			pre = s[left]-'0';
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int main() {
    int n, lt, t, len, minv, idx;
    for(; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        scanf("%d", &lt);
        idx=0, len = 1, minv = lt;
        for (int i = 1; i < n; i++) {
            scanf("%d", &t);
            if (t - lt == 1) { len++; lt = t; }
            else if (t - lt > 1) {
                if (len == 1) printf("%d ", lt);
                else printf("%d-%d ", minv, lt);
                len = 1, minv = lt = t;
            }
        }
        if (len == 1) printf("%d", lt);
        else printf("%d-%d", minv, lt);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2568
import java.util.Scanner;

// modの最大値
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int res = 0;
        for(int i = 0; i < N; i++) {
            res += sc.nextInt();
        }
        System.out.println(res - N);
    }
}


Measured memory_bytes: 40496