akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
	int n, p[105] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 100; i >= 0; i--) {
		int ct = 0;
		for (int j = 0; j < n; j++) if (p[j] >= i) ct++;
		if (ct >= i) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3100
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

const double pi = acos(-1);

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

// 角度 -> ラジアン
double torad(double deg){
    return 1. * deg * pi / 180;
}

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

    int a, b, h, m; cin>>a>>b>>h>>m;

    double H = 30 * h + 0.5 * m;
    double M = 6 * m;

    double theta = abs(H - M);

    double ans = sqrt(a * a + b * b - 2 * a * b * cos(torad(theta)));

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

    return 0;
}

Measured memory_bytes: 4172
#include<stdio.h>

int func(int n){
    int s=0, f=0, t=0;
    while(n>0){
        if(n%10==7){
            s++;
        }else if(n%10==5){
            f++;
        }else if(n%10==3){
            t++;
        }else{
            return 0;
        }
        n = n/10;
    }
    if(s>0 && f>0 && t>0){
        return 1;
    }else{
        return 0;
    }
}

int count(long long int n, int max){
    int dst = 0;
    if(n > max){
        return 0;
    }
    if(func(n)){
        dst++;
    }
    dst += count(n*10+3, max);
    dst += count(n*10+5, max);
    dst += count(n*10+7, max);
    return dst;
}

int main(){
    int n;
    scanf("%d", &n);
    printf("%d", count(0LL,n));

    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		
		
		int start = -1;
		int end = -1;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'A' && start == -1){
				start = i;
			}
			if(s.charAt(i) == 'Z' && start != -1){
				end = i;
			}
		}
		System.out.println(end-start+1);
	}

}


Measured memory_bytes: 28116
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String tmp = scan.nextLine();
	  int n = Integer.parseInt(tmp.split(" ")[0]);
		int m = Integer.parseInt(tmp.split(" ")[1]);
		int l = Integer.parseInt(tmp.split(" ")[2]);
		long[][] A = new long[n][m];
		long[][] B = new long[m][l];
		long[][] rs = new long[n][l];

		for (int i = 0; i < n; i++) {
			String num = scan.nextLine();
			for (int j = 0; j < m; j++) {
				int tmpLine = Integer.parseInt(num.split(" ")[j]);
				A[i][j] = tmpLine;
			}
		}

		for (int i = 0; i < m; i++) {
			String num = scan.nextLine();
			for (int j = 0; j < l; j++) {
				int tmpLine = Integer.parseInt(num.split(" ")[j]);
				B[i][j] = tmpLine;
			}
		}

		long sum = 0;
		int cnt = 0;

		while (cnt < n) {
			for (int i = 0; i < l; i++) {
				for (int j = 0; j < m; j++) {
					sum += A[cnt][j] * B[j][i];
				}
				rs[cnt][i] = sum;
				sum = 0;
			}
			cnt++;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				System.out.print(rs[i][j]);
				if(j != l - 1){
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
	}
}



Measured memory_bytes: 97720
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    string s;
    cin >> s;
    int a=0,b=0,ans=0;
    rep(i,s.size()){
        if (s.at(i)=='0'){
            a++;
            if (b>0) {
                a--;
                b--;
                ans+=2;
            }
        }
        else{
            b++;
            if (a>0){
                a--;
                b--;
                ans+=2;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
   int S;
   cin >> S;
   int s1 = S / 100;
   int s2 = (S - (s1 * 100)) / 10;
   int s3 = S % 10;
   cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(int argc, char const* argv[])
{
	int a, b;
	std::string op;

	do {
		std::cin >> a >> op >> b;

		if(op == "+")
			std::cout << a + b << std::endl;
		else if( op == "-")
			std::cout << a - b << std::endl;
		else if( op == "*")
			std::cout << a * b << std::endl;
		else if (op == "/")
			std::cout << a / b << std::endl;
	} while( op != "?");

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll k;
   cin >> k;

    map<ll, ll> mp;
    if(k%2==0) {
        cout << -1 <<endl;
    } else {
        ll num = 7;
        ll index = 1;
        while(1) {
            num%=k;
            if(mp[num]!=0) {
                cout << -1 << endl;
                break;
            }
            mp[num]++;
            if(num == 0) {
                cout << index << endl;
                break;
            }
            while(num<=k) {
                    num = num * 10 + 7;
                    index++;
            }
        }
    }

}

Measured memory_bytes: 59892
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int a = 0;
        int b = 0;
        int c = 0;
        for(char ch : s){
            if(ch == 'a'){
                a++;
            }else if(ch == 'b'){
                b++;
            }else{
                c++;
            }
        }
        int chk = 0;
        if(a != 0) chk++;
        if(b != 0) chk++;
        if(c != 0) chk++;
        if(chk == 3 && Math.abs(a-b) <= 1 && Math.abs(b-c) <= 1 && Math.abs(c-a) <= 1){
            System.out.print("YES");
        }else if(chk == 2 && a+b+c == 2 || chk == 1 && a+b+c == 1){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
    }
}

Measured memory_bytes: 26616
#include <bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;

void solve(){
	int n; cin >> n;
	vi v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	
	for(int i = 0; i < n; i++){
		if( (~v[i] & 1) && v[i]%3 != 0 && v[i]%5 != 0){
			cout << "DENIED\n";
			return;
		}
	}
	cout << "APPROVED\n";
}

int main(){
	/*
	int t;
	cin >> t;
	while(t--)
		solve();
	*/	
	solve();	
	return 0;
}


Measured memory_bytes: 256
i = gets.to_i

if i >= 1800
  m = 1
elsif i >= 1600
  m = 2
elsif i >= 1400
  m = 3
elsif i >= 1200
  m = 4
elsif i >= 1000
  m = 5
elsif i >= 800
  m = 6
elsif i >= 600
  m = 7
else
  m = 8
end
  
  
  
puts m

Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  int a = 0,b = 0;
  cin >> S;
  for(int i = 0;i < S.size(); i++){
    if(S.at(i) == '0')
      a++;
    else
      b++;
  }
  int kaisuu = min(a,b);
  cout << kaisuu * 2 << endl;
}



Measured memory_bytes: 3760
eval"N,*T,Z=#{`tr ' 
' ,`}1"
T<<0
N.times{|i|a,b=T[N+i,2]
Z=Z*[[[a,t=T[i]].min,0,-1[a-t]][s=T[i-1]<=>t],0,(s%3-1)[t-a]][b<=>a]%(10**9+7)}
p Z

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

int main() {
int n,k;
cin>>n>>k;
vector<int>v(n);
for(auto &a:v)cin>>a;
int sum=0;
sort(v.begin(),v.end());
for(int i=0;i<k;i++)
sum+=v[i];
cout<<sum;
return 0;
}

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

int main(void){
	int i,l,s,t,f,a[20],b[20];
	long n;
	
	//for(i=0;i<10;i++)scanf(" %d",&a[i]);
	
	while(scanf("%ld",&n)!=EOF){
		
		for(i=0;i<10;i++){
			a[i]=n%10;
			n/=10;
		}
		
		for(i=10;i>1;i--){
			for(l=0;l<i-1;l++){
				b[l]=(a[l]+a[l+1])%10;
			}
			for(l=0;l<i-1;l++)a[l]=b[l];
		}
		
		printf("%d\n",a[0]);
	}
	
	return 0;
}
		

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

int main() {

	int n;
	cin >> n;
	int c;
    c = n / 100;
    if(n <= c * 111){
    	cout << c * 111 << '\n';
    }else{
    	cout << (c + 1) * 111 << '\n';
    }
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x
    
def main():
    s = stdin.readline().rstrip()
    if s.isupper():
        print("A")
    else:
        print("a")
main()

Measured memory_bytes: 9872
Cs = [*'a' .. 'z', *'A' .. 'Z', *'0' .. '9']
L = 128

class PriorityQueue
  def initialize
    @q = [nil]
  end

  def bubble_up(i)
    pi = i / 2
    return if i <= 1 || @q[pi][0] <= @q[i][0]
    @q[i], @q[pi] = @q[pi], @q[i]
    bubble_up(pi)
  end

  def add(e)
    @q << e
    bubble_up(@q.size - 1)
  end

  def bubble_down(i)
    ci = i * 2
    return if ci > @q.size - 1
    ci += 1 if ci != @q.size - 1 && @q[ci][0] > @q[ci + 1][0]
    return if @q[i][0] <= @q[ci][0]
    @q[i], @q[ci] = @q[ci], @q[i]
    bubble_down(ci)
  end

  def pop
    @q[1], @q[-1] = @q[-1], @q[1]
    ret = @q.pop
    bubble_down(1)
    ret
  end

  def size
    @q.size - 1
  end
end

def query(s)
  puts '? ' + s; STDOUT.flush
  r = gets.to_i
  (puts '! ' + s; exit) if r == 0
  r
end

def merge(s, t)
  c = query(s)
  ret = ''
  i, j = 0, 0
  while i < s.length && j < t.length
    r = query(ret + t[j] + s[i ..])
    if r < c
      c = r
      ret += t[j]
      j += 1
    else
      ret += s[i]
      i += 1
    end
  end
  if i == s.length
    ret += t[j ..]
  else
    ret += s[i ..]
  end
  ret
end

pq = PriorityQueue.new
Cs.each do |c|
  r = query(c*L)
  m = L - r
  pq.add([m, c*m]) unless m.zero?
end
while pq.size >= 2
  _, s = pq.pop
  _, t = pq.pop
  u = merge(s, t)
  pq.add([u.length, u])
end
query(pq.pop.last)

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.141592653
#define oo 1000000007
#define loo 10000000000000007

#define prime 998244353 
#define mod 998244353 

ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int pai[200100], r[200100];

int find(int a){
    if(a == pai[a]) return a;
    return pai[a] = find(pai[a]);
}

void Union(int x, int y){
    int a = find(x);
    int b = find(y);
    if(a == b) return;
    if(r[a] < r[b]){
        pai[a] = b;
        r[b]+=r[a];
    }else{
        pai[b] = a;
        r[a]+=r[b];
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 1; i < n+1; ++i){
        pai[i] = i;
        r[i] = 1;
    }
    for (int i = 0; i < m; ++i){
        int a, b; cin >> a >> b;
        Union(a, b);
    }
    int ans = 0;
    for (int i = 1; i < n+1; ++i){
        ans = max(ans, r[find(i)]);
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
int X[200005],Y[200005];
char c[200005];
vector<int>down[200005],le[200005],ri[200005],up[200005];
map<int,vector<int>>do1,do2,le1,le2,ri1,ri2,up1,up2;
signed main(){
	cin>>N;
	rep(i,N){
		cin>>X[i]>>Y[i]>>c[i];
		if(c[i]=='D'){
			up[X[i]].push_back(Y[i]);
			up1[X[i]+Y[i]].push_back(X[i]);
			up2[X[i]-Y[i]].push_back(X[i]);
		}
		else if(c[i]=='U'){
			down[X[i]].push_back(Y[i]);
			do1[X[i]+Y[i]].push_back(X[i]);
			do2[X[i]-Y[i]].push_back(X[i]);
		}
		else if(c[i]=='L'){
			le[Y[i]].push_back(X[i]);
			le1[X[i]+Y[i]].push_back(X[i]);
			le2[X[i]-Y[i]].push_back(X[i]);
		}
		else {
			ri[Y[i]].push_back(X[i]);
			ri1[X[i]+Y[i]].push_back(X[i]);
			ri2[X[i]-Y[i]].push_back(X[i]);
		}
	}
	rep(i,200001){
		sort(all(down[i]));sort(all(up[i]));sort(all(le[i]));sort(all(ri[i]));
	}
	for(auto &i:le1)sort(all(i.second));
	for(auto &i:le2)sort(all(i.second));
	for(auto &i:do1)sort(all(i.second));
	for(auto &i:do2)sort(all(i.second));
	for(auto &i:up1)sort(all(i.second));
	for(auto &i:up2)sort(all(i.second));
	for(auto &i:ri1)sort(all(i.second));
	for(auto &i:ri2)sort(all(i.second));
	
	int ans=inf;
	rep(y,200001){
		for(int i:up[y]){
			auto it=upper_bound(all(down[y]),i);
			if(it!=down[y].begin()){
				chmin(ans,(i-*--it)*5);
			}
		}
		for(int i:le[y]){
			auto it=upper_bound(all(ri[y]),i);
			if(it!=ri[y].begin()){
				chmin(ans,(i-*--it)*5);
			}
		}
	}
	for(int i=-200000;i<=400000;i++){
		for(int j:up2[i]){
			auto it=upper_bound(all(ri2[i]),j);
			if(it!=ri2[i].begin())chmin(ans,(j-*--it)*10);
		}
		for(int j:up1[i]){
			auto it=upper_bound(all(le1[i]),j);
			if(it!=le1[i].end())chmin(ans,(*it-j)*10);
		}
		for(int j:do1[i]){
			auto it=upper_bound(all(ri1[i]),j);
			if(it!=ri1[i].begin())chmin(ans,(j-*--it)*10);
		}
		for(int j:do2[i]){
			auto it=upper_bound(all(le2[i]),j);
			if(it!=le2[i].end())chmin(ans,(*it-j)*10);
		}
	}
	if(ans==inf)cout<<"SAFE"<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 262492
//
// Created by GGG1235 on 2019/11/23.
//

#include <bits/stdc++.h>

#pragma GCC optimize(3)

using namespace std;

typedef long long LL;

int main(int argc,const char **argv,const char **envp)
{
    ios::sync_with_stdio(false);
    cin.tie();

    int nN;
    int nM;
    int nXi;
    int nYi;
    
    int nRes = 0;
    unordered_map<int,bool> kumMap;
    
    while (cin >> nN >> nM) 
    {
        nRes = 0;
        kumMap.clear();
        vector<int> kvBi(nN + 1, 1);
        kvBi[0] = 0;
        kumMap[1] = true;
        for (int i = 1; i <= nM; i++) 
        {
            cin >> nXi >> nYi;
            if (kumMap[nXi]) 
            {
                kumMap[nYi] = true;
                if (kvBi[nXi] == 1) 
                {
                    kumMap[nXi] = false;
                }
            }
            kvBi[nYi]++;
            kvBi[nXi]--;
        }
        kvBi.clear();
        for (int i = 1; i <= nN; i++) 
        {
            nRes += kumMap[i];
        }
        cout << nRes << endl;
    }
    return 0;
}

Measured memory_bytes: 4772
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        
        StringBuilder sb = new StringBuilder();
        int s2;
        if(s == 1000000000){
            s2 = s-1;
        }else{
            s2 = s+1;
        }
        for(int i = 0; i < k; i++){
            sb.append(s).append(" ");
        }
        for(int i = k; i < n; i++){
            sb.append(s2).append(" ");
        }
        
        System.out.println(sb);
    }
}

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

int main(){
    int A[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int a;
            cin >> a;
            A[i][j] = a;
        }
    }

    int N;
    cin >> N;
    int b[N];
    for(int i=0;i<N;i++) cin >> b[i];

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

    //横
    for(int i=0;i<3;i++){
        if(A[i][0]==0 && A[i][1]==0 && A[i][2]==0) ans++;
    }
    for(int i=0;i<3;i++){
        if(A[0][i]==0 && A[1][i]==0 && A[2][i]==0) ans++;
    }
    
        if(A[0][0]==0 && A[1][1]==0 && A[2][2]==0) ans++;
        if(A[0][2]==0 && A[1][1]==0 && A[2][0]==0) ans++;

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


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, t, a; cin >> n >> t >> a;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<double> diffs(n);
    rep(i,n) diffs[i] = abs(t-h[i]*0.006 - a);
    int idx = 0;
    double m = 1 << 30;
    rep(i,n){
        if(m > diffs[i]){
            idx = i;
            m = diffs[i];
        }
    }
    cout << idx+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, A, B, C, R, Q;

	while (true)
	{
		cin >> A >> B >> C;

		if (A == 0 && B == 0 && C == 0)
		{
			break;
		}

		if (A > B) { swap(A, B); }
		if (A > C) { swap(A, C); }
		if (B > C) { swap(B, C); }

		Q = A * A + B * B;

		cin >> N;

		for (int i = 0; i < N; i++)
		{
			cin >> R;

			if (R * R * 4 > Q)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}

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

int main()
{
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < o.size() + e.size(); ++i)
	{
		cout << (i%2==0?o[i/2]:e[i/2]);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr, tails)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  [n,d] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  points <- replicateM n $ do
    U.unfoldrN d (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ sum [ 1
              | x:ys <- tails points
              , y <- ys
              , let distance = U.sum $ U.map (^2) (U.zipWith (-) x y)
              , distance == (floor $ sqrt $ fromIntegral distance)^2
              ]


Measured memory_bytes: 508
// B. 

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int n, l;
	cin >> n >> l;
	vector<string> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (auto s : v) {
		cout << s;
	}
	cout << endl;
	return 0;
}


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

using namespace std;

bool a[1000000];

int main()
{
    memset(a, true, sizeof(a));

    int n;
    while (~scanf("%d", &n)) {
        for (int i = 2; i * i <= n; ++i) {
            if (a[i]) for (int j = i + i; j <= n; j += i) a[j] = false;
        }
        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += a[i];
        printf("%d\n", cnt);
    }
}

Measured memory_bytes: 2172
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int P[8],Q[8];
int main () {
    int N; cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    for (int i=0; i<N; i++) cin >> P[i];
    for (int i=0; i<N; i++) cin >> Q[i];
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);
    int i=0,a=0,b=0;
    do {
        if (P==v) a=i;
        if (Q==v) b=i;
        i++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
/* TLE*/
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

const int INF = 100000000;
typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // 無向グラフの対の辺
    Edge(int from, int to, Weight weight) :
        from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
        from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

void dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev){
    int n = g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q;     // a < b <-> a.weight > b.weight
    Q.push(Edge(-2, s, 0));
    while(!Q.empty()){
        Edge e = Q.top(); Q.pop();
        if(prev[e.to] != -1) continue;
        prev[e.to] = e.from;
        EACH(i, g[e.to]){
        //for(Edges::const_iterator i=g[e.to].begin(); i!=g[e.to].end(); ++i){    //マクロが使えないとき
            if(dist[i -> to] > dist[i -> from] + i -> weight){
                dist[i -> to] = dist[i -> from] + i -> weight;
                Q.push(Edge(i -> from, i -> to, dist[i -> to]));
            }
        }
    }
}

int main(){
	int K;
	cin >> K;
	Graph g(K);
	for(int i = 0; i < K; ++i) {
		g[i].push_back(Edge(i, (i + 1) % K, 1));
		g[i].push_back(Edge(i, (i * 10) % K, 0));
	}
	vector<int> prev(K), dist(K);
	dijkstra(g, 1, dist, prev);
	cout << dist[0] + 1 << endl;
	return 0;
}


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#include<bitset>
#include<string>
using namespace std;
#include <numeric> 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using pi=pair<long long,long long>;
#define pii 3.1415926536
#define binary
#define mod 1000000007
typedef long long ll;
typedef long double ld;
bool sortbysec(const pair<long long,long long> &a, 
              const pair<long long,long long> &b) 
{ 
    return (a.first < b.first); 
}
bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll>&b)
{
    if(a.first.first==b.first.first)return (a.first.second<b.first.second);
    return (a.first.first < b.first.first); 
}
 int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
 int Kad(ll dp[],ll n)
{
  ll curr_max=0,maxx=INT_MIN;
  for(int i=0;i<n;i++)
  {
    curr_max=curr_max+dp[i];
    if(curr_max>maxx)
      maxx=curr_max;

    if(curr_max<0)
      curr_max=0;
   
  }

  return maxx;
}

/*void dfs(int u)
{
    vis[u]=true;
    //cout<<u<<" ";
    std::vector<ll> ::iterator i;
     for (i = g[u].begin(); i != g[u].end(); ++i) 
        if (!vis[*i]) 
            dfs(*i); 
    for(int i=1;i<g[u].size();i++)
    {
        if(!vis[g[u][i]])
        {
            dfs(i);
        }
    }
}*/


int main(){
    IOS;
   
   ll n,d;
   cin>>n>>d;
   ll ans=0;
   for(int i=0;i<n;i++)
   {
    ll x,y;
    cin>>x>>y;
    ll dist=pow(abs(x),2)+pow(abs(y),2);
    if(dist<=pow(d,2))
        ans++;
   }
   cout<<ans<<endl;
   
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
string k;
int x;
int main()
{
	cin>>k;
	for(int i=0;i<k.size();i++)
	{
			if(k[i]=='x')
			{
				x++;
			}
	}
	if(x<=7)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
}


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

int main(){

    int w[10004], n;
    cin >> n;
    for(int i=0; i<n; i++) cin >> w[i];

    int s1=0, s2=0;
    s1 = w[0];
    for(int i=1; i<n; i++) s2 += w[i];      

    int min1 = abs(s1-s2);
    for(int i=1; i<n; i++){
        s1 += w[i];
        s2 -= w[i];
        min1 = min(abs(s1-s2), min1);
    }
    cout << min1 << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

A_list = [int(a) for a in input().split()]

# print(N, K)
# print(A_list)

keiro = [1]
visit_town = [0]*N

town = 1
c = 1
while True:
    visit_town[town - 1] = c
    c += 1
    town = A_list[town - 1]
    # print('town', town)

    if len(keiro) > 1 and visit_town[town-1] != 0:
        break
    keiro.append(town)

# print(keiro)
# print(visit_town)
# print(town)


first_visit = keiro[:visit_town[A_list[keiro[-1]-1]-1]-1]
loop_visit = keiro[visit_town[A_list[keiro[-1]-1]-1]-1:]

# print(first_visit)
# print(loop_visit)

if K <= len(first_visit)-1:
    print(first_visit[K])
else:
    l = K - len(first_visit)
    # print(l)
    c = (l) % len(loop_visit)
    # print(c)
    print(loop_visit[c])

# print(keiro[len(first_visit) + (K - len(first_visit)) % len(loop_visit)])


Measured memory_bytes: 32256
#include <stdio.h>
#include <math.h>

#define CONVERGENT_COEFFICIENT (0.00001)

static int q;

double next_xn (double xn) {
	return xn - (xn * xn * xn - q)/(3 * xn * xn);
}

double solve() {
	double xn = q / 2.0;
	while(fabs(xn * xn * xn - q) >= CONVERGENT_COEFFICIENT * q) {
		/*printf("xn = %lf\n", xn);*/
		xn = next_xn(xn);
	}
	/*printf("収束した。%lf\n", xn);*/
	return xn;
}

int main() {
	double xn;
	while(1) {
		scanf("%d", &q);
		/*printf("スキャン：q = %d\n", q);*/
		if (q == -1) {
			break;
		}
		xn = solve();
		printf("%lf\n", xn);
	}
	return 0;
}

Measured memory_bytes: 632
fun main(args: Array<String>) {
    val (N, A, B) = readInts()
    val h = Array(N, { i -> i })
    for (i in 1..N) {
        h[i - 1] = readInt()
    }
    var (l, r) = listOf(h.min()!! / A, h.max()!! / B + 1)
    while (l + 1 < r) {
        val m = (l + r) / 2
        if (enough(m, h, A, B)) {
            r = m
        } else {
            l = m
        }
    }
    println(if (enough(l, h, A, B)) l else r)
}

fun enough(x: Int, h: Array<Int>, A: Int, B: Int): Boolean {
    var total = 0
    for (hi in h) {
        total += Math.max(0, Math.ceil((hi - x * B) / (A - B).toDouble()).toInt())
        if (total > x) {
            return false
        }
    }
    return true
}

fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(' ').map(String::toInt)

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

int main(){
	int N;
	cin>>N;
	
	if(N<10)
		cout<<N;
	else if(N<100)
		cout<<9;
	else if(N<1000)
		cout<<9+(N-99);
	else if(N<10000)
		cout<<9+900;
	else if(N<100000)
		cout<<9+900+(N-9999);
	else if(N==100000)
		cout<<9+900+90000;
		
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	int n, i, j, k;
	vi a;

	cin >> n;
	
	a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());

	k = a.size();
	
	if (k % 2 == 0) {
		cout << k - 1;
	}
	else {
		cout << k;
	}
	
	return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  ll ans = 0, sum = A.at(N - 1);
  for (int i = N - 2; i >= 0; i--){
    ans += A.at(i) * sum;
    //cout << ans << endl;
    ans %= 1000000007;
    sum += A.at(i);
    sum %= 1000000007;
  }
  
  //cout << A.at(0) << endl;
  cout << ans << endl;
}

Measured memory_bytes: 3960
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]=new int[3*n];

		for(int i =0;i<n;i++){
			a[3*i]=scan.nextInt();
			a[3*i + 1]=scan.nextInt();
			a[3*i + 2]=scan.nextInt();
		}

		Arrays.sort(a);

		long strength=0;
		for(int i=0;i<n;i++){
			strength+=a[3*n-2 -2*i];
		}
		System.out.println(strength);

	}

}


Measured memory_bytes: 95700
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cassert>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

class Prime {
private:
	vector<int> Ptb;

	void Eratos(lint N) {
		for (lint i = 2; i * i < N; i++) {
			if (Ptb[i]) for (int j = 0; i * (j + 2) < N; j++) Ptb[i *(j + 2)] = 0;
		}
	}

public:
	Prime(lint N) : Ptb(N + 1, 1) { Eratos(N + 1); }

	vector<pair<lint, int>> Pfact(lint num) {
		vector<pair<lint, int>> res;
		for (lint i = 2; i * i <= num; i++) {
			int cnt = 0;
			while (num % i == 0) {
				cnt++;
				num /= i;
			}
			if (cnt) res.emplace_back(i, cnt);
		}
		if (num != 1) res.emplace_back(make_pair(num, 1));
		return res;
	}

	bool isPrime(lint num) {
		if (num < 2) return false;
		else if (num < (int)(Ptb.size())) return (bool)(Ptb[num]);
		else if (num == 2 || num == 3) return true;
		else if (num % 2 == 0 || num % 3 == 0) return false;
		else if (num % 6 != 1 && num % 6 != 5) return false;
		for (lint i = 5; i * i <= num; i += 6) {
			if (num % i == 0) return false;
			if (num % (i + 2) == 0) return false;
		}
		return true;
	}
};

template <class T>
class CuSum {
private:
	vector<T> cusum;
public:
	// Constructors 
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()); i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r] 
	T operator()(int l, int r) {
		if (r < l || r < 0) { 
			cerr << "invalid [l, r] input\n";
			return T(0); 
		}
		else return cusum[r + 1] - cusum[l];
	}
	// 0-indexed
	T operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

int main() {

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

	vector<int> similar(100000);
	Prime p(100000);
	for (int i = 1; i < 100000; i += 2) {
		if (p.isPrime(i) && p.isPrime((i + 1) / 2)) similar[i] = 1;
	}

	CuSum<int> sum(similar);
	int Q, r, l;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << sum(l, r) << "\n";
	}

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, N;
    cin >> H >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    vector<ll> dp(H + 1, INF);
    dp[0] = 0;
    rep(i, H) {
        rep(j, N) {
            P p = items[j];
            dp[min(H, i + p.first)] = min(dp[min(H, i + p.first)], dp[i] + p.second);
        }
    }
    cout << dp[H] << '\n';
}

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


Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int h[100005];
    for(int i=1;i<=n;i++) cin >> h[i];

    int dp[100005];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
import kotlin.math.min

fun main() {
  val (h,n) = readLine()!!.split(' ').map { it.toInt() }
  val dp = IntArray(h+1){1000000000}
  dp[0] = 0
  for(i in 0 until n){
    val (value, cost) = readLine()!!.split(' ').map { it.toInt() }
    for(j in 0 until h){
      val k = min(h, j+value)
      dp[k] = min(dp[k], dp[j]+cost)
    }
  }
  println(dp[h])
}

Measured memory_bytes: 40148
N = int(input())
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

alice = [a[2*i] for i in range(N) if 2*i<N]
bob = [a[2*i+1] for i in range(N) if (2*i+1)<N]

print(sum(alice) - sum(bob))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 2);
	a[0] = -2 * inf; a[n + 1] = 2 * inf;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int l;
	cin >> l;
	vector<vector<int>> dl(20, vector<int>(n + 2));
	vector<vector<int>> dr(20, vector<int>(n + 2));
	dl[0][0] = dr[0][0] = 0; dl[0][n + 1] = dr[0][n + 1] = n + 1;
	for (int i = 1; i <= n; i++) {
		int now = a[i];
		dl[0][i] = lower_bound(all(a), now - l) - a.begin();
		dr[0][i] = upper_bound(all(a), now + l) - a.begin() - 1;
	}
	for (int i = 1; i < 20; i++) {
		rep(j, n + 2) {
			dl[i][j] = dl[i - 1][dl[i - 1][j]];
			dr[i][j] = dr[i - 1][dr[i - 1][j]];
		}
	}
	int q;
	cin >> q;
	while (q--) {
		int a, b;
		cin >> a >> b;
		if (a > b) swap(a, b);
		int ans = 1;
		for (int i = 19; i >= 0; i--) {
			if (dr[i][a] < b) {
				ans += 1 << i;
				a = dr[i][a];
			}
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 19744
//Code Author:-code_kika //
//Institution:-IIT(BHU)  //
#include<bits/stdc++.h>
using namespace std;
//basic
#define pb push_back
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007LL

//typedefs
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vll vector<ll>
#define vi vector<int>

//functions
#define all(c) c.begin(),c.end()
#define mini(c) min_element(all(c))
#define maxi(c) max_element(all(c))
#define fill(c,val) memset(c,val,sizeof(c))

//debug
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
int main(){
	int i,n,a[100005],e=0,o=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			e++;
		}
		else{
			o++;
		}
	}
	if(n==1){
		cout<<"YES";
		return 0;
	}
	if(o%2==1){
		cout<<"NO";
		return 0;
	}
	else{
		cout<<"YES";
	}

		
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var n = decimal.Parse(Console.ReadLine());

            long result = 100;
            long count = 0;

            while (true) {
                result += result / 100;
                count++;

                if(result >= n) {
                    break;
                }
            }

            Console.WriteLine(count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27528
#include "bits/stdc++.h"

int main() {

    int N;
    std::cin >> N;
    std::vector<int> cumsum(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        int W;
        std::cin >> W;
        cumsum[i + 1] = cumsum[i] + W;
    }
    int ans = INT_MAX;
    for (int i = 1; i < N; ++i) {
        int S1 = cumsum[i];
        int S2 = cumsum[N] - S1;
        ans = std::min(ans, std::abs(S1 - S2));
    }
    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[100];
	int a=0;
	int b=0;
	
	scanf("%s",s);
	
	for(int i=0;i<3;i++){
		if(s[i]=='a'){
			a++;
		}
		if(s[i]=='b'){
			b++;
		}
	}
	
	if(a==1&&b==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
a=int(input())
b=int(input())
c=int(input())
x=int(input())
output=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                output+=1

print(output)

Measured memory_bytes: 3064
from collections import deque
n,q=map(int,input().split())
eage=[[] for i in range(n)]
visited=[False]*n
point=[0]*n
for i in range(n-1):
    a,b=map(int,input().split())
    eage[a-1].append(b-1)
    eage[b-1].append(a-1)
for i in range(q):
    p,x=map(int,input().split())
    point[p-1]+=x

q=deque([0])
while q:
    v=q.popleft()
    visited[v]=True
    for nv in eage[v]:
        if visited[nv]==True:
            continue
        point[nv]+=point[v]
        q.append(nv)
print(*point)



Measured memory_bytes: 56088
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim a As Integer = NextInt()
        Dim b As Integer = NextInt()

        WriteLine(Math.Max(0, CLng(b - a) * (n - 2) + 1))
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 20432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    ll A, B, N;
    cin>>A>>B>>N;
    if(N>=B-1){
        cout<<(A*(B-1))/B<<endl;
        return 0;
    }
    cout<<(A*N)/B<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    ll ts = 0, as = 0;
    ll t, a;

    cin >> ts >> as;
    rep1(i, n){
      cin >> t >> a;
      ll r = max((ts + t - 1) / t, (as + a - 1) / a);
      ts = t * r;
      as = a * r;
    }
    pri(ts + as);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int b[1000000010];

int main()
{
	int n, q, s, t;
	int ans = 0 ;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		b[s]++;
	}
	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> t;
		if (b[t] >= 1) ans++;
	}
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 3240
def main():
    N = int(input())
    P = list(map(int, input().split()))
    crnt_min = float('inf')
    res = 0
    for i, p in enumerate(P):
        if crnt_min >= p:
            res += 1
        if p < crnt_min:
            crnt_min = p
    
    print(res)
    

main()

Measured memory_bytes: 24744
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    cin >> a>>b>> c>>d;

    cout << min(a, b) + min(c,d) << endl;

    return 0;
}

Measured memory_bytes: 256
alphabet='abcdefghijklmnopqrstuvwxyz'
dic={ch:0 for ch in alphabet}
while True:
    try:
        inp=input()
        if inp=="":break
        inp=inp.lower()
        for ch in inp:
            if ch in alphabet:
                dic[ch]+=1
    except EOFError:
        break

for k, v in dic.items():
    print("{} : {}".format(k,v))


Measured memory_bytes: 5568