akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

class union_find:
	def __init__(self, num_node):
		self.parent = [-1] * num_node
		
	def root(self, node):
		if self.parent[node] < 0:
			return node
		else:
			self.parent[node] = self.root(self.parent[node])
			return self.parent[node]
			
	def size(self, node):
		return -self.parent[self.root(node)]
		
	def same(self, node1, node2):
		if self.root(node1) == self.root(node2):
			return True
		else:
			return False
			
	def unite(self, node1, node2):
		if self.same(node1, node2):
			return False
		else:
			siz1 = self.size(node1)
			siz2 = self.size(node2)
			if siz1 < siz2:	
				self.parent[self.root(node2)] -= siz1
				self.parent[self.root(node1)] = self.root(node2)
			else:
				self.parent[self.root(node1)] -= siz2
				self.parent[self.root(node2)] = self.root(node1)
			return True
	
def main():
	N, M = map(int, input().split())
	A = [0] * M
	B = [0] * M
	uf = union_find(N)
	
	for i in range(M):
		A[i], B[i] = map(int, input().split())
		A[i] -= 1
		B[i] -= 1
		
	unco = [0] * M
	unco[M - 1] = (N * (N - 1)) // 2
	
	for i in range(M - 1, 0, -1):
		tmp1 = uf.size(A[i])
		if uf.unite(A[i], B[i]):
			tmp2 = uf.size(A[i])
			unco[i - 1] = unco[i] - (tmp2 - tmp1) * tmp1
		else:
			unco[i - 1] = unco[i]
	
	for i in range(M):
		print(unco[i])
		
main()

Measured memory_bytes: 114652
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    FasterIO
    vector <int> v ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << v[n-1] << endl;

    return 0;
}


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    if (w == 1) {
        cout << 1 << endl;
        return 0;
    }
    k--;
    long t[h + 1][w];
    fill(t[0] + 1, t[0] + w, 0);
    t[0][0] = 1;
    for (int i = 1; i <= h; i++) {
        fill(t[i], t[i] + w, 0);
    }
    for (int i = 1; i <= h; i++) {
        for (int k = 0; k < (2 << (w - 2)); k++) {
            bool flag = true;
            for (int l = 1; l < w - 1; l++) {
                if ((k & (1 << l)) && k & (1 << (l - 1))) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                if (k & 1) {
                    t[i][0] = (t[i][0] + t[i - 1][1]) % MOD;
                } else {
                    t[i][0] = (t[i][0] + t[i - 1][0]) % MOD;
                }
            }
        }
        for (int j = 1; j < w - 1; j++) {
            for (int k = 0; k < (2 << (w - 2)); k++) {
                bool flag = true;
                for (int l = 1; l < w - 1; l++) {
                    if ((k & (1 << l)) && k & (1 << (l - 1))) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    if (k & (1 << (j - 1))) {
                        t[i][j] = (t[i][j] + t[i - 1][j - 1]) % MOD;
                    } else if (k & (1 << j)) {
                        t[i][j] = (t[i][j] + t[i - 1][j + 1]) % MOD;
                    } else {
                        t[i][j] = (t[i][j] + t[i - 1][j]) % MOD;
                    }
                }
            }
        }
        for (int k = 0; k < (2 << (w - 2)); k++) {
            bool flag = true;
            for (int l = 1; l < w - 1; l++) {
                if ((k & (1 << l)) && k & (1 << (l - 1))) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                if (k & (1 << (w - 2))) {
                    t[i][w - 1] = (t[i][w - 1] + t[i - 1][w - 2]) % MOD;
                } else {
                    t[i][w - 1] = (t[i][w - 1] + t[i - 1][w - 1]) % MOD;
                }
            }
        }
    }
    cout << t[h][k] << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  vector<string> s(N);
  rep(i,N) {
    cin >> s[i];
  }

  int cnt = 1;
  sort(s.begin(), s.end());
  rep(i,N-1) {
    if (s[i] != s[i+1]) cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	cio;
	lli n,m,k,ans=0,i;
	double sum=0,dd;
	cin>>n>>m;
	dd=4*m;
	lli a[n];
	rep(i,0,n){
		cin>>a[i];
		sum+=a[i];
	}
	dd=sum/dd;
	k=ceil(dd);
	rep(i,0,n){
		if(a[i]>=k)
		ans++;
	}
	if(ans>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3756
#include <cstdio>


int n, sum, p[3];
bool f;

int main(){
    while(scanf("%d", &n) != EOF){
        if(n == 0) break;

        for(int i = 0; i < n; i++){
            f = false;
            scanf("%d %d %d", &p[0], &p[1], &p[2]);
            sum = p[0] + p[1] + p[2];

            for(int j = 0; j < 3; j++)
            if(p[j] == 100){
                printf("A\n");
                f = true;
                break;
            }

            if(f) continue;
            if(p[0] + p[1] >= 180){
                printf("A\n");
                continue;
            }
            if(sum >= 240){
                printf("A\n");
                continue;
            }
            if(sum >= 210){
                printf("B\n");
                continue;
            }
            if(sum >= 150 && (p[0] >= 80 || p[1] >= 80)){
                printf("B\n");
                continue;
            }
            printf("C\n");

        }
    }


    return 0;
}

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

int main() {
  long long int K = 0;
  long long int N = 0;
  long long int mx = 0;
  cin >> K >> N;
  vector <long long int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  for (int i = 0; i < N - 1; i++) mx =max(A.at(i + 1) - A.at(i), mx);
  mx = max(mx, A.at(0) + K - A.at(N-1));
  cout << K - mx;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
long long a,b,r,A;
int main()
{
	cin>>a>>b;
	if(a==b)
	{
		cout<<1;
		return 0;
	}
	for(int i=59;i>=0;i--)
		if((a>>i)!=(b>>i))
			r=i,i=0;
		else if(a>>i&1)
			a^=((long long)1<<i),b^=((long long)1<<i);
	for(int i=0;i<r;i++)
		if(b>>i&1)
			A=((long long)2<<i)-1;
	cout<<((long long)2<<r)+A-a-max(A+1,a)+1;
	return 0;
}

Measured memory_bytes: 256
'use strict'

const INF = 900719925474099;
function mapint(temp){
  return temp.split(' ').map((v)=>parseInt(v));
}

function Main(input){
  let temp = input.trim();
  let n = mapint(temp)[0];
  let d = mapint(temp)[1];
  let ans = Math.ceil( n/(2*d+1) );
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N, D;
ll x[100000], y[100000];
ll d[2000][2000];
ll s[2001][2001], ss[2001][2001], t[2001][2001], tt[2001][2001];
bool check(ll x, ll y, ll c){
    bool t=true;
    if(ss[x+c][y+c]+ss[x][y]-ss[x+c][y]-ss[x][y+c]!=ss[D][D]+ss[0][0]-ss[0][D]-ss[D][0]) t=false;
    if(tt[x+D][y+D]+tt[x+c][y+c]-tt[x+D][y+c]-tt[x+c][y+D]!=(D-c)*(D-c)) t=false;
    return t;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>D;
    rep(i,0,N){
        cin>>x[i]>>y[i];
        d[x[i]%D][y[i]%D]++;
        d[x[i]%D+D][y[i]%D]++;
        d[x[i]%D][y[i]%D+D]++;
        d[x[i]%D+D][y[i]%D+D]++;
    }
    ll T=0;
    rep(i,0,D){
        T=max(T,*max_element(d[i], d[i]+D));
    }
    T=ll(sqrt(T-1));
    ll ans=D*T;
    rep(i,0,2*D){
        rep(j,0,2*D){
            if(d[i][j]>T*(T+1)){
                s[i][j+1]=s[i][j]+1;
            }
            else{
                s[i][j+1]=s[i][j];
            }
            if(d[i][j]<=T*T){
                t[i][j+1]=t[i][j]+1;
            }
            else{
                t[i][j+1]=t[i][j];
            }
        }
    }
    rep(i,0,2*D){
        rep(j,1,2*D){
            ss[i+1][j]=ss[i][j]+s[i][j];
            tt[i+1][j]=tt[i][j]+t[i][j];
        }
    }
    ll ng=-1, ok=D;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        bool t=false;
        rep(i,0,D){
            rep(j,0,D){
                if(check(i,j,mid)) t=true;
            }
        }
        if(t) ok=mid;
        else ng=mid;
    }
    cout <<ans+ok-1<<"\n";
}

Measured memory_bytes: 158208
#include <iostream>

using namespace std;

int N,M;
const int MAX_N = 100010;
const int INF = 1 << 20;
int A[MAX_N];
int Left[MAX_N];
int Right[MAX_N];
int main(){
  cin >> N >> M;
  int result = 0;

  for (int i = 0; i < M; i++){
    int x;
    cin >> x;
    x--;
    A[x]++;
  }
  int tmp = INF;
  for (int i = 0; i < N; i++){

    if (A[i]){
      tmp = 0;
    }
    Left[i] = tmp;    
    tmp++;
  }
  tmp = INF;
  for (int i = N - 1; i >= 0; i--){
   
    if (A[i]){
      tmp = 0;
    }
    Right[i] = tmp;    
    tmp++;
  }
  int res = 0;
  for (int i = 0; i < N; i++){
    res = max(res, min(Left[i], Right[i]));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4016
a, b = map(int, input().split())
s = input().split("-")

def check(a, b, s):
    if not len(s) == 2:
        return "No"

    former, latter = s[0], s[1]
    if not(len(former) == a and len(latter) == b):
        return "No"

    try:
        num_former = int(former)
        num_latter = int(latter)
        return "Yes"
    except ValueError:
        return "No"

print(check(a, b, s))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  string s,t;
  cin>>n>>s>>t;
  for(in o=n;o>=0;--o){
    if(s.substr(n-o)==t.substr(0,o)){
      cout<<2*n-o<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
/*
𝓐𝓾𝓽𝓱𝓸𝓻:-

╭━━━┳━━━┳╮╱╭┳━━━┳━━━┳━━╮╭╮╱╭╮
┃╭━╮┃╭━╮┃┃╱┃┃╭━╮┃╭━╮┃╭╮┃┃┃╱┃┃  
┃╰━━┫┃╱┃┃┃╱┃┃╰━╯┃┃╱┃┃╰╯╰┫╰━╯┃
╰━━╮┃╰━╯┃┃╱┃┃╭╮╭┫╰━╯┃╭━╮┃╭━╮┃
┃╰━╯┃╭━╮┃╰━╯┃┃┃╰┫╭━╮┃╰━╯┃┃╱┃┃
╰━━━┻╯╱╰┻━━━┻╯╰━┻╯╱╰┻━━━┻╯╱╰╯  

*/

#include <bits/stdc++.h> 
using namespace std; 
#define int long long int
#define REDBULL ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl "\n"


int32_t main()
{
	REDBULL
	int a,b;
	cin>>a>>b;
	int ans=0;
	if(a<=3)
	{
		if(a==3)
		ans+=100000;
		if(a==2)
			ans+=200000;
		if(a==1)
			ans+=300000;
	}

	if(b<=3)
	{

		if(b==3)
		ans+=100000;
		if(b==2)
			ans+=200000;
		if(b==1)
			ans+=300000;
	}
	if(a==1&&b==1)
		ans+=400000;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

ll W, H, x, y;

int main() {
    cin >> W >> H >> x >> y;
    cout << double(W) * double(H) / 2 << " " <<  ((2*x==W) && (2*y==H)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  rep(i, s.length() - 1) {
    if (s[i] == 'A')
      if (s[i + 1] == 'C') {
        cout << "Yes" << endl;
        return 0;
      }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define int long long int
const int mod = 1000000007;
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;


signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    double d, t, s;
    cin>>d>>t>>s;
    if(s*t >= d ){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int x, y;cin >> x >> y; x--; y--;
  string result;
  int l[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  if ( l[x] == l[y] ) result = "Yes";
  else result = "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
import bisect
import sys
import logging
import heapq

#logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	n = int(input())
	d = defaultdict(int)
	for _ in range(n):
		t = int(input())
		if(d[t] == 0):
			d[t] += 1
		else:
			d[t] -= 1
	ans = 0
	for v in d.values():
		ans += v
	print(ans)

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 81752
s = input()
if len(s)%2==0:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2:]
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
s2 = s2[::-1]
num=0
for i in range(len(s1)):
    if s1[i]!=s2[i]:
        num+=1
print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;

int main() {
  int N, M;
  cin >> N >> M;
  vector<P> keys;
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    int bitSum = 0;
    rep(j, B) {
      int C;
      cin >> C;
      --C;
      bitSum += 1<<C;
    }
    keys.emplace_back(A, bitSum);
  }
  vector<int> dp(1<<N, INF); // dp.back()がans
  dp[0] = 0;
  for (int i = 0; i < 1<<N; i++) {
    for (auto p : keys) {
      int newPrice = dp[i] + p.first;
      int newBit = i | p.second;
      dp[newBit] = min(dp[newBit], newPrice);
    }
  }
  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans << '\n';
  return 0;
}


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

int main() {
 int n;
 cin >> n;
 vector<int> h(n);
 rep(i,n) cin >> h.at(i);
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
 vector<int> a(n-1);
 rep(i,n-1){
   a.at(i) = h.at(i)-h.at(i+1);
 }
 vector<int> b;
 
 int x = 0;
 rep(i,n-1){
   if(a.at(i) >= 0){
     x++;
     if(i == n-2) b.push_back(x);
   }
   else{
     b.push_back(x);
     x = 0;
   }
 }
 
 sort(b.begin(),b.end());
 cout << b.back() << endl;
}

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

int main() {
  int A[3][3], N;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> A[i][j];
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; ++i)
    cin >> b[i];

  bool A2[3][3] = {};
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k)
        if (b[i] == A[j][k])
          A2[j][k] = true;

  bool flag = false;
  for (int i = 0; i < 3; ++i)
    if ((A2[i][0] && A2[i][1] && A2[i][2]) ||
        (A2[0][i] && A2[1][i] && A2[2][i]))
      flag = true;
  if ((A2[0][0] && A2[1][1] && A2[2][2]) || (A2[0][2] && A2[1][1] && A2[2][0]))
    flag = true;

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

Measured memory_bytes: 256
import numpy as np
import math
X,Y = map(int,input().split())


c1 = (2*Y-X)
if c1%3!=0:
  print(0)

else:
  def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
  c1 = c1//3
  c2 = Y-2*c1
  c3 = c1+c2
  mod = 10**9+7
  g1 = [1, 1]
  g2 = [1, 1]
  inverse = [0, 1]
  for i in range( 2,c3+1):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

  a = cmb(c3,c1,mod)

  print(a)

Measured memory_bytes: 91308
#include <iostream>
#include <vector>
#include <cmath>
int N;
std::vector<double> x, y;
int main(){
    std::cin >> N;
    x.resize(N);
    y.resize(N);
    for(int i = 0; i < N; i++) std::cin >> x[i] >> y[i];
    double ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i != j) ans += std::sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    ans = ans / N;
    printf("%.10lf\n", ans);
}

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

int main () {
  int d, g;
  cin >> d >> g;
  vector<pair<int,int>> p(d);
  for (int i = 0; i < d; i++)
    cin >> p[i].first >> p[i].second;
  
  vector<int> v(d);
  iota (v.begin(), v.end(), 0);
  int ans = 1000;
  do {
    int sum = 0, c = 0;
    for (int i = 0; i < d; i++) {
      int x = v[i];
      int i100 = 100 * (x+1);
      int pi100 = p[x].first * i100;
      if (g > sum + pi100 + p[x].second) {
        sum += pi100 + p[x].second;
        c += p[x].first;
      }
      else if (sum + pi100 <= g &&
               g <= sum + pi100 + p[x].second) {
        c += p[x].first;
        break;
      }
      else {
        c += (g - sum + i100-1) / i100;
        break;
      }
    }
    ans = min(ans, c);
  }
  while (next_permutation(v.begin(), v.end()));
  
  cout << ans << endl;
}


Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 3000050;
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
	cout<<s[i];
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
P p[200005];
ll d;
ll a,b;
ll m=1000000000000000000,M=-1000000000000000000;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i].first>>p[i].second;
        a=p[i].first+p[i].second;
        b=p[i].first-p[i].second;
        p[i].first=a;
        p[i].second=b;
    }
    sort(p,p+n);
    d=abs(p[n-1].first-p[0].first);
    for(int i=0;i<n;i++){
        m=min(m,p[i].second);
        M=max(M,p[i].second);
    }
    d=max(M-m,d);
    cout<<abs(d)<<endl;
    
}


Measured memory_bytes: 6764
n=int(input())
a=[int(i) for i in input().split()]
s=0
m=1000
l=0
for i in range(1,n):
  if a[i-1]<=a[i]:
    l=i
if l==0:
  print(1000)
  exit()
if l<n-1:
  for i in range(l):
    if a[i]<a[i+1]:
      s+=m//a[i]
      m-=a[i]*(m//a[i])
    if a[i]>a[i+1]:
      m+=s*a[i]
      s=0
  m+=s*a[l]
else:
  for i in range(n-1):
    if a[i]<a[i+1]:
      s+=m//a[i]
      m-=a[i]*(m//a[i])
    if a[i]>a[i+1]:
      m+=s*a[i]
      s=0
  m+=s*a[l]
print(m)

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int A, B;
    cin >> A >> B;
    int res = 0;
    FOR(i, A, B + 1) {
        int a[5];
        a[0] = i % 10;
        int n = i;
        FOR(j, 1, 5) {
            n /= 10;
            a[j] = n % 10;
        }
        if(a[0] == a[4] && a[1] == a[3]) ++res;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(abs(a-c)<=d || ((abs(a-b)<=d) && (abs(b-c)<=d))){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
   return 0;
}

Measured memory_bytes: 128
import heapq

n,m,s=map(int,input().split())
limit=2500
s=min(s,limit)
path=[[] for _ in range(n+1)]
coin=[(0,0)]
time=[[float("inf") for _ in range(limit+1)] for _ in range(n+1)]
queue=[]

for i in range(m):
    u,v,a,b=map(int,input().split())
    path[u].append((v,a,b))
    path[v].append((u,a,b))

for i in range(n):
    c,d=map(int,input().split())
    coin.append((c,d))

time[1][s]=0
heapq.heappush(queue,(0,1,s))

while len(queue)!=0:
    t,v,c=heapq.heappop(queue)
    for nv,na,nb in path[v]:
        if na>c:
            continue
        elif time[nv][c-na]<=t+nb:
            continue
        else:
            time[nv][c-na]=t+nb
            heapq.heappush(queue,(t+nb,nv,c-na))

    nc=min(c+coin[v][0],limit)
    nt=t+coin[v][1]
    if time[v][nc]<=nt:
        continue
    else:
        time[v][nc]=nt
        heapq.heappush(queue,(nt,v,nc))
    
for i in range(2,n+1):
    print(min(time[i]))


Measured memory_bytes: 27844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn = 100100;
int n;
vector<int> mp[maxn];
int sg[maxn];
void dfs(int u, int f){
    for(int i = 0; i < mp[u].size(); ++i)if(mp[u][i] != f){
        dfs(mp[u][i], u);
        sg[u] ^= sg[mp[u][i]] + 1;
    }
    return ;
}
int main(){
    scanf("%d", &n);
    for(int i = 2; i <= n; ++i){
        int a, b;
        scanf("%d%d", &a, &b);
        mp[a].push_back(b);
        mp[b].push_back(a);
    }
    dfs(1,1);
    //for(int i = 1; i <= n; ++i)printf("sg[%d] = %d\n", i, sg[i]);
    if(sg[1])cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 12416
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(len(s_list)):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            if len(zero_list) > 0:
                zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
                if zero_p <= 0:
                    ttt = h + abs(x_ - x) + abs(y_ - y)
                    ans = str(x) + " " + str(y) + " " + str(ttt)
                    break
            else:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
                
print(ans)

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

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

int main(){
	int n;
	cin>>n;
	long long sum=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			for (int k=1;k<=n;k++){
				int res=gcd(i,j);
				int ans=gcd(k,res);
				sum+=ans;
			}	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
/*================================================
# ~  file:C.cpp
# ~~ date:2020-03-14
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;

long double a,b,c;

int main(){
 ios::sync_with_stdio(false);
  cin>>a>>b>>c;
    c=c-a-b;
    if(c<=0) cout<<"No"<<endl;
    else{
	c=c*c/4;
	if(a*b<c) cout<<"Yes"<<endl;
	else  cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll x=b,y=a;
  x+=(n-1)*a;
  y+=(n-1)*b;
  if(a>b) pr(0);
  else pr(max(y-x+1,0LL));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
	int n,l;
	cin>>n>>l;
	string s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++){
		cout<<s[i];
	}
	cout<<endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    ll price[4];
    rep(i,4){
        cin >> price[i];
    }
    price[0] *= 4;  price[1] *= 2;
    
    ll price_1L(min({price[0],price[1],price[2]}));

    ll n;   cin >> n;

    if(price_1L*2<=price[3]){
        cout << n*price_1L << endl;
    }else if(n%2==0){
        cout << n/2*price[3] << endl;
    }else{
        cout << n/2*price[3]+price_1L << endl;
    }


    return 0;
}

Measured memory_bytes: 3644
def c_show(graph,x):
    seen = set()
    nodes = set([x])
    while nodes:
        cur = nodes.pop()
        seen.add(cur)
        nodes |= set(graph[cur]) - seen
    return seen

def c_cnt(graph,n): 
    done = set()
    cnt = 0
    for x in range(n):
        if x not in done:
            done |= c_show(graph,x)
            cnt += 1
    return cnt
  
n,m = map(int, input().split())
g = [list() for _ in range(n)]
for _ in range(m):
    x,y,z = map(int, input().split())
    g[x-1].append(y-1)
    g[y-1].append(x-1)
print(c_cnt(g,n))

Measured memory_bytes: 33004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String a = in.next();
		String b = in.next();
		String c = in.next();

		int o = 0;
		for (int i = 0; i < n; i++) {
			char aa = a.charAt(i);
			char bb = b.charAt(i);
			char cc = c.charAt(i);
			if (aa == bb && bb == cc && cc == aa) {

			} else if (aa == bb || bb == cc || cc == aa) {
				o++;
			} else {
				o += 2;
			}
		}
		in.close();
		System.out.println(o);
	}

}


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

int main(){

    int n;
    cin >> n;

    vector<int> ab[n];
    vector<pair<int,int>> pp(n-1);
    rep(i,n-1){
        int s,t;
        cin >> s >> t;
        s--;t--;
        ab[s].push_back(t);
        ab[t].push_back(s);
        pp[i].first=s;
        pp[i].second=t;
    }
    int r=0;
    rep(i,n){
        if(ab[r].size()<ab[i].size()){
            r=i;
        }
    }

    vector<int> c(n);

    rep(i,n){
        cin >> c[i];
    }
    sort(c.begin(),c.end(),greater<int>());

    deque<int> q;
    vector<int> cc(n);
    q.push_back(r);
    int pc=0;
    vector<bool> vis(n,true);
    vis[r]=false;

    while(q.size()){
        int tn=q.front();q.pop_front();
        cc[tn]=c[pc];
        pc++;
        for(int i=0;i<ab[tn].size();i++){
            if(vis[ab[tn][i]]){
                q.push_back(ab[tn][i]);
                vis[ab[tn][i]]=false;
            }
        }
    }

    int ans=0;
    rep(i,pp.size()){
        ans+=min(cc[pp[i].first],cc[pp[i].second]);
    }

    cout << ans << endl;
    rep(i,n){
        cout << cc[i] << " ";
    }cout << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N; 
  for (int i = 0; i < N ; i++) {
    string S;
    cin >> S;
    if(S== "Y"){
      cout << "Four" << endl;
    break;
    }
    if(i== N - 1){
      cout << "Three" << endl;
  }
  }
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int h[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    int mn = -1e9;
    for(int i = 1; i <= n; i++){
        if(h[i - 1] > h[i]){
            puts("No");
            return 0;
        }
        if(h[i - 1] <= h[i] - 1 && h[i] - 1 >= 1)
            h[i] = h[i] - 1;
    }
    puts("Yes");
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int l;
    string s;
    cin >> l;
    cin >> s;
    bool able = true;
    if (l % 2 == 0) {
        for (int i = 0; i < l / 2; ++i) {
            if (s[i] != s[i + l / 2]) {
                able = false;
            }
        }
    } else {
        able = false;
    }
    if (able) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * (n+1) for i in range(n+1)]
A = []
for i in range(n):
    A.append([a[i], i])
A.sort(reverse=True)
for i in range(1, n+1):
    for j in range(i+1):
        if j == 0:
            dp[j][i-j] = dp[j][i-j-1] + A[i-1][0] * abs(n-i-A[i-1][1])
        elif j == i:
            dp[j][i-j] = dp[j-1][i-j] + A[i-1][0] * abs(A[i-1][1]-i+1)
        else:
            dp[j][i-j] = max(dp[j][i-j-1] + A[i-1][0] * abs(n-i+j-A[i-1][1]), dp[j-1][i-j] + A[i-1][0] * abs(A[i-1][1]-j+1))
ans = 0
for i in range(n+1):
    ans = max(ans, dp[i][n-i])
print(ans)

Measured memory_bytes: 100720
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            var success = a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0;

            Console.Write(success ? "Possible" : "Impossible");
        }
    }
}

Measured memory_bytes: 13140
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
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 conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (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){
    ll n;
    cin >> n;
    bool ok = false;
    ll idx = 0;
    for(ll i = 0; i <= 100100; i++){
        if(n == i * (i - 1) / 2){
            ok = true;
            idx = i;
            break;
        }
    }

    if(!ok){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    cout << idx << endl;

    vector<pair<ll,ll>> e;
    rep(i, idx){
        for(ll j = 0; j < i; j++){
            e.push_back({i, j});
        }
    }

    vector<vector<ll>> ans(idx);

    rep(i, e.size()){
        ans[e[i].first].push_back(i + 1);
        ans[e[i].second].push_back(i + 1);
    }

    rep(i, idx){
        cout << ans[i].size() << " ";
        rep(j, ans[i].size()){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}


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

int main() {
	
	int n,k;
	cin >> n >> k;
	vector<int> a(n),b(n);
	int j{};
	for(int i=0; i<n; i++) a.at(i) = i+1;
	for(int i=0; i<n; i++){
		int j=0;
		while(1){
			if(a.at(i)>=k){
				b.at(i) = j;
				break;
			}
			a.at(i) *= 2;
			j++;
		}
	}
	double ans{};
	for(int i=0; i<n; i++){
		ans += pow(0.5,b.at(i));
	}
	cout << fixed << setprecision(10);
	cout << ans/n << endl;
	
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i,n) cin >> t[i];
  int m;
  cin >> m;
  vector<pii> px(m);
  rep(i,m) cin >> px[i].first >> px[i].second;
  rep(i,m) {
    int temp = px[i].second;
    rep(j,n) {
      if (px[i].first - 1 == j) continue;
      temp += t[j];
    }
    cout << temp << endl;
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3612
a, b, x = map(int, input().split())
array = [int(x) for x in input().split()]

tmp = 0
tmp2 = 0
for i in range(1, x+1):
    if i in array:
        tmp +=1

for j in range(x, a+x):
    if j in array:
        tmp2 += 1

print(min(tmp, tmp2))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] str = sc.next().toCharArray();
		int mod = 1_000_000_007;
		long modCount[][] = new long[str.length][13];

		int geta = 1;
		for(int i = str.length - 1; i >= 0; i--){
//			System.out.println("i = "+i);
			if(str[i] == '?'){
				for(int j = 0; j <= 9; j++){
					int tmp = j*geta % 13;

					if(i < str.length - 1){
						for(int k = 0; k < 13; k++){
							modCount[i][(tmp + k) % 13] += modCount[i + 1][k];
							modCount[i][(tmp + k) % 13] %= mod;
						}
					}
					else {
						modCount[i][j] = 1;
					}
				}
			}
			else {
				int num = str[i] - '0';
				int tmp = num*geta%13;

				if(i == str.length - 1){
					modCount[i][tmp] = 1;
				}
				else {
					for(int j = 0; j < 13; j++){
						modCount[i][(tmp + j)%13] += modCount[i + 1][j];
						modCount[i][(tmp + j)%13] %= mod;
					}
				}
			}

			geta *= 10;
			geta %= 13;
//			for(int j = 0; j < 13; j++){
//				System.out.print(modCount[i][j]+" ");
//			}
//			System.out.println();
		}

		System.out.println(modCount[0][5]);

	}

}


Measured memory_bytes: 42448
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 1050;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,a[d5],b[d5],c[d5][20];
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i]>>b[i];
        for(int j=1;j<=b[i];j++)cin>>c[i][j];
    }
    int dp[5000];
    fill(dp,dp+5000,inf);
    dp[0]=0;
    for(int i=1;i<=m;i++){
        int now=0;
        for(int j=1;j<=b[i];j++){
            now|=(1<<(c[i][j]-1));
        }
        for(int bit=0;bit<(1<<n);bit++){
            dp[bit|now]=min(dp[bit|now],dp[bit]+a[i]);
        }
    }
    if(dp[(1<<n)-1]==inf)dp[(1<<n)-1]=-1;
    //for(int i=0;i<100;i++)cout<<dp[i]<<' ';
    cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define pf		 push_front
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int32_t main()
{	pre();
	//case
	{	int n, k;
		cin >> n >> k;
		int a[n];
		for (int i = 0; i < n; i++)
			cin >> a[i];
		int dp [k + 1];
		dp[0] = 1;
		for (int i = 1; i <= k; i++)
		{	int tp = 1;
			for (int j = 0; j < n; j++)
			{	if (a[j] > i)
					continue;
				int vl = dp[i - a[j]] ^ 1;
				tp *= vl;
			}
			dp[i] = tp;
		}
		if (dp[k] == 1)
			cout << "Second";
		else
			cout << "First";
	}
	return 0;
}

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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , int> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 1e9+7;
const int MAX = 1e6+5;
const db eps = 1e-13;

vi v;
int n , k;

bool dp[MAX];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(11)<<fixed;
    cin>>n>>k;
    v = vi(n+1);
    int mn = INT_MAX;
    for( int i = 1; i <= n ; i++ ) {
        cin>>v[i];
        mn = min( mn , v[i] );
    }
    for( int i = mn ; i <= k ; i++ ) {

        for( int j = 1 ; j <= n ; j++ )
            if( i-v[j] >= 0 )
                dp[i] |= !dp[i-v[j]];

//        cout<<dp[i]<<" "<<i<<"\n";
    }

    cout<<( dp[k] ? "First\n" : "Second\n" );
}
/*
1 100000
1
*/


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n, m = [int(item) for item in input().split()]
if m % 2 != 0:
    print(-1)
    exit()
visited_e = [False] * m
visited_v = [False] * n
edge = [[] for _ in range(n)]
for i in range(m):
    a, b = [int(item) for item in input().split()]
    a -= 1; b -= 1
    edge[a].append([b, i])
    edge[b].append([a, i])
 
ans = []
def dfs(prev, n):
    if visited_v[n]:
        return 1
    visited_v[n] = True
    child_num = 0
    for v, index in edge[n]:
        if visited_e[index]:
            continue
        visited_e[index] = True
        if dfs(n, v) == 1:
            child_num += 1
            ans.append([n+1, v+1])
    if child_num % 2 == 0:
        return 1
    else:
        ans.append([n+1, prev+1])
        return 0
 
dfs(-1, 0)
print("\n".join([str(f) + " " + str(t) for f, t in ans]))

Measured memory_bytes: 140660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

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

long double x[8],y[8],d[8][8],s=0.0,c=0.0;

int main(void){
	int n,i,j;

	cin >> n;
	vector<int> v(n);
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i];
		for(j=0; j<n; ++j){
			d[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
			d[j][i] = d[i][j];
		}
	}
	iota(v.begin(),v.end(),0);
	do{
		for(i=1; i<n; ++i){
			s += d[v[i-1]][v[i]];
		}
		c += 1.0;
	}while(next_permutation(v.begin(),v.end()));
	s /= c;
	cout << fixed << setprecision(50) << s << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)
if list(s) != list(reversed(s)):
    print('No')
    exit()
if list(s[:(l - 1) // 2]) != list(reversed(s[:(l - 1) // 2])):
    print('No')
    exit()
if list(s[(l + 3) // 2 -1:l]) != list(reversed(s[(l + 3) // 2 -1:l])):
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064