akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  // 入力
  ll N, K;
  cin >> N >> K;
  vector<ll> x(N + 1), y(N + 1);
  vector<char> c(N + 1);
  for (int i = 1; i <= N; ++i) { cin >> x[i] >> y[i] >> c[i]; }

  // 各クエリを(0, 0)から(K -1, K - 1) の矩形にマッピングし、各マスの個数をカウント
  ll K2 = 2 * K;
  vector<vector<ll>> cs(K2, vector<ll>(K2, 0));
  for (int i = 1; i <= N; i++) {
    if (c[i] == 'B') { cs[x[i] % K2][y[i] % K2]++; }
    else { cs[(x[i] + K) % K2][y[i] % K2]++; }
  }
  // dp[i][j] はマス(i, j) から K*K のマスを黒で塗るときに叶えられる要望の数
  vector<vector<ll>> dp(K2, vector<ll>(K2, 0));
  // 累積和を用いて解を求める
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      dp[0][0] += cs[i][j];
    }
  }
  for (int i = 1; i < K2; i++) {
    dp[i][0] = dp[i - 1][0];
    dp[0][i] = dp[0][i - 1];
    for (int j = 0; j < K; j++) {
        dp[i][0] += cs[(i + K - 1) % K2][j] - cs[i - 1][j];
        dp[0][i] += cs[j][(i + K - 1) % K2] - cs[j][i - 1];
    }
  }
  for (int i = 1; i < K2; i++) {
      for (int j = 1; j < K2; j++) {
          dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] +
                     cs[(i + K - 1) % K2][(j + K - 1) % K2] +
                     cs[i - 1][j - 1] - cs[i - 1][(j + K - 1) % K2] -
                     cs[(i + K - 1) % K2][j - 1];
      }
  }
  ll ans = 0;
  for (int i = 0; i < K2; i++) {
      for (int j = 0; j < K2; j++) {
          ans = max(ans, dp[i][j] + dp[(i + K) % K2][(j + K) % K2]);
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 64640
import numpy as np
N, D = map(int, input().split())
a = list(input().split() for _ in range(N))
aa = np.array(a, dtype='i8')

cnt = 0
for i in range(N):
    d = np.linalg.norm(aa[i])
    if d <=D:
        cnt += 1
print(cnt)

Measured memory_bytes: 101436
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    cout << (A[0] * A[1]) / 2 << endl;

    return 0;
}


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

int findSumofDigits(int n){
    int sum = 0;
    while (n > 0) {
        sum+= n%10;
        n/=10;

    }
    return sum;
}

int main(){
    int N,A,B;
    cin >> N >> A>>B;
    int total = 0;
    for (int i=1; i<=N; ++i){
        int sum = findSumofDigits(i);
        if (sum >= A && sum <= B){
            total+=i;
        }
    }
    cout << total << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, x;

int main() {
    cin >> x;
    n = 0;
    while (x > 0) {
        ++n;
        x -= n;
    }
    cout << n << endl;
    return 0;
}


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

long long n;
string s[2];

long long solve();

int main() {
  cin >> n >> s[0] >> s[1];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 3;
  for(long long i = 0; i < n; ++i) {
    if(i == 0 && s[0][0] != s[1][0]) {
      ans = 6;
      ++i;
      continue;
    }
    if(i == 0) continue;
    if(s[0][i] == s[1][i]) {
      if(s[0][i - 1] == s[1][i - 1]) ans *= 2;
      ans %= N;
    }
    else {
      if(s[0][i - 1] == s[1][i - 1])
        ans *= 2;
      else
        ans *= 3;
      ans %= N;
      ++i;
    }
  }
  return ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc123_b

# input
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
arr = [a, b, c, d, e]
# output
def get_1(n):
    n = n%10
    return n if n!=0 else 10
def ceil(n):
    import math
    n = n/10
    n = math.ceil(n)
    n = n * 10
    return n
last = min(arr, key=get_1)
arr.remove(last)
arr = list(map(ceil, arr))
ans = sum(arr) + last
print(ans)


Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(' ');
	var ball_num = parseInt(input[0]);
	var color_num = parseInt(input[1]);
	var patterns = 1;
    for(var i = 0; i < ball_num; i++){
        if(i === 0){
            patterns = patterns * color_num;
        } else {
            patterns = patterns * (color_num - 1); 
        }
    }
    console.log(patterns);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n = int(input())

j = list()
for _ in range(n):
    string = input()
    j.append(string)

ac = j.count("AC")
wa = j.count("WA")
tle = j.count("TLE")
re = j.count("RE")
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 16264
import math

n = int(input())
nodes = []
for i in range(n):
    nodes.append([int(x) for x in input().split(' ')])

sums = 0

for i in range(n):
    for j in range(n):
        if i != j:
            sums += math.sqrt((nodes[i][0] - nodes[j][0]) ** 2 + (nodes[i][1] - nodes[j][1]) ** 2)

print(sums / n)

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

int main() {
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N+1);
    for (int i = 1; i <= N; i++) cin >> a[i];
    int tmp = 1;
    vector< vector<int> > ans(H, vector<int>(W));
    pair<int, int> now = make_pair(0, 0);
    bool flag = true;
    while (tmp <= N) {
        while (a[tmp] > 0) {
            a[tmp]--;
            ans[now.first][now.second] = tmp;
            if (flag && now.second < W-1) now.second++;
            else if (flag && now.second >= W-1) {
                now.first++;
                flag = false;
            }
            else if (!flag && now.second > 0) now.second--;
            else if (!flag && now.second <= 0) {
                now.first++;
                flag = true;
            }
        }
        tmp++;
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (j) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

seen = set()
t = ini()
for _ in range(t):
    s = ins()
    seen.add(s)
print(len(seen))

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

#define MAX 151200

int main(){
  vector<int> cubic;
  vector<int> tetra;

  cubic.push_back(0);
  for(int i = 1; i * i * i <= MAX; i++){
    cubic.push_back(i * i * i);
  }
  tetra.push_back(0);
  for(int i = 1; i * (i + 1) * (i + 2) / 6 <= MAX; i++){
    tetra.push_back(i * (i + 1) * (i + 2) / 6);
  }

  int n;

  while(cin >> n, n){
    int ans = 0;

    for(int i = 0; i < cubic.size(); i++){
      for(int j = 0; j < tetra.size(); j++){
	int sum = cubic[i] + tetra[j];

	if(sum <= n){
	  ans = max(ans, sum);
	}
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1220
import java.io.*;
public class Main {
	public static void main(String[] args)
	throws java.io.IOException{
				int c = System.in.read();
				if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o'){
					System.out.println("vowel");
				}else{
					System.out.println("consonant");
				}
	}
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll a, b;
  string s, t, u;
  cin >> s >> t >> a >> b >> u;
  if (s == u) {
    cout << a - 1 << " " << b << endl;
  } else {
    cout << a << " " << b - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int n;
int a[100];
int main(){
    int count=0;
    int m;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        m = i;
        for(int j=i;j<n;j++){
            if(a[m] > a[j]) m = j;
        }
        if(m != i){
            swap(a[i], a[m]);
            count++;
        }
    }
    cout << a[0];
    for(int i=1;i<n;i++){
        cout << " " << a[i];
    }
    cout << endl;
    cout << count << endl;

}

Measured memory_bytes: 1160
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846
#define IOS ios::sync_with_stdio(0);cin.tie(0);
typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
const int p1 = 31;

int main() { IOS

	//Use long long
    ll n;
    cin>>n;
    string ans ="";
    while(n)
    {   ll k = n/26;
        ll z = n%26;
        if(z==0)
        {   k--;
            ans = (char)'z' + ans;

        }
        else 
        {
            ans = (char)('a' + z - 1) + ans;
        }
        n=k;
    }
    cout<<ans;


 	return 0;
            
}

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

char_dic = {}
for i in range(N):
  char = S[i]
  if char not in char_dic:
    char_dic[char] = 2
  else:
    char_dic[char] += 1
    
prod = 1
for key in char_dic:
  prod *= char_dic[key]
  
print((prod-1)%(10**9+7))

Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
	int i,j,t,a,b,c,d,e=1,r[128],k,s[128]={0};
	scanf("%d",&t);
	for(i=1;i<=t*(t-1)/2;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c>d) s[a]+=3;
		if(c<d) s[b]+=3;
		if(c==d){
			s[a]++;
			s[b]++;
		}
	}
	for(i=3*t;i>=0;i--){
		k=0;
		for(j=1;j<=t;j++){
			if(s[j]==i){
				r[j]=e;
				k++;
			}
		}
		e+=k;
	}
	for(i=1;i<=t;i++){
		printf("%d\n",r[i]);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

class Main{

    public static void main(String args[]){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	long[] a=new long[n];
	for(int i=0;i<n;i++){
	    a[i]=sc.nextLong();
	}
	long sum=0;
	for(int i=0;i<n;i++){
	    sum+=a[i];
	}
	long nn=n;
	long consume=nn*(nn+1)/2;
	if(sum%consume!=0){
	    System.out.println("NO");
	    return;
	}

	long sump=sum/consume;
	long cnt=0;
	boolean isok=true;
	for(int i=0;i<n;i++){
	    //a[i-1]+(sump-p)=a[i]+(n-1)*p
	    long chil=(a[(i-1+n)%n]+sump-a[i]);
	    if(chil<0 || chil%n!=0) isok=false;
	    long p=chil/n;
	    if(a[(i-1+n)%n]+(sump-p)!=a[i]+(n-1)*p) isok=false;
	    if(p<0) isok=false;
	    cnt+=p;
	}
	if(isok && sump==cnt){
	    System.out.println("YES");
	}
	else{
	    System.out.println("NO");
	}
	return;
    }
    

    
}


Measured memory_bytes: 58176
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   string S;
   cin>>S;
   set<char>k;
   for(int i=0;i<4;i++){
       k.insert(S[i]);
   }
   if(k.size()==2){cout<<"Yes"<<endl;}
   else{cout<<"No"<<endl;}
return 0;}

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


int main() {
	ll N;
  cin >> N;
  vec H(N);
  for(int i=0;i<N;i++)cin >>H[i];
  int memo =0;
  int ans =0;
  for(int i=0;i<N-1;i++){
   if(H[i] >= H[i+1]){
    memo++;
     ans = max(ans,memo);
   }
    else memo=0;
  }
  cout <<ans <<endl;
}
  


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from functools import lru_cache

@lru_cache(None) # 再帰にしつつ、下から計算することで再帰処理をしない
def subsets(U): # O(2^k)
    # base case
    if U == 0:
        return [0]
    # recursion
    d = U.bit_length() - 1
    U ^= 1 << d
    prev = subsets(U)
    return prev + [U | 1 << d for U in prev]

def resolve():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))

    # O(n^2 * 2^n)
    state_to_score = [0] * (1 << n)
    for U in range(1 << n):
        for i in range(n):
            if (U >> i) & 1 == 0:
                continue
            for j in range(i):
                if (U >> j) & 1:
                    state_to_score[U] += A[i][j]

    # dp[i][U] : i まで見て U <= {1, ..., n} を grouping したときの max
    # msb(U) = i ならば dp[i][U] = dp[i + 1][U] = ... = dp[n - 1][U] なので dp は使いまわせる
    # dp[i + 1][U | 1 << (i + 1)] = max((V + {i + 1} の score) + dp[i][W]) for all V + W = U
    dp = [-INF] * (1 << n)
    dp[0] = 0
    for i in range(n): # 既に U = 0, ..., 2^i - 1 までは確定している
        for U in range(1 << i): # O(2^i) これから 2^i, ..., 2^(i + 1) - 1 を確定させる
            for V in subsets(U): # O(2^k) where k = popcount(U)
                W = U ^ V
                dp[U | 1 << i] = max(dp[U | 1 << i], state_to_score[V | 1 << i] + dp[W])

    # 計算量は sum_{0 <= i < n} sum_{0 <= U < 2^i} 2 ^ popcount(U)
    # = sum_{0 <= i < n} sum_{0 <= k <= i} iCk * 2^k = (3^n - 1) / 2
    print(dp[-1])
resolve()

Measured memory_bytes: 172552
h, w = map(int, input().split())
a = []
delrow = []
delcol = []
cnt = 0

for i in range(h):
    a.append(list(input()))

for i in range(h):
    if set(a[i]) == {"."}:
        delrow.append(i)

for i in range(w):
    for j in range(h):
        if a[j][i] != ".":
            break
        else:
            cnt += 1
        if cnt == h:
            delcol.append(i)
    cnt = 0
        
for i in delrow [::-1]: #行を削除
    del a[i]
for i in delcol [::-1]: #列を削除
    for j in range(len(a)):
        del a[j][i]

for i in range(len(a)):
    print(*a[i], sep="")

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    LL T;
    cin >> T;
    LL ans = T;
    LL prev_t = 0;
    REP0(i, N)
    {
        LL t;
        cin >> t;
        ans += min(T, (t - prev_t));
        prev_t = t;
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main(){
    int K;
    cin >> K;
    queue<ll> lunlun;
    for (int i=1; i<=9; i++) {
        lunlun.push(i);
    }
    ll x;
    for (int i=0; i<K; i++) {
        x = lunlun.front();
        lunlun.pop();
        if (x%10 != 0) lunlun.push(10*x + x%10 - 1);
        lunlun.push(10*x + x%10);
        if (x%10 != 9) lunlun.push(10*x + x%10 + 1);
    }
    cout << x << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
ll n;
vector<pair<ll,ll>> vec[10000];
vector<ll> dis(10000,INFLONG);
vector<ll> visited(10000,0);
void dij(ll k){
  priority_queue<pair<ll,ll>> pq; // -c -> v

  dis[k] = 0;
  pq.push(make_pair(0,k));
  pair<ll,ll> f;
  ll u,v;
  while(!pq.empty()){
    f = pq.top();
    pq.pop();
    u = f.second;
    if(visited[u]){
      continue;
    }
    visited[u] = 1;
    for(auto itr:vec[u]){
      v = itr.second;
      if(visited[v]){
        continue;
      }
      if(dis[v] > dis[u] + itr.first){
        dis[v] = dis[u] + itr.first;
        pq.push(make_pair(dis[v] * (-1),v));
      }
    }
  }
}
int main(){
  cin >> n;
  ll u,k,v,c;
  rep(i,n){
    cin >> u >> k;
    rep(j,k){
      cin >> v >> c;
      vec[u].emplace_back(make_pair(c,v));
    }
  }
  dij(0);
  rep(i,n){
    cout << i << " " << dis[i] << endl;
  }
}



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

int prime[100005];
int p2[100005];

int main() {
  int Q;
  cin >> Q;
  REP(i, 100005) prime[i] = 1;
  prime[0] = 0;
  prime[1] = 0;
  for (int i=2; i*i<=100005; i++ ) {
    if ( prime[i] == 1 ) {
      for (int j=2; i*j<=100005; j++ ) {
        prime[i*j] = 0;
      }
    }
  }
//  REP(i, 100) cout << i << " : " << prime[i] << endl;
  for ( int i=3; i<100005; i+=2 ) {
    if ( prime[i] == 1 && prime[(i+1)/2] == 1 ) p2[i] = 1;
  }
  REP(i, 100005) p2[i+1] += p2[i];
//  REP(i, 100) cout << i << " : " << p2[i] << endl;
  REP(i,Q) {
    int l,r;
    cin >> l >> r;
    int ans = p2[r] - p2[l-1];
    cout << ans << endl;
  }
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	ll sum=a+b;
	ll ans=n/sum*a;
	ll sum2=n%sum;
	ans+=min(a,sum2);
	cout <<ans;
	// your code goes here
	return 0;
}

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

//包除原理

public class Main {
    static long div=1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        //長さnの配列の種類 10^ｎ通り
        //0と9両方が含まれない　8^n通り
        //0か9の一方が　〃　　　(9^n)*2-8^n通り
        long ans=pow(10, n)-pow(9, n)*2+pow(8, n);
        System.out.println(((ans % div) + div) % div);
    }

    public static long pow(long a,long b) {
        long re=1;
        for (int i = 0; i < b; i++)  re=(re*a)%div;
        return re;
    }
}




Measured memory_bytes: 35676
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

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


    if(n==1){
        cout << 1 << endl;
    }
    else if(n==2 || n==3) cout << 2 << endl;
    else if(4<=n && n<8) cout << 4 << endl;
    else if(8<=n && n<16) cout << 8 << endl;
    else if(16<=n && n<32) cout << 16 << endl;
    else if(32<=n && n<64) cout << 32 << endl;
    else if(64<=n && n<101) cout << 64 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
   
struct segtree{
   
  bool check(set< P > &T,int a,int b){
    set<P> :: iterator it;
    it=T.lower_bound(P(a,a)); 
    if(it!=T.end()&&it->first <= b)return true;
    if(it!=T.begin()&&a<=(--it)->second)return true;
    return false;
  }
 
  void insert(set<P> &T,int a,int b){
    set<P> :: iterator it;
    while(1){
      it=T.lower_bound(P(a,a));
      if(it!=T.end()&&it->first<=b){
        a=min(a,it->first);
        b=max(b,it->second);
        T.erase(it);      
      }else if(it!=T.begin()&&a<=(--it)->second){
        a=min(a,it->first);
        b=max(b,it->second);
        T.erase(it);
      }else break;
    }
    T.insert(P(a,b));
  }
   
  set< P > t[(1<<19)],u[(1<<19)];
   
  void init(){
    for(int i=0;i<(1<<19);i++)t[i].clear(),u[i].clear();
  }
   
  bool check(int a,int b,int c,int d,int k,int l,int r){
    if(b<=l||r<=a)return false;
    if(check(t[k],c,d))return true;
    if(a<=l&&r<=b)return check(u[k],c,d);
    int m=(l+r)/2;
    return check(a,b,c,d,k*2+1,l,m)||check(a,b,c,d,k*2+2,m,r);
  }
 
  void insert(int a,int b,int c,int d,int k,int l,int r){
    if(b<=l||r<=a)return;
    insert(u[k],c,d);
    if(a<=l&&r<=b){insert(t[k],c,d);return;}
    int m=(l+r)/2;
    insert(a,b,c,d,k*2+1,l,m);insert(a,b,c,d,k*2+2,m,r);
  }
};
 
segtree T;

#define MAX_N 100005
int N;
int ax[MAX_N],ay[MAX_N],bx[MAX_N],by[MAX_N];

int main(){
  scanf("%d",&N);
  vector<int> X(N+N),Y(N+N);
  
  for(int i=0;i<N;i++){
    scanf("%d %d %d %d",&ax[i],&ay[i],&bx[i],&by[i]);
    if(ax[i]>bx[i])swap(ax[i],bx[i]);
    if(ay[i]>by[i])swap(ay[i],by[i]);
    
    X[i]=ax[i],X[i+N]=bx[i];
    Y[i]=ay[i],Y[i+N]=by[i];
  }

  sort(X.begin(),X.end());
  X.erase( unique( X.begin(),X.end() ), X.end() );

  sort(Y.begin(),Y.end());
  Y.erase( unique( Y.begin(),Y.end() ), Y.end() );
  
  for(int i=0;i<N;i++){
    ax[i]=lower_bound(X.begin(),X.end(),ax[i])-X.begin()+1;
    ay[i]=lower_bound(Y.begin(),Y.end(),ay[i])-Y.begin()+1;
    bx[i]=lower_bound(X.begin(),X.end(),bx[i])-X.begin()+1;
    by[i]=lower_bound(Y.begin(),Y.end(),by[i])-Y.begin()+1;
  }

  for(int i=0;i<N;i++){
    if( T.check(ax[i],bx[i]+1,ay[i],by[i],0,0,(1<<18)) ){
      printf("0\n");
    }else{
      T.insert(ax[i],bx[i]+1,ay[i],by[i],0,0,(1<<18));
      printf("1\n");
    }
  }
  return 0;
}

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

const ll INF = 1e18;

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

  vector<vector<ll>> dp(n, vector<ll>(2, -INF));

  for (int i = 1; i < n; ++i) {
    if (i == 1) {
      dp[1][0] = a[0] + a[1];
      dp[1][1] = -a[0] - a[1];
      continue;
    }
    dp[i][0] = max(dp[i][0], dp[i-1][0] + a[i]);
    dp[i][0] = max(dp[i][0], dp[i-1][1] + a[i]);
    dp[i][1] = max(dp[i][1], dp[i-1][0] - 2 * a[i-1] - a[i]);
    dp[i][1] = max(dp[i][1], dp[i-1][1] + 2 * a[i-1] - a[i]);
  }

  ll ans = max(dp[n-1][0], dp[n-1][1]);
  cout << ans << endl;
  return 0;
}

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

#define mx 1000005
using namespace std;

int n, ans = 1;
bool used[mx];

int main(){
	scanf("%d", &n);

	while(!used[n]){
		used[n] = true;
		n = n&1 ? 3*n+1 : n/2;
		ans++;
	}

	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define MAXN 200010
int n, a[MAXN], Q, pre0[MAXN], pre1[MAXN], tree[MAXN << 2], tree2[MAXN << 2];
void getmin(int & a, int b) {if (a > b) a = b;}
struct Query {
	int l, r;
	inline bool operator < (const Query & b) const {return l == b.l ? r < b.r : l < b.l;}
	void read() {scanf("%d%d", &l, &r);}
} qs[MAXN];
void modify(int u, int l, int r, int tar, int v) {
	if (l == r) {
		tree[u] = v;
		tree2[u] = v - pre0[tar] + pre1[tar];
		return ;
	}
	int mid = l + r >> 1;
	if (tar <= mid) modify(u << 1, l, mid, tar, v);
	else modify(u << 1 | 1, mid + 1, r, tar, v);
	tree[u] = min(tree[u << 1], tree[u << 1 | 1]);
	tree2[u] = min(tree2[u << 1], tree2[u << 1 | 1]); 
}
int query(int u, int l, int r, int L, int R, int * tree) {
	if (L <= l && r <= R) return tree[u];
	int mid = l + r >> 1, res = 0x3f3f3f3f;
	if (L <= mid) getmin(res, query(u << 1, l, mid, L, R, tree));
	if (mid < R) getmin(res, query(u << 1 | 1, mid + 1, r, L, R, tree));
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		pre0[i] = pre0[i - 1] + !a[i];
		pre1[i] = pre1[i - 1] + a[i];
	}
	scanf("%d", &Q);
	for (int i = 1; i <= Q; ++i) qs[i].read();
	sort(qs + 1, qs + 1 + Q);
	memset(tree, 0x3f, sizeof tree);
	memset(tree2, 0x3f, sizeof tree2);
	modify(1, 0, n, 0, pre1[n]);
	for (int i = 1; i <= Q; ++i) {
		int tx = min(	query(1, 0, n, 0, qs[i].l - 1, tree) - pre0[qs[i].l - 1] + pre1[qs[i].l - 1], 
						query(1, 0, n, qs[i].l, qs[i].r - 1, tree2))
				+ pre0[qs[i].r] - pre1[qs[i].r];
		getmin(tx, query(1, 0, n, qs[i].r, qs[i].r, tree));
		modify(1, 0, n, qs[i].r, tx);
	}
	printf("%d\n", query(1, 0, n, 0, n, tree));
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
string  a,b,u;
cin>>a>>b;
cin>>x>>y;
 cin>>u;

  if(u==a){
    x--;
  }
  else if(u==b){
    y--;
  }
    cout<<x<<" "<<y;
}


Measured memory_bytes: 3580
import sys
input = sys.stdin.readline
import heapq

N,M = map(int,input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A)
    # 計算誤差を減らすためにtmpを正に直してシフト演算している
    heapq.heappush(A, (-1)*(-tmp >> 1))

print(-sum(A))

Measured memory_bytes: 14168
function main(input) {
  const [ h, w, k ] = input[0].trim().split(" ").map(i => parseInt(i));
  const c = [];
  for(let i=0;i<h;i++){
    c[i] = new Array(w);
    c[i] = input[i+1].trim().split("");
  }

  const H = new Array(h).fill(null).map((a, i) => i+1);
  const W = new Array(w).fill(null).map((a, i) => i+1);

  let h_pat = [[]];
  let w_pat = [[]];

  for(let i=1;i<=h;i++){
    h_pat = h_pat.concat(kumiawase(H, i));
  }

  for(let i=1;i<=w;i++){
    w_pat = w_pat.concat(kumiawase(W, i));
  }

  let count = 0;

  for(let i=0;i<h_pat.length;i++){
    for(let j=0;j<w_pat.length;j++){
      let cnt = 0;
      for(let l=1;l<=c.length;l++){
        if(!(h_pat[i].includes(l))){
          for(let s=1;s<=w;s++){
            if(!(w_pat[j].includes(s))){
              if(c[l-1][s-1]==="#"){
                cnt++;
              }
            }
          }
        }
      }
      if(cnt === k){
        count++;
      }
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

function kumiawase(balls, nukitorisu){
  var arrs, i, j, zensu, kumis;
  arrs = [];
  zensu = balls.length;
  if(zensu < nukitorisu){
    return;
  }else if(nukitorisu == 1){
    for(i = 0; i < zensu; i++){
      arrs[i] = [balls[i]];
    }
  }else{
    for(i = 0; i < zensu - nukitorisu + 1; i ++){
      kumis = kumiawase(balls.slice(i + 1), nukitorisu - 1);
      for(j = 0; j < kumis.length; j ++){
        arrs.push([balls[i]].concat(kumis[j]));
      }
    }
  }
  return arrs;
}

Measured memory_bytes: 32652
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define Y {cout<<"YES"<<endl;return 0;}
#define pb(x) push_back(x)
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f,maxn=2e5+100;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
ll n,k,c[2005][2005]={0}; 
void pre()
{
	c[0][0]=1;
	for(int i=1;i<=2000;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
}
int main()
{
	cin>>n>>k;
	pre();
	for(int i=1;i<=k;i++)
	{
		ll n1=i-1;
		ll ban=c[k-1][n1];
		ll ans=(c[n-k+1][i]*ban)%mod;
		cout<<ans<<endl; 
	}
} 

Measured memory_bytes: 30208
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)

int main()
{
    fast;
    ll n;
    cin >> n;
    vl v(n);
    ll sum = 0;
    f(i, 0, n)
    {
        cin >> v[i];
        sum += v[i];
    }
    test
    {
        ll a, b;
        cin >> a >> b;
        ll ans = sum;
        ans -= v[a - 1];
        ans += b;
        cout << ans << "\n";
    }
}


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

int main(){
    set<int> color;
    int tmp;
    rep(i, 3){
        cin >> tmp;
        color.insert(tmp);
    }
    cout << color.size() << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int k;
	scanf("%d",&k);
	if(k%2==0){
		printf("%d\n",(k/2)*(k/2));
	}else{
		printf("%d\n",(k/2)*(k/2+1));
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m,i,s,t,p[1<<17],q;
int root(int u){
  return p[u]==u?u:p[u]=root(p[u]);
}
int main(void){
  for(i=0;i<1<<17;i++)p[i]=i;
  cin>>n>>m;
  while(m--){
    cin>>s>>t;
    s=root(s);
    t=root(t);
    // if(s>t)swap(s,t);
    if(s!=t)p[t]=s;
  }
  cin>>q;
  while(q--){
    cin>>s>>t;
    cout<<(root(s)==root(t)?"yes":"no")<<endl;
  }
  return 0;
}



Measured memory_bytes: 3628
/* ex3_2
   urah  */

#include <stdio.h>

int main(void){
    int num;

    // 入力受け取り
    scanf("%d", &num);

    // 条件分岐
    if (num%10 == 3) {    // 1の位の数字を見ていく
        printf("bon");
    } else if (num%10 == 0 || num%10 == 1 || num%10 == 6 || num%10 == 8){
        printf("pon");
    } else {
        printf("hon");
    }

    return 0;
}


Measured memory_bytes: 1700
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CFolia {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N+1);
        vc<lint> sum(N+1, 0);
        for(auto& a : A) in>>a;
        sum[N] = A[N];
        for(int i=N-1;0<=i;--i) sum[i] = sum[i+1] + A[i];
        lint ans = 0, par = 1;
        REP(i, N+1){
            lint cur = min((i==0 ? 1ll : 2 * par), sum[i]);
            if(cur<A[i]){
                out<<"-1\n";
                return;
            }
            ans += cur;
            par = cur - A[i];
        }
        out<<ans<<'\n';
    }
};


int main() {
	CFolia solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,s=0;
  cin>>n;
  map <int,int> a;
  for (int i=0;i<n;i++)
  {
  	cin>>t;
  	if (a[t]==0)
  	{
  		s++;a[t]=1;
  	}
  	else
  	{
  		s--;a[t]=0;
  	}
  }
  cout<<s;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> v(n);
    set<string> s;
    for (int i = 0; i < n; i++) {
        string w;
        cin >> w;
        v.at(i) = w;
        s.insert(w);
    }
    bool on_rule = true;
    if (s.size() != v.size())
        on_rule = false;
    else {
        for (int i = 0; i < n-1; i++) {
            if (v.at(i).back() != v.at(i+1).front())
                on_rule = false;
        }
    }
    if (on_rule)
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;

double dist(double a, double b){
	return a*a + b*b;
}

int main(){
	
	int n; cin >> n;
	double x[n+7], y[n+7];
	double X = 0, Y = 0, d, e;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		X += x[i]; Y += y[i]; 
	}

	X /= n; Y /= n;

	double P = 0.1;
	for(int i = 0; i < 50000; i++){
		int f = 0;
		d = dist(X-x[0], Y-y[0]);
		for(int j = 1; j < n; j++){
			e = dist(X-x[j], Y-y[j]);
			if(e > d){
				d = e; f = j;
			}
		}
		X += (x[f]-X)*P;
		Y += (y[f]-Y)*P;
		P *= 0.999;
	}

	cout << setprecision(15) << sqrt(d) << '\n';

	return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    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);
return res;
}




int main(){
	int H, W, N;
	cin >> H >> W >> N;
	vector<vector<int>> M(H, vector<int>(W, 0));
	int color;
	int x = 0;
	for(int i = 1; i <= N; i++){
		cin >> color;
		for(int j = 0; j < color; j++){
			M.at(x / W).at(x % W) = i;
			x++;
		}
	}
	for(int i = 0; i < H; i++){
		if(i % 2 == 1){
			reverse(all(M.at(i)));
		}
		for(int j = 0; j < W; j++){
			cout << M.at(i).at(j) << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 384
import numpy as np

N,K = list(map(int, input().split()))
h = []
for _ in range(N):
    h.append(int(input()))
h = sorted(h)
res = h[N-1] - h[0]
for i in np.arange(0,N-K+1,1):
    tmp = h[i+K-1] - h[i]
    if res > tmp:
        res = tmp
    
print(res)
    


Measured memory_bytes: 17496
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    v[0]--;
    for (int i = 1; i < n; ++i) {
        if(v[i-1] > v[i]){
            puts("No");
            return 0;
        }else if(v[i-1] < v[i]) v[i]--;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll A, B;
  cin >> A >> B;

  rep(i, 10000) {
    if ((ll)(i * 0.08) == A && (ll)(i * 0.1) == B) {
      COUT(i);
      return 0;
    }
  }
  COUT(-1);
  // ll X = A / 0.08;
  // ll Y = B / 0.1;
  // debug(X);
  // debug(Y);
  // ll M = max(X, Y);

  // if ((ll)(M * 0.08) == A && (ll)(M * 0.1) == B) {
  //   COUT(X);
  // } else {
  //   COUT(-1);
  // }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int[] A = new int[N];

    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    sc.close();

    Set<Integer> hashSet = new HashSet<Integer>();

    for (int i = 0; i < N; i++) {
      if (hashSet.contains(A[i])){
        hashSet.remove(A[i]);
      } else {
        hashSet.add(A[i]);
      }
    }

    System.out.println(hashSet.size());

  }

}

Measured memory_bytes: 54588
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp[5],tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    rep(i,3)cin>>tmp[i];
    sort(tmp,tmp+3);
    Cout(tmp[0]+tmp[1]);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    private static Scanner scr;
	public static void main(String args[]) throws IOException{
	    scr = new Scanner(System.in);
		while (true){
		    try{
				String[] str = scr.nextLine().split(" ", 0);
				int x = Integer.parseInt(str[0]);
				int y = Integer.parseInt(str[1]);
				int s = Integer.parseInt(str[2]);
				if (x==0 && y==0 && s==0) break; //??\?????????
				System.out.println( MaxPrice(x, y, s) );
			}catch(Exception e){
				System.err.println("Exception");
				break;
			}
        }
	}
	
	private static int MaxPrice(int x, int y, int s){
		int max = 0;
		int p=0;
	    for(int i=1; i<=s; i++){
	    	//for(int j=s; j>=s/2; j--){
		    for(int j=i; j<=s; j++){
	    		if(Tax(i,j,x)==s){
	    			if((p=Tax(i,j,y))>max) max=p;
	    		}
	    	}
	    }
	    return max;
	}
	private static int Tax(int a, int b, int tax){
		return (a*(100+tax)/100) + (b*(100+tax)/100);
	}
}

Measured memory_bytes: 27228
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using pint = tuple<int64_t, int64_t>;
using vint = vector<int64_t>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<(itr==--v.end())?"\n":" ";}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    vint v(5); vin(v);
    sort(all(v), 
        [](int x, int y){
             if(x % 10 == 0) return true;
             if(y % 10 == 0) return false;
             return x % 10 > y % 10;
        });
    int ans = 0;
    rep(i, 4) {
        ans += v[i];
        if(v[i] % 10 > 0) ans += 10 - v[i] % 10;
    }
    println(ans + v[4]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, x;
	while (scanf("%d%d", &n, &x) == 2 && (n|x) != 0) {
		int i, j;
		int count = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				int k = x - i - j;
				if (j < k && k <= n) count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}


Measured memory_bytes: 2132
import fractions
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
B[0] = A[0]
for i in range(1, N-1):
    B[i] = fractions.gcd(A[i], B[i-1])

C = [0]*N
C[-1] = A[-1]
for i in reversed(range(1, N - 1)):
    C[i] = fractions.gcd(C[i+1], A[i])

ans = max(B[N-2], C[1])
for i in range(N-2):
    ans = max(ans, fractions.gcd(B[i], C[i+2]))
print(ans)


Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s; i < n; i++)
typedef long long ll;
typedef pair<int, int> ii;
const int maxn = 100005;
int N, M;
vector<int> g[maxn];
int d[maxn];
int dp(int a){
	if(d[a]!=-1)return d[a];
	int ans = 0;
	for(int from : g[a]){
		ans = max(ans, dp(from)+1);
	}
	return d[a] = ans;
}


int main(){
	cin>>N>>M;
	rep(i,0,M){
		int x,y;cin>>x>>y;
		g[y].push_back(x);
	}
	memset(d,-1,sizeof d);
	int ans = 0;
	rep(i,1,N+1) ans = max(ans, dp(i));
	cout<<ans<<endl;
}

Measured memory_bytes: 10624
#include <stdio.h>

long pow(long x, long y){
    long ret = 1;
    for(long i=0;i<y;i++){
        ret *= x;
    }
    return ret;
}

int main(void){

    long n;
    long k;
    scanf("%ld %ld", &n, &k);

    long i = 0;
    while(n >= pow(k, i)){
        i++;
    }

    printf("%ld\n", i);


    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n, int mod) {
    if (n == 0) { return 1 % mod; }
    int x = rui(a, n / 2, mod);
    x *= x; x %= mod;
    if (n % 2 == 1) { x *= a; x %= mod; }
    return x;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vel uni(vel &x) {
    if (x.size() == 0) { return x; }
    sor(x);
    int n = x.size();
    vel ans(1, x[0]);
    for (int j = 1; j < n; j++) {
        if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
    }
    x = ans;
    return x;
}
signed main() {
    int L = 7000;
    int M = 6900;
    int h, w; cin >> h >> w;
    vvel a(h+1, vel(w+1,0));
    vvel b = a;
    vvel diff = a;
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            cin >> b[i][j];
            diff[i][j] = abs(a[i][j] - b[i][j]);
        }
    }
    V<V<veb>> dp(h+1, V<veb>(w+1, veb(L, false)));
    dp[0][0][diff[0][0]] = true;
    rep(i, h) {
        rep(j, w) {
            rep(k, M) {
                if (dp[i][j][k]) {
                    dp[i + 1][j][k + diff[i+1][j]] = true;
                    dp[i][j + 1][k + diff[i][j+1]] = true;
                    dp[i + 1][j][abs(k - diff[i + 1][j])] = true;
                    dp[i][j + 1][abs(k - diff[i][j + 1])] = true;
                }
            }
        }
    }
    int ans = L;
    rep(k, L) {
        if (dp[h - 1][w - 1][k]) { 
            ans = k; break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

// void bt(vector<vector<int>>&mat,int p, int i, int cost){
//     //cout<<i<<" ";
//     if(i==n){
//         //cout<<cost<<" ";
//         if(cost>ans)
//             ans=cost;
//         return;
//     }
//     for(int k=0; k<3; k++){
//         if(k==p)
//             continue;
//         cost+=mat[i][k];
//         bt(mat, k, i+1, cost);
//         cost-=mat[i][k];
//     }
// }
int main(){
    int n,ans;
    cin>>n;
    //cout<<n<<"\n";
    vector<vector<int>>mat(n,vector<int>(3,0));
    
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>mat[i][j];
         //   cout<<mat[i][j]<<" ";
        }
    }
    
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            int mx=INT_MIN;;
            for(int k=0;k<3;k++){
                if(k==j)
                    continue;
                if(mat[i-1][k]>mx)
                    mx=mat[i-1][k];
            }//cout<<mx<<"\n";
            mat[i][j]+=mx;//cout<<mat[i][j]<<" ";
        }//cout<<"\n";
    }
    ans=max(max(mat[n-1][0], mat[n-1][1]), mat[n-1][2]);
    cout<<ans;    
}

Measured memory_bytes: 5760
#include <stdio.h>
int isprime2(int n){
	int i;
	for(i = 2; i * i <= n; i++){
		if(n % i == 0) return 0;
	}
	return 1;
}
int main() {
	int n, p, q, i;
	scanf("%d", &n);
	while(1){
		if(n == 0) break;
		for(i = n; n >= 5; i--){
			if(isprime2(i) == 1 && isprime2(i-2) == 1){
				p = i-2;
				q = i;
				break;
			}
		}
		printf("%d %d\n", p, q );
		scanf("%d", &n);
	}
	return 0;
}

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

#define rep(i,s,t) for(int i = s; i <= t; ++ i)
#define reep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 100050;

char str[MaxN];
int n;

int b_va()
{
	int cur = 0, block = 0;
	rep(i,1,n)
		if(str[i] == 'B') ++ cur;
		else
		{
			if(cur) ++ block;
			cur = 0;
		}
	return block + (cur>0);
}
int w_va()
{
	int cur = 0, block = 0;
	rep(i,1,n)
		if(str[i] == 'W') ++ cur;
		else
		{
			if(cur) ++ block;
			cur = 0;
		}
	return block + (cur>0);
}
int main()
{
	scanf("%s",str+1);
	n = strlen(str+1);
	int w1 = b_va(), w2 = w_va();
	if(str[1] != str[n]) printf("%d",min(w1,w2)*2-1);
	else printf("%d",min(w1,w2)*2);
	return 0;
}


Measured memory_bytes: 384