akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    map<int,int> counter;
    bool is_all_zero = true;
    
    rep(i,N){
        counter[a[i]]++;
        if (a[i] != 0) is_all_zero = false;
    }

    bool isOK = false;

    if (is_all_zero) isOK = true;

    if(N%3 == 0){
    
        int kind_count = counter.size();
        if (kind_count == 2){
            for (auto c : counter){
                if (c.first == 0){
                    if (c.second == N/3){
                        isOK = true;
                    }
                }
            }
        }
        else if (kind_count == 3){
            int xor_val = 0;
            bool countOK = true;
            for (auto c : counter){
                if (c.second != N/3){
                    countOK = false;
                }
                xor_val ^= c.first;
            }
            if (xor_val == 0 && countOK){
                isOK = true;
            }

        }
    }

    if(isOK) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 7240
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

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

    int ans=0;

    REP(i,s.size()){
        if(s[i]=='1'){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    a = i_list()
    a_min = min(a)
    a_max = max(a)
    ans = INF
    for i in range(a_min,a_max+1):
        trial = 0
        for j in a:
            trial += (i-j)**2
        ans = min(ans,trial)
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 9488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main() {
	int t, i, j, k;
	int a, b, c ,d,F=0;
	char A[100];
	
	cin >> a >> b >> c >> d;

	F = max(a*b, c*d);
		
		
		cout << F << endl;
	return 0;
}

Measured memory_bytes: 256
def knapsack_weight(single=True):
    """
    重さが小さい時のナップサックDP
    :param single: True = 重複なし
    """
    """ dp[weight <= W] = 重さ上限を固定した時の最大価値 """
    dp_min = 0  # 総和価値の最小値
    dp = [dp_min] * (W + 1)

    for item in range(N):
        if single:
            S = range(W, weight_list[item] - 1, -1)
        else:
            S = range(weight_list[item], W + 1)
        for weight in S:
            if weight - weight_list[item] < T:
                dp[weight] = max2(dp[weight], dp[weight - weight_list[item]] + price_list[item])
    return max(dp[T:])

import sys
input = sys.stdin.readline


def max2(x, y):
    return x if x > y else y

def min2(x, y):
    return x if x < y else y


N, T = map(int, input().split())                                # N: 品物の種類 W: 重量制限

price_list = []
weight_list = []
data = []
for _ in range(N):
    weight, price = map(int, input().split())
    data.append((weight, price))
data.sort()
for weight, price in data:
    price_list.append(price)
    weight_list.append(weight)

max_weight = max(weight_list)

W = T + max_weight - 1

print(knapsack_weight(single=True))

Measured memory_bytes: 74592
from copy import deepcopy
def howmanytimes(x):
	global count
	flag=False	
	for i in range(len(x)):
		if x[i]%2==0:
			x[i]=int(x[i]/2)
		else:
			flag=True
	if flag:
		return 0
	else:
		count+=1
		howmanytimes(x)
	
			
a=int(input())
t=list(map(int,input().split()))
q=deepcopy(t)
count=0
howmanytimes(q)
print(count)

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main()
{
  int a, b, an[5001], br[5001], s, t;
  while(cin>>a>>b && a+b){
    for(int i = 0; i < a; ++i) cin >> an[i];
    for(int i = 0; i < b; ++i) cin >> br[i];
    s = 0;

    for(int i = 0; i < b; ++i){
      t = 0;
      for(int j = 0; i+t < b && j < a; ++j)
        if(an[j] == br[i+t]) ++t;
      if(s < t) s = t;
    }

    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
x = I()
ans = -1
for b in range(1,x+2):
    for p in range(2, x+2):
        if b**p > x:
            break
        ans = max(ans, b**p)
print(ans)


Measured memory_bytes: 10344
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int> (w, 0));
	string s;
	for(int i = 0; i < h; i++) {
		cin >> s;
		for(int j = 0; j < w; j++) {
			if (s[j] == '#')
				a[i][j] = 1;
		}
	}

	vector<vector<ll>> dp(h, vector<ll> (w, 0));
	dp[0][0] = 1;

	for(int i = 0; i < w; i++) {
		for(int j = 0; j < h; j++) {
			if (!a[j][i]) {
				if (j > 0 && !a[j-1][i])
					dp[j][i] += (dp[j-1][i]%M);
				if (i > 0 && !a[j][i-1])
					dp[j][i] += (dp[j][i-1]%M);
			}
		}
	}

	cout << dp[h-1][w-1]%M << "\n";
}

Measured memory_bytes: 12032
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int K = scan.nextInt();
			int R = scan.nextInt();
			int S = scan.nextInt();
			int P = scan.nextInt();
			String T = scan.next();//|T| = N
			char[] t = new char[N];
			char[] dasita = new char[N];
			t = T.toCharArray();
			long goukei = 0;
			
			for(int i = 0;i<N;i++) {
				if(i<=K-1){
						dasita[i]=katu(t[i]);
						switch(dasita[i]) {
						case 'r':goukei+=R;break;
						case 's':goukei+=S;break;
						case 'p':goukei+=P;break;
						}
				}else{
					if(t[i]=='r') {
						if(dasita[i-K]=='p') {
							if(i+K<N) {
								dasita[i] = saiteki(dasita[i-K],katu(t[i+K]));
							}else {
								dasita[i]='r';	
							}
						}else {
						goukei+=P;dasita[i]='p';
						}
					}
					if(t[i]=='s') {
						if(dasita[i-K]=='r') {
							if(i+K<N) {
								dasita[i] = saiteki(dasita[i-K],katu(t[i+K]));
							}else {
								dasita[i]='s';	
							}
							}else {
							goukei+=R;dasita[i]='r';
							}
					}
					if(t[i]=='p') {
						if(dasita[i-K]=='s') {
							if(i+K<N) {
								dasita[i] = saiteki(dasita[i-K],katu(t[i+K]));
							}else {
								dasita[i]='p';	
							}
							}else {
							goukei+=S;dasita[i]='s';
							}
					}	
					
				}
				
				//System.out.println(dasita[i]);
			}
			
			
			
			System.out.println(goukei);
			
		}
		
		
		
		
	}

		
		private static char katu(char c) {
			char s='1';
			
			if(c=='r')s='p';
			if(c=='s')s='r';
			if(c=='p')s='s';
			
			return s;
		}
		
		private static char saiteki(char mae,char ato) {
			if(mae=='r') {//チーパー
				if(ato=='r')return's';//なんでもいい
				if(ato=='s')return'p';
				if(ato=='p')return's';
				
			}
			if(mae=='s') {//グーパー
				if(ato=='r')return'p';
				if(ato=='s')return'r';//なんでもいい
				if(ato=='p')return'r';
				
			}
			if(mae=='p') {//チーグー
				if(ato=='r')return's';
				if(ato=='s')return'r';
				if(ato=='p')return'r';//なんでもいい
			}
			return'2';
		}
		
		
		
	
		

}


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

#define pf push_front
#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

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

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=5005,INF=1e9;
int n;
char s[MAXN],t[MAXN];
deque<int>a,b;
int main() {
	scanf("%d%s%s",&n,s+1,t+1);
	for(int i=1;i<=n;++i)s[i]-='0',t[i]-='0';
	s[0]=s[1]^1,s[n+1]=s[n]^1,t[0]=t[1]^1,t[n+1]=t[n]^1;
	for(int i=1;i<=n+1;++i){
		if(s[i]!=s[i-1])a.pb(i);
		if(t[i]!=t[i-1])b.pb(i);
	}
	if(s[1]!=t[1])a.pf(1);
	for(int i=0;i<=n+1;++i)a.pf(1),a.pf(1);
	for(int i=0;i<=n+1;++i)a.pb(n+1),a.pb(n+1);
	int ans=INF;
	for(int i=0;i+b.size()<=a.size();i+=2){
		int tmp=0;
		for(int j=0;j<i;++j)tmp+=abs(a[j]-1);
		for(int j=i;j<(int)(i+b.size());++j)tmp+=abs(a[j]-b[j-i]);
		for(int j=i+b.size();j<(int)a.size();++j)tmp+=abs(a[j]-(n+1));
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    string S;
    cin >> S;
    int b=0;
    REP(i,3){
        if(S[i]=='B')b++;
    }
    if(b==1 || b==2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60; // 十分大きい値とする

int main() {
    // 入力
    int N; cin >> N;
    vector<long long> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 配列 dp を定義 (配列全体を無限大を表す値に初期化)
    vector<long long> dp(N, INF);

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        if (i == 1) dp[i] = abs(h[i] - h[i - 1]);
        else dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), 
                         dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

// 9min
int main(void){
  int n = 0;
  int a[101];
  double sum = 0;
  double ans = 0;

  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  //逆数の総和の逆数を求める
  //まず逆数の総和を求める
  
  for(int i = 0; i < n; i++){
    sum += 1.0 / a[i];
  }

  ans = 1.0 / sum;

  printf("%f\n", ans);

  return 0;

}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int i,N;
  int s=0;
  int a[100];
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<N;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        s=1;
        break;
      }
    }
  }
  
  if(s==0)
    printf("APPROVED");
  else
    printf("DENIED");
  
  return 0;
}

Measured memory_bytes: 1736
import sys
import numpy as np

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())
    p = np.array(list(map(int, input().split())), dtype='f8')
    p = (p + 1) / 2
    rs = np.zeros(N + 1, dtype='f8')
    for i in range(N):
        rs[i + 1] = rs[i] + p[i]
    ans = 0
    for i in range(N - K + 1):
        ans = max(ans, rs[i + K] - rs[i])

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 33960
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    s = input()
    if s[-1] != 's':
        print(s + "s")
    else:
        print(s + "es")

if __name__ == '__main__':
    main()


Measured memory_bytes: 9344
S = input()
T = input()

flag = True
translate1 = [-1 for i in range(26)]
translate2 = [-1 for i in range(26)]
for i in range(len(S)):
    s = ord(S[i])-97
    t = ord(T[i])-97

    if translate1[s] == -1:
        translate1[s] = t
    else:
        if translate1[s] != t:
            flag = False
            break 

    if translate2[t] == -1:
        translate2[t] = s
    else:
        if translate2[t] != s:
            flag = False
            break


if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3760
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 100000000
typedef pair<ll, ll> P;



//initialization here
//
const int maxn = 1e5+10;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int h, w;
queue<pair<int, pair<int, int>>> que;
int dist[60][60];
string s[60];
//
//initialization finish


// your function is here
//

void qpush(int cost, int x, int y)
{
	que.push(mp(cost, mp(x, y)));
}

bool isinField(int x, int y)
{
	if (0 <= x && 0 <= y && x <= h - 1 && y <= w - 1) return true;
	else return false;
}


//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//
	cin >> h >> w;
	int siro = 0;
	rep(i, h)
	{
		cin >> s[i];
		rep(j, s[i].size())if (s[i][j] == '.') siro++;
	}

	rep(i, h)rep(j, w) dist[i][j] = INF;

	qpush(0, 0, 0);

	while (!que.empty())
	{
		int cost = que.front().F;
		int x = que.front().S.F;
		int y = que.front().S.S;
		que.pop();

		if (dist[x][y] <= cost) continue;
		dist[x][y] = cost;

		rep(i, 4)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (!isinField(nx,ny))continue;
			if (s[nx][ny] == '#')continue;
			if (dist[nx][ny] < INF) continue;
			qpush(cost + 1, nx, ny);
		}
	}

	if (dist[h - 1][w - 1] == INF) Print(-1);
	else Print(siro - dist[h - 1][w - 1] - 1);

	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int a, b;
	cin >> a >> b;

	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
		return 0;
	}
	
	if (a < 0 && b < 0) {
		int sa = b - a - 1;
		if (sa % 2 == 0) {
			cout << "Positive" << endl;
			return 0;
		}
		else {
			cout << "Negative" << endl;
			return 0;
		}
	}

	return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	string s;
	cin >> s;
	int n = s.size();

	// LL を見つける
	vector<int> l(0) , r(0);
	rep(i,n){
		if((i == 0 || s[i] != s[i-1]) && s[i] == 'L'){
			l.push_back(i);
		}
		if((i == n - 1 ||  s[i] != s[i+1]) && s[i] == 'L'){
			l.push_back(i);
		}
		if((i == 0 || s[i] != s[i-1]) && s[i] == 'R'){
			r.push_back(i);
		}
		if((i == n - 1 ||  s[i] != s[i+1]) && s[i] == 'R'){
			r.push_back(i);
		}
	}

	vector<int> ans(n,0);
	rep(i,l.size()/2){
		int m = l[2*i];
		int M = l[2*i+1];
		int kazu = M - m + 1;
		int guu =(kazu+1) / 2;
		ans[m] = guu;
		ans[m-1] = kazu - guu;
	}
	rep(i,r.size()/2){
		int m = r[2*i];
		int M = r[2*i+1];
		int kazu = M - m + 1;
		int guu =(kazu+1) / 2;
		ans[M] += guu;
		ans[M+1] += kazu - guu;
	}

	for(auto x: ans){
		cout << x << " ";
	}
	cout << endl;
}


Measured memory_bytes: 4728
#include <stdio.h>

int main(){
	int n,a=0,b=0,ab=0,o=0;
	char s[10];
	while( scanf("%d,%s", &n , s) != EOF ){
		//if(n==-1)break;
		
		if(s[0]=='A' && s[1]=='B'){
			ab++;
		}else if(s[0]=='A'){
			a++;
		}else if(s[0]=='B'){
			b++;
		}else if(s[0]=='O'){
			o++;
		}
	}
	printf("%d\n%d\n%d\n%d\n", a,b,ab,o);
	return 0;
}

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

int main() {
    int N; cin>>N;
    vi A(N+1),B(N);
    ll sum=0;
    for (int i = 0; i < N+1; i++){
        cin>>A[i];
        sum+=A[i];
    }
    for (int i = 0; i < N; i++)cin>>B[i];
    ll ans=0;
    for (int i = 0; i < N; i++){
        int old_A=A[i],old_A2=A[i+1];
        A[i]=max(0,A[i]-B[i]);
        B[i]-=old_A-A[i];
        A[i+1]=max(0,A[i+1]-B[i]);
        B[i]-=old_A2-A[i+1];
    }
    ll sum2=0;
    for (int i = 0; i < N+1; i++)sum2+=A[i];
    cout<<sum-sum2<<endl;
}

Measured memory_bytes: 3972
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n; cin >> n; vl num((n+1)/2); bool flag = true; ll ans = 0;
  
  rep(i,n){
    ll x; cin >> x; num[x/2]++;
  }
  
  
  if(n % 2 == 0){
    rep(i,n/2){
      if(num[i] != 2){
        flag = false;
        break;
      }
    }
  }
  
  else{
    if(num[0] != 1){
      flag = false;
    }
    
    rep(i,n/2){
      if(num[i+1] != 2){
        flag = false;
        break;
      }
    }
  }
  
  if(flag){
    ans = 1;
    rep(i,n/2){
      ans *= 2;
      ans = mod(ans);
    }
  }
  
  cout << ans << endl;
}

    
       

Measured memory_bytes: 640
import           Control.Monad
import           Data.Char
main = do
    s <- map digitToInt <$> getLine :: IO [Int]
    putStrLn . head $ f s
  where
    f [a,b,c,d] = do
        [(o1,s1), (o2,s2), (o3,s3)] <- replicateM 3 [((+), "+"),((-), "-")]
        guard (a `o1` b `o2` c `o3` d == 7)
        return $ show a ++ s1 ++ show b ++ s2 ++ show c ++ s3 ++ show d ++ "=7"

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=2e6+9;
bool vis[N];
vector<int>adj[N];
int n,m,cnt;
void dfs(int s)
{
	vis[s]=1;
	cnt ++;
	for(auto v : adj[s]) {
		if(!vis[v]) dfs(v);
	}
}
int main()
{
    cin >> n >> m;
	int ans=0;
	while (m--)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			cnt = 0;
			dfs(i);
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 63112
#include "stdio.h"

int binarySearch(int [], int [], int i, int n);

main(){

  int i, c=0, n, q, s, t, S[100001], T[50001];

  scanf("%d", &n);

  for(i=0 ; i<n ; i++){

    scanf("%d", &s);
    S[i] = s;
  }

  scanf("%d", &q);

  for(i=0 ; i<q ; i++){

    scanf("%d", &t);
    T[i] = t;
  }

  for(i=0 ; i<q ; i++){
    c += binarySearch(S,T,i,n);
  }

  printf("%d\n", c);

  return 0;

}


int binarySearch(int S[], int T[], int i, int n)
{
  int left=0, right=n, mid;

  while(left < right){
    mid = (left + right)/2;

    if(S[mid] == T[i]){
      return 1;
    }else if(T[i] < S[mid]){
      right = mid;
    }else {
      left = mid + 1;
    }
  }
    return 0;
}

Measured memory_bytes: 1184
def resolve():
  base = 10**9+7
  S = int(input())
  dp = [0] * (S+1)
  dp[0] = 1
  if S >= 3:
    dp[3] = 1

  for i in range(4, S+1):
    dp[i] = dp[i-2] + dp[i-3] + dp[i-4]
  # print(dp)
  print(dp[S]%base)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 63612
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  string S;
  string T;
  int A;
  int B;

  string U;

  cin >> S >> T >> A >> B >> U;

  if (S == U) {
    A--;
  }
  else {
    B--;
  }

  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long
string s1,s2,s3;
long long l1,l2,l3;
long long k1=0,k2=0,k3=0;
char c;
void f1();
void f2();
void f3();
void f1()
{
	if(l1==0)
	{
		cout<<'A'<<endl;
		return;
	}
	l1--;
	//k1++;
	if(s1[k1]=='a')
	{
		k1++;
		f1();
	}
	else if(s1[k1]=='b')
	{
		k1++;
		f2();
	}
	else if(s1[k1]=='c')
	{
		k1++;
		f3();
	}
}

void f2()
{
	if(l2==0)
	{
		cout<<'B'<<endl;
		return ;
	}
	l2--;
	if(s2[k2]=='a')
	{
		k2++;
		f1();
	}
	else if(s2[k2]=='b')
	{
		k2++;
		f2();
	}
	else if(s2[k2]=='c')
	{
		k2++;
		f3();
	}
}

void f3()
{
	if(l3==0)
	{
		cout<<'C'<<endl;
		return ;
	}
	l3--;
	if(s3[k3]=='a')
	{
		k3++;
		f1();
	}
	else if(s3[k3]=='b')
	{
		k3++;
		f2();
	}
	else if(s3[k3]=='c')
	{
		k3++;
		f3();
	}
}


int main()
{
	cin>>s1>>s2>>s3;
	l1=(int)s1.size();
	l2=(int)s2.size();
	l3=(int)s3.size();
	c=s1[k1];
	f1();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;
#define INF 1000000007

int main(){
    string s; cin >> s;
    int l = s.size();

    int c0 = 0, c1 = 0;
    for(int i = 0; i < l; i++)
    {
        if(s[i] == '0') c0++;
        else c1++;
    }

    cout << 2 * min(c0, c1) << "\n";
    return 0;
}


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

long long min(long long x,long long y){
	if(x<y){
		return x;
	}else{
		return y;
	}
}


int main(){
	int N,M;
	long long a[50],b[50],c[50],d[50];
	long long far;
	pair<long long,long long> answer[50];//first:距離
	cin >> N >> M;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<M;i++){
		cin >> c[i] >> d[i];
	}
	
	for(int i=0;i<50;i++){
		answer[i].first=100000000000;
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			far=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(answer[i].first>far){
				answer[i].first=far;
				answer[i].second=j;
			}
		}
		cout << answer[i].second+1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int A, B;
	string S;
	cin >> S >> A >> B;
	VI X;
	VI Y;
	int sum = 0,cnt = 0;
	int fcnt = 0;
	bool F = true;
	REP(i, S.size()) {
		if(S[i]=='F')
			fcnt++;

		sum++;
		if ((i==S.size()-1 || S[i] == 'T') && F) {
			if (i == S.size() - 1 && S[i] == 'F')sum++;
			X.push_back(sum - cnt-1);
			cnt=sum;
			F = false;
		}
		else if ((i == S.size() - 1 || S[i] == 'T')  && !F) {
			if (i == S.size() - 1 && S[i] == 'F')sum++;
			Y.push_back(sum - cnt - 1);
			cnt=sum;
			F = true;

		}
		
	}
	//REP(i, X.size())cout << X[i] << endl;
	//cout << endl;
	//REP(i, Y.size())cout << Y[i] << endl;

	bool dpx[8000][16001] = { false };
	bool dpy[8000][16001] = { false };

	dpx[0][X[0] + 8000] = true;

	if (Y.size() > 0) {
		dpy[0][Y[0] + 8000] = true;
		dpy[0][8000 - Y[0]] = true;
	}

	FOR(i, 1, X.size()) {
		REP(j, 16001) {
			if ((dpx[i - 1][j - X[i]] && j - X[i]>=0 )|| (dpx[i - 1][j + X[i]] && j + X[i]<16001)) {
				dpx[i][j] = true;
				//cout << i << " " << j << endl;
			}
		}
	}
	//cout << endl;
	FOR(i, 1, Y.size()) {
		REP(j, 16001) {
			if ((dpy[i - 1][j - Y[i]] && j - Y[i] >=0)|| (dpy[i - 1][j + Y[i]] && j + Y[i]<16001)){
				dpy[i][j] = true;
				//cout << i << " " << j << endl;
			}
		}
	}
	if (Y.size() == 0) {
		if (A == fcnt)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

		return 0;
	}

	if (dpy[Y.size() - 1][B+8000] && dpx[X.size() - 1][A+8000])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
		
	return 0;
}



Measured memory_bytes: 250496
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
const int N=1e5+5;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef map<ll,int>::iterator miter;
int n,p[N+5],pcnt;
bool vis[N+5];
map<ll,int> cnt,calc;
map<ll,ll> inver;
void Init()
{
	for(int i=2;i<=N;i++)
	{
		if(!vis[i])
            p[++pcnt]=i,calc[1ll*i*i]=i;
		for(int j=1;i*p[j]<=N;j++)
		{
			vis[i*p[j]]=true;
			if(i%p[j]==0)
                break;
		}
	}
}
int main()
{
	//freopen("anticube.in","r",stdin);
	//freopen("anticube.out","w",stdout);
	scanf("%d",&n);
	Init();
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ll a,tmp,h=1,inv=1;
		scanf("%lld",&a);
		tmp=a;
		for(int j=1;j<=pcnt&&1ll*p[j]*p[j]*p[j]<=a;j++)
			if(tmp%p[j]==0)
			{
				int xcnt=0;
				while(tmp%p[j]==0)
                    tmp/=p[j],xcnt++;
				xcnt%=3;
				int xxcnt=xcnt;
				while(xxcnt--)
                    h*=p[j];
				for(int i=1;i<=(3-xcnt)%3;i++)
                    inv*=p[j];
			}
		if(tmp>1)
		{
			h*=tmp;
			miter it=calc.find(h);
			if(it!=calc.end())
                inv*=it->second;
			else
                inv*=tmp*tmp;
		}
		cnt[h]++;
		inver[h]=inv,inver[inv]=h;
	}
    if(cnt.find(1)!=cnt.end()){
        ans++;
        cnt.erase(1);
    }
	for(miter it=cnt.begin();it!=cnt.end();it++)
		if(cnt.find(inver[it->first])==cnt.end())
            ans+=it->second;
		else
		{
			ans+=max(it->second,cnt[inver[it->first]]);
			it->second=cnt[inver[it->first]]=0;
		}
	printf("%d\n",ans);
}


Measured memory_bytes: 19712
#include "bits/stdc++.h"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------"
using namespace std;
using Info = tuple<int, int>;
int main()
{
    int coins[] = {10,50,100,500};
    stringstream result;
    int f;
    while (cin >> f, f) {
        int have[4], change[4];
        int m;
        rep(i, 4) {
            cin >> have[i];
            m += have[i] * coins[i];
        }
        m -= f;
        rrep(i, 4) {
            change[i] = m / coins[i];
            m -= change[i] * coins[i];
        }
        rep(i, 4) {
            int use = have[i] - change[i];
            if (use <= 0) continue;
            result << coins[i] << " " << use << endl;
        }
        result << endl;
    }
    string r = result.str();
    r.erase(--r.end());
    cout << r;
    
    return EXIT_SUCCESS;
}

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


void solution(){
	ll n;
	cin>>n;
	if(n <=1000)
		cout<<1000-n<<'\n';
	else if(n>1000 and n <=2000)
		cout<<2000-n<<'\n';
	else if(n>2000 and n <=3000)
		cout<<3000-n<<'\n';
	else if(n>3000 and n <=4000)
		cout<<4000-n<<'\n';
	else if(n>4000 and n <=5000)
		cout<<5000-n<<'\n';
	else if(n>5000 and n <=6000)
		cout<<6000-n<<'\n';
	else if(n>6000 and n <=7000)
		cout<<7000-n<<'\n';
	else if(n>7000 and n <=8000)
		cout<<8000-n<<'\n';
	else if(n>8000 and n <=9000)
		cout<<9000-n<<'\n';
	else
		cout<<10000-n<<'\n';

}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	solution();
	return 0;

}

Measured memory_bytes: 3640
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	int ans = 1e9;

	for (int a = 1; a < n; a++){
		int b = n - a;

		string stra = to_string(a);
		string strb = to_string(b);

		int atotal = 0;
		int btotal = 0;

		for (int i = 0; i < stra.size(); i++){
			atotal += stra[i] - '0';
		}

		for (int i = 0; i < strb.size(); i++){
			btotal += strb[i] - '0';
		}

		ans = min(ans, atotal + btotal);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
/**
 *   created: 12 April 2019  00:37:24
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
int main(){
	int tc=1;
	// cin>>tc;
	while(tc--){
		int n;
		cin>>n;
		vi v(n);
		rep(i,0,n)
		cin>>v[i];
		int max=0,res=0;
		rep(i,0,n){
			if(max<=v[i]){
				res++;
				max = v[i];
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main(){
    long n;
    string s;
    cin >> n;
    while(n>0){
        n--;
        s += 'a'+n%26;
        n = (n-n%26)/26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
    static String a;
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int count = 0;
        IN:for(int i = 0; i < n; i++) {
            int x = stdIn.nextInt();
            for(int j = 2; j*j <= x; j++) {
                if(x % j == 0) continue IN;
            }
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 41020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    vector<int> cnt(60);
    rep(i,n){
        rep(j, 60){
            if (a[i] & 1LL<<j) cnt[j]++;
        }
    }

    ll ans = 0;
    for(int i = -1; i < 60; i++){
        if (i != -1 && !(k & 1LL<<i)) continue;

        ll sum = 0;
        for(int j = 0; j < 60; j++){
            ll ketaNum = 1LL<<j;
            if (j < i){
                sum += ketaNum * max(cnt[j], n-cnt[j]);
            }else if (i == j){
                sum += ketaNum * cnt[j];
            }else{
                if (k & ketaNum) sum += ketaNum * (n-cnt[j]);
                else sum += ketaNum * cnt[j];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	
	
	vector<vector<int>> nex(d);
	// 貪欲
	ll ans = 0;
	rep(i, d) {
		ll mx = -1001001001;
		int now = 0;
		
		rep(j, n) {
			ll tmp = ans;
			tmp += s[i][j];
			rep(k, n) {
				if(j == k) continue;
				tmp -= c[k] * (i+1-last[k]);
			}
			if(mx < tmp) {
				nex[i].push_back(now+1);
				mx = tmp;
				now = j;
			}
		}
		ans = mx;
		last[now] = i+1;
		t[i] = now+1;
	}
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 200000) break;
		vector<int> old = t;
		const int CH = rand()%10 + 1; // CH箇所変える
		rep(i, CH) {
			// int nd = rand()%d;
			// int nq = rand()%n + 1;
			// t[nd] = nq;
			int nd = rand()%d;
			t[nd] = nex[nd][rand()%nex[nd].size()];
		}
		
		// 点数の再計算
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j-1]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
		} else {
			t = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    ll n;
    cin>>n;
    vector<pl> red(n),blue(n);
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        red[i] = {a,b};
    }
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        blue[i] = {a,b};
    }
    sort(all(blue));
    vb ispair(n,false);
    ll ans = 0;
    rep(i,n){
        ll maxi = -1;
        ll maxind = -1;
        rep(j,n){
            if(red[j].first < blue[i].first && red[j].second < blue[i].second){
                if(ispair[j]) continue;
                if(maxi < red[j].second){
                    maxi = red[j].second;
                    maxind = j;
                }
            }
        }
        if(maxind != -1){
            ispair[maxind] = true;
            ans++;
        }
    }
    cout<<ans<<endl;
	return 0;
}


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

using namespace std;

void D(int N, vector<int>& A) {
	long long ways = 0;
	unordered_map<int, long long> freq;

	for (int num: A)
		freq[num]++;
	for (auto it: freq)
		ways += it.second * (it.second - 1) / 2;
	
	for (int i = 0; i < N; i++)
		cout << ways + 1 - freq[A[i]] << endl;
}

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

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(true){
        int n, x;
        cin>>n>>x;
        if(n==0 && x==0) break;
        int c=0;
        for(int i=1; i<=n; i++){
            for(int j=1; j!=i && j<=n; j++){
                for(int k=1; k!=j && k<=n; k++){
                    if(i+j+k==x) c++;
                }
            }
        }
        cout<<c<<endl;
    }
    
    
}


Measured memory_bytes: 3136
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long k = Long.parseLong(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()) - 1);
        sc.close();

        // 主処理
        boolean[] used = new boolean[n]; // List.containsが遅いためbooleanの配列でループ判定をする
        List<Integer> loopNum = new ArrayList<>();
        int now = 0;

        // ループするまでの移動の証跡をリストに格納する
        while (!used[now]) {
            used[now] = true;
            loopNum.add(now);
            now = a[now];
        }

        int size = loopNum.size(); // ループによる重複をなくした移動回数
        int primalyCount = loopNum.indexOf(now); // ループ外の部分の移動回数
        int loopCount = size - primalyCount; // ループ部分の移動回数

        long num = k; // ループ部分を排除した移動回数を求める
        if (primalyCount < num) {
            num = ((num - primalyCount) % loopCount) + primalyCount;
        }

        int result = loopNum.get((int) num) + 1;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 64120
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll cntC = (b/c)-((a-1)/c);
	ll cntD = (b/d)-((a-1)/d);
	ll g = (c*d)/__gcd(c, d);
	ll cntG = (b/g)-((a-1)/g);
	cout << 1+b-a-(cntC+cntD-cntG) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = sorted([int(input()) for _ in range(N)])
ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    for s_i in s:
        if s_i % 10 != 0:
            ans -= s_i
            print(ans)
            break
    else:
        print(0)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	
	int n, m;
	int k[10];
	int s[10][10];
	int p[10];


	cin >> n >> m;
	rep(i,m) {
		cin >> k[i];
		rep(j, k[i]) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	rep(i, m)cin >> p[i];

	int ans = 0;
	rep(x, 1<<n) {
		bool ok = true;
		rep(i, m) {
			int cnt = 0;
			rep(j, k[i]) {
				if (x >> s[i][j] & 1)cnt ^= 1;
			}
			if (cnt != p[i]) {
				ok = false;
				break;
			}
		}
		if (ok)
 			ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 074c
int n, m;
int adj[60][60];
bool visited[50];

void dfs(int v){
    visited[v] = true;
    for(int nv=0; nv<50; nv++){
        if (adj[v][nv]==0) continue;
        if (visited[nv]) continue;
        dfs(nv);
    }
}

int main(){
    cin >> n >> m;
    rep(i, n)rep(j, n) adj[i][j] = 0;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a][b] = 1;
        adj[b][a] = 1;
    }
    int cnt = 0;
    rep(i, n-1)for(int j=i+1; j<n; j++){
        if (adj[i][j] == 0) continue;
        rep(k, n) visited[k] = false;
        adj[i][j] = 0;
        adj[j][i] = 0;
        dfs(0);
        bool flag = true;
        rep(l, n){
            if (!visited[l]){
                flag = false;
                break;
            }
        }
        if (!flag) cnt++;
        adj[i][j] = 1;
        adj[j][i] = 1;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
using namespace std;
bool fl=		0				;
bool mtest=		0			;

//

//

void solve()
{
	ld r;	cin>>r;
	cout<<2*3.14159*r<<endl;
}


int main()
{
	
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 3788
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A == B) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

def ans() :
    evenStr = "LUD"
    oddStr = "RUD"

    s = input()
    flg = True
    for i in range(len(s)):
        if i % 2 == 1 and s[i] in evenStr:
            continue
        elif i % 2 == 0 and s[i] in oddStr:
            continue
        else:
            flg = False
            break

    if flg:
        print("Yes")
    else:
        print("No")




if __name__ == '__main__':
    ans()

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

const long INFTY = 1000000001;
long cnt = 0;

void merge(long A[], long left, long mid, long right){
	long n1 = mid - left;
	long n2 = right - mid;
	vector<long> L(n1 + 1), R(n2 + 1);
	for (long i = 0; i < n1; i++) L[i] = A[left + i];
	for (long i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = INFTY;
	R[n2] = INFTY;
	long i = 0;
	long j = 0;
	for (long k = left; k < right; k++){
		cnt++;
		if (L[i] <= R[j]){
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}

void mergeSort(long A[], long left, long right){
	if (left + 1 < right){
		long mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	long n, S[500000];
	cin >> n;
	for (long i = 0; i < n; i++) cin >> S[i];
	mergeSort(S, 0, n);
	for (long i = 0; i < n; i++){
		if (i) cout << " ";
		cout << S[i];
	}
	cout << endl << cnt << endl;
	return 0;
}

Measured memory_bytes: 8856