akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define trv(p, u) for (edg *p = h[u]; p; p = p->nxt)
#define push_back pb
typedef long long ll;
typedef double db;
const int N = 1e6 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int rd() {
  int s = 0, w = 1; char c = getchar();
  while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
  while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
  return s * w;
}

int n, ans, a[N], s[N];

struct nod {
  int lft, rgt, sum;
  nod *ls, *rs;
  inline void setc() { sum++; }
  inline void upd() { sum = ls->sum + rs->sum; }
} pol[N << 2], *rot, *cur = pol;

inline void build(nod *r, int lft, int rgt) {
  r->lft = lft, r->rgt = rgt;
  if (lft == rgt) {
    r->sum = 0;
    return ;
  }
  int mid = (lft + rgt) >> 1;
  nod *ls = ++cur, *rs = ++cur;
  r->ls = ls, r->rs = rs;
  build(ls, lft, mid), build(rs, mid + 1, rgt);
  r->upd();
}

inline void chg(nod *r, int pos) {
  if (r->lft == pos && r->rgt == pos) {
    r->setc(); return ;
  }
  if (r->ls->rgt >= pos) chg(r->ls, pos);
  else chg(r->rs, pos);
  r->upd();
}

inline int qry(nod *r, int lft, int rgt) {
  if (lft > rgt) return 0;
  if (r->lft == lft && r->rgt == rgt) return r->sum;
  if (r->ls->rgt >= rgt) return qry(r->ls, lft, rgt);
  else if (r->rs->lft <= lft) return qry(r->rs, lft, rgt);
  else return qry(r->ls, lft, r->ls->rgt) +
              qry(r->rs, r->rs->lft, rgt);
}

inline bool chk(int x) {
  ll res = 0;
  memset(s, 0, sizeof(s));
  cur = pol;
  rep(i, 1, n) {
    if (a[i] <= x) s[i] = s[i - 1] + 1;
    else s[i] = s[i - 1] - 1;
  }
  rep(i, 0, n) s[i] += (n + 1);
  build(rot = pol, 1, N - 100);
  rep(i, 0, n) {
    res += 1ll * qry(rot, 1, s[i] - 1);
    chg(rot, s[i]);
  }
  return (res >= 1ll * n * (n + 1) / 4 + 1);
}

int main() {
  n = rd();
  rep(i, 1, n) a[i] = rd();
  int l = 1, r = inf;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (chk(mid)) ans = mid, r = mid - 1;
    else l = mid + 1;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 69888
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0
if(len(A)==1):
    print(1)
    sys.exit(0)

for i in range(len(A)):
    if(p_l[A[i]]!=0):
        continue
    for k in range(A[i],A_MAX,A[i]):
        if(p_l[k]):
            continue
        p_l[k]=1
    if(i<(len(A)-1) and A[i]==A[i+1]):
        continue
    c+=1
    

print(c)
        
    
    


Measured memory_bytes: 34940
#
# Yet I'm feeling like
# 	There is no better place than right by your side
# 		I had a little taste
# 			And I'll only spoil the party anyway
# 				'Cause all the girls are looking fine
# 					But you're the only one on my mind


import sys
inf = float("inf")
#sys.setrecursionlimit(1000000)


# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0],[0,0,1,-1]

#from cmath import sqrt
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
# from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10
#from bisect import bisect_left,bisect_right
#import numpy as np

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

k,x=get_ints()
result=[]
for i in range(x-k+1,x+k):
    result.append(i)
print(*result)

Measured memory_bytes: 3060
def main():
    k = int(input())
    res = 0
    for x in range(1, k + 1):
        for y in range(1, x + 1):
            for z in range(1, y + 1):
                d = gcd(y, z)
                ins = gcd(x, d)
                if x != y and y != z:
                    res += 6 * ins
                elif x == z:
                    res += ins
                else:
                    res += 3 * ins
    print(res)

def gcd(s, t):
    u = s % t
    if u == 0:
        return t
    return gcd(t, u)


    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
N=int(input())
S=input()
K=int(input())

moji=S[K-1]
S_ok=""
for i in range(N):
    now_moji=S[i]
    if now_moji==moji:
        S_ok=S_ok+now_moji
    else:
        S_ok=S_ok+"*"

print(S_ok)




Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<functional>
#define MM 2000000000
void func(int,int);
int n,m,x,c[12],a[12][12],wk[12],mn;
using namespace std;
int main(void)
{
	int i,j;
	scanf("%d %d %d",&n,&m,&x);
	for(i=0;i<n;i++)	{
		scanf("%d",&c[i]);
		for(j=0;j<m;j++)	{
			scanf("%d",&a[i][j]);
		}
	}
	mn=MM;
	for(i=0;i<m;i++)	wk[i]=0;
	func(0,0);
	if(mn!=MM)	printf("%d\n",mn);
	else printf("-1\n");
	return 0;
}
void func(int nn,int sum)
{
	int i,flg;
	if(nn==n)	{
		flg=1;
		for(i=0;i<m;i++)	{
			if(wk[i]<x)	{
				flg=0;	break;
			}
		}
		if(flg==1)	mn=min(mn,sum);
	}
	else {
		func(nn+1,sum);
		for(i=0;i<m;i++)	{
			wk[i]+=a[nn][i];
		}
		func(nn+1,sum+c[nn]);
		for(i=0;i<m;i++)	{
			wk[i]-=a[nn][i];
		}
	}
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.00001;

int main() {
    int n,q,s[100000];
    cin >> n;
    for(int i = 0;i < n;i++) cin >> s[i];
    cin >> q;
    int c = 0;
    for(int i = 0;i < q;i++) {
        int t;
        cin >> t;
        int l = 0,r = n;
        while(r - l > 1) {
            int m = (r+l)/2;
            if(s[m] < t) l = m+1;
            else if(s[m] > t) r = m;
            else r = (l = m)+1;
        }
        if(s[l] == t) c++;
    }
    cout << c << endl;
}



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


int main() {
  int n  ;
  cin >> n ;
  
  vector<int> a(n);
  int c=1;
  for(int i=0;i<n ;i++){
    cin >> a.at(i);
    if(i>0){
      if(a.at(i-1)>=a.at(i)){
        c++;
      }
      a.at(i)=min(a.at(i),a.at(i-1));
    }
  }
  
  cout << c << endl;
}

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

int main() {
  int N, btn;
  cin >> N;
  btn = 1;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (btn == 2) {
      cout << i << endl;
      break;
    }
    btn = a.at(btn - 1);
  }
  
  if (btn != 2) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
std::string O,E;
void solve(){
  int so=O.size(),se=E.size();
  char res[so+se];
  rep(i,so){
    res[2*i]=O[i];
  }
  rep(i,se){
    res[2*i+1]=E[i];
  }
  rep(i,so+se){
    std::cout<<res[i];
  }
  std::cout<<"\n";
}
int main(){
  cin>>O>>E;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 998244353;
 
priority_queue<int, vector <int>, greater<int>> pq;
int x, y, a, b, c;
vector <int> red, green, colorless;
int32_t main()
{
    usecppio
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i<a; i++)
    {
        int u; cin >> u; red.push_back(u);
    }
    for (int i = 0; i<b; i++)
    {
        int u; cin >> u; green.push_back(u);
    }
    for (int i = 0; i<c; i++)
    {
        int u; cin >> u; colorless.push_back(u);
    }
    sort(all(red),greater<int>());
    sort(all(green),greater<int>());
    sort(all(colorless),greater<int>());
    for (int i = 0; i<x; i++)
        pq.push(red[i]);
    for (int i = 0; i<y; i++)
        pq.push(green[i]);
    for (auto it:colorless)
    {
        if (pq.top() < it)
        {
            pq.pop();
            pq.push(it);
        }
    }
    int ans = 0;
    while(!pq.empty())
    {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4852
N = int(input())
H = list(map(int, input().split()))
H[0] = H[0] - 1
ans ="Yes"
for i in range(N-1):
    if H[i+1] - H[i] >= 1:
        H[i+1] = H[i+1] - 1
    elif H[i+1] - H[i] < 0:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 14396
open Batteries
let () =
  let n,t = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let t_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let rec aux prev l =
    match l with
    | [] -> []
    | hd :: tl -> (hd - prev) :: (aux hd tl)
  in
  let l = aux 0 t_lst in
  let res = t + List.fold_left (fun x y -> x + (if y < t then y else t)) 0 l in
  Printf.printf "%d\n" res



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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N=S.length();
    int cou=0;
    int ans[N];
    for(int i=0;i<N;i++){
        ans[i]=0;
    }
    bool R=true;
    int rar;
    for(int i=0;i<N;i++){
        if(R && S[i]=='R')cou++;
        if(R && S[i]=='L'){
            ans[i]+=cou/2;
            ans[i-1]+=(cou+1)/2;
            cou=0;
            rar=i;
            R=false;
        }
        if(!R && S[i]=='L')cou++;
        if((!R && S[i]=='R') || i==N-1){
            ans[rar]+=(cou+1)/2;
            ans[rar-1]+=cou/2;
            cou=1;
            R=true;
        }
      	cerr << cou;
    }
    for(int i=0;i<N;i++){
        cout << ans[i] << ' ';
    }


}

/*

ちくわぶ

 */



Measured memory_bytes: 1024
N = int(input())
S = input()

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)


Measured memory_bytes: 73680
#include <bits/stdc++.h>
using namespace std;
int main(){
    //write code  here
    int N;
    cin >> N;
    switch (N - (N/10 * 10)) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9: cout << "hon\n";
            break;

        case 0:
        case 1:
        case 6:
        case 8: cout << "pon\n";
            break;

        case 3: cout << "bon\n";
            break;

        default :
            break;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(){
	unsigned long long sum =1;
	long N;
	scanf("%ld",&N);
	for(long i=0;i <N;i++)
	{
		sum *= (i+1);
		sum = sum%1000000007;
	}
	printf("%llu",sum%1000000007);
	}

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

int main(){
	string s,t;
	int cnt = 0;
	cin >> s >> t;
	for(int i=0;i<3;i++) {
		if(s[i] == t[i])
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
const long double PI = acos(-1.0L);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	long double r,ans;
	std::cin >> r;
	ans = r*2.0L*PI;
	std::cout << std::fixed << std::setprecision(50) << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3816
def root(nodes, x):
    if nodes[x] < 0:
        return x
    else:
        nodes[x] = root(nodes, nodes[x])
        return nodes[x]

def unite(nodes, x, y):
    root_x, root_y = root(nodes, x), root(nodes, y)
    if root_x != root_y:
        large_root = min(root_x,root_y)
        small_root = max(root_x,root_y)
        nodes[large_root] += nodes[small_root]
        nodes[small_root] = large_root 

N, M = map(int, input().split())
p = [int(e)-1 for e in input().split()]
# ノードは-1で初期化
nodes = [-1]*N
info = [[int(e)-1 for e in input().split()] for i in range(M)]
for x, y in info:
    unite(nodes, x, y)

group = [[] for i in range(N)]
for i in range(N):
    group[root(nodes,i)].append(i)

def deplications(list1,list2):
    before = len(list1) + len(list2)
    list3 = list(set(list1 + list2))
    after = len(list3)
    return before - after

def make_list(list1):
    list2 = [p[e] for e in list1]
    return list2

ans = 0
for pair in group:
    if pair == []:
        continue
    ans += deplications(pair,make_list(pair))

print(ans)

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

int main(){
    int n;
    cin>>n;
    vector<int> t(n),v(n);
    for(int i = 0; i<n;++i){
        cin>>t[i];
        v[i] = t[i];
    }
    sort(v.begin(),v.end());
    int diff = 0;
    for(int i = 0;i<n;++i){
        if(t[i] != v[i]){
            diff++;
        }
    }
    if(diff<=2){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    


    return 0;
}

Measured memory_bytes: 3600
// --------------
// Tejas Pandey  |
// 26 - 01 - 20  |
// ATCODER #153  |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		ll h,n,k;
		cin >> h;
		ll ans = 0,cur = 1;
		while(h){
			 ans += cur;
			 h /= 2;
			 cur *= 2;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,r,s,p,ans=0,v[100005];
string t;
int main(){
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0;i<n;i++)
    {
        if(i-k>=0&&v[i-k]&&t[i]==t[i-k]) continue;
        if(t[i]=='r') ans+=p;
        if(t[i]=='s') ans+=r;
        if(t[i]=='p') ans+=s;
        v[i]=1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    vector<int> rev(N);
    for(int i=0;i<N;i++){
        rev[v[i]-1] = i + 1;
    }
    for(int i=0;i<N;i++){
        cout<<rev[i]<<endl;
    }
}

Measured memory_bytes: 4044
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int N = scan.nextInt();
            int a;
            int b;
            int c;
            int d;
            int i;
            for (i = 0; i < N; i++) {
                a = scan.nextInt();
                b = scan.nextInt();
                c = scan.nextInt();

                if ((a * a) + (b * b) == (c * c) || (a * a) + (c * c) == (b * b) || (c * c) + (b * b) == (a * a)) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");

                }
            }
        }
    }
}



Measured memory_bytes: 32844
/*
dict
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int n, ans = 0;
    std::cin >> n;
    std::vector<long> a(n);
    for (long i = 0; i < n; i++)
        std::cin >> a[i];

    std::sort(a.begin(), a.end());

    int tmp;
    for (long i = a[1]; i > 0; i--)
    {
        tmp = 0;
        for (int j = 0; j < n; j++)
        {
            if (a[j] % i != 0)
            {
                if (tmp++ >= 2)
                    break;
            }
        }
        if (tmp < 2)
        {
            ans = i;
            break;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		
		int v, j;
		int[] A = new int[N];
		
		for(int i = 0; i < N; i++){
			A[i] = scan.nextInt();
		}
		
		for(int k = 0; k < N; k++){
			System.out.print(A[k]);
			if(k < N-1)System.out.print(" ");
		}
		System.out.println();
		
		for(int i = 1; i < N; i++){
			v = A[i];
			j = i - 1;
			
			while(j >= 0 && A[j] > v){
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			for(int k = 0; k < N; k++){
				System.out.print(A[k]);
				if(k < N-1)System.out.print(" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34104
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n;
    cin >> n;
    int d;
    set<int> s;
    for(int i=0; i<n; i++) {
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 17

int N,K;
int POW[NUM];
int table_index,num_rest;
int table[6][3],work[3];
bool check[3];
string input[NUM];
vector<map<string,string>> dp(65536);

void makeTable(int index){

	if(index == num_rest){
		for(int i = 0; i < num_rest; i++){
			table[table_index][i] = work[i];
		}
		table_index++;
		return;
	}
	for(int i = 0; i < num_rest; i++){
		if(check[i])continue;
		check[i] = true;
		work[index] = i;
		makeTable(index+1);
		check[i] = false;
	}
}

string recursive(int state,string line){

	if(state == POW[N]-1)return "";
	if(dp[state].count(line))return dp[state][line];

	string ret = "wrong";

	int index;
	bool FLG;

	for(int loop = 0; loop < N; loop++){

		if(state & (1 << loop))continue;

		index = 0;
		for(int i = 0; i < N; i++){
			if(input[loop][index] == line[i]){
				index++;
			}
		}
		if(index != K)continue;

		string next_line = input[loop];
		reverse(next_line.begin(),next_line.end());

		for(int i = 0; i < N; i++){
			FLG = false;
			for(int a = 0; a < K; a++){
				if(next_line[a] == line[i]){
					FLG = true;
					break;
				}
			}
			if(!FLG){
				next_line += line[i];
			}
		}
		ret = recursive(state+POW[loop],next_line);
		if(ret != "wrong"){
			ret = (char)('A'+loop)+ret;
			break;
		}
	}
	return dp[state][line] = ret;
}


int main(){

	for(int i = 0; i < NUM; i++)POW[i] = pow(2,i);

	scanf("%d %d",&N,&K);

	getchar();
	for(int i = 0; i < N; i++){
		getline(cin,input[i]);
	}

	num_rest = N-K;

	table_index = 0;
	for(int i = 0; i < num_rest; i++){
		check[i] = false;
	}
	for(int i = 0; i < num_rest; i++){
		check[i] = true;
		work[0] = i;
		makeTable(1);
		check[i] = false;
	}

	string ans = "TMP_ANS";
	bool FLG;

	for(int first = 0; first < N; first++){

		string tmp = input[first];
		reverse(tmp.begin(),tmp.end());

		string rest;

		for(int i = 0; i < N; i++){
			FLG = false;
			for(int a = 0; a < K; a++){
				if(tmp[a] == 'A'+i){
					FLG = true;
					break;
				}
			}
			if(!FLG){
				rest += 'A'+i;
			}
		}

		for(int loop = 0; loop < table_index; loop++){
			string add;
			for(int i = 0; i < num_rest; i++){
				add += rest[table[loop][i]];
			}
			string line = tmp+add;
			string ret = recursive(POW[first],line);
			if(ret != "wrong"){
				ans = min(ans,(char)('A'+first)+ret);
			}
		}
		if(ans != "TMP_ANS")break;
	}

	printf("%s\n",ans.c_str());

	return 0;
}



Measured memory_bytes: 24576
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest114-B
#  https://beta.atcoder.jp/contests/abc082/tasks/abc082_b


def compalTwoString(orgs,orgt):

	minStringS = ''.join(sorted(orgs,reverse=False))
	maxStringT = ''.join(sorted(orgt,reverse=True))
	if minStringS < maxStringT :
		answer= "Yes"
	else:
		answer= "No"
	return answer


if __name__ == '__main__':
	stringS=input()
	stringT=input()
	check=compalTwoString(stringS,stringT)
	print(check)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int x, y; cin >> x >> y;
	printf("%d\n", x + y / 2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    stack<char> stk;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') {
            if (!stk.empty() && stk.top() == '0') {
                stk.pop();
            } else {
                stk.push('1');
            }
        } else {
            if (!stk.empty() && stk.top() == '1') {
                stk.pop();
            } else {
                stk.push('0');
            }
        }
    }
    cout << n - stk.size() << endl;
    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;

	int l = 1;
	int r = n;
	if (n % 2 == 1) {
		while (m > 0) {
			cout << l << " " << r << endl;
			
			++l;
			--r;
			--m;
		}

		return 0;
	}

	bool f = false;
	while (m > 0) {
		if (!f && r - l <= n / 2) {
			--r;
			f = true;
		}

		cout << l << " " << r << endl;
		
		++l;
		--r;
		--m;
	}
	
	return 0;
}


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

int main() {
	int n, m;
	map<int, int> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		if (v.count(d)) {
			v[d]++;
		} else {
			v[d] = 1;
		}
	}
	cin >> m;
	bool r = true;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		if (v.count(t) && v[t]) {
			v[t]--;
		} else {
			r = false;
			break;
		}
	}
	cout << (r ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 9600
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(n):
  x-=a[i]
  if x < 0:
    n=i
    break
if x <=0:
  print(n)
elif x > 0:
  print(n-1)


Measured memory_bytes: 9024
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		BigInteger n = BigInteger.ONE;
		Long a = Long.parseLong(sc.next());
		String bb = sc.next();
		long b = ((long)bb.charAt(0) - 48) * 1000 + 100 * ((long)bb.charAt(2) - 48) + ((long)bb.charAt(3) - 48) * 10;
		n = n.multiply(BigInteger.valueOf(a));
		n = n.multiply(BigInteger.valueOf(b));
		n = n.divide(BigInteger.valueOf((long)1000));
		ou.println(n);
		ou.flush();
	}
}

Measured memory_bytes: 35976
#include <cstdio>
#include <iostream>
#include <string>

main() {
    int d, num;
    scanf("%d", &d);
    num = 25 - d;
    std::string s = "Christmas";
    for (int i = 0; i < num; i++) {
        s += " Eve";
    }
    std::cout << s << std::endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var sum, max, l int
	for i := 0; i < N; i++ {
		fmt.Scan(&l)
		sum += l
		if max < l {
			max = l
		}
	}

	if max < sum-max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
from fractions import gcd
a,b,c,d = map(int,input().split())
cd = gcd(c,d)

#A-1
A1 = (a-1) - (a-1)//c -(a-1)//d +(a-1)//(c*d//cd)
 
#Bまで
B = b - b//c - b//d +b//(c*d//cd)
 
print(B-A1)

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

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1)/2) + (m*(m-1)/2) << endl;
    return 0;
}

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

string R;
double Rd,ans;

int main(){
    std::cin >> R;
    Rd = std::stod(R);
    ans = (double)M_PI * Rd * 2.;
    std::cout << std::setprecision(16) << ans;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main(){
    string o,e;
    cin >> o >> e;
    for(int i = 0; i < o.length()+e.length(); i++){
        if(i%2==0){
            cout << o[i/2];
        }else{
            cout << e[i/2];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a;
    std::deque<int> deq;
    for (int i=0;i<5;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int ans=100000;
    sort(deq.begin(),deq.end());
    do {
        int sum=0;
        for (int j=0;j<5;j++) {
            sum+=deq[j];
            if (j!=4) {
                if (sum>10&&sum%10!=0) {
                    int tmp=sum/10+1;
                    sum=tmp*10;
                } else if (sum<10) {
                    sum=10;
                }
            }
        }
        if (sum<ans) {
            ans=sum;
        }
    } while (next_permutation(deq.begin(),deq.end()));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"oder atc"# => r#"atcoder"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        s: String,
        t: String,
    }

    format!("{}{}", t, s)
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
const double PI=3.141592653589793; 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) REP(i,0,n)
#define pb push_back

int N; 
double d[101][2];

double solve(int x){
    double L1=PI, R1=2*PI;
    double L2=2*PI, R2=3*PI;
    rep(i,N) if(i!=x){
        double X=d[i][0]-d[x][0], Y=d[i][1]-d[x][1];
        //cout<<X<<' '<<Y<<':'<<x<<' '<<i<<endl;
        if(X==0 && Y>0) {L2=max(3*PI,L2);}
        else if(X==0 && Y<0) {R1=min(PI,R1);}
        else{
            double A=atan(Y/X);
            if(X>0) {L1=max(L1,A+(PI/2)); R1=min(R1,A+(PI*3/2)); L2=max(L2,A+(PI*5/2)); R2=min(R2,A+(PI*7/2));}
            else {L1=max(L1,A+(PI*3/2)); R2=min(R2,A+(PI*5/2));}
        }
    }

    double ret=0;
    if(R1>L1) ret+=(R1-L1); 
    if(R2>L2) ret+=(R2-L2); 
    return (ret/(2*PI));

}
int main(){
    cin>>N;
    rep(i,N) cin>>d[i][0]>>d[i][1];
    rep(i,N) cout<<setprecision(7)<<solve(i)<<endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
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){
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    bool k = false;
    ll ans = 0;
    for(int i = 0; i < s.size(); i++){
        int now = s[i] - '0';
        if(k)now++;
        if(now < 5){
            ans += now;
            k = false;
        } else if(now > 5){
            ans += 10 - now;
            k = true;
        } else {
            if(i != s.size() - 1){
                int next = s[i + 1] - '0';
                if(next >= 5){
                    ans += 10 - now;
                    k = true;
                } else {
                    ans += now;
                    k = false;
                }
            } else {
                ans += now;
                k = false;
            }
        }
    }
    if(k) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 1412
#include <iostream>

using namespace std;

#define MAX 100

int main(void)
{
    int num;
    int numArray[MAX];
    
    cin >> num;
    for(int i = 0; i < num; ++i) {
        cin >> numArray[i];
    }
    for(int i = num - 1; i >= 0; --i) {
        if(i > 0) {
            cout << numArray[i] << ' ';
        } else {
            cout << numArray[i] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n,i,j,k,ans=0;
    cin >> n;
    vector<int>l(n);
    for(i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end());
    for(i=0;i<n;i++){
        for(j=0;j<i;j++){
            for(k=0;k<j;k++){
                if(l[i]!=l[j] and l[j]!=l[k] and l[j]+l[k]>l[i]) ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3548
n = int(input())
a = list(map(int, input().split()))
ki=a[0::2]
ki2=[]
for i in ki[::-1]:
    ki2.append(i)
guu=a[1::2]
guu2=[]
for i in guu[::-1]:
    guu2.append(i)

if n%2==0:
    kotae=guu2+ki
else:
    kotae=ki2+guu
kotae=" ".join(map(str,kotae))
print(kotae)

Measured memory_bytes: 33144
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

char buf[300000+10];

int es[300000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  scanf("%s", buf);
  REP(i, n) {
    es[i+1] = es[i] + (buf[i] == 'E');
  }
  int res = 10000000;
  REP(i, n) {
    int cur = (i - es[i]) + (es[n] - es[i+1]);
    res = min(cur, res);
  }
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 1664
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Data.Maybe (fromMaybe)
import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Class (lift)
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

-- 有向グラフに閉路があるか判定し、閉路があれば Nothing を返す。
-- 閉路がなければ最長路の長さを返す。
solve :: V.Vector [Int] -> Maybe Int
solve edges = fmap U.maximum $ runST $ runMaybeT $ do
  let !n = V.length edges  -- 頂点の個数
  vec <- UM.replicate n (-2 :: Int) -- -2: new, -1: DFSの最中, 正: チェック済み
  let dfs !x = do
        s <- UM.read vec x
        case s of
          -2 -> do
            -- x を通る閉路があるかチェックする
            UM.write vec x (-1)
            v <- foldM (\ !a y -> max a <$> dfs y) 0 (edges V.! x)
            lift $ do let !v' = v + 1
                      UM.write vec x v'
                      return v'
          -1 -> mzero  -- コールスタックのどこかで dfs x が呼ばれている。閉路
          v -> return v
  mapM_ dfs [0..n-1]
  U.unsafeFreeze vec

main = do
  n <- readLn
  xs <- V.replicateM n $ do
    U.map (subtract 1) . U.unfoldrN (n-1) (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = n * (n - 1) `quot` 2  -- グラフの頂点数
  let -- (i,j) (0 <= i < j < n) を 0 以上 m 未満の整数値にコードする
      makePair :: Int -> Int -> Int
      makePair i j | i' < j' = n * i' - (i' + 1) * i' `quot` 2 + j' - i' - 1
                   | otherwise = undefined
        where i' = min i j; j' = max i j
  -- 「試合 (i,j) よりも試合 (i',j') の方を後に行う場合に辺 makePair i j → makePair i' j' が存在する」ようなグラフを作る
  let edges :: V.Vector [Int]
      edges = V.create $ do
        e <- VM.replicate m []
        V.forM_ (V.indexed xs) $ \(i,ys) -> do
          U.forM_ (U.zip ys (U.tail ys)) $ \(a,b) -> do
            -- (i,a) -> (i,b)
            let !b' = makePair i b
            -- VM.modify e (b' :) (makePair i a)
            t <- VM.read e (makePair i a)
            VM.write e (makePair i a) $! b' : t
        return e
  print $ fromMaybe (-1) $ solve edges


Measured memory_bytes: 103036
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}


int N,tp[100010];

int ask(int p){
	cout << p << "\n";
	cout.flush();
	
	string s;
	cin >> s;
	if (s=="Male") return 1;
	else if (s=="Female") return 2;
	else exit(0);
}


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	
	tp[0]=ask(0);
	
	int l=0,r=N-1;
	while (r-l>2){
		int mid=(l+r)/2;
		if (mid%2!=l%2) mid++;
		
		tp[mid]=ask(mid);
		if (tp[mid]!=tp[l]) r=mid;
		else l=mid;
	}
	
	ask(l);
	ask(l+1);
	ask(l+2);
	
	return 0;
}



Measured memory_bytes: 852
#include <iostream>
using namespace std;
const int MAXN = 2e5 + 1;
int n, m, i, j, k, z;
long long a[MAXN], b[MAXN];
int main()
{
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m >> k;
	for (i = 1; i <= n; ++i)
		cin >> a[i], a[i] += a[i - 1];
	for (i = 1; i <= m; ++i)
		cin >> b[i], b[i] += b[i - 1];
	z = 0, i = 0, j = m;
	while (a[i] <= k && i <= n)
	{
		while (b[j] > k - a[i])
			--j;
		z = max(z, i + j);
		++i;
	}
	cout << z;
    return 0;
}

Measured memory_bytes: 6720
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,M = MI()
A = [LS2() for _ in range(N)]
B = [LS2() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        if B == [A[i][j:j+M] for i in range(i,i+M)]:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 70608
#include <bits/stdc++.h>
using namespace std;
int main(){

  //input
  int H,W,K;
  cin >> H >> W >> K;
  char A[H][W];
  for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> A[i][j];
  
  
  //setup
  int lpnum = 1<<(H+W);
  int Total = 0;
  for(int i=0;i<lpnum;i++){
    int bknum=0;
    for(int j=0;j<H*W;j++){
      if(A[j/W][j%W]=='#'){
        if((i>>(W+(j/W)))&1&(i>>(j%W))){
          bknum++;
        }
      }
    }
    //cout << bknum << endl;
    if(bknum==K) Total++;
  }
  
  //output
  cout << Total << endl;

}

Measured memory_bytes: 3580
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<int, int>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var a = int.Parse(Console.ReadLine().Trim());
            if (d.ContainsKey(a)) d[a]++;
            else d[a] = 1;
        }
        var res = 0;
        foreach (var x in d)
            if (x.Value % 2 == 1) res++;
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 21088
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
B = sorted([list(map(int,input().split())) for _ in range(M)],key=lambda x:x[1],reverse=True)
cur = 0
cnt = 0
for i in range(N):
    if A[i]<B[cur][1] and cnt<B[cur][0]:
        A[i]=B[cur][1]
        cnt += 1
    elif A[i]>=B[cur][1]:break
    elif cnt>=B[cur][0]:
        cur += 1
        cnt = 0
        if cur>=M:break
        if A[i]<B[cur][1]:
            A[i] = B[cur][1]
            cnt += 1
print(sum(A))

Measured memory_bytes: 82968
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;

typedef long long ll;
typedef complex<double> P;

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

#define curr(p,i) p[i]
#define next(p,i) p[(i+1)%p.size()]
#define EPS (1e-8)

double cross(const P &a,const P &b){
  return imag(conj(a) * b);
}

double dot(const P &a,const P &b){
  return real(conj(a) * b);
}

int ccw(P a,P b,P c){
  b -= a;
  c -= a;
  if(cross(b,c) > 0) return 1;
  if(cross(b,c) < 0) return -1;
  if(dot(b,c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crosspoint(P a,P b,P c,P d){
  double A = cross(b-a,d-c);
  double B = cross(b-a,b-c);
  if(abs(A) < EPS && abs(B) < EPS) return c;
  return c + B / A * (d - c);
}

vector<P> convex_cut(const vector<P> &p,P a,P b){
  vector<P> res;
  rep(i,p.size()){
    P A = curr(p,i), B = next(p,i);
    if(ccw(a,b,A) != -1) res.push_back(A);
    if(ccw(a,b,A) * ccw(a,b,B) < 0)
      res.push_back(crosspoint(A,B,a,b));
  }

  vector<P> r;
  r.push_back(res[0]);
  REP(i,1,res.size()){
    if(abs(res[i] - res[i-1]) > EPS){
      r.push_back(res[i]);
    }
  }

  return r;
}

P getPoint(P a,P b,P med){
  P ab = b - a;
  P n1 = (ab * P(0,1)) / abs(ab);
  double mul = 0.1;
  return med + n1 * mul;
}

double area(vector<P> &p){
  int n = p.size();
  double res = 0;

  rep(i,n){
    res += cross(p[i],p[(i+1)%n]);
  }
  return fabs(res) / 2;
}

int main(){
  P t[3];

  for(int SET=1;;SET++){
    rep(i,3){
      cin>>t[i].real()>>t[i].imag();
    }
    if(t[0].real() == 0) break;

    vector<P> v;
    v.push_back(P(0,0));
    v.push_back(P(10000,0));
    v.push_back(P(10000,10000));
    v.push_back(P(0,10000));

    rep(i,2){
      double div = 2;
      P med = (t[0] + t[i+1]) / div;
      P med_left = getPoint(t[0],t[i+1],med);
      if(ccw(med_left,med,t[0]) == 1){
        v = convex_cut(v,med_left,med);
      }
      else{
        v = convex_cut(v,med,med_left);
      }
    }

    printf("%d %.5f\n",SET,area(v)/(10000*10000));
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

// key: 下から数えてiビット目以上は決まっているとき，x, y の下からiビット目の値
// value: パターン数
ll memo[62][2][2]; 
ll L, R;

// 次に決めるべきはiビット目，L < x 確定済みか， y < R 確定済みか
ll dfs(int i, int flag_x, int flag_y) {
    if(i == -1) return 1LL;
    if(memo[i][flag_x][flag_y]) return memo[i][flag_x][flag_y];

    ll ret = 0LL;
    // 0, 0
    if(flag_x || !(L & (1LL << i))) {
        ret += dfs(i-1, flag_x, flag_y || (R & (1LL << i)));
        ret %= MOD;
    }

    // 0, 1
    if((flag_x || !(L & (1LL << i))) && (flag_y || (R & (1LL << i)))) {
        ret += dfs(i-1, flag_x, flag_y);
        ret %= MOD;
    }

    // 1, 1
    if(flag_y || (R & (1LL << i))) {
        ret += dfs(i-1, flag_x || !(L & (1LL << i)), flag_y);
        ret %= MOD;
    }

    return memo[i][flag_x][flag_y] = ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> L >> R;

    ll ans = 0LL;
    for(int i=0;i<62;++i) {
        if((1LL << (i+1))-1 < L || R < (1LL << i)) continue;
        ans += dfs(i-1, L < (1LL << i), ((1LL << (i+1))-1) < R);
        ans %= MOD;
    }

    cout << ans << endl;
}


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

bool vector_find(vector<int> n, int num) {
    auto itr = find(n.begin(), n.end(), num);
    size_t index = distance(n.begin(), itr);
    if (index != n.size()) return true;
    else return false;
}

int main()
{
    int n, k, count=0;
    vector<int> l;
    cin >> n >> k;
    for (int i=0; i<k; i++) {
        int d;
        cin >> d;
        vector<int> a(d);
        for (int j=0; j<d; j++) {
            cin >> a.at(j);
            if (!vector_find(l, a.at(j))) l.push_back(a.at(j));
        }
    }
    for (int i=1; i<=n; i++) {

        if (!vector_find(l, i)) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3600
# coding: utf-8
# 整数の入力
a, b, c, d = [int(i) for i in input()]
# 計算
if a+b+c+d == 7:
    s = "{}+{}+{}+{}=7"
elif a+b+c-d == 7:
    s = "{}+{}+{}-{}=7"
elif a+b-c+d == 7:
    s = "{}+{}-{}+{}=7"
elif a+b-c-d == 7:
    s = "{}+{}-{}-{}=7"
elif a-b+c+d == 7:
    s = "{}-{}+{}+{}=7"
elif a-b+c-d == 7:
    s = "{}-{}+{}-{}=7"
elif a-b-c+d == 7:
    s = "{}-{}-{}+{}=7"
elif a-b-c-d == 7:
    s = "{}-{}-{}-{}=7"
# 出力
print(s.format(a, b, c, d))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
signed main(){
	IOS;
	int n , r ; 
	cin >> n >> r; 
	if(n<10){
		r += 100*(10-n);
	}
	cout << r << endl ;
	return 0;
}


Measured memory_bytes: 256
a, b = [int(s) for s in input().split()]

p = int(a // 0.08)
q = int(b // 0.1)
s = 13 if p < 24 else p - 12
e = 999 if q > 999 else q + 10
for i in range(s, e+1):
    if int(i * 0.08) == a and int(i *0.1) == b:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

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

#define mk make_pair
#define inb push_back
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define sqr(x) (x) * (x)
#define TIME 1.0 * clock() / CLOCKS_PER_SEC
#define y1 AYDARBOG
//continue break pop_back return

int solve();

int main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
#define TASK "lzss"
#ifndef _DEBUG
    //freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
    solve();
#ifdef _DEBUG
    fprintf(stderr, "\nTIME: %.3f\n", TIME);
#endif
}

int solve()
{
    int n;
    scanf("%d", &n);
    int MAXN = (int)1e5 + 2;
    vi cnt(MAXN);
    for (int i = 0; i < n; ++i)
    {
        int x;
        scanf("%d", &x);
        cnt[x]++;
    }
    int ans = 0;
    for (int i = 1; i <= 99999; ++i)
        ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640