akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  out("square1001");
}


Measured memory_bytes: 3080
/*ex9_2
  kt125 */

#include<stdio.h>
#define SIZE 100001

//キューブを格納する単方向リスト
typedef struct _cube{
    char num;
    struct _cube *next;
}cube;

void push(cube **head, char num); //キューブの追加をする関数
void pop(cube **head); //キューブの取り出しをする関数

int main(void){
    cube *head = NULL;
    char string[SIZE], *ptr;
    int count =0; //取り除く個数をカウントする変数
    scanf("%s", string);
    ptr = string; //文字列の先頭アドレスを渡す

    while(*ptr){
        //キューブが何もない場合と、同色のものしかない場合は追加
        if(head == NULL || head->num == *ptr){
            push(&head, *ptr);
        }else{ //それ以外では異色のペアができるので取り除いてカウント+2
            pop(&head);
            count+=2;
        }
        ptr++;
    }
    
    printf("%d", count);
    return 0;
}

void push(cube **head, char num){
    cube *new = calloc(1, sizeof(cube)); //追加する分の領域確保
    if(new == NULL) exit(1);
    new->num = num;
    new->next = *head;
    *head = new;
}

void pop(cube **head){
    cube *tmp = *head;
    if(tmp == NULL) exit(1);
    *head = tmp->next;
    free(tmp); //メモリ解放
}

Measured memory_bytes: 4932
s = sorted(input())
t = sorted(input(), reverse = True)
N = len(s)
M = len(t)

i = 0

while(i < N and i < M):
  if(s[i] < t[i]):
    print("Yes")
    break
  elif(s[i] > t[i]):
    print("No")
    break
  else:
    i += 1

if(N < M and i == N):
  print("Yes")

if(M <= N and M == i):
  print("No")

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

int main()
{ 
    char x,y;
    cin >> x >> y;
    if(x == y) {
        cout << '=' << endl;
    } 
    else if (x < y) {
        cout << '<' << endl;
    } else {
        cout << '>' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=[]
A=list(map(int, input().split()))

# print(A)
mina = min( A )
maxa = max( A )

A.sort()
A.reverse()

sum = 0
for i in range(n-1):
    sum +=A[(i+1)//2]
    # print(A[(i+1)//2])

# print(mina)
# print(maxa)
# print(sum)
print(sum)


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    cout << a[0] << " " << a[n - 1] << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, a, b;
  int hourPrice, FixPrice, realCost;
  cin >> N >> a >> b;
  hourPrice = N * a;
  FixPrice = b;
  realCost = min(hourPrice, FixPrice) ;
  cout << realCost << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

llint n;
bool dp[405][3][3][7][7][7][7];
bool sch[405][4][4];
llint dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

bool check(llint d, llint x, llint y)
{
	if(sch[d][x][y] || sch[d][x+1][y] || sch[d][x][y+1] || sch[d][x+1][y+1]) return false;
	return true;
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		
		for(int i = 1; i <= n; i++){
			for(int j = 0; j < 16; j++){
				cin >> sch[i][j%4][j/4];
			}
		}
		
		for(int d = 0; d <= n; d++){
			for(int x = 0; x < 3; x++){
				for(int y = 0; y < 3; y++){
					for(int i = 0; i < 7; i++){
						for(int j = 0; j < 7;j++){
							for(int k = 0; k < 7; k++){
								for(int l = 0; l < 7; l++){
									dp[d][x][y][i][j][k][l] = false;
								}
							}
						}
					}
				}
			}
		}
		if(!check(1, 1, 1)){
			cout << 0 << endl;
			continue;
		}
		dp[1][1][1][1][1][1][1] = true;
		
		for(int d = 1; d < n; d++){
			for(int x = 0; x < 3; x++){
				for(int y = 0; y < 3; y++){
					for(int i = 0; i < 7; i++){
						for(int j = 0; j < 7;j++){
							for(int k = 0; k < 7; k++){
								for(int l = 0; l < 7; l++){
									if(!dp[d][x][y][i][j][k][l]) continue;
									for(int s = 0; s < 4; s++){
										for(int t = 0; t <= 2; t++){
											llint nx = x + t*dx[s], ny = y + t*dy[s];
											if(nx < 0 || nx >= 3 || ny < 0 || ny >= 3) continue;
											if(!check(d+1, nx, ny)) continue;
											llint ni = i+1, nj = j+1, nk = k+1, nl = l+1;
											if(nx == 0 && ny == 0) ni = 0;
											if(nx == 0 && ny == 2) nj = 0;
											if(nx == 2 && ny == 2) nk = 0;
											if(nx == 2 && ny == 0) nl = 0;
											if(ni >= 7 || nj >= 7 || nk >= 7 || nl >= 7) continue;
											dp[d+1][nx][ny][ni][nj][nk][nl] = true;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	
		bool ans = false;
		for(int x = 0; x < 3; x++){
			for(int y = 0; y < 3; y++){
				for(int i = 0; i < 7; i++){
					for(int j = 0; j < 7;j++){
						for(int k = 0; k < 7; k++){
							for(int l = 0; l < 7; l++){
								ans |= dp[n][x][y][i][j][k][l];
							}
						}
					}
				}
			}
		}
		if(ans) cout << 1 << endl;
		else cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 10740
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

int main(){
    string s;
    cin >> s;
    char cur=s[0];
    bool ans=true;
    for(int i=1;i<4;i++){
        if(cur==s[i]){
            ans=false;
        }
        cur=s[i];
    }
    if(ans){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define N_MAX 100

int main(){
  int n, i, j, k, v, a[N_MAX];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(i = 0; i < n; i++){
    printf("%d", a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");


  for(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(k = 0; k < n; k++){
      printf("%d", a[k]);
      if(k != n-1) printf(" ");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int k;
  cin >> n;
  cin >> k;
  vector<int> saikoro(n); 
  for(int i=0;i<n;i++){
    cin >> saikoro.at(i);
  }
  auto expectation = [](int x){
    int sum;
    sum =0;
    for(int i=1;i<=x;i++){
      sum+=i;
    }
    return sum/((double) x);
  };
  double init_sum;
  vector<double> kitaichi(n);
  for(int i=0;i<n;i++){
    kitaichi.at(i) = expectation(saikoro.at(i));
  }
  for(int i=0;i<k;i++){
    init_sum += kitaichi.at(i);
  }
  double max_sum;
  double pre_sum;
  double now_sum;
  pre_sum = init_sum;
  max_sum = init_sum;
  now_sum = init_sum;
  for(int i=k;i<n;i++){
    now_sum = pre_sum- kitaichi.at(i-k)+kitaichi.at(i);
    if(now_sum > max_sum){
      max_sum = now_sum;
    }
    pre_sum = now_sum;
  }
  printf("%.10f\n", max_sum);
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static P[] p;
	static Map<Long, Long> map = new HashMap<>();
	static int N, W;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			N = in.nextInt();
			W = in.nextInt();
			p = new P[N];
			for (int i = 0; i < N; i++) {
				int w = in.nextInt(), v = in.nextInt();
				p[i] = new P(w, v);
			}

			out.println(func(0, 0));

		}
	}

	static long func(int d, int j) {
		long key = (long)d << 32 | j;
		if (d == N) {
			map.put(key, 0L);
			return 0;
		}
		if (map.containsKey(key)) {
			return map.get(key);
		}

		long ret = 0;
		long r1 = 0;
		long r2 = 0;

		if (j + p[d].w <= W) {
			r1 = func(d + 1, j + p[d].w) + p[d].v;
		}
		r2 = func(d + 1, j);
		ret = Math.max(r1, r2);
		map.put(key, ret);
		return ret;
	}

	static class P {
		int w,v;
		P (int w, int v) {
			this.w = w;
			this.v = v;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 67264
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  int road[55];
  for (int i = 0; i < 55; i++)
    road[i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    road[a-1]++; road[b-1]++;
  }
  for (int i = 0; i < N; i++)
    cout << road[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int k;
    cin >> k;
    ll sum = 0;
    for(int i = 1 ; i <= k ; i++)
    {
        for(int j = 1 ; j <= k ; j++)
        {
            for(int w = 1 ; w <= k ; w++)
            {
                sum += __gcd(i , __gcd(j , w));
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

eat_r = p[:x]
eat_g = q[:y]
eat = eat_r + eat_g
sort_eat = sorted(eat)
for i in r:
    if sort_eat[0] < i:
        sort_eat.append(i)
sort_eat.sort(reverse=True)

print(sum(sort_eat[:x + y]))


Measured memory_bytes: 23484
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	ll a, b;
	cin >> a >> b;
	cout <<a*b/ __gcd(a, b) << endl;	
	
}





Measured memory_bytes: 256
array  = []
while True:
    n = int(input())
    if n == 0:
        break
    tmp_array = []
    for i in range(n):
        tmp_array.append(int(input()))
    tmp_array.sort()
    array.append(str(sum(tmp_array[1:-1])//(n-2)))

print("\r\n".join(array))



Measured memory_bytes: 5604
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cstring>
#define INT long long
#define oo 987654321
 
using namespace std;
INT T[1<<20], n, k, base, mn, cnt = 1;
INT getMax(int l, int r)
{
    INT ret = 0;
    while( l <= r )
    {
        if( l%2==1 ) ret = max( ret, T[l++]);
        if( r%2==0 ) ret = max( ret, T[r--]);
        l>>=1, r>>=1;
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for( base = 1 ; base < n ; base<<=1 );
    for(int i = base ; i < base+n ; i++ ) cin>>T[i];
    for(int i = base-1 ; i > 0 ; i-- ) T[i] = max( T[2*i], T[2*i+1] );
    for(int i = base ; i < base+n ; i++ )
    {
        INT val = getMax(i+1, base+n-1);
        if( val-T[i] > 0 and val - T[i] == mn ) cnt++;
        else if( val-T[i] > 0 and val - T[i] > mn ) mn = val - T[i], cnt = 1;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

bool pair_compair_blue(pair<int, int> a, pair<int, int> b)
{
  if (a.first != b.first)
  {
    return a.first < b.first;
  }
  else
  {
    return a.second > b.second;
  }
}

bool pair_compair_red(pair<int, int> a, pair<int, int> b)
{
  if (a.second != b.second)
  {
    return a.second > b.second;
  }
  else
  {
    return a.first < b.first;
  }
}

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

  vector<pair<int, int>> r, b;
  bool used[110] = {};

  rep(i, n)
  {
    int x, y;
    cin >> x >> y;
    r.push_back({x, y});
  }

  rep(i, n)
  {
    int x, y;
    cin >> x >> y;
    b.push_back({x, y});
  }

  sort(r.begin(), r.end(), pair_compair_red);
  sort(b.begin(), b.end(), pair_compair_blue);

  int ans = 0;
  for (auto blue : b)
  {
    rep(i, n)
    {
      if (used[i])
        continue;

      auto red = r[i];
      if (blue.first >= red.first + 1 && blue.second >= red.second + 1)
      {
        ans++;
        used[i] = true;
        // cout << "blue: " << blue.first << " " << blue.second << endl;
        // cout << "red: " << red.first << " " << red.second << endl;
        break;
      }
    }
  }

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

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
X = [[] for _ in range(N)]
P = [-1] * N
for i in range(N-1):
    a, b = map(int, input().split())
    X[a-1].append((i, b-1))
    #print(X)
    #P[b-1] = a-1
#print(X)

Q = deque([(0, -1)])
ANS = [-1] * (N-1)
cmax = 0
while Q:
    x, c0 = Q.pop()
    c = 1
    for i, y in X[x]:
        if c == c0: c += 1
        ANS[i] = c
        Q.appendleft((y, c))
        c += 1
    cmax = max(cmax, c-1)

print(cmax)
for ans in ANS:
    print(ans)

Measured memory_bytes: 28984
#include <stdio.h>
int main(){
	int i;
	char cards[201];
	int n;
	int k;
	int turn;
	int rem[2];
	
	while(1){
		scanf("%d\n",&n);
		if(!n)break;
		for(i=0;i<=200;i++){
			cards[i]=9;
		}
		for(i=1;i<=2*n;i++){
			cards[i]=1;
		}
		for(i=1;i<=n;i++){
			scanf("%d\n",&k);
			cards[k]=0;
		}
		//start
		turn=0;
		rem[0]=n;
		rem[1]=n;
		
//int l;for(l=1;l<=2*n;l++){printf(l==2*n?"%d\t":"%d ",cards[l]);}printf("%d %d\n",rem[1],rem[0]);
		
		while(rem[0]>0&&rem[1]>0){
			for(i=1;i<=2*n;i++){
				if(cards[i]==turn){
					cards[i]=7+turn;
					rem[turn]--;
					if(!rem[0]||!rem[1])break;
//for(l=1;l<=2*n;l++){printf(l==2*n?"%d\t":"%d ",cards[l]);}printf("%d %d\n",rem[1],rem[0]);
					turn=1-turn;
				}
			}
			turn=1-turn;
		}
		printf("%d\n%d\n",rem[1],rem[0]);
	}
	return 0;
}

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B = MAP()

if abs(A - B) % 2 == 0:
    print('Alice')
else:
    print('Borys')


Measured memory_bytes: 5532
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int calc(int n){
	int count=0;

	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int k=0;k<=9;k++){
				if((n-i-j-k)<=9 && (n-i-j-k)>=0){
					count++;
				}
			}
		}
	}

	return count;
}

int main(void){
	int n;

	while(scanf("%d",&n)!=EOF){
		printf("%d\n",calc(n));
	}

    return 0;
}


Measured memory_bytes: 2044
char s[199],*t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
a[199];main(i,n){for(;scanf("%d",&n),n;puts("")){
	for(i=0;i<n;i++)scanf("%d",a+i);
	scanf("%s",s);
	for(i=0;i<strlen(s);i++)putchar(t[(strchr(t,s[i])-t-a[i%n]+52)%52]);
}exit(0);}

Measured memory_bytes: 596
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	a, b, x := float64(sc.nextInt()), float64(sc.nextInt()), float64(sc.nextInt())
	rest := math.Pow(a, 2)*b - x
	if x >= math.Pow(a, 2)*b/2 {
		c := rest * 2 / math.Pow(a, 2)
		arctan := math.Atan2(c, a)
		fmt.Println(arctan * 180 / math.Pi)
	} else {
		c := x * 2 / (a * b)
		arctan := math.Atan2(b, c)
		fmt.Println(arctan * 180 / math.Pi)
	}
}


Measured memory_bytes: 640
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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


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

    long x, n;
    cin >> x >> n;
    vector<long> a(102, 0);
    for (long i = 0; i < n; i++) {
        long m;
        cin >> m;
        a[m] = 1;
    }
    
    long ans = 0;
    for (long i = 0; i <= 101; i++) {
        if (abs(ans - x) > abs(x - i) && a[i] == 0) ans = i;
    } 
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 3656
#include <string>
#include <stack>
#include <iostream>
using namespace std;

int main(){
	string word;
	stack<int> S;
	while(cin >> word){
		if(word=="+"){
			double a = S.top();
			S.pop();
			double b = S.top();
			S.pop();
			S.push(a+b);
		}else if(word=="-"){
			double a = S.top();
			S.pop();
			double b = S.top();
			S.pop();
			S.push(b-a);
		}else if(word=="*"){
			double a = S.top();
			S.pop();
			double b = S.top();
			S.pop();
			S.push(a*b);
		}else{
			double a = stoi(word);
			S.push(a);
		}
	}
	cout << S.top() << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, W;
  std::cin >> N >> W;
  std::vector<int> w(N+1), v(N+1);
  range(i, N) std::cin >> w[i+1] >> v[i+1];
  std::vector<std::vector<ll> > dp(N+1, std::vector<ll> (W+1));
  w[0] = 0;
  v[0] = 0;
  dp[0][0] = 0;

  ranges(i, 1, N+1){
    ranges(j, 0, W+1){
      if(w[i]>j) {
        dp[i][j] = dp[i-1][j];
      }else{
        dp[i][j]=max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
    }
  }
  std::cout << dp[N][W] << '\n';
  return 0;
}


Measured memory_bytes: 80256
main = do
    [n, m] <- map read . words <$> getLine
    let xs = [[x, y, n-x-y] | x <- [0..n], y <- [0..n-x], x*10000 + y*5000 + (n-x-y)*1000 == m]
    putStrLn $ if null xs then "-1 -1 -1" else unwords $ map show $ head xs


Measured memory_bytes: 1020
#include <stdio.h>
#include <queue>
 
using namespace std;
 
int n,inputed_order[41] = {0};
queue<int> Queue;
 
struct Node{
    Node(){
        left_child = right_child = -1;
    };
    int left_child,right_child;
};
 
void postORDER(Node order[],int id){
    if(order[id].left_child != -1) postORDER(order,order[id].left_child );
    if(order[id].right_child != -1) postORDER(order,order[id].right_child );
    Queue.push(id+1);
}
 
int findRoot(int inorder[],int left,int right){
    int root = inorder[left];
    for(int i = left+1; i <= right; i++){
        if(inputed_order[root] > inputed_order[inorder[i]]){
            root = inorder[i];
        }
    }
    return root;
}
 
void reconstruct(int inorder[],Node order[],int root,int left,int right){
    int root_index;
    for(root_index = left; inorder[root_index] != root; root_index++);
    if(left < root_index){
        int new_root = findRoot(inorder,left,root_index-1);
        order[root-1].left_child = new_root-1;
        if(left < root_index-1)  reconstruct(inorder,order,new_root,left,root_index-1);
    }
    if(root_index < right){
        int new_root = findRoot(inorder,root_index+1,right);
        order[root-1].right_child = new_root-1;
        if(root_index+1 < right) reconstruct(inorder,order,new_root,root_index+1,right);
    }
}
 
int main(){
    scanf("%d",&n);
    int preorder[n],inorder[n];
    Node order[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d",&preorder[i]);
        inputed_order[preorder[i]] = i;
    }
    for(int i = 0; i < n; i++){
        scanf("%d",&inorder[i]);
    }
 
    if(n == 1){
        printf("%d\n",preorder[0]);
    }else{
        reconstruct(inorder,order,preorder[0],0,n-1);
        postORDER(order,preorder[0]-1);
        while(!Queue.empty()){
            if(Queue.size() != 1){
                printf("%d ",Queue.front());
                Queue.pop();
            }else{
                printf("%d\n",Queue.front());
                Queue.pop();
            }
        }
    }
 
}


Measured memory_bytes: 2728
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),k=in(),q=in(),ans=INT_MAX;
    vec a(n);
    rep(i,n)a[i]=in();
    REP(y,a){
        vec v,u;
        rep(j,n){
            if(a[j]<y||j==n-1){
                if(j==n-1&a[n-1]>=y)v.pb(a[n-1]);
                if(v.size()>=k){
                    sort(All(v));
                    int x=0;
                    while(v.size()-x>=k){
                        u.pb(v[x]);
                        x++;
                    }
                }
                v.clear();
            }else v.pb(a[j]);
        }
        if(u.size()>=q){
            sort(All(u));
            ans=min(ans,u[q-1]-u[0]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int[] x=new int[3];
      for(int i=0; i<3; i++){
        x[i]=Integer.parseInt(sc.next());
      }

      Arrays.sort(x);
      System.out.println(x[0]+x[1]+x[2]*10);
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


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


int main() {
    string w;
    cin >> w;
    int x=w.size();
    vector<char> V(x);
    for(int i=0;i<x;i++){
        V.at(i)=w.at(i);
    }
    sort(V.begin(),V.end());
    char Ch=V.at(0);
    int cnt=1;
    bool ans=1;
    for(int i=1;i<x;i++){
        if(Ch==V.at(i)){
            cnt++;
        }
        else{
            if(cnt%2==1){
                ans=0;
                break;
            }
            else{
                Ch=V.at(i);
                cnt=1;//Chを初期化して、更にcntを1に。
            }
        }
    }

    if(x==1) ans=0;//例外パターン

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


Measured memory_bytes: 256
a, b, c = map(int, input().split())

if (a == 5 and b == 5 and c == 7) or \
   (a == 5 and b == 7 and c == 5) or \
   (a == 7 and b == 5 and c == 5):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
n,*a=map(int,open(0).read().split())
c=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[j]<a[minj]:
            minj=j
    if a[i]!=a[minj]:
        c+=1
    a[i],a[minj]=a[minj],a[i]
print(*a)
print(c)



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

int main() {
  ll n;
  cin >>n;
  vector<ll> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  bool ok = true;
  ll sum =0;
  ll a= 2*100000 +1;
  rep(i,n){
    a = min(a,v.at(i));
    if (a == v.at(i)){
      sum++;
    }
  }
  cout << sum << endl;
}

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

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

    while(true) {
        s.pop_back(); s.pop_back();
        n -= 2;
        string a = s.substr(0, n / 2), b = s.substr(n / 2);
        if(a == b) return cout << n << endl, 0;
    }
}

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

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

    string t = s;
    if (t.size() == 26) {
        if (next_permutation(t.begin(), t.end())) {
            for (int i = 0; i < t.size(); i++) {
                cout << t[i];
                if (s[i] != t[i]) return cout << endl, 0;
            }
        }
        else return cout << -1 << endl, 0;
    }

    int alf[26] = {};
    for (int x: s) alf[x - 'a']++;

    for (int i = 0; i < 26; i++) {
        if (!alf[i]) {
            char c = 'a' + i;
            return cout << s << c << endl, 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;


bool isATGC(const char& b)
{
    if (b == 'A' or b == 'T' or b == 'G' or b == 'C') {
        return true;
    } else {
        return false;
    }
}

int main()
{
    std::string S;
    std::cin >> S;
    int max = 0;
    for (size_t i = 0; i < S.size(); i++) {
        int j = 0;
        while (true) {
            if (i + j >= S.size()) {
                break;
            }
            if (isATGC(S.at(i + j))) {
                j++;
                if (max < j) {
                    max = j;
                }
            } else {
                break;
            }
        }
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = 5;
    let a: Vec<u32> = (0..n).map(|_| read()).collect();

    let mut last = 0;
    for i in &a {
        if (i + 9) % 10 <= (last + 9) % 10 {
            last = *i;
        }
    }
    let mut ans = 0;
    let mut did = false;
    for i in a {
        if i != last {
            ans += i;
        } else {
            if did {
               ans += i;
            } else {
                did = true;
            }
        }
        while ans % 10 != 0 {
            ans += 1
        }
    }

    println!("{}", ans + last);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
const int SIZEN = 100010;
typedef long long LL;
LL pw[100] = {0};
int cnt = 0;
int query(LL x){
	cnt++;
	printf("? %lld\n",x);
	fflush(stdout);
	char opt[10];
	scanf("%s",opt);
	return opt[0] == 'Y';
}
int main(){
	pw[0] = 1;
	for(int i = 1;i <= 10;i++)pw[i] = pw[i-1]*10;
	int bit = 0;
	for(int i = 0;i <= 9;i++){
		int now = query(pw[i]);
		if(now == false){bit = i;break;}
	}
	if(bit == 0){
		for(int i = 0;i <= 9;i++){
			int now = query(2*pw[i]);
			if(now == true){
				printf("! %d\n",pw[i]);
				return 0;
			}
		}
		printf("! 1\n");
		return 0;
	}
	else{
		LL ans = 0;//printf("bit = %d\n",bit);
		for(int i = bit;i >= 2;i--){
			int l = 1,r = 9,mid,tmp=0;
			while(l <= r){
				mid = (l+r)>>1;
				if(query(ans*10+mid))l = mid+1,tmp = mid;
				else r = mid-1;
			}
			ans = ans*10+tmp;
		}
		if(bit == 1){
			for(int i = 1;i <= 9;i++)if(query((LL)i*pw[1])){
				printf("! %d\n",i);
				return 0;	
			}	
			printf("! 1\n");
			return 0;
		}
		for(int i = 0;i <= 9;i++){
			if(query((ans*10LL+i)*10)){
				printf("! %d\n",ans*10+i);
				return 0;
			}
		}
		printf("! %d\n",ans*10);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if(sum <=21){
    cout << "win" << endl;
  }
  else{
    cout << "bust" << endl;
  }
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];

    int q;cin>>q;
    rep(i,0,q){
        int b,m,e;
        cin>>b>>m>>e;
        rotate(v.begin()+b,v.begin()+m,v.begin()+e);
    }
    rep(i,0,n){
        if(i)cout<<" ";cout<<v[i];
    }
    cout<<endl;
}



/*
1 2 3 4 5

6
*/



Measured memory_bytes: 3152
#include <stdio.h>
typedef long long int i64;

void swap(i64 *x, i64 *y){
    i64 tmp = *x;
    *x = *y;
    *y = tmp;
    return;
}

int main(void){
    i64 n, m;
    scanf("%lld %lld", &n, &m);
    if(n < m) swap(&n, &m);

    i64 ans;
    if(m == 1){
        if(n == 1) ans = 1;
        else ans = n - 2;
    }else ans = (n - 2) * (m - 2);
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
    int n;
    int n1;
    int n2;
    int num;
    int cnt;
    int ans = 0;
    int tmpans;
    int m;
    while (cin>>n>>n1>>n2,n!=0||n1!=0||n2!=0){
        vector<int> vec(n);
        m = 0;
        for(m = 0;m < n;m++){
            cin >> num;
            vec.at(m) = num;
        }
        ans = 0;
        while(n1<=n2){
            tmpans = vec.at(n1-1) - vec.at(n1);
            if (tmpans >= ans){
                ans = tmpans;
                cnt = n1;
            }
            n1 = n1 + 1;
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3096
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var lastT = 0
    var lastX = 0
    var lastY = 0
    var failed = false

    repeat(n) {
        val (t, x, y) = readLine()!!.split(" ").map{ it.toInt() }
        val diffT = t - lastT
        val diffX = Math.abs(lastX - x)
        val diffY = Math.abs(lastY - y)
        val rest = diffT - diffX - diffY

        if (rest < 0 || rest % 2 != 0) {
            failed = true
        }

        lastT = t
        lastX = x
        lastY = y
    }

    println(if (failed) "No" else "Yes")
}

Measured memory_bytes: 50288
using System;

public class Hello
{
    public static void Main()
    {
        var map = new int[10, 10];
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var t = line.Trim().Split(',');
            var x = int.Parse(t[0]);
            var y = int.Parse(t[1]);
            var s = int.Parse(t[2]);
            if (s == 1) putSmall(map, x, y);
            else if (s == 2) putMiddle(map, x, y);
            else putBig(map, x, y);
        }
        var zc = 0; var max = -1;
        foreach (var x in map)
        {
            if (x == 0) zc++;
            max = Math.Max(max, x);
        }
        Console.WriteLine(zc);
        Console.WriteLine(max);
    }
    public static void putSmall(int[,] map, int x, int y)
    {
        map[x, y] += 1;
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { -1, 0, 1, 0 };
        for (int i = 0; i < dx.Length; i++)
        {
            var nx = x + dx[i]; var ny = y + dy[i];
            if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) map[nx, ny] += 1;
        }
    }
    public static void putMiddle(int[,] map, int x, int y)
    {
        map[x, y] += 1;
        var dx = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
        var dy = new int[] { -1, -1, 0, 1, 1, 1, 0, -1 };
        for (int i = 0; i < dx.Length; i++)
        {
            var nx = x + dx[i]; var ny = y + dy[i];
            if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) map[nx, ny] += 1;
        }
    }
    public static void putBig(int[,] map, int x, int y)
    {
        map[x, y] += 1;
        var dx = new int[] { 0, 1, 1, 1, 0, -1, -1, -1, 0, 2, 0, -2 };
        var dy = new int[] { -1, -1, 0, 1, 1, 1, 0, -1, -2, 0, 2, 0 };
        for (int i = 0; i < dx.Length; i++)
        {
            var nx = x + dx[i]; var ny = y + dy[i];
            if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) map[nx, ny] += 1;
        }
    }
}

Measured memory_bytes: 9156
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(A: int, B: int):
    return [a for a in [1, 2, 3] if A != a != B][0]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(f'{solve(A, B)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75040
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

int N;

int line[100005];
bool is_valid[100005];
vector<int> vertical[100005];
int valid_x[100005];
int valid_x_sz;

int parent[100005];
int set_point_cnt[100005];
int set_line_cnt[100005];

int total_point_cnt[100005];

int find(int u)
{
	if (parent[u] == u) return u;
	return parent[u] = find(parent[u]);
}

void merge(int u, int v)
{
	u = find(u), v = find(v);

	if (u == v) return;
	if (u > v) swap(u, v);

	parent[v] = u;
}

int main()
{
	memset(line, -1, sizeof(line));

	scanf("%d", &N);

	for (int i = 0; i < N; ++i)
	{
		int _x, _y;

		scanf("%d %d", &_x, &_y);
		vertical[_x].push_back(_y);
		is_valid[_x] = true;
	}

	for (int i = 1; i <= 100000; ++i)
	{
		if (is_valid[i]) valid_x[valid_x_sz++] = i;	
	}

	for (int i = 0; i < valid_x_sz; ++i)
	{
		int cur_x = valid_x[i];
		
		parent[i] = i;
		set_point_cnt[i] = vertical[cur_x].size();
		set_line_cnt[i] = 1;

		for (auto &_y : vertical[cur_x])
		{
			if (line[_y] == -1) line[_y] = i;
			else merge(line[_y], i);
		}
	}

	for (int i = 1; i <= 100000; ++i)
	{
		if (line[i] == -1) continue;
		else
		{
			line[i] = find(line[i]);
			total_point_cnt[line[i]]++;
		}
	}

	long long ans = 0;

	for (int i = 0; i < valid_x_sz; ++i) ans += total_point_cnt[find(i)] - vertical[valid_x[i]].size();
	
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
using namespace std;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;



ll n;
ll a,b;
ll l[100010];
string YN[2];

ll flr(ll x){
    return max((ll)0,min((ll)(n+1),x));
}

int main(void){
    cin>>a>>b;
    long long ans=1;
    if(max(a,b)<=8)ans=0;
    
    YN[0]="Yay!";
    YN[1]=":(";
    cout<<YN[ans];
}

Measured memory_bytes: 256
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
left = 0
right = 0
for i in a:
    if i < x:
        left += 1
    elif i > x:
        right += 1
print(min(right, left))

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	int d;cin >> d;
	int t;cin >> t;
	int s;cin >> s;
	if((double)d/s <= t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3552
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n;
    vi a(3);
    cin >> n >> a[0] >> a[1] >> a[2];
    
    int tot = a[0] + a[1] + a[2];
    vi ans;
    
    if(tot == 0){
        puts("No");
        return;
    }
    if(tot == 1){
        int one;
        rep(i, 3) if(a[i] == 1) one = i;

        rep(i, n){
            int now;
            string s; cin >> s;

            if(s == "BC") now = 0;
            else if(s == "AC") now = 1;
            else now = 2;

            if(now == one){
                puts("No");
                return;
            }
            
            int tmp = 3 - one - now;
            ans.pb(tmp);
            one = tmp;
        }
    }
    else{
        vector<P> q;
        rep(i, n){
            string s; cin >> s;
            if(s == "BC") q.eb(1, 2);
            else if(s == "AC") q.eb(0, 2);
            else q.eb(0, 1);
        }
        auto add = [&](int x, int y){
            a[x]++;
            a[y]--;
            ans.pb(x);
        };
        q.eb(0, 1); // 番兵
        rep(i, n){
            int x = q[i].fi;
            int y = q[i].se;
            if(!a[x] && !a[y]){
                puts("No");
                return;
            }
            if(!a[x]) add(x, y);
            else if(!a[y]) add(y, x);
            else{
                int nx = q[i+1].fi;
                int ny = q[i+1].se;
                if(x == nx || x == ny){
                    add(x, y);
                }else{
                    add(y, x);
                }
            }
        }
    }
    
    cout << "Yes" << endl;
    for(auto i : ans) cout << char('A' + i) << endl;
	return;
}

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

Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int64_t N,P;
 cin>>N>>P;
 auto p=prime_factorize(P);
 int64_t ans=1;
 for(auto v:p){
   ans=ans*pow(v.first,v.second/N);
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int n = 4;
    int count = 0;
    rep(i, n){
        count = 0;
        rep(j, n){
            if(s[j] == s[i]){
                count++;
            }
        }
        if(count != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
const int MAXN = 1e5 + 5, mod = 1e9 + 7;
inline int addmod(int a, int b) { return ((a + b) % mod + mod) % mod; }
inline int mulmod(long long a, int b) { return ((a * b) % mod + mod) % mod; }

int n, m, x[MAXN], y[MAXN], suffix[MAXN];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%d", &x[i]);
	for(int i = 1; i <= m; i++) scanf("%d", &y[i]);

	int sum = 0;
	for(int i = n; i >= 1; i--) suffix[i] = addmod(suffix[i + 1], x[i]);
	for(int i = n; i >= 1; i--) sum = addmod(sum, suffix[i]);
	for(int i = 1; i <= n; i++) sum = addmod(sum, mod - mulmod(n - i + 1, x[i]));

	int sumy = 0;
	suffix[m + 1] = 0;
	for(int i = m; i >= 1; i--) suffix[i] = addmod(suffix[i + 1], y[i]);
	for(int i = m; i >= 1; i--) sumy = addmod(sumy, suffix[i]);
	for(int i = 1; i <= m; i++) sumy = addmod(sumy, mod - mulmod(m - i + 1, y[i]));

	printf("%d\n", mulmod(sum, sumy));
	return 0;
}

Measured memory_bytes: 1280