akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int A, B, C, D, E, F;

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

	cin >> A >> B >> C >> D >> E >> F;

	double max_v = -1.0;
	int max_w = 0, max_s = 0;
	for(int a = 0; 100 * a * A <= F; a++) {
		for(int b = 0; 100 * b * B <= F; b++) {
			for(int c = 0; c * C<= F; c++) {
				for(int d = 0; d * D <= F; d++) {
					int w = 100 * (a * A + b * B);
					int s = (c * C + d * D);
					if(w + s == 0) continue;
					if(w + s > F) {
						continue;
					}
					if(w * E < 100 * s) {
						continue;
					}
					double consentration = 100.0 * s / (w + s);
					if(max_v < consentration) {
						max_v = consentration;
						max_w = w;
						max_s = s;
					}
				}
			}
		}
	}


	cout << max_w + max_s << " " << max_s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

Graph g;
ll n;
vector<ll>dist;

/*トポロジカルソートを行う
DAGでない場合にはsize０のvectorを返す*/

struct TopologicalSort{
    int v;
    vector<vector<int> >g;
    vector<int>deg,res;//degは頂点に入ってくる辺の数
    TopologicalSort(int n) : v(n),g(v),deg(v,0){}
    void add_edge(int from,int to){
        g[from].push_back(to);
        deg[to]++;
    }
    vector<int> solve(){
        queue<int>que;
        rep(i,v){
            if(deg[i]==0){
                que.push(i);
            }
        }
        while(!que.empty()){
            int p = que.front();
            que.pop();
            res.push_back(p);
            for(int v:g[p]){
                if(--deg[v]==0){
                    que.push(v);
                }
            }
        }
        if(*max_element(deg.begin(),deg.end())==0){
            return res;
        }
        else{
            return vector<int>();
        }
    }
    bool unique(){//解の一意性を判定する
        for(int i=0;i<v-1;i++){
            int from = res[i];
            int to = res[i+1];
            bool flg = false;
            for(int x:g[from]){
                if(x==to)flg=true;
            }
            if(!flg){
                return false;
            }
        }
        return true;
    }
};

int main(){
    cin >> n;
    g.resize(n*n);
    dist.resize(n*n,0);
    TopologicalSort tps(n*n);
    rep(i,n){
        int past = 0;
        rep(j,n-1){
            int a;
            cin >> a;
            a--;
            int l = min(i,a);
            int r = max(i,a);
            int nx = l*n+r;
            g[nx].push_back(past);
            tps.add_edge(past,nx);
            past = nx;
        }
    }
    //DAGの判定
    auto vec = tps.solve();
    if(vec.size()==0){
        cout << -1 << endl;
        return 0;
    }
    rep(i,vec.size()){
        for(int x:g[vec[i]]){
            chmax(dist[vec[i]],dist[x]+1);
        }
    }
    ll ans = 0;
    rep(i,n*n){
        chmax(ans,dist[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 102948
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = list(input())
ans = 0
dic = {'p': s, 's': r, 'r': p}
for i in range(k):
  ans += dic[t[i]]
dic_ls = []
for i in range(k, n):
  if t[i] != t[i - k]:
    ans += dic[t[i]]
  else:
    t[i] = 'j'
print(ans)

Measured memory_bytes: 9992
def checkWays(n,x)
  count = 0
  catch(:stop) do
    n.downto(1) do |n1|
      (n1-1).downto(1) do |n2|
        n3 = x - n1 - n2
        count += 1 if (n3 < n2) && (n3 > 0)
        throw :stop if (n3 > n1)
        break if (n3 > n2)
      end
    end
  end
  puts count
end

while ((n,x = gets.split(" ").map(&:to_i)) != [0,0]) do
  checkWays(n,x)
end

Measured memory_bytes: 8604
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    int n,ans=0,a[100000];
    cin>>n;
	rep(i,n) cin>>a[i];
	map<int,int> mp;
	rep(i,n) mp[a[i]]++;
	for(auto p:mp){
		int x=p.first;
		int n=p.second;
		if(n<x){
		  ans+=n;
        }else{
		  ans+=n-x;
        }
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5120
a, b, c = map(int, input().split())
if a == b == c:
  x = "1"
elif a != b == c:
  x = "2"
elif a == b != c:
  x = "2"
elif a == c != b:
  x = "2"
elif a != b != c:
  x = "3"
        
print(x)

Measured memory_bytes: 2940
#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()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int v[32] = {
        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 k;
    cin >> k;

    cout << v[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int

	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var result int

	for {
		var flag int
		for k, v := range a {
			if v%2 != 0 {
				flag = 1
				break
			}
			a[k] = v / 2
		}
		if flag == 1 {
			break
		}
		result++
	}

	fmt.Println(result)
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    long ans = LONG_MAX;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++)
        cin >> a[i];
    for (int x=-100; x<=100; x++) {
        long tmp = 0;
        for (int i=0; i<n; i++)
            tmp += pow(x-a[i], 2);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[200002] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, a[200001], b[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(b[i]));
	
	int j, k, bit[31] = {1}, lower[2][31][200002], ans = 0, tmp;
	for (i = 1; i < 31; i++) bit[i] = bit[i-1] << 1;
	for (i = 1; i <= N; i++) {
		for (j = 0; j < 30; j++) {
			if ((a[i] | bit[j]) == a[i]) ans ^= bit[j] * (N % 2);
			if ((b[i] | bit[j]) == b[i]) ans ^= bit[j] * (N % 2);
			lower[0][j][i] = a[i] % bit[j+1];
			lower[1][j][i] = b[i] % bit[j+1];
		}
	}
	for (j = 0; j < 30; j++) {
		merge_sort(&(lower[0][j][1]), N);
		merge_sort(&(lower[1][j][1]), N);
	}
	for (k = 0; k < 30; k++) {
		for (i = 1, j = N, tmp = 0; i <= N; i++) {
			for (; j >= 1 && lower[0][k][i] + lower[1][k][j] >= bit[k+1]; j--);
			tmp += (N - j) % 2;
		}
		ans ^= bit[k+1] * (tmp % 2);
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 50560
def main():
    n, k = map(int, input().split())
    h_list = list(map(int, input().split()))
    h_list.sort()

    for i in range(k):
        h_list.pop()
        if not h_list:
            print(0)
            return
    ans = sum(h_list)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25896
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, m, a, sum = 0;
	cin >> num >> m;
	rep(i, m) {
		cin >> a;
		sum += a;
	}
	int ans = num - sum;
	if (ans < 0)
		printf("-1\n");
	else
		cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3632
s = input()
# print(s)
o = []
for i in range(len(s)):
    # print(i,s[i],o)
    if (s[i] == 'B'):
        if (len(o)>0):
            o = o[:-1]
    else:
        o.append(s[i])

print(''.join(o))


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



int main() {
	int N,ans=0;
	cin >> N;
	vector<int>D(N);
	rep(0, N) {
		cin >> D[i];
	}
	rep(1, N) {
		for (int j = i-1; j >=0; j--) {
			ans += D[i] * D[j];
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#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)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int h, a;
    cin >> h >> a;

    int ans = 0;
    while(h>0)
    {
        h -= a;
        ans++;
    }
    cout << ans;




    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



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


int main() {
    int  A,B;
    cin >>A>>B;
    int count=0;
    for(int i=A;i<=B;i++){
        string a =to_string(i);
        if(a[0]==a[4]&&a[1]==a[3])count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
void setIO(string name) {
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}
vector<int> adj[200005];
int visited[200005]={0};
int ender=-1;
int cnt=1;
vector<int> c;
void dfs(int node,int length){
  visited[node]=length;
   c.pb(node);
  cnt=max(cnt,length);
  for(int next:adj[node]){
    if(!visited[next]){
      
      dfs(next,length+1);

    }else{
      ender=next;
    }
  }
  cnt=max(cnt,length);

}

int main() {
   fast();
   //setIO("moop");
   int n;
   cin>>n;
   long long k;
   cin>>k;
   for(int i=0;i<n;i++){
    int l;
    cin>>l;
    --l;
    adj[i].pb(l);
   }
   dfs(0,1);
   int length_of_cycle;
   if(ender!=-1){
     int x;
      for(int i=0;i<c.size();i++){
        if(c[i]==ender){
           x=i;
           break;
        }
      }
     if(k<=x){
       cout<<c[k]+1<<"\n";
       return 0;
     }else{
      long long y=c.size()-x;
      k-=x;
      k%=y;
      cout<<c[k+x]+1<<"\n";
      return 0;
     }
      
   }

   

   

   
   



   
}
 

Measured memory_bytes: 28036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPT1_5B
{
    class Program
    {
        static void Main(string[] args)
        {
            int numH, numW;

            while (true)
            {
                string[] inString = Console.ReadLine().Split(' ');

                numH = int.Parse(inString[0]);
                numW = int.Parse(inString[1]);
                if ((numH == 0) && (numW == 0)) break;
                for (int i = 0; i < numH; i++)
                {
                    for (int j = 0; j < numW; j++)
                    {
                        if ((i == 0) || (i == numH - 1)) Console.Write("#");
                        else if ((j == 0) || (j == numW - 1)) Console.Write("#");
                        else Console.Write(".");
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 8756
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 998244353
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def inv(self, n):
        return self._fact[n - 1] * self._invfact[n] % MOD

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD

    def perm(self, n, k):
        if k < 0 or n < k: return 0
        return self._fact[n] * self._invfact[n - k] % MOD

def resolve():
    n, m, k = map(int, input().split())
    mf = modfact(n)
    res = 0
    for i in range(k + 1):
        res += m * pow(m - 1, n - i - 1, MOD) % MOD * mf.comb(n - 1, i)
        res %= MOD
    print(res)
resolve()

Measured memory_bytes: 70692
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
  int a[3];
  for(int i=0; i<3; i++){
    cin>>a[i];
    }
  sort(a,a+3);
  cout<<a[0]<<' '<<a[1]<<' '<<a[2]<<endl;
 }

Measured memory_bytes: 1176
#!/usr/bin/env python3

from pprint import pprint
from random import shuffle, sample

import numpy as np
import random

H, W = [int(x) for x in input().split(" ")]
h, w = [int(x) for x in input().split(" ")]

array = np.zeros((H, W), dtype=np.bool)

for r in sample(list(range(H)), h):
    array[r, :] = True

for c in sample(list(range(W)), w):
    array[:, c] = True

print(len(array[array == False]))


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

int main()
{
  string s; 
  cin >> s;
  
  int zero = 0, one = 0;
  int n = s.size();
  rep(i,n)
  {
    if(s[i] == '0')
    {
      zero++;
    }else{
      one++;
    }     
  }
  
  cout << n - abs(zero - one) << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

unordered_map<string, int> m;

int main(){
    string S;
    size_t max_len = 0;
    string ans;
    while (cin >> S) {
        m[S]++;
        if (max_len < S.length()) {
            ans = S;
            max_len = S.length();
        }
    }
    int ma = 0;
    for (auto i: m) {
        ma = max(i.second, ma);
    }
    for (auto i: m) {
        if (ma == i.second) {
            cout << i.first << " ";
            break;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=2e5+7;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
ll inv[maxn],h,w,a,b;
inline ll C(ll x,ll y)
{
    x=min(x,y-x);
    ll ans=1;
    for(ll up=y,down=1;down<=x;down++,up--) ans=ans*up%modn*inv[down]%modn;
    return ans;
}
int main()
{
    for(ll i=1;i<maxn;i++) inv[i]=qpow(i,modn-2);
    while(scanf("%lld%lld%lld%lld",&h,&w,&a,&b)==4)
    {
        ll ans=C(h-1,w+h-2);
        ll left=C(w-b-1,a+w-b-2),right=C(b-1,h-a+b-1);
        while(a)
        {
            ans=((ans-left*right%modn)%modn+modn)%modn;
            left=left*(a-1)%modn*inv[a+w-b-2]%modn;
            right=right*(h-a+b)%modn*inv[h-a+1]%modn;
            a--;
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 1792
/*
Author : N_o_o_B
Created : April 26 2020 17:36:17 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    set<string> s;  
    fori(i,n){
        string foo;
        cin >> foo;
        s.insert(foo);
    }

    cout << sz(s) << endl;

    time_taken();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll N, M, Q, A, B, C, D, E, X, Y, Z, arr[100005];

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	C = 0, D = N+1;
	for (int i = 1; i <= M; ++i){
		cin >> A >> B;
		C = max(C,A);
		D = min(D,B);
	}
	if (C > D){
		cout << 0 << '\n';
	}
	else cout << D-C+1 << '\n';
}

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

int main() {
	int num1, num2, num3;
	int tmp;

	cin >> num1 >> num2 >> num3;

	while(true){
		if(num1 > num2){
			tmp = num1;
			num1 = num2;
			num2 = tmp;
		} else if(num2 > num3){
			tmp = num2;
			num2 = num3;
			num3 = tmp;
		} else if(num1 > num3){
			tmp = num1;
			num1 = num3;
			num3 = tmp;
		} else{
			break;
		}
	}

	printf("%d %d %d\n",num1, num2, num3);

	return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
int main()
{
    int n, a[101];
    scanf("%d", &n);
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    long sa = 0, sb = 0;
    int max;
    int j;
    for (i = 1; i <= n; i++)
    {
        for (j = 0; j < n; j++)
        {
            if (a[max] < a[j])
                max = j;
        }
        if (i % 2 == 1)
            sa += a[max];
        else
            sb += a[max];
        a[max] = 0;
    }
    printf("%d\n", sa - sb);
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,ans=1e18;
	cin>>n;
	ll num=sqrt(n);
	for(int i=1;i<=num;i++){
		if(n%i==0)ans=min(ans,i+n/i-2);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

struct edge{
    int to, cap, rev;
};

int H, W;
const int MAX_V = 3e4;
vector<edge> es[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap = 1){
    edge e1 = {to, cap, es[to].size()}, e2 = {from, cap, es[from].size()};
    es[from].pb(e1), es[to].pb(e2);
}

int dfs(int now, int goal, int flow){
    if(now == goal) return flow;
    used[now] = true;
    for(auto &e: es[now]){
        if(used[e.to] || e.cap == 0) continue;
        int d = dfs(e.to, goal, min(flow, e.cap));
        if(d > 0){
            e.cap -= d;
            es[e.to][e.rev].cap += d;
            return d;
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(true){
        fill(used, used+MAX_V, false);
        int f = dfs(s, t, inf);
        if(f == 0) break;
        flow += f;
    }
    return flow;
}

int main(){
    int H, W;
    cin >> H >> W;
    string a[H];
    rep(i, H) cin >> a[i];
    int s, t;
    rep(i, H) rep(j, W){
        if(a[i][j] == 'S') s = W*i+j;
        if(a[i][j] == 'T') t = W*i+j;
        if(a[i][j] != '.') add_edge(W*i+j, H*W + W*i+j);
    }
    if(s%W == t%W || s/W == t/W){
        cout << -1 << endl;
        return 0;
    }
    rep(i, H){
        vector<int> v;
        rep(j, W){
            if(a[i][j] != '.') v.pb(j);
        }
        rep(p, v.size()) rep2(q, p+1, v.size()-1){
            add_edge(W*i+v[p], W*i+v[q]);
        }
    }
    rep(j, W){
        vector<int> v;
        rep(i, H){
            if(a[i][j] != '.') v.pb(i);
        }
        rep(p, v.size()) rep2(q, p+1, v.size()-1){
            add_edge(H*W + W*v[p]+j, H*W + W*v[q]+j);
        }
    }
    add_edge(s, 2*H*W, inf), add_edge(s+H*W, 2*H*W, inf);
    add_edge(t, 2*H*W+1, inf), add_edge(t+H*W, 2*H*W+1, inf);
    cout << max_flow(2*H*W, 2*H*W+1) << endl;
}

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

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

    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }

    vector<int> count1(1e5+1);
    vector<int> count2(1e5+1);
    for(int i=0; i<n; i+=2){
        count1[v[i]] += 1;
    }
    for(int i=1; i<n; i+=2){
        count2[v[i]] += 1;
    }

    vector<pair<int, int>> pcount1(1e5+1);
    vector<pair<int, int>> pcount2(1e5+1);
    for(int i=0; i<1e5+1; i++){
        pcount1[i] = make_pair(count1[i],i);
    }
    for(int i=0; i<1e5+1; i++){
        pcount2[i] = make_pair(count2[i],i);
    }

    sort(count1.begin(),count1.end());
    sort(count2.begin(),count2.end());
    sort(pcount1.begin(),pcount1.end());
    sort(pcount2.begin(),pcount2.end());

    int a = count1[1e5];
    int b = count2[1e5];
    if(pcount1[1e5].second == pcount2[1e5].second){
        if(count1[1e5-1] >= count2[1e5-1]){
            a = count1[1e5-1];
        }
        if(count1[1e5-1] <  count2[1e5-1]){
            b = count2[1e5-1];
        }
    }
    cout << n - a - b << endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){int i,n;
string s;
cin>>s;
n=s.size();
if(n!=6){cout<<"No";return 0;}
if((s[2]==s[3])&&(s[4]==s[5])){cout<<"Yes";}
else{cout<<"No";}
    return 0;}

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

const int MAX = 100000;

vector<int> G[MAX];
int parent[MAX], prenum[MAX], lowest[MAX], timer;
bool visited[MAX];
int V;

void dfs(int current, int prev){
    //訪れた直後の処理
    prenum[current] = lowest[current] = timer;
    timer++;

    visited[current] = true;

    int next;
    for(int i = 0; i < G[current].size(); i++){
        next = G[current][i];
        if(!visited[next]){
            //訪れる前の処理
            parent[next] = current;
            dfs(next, current);
            lowest[current] = min(lowest[current], lowest[next]);
        }else if(next != prev){ //逆辺になっている場合
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }
}

void art_point(){
    for(int i = 0; i < V; i++){
        visited[i] = false;
    }

    timer = 1;

    dfs(0, -1);

    set<int> ap;
    int np = 0;
    for(int i = 1; i < V; i++){ //0の親は見ない
        int p = parent[i];
        if(p == 0) np++;
        else if(prenum[p] <= lowest[i]) ap.insert(p);
    }

    if(np > 1) ap.insert(0);

    for( set<int>::iterator it = ap.begin(); it !=  ap.end(); it++){
        cout << *it << endl;
    }
}

int main(){
    int E;
    cin >> V >> E;

    int s, t;
    rep(i,E){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    art_point();

    return 0;
}


Measured memory_bytes: 6924
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] arr=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			arr[i]=a;
			sum+=a;
		}
		double p=sum/n;
		int min=0;
		int min2=0;
		for(int i=0;i<n;i++)min+=(arr[i]-p)*(arr[i]-p);
		p++;
		for(int i=0;i<n;i++)min2+=(arr[i]-p)*(arr[i]-p);
		if(min<min2)System.out.println(min);
		else System.out.println(min2);
	}
}

Measured memory_bytes: 22996
N = int(input())
A = [0]+list(map(int, input().split()))+[0]
B = [0]*(N+1)
for i in range(N+1):
    B[i] = abs(A[i]-A[i+1])
S = sum(B)
for i in range(N):
    print(S-B[i]-B[i+1]+abs(A[i]-A[i+2]))

Measured memory_bytes: 14048
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll n, a, b; cin >> n >> a >> b;
  ll ope = a + b, ans = n / ope * a;
  n %= ope;
  cout << ans + min(n, a) << '\n';
  return 0;
}


Measured memory_bytes: 256
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
t0 = 0
tn = 0

for i in range(x,n+1):
  if i in a:
    tn += 1
for i in range(x,0,-1):
  if i in a:
    t0 += 1
print(min(t0,tn))

Measured memory_bytes: 3064
/*
* @Author: _dp95
* @Date:   2020-04-04 09:58:15
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 22 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int ar[MAX][MAX], dp[MAX][1<<MAX] ;
int n ;

int sol( int ind, int mask ){
    if( ind == n )
        return 1 ;
    if( dp[ind][mask] != -1 )
        return dp[ind][mask] ;
    int &ans = dp[ind][mask] = 0 ;
    for( int i = 0 ; i < n ; i++ ){
        if( (mask&(1<<i)) or!(ar[ind][i] ) )
            continue ;
        ans += sol( ind+1, mask|(1<<i)); 
        if( ans >= MOD )
            ans %= MOD ;
    }
    return ans ;
}

signed main( ){
  timesaver ;
  cin >> n ;
  for( int i = 0 ; i < n ; i++ )
    for( int j = 0 ; j < n ; j++ )
        cin >> ar[i][j] ;
  mem( dp, -1 ) ;
  cout << sol( 0, 0 ) << nl ;
}

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

int main() {
  vector<string> w(2);
  string t;
  w={"Sunny","Cloudy","Rainy"};
  cin >> t;
  for(int i=0;i<3;i++){
    if(w.at(i)==t){
      cout << w.at((i+1)%3) << endl;
    }
  }
}

Measured memory_bytes: 256
N, D= map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
def d(x, y):
    ans = 0
    for i in range(D):
        ans+=(x[i]-y[i])**2
    return ans
ans = 0
for i in range(N):
    for j in range(i+1, N):
        dis = d(X[i], X[j])
        if dis==int(dis**(1/2))**2 or dis == int(dis**(1/2)+1)**2:
            ans+=1
print(ans)

Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

int main()
{
	int A,B;
	cin >> A >> B;

	cout << (A-1)*(B-1) << endl;
}

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

int main() {

  int N, l, r, sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
  
}


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

struct UnionFind {
	vector<int> par, siz;
	UnionFind(int n): par(n), siz(n, 1) {
		rep(i,n) par[i] = i;
	}
	int find(int x) {
		return par[x] == x ? x: par[x] = find(par[x]);
	}
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return siz[find(x)];
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		uf.unite(a, b);
	}
	int ans = 0;
	rep(i,n) {
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
    IOS;
    int t;
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        string s;
        string AC = "AC", WA = "WA", TLE = "TLE", RE = "RE";
        int ac = 0, tle = 0, wa = 0, re = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> s;
            if (s == AC)
                ac++;
            else if (s == WA)
                wa++;
            else if (s == TLE)
                tle++;
            else
                re++;
        }
        cout << AC << " x " << ac << endl;
        cout << WA << " x " << wa << endl;
        cout << TLE << " x " << tle << endl;
        cout << RE << " x " << re << endl;
    }
}


Measured memory_bytes: 3596
import sys

s = sys.stdin.readline().strip()

def solve(s):
	n = len(s)
	for i in range(n):
		if i%2==0:
			if s[i] == "L":
				return False
		else:
			if s[i] == "R":
				return False
	return True

print("Yes" if solve(s) else "No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  int A = 0;
  vector<int> h(N);
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    cin >> h.at(i);
    if (h.at(i) >= K) A++;
  }
  cout << A << endl;
}

Measured memory_bytes: 16640
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
 
N,K = LI()
p = []
for i in range(N):
    a,b = LI()
    p.append((a,b))
sx = sorted(p)
ans = 10**50
for x,y in sx:
    for x2,y2 in sx:
        if x2 <= x:
            continue
        points = sx.index((x2,y2)) - sx.index((x,y)) + 1
        if points < K:
            continue
        sy = sorted(sx[sx.index((x,y)):sx.index((x2,y2))+1],key=lambda sx: sx[1])
        for j in range(len(sy)-K+1):
            if sy[j][1] <= y and y2 <= sy[j+K-1][1]:
                ans = min(ans, (x2 - x) * (sy[j+K-1][1]-sy[j][1])) 
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> A(N);
    rep(i, N) cin >> A[i].first >> A[i].second;
    ll ret = 1LL << 62;
    rep(i, N) rep(j, i + 1, N) {
        
        vector<pair<ll, ll>> B;
        rep(k, N) {
            if((A[i].second - A[k].second) * (A[j].second - A[k].second) <= 0) {
                B.pb(A[k]);
            }
        }
        sort(all(B));
        if(K <= (int)B.size()){
            rep(k, B.size() - K + 1) {
                ll area = abs(A[i].second - A[j].second) * abs(B[k + K - 1].first - B[k].first);
                ret = min(ret, area);
            }
        }
    }
    output(ret);
    
    return 0;
}


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

using namespace std;

int main()
{
    int a[5], k, i;
    for (i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    cin >> k;
    for (i = 0; i < 4; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {
            if (a[j] - a[i] > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


void merge_cnt(vector<int> &A, set<int> &S){
  int N = A.size();
  if (N == 1){
    S.insert(A[0]); return;
  }
  int n2 = N/2;
  vector<int> B(n2); rep(i, n2) B[i] = A[i];
  vector<int> C(N-n2); rep(i, N-n2) C[i] = A[i+n2];
  set<int> S1,S2;
  merge_cnt(B, S1); merge_cnt(C, S2);
  for (int x : S1) S.insert(x);
  for (int x : S2) S.insert(x);
  for (int x : S1){
    for (int y : S2){
      S.insert(x+y);
    }
  }
}

int main() {
  int N; cin >>N;
  vector<int> A(N); rep(i, N) cin >>A[i];
  set<int> S;
  merge_cnt(A, S);
  int q; cin >>q;
  rep(i, q){
    int m; cin >>m;
    cout <<(S.count(m) ? "yes" : "no") <<endl;
  }
}


Measured memory_bytes: 3128
n=int(input())
h=list(map(int,input().split()))
ans=0
while sum(h):
  a=0
  if h[0]!=0:a+=1
  for i in range(n):
    if a==1 and h[i]==0:
      ans+=1
      a=0
    if h[i]!=0:
      a=1
      h[i]-=1
  ans+=a
print(ans)

Measured memory_bytes: 3064
def updiv(a,b):

    if a % b == 0:
        return a // b
    else:
        return a // b + 1


D,G = map(int,input().split())

pc = []

for i in range(D):

    p,c = map(int,input().split())

    pc.append([i+1,p,c])

pc.reverse()

ans = float("inf")

for j in range(2 ** D):

    j_bin = format(j,'b')
    flags = j_bin.zfill(D)

    num = 0
    score = 0

    for k in range(D):

        if flags[k] == "1":

            num += pc[k][1]
            score += pc[k][1] * pc[k][0] * 100 + pc[k][2]

    if G > score:

        for k in range(D):

            if flags[k] == "0" and score + pc[k][1] * pc[k][0] * 100 >= G:

                plnum = updiv( G - score , pc[k][0] * 100 )
                num += plnum

                score += plnum * pc[k][0] * 100
                break

    if G <= score:

        ans = min(ans,num)
        #print (ans,num,score,flags)

print (ans)

                

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

typedef long long ll;
int MOD = 1000000007;

int main() {
  int N; cin >> N;
  
  ll ans = 0;
  for (int a = 1; a < N; a++) {
    int cur = N / a;
    if (N % a == 0) cur--;
    ans += cur;
  }
  
  cout << ans << endl;
}   

Measured memory_bytes: 3636
x, k, d = map(int, input().split())

x = abs(x)
kk = k - int(x/d)
if kk <= 0:
    print(x - k * d)
    exit()

a = x - int(x/d)*d
if kk % 2 == 0:
    ans = a
else:
    ans = abs(a - d)

print(ans)

Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>b) swap(a,b);
	if(a==1&&b==2) printf("3\n");
	else if(a==1&&b==3) printf("2\n");
	else printf("1\n");
	return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

L,R=MAP()

if R-L+1>2019:
    print(0)
else:
    ans=INF
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans=min(ans, (i%2019)*(j%2019)%2019)
    print(ans)


Measured memory_bytes: 42092
N = int(input())
S = input()
W = [0] * N
E = [0] * N
for i in range(N):
    if i == 0:
        if S[i] == 'W':
            W[i] = 1
        continue
    if S[i] == 'W':
        W[i] = W[i - 1] + 1
    else:
        W[i] = W[i - 1]
for i in range(N - 1, -1, -1):
    if i == N - 1:
        if S[i] == 'E':
            E[i] = 1
        continue
    if S[i] == 'E':
        E[i] = E[i + 1] + 1
    else:
        E[i] = E[i + 1]
A = []
for i in range(N):
    A.append(W[i] + E[i] - 1)
print(min(A))

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

using namespace std;

int main(int argc, char const *argv[]) {
        int char1[26] = {0};
        char a;
        while(cin >> a) {
                if(isupper(a)) a = char(tolower(a));
                char1[int(a-'a')]++;
        }
        for(int i = 0; i < 26; i++) {
                cout << char(i + 'a') << " : " << char1[i] << endl;
        }
        return 0;
}



Measured memory_bytes: 3092
H = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)

array.each_with_index do |num,i|
  i = i+1
  parent = i/2
  left = 2*i
  right = 2*i+1
  output = "node #{i}: key = #{num}, "
  if(parent >= 1)
    output = output + "parent key = " + array[parent-1].to_s + ", "
  end
  if(left <= H)
    output = output + "left key = " + array[left-1].to_s + ", "
  end
  if(right <= H)
    output = output + "right key = " + array[right-1].to_s + ", "
  end
  puts(output)
end



Measured memory_bytes: 6888
#include "bits/stdc++.h"
using namespace std;
#define lint long long
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
#define P pair<int, int>
#define D pair<double, double>
//using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int main() {
	cout << "square1001" << endl;
}


Measured memory_bytes: 3084