akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

using namespace std;

void re(int& x);

template<class T, class... Ts> void re(T& t, Ts&... ts);

void pr(int x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

typedef pair<int, int> pii;

#define rep(i, a, b) for(int i = a; i < (b); ++i)

int n,m;

int ea[110000];
int eb[110000];
int mk[110000];
int sn[110000];
vector< pii > g[110000];
int deg[110000];

void dfs1(int v) {
    sn[v] = 1;
    for (pii tt : g[v]) if (!sn[tt.first]) {
        mk[tt.second] = 1;
        dfs1(tt.first);
    }
}

int dfs2(int v) {
    sn[v] = 1;
    for (pii tt : g[v]) if (!sn[tt.first]) {
        int sw = dfs2(tt.first);
        deg[v] ^= (!sw);
        if ( (sw) == (ea[tt.second] == v) ) swap(ea[tt.second], eb[tt.second]);
    }

    // dbg(v,deg[v]);
    return deg[v];
}

void solve()
{
    re(n,m);

    if (m % 2 == 1) {
        ps(-1);
        return;
    }

    rep(i,0,m) {
        int u,v; re(u,v); u--; v--;
        g[u].push_back({v,i});
        g[v].push_back({u,i});
        ea[i] = u;
        eb[i] = v;
    }

    dfs1(0);

    rep(i,0,m) if (!mk[i]) deg[ea[i]] ^= 1;

    memset(sn,0,sizeof(sn));
    dfs2(0);

    rep(i,0,m) {
        ps(ea[i]+1, eb[i]+1);
    }
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

template<class T, class... Ts> void re(T& t, Ts&... ts) { 
    re(t); re(ts...); 
}

void pr(int x) { printf("%d", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 13824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final long D = 1000000007;
		long result = 1;

		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();

		// 壊れ段 スタート直前とゴール直後も登録しておく
		int[] a = new int[M + 2];
		a[0] = -1;
		a[M + 1] = N + 1;

		long[] ptrns = new long[M + 2];
		for ( int i = 1; i <= M; i++ ) {
			a[i] = in.nextInt();
			ptrns[i] = getStepPatterns(a[i] - a[i - 1] - 1);
		}
		ptrns[M + 1] = getStepPatterns(a[M + 1] - a[M] - 1);

		for ( int i = 1; i <= M + 1; i++ ) {
			result = (result * (ptrns[i]) % D) % D;
		}

		System.out.println(result);
		in.close();
	}

	// n段のステップパターンを計算する（nにはスタートとゴールの段を含む）
	private static long getStepPatterns(int ｎ) {
		long D = 1000000007;
		long ptrn = 0;

		if ( ｎ <= 0 ) ptrn = 0;
		else if ( ｎ == 1 || ｎ == 2 ) ptrn = 1;
		else
		// (p+2)段目のパターン = (p+1)段目のパターン + p段目のパターン
		if ( 3 <= ｎ ) {
			long p0, p1, p2;
			p0 = p1 = p2 = 1;

			for ( int i = 2; i < ｎ; i++ ) {
				p2 = (p1 + p0) % D;

				p0 = p1;
				p1 = p2;
				if ( p2 > D ) p2 %= D;
			}
			ptrn = p2;
		}
		return ptrn;
	}
}


Measured memory_bytes: 56192
N, M = map(int, input().split())
graph = [[False] * N for _ in range(N)]
visited = [False] * N
sides = []


def dfs(node):
    if visited[node]:
        return
    
    visited[node] = True

    for i in range(N):
        if graph[node][i]:
            dfs(i)


for i in range(M):
    a, b = map(int, input().split())
    sides.append([a - 1, b - 1])
    graph[a - 1][b - 1] = True
    graph[b - 1][a - 1] = True

ans = 0
for side in sides:
    visited = [False] * N
    graph[side[0]][side[1]] = False
    graph[side[1]][side[0]] = False
    dfs(0)
    if False in visited:
        ans += 1
    graph[side[0]][side[1]] = True
    graph[side[1]][side[0]] = True

print(ans)


Measured memory_bytes: 3064
import sys


# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


solution = {}
choice = {}


def solve(x, y):
    if (x, y) in solution:
        return solution[(x, y)]
    for j in range(2, x + 1, 2):
        i = j // 2
        if not solve(x - 2 * i, y + i):
            res = True
            solution[(x, y)] = res
            choice[x, y] = x - 2 * i, y + i
            return res
    for j in range(2, y + 1, 2):
        i = j // 2
        if not solve(x + i, y - 2 * i):
            res = True
            solution[(x, y)] = res
            choice[x, y] = x + i, y - 2 * i
            return res
    res = False
    solution[(x, y)] = res
    return res


def solve2(x, y):
    return abs(x - y) >= 2


def test(N):
    for x in range(N):
        for y in range(N):
            if solve(x, y):
                print(x, y, '     ', choice[x, y])


def main():
    x, y = read_int_list()
    res = solve2(x, y)
    if res:
        print('Alice')
    else:
        print('Brown')


# test(10)
main()


Measured memory_bytes: 3064
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

sm = sum(a)
sm_odd = sum([a[i] for i in range(1, n - 1, 2)])
x = [sm - 2 * sm_odd]

for i in range(1, n):
    x.append(2 * a[i-1] - x[i-1])

print(*x)

Measured memory_bytes: 14708
#include <stdio.h>

int main(void){
    char s1[10],s2[10],s3[10];
    scanf("%s %s %s",s1,s2,s3);
    printf("%c%c%c\n",s1[0] - 32, s2[0] - 32,s3[0] -32);
    return 0;
}

Measured memory_bytes: 128
def main():
    H, W = map(int, input().split())
    a = [[0] * W]
    for _ in range(H):
        ai = list(map(int, input().split()))
        ai.insert(0, 0)
        a.append(ai)
    ans = []
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if a[i][j] % 2 == 0:
                continue
            if W >= j + 1:
                a[i][j] -= 1
                a[i][j + 1] += 1
                ans.append([i, j, i, j + 1])
        if H >= i + 1 and a[i][j] % 2 != 0:
            a[i][j] -= 1
            a[i + 1][j] += 1
            ans.append([i, j, i + 1, j])
    print(len(ans))
    for row in ans:
        print(' '.join(list(map(str, row))))


main()


Measured memory_bytes: 25988
#include <iostream>
#include <vector>
#include <cmath>

#define INF 100000

using namespace std;

void chmin(int &a, int b) { if(a>b) a=b; }

int N, A, B, C;
vector<int> L;

int rec(int i,int a,int b,int c){
	if(i == N){
		if(!a || !b || !c) return INF;
		return abs(a-A)+abs(b-B)+abs(c-C);
	}
	int res=rec(i+1,a,b,c);
	chmin(res,rec(i+1,a+L[i],b,c)+(a ? 10 : 0));
	chmin(res,rec(i+1,a,b+L[i],c)+(b ? 10 : 0));
	chmin(res,rec(i+1,a,b,c+L[i])+(c ? 10 : 0));
	return res;
}

int main() {
    cin >> N >> A >> B >> C;
	L.resize(N);
    for(int i=0; i<N; i++) cin>>L[i];
	cout << rec(0,0,0,0) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N;
    ll A[200000];
    bool checked[200000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
        checked[i]=false;
    }

    int ans=0;
    sort(A, A+N);

    for(int i=N-1;i>=0;i--){
        if(checked[i]) continue;
        checked[i]=true;
        int lgA=log2(A[i]);
        lgA++;
        int val = (1LL<<lgA)-A[i];
        int l=0, r=i;
        while(l<r){
            int m=(l+r)/2;
            if(val<A[m] || (A[m]==val && checked[m])) r=m;
            else l=m;
            if(l+1==r){
                if(checked[l]==false && A[l]==val){
                    checked[l]=true;
                    ans++;
                }
                break;
            }
        }
    }

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

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, M);

    ll T = 1900 * M + 100 * (N-M);
    ll ans = T * pow(2, M);

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
if not bool(H % 3 and W % 3):
    print(0)
    exit()
ans = float('inf')

n = H
m = H//2
l = H-m
for i in range(1, W):
    S1 = n*i
    S2 = m*(W-i)
    S3 = l*(W-i)
    ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))
n = W
m = W//2
l = W-m
for i in range(1, H):
    S1 = n*i
    S2 = m*(H-i)
    S3 = l*(H-i)
    ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))
if H > 3:
    ans = min(ans, (H//3+1)*W-H//3*W)
if W > 3:
    ans = min(ans, (W//3+1)*H-W//3*H)
print(ans)


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

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

using namespace std;

int main(){
	string s; cin>>s;
	cout<<(s=="RRR"?3:s=="SRR"||s=="RRS"?2:s=="SSS"?0:1)<<'\n';
	return 0;
}


Measured memory_bytes: 3616
import math
import copy

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

a = int(inputa[0])
b = int(inputa[1])
# c = int(inputa[2])

# inputb = input().split()
# inputbint = [int(x) for x in inputb]
# inputList = list(b)

# x = int(inputb[0])
# y = int(inputb[1])

inputList=[]
for i in range(a):
    inputNum = input().split()
    inputNum = [int(x) for x in inputNum]
    inputList.append(inputNum)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

ans = [True]*b

for i in range(len(inputList)):
    anstmp = [False]*b

    for j in range(1, len(inputList[i])):
        anstmp[inputList[i][j]-1] = True

    for j in range(b):
        ans[j] = ans[j] * anstmp[j]

cnt = 0
for i in range(b):
    if ans[i] == True:
        cnt += 1

print(cnt)










Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
int main(){
   ll a,b,c;
   cin>>a>>b>>c;
   if(a+b+2*sqrtl(a*b)<c)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}


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

using namespace std;

int main(){
	string s;
	int k;
	cin>>s>>k;
	set<string> q;
	for(int i=0;i<s.size();i++){
		q.insert(s.substr(i,1));
	}
	vector<string> ans;
	while(ans.size()<k){
		string t=*q.begin();
		q.erase(t);
		ans.push_back(t);
		int tlen=t.size();
		for(int i=0;i<s.size()-tlen;i++){
			if(s.substr(i,tlen)==t){
				q.insert(s.substr(i,tlen+1));
			}
		}
	}
	cout<<ans[ans.size()-1]<<endl;
	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	
	for i := 'a'; i <= 'z'; i++ {
		has := false
		for j := 0; j < len(s); j++ {
        	if string(i) == string(s[j]) {
				has = true
			}
		
		}
		if !has {
        	fmt.Println(string(i))
        	return
		}
	}
	fmt.Println("None")
}

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

int main() {
  string S;
  cin >> S;
  
  int zero, one, Min;
  zero = 0;
  one = 0;
  
  for (int i=0; i<S.size(); i++){
    if(S[i] == '0'){
      zero++;
    }else{
      one++;
    }
  }
  
  Min = min(zero, one);
  
  cout << Min*2 << endl;
  
}


Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    _, m = map(int, input().split())

    max = -1
    min = 10 ** 5 + 1
    for _ in range(m):
        l, r = map(int, input().split())
        if l > max:
            max = l
        if r < min:
            min = r
    if min - max < 0:
        print(0)
    else:
        print(min - max + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := scanInt(), scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}
	sort.Ints(A)
	A = append(A, 0)

	cntList, cnt := make([]int, 0), 1
	for i := 1; i <= N; i++ {
		if A[i] == A[i-1] {
			cnt++
		} else {
			cntList = append(cntList, cnt)
			cnt = 1
		}
	}

	sort.Ints(cntList)
	ans := 0
	M := len(cntList)
	for i := 0; i < M-K; i++ {
		ans += cntList[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 10272
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	if(a*b <= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	if(a < 0 && (b-a) % 2 == 0) {
		cout << "Negative" << endl;
		return 0;
	}
	cout << "Positive" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
 
int main(){
    int n;
    double x[4], y[4];
    int xi[4], yi[4];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]);
 
        for(int i = 0; i < 4; i++){
            xi[i] = (int)(x[i] * 1000000);
            yi[i] = (int)(y[i] * 1000000);
        }
         
        if((yi[0] - yi[1])*(xi[2] - xi[3]) == (xi[0] - xi[1])*(yi[2] - yi[3])){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1040
N = int(input())
src = list(map(int, input().split()))

x1 = x2 = x4 = 0
for a in src:
    if a%2 == 1:
        x1 += 1
    elif a%4 == 0:
        x4 += 1
    else:
        x2 += 1

def solve():
    if x4 >= x1: return True
    if x4 + 1 == x1:
        return x2 == 0
    else: return False

print('Yes' if solve() else 'No')


Measured memory_bytes: 14252
N, L = map(int, input().split())

apple = []
for i in range(1, N+1):
    apple.append(L + i - 1)
apple.sort()


taberu_abs = float('inf')
for a in apple:
    if abs(a) < taberu_abs:
        taberu_abs = abs(a)
        taberu = a

print(sum(apple) - taberu)


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int bits_ctzll(unsigned long long b){
	b&=-b;
	int res=0;
	for(int i=5;i>=0;i--){
		int shift=1<<i;
		if(b>>shift){
			b>>=shift;
			res|=shift;
		}
	}
	return res;
}


int main(){
	int n,m,q;
	long long maybe[1000];

	while(cin>>n>>m>>q,n|m|q){
		fill_n(maybe,m,(1LL<<n)-1);
		long long switches=0;
		rep(i,q){
			long long s=0;
			string str,b;
			cin>>str;
			rep(i,n)s|=(long long)(str[i]-'0')<<i;
			cin>>b;
			switches^=s;
			rep(i,m){
				if(b[i]=='1'){
					maybe[i]&=switches;
				}else{
					maybe[i]&=~switches;
				}
			}
		}
		rep(i,m){
			if(maybe[i]&maybe[i]-1){
				cout<<'?';
			}else{
				int ctz=bits_ctzll(maybe[i]);
				if(ctz<10)cout<<ctz;
				else cout<<char('A'+ctz-10);
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100100
const ll inf = (ll)1e10;
ll dp[MAXN];
int n, h[MAXN],k;
ll solve( int pos ) {
	if ( pos == n ) return 0;
	if ( dp[pos] != -1 ) return dp[pos];
	ll ret = inf;
	for ( int i = 1; i <= k; i++ ) {
		if ( pos + i <= n ) {
			ret = min(ret,solve(pos+i)+abs(h[pos]-h[pos+i]));
		}
	}
	return dp[pos] = ret;
}
int main()
{
	#ifdef __APPLE__
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for ( int i = 1; i <= n; i++ ) cin >> h[i];
	memset(dp,-1,sizeof(dp));
	cout << solve(1) << endl;
	return 0;
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
 	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll c;
	cin >>n >>c;
	VL x(n), v(n);
	rep(i, n) cin >>x[i] >>v[i];
	
	VL sv(n+1), rs(n+1);
	rep(i, n) sv[i+1]=sv[i]+v[i];
	
	auto rx=x; auto rv=v;
	reverse(all(rx)); reverse(all(rv));
	rep(i, n) rx[i] = c-rx[i];
	rep(i, n) rs[i+1]=rs[i]+rv[i];
	rep2(i, 1, sz(sv)) sv[i] -= x[i-1];
	rep2(i, 1, sz(rs)) rs[i] -= rx[i-1];
	rep(i, n) sv[i+1] = max(sv[i+1], sv[i]);
	rep(i, n) rs[i+1] = max(rs[i+1], rs[i]);
	//for(auto x :sv) printf("%lld, ",x); puts("");
	//for(auto x :rs) printf("%lld, ",x); puts("");
	
	ll ans = max(sv.back(), rs.back());
	
	rep(i,  n){
		ll w = sv[i+1] + rs[n-i-1] - x[i];
		//dbg(i,w,sv[i+1],rs[n-i],x[i]);
		ans = max(ans , w);
	}
	rep(i,  n){
		ll w = rs[i+1] + sv[n-i-1] - rx[i];
		//dbg(i,w,rs[i+1],sv[n-i],rx[i]);
		ans = max(ans , w);
	}
	if(ans < 0) ans =0;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int H,W;
    cin >> H >> W;
    vector<int> alf(26,0);
    rep(i,H*W){
        char a;
        cin >> a;
        alf[a - 'a']++;
    }
    int ecnt,qcnt,ocnt;
    ecnt = qcnt = ocnt = 0;
    rep(i,26){
        if(alf[i] % 4 == 0){
            qcnt++;
        }else if(alf[i] % 2 == 0){
            ecnt++;
        }else{
            ocnt++;
            if((alf[i] - 1) % 4 == 0){
                qcnt++;
            }else{
                ecnt++;
            }
        }
    }
    bool state = false;
    if(H%2 == 1 && W%2 == 1){
        if(ocnt == 1 && ecnt <= (H+W-2)/2) state = true;    
    }else if(H%2 == 1 && W%2 == 0){
        if(ocnt == 0 && ecnt <= W/2) state = true;
    }else if(H%2 == 0 && W%2 == 1){
        if(ocnt == 0 && ecnt <= H/2) state = true;
    }else{
        if(ocnt == 0 && ecnt == 0) state = true;
    }
    if(state) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
func main(text1: String = readLine()!, text2: String = readLine()!) {
    let text2Indices = text2.indices
    let text2Count = text2.count
    var result = text2Count
    for text1Index in text1.indices {
        if text1[text1Index...].count < text2Count { break }
        var counter = 0
        for (i, j) in zip(text1[text1Index...].indices, text2Indices) where text1[i] != text2[j] {
            counter += 1
        }
        if result > counter {
            result = counter
        }
    }
    print(result)
}

main()

Measured memory_bytes: 7812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, int K, int[] A)
        {
            var sum = new long[N + 1];
            for (int i = 1; i <= N; ++i) { sum[i] = sum[i - 1] + A[i - 1]; }
            var list = new List<long>();
            long max = 0;
            for (int i = 0; i < N; ++i)
            {
                for (int j = i + 1; j <= N; ++j)
                {
                    long value = sum[j] - sum[i];
                    list.Add(value);
                    max = Math.Max(value, max);
                }
            }
            int n = Enumerable.Range(0, 62).First(i => (1L << i) > max) - 1;
            long ans = 0;
            long[] v1 = list.ToArray();
            for (int i = n; i >= 0; --i)
            {
                long[] v2 = v1.Where(v => (v & (1L << i)) != 0).ToArray();
                if (v2.Length >= K)
                {
                    ans |= 1L << i;
                    v1 = v2;
                }
            }
            return ans;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int[] A = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], A));
        }
    }
}


Measured memory_bytes: 34124
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, D, A = map(int, input().split())

I = np.array(read().split(), np.int64)
X = I[::2]
H = I[1::2]

sort_ind = np.argsort(X)
X = X[sort_ind]
H = H[sort_ind]

atack = np.zeros(N+1, np.int64)
cover = np.searchsorted(X, X + (2 * D), side = 'right')

ans = 0
cnt = 0
for i in range(N):
	cnt += atack[i]
	H[i] -= cnt
	if H[i] > 0:
		tmp = -(-H[i]//A)
		ans += tmp
		cnt += tmp * A
		atack[cover[i]] -= tmp * A

print(ans)

Measured memory_bytes: 60192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n; cin>>n;
	map<ll,ll>mp,ret;
	vector<ll>a(n);
	for(ll i=0;i<n;i++){
		ll x; cin>>x;
		a[i]=x;
		mp[x]++;
	}
	ll tot=0;
	for(const auto& m:mp){
		ll val=m.second;
		tot+=(val*(val-1)/2);
	}
	for(const auto& m:mp){
		ll val=m.second;
		ll tmp=tot;
		tmp -=(val*(val-1)/2);
		tmp +=((val-1)*(val-2)/2);
		ret[m.first]=tmp;
	}
	for(const int& aa:a){
		cout<<ret[aa]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int g = 0;
  int p = 0;
  int w = 0, l = 0;
  rep(i,sz(s)) {
    if ( s[i] == 'g' ) {
      if ( p < g ) p++, w++;
      else g++;
    }
    else {
      if ( p < g ) p++;
      else g++, l++;
    }
  }
  std::cout << w - l << std::endl;
  return 0;
}


Measured memory_bytes: 512
N, C = map(int, input().split())
tv = [[0]*C for _ in range(100000)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s-1, t): tv[i][c-1] = 1
print(max([sum(tv[i]) for i in range(100000)]))


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const ll MOD = 1000000007;

const int N = 1000005;

void set_file_io(string in, string out)
{
    freopen((in+".in").c_str(), "r", stdin);
    freopen((out+".out").c_str(), "w", stdout);
}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //set_file_io("input", "output");
    int n;
    cin >> n;
    ll sum = 0, sqr = 0;
    for(int i=0; i<n; i++)
    {
        ll x;
        cin >> x;
        sum = (sum + x) % MOD;
        sqr = (sqr + x*x) % MOD;
    }
    cout << ((sum*sum + MOD - sqr) % MOD) * ((MOD+1)/2) % MOD;
    return 0;
}


Measured memory_bytes: 3652
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scan(&n)
	var a = make([]string, n)
	for i := 1; i <= n; i++ {
		var j int
		fmt.Scan(&j)
		a[j-1] = strconv.Itoa(i)
	}
	fmt.Println(strings.Join(a, " "))
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <set>
using namespace std;

class Point {
public:
  int x, y, z;
  Point(int x = 0, int y = 0, int z = 0) : x(x), y(y), z(z) {}
  bool operator <(const Point &p) const{
    if(z != p.z) return z < p.z;
    if(y != p.y) return y < p.y;
    if(x != p.x) return x < p.x;
    return false;
  }
};

int main() {
  while(1) {
    int n, h;
    cin >> n >> h;
    if(n == 0 && h == 0) break;

    set<Point> hole;
    for(int i = 0; i < h; i++) {
      string str;
      int a, b;
      cin >> str >> a >> b;
      if(str == "xy") {
	for(int j = 1; j <= n; j++) {
	  hole.insert(Point(a, b, j));
	}
      } else if(str == "xz") {
	for(int j = 1; j <= n; j++) {
	  hole.insert(Point(a, j, b));
	}
      } else if(str == "yz") {
	for(int j = 1; j <= n; j++) {
	  hole.insert(Point(j, a, b));
	}
      }
    }

    cout << n*n*n - hole.size() << endl;
  } 

  return 0;
}

Measured memory_bytes: 2336
/* 134c */
#include<stdio.h>
#include<math.h>
int main(void)
{
  int n,i,a[200000],j,m,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<2;i++){
    for(j=i+1;j<n;j++){
      if(a[i]<a[j]){
	if(a[0]<a[j]){
	  c=j;
	}
      m=a[i];
      a[i]=a[j];
      a[j]=m;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i!=c){
      printf("%d\n",a[0]);
    }
    if(i==c){
      printf("%d\n",a[1]);
    }
  }
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)

#define MAX_E (500000)
#define MAX_V (100000)

int V, E; // V:頂点数、E:辺数
struct edge { int from, to, cost; }; // 辺の構造
vector<edge> es; // 辺のメモリを確保
int d[MAX_V];

// ベルマンフォード法　O(VE)
// 配列dに基点sからの最短距離を返す
// 戻り値：sから到達可能なネガティブループがある(true) ない(false)
bool shortest_path(int s) {
	for (int i = 0; i < V; i++) {
		d[i] = INF;
	}
	d[s] = 0;
	for (int i = 0; i < V; i++) {
		bool update = false;
		for (int j = 0; j < es.size(); j++) {
			edge e = es[j];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				// 基点が既に計算済みの辺で、コストがより小さくなるならそのコストを採用
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) return false; // 更新が終わればループを抜ける
	}
	return true; //V回目まで更新がある場合はネガティブループあり
}

int main() {

	cin >> V >> E;
	int r;
	cin >> r;


	for (int i = 0; i < E; i++) {
		edge tmp;
		cin >> tmp.from >> tmp.to >> tmp.cost;
		es.push_back(tmp); // 有向グラフ
	}

	if (shortest_path(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			if (d[i] < INF) cout << d[i] << endl;
			else cout << "INF" << endl;
		}
	}


	return 0;

}


Measured memory_bytes: 3220
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }.toIntArray()

  val max = a.max()!!
  val second = a.sorted().reversed().drop(1).max()!!

  val ans = IntArray(n) { max }
  for (i in 0 until n) {
    if (a[i] == max) ans[i] = second
  }

  println(ans.joinToString("\n"))
}


Measured memory_bytes: 80932
#!/usr/bin/python3
import bisect
# from collections import Counter, deque, OrderedDict, defaultdict
# from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, m, k = map(int, input().split())
    A = [0]+list(map(int, input().split()))
    B = [0]+list(map(int, input().split()))

    from itertools import accumulate

    AA = [0] + A
    BB = [0]+B
    # 累積和を格納したリスト．A[l:r]の総和はB[r] - B[l]
    AA = list(accumulate(A))
    BB = list(accumulate(B))

    ans = 0
    for i in range(n+1):
        s = AA[i]
        if s > k:
            break
        rem = k-s
        idx = bisect.bisect_right(BB, rem)-1
        ans = max(ans, i+idx)
    print(ans)


resolve()

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

using namespace std;

const long long mod = 1000000007;

vector <vector <int>> dp(1009, vector <int>(1009, 0));

int main()
{
    int h, w;

    cin >> h >> w;

    vector <string> s(h);

    for (int i = 0; i < h; ++i)
        cin >> s[i];

    dp[0][0] = 1;

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            char downDirection, rightDirection;
            if (i + 1 < h)
                downDirection = s[i + 1][j];
            if (j + 1 < w)
                rightDirection = s[i][j + 1];

            if(i + 1 < h && downDirection == '.')
                dp[i+1][j] = (dp[i + 1][j] + dp[i][j]) % mod;

            if(j + 1 < w && rightDirection == '.')
                dp[i][j+1] = (dp[i][j + 1] + dp[i][j]) % mod;

            //cout << downDirection << " " << rightDirection << "\n";
        }

    cout << dp[h - 1][w - 1];

    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	rep(i, n-2) {
		if (s.substr(i, 3) == "ABC") {
			++ans;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	string S; cin>>S;
	rp(i,0,S.size()){
		int n = (S[i]-'A'+N)%26;
		cout<<(char)(n+'A');
	}
	puts("");
}


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


q = []
for i in range(N):
    x,l = map(int, input().split())
    q.append((x+l, x-l))

q.sort()

cnt = 0
INF = float("inf")
b = -INF
for r,l in q:
    if l >= b:
        b = r
    else:
        cnt += 1


print(N-cnt)


Measured memory_bytes: 17084
#include <iostream>
#include <string>
#include <cstring>
#include <vector>

int arr[2][8008];
int cache[2][8008][8008];

int canGo(int type, int goal, int len) {
    if (len < 0) {
        return (goal == 0) ? 1 : 0;
    }
    int& ret = cache[type][len][goal];
    if (ret != -1) return ret;

    if (canGo(type, abs(goal - arr[type][len]), len - 1)) {
        return ret = 1;
    } else if (canGo(type, abs(goal + arr[type][len]), len - 1)) {
        return ret = 1;
    } else {
        return ret = 0;
    }
}

int main() {
    int tCnt=0, first = 0;
    int cnt[2]; cnt[0] = -1; cnt[1] = 0;
    int x, y;
    memset(cache, -1, sizeof(cache));
    std::string s;
    std::cin >> s;
    std::cin >> x >> y;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'F') {
            if (tCnt == 0) {
                ++first;
            } else {
                ++arr[tCnt % 2][cnt[tCnt % 2]];
            }
        } else {
            ++cnt[tCnt % 2];
            ++tCnt;
        }
    }
    if (canGo(0, abs(x - first), cnt[0]) && canGo(1, abs(y), cnt[1])) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

}

Measured memory_bytes: 501504
n,k = map(int,input().split())

cnt1,cnt2 = 0,0
if k%2 == 1:
    for i in range(1,n+1):
        if i%k == 0:
            cnt1 +=1
    print(cnt1**3)
else:
    for i in range(1,n+1):
        if  i%k == k//2:
            cnt2 += 1
    for i in range(1,n+1):
        if i%k == 0:
            cnt1 +=1
    print(cnt1**3+cnt2**3)

Measured memory_bytes: 9124
#include <iostream>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;

#define EPS 1e-8
typedef complex<double> P;

P center(P a, P b){
  P m  = (a+b) / 2.0;    // p[i]Æp[j]Ì_
  P n = (a-b) * P(0,1);  // @üxNg
  n = n / abs(n);
  
  double x = abs( a-b )/2.0;
  return m + n * sqrt( 1.0-x*x );     // ~ÌS
}

int main(){
  int n;
  P p[301];

  while( cin>>n && n ){
    for( int i=0;i<n;i++ )
      cin >> p[i].real() >> p[i].imag();

    int ans=1;
    for( int i=0;i<n;i++ ){
      for( int j=0;j<n;j++ ){
	if( i==j ) 	  continue;
	if( abs( p[i]-p[j] )+EPS > 2.0 ) continue;
	P c = center( p[i],p[j] );

	int num=0;
	for( int k=0;k<n;k++ )
	  if( abs( c-p[k] ) < 1.0 + EPS  )
	    num++;
	ans = max( ans,num );
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 984
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>



#define  ll long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define v(T,n) vector<T>n
using namespace std;
const ll MOD = 1000000007;
const ll MAX = 65565;
ll fac[MAX], finv[MAX], inv[MAX];
using Graph = vector<vector<int>>;


/*
  // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
 while (!que.empty()) {  
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
	*/










ll modpow(ll a, ll  n) { //二分累乗法 a^n
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){ //nCk
//use COMinit() before use this.
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



void Main()
{
	int N;
	cin>>N;
	int p[N];

	int ans = 0;
	REP(i,N){
		cin>>p[i];
		
			if(i+1 != p[i]){
				ans++;
			}
		}
	
	if(ans > 2){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	COMinit();
	Main();
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) (a.begin(), a.end())
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

const ll oo = 1e9;

int dp[E5+1];

int pow(int a, int j) {
	int res = 1;
	while (j--) {
		res *= a;
	}

	return res;
}

void solve() {
	ll n;
	cin >> n;
	fill(dp,dp+n+1,oo);
	dp[0] = 0;
	for (int i = 1; i <= n; ++i) {
		int j = 0;
		while (i-pow(9,j) >= 0) {
			dp[i] = min(dp[i],dp[i-pow(9,j)] + 1);
			++j;
		}
		j = 0;
		while (i-pow(6,j) >= 0) {
			dp[i] = min(dp[i],dp[i-pow(6,j)] + 1);
			++j;
		}
		dp[i] = min(dp[i],dp[i-1]+1);
	}

	cout << dp[n] << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std; 
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 
 
#define MAX 300005
#define endl endl
#define UPPER 1000000000

ll H, W;
ll C1, C2, D1, D2;
vector<string> vec;
vector<vector<ll>> flg(1000+1, vector<ll>(1000+1, 0));
vector<vector<ll>> cost(1000+1, vector<ll>(1000+1, 1e18));
set < pair<ll, pair<ll,ll> > > q;
	
int main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll H, W;
	cin>>H>>W;
	
	vector<ll> vec[H+1];
	ll m;
	cin>>m;
	unordered_map<ll,ll> col;
	map<ll,ll> mp;
	for(ll i=0;i<m;++i){
		ll a, b;
		cin>>a>>b;
		vec[a].push_back(b);
		
		col[b]++;
	}	
	
	for(auto it: col){
		mp[it.second]++;
	}
	
	ll ans = 0;
	for(ll i=1;i<=H;i++){
		for(ll j: vec[i]){
			mp[col[j]]--;
			if(mp[col[j]]==0){
				mp.erase(col[j]);
			}
			col[j]--;
			mp[col[j]]++;
		}
		if(mp.size()!=0)
			ans = max(ans, ll(vec[i].size())+(*(--mp.end())).first);
		for(ll j: vec[i]){
			mp[col[j]]--;
			if(mp[col[j]]==0){
				mp.erase(col[j]);
			}
			col[j]++;
			mp[col[j]]++;
		}
	}
	
	cout<<ans<<endl;
	
	
	
}


Measured memory_bytes: 48824
#include<cstdio>
#include<iostream>
using namespace std;
#define rep(x,y) for(x=0;x<(y);++x)
void in();
void solve();
void dfs(int l,int h,char f);
const int MAX_N=110;
char orch[MAX_N][MAX_N];
int L,H;
int x[]={1,0,-1,0};
int y[]={0,1,0,-1};
int main()
{
	in();
	while(L&&H)
	{
		solve();
		in();
	}
	return 0;
}
void in()
{
	cin>>H>>L;
	if(H&&L)
	{
		int i,j;
		rep(i,H)
		{
			rep(j,L)
			{
				cin>>orch[i][j];
			}
		} 
	}
}
void solve()
{
	int l,h;
	int ans=0;
	rep(h,H)
	{
		rep(l,L)
		{
			if(1!=orch[h][l])
			{
				dfs(h,l,orch[h][l]);
				++ans;
			}
		}
	}
	cout<<ans<<endl;
}
void dfs(int h,int l,char f)
{
	orch[h][l]=1;
	int i;
	int ch,cl;
	rep(i,4)
	{
		cl=l+x[i];
		ch=h+y[i];
		if(cl>=0&&cl<L&&ch>=0&&ch<H&&f==orch[ch][cl])
		{
			dfs(ch,cl,f);
		}
	}
}

Measured memory_bytes: 1640
#入力
#aaa
#bvv
#違う文字数を数えれば良い
s=gets
t=gets
#print s,t

s_ar=s.split("")
t_ar=t.split("")

i=0;cnt=0
for s_ in s_ar
  if s_ar[i]!=t_ar[i]
    cnt+=1
  end
  i+=1
end
print cnt


Measured memory_bytes: 34716
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define maxn 1000000
//sort(a,a+n);a数组排列,长度n;升序
//sort(a,a+n,greater<int>());int是数组类型;降序
//mid=l+(r-l)/2;避免越界
long long n,i,j,l1,r1,l2,r2,num,a[maxn+10],b[maxn+10],c[maxn+10],mid;
int main()
{
    while(~scanf("%lld",&n))
    {
        num=0;
        for(i=0; i<n; i++)
            scanf("%lld",&a[i]);
        for(i=0; i<n; i++)
            scanf("%lld",&b[i]);
        for(i=0; i<n; i++)
            scanf("%lld",&c[i]);
        sort(a,a+n);
        sort(b,b+n);
        sort(c,c+n);
        for(i=0; i<n; i++)
        {
            l1=0;
            r1=n-1;
            while(l1<=r1)
            {
                mid=l1+(r1-l1)/2;
                if(a[mid]<b[i])
                    l1=mid+1;
                else
                    r1=mid-1;
            }
            l2=0;
            r2=n-1;
            while(l2<=r2)
            {
                mid=l2+(r2-l2)/2;
                if(c[mid]<=b[i])
                    l2=mid+1;
                else
                    r2=mid-1;
            }
            num+=l1*(n-l2);
        }
        printf("%lld\n",num);
    }
}


Measured memory_bytes: 9216
while True:
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    count = 0
    
    for i in range(1,n - 1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    count += 1
    print(count)


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

using namespace std;
using ll = long long;

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll temp = Y/X;
    int ans = 0;
    while(temp) {
        temp /= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(int argc, char *argv[])
{
	long long int A,B,X,z,x2;
	while(scanf("%lld%lld%lld",&X,&A,&B)!=EOF)
	{
		z=A-B;
		x2=-1*X;
	    if(z>=0)printf("delicious\n");
		else if(z>=x2)printf("safe\n"); 
		else printf("dangerous\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main () {
	long int h, n, a, sum = 0;
	cin >> h >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		sum += a;
	}
	if (sum >= h) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    ordered_students = ['' for _ in range(N)]
    for i, a in enumerate(A):
        ordered_students[a - 1] = str(i + 1)
    print(' '.join(ordered_students))


if __name__ == '__main__':
    main()

Measured memory_bytes: 15588
import math
A, B = map(int, input().split())



def func(a, b):
#     print(a, b)
    if a < b:
        return func(b, a)
    if a % b == 0:
        return b
    else:
        return func(b, a % b)

# print(func(4, 6))
print(A*B//func(A,B))

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

void findab(long long int &a, long long int &b, long long int x) {
    long long int target = pow(a,5) - x;
    if (target==0) return;
    if (target > 0) {
        b++;
        while (pow(b,5) < target) {
            b++;
        }
    }
    else {
        b--;
        while (pow(b,5) > target) {
            b--;
        }
    }
    if (pow(b,5) == target) {
            return;
    }
    a++;
    b=0;
    findab(a, b, x);
}

int main(void) {
    long long int a=1, b=0, x;
    cin >> x;
    findab(a, b, x);
    cout << a << " " << b;
}

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

#define MOD 1000000007
#define MAX_P 1000005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];;
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

Int mod_pow(Int x,Int n,Int mod){
  Int res=1;
  while(n){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

Int mod_inverse2(Int a,Int mod){
  return mod_pow(a,mod-2,mod);
}

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

Int mod_fact(Int n,Int mod,Int& e){
  e=0;
  if(n==0) return 1;
  Int res=mod_fact(n/mod,mod,e);
  e+=n/mod;
  if(n/mod%2!=0)return res*(mod-fact[n%mod]) %mod;
  return res*fact[n%mod]%mod;
}

Int mod_comb(Int n,Int k,Int mod){
  if(n==k||k==0) return 1;
  Int e1,e2,e3;
  Int a1=mod_fact(n,mod,e1),a2=mod_fact(k,mod,e2),a3=mod_fact(n-k,mod,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%mod,mod)%mod;
}

Int mod_comb2(Int n,Int k,Int mod){
  Int res=1;
  for(Int i=0;i<k;i++){
    res*=(n-i)%mod;
    res%=mod;
    res*=mod_inverse(i+1,mod);
    res%=mod;
  }
  return res;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}

Int montmort(Int n,Int mod){
  Int res=0,inv=1;
  for(Int k=2;k<=n;k++){
    (inv*=mod_inverse(k,mod))%=mod;
    if(k%2) (res+=mod-inv)%=mod;
    else (res+=inv)%=mod;
  }
  for(Int i=1;i<=n;i++)
    (res*=i)%=mod;
  return res;
}

// calculate P(t) from given points in [0,N]
Int LagrangePolynomial(vector<Int> &y,Int t,const Int mod){
  init(mod);
  Int n=y.size()-1;
  Int num=1;
  for(Int i=0;i<=n;i++)
    num=num*((t-i)%mod)%mod;
  Int res=0;
  for(Int i=0;i<=n;i++){
    Int tmp=(y[i]*num%mod)*mod_inverse((t-i)%mod,mod)%mod;
    tmp=tmp*finv[i]%mod;
    tmp=tmp*finv[n-i]%mod;
    if((n-i)&1) tmp=mod-tmp;
    res=(res+tmp)%mod;
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  init(MOD);
  Int n;
  cin>>n;
  if(n==2){
    cout<<1<<endl;
    return 0;
  }
  if(n==3){
    cout<<4<<endl;
    return 0;
  }
  Int ans=0,pre=0;
  for(Int i=1;i<n;i++){
    if(i*2<n) continue;
    Int len=mod_comb3(i-1,n-1-i,MOD)*fact[n-1-i]%MOD*fact[i]%MOD;
    ans+=i*(len+MOD-pre)%MOD;
    ans%=MOD;
    pre=len;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 23680
N = int(input())
H = [i for i in map(int,input().split())]
ok=1
for i in range(N-1,0,-1):
  if H[i-1] > H[i]:
    H[i-1] -= 1

for i in range(1,N-1):
  if not H[i-1] <= H[i] <= H[i+1]:
    ok=0
    break
      
if ok:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14224