akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

template<typename T> inline size_t popcount(T x){
    static_assert(sizeof(x) <= 16,  "popcount : must be shorter than 128 bits.");
    static_assert(is_integral<T>(), "popcount : must be integer.");
    static int const mask = 65535;
    static int dp[66000];
    if(dp[mask] != 16) for(int i = 0; i <= mask; i++) dp[i] = (i&1) + dp[i>>1];
    if(false){
    } else if(sizeof(T) <= 2){
        return dp[x];
    } else if(sizeof(T) <= 4){
        return dp[x&mask] + dp[(x>>16)&mask];
    } else if(sizeof(T) <= 8){
        return dp[x&mask] + dp[(x>>16)&mask] + dp[(x>>32)&mask] + dp[(x>>48)&mask];
    } else {
        // return dp[x&mask] + dp[(x>>16)&mask] + dp[(x>>32)&mask] + dp[(x>>48)&mask]
        //     + dp[(x>>64)&mask] + dp[(x>>80)&mask] + dp[(x>>96)&mask] + dp[(x>>112)&mask];
    }
}

int solve(ll s, ll d){
    __int128_t x = 10;
    if(s <= 0 && d >= 0) return popcount(-s) + popcount(d);
    else if(s >= 0 && d >= 0){
        int j = 0;
        int ans = 0;
        while(s < d){
            if((s>>j&1) && (d>>j&1)){
                s += 1LL<<j;
                d -= 1LL<<j;
                ans += 2;
            } else if((s>>j&1) ^ (d>>j&1)){
                s += 1LL<<j;
                ans ++;
            }
            j++;
        }
        return ans;
    } else return solve(-d,-s);
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N;
    cin >> N;
    rep(i,N){
        ll s,d;
        cin >> s >> d;
        cout << solve(s,d) << endl;
    }
}

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



int main(){
    ll n,k;cin>>n>>k;
    ll a[100010];
    rep(i,0,n)cin>>a[i];
    ll an=0;
    for(ll i=43;i>=0;i--){
        ll cn1=0;
        rep(j,0,n){
            if((a[j]>>i)&1)cn1++;
        }
        if(cn1*2<n&&(an+(1LL<<i)<=k))an+=(1LL<<i);
    }
    ll ans=0;
    rep(i,0,n)ans+=(a[i]^an);
    cout<<ans<<endl;
}

    









Measured memory_bytes: 1024
package main

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

const maxBuf = 300100

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(buf, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	s := sc.Text()

	lnum := make([]int, n)
	rnum := make([]int, n)
	for i := 0; i < n; i++ {
		if s[i] == 'E' {
			rnum[i] = 1
		} else {
			lnum[i] = 1
		}
	}
	lsum := make([]int, n+1)
	rsum := make([]int, n+1)
	for i := 0; i < n; i++ {
		lsum[i+1] = lsum[i] + lnum[i]
		rsum[i+1] = rsum[i] + rnum[i]
	}

	ans := int(1e9)
	for i := 0; i < n; i++ {
		res := lsum[i] + (rsum[n] - rsum[i+1])
		if ans > res {
			ans = res
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 1e6 + 7;
vector <int> g[N];
bool dfs(int u, int p) {
    int cnt = 0;
    for (int v : g[u])
        if (v != p)
            cnt += dfs(v, u);
    if (cnt > 1) {
        cout << "First" << endl;
        exit(0);
    }   
    return !cnt;
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif  
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].app(v); g[v].app(u);
    }
    if (!dfs(1, 1))
        cout << "Second";
    else
        cout << "First";
    cout << endl;            
}   

Measured memory_bytes: 27392
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	char s[64];
	int len;

	scanf("%s", s);
	len = strlen(s);

	const char* akihabara = "AKIHABARA";
	int aki_len = strlen(akihabara);
	int aki_it = 0;
	int it = 0;
	bool ok = true;

	while(aki_it < aki_len || it < len) {
		if(akihabara[aki_it] == s[it]) {
			aki_it += 1;
			it += 1;
		} else if(akihabara[aki_it] == 'A') {
			aki_it += 1;
		} else {
			ok = false;
			break;
		}
	}

	printf("%s\n", ok ? "YES" : "NO");

	return 0;
}

/* waffle */


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int m,n;
char a[100][100];
int s(int x,int y)
{
    int num=0;
    int i,j;
    for( i=x-1;i<=x+1;i++)
    {
        for( j=y-1;j<=y+1;j++)
        {
            if(i>=0&&i<=m-1&&j>=0&&j<=n-1&&a[i][j]=='#')
                num++;
        }
    }
    return num;
}
int main()
{
    int i,j,k;
    scanf("%d %d",&m,&n);
    getchar();
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            scanf("%c",&a[i][j]);
        }
        getchar();
    }
    for( i=0;i<m;i++)
    {
        for( j=0;j<n;j++)
        {
            if(a[i][j]=='.')
            {
                k=s(i,j);
                a[i][j]=k+'0';
            }
        }
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 128
h,w = gets.split.map(&:to_i)
a = h.times.map{gets.chomp}
yoko = []
tate = []
h.times do |i|
    yoko << i if a[i] == "."*w
end
w.times do |i|
    f = true
    h.times do |j|
        f = false if a[j][i] == "#"
    end
    tate << i if f
end

h.times do |i|
    next if yoko.include?(i)
    w.times do |j|
        next if tate.include?(j)
        print a[i][j]
    end
    puts ""
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(2);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        if(x == 1) {
            a[0].push_back(y);
        } else if(y == n) {
            a[1].push_back(x);
        }
    }
    sort(a[1].begin(), a[1].end());
    for(auto &el : a[0]) {
        if(binary_search(a[1].begin(), a[1].end(), el)) {
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 2004
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
array = [0]*(10**5+1)
for _ in range(N):
    a, b = map(int, input().split())
    array[a] += b
ans = 0
for i in range(10**5+1):
    K -= array[i]
    if K<= 0:
        ans = i
        break
print(ans)

Measured memory_bytes: 41964
#include<stdio.h>
#include<iostream>
using namespace std;

main() {

  int m, f, r, sum;

  while(1){
    m = 0, f = 0, sum = 0;
    scanf("%d %d %d",&m, &f, &r);
    
    sum = m + f;

    if(m == -1 && f == -1 && r == -1){
      break;
    }else{

      if(m == -1 || f == -1){
	cout << "F\n";
      }else if(sum >= 80){
	cout << "A\n";
      }else if(sum >= 65 && sum < 80){
	cout << "B\n";
      }else if(sum >= 50 && sum < 65){
	cout << "C\n";
      }else if(sum >= 30 && sum < 50 && r < 50){
        cout << "D\n";
      }else if(sum >= 30 && sum < 50 && r >= 50){
	cout << "C\n";
      }else if(sum < 30){
	cout << "F\n";
      }

    }

  }

}

Measured memory_bytes: 1168
from string import ascii_lowercase
s = input()
t = input()

begin = {c:None for c in ascii_lowercase}
end = {c:None for c in ascii_lowercase}

for idx in range(len(s)):
    sc = s[idx]
    tc = t[idx]
    if begin[sc] is not None and begin[sc] != tc:
        print('No')
        exit()
    if end[tc] is not None and end[tc] != sc:
        print('No')
        exit()
    begin[sc] = tc
    end[tc] = sc

print('Yes')

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

const int maxn = 1e5 + 10;
typedef long long int ll;
ll sum[maxn][4]; 
void solved(){
	ll n;cin>>n;
	char s[5000];scanf("%s",s + 1);
	ll r = 0, b = 0,g = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'R'){
			r++;
			sum[i][1] = sum[i - 1][1] + 1;
			sum[i][2] = sum[i - 1][2];
			sum[i][3] = sum[i - 1][3];
		}else if(s[i] == 'G'){
			g++;
			sum[i][1] = sum[i - 1][1];
			sum[i][2] = sum[i - 1][2] + 1;
			sum[i][3] = sum[i - 1][3];
		}else if(s[i] == 'B'){
			b++;
			sum[i][1] = sum[i - 1][1];
			sum[i][2] = sum[i - 1][2];
			sum[i][3] = sum[i - 1][3] + 1;
		}
	}
	//cout<<"r :"<<r<<"  G:"<<g<<"  B:"<<b<<endl;
	//cout<<"R:  "<<sum[n][1]<<"  G:"<<sum[n][2]<<"   B:"<<sum[n][3]<<endl;
	ll ans = 0;
	for(int i = 1; i <= n; i++)
	for(int k = i + 1; k <= n; k++){
		if(s[i] == 'R' && s[k] == 'B' ){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'G')ans --;
			ans += sum[k - 1][2] - sum[i][2];
		}
		if(s[i] == 'B' && s[k] == 'R'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'G')ans --;
			ans += sum[k - 1][2] - sum[i][2];
		}
		if(s[i] == 'G' && s[k] == 'B'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'R')ans --;
			ans += sum[k - 1][1] - sum[i][1];
		}
		if(s[i] == 'B' && s[k] == 'G'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'R')ans --;
			ans += sum[k - 1][1] - sum[i][1];
		}
		if(s[i] == 'R' && s[k] == 'G'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'B')ans --;
			ans += sum[k - 1][3] - sum[i][3];
		}
		if(s[i] == 'G' && s[k] == 'R'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'B')ans --;
			ans += sum[k - 1][3] - sum[i][3];
		}
	}
	cout<<ans<<endl;
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 3820
N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for i in range(Q)]
 
import itertools
 
A = list(itertools.combinations_with_replacement(range(1,M+1),N))
answer = 0
 
for i in range(len(A)):
    ans = 0
    for j in range(Q):
        if A[i][ abcd[j][1]-1 ] - A[i][ abcd[j][0]-1 ] == abcd[j][2]:
            ans += abcd[j][3]  
    answer = max(answer,ans)
    
print(answer)

Measured memory_bytes: 21492
## https://atcoder.jp/contests/abc171/submissions/14626518
## パクった

k=int(input())
s=input()
len_s=len(s)

p = 10 ** 9 + 7

pow26=pow(26,k,p)
pow25=pow(26,p-1-1,p)*25%p 
ans=0
for i in range(k+1): ## i:末尾以外に入る文字数
  ans+=pow26
  ans%=p
  pow26=(pow26*pow25)%p * (len_s+i)%p * pow(i+1,p-2,p)%p
print(ans)

Measured memory_bytes: 71424
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    static String flag = "1";

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

    static int[] warpx = { -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
    static int[] warpy = { -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2 };

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = Integer.parseInt(scan.next());
        int w = Integer.parseInt(scan.next());
        int ch = Integer.parseInt(scan.next());
        int cw = Integer.parseInt(scan.next());
        int dh = Integer.parseInt(scan.next());
        int dw = Integer.parseInt(scan.next());
        ch--;
        cw--;
        dh--;
        dw--;
        String[][] s = new String[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = scan.next().split("");
        }
        scan.close();

        long ans = 0;

        Deque<Pair> stack = new ArrayDeque<Pair>();
        s[ch][cw] = flag;
        stack.push(new Pair(ch, cw));

        while (true) {
            List<Pair> warpList = new ArrayList<Pair>();
            while (!stack.isEmpty()) {
                Pair p = stack.poll();

                for (int i = 0; i < dx.length; i++) {
                    int x = p.h + dx[i];
                    int y = p.w + dy[i];

                    if (x == dh && y == dw) {
                        System.out.println(ans);
                        return;
                    }

                    if (0 <= x && x < h && 0 <= y && y < w) {
                        if (s[x][y].equals(".")) {
                            s[x][y] = flag;
                            stack.push(new Pair(x, y));
                        }
                    }
                }

                warpList.add(p);
            }

            ans++;
            for (Pair p : warpList) {
                for (int i = 0; i < warpx.length; i++) {
                    int x = p.h + warpx[i];
                    int y = p.w + warpy[i];
                    if (0 <= x && x < h && 0 <= y && y < w) {
                        if (x == dh && y == dw) {
                            System.out.println(ans);
                            return;
                        }

                        if (s[x][y].equals(".")) {
                            s[x][y] = flag;
                            stack.push(new Pair(x, y));
                        }
                    }
                }
            }

            if (stack.isEmpty()) {
                break;
            }
        }
        System.out.println(-1);
    }

    static class Pair {
        int h;
        int w;

        public Pair(int h, int w) {
            this.h = h;
            this.w = w;
        }
    }
}


Measured memory_bytes: 125120
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int ans = 0;
    
    if( N % 2 == 0){
      ans = N;
    }
    else
    {
      ans= N * 2;
    }
    
    System.out.println(ans);
    
  }
}

  

Measured memory_bytes: 21972
function Main(input) {
	var list = input.split("\n")[1].split(" ");
   var output = 0;
  for(var i = 0; i < list.length; i++){
    output += 1 / parseInt(list[i]);
  }
  console.log(1 / output);
}

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


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int X, Y;
  cin >> X >> Y;

  bool h = 0;

  int dif = Y - X * 2;
  if (dif / 2 <= X && dif >= 0) h = 1;
  if (dif % 2 == 1) h = 0;

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


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

from collections import Counter 

N, K = map(int, input().split())
num_list = list(map(int, input().split()))

# 各数値ごとに数を集計
num_dict = Counter(num_list)
# 数の多い順でソート
num_tpl = num_dict.most_common()

# 種類が少ない時は書き換え0回
if len(num_tpl) <= K:
    print(0)
    exit()
else:
    sum1 = 0
    # 残していい数を集計
    for i in range(K):
        sum1 += num_tpl[i][1]
    # 全体の数 - 残す数で、書き換える数を出す
    print(N - sum1)

Measured memory_bytes: 39336
S=input()
T=input()
s=list(S)
t=list(T)
ss=[]
tt=[]
for i in range(97,123):
    a=s.count(chr(i))
    ss.append(a)
    b=t.count(chr(i))
    tt.append(b)
ss.sort()
tt.sort()
if ss==tt:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6832
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll n,q;
    ll a[100010];
    ll b[100010];
    ll c[100010];
    pair<ll,ll> p[100010];
    rep(i,100010){
      p[i].first = i;
    }
    cin >> n;
    rep(i,n){
      cin >> a[i];
      p[a[i]].second++;
    }
    cin >> q;
    rep(i,q){
      cin >> b[i] >> c[i];
    }
    ll sum = 0;
    rep(i,n){
      sum += a[i];
    }
    rep(i,q){
      sum += (c[i]-b[i])*p[b[i]].second;
      p[c[i]].second += p[b[i]].second;
      p[b[i]].second = 0; 
      cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 7544
#include<bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;  cin >> N;
    vector<int> C(N), S(N), F(N);

    for(int i = 0 ; i < N - 1 ; i++){
        int c, s, f;  cin >> c >> s >> f;
        C[i] = c, S[i] = s, F[i] = f;
    }

    for(int i = 0 ; i < N ; i++){
        int t = 0;
        for(int j = i ; j < N - 1; j++){
            if(t < S[j])  t = S[j];
            else if(t % F[j] == 0);
            else   t = t + F[j] - t % F[j];

            t += C[j];
        }
        cout << t << endl;
    }
    
    return 0;
}


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

using namespace std;

int main(){
  int N, K; cin >> N >> K;
  vector<int> a(N);
  for(auto& t : a) cin >> t;
  vector<long long> s;
  for(int i=0;i<N;i++){
    long long sum = 0;
    for(int j=i;j<N;j++){
      sum += a[j];
      s.push_back(sum);
    }
  }
  long long res = 0;
  for(int i=40;i>=0;i--){
    long long test = res|(1LL<<i);
    int cnt = 0;
    for(auto& t : s){
      if((t&test) == test) ++cnt;
    }
    if(cnt >= K) res |= (1LL << i);
  }
  cout << res << endl;
}

Measured memory_bytes: 6516
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string ret = "";
	while(N != 0){
		if(N%(-2) == 0)
			ret = "0" + ret;
		else{
			N--;
			ret = "1" + ret;
		}

		N /= -2;
	}

	if(ret=="")
		ret = "0";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

/** Problem0036 : A Figure on Surface **/
int main()
{
	char board[8][9];
	
	while (1) {
		for (int i=0; i<8; i++)
			for (int j=0; j<8; j++)
				cin >> board[i][j];
		
		if (cin.eof()) break;
		
		for (int y=0; y<8; y++) {
			for (int x=0; x<8; x++) {
				if (board[y][x] == '1') {
					if (board[y][x+1] == '1' && board[y+1][x] == '1' && board[y+1][x+1] == '1')
						cout << "A" << endl;
					else if (board[y+1][x] == '1' && board[y+2][x] == '1' && board[y+3][x] == '1')
						cout << "B" << endl;
					else if (board[y][x+1] == '1' && board[y][x+2] == '1' && board[y][x+3] == '1')
						cout << "C" << endl;
					else if (board[y+1][x] == '1' && board[y+1][x-1] == '1' && board[y+2][x-1] == '1')
						cout << "D" << endl;
					else if (board[y][x+1] == '1' && board[y+1][x+1] == '1' && board[y+1][x+2] == '1')
						cout << "E" << endl;
					else if (board[y+1][x] == '1' && board[y+1][x+1] == '1' && board[y+2][x+1] == '1')
						cout << "F" << endl;
					else
						cout << "G" << endl;
					goto endloop;
				}
			}
		}
	endloop:
		;
	}
	
	return 0;
}

Measured memory_bytes: 1136
class Node():
    def __init__(self,index):
        self.index = index
        self.parent = self 
        self.size = 1

    @staticmethod
    def find_set(node):
        if node.parent == node:
            return node 
        root = Node.find_set(node.parent)
        node.parent = root
        return root

    @staticmethod
    def union(node_a,node_b):
        root_a = Node.find_set(node_a)
        root_b = Node.find_set(node_b)
        if root_a != root_b:
            if root_a.size < root_b.size:
                root_a.parent = root_b
                root_b.size == root_a.size
            else:
                root_b.parent = root_a
                root_a.size += root_b.size



if __name__ == "__main__":
    n,m = [int(val) for val in input().split()]
    
    persons = []
    count = []
    for i in range(n):
        persons.append(Node(i))
        count.append(0)
    
    for i in range(m):
        a,b = [int(val) for val in input().split()]
        if a > b:
            Node.union(persons[a-1],persons[b-1])
        else:
            Node.union(persons[b-1],persons[a-1])


    for idx,person in enumerate(persons):
        count[Node.find_set(person).index] += 1
    
    # print(count)
    result = max(count)
    print(result)



Measured memory_bytes: 50432
#include<iostream>
using namespace std;
int main() {
    string s;
    while (cin >> s) {
        for (int i = 0; i < (int)s.size() - 1; ++i)
            if (s[i] == s[i + 1]) {
                cout << "Bad" << endl;
                return 0;
            }
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    
    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    // なぜmodintの後ろに＆を書いたり書かなかったりしてるかの理解ができていない
    //おそらく＆をつけるとポインタで参照しているのでもとの値を書き換えることができる
    //＆をつけないとコピーを作ってからそれに対して計算するので、もとの値は変更されない
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }
};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;

//////////////////////////////////////////////////////////////////////
//combination
vector<mint> mintcombvector(3e7);
int startmintcomb(){
    mintcombvector[0]=0;
    mintcombvector[1]=1;
    rep(i,3e7-5){
        mintcombvector[i+2]=mintcombvector[i+1]*(i+2);
    }
    return 0;
}
mint comb(mint a, mint b){
    if(a.x<b.x || a.x<=0 || b.x<0) return mint(0);
    if(b.x==0) return mint(1);
    if(a==b) return mint(1);
    return mintcombvector[a.x]*(mintcombvector[b.x].inv())*(mintcombvector[a.x-b.x].inv());
}
//combinationを使いたいときは　startmintcomb(); を始めに打つこと

int main(){
    startmintcomb();
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int z=(x+y)/3;
    mint a=x-z, b=y-z;
    cout<<comb((a+b),b)<<endl;
    return 0;
}

Measured memory_bytes: 234624
#include <iostream>
#include <cmath>
 
typedef long long ll;
const ll INF = 1LL << 62;
 
using namespace std;
 
int main(){
      ll N;
      cin >> N;
      
      ll ans = INF;
 
      for(ll i = 1;i*i <= N;i++){
            if(N%i==0){
                  ans = min(ans,(i-1)+(N/i-1));
            }
      }
      cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int h,a;
    cin>>h>>a;
    int ans=0;
    if(h%a==0){
        ans=h/a;
    }else{
        ans=h/a+1;
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;

void solve()
  {
   int n;
   cin>>n;
   loop(i,0,n)
    cout<<"ACL";
  } 
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll power(ll n,ll p){
    ll ans = 1;
    while(p){
        if(p&1)ans*=n;
        n*=n;
        p>>=1;
    }
    return ans;
}
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,p;cin>>n>>p;
    map<ll,ll> mp;
    for(ll i=2;i*i<=p;i++){
        if(p%i)continue;
        ll cnt=0;
        while(p%i==0)p/=i,cnt++;
        mp[i]=cnt;
    }
    if(p>1)mp[p]=1;
    ll ans = 1;
    for(auto &ele:mp)ans=ans*power(ele.first,ele.second/n);
    cout<<ans;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
//		String s = sc.next();
//		int n = sc.nextInt();
		double n = sc.nextDouble();
		double k = sc.nextDouble();

		double cnt = 0;
		while(true) {
			if(n < Math.pow(k,cnt)) {
				System.out.println((int)cnt);
				break;
			}
			cnt++;
		}

	}
}


Measured memory_bytes: 24532
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)
	mp := map[int]bool{}
	mp[s] = true
	m := 1
	for {
		m++
		s = f(s)
		if mp[s] {
			fmt.Println(m)
			return
		}
		mp[s] = true
	}
}

func f(a int) int {
	if a%2 == 0 {
		return a / 2
	} else {
		return 3*a + 1
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int n, q;
    cin >> n >> q;
    vll a(n);
    rep(i, n) cin >> a[i];
    
    rep(i, q) {
        ll x;
        cin >> x;

        ll sum = 0, ans = 0;
        int r = 0;
        rep(l, n) {
            while(r < n && sum + a[r] <= x) {
                sum += a[r];
                r++;
            }
            ans += r-l;
            if(l==r) r++;
            else sum -= a[l];
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
int main(void)
{
    int k;
    char s[200],a[200];
    for(int i=0;i<100;i++){
        a[i]='\0';
    }
    scanf("%d",&k);
    scanf("%s",s);
    int l=strlen(s);
    if(l>k){
        strncpy(a,s,k);
        strcat(a,"...");
        printf("%s\n",a);
    }else{
        printf("%s\n",s);
    }
    return 0;
}

Measured memory_bytes: 1644
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int E=in.nextInt(),Y=in.nextInt();
		char r='H';
		switch(E) {
		case 0:
			if(Y<=1911) {
				r='M';
				Y=Y-1911+44;
			}
			else if(Y<=1925) {
				r='T';
				Y=Y-1925+14;
			}
			else if(Y<=1988) {
				r='S';
				Y=Y-1988+63;
			}
			else {
				r='H';
				Y=Y-2016+28;
			}
			break;
			
		case 1:
			Y+=1868-1;
			break;
			
		case 2:
			Y+=1912-1;
			break;
			
		case 3:
			Y+=1926-1;
			break;
			
		case 4:
			Y+=1989-1;
			break;
		}
		
		if(E==0)System.out.printf("%c%d\n", r,Y);
		else System.out.println(Y);
	}

}



Measured memory_bytes: 26484
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

bool bigger(string S, string T) {
    int s = S.size(), t = T.size();
    if (s > t) {
        return true;
    } else if (s < t) {
        return false;
    }
    REP(i, s) {
        if (S[i] > T[i]) {
            return true;
        } else if (S[i] < T[i]) {
            return false;
        }
    }
    return true;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int cost[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i, M) {
        cin >> A[i];
    }
    vector<string> dp(N + 1, "");
    REP(i, N + 1) {
        REP(j, M) {
            int k = i - cost[A[j] - 1];
            if (k < 0) {
                continue;
            }
            string S = to_string(A[j]);
            if (k > 0 && dp[k] == "") {
                continue;
            }
            if (A[j] >= dp[k][0] - '0') {
                S = S + dp[k];
            } else {
                S = dp[k] + S;
            }
            if (bigger(S, dp[i])) {
                dp[i] = S;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 35200
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

int n,y,x,ans;

bool b[105];

int main()
{
    cin >> x >> n;
    for (int i=0;i<n;i++)
    {
        cin >> y;b[y]=1;
    }
    for (int l=x,r=x;l>-1,r<102;l--,r++)
    {
        if (!b[l]){ans=l;break;}
        if (!b[r]){ans=r;break;}
    }
    cout << ans << endl;
    return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using ll = long long;

int N;
ll R = 0;
vector<int> L;

inline void input() {
  cin >> N;
  L.resize(N);
  rep(i, N) cin >> L.at(i);
  sort(all(L));
}

inline void solve() {
  rep(i, N-2) {
    repi(j, i+1, N-1) {
      decltype(L)::iterator it = upper_bound(
        L.begin()+j+1, L.end(),
        max(L.at(i)-L.at(j), L.at(j)-L.at(i)));
      if(it == L.end()) continue;
      size_t pos = distance(L.begin()+j+1, it);
      R += pos;
    }
  }

  for (int i = N-1; i >= 2; i--) {
    for (int j = i-1; j >= 1; j--) {
      decltype(L)::iterator it = upper_bound(
        L.begin(), L.begin()+j,
        max(L.at(i)-L.at(j), L.at(j)-L.at(i)));

      if(it >= L.begin()+j) continue;

      size_t pos = distance(it, L.begin()+j);

      R += pos;
    }
  }
}

inline void Main() {
  // code
  input();
  solve();
  cout << R << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="o"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]


        d = deque()
        for i in range(1, self.h+1):
            for j in range(1, self.w+1):
                if self.getgrid(j, i) == "#":
                    self.set(j, i, 0)
                    d.append((j, i, 0))
        # print(d)
        ans = 0
        while d:
            # print(d)
            cx, cy, cc = d.popleft()
            for dx, dy in move:
                nx, ny = dx + cx, dy + cy
                # print(nx, ny)
                if self.getgrid(nx, ny) == ".":

                    if self.get(nx, ny) > cc + 1:
                        ans = max(ans, cc + 1)
                        self.set(nx, ny, cc + 1)
                        d.append((nx, ny, cc + 1))

        # print(self.getgrid(1, 4))
        print(ans)



def solve():
    h, w = getList()
    g = TwoDimGrid(h, w)
    g.search()
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()







Measured memory_bytes: 185204
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b;
	ans = a - b*2;
	if (ans<0) ans = 0;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

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


Measured memory_bytes: 256
import itertools
import math

n = int(input())
pos = []
for i in range(n):
  pos.append(tuple(map(int, input().split())))
l = list(itertools.permutations(pos))
sum = 0
for i in l:
  for j in range(len(i)-1):
    sum += math.sqrt((i[j][0] - i[j+1][0])**2 + (i[j][1] - i[j+1][1])**2)
print(sum / len(l))


Measured memory_bytes: 8228
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

const int M = 212345;

vector<vector<int>> to(M);
vector<int> x(M);
vector<bool> seen(M, false);

void dfs(int v) {
    seen[v] = true;
    for (auto nv : to[v]) {
        if (seen[nv]) continue;
        x[nv] += x[v];
        dfs(nv);
    }
}

int main () {
    int n, q; cin >> n >> q;
    rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, q) {
        int p; cin >> p; p--;
        int a; cin >> a;
        x[p] += a;
    }
    dfs(0);
    rep(i, n) printf("%d ", x[i]);
    cout << endl;
    return 0;
}

Measured memory_bytes: 23808
n=int(input())
jop=[0]*5
for i in range(n):
    lop=input()
    if lop[0]=='M':
        jop[0]+=1
    elif lop[0]=='A':
        jop[1]+=1
    elif lop[0]=='R':
        jop[2]+=1
    elif lop[0]=='C':
        jop[3]+=1
    elif lop[0]=='H':
        jop[4]+=1
kip=0
for j in range(3):
    for k in range(j+1,5):
        for l in range(k+1,5):
            kip+=jop[j]*jop[k]*jop[l]
print(kip)
    

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}

int main() {
	array<int, 3> Ns;
	cin >> Ns[0] >> Ns[1] >> Ns[2];
	int Max = 0;
	int Sum = 0;
	for (int i = 0; i < 3; i++) {
		Max = max(Max, Ns[i]);
		Sum += Ns[i];
	}
	cout << Max * 10 + Sum - Max << endl;
}



Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    ps <- replicateM n $ do
        [t, x, y] <- map strToInt . words <$> getLine
        return (t, x, y)
    -- 出力
    putStrLn $ if solve (0,0,0) ps then "Yes" else "No"

solve :: (Int, Int, Int) -> [(Int, Int, Int)] -> Bool
solve _ [] = True
solve (t0, x0, y0) ((t1, x1, y1):ps) = (solve (t1, x1, y1) ps) && (even (t0 + t1) == even (x0 + x1 + y0 + y1) && (t1 - t0) >= (abs(x0 - x1) + abs(y0 - y1)))


Measured memory_bytes: 75132
#include <iostream>

using namespace std;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if (b-a<=0) {
        cout<<"delicious"<<endl;
    }else{
        if(x>=b-a){
            cout<<"safe"<<endl;
        }else{
            cout<<"dangerous"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::iter::once;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

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

fn main() {
    let n = read!(usize);
    let a = read!([i64]);

    let mut b = vec![];
    let mut bn = vec![0; n];

    let mut baisu_table = vec![vec![]; n];
    for i in 0..n {
        for j in 0..n {
            let j2 = (i + 1) * (j + 1) - 1;
            if j2 >= n {
                break;
            }
            baisu_table[j2].push(i);
        }
    }

    for i in (0..n).rev() {
        if a[i] != bn[i] % 2 {
            b.push(i + 1);
            debug!(i + 1);
            for &x in &baisu_table[i] {
                bn[x] += 1;
                debug!(x);
            }
        }
    }

    let mut impossible = false;
    for i in 0..n {
        if a[i] != bn[i] % 2 {
            impossible = true;
        }
    }

    if impossible {
        println!("-1");
    } else {
        println!("{}", b.len());
        for x in &b {
            println!("{}", x);
        }
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  long long int ans = 0;
  for (int i = 0; i < 32; i++) {
    int KK;
    if ((K >> i) & 1) {
      KK = (K ^ (1 << i)) | ((1 << i) - 1);
    } else {
      KK = K;
    }
    long long int tmp = 0;
    for (int j = 0; j < N; j++) {
      if ((KK | A[j]) == KK) {
        tmp += B[j];
      }
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll a, b;
  cin >> a >> b;
  
  ll c=0;
  if(b==100) {
    c=a*1000+b;
  }else if(b<10) {
    c=a*10+b;
  }else {
    c=a*100+b;
  }
  
  for(i=0; i*i<c; i++);
  if(i*i==c) pt("Yes");
  else pt("No");
  
  
}




Measured memory_bytes: 256
<?php
//上の段の一番右のカードを、下の段の一番左のカードと交換してしまうミスに気をつけてください。
//最初にゴールの状態からとりうる全パターン（８！通り）を探索し、各パターンへの最小手数を記録しておく。
//普通にやったらTime Limit Exceededになったので。

$file_handle = fopen('php://stdin', "r");	//fopen()は同位フォルダにファイルがあればその名前のみでOK
//$file_handle = fopen('aoj0121_in.txt', "r");

$goal = array(0,1,2,3,4,5,6,7);	//goal state
$move = array(-4, 1, 4, -1);	//0が↑→↓←に動く場合
$visited = array();

//wfs
function wfs() {
	//グローバル変数定義
	global $goal;
	global $move;
	global $visited;
	
	$str = toString($goal);
	$visited[$str] = 0;			//最初の状態を探索済みに追加。代入するのは最短手数
	$queue[0] = $goal;			//ゴールを$queueに入れて開始
	$queue[0]['dist'] = 0;
	while (!empty($queue)) {
	   $cur = array_shift($queue);	//$queueの『頭』から１つ取り出す。
	   
	   //終了条件は不要
	   
	   //探索ロジック
	   //０がどこにあるか
	   for ($i=0; $i<=7; $i++) {
	       if ($cur[$i]===0){
	           $zero = $i;
	           break;
	       }
	   }
	   
	   for ($i=0; $i<=3; $i++) {
	       //スワップ
	       $new_zero = $zero + $move[$i];		//ゼロの位置を移動
	       $new = $cur;		//バグの原因修正１。for文なので$curのままスワップ操作するとNG
	       if ($new_zero>=0 && !empty($new[$new_zero])) {
	           if ($zero===3 && $new_zero===4){ continue; }    //バグの修正２。
	           if ($zero===4 && $new_zero===3){ continue; }    //バグの修正２。
	           $new[$zero] = $new[$new_zero];
	           $new[$new_zero] = 0;
	           //未探索か
	           $str = toString($new);
	           if (!isset($visited[$str])) {				//バグの修正１。empty()は数値の0、文字列の'0'も空と見なしてしまう。ここはisset()が良い
				    $new['dist'] = $cur['dist'] + 1;
				    $visited[$str] = $new['dist'];		//発見したパターンに手数を入れておく
		    		array_push($queue, $new);
	           }
	       }
	   }
	}
}

//toString
function toString($ary){
	$str = '';
	foreach ($ary as $key => $val){
		if (is_numeric($key)) {		//配列のキーが数値ならば（distがあるので）
			$str = $str.$val;
		}
	}
	return $str;
}

//探索
wfs();
//print_r($visited);

while (1){
	//変数の初期化

	//ファイル読み込み
	$ary_start = fscanf($file_handle, '%d %d %d %d %d %d %d %d');
	//終了条件
	if ($ary_start === false){
		break;
	}
	
	//最短手数を計算
	$str = toString($ary_start);
	
	//出力
	if (isset($visited[$str])){
		echo $visited[$str];
	} else {
		echo 'ERROR';
	}
	echo PHP_EOL;
}

fclose($file_handle);

Measured memory_bytes: 11520
/*
贪心，二分答案即可。
*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<numeric>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF=1e9+7;
const int MOD=998244353;
const int N = 1e6 + 5;
const ll inv2=499122177;
const double pi=acos(-1);
ll a[1000005],f[1000005];
ll n,k,ans;
bool cmp(ll a,ll b)
{
	return a>b;
}
bool solve(ll o)
{
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		ll p=o/f[i];
		if(p<a[i])
			sum+=a[i]-p;
	}
	return sum<=k;
}
int main()
{
	ll sum=0;
	scanf("%lld%lld",&n,&k);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	sort(a,a+n);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&f[i]);
	}
	sort(f,f+n,cmp);
	ll L=0,R=1e12,mid;
	while(L+1<=R)
	{
		mid=(L+R)/2;
		if(solve(mid))
			R=mid;
		else
			L=mid+1;
	}
	printf("%lld\n",R);
    return 0;
}



Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	int nh = H / h;
	int nw = W / w;
	int k;
	int maxa = 1000000000;
	if (h == 1 && w == 1) {
		cout << "No" << endl;
		return 0;
	}
	k = (maxa - 1) / (h*w - 1);
	int x = -((h*w - 1)*k + 1);
	if ((H*W - nh*nw)*k > ((h*w - 1)*k + 1)*nh*nw) {
		cout << "Yes" << endl;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (j > 0) {
					cout << " ";
				}
				if ((i%h == h - 1) && (j % w == w - 1)) {
					cout << x;
				}
				else {
					cout << k;
				}
			}
			cout << endl;
		}

	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    ll n, v[100010];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int mn = 1;
    for (int i = 0; i < n - 1; i++) {
        mn += (v[i] >= v[i + 1]);
    }
    cout << mn << endl << n << endl;

}


Measured memory_bytes: 3880