akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, c);
    Cin(int, d);
    //Cout();
    //Cout(() ? "Yes" : "No");
    Cout((a+c==b+b) ? "YES" : "NO");
}

Measured memory_bytes: 256
n = int(input())
s = input()
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        k = 2*j - i
        if j < k < n and len({s[i], s[j], s[k]}) == 3:
            cnt += 1
print(s.count('R') * s.count('G') * s.count('B') - cnt)

Measured memory_bytes: 73868
import math
n,d=map(int,input().split())

x=[]
y=[]
cnt=0
for i in range(n):
    tmpx,tmpy=map(int,input().split())
    x.append(tmpx)
    y.append(tmpy)

for i in range(n):
    dis=math.sqrt(x[i]*x[i]+y[i]*y[i])
    if dis<=d:
        cnt+=1
print(cnt)

Measured memory_bytes: 24936
#ifndef ___Class_Point
#define ___Class_Point

#include <cmath>

class Point
{
private:

	double x_;
	double y_;

public:

	Point() : x_(0), y_(0) { }

	explicit Point(double x, double y) : x_(x), y_(y) { }

	explicit Point(double x1, double y1, double x2, double y2) : x_(x2 - x1), y_(y2 - y1) { }

	double x() const { return x_; }
	double y() const { return y_; }

	Point& operator+= (const Point& p) { x_ += p.x_; y_ += p.y_; return *this; }
	Point& operator-= (const Point& p) { x_ -= p.x_; y_ -= p.y_; return *this; }

	Point& operator*= (double s) { x_ *= s; y_ *= s; return *this; }
	Point& operator/= (double s) { x_ /= s; y_ /= s; return *this; }

	friend bool operator== (const Point& p1, const Point& p2) { return p1.x_ == p2.x_ && p1.y_ == p2.y_; }
	friend bool operator!= (const Point& p1, const Point& p2) { return !(p1 == p2); }
	
	friend Point operator+ (const Point& p1, const Point& p2) { return Point(p1.x_ + p2.x_, p1.y_ + p2.y_); }
	friend Point operator- (const Point& p1, const Point& p2) { return Point(p1.x_ - p2.x_, p1.y_ + p2.y_); }

	friend Point operator* (const Point& p, double s) { return Point(p.x_ * s, p.y_ * s); }
	friend Point operator/ (const Point& p, double s) { return Point(p.x_ / s, p.y_ / s); }

	friend Point operator* (double s, const Point& p) { return Point(p.x_ * s, p.y_ * s); }
};

#endif

#ifndef ___Class_Vector
#define ___Class_Vector

typedef Point Vector;

double norm(Vector p1)
{
	return p1.x() * p1.x() + p1.y() * p1.y();
}

double abs(Vector p1)
{
	return sqrt(norm(p1));
}

double cross(Vector p1, Vector p2)
{
	return p1.x() * p2.y() - p1.y() * p2.x();
}

double dot(Vector p1, Vector p2)
{
	return p1.x() * p2.x() + p1.y() * p2.y();
}

#endif

#ifndef ___Computational_Geometry
#define ___Computational_Geometry

bool palarell(Vector p1, Vector p2)
{
	return cross(p1, p2) == 0;
}

bool palarell(Point p1_s, Point p1_e, Point p2_s, Point p2_e)
{
	return palarell(p1_e - p1_s, p2_e - p2_s);
}

bool orthogonal(Vector p1, Vector p2)
{
	return dot(p1, p2) == 0;
}

bool orthogonal(Point p1_s, Point p1_e, Point p2_s, Point p2_e)
{
	return orthogonal(p1_e - p1_s, p2_e - p2_s);
}

double dist_sqr(Point p1, Point p2)
{
	return pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2);
}

double distance(Point p1, Point p2)
{
	return sqrt(dist_sqr(p1, p2));
}

Vector projection(Vector hypo, Vector base)
{
	return base * (dot(hypo, base) / norm(base));
}

Vector reflection(Vector hypo, Vector base)
{
	return base + (projection(hypo, base) - hypo) * 2.0;
}

#endif

#include <cstdio>

#pragma warning(disable: 4996)

int main()
{
	int x1, y1, x2, y2, x3, y3, q;

	scanf("%d", &x1);
	scanf("%d", &y1);
	scanf("%d", &x2);
	scanf("%d", &y2);

	Vector p(x1, y1, x2, y2);

	scanf("%d", &q);

	for (int i = 0; i < q; i++)
	{
		scanf("%d", &x3);
		scanf("%d", &y3);

		Vector a(x1, y1, x3, y3);

		Vector c = projection(a, p);

		printf("%.15f %.15f\n", x1 + c.x(), y1 + c.y());
	}

	return 0;
}

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


int main() {
string s;
cin>>s;
int n=s.size();
if(s=="hi") cout<<"Yes"<<endl;
else if(s=="hihi") cout<<"Yes"<<endl;
else if(s=="hihihi") cout<<"Yes"<<endl;
else if(s=="hihihihi") cout<<"Yes"<<endl;
else if(s=="hihihihihi") cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


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

using namespace std;

int p[1000];

int main(){
	std:ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k,i,sum=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>p[i];
	sort(p,p+n);
	for(i=0;i<k;i++)
		sum+=p[i];
	cout<<sum<<"\n";
}

Measured memory_bytes: 3656
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd, log10
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
# 1 2 3
# a, b, c = LI()


def I(): return int(sys.stdin.buffer.readline())
# a = I()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
# abc def
# a, b = LS()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
# a = S()


def IR(n): return [I() for i in range(n)]
# 2
# 1
# 2
# [1, 2]


def LIR(n): return [LI() for i in range(n)]
# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def SR(n): return [S() for i in range(n)]
# 2
# abc
# def
# [abc, def]


def LSR(n): return [LS() for i in range(n)]
# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def SRL(n): return [list(S()) for i in range(n)]
# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = LI()
uf = UnionFind(n)
for _ in range(m):
    a, b = LI()
    uf.union(a-1, b-1)
print(uf.group_count()-1)


Measured memory_bytes: 74256
n=int(input())
s=input()

def Z_algorithm(s):
    N = len(s)
    Z_alg = [0]*N

    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_alg[k]<j:
            Z_alg[i+k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg
ans=0
for i in range(n):
    t=s[i:]
    z=Z_algorithm(t)
    ans=max(ans,max([min(j,z[j]) for j in range(len(z))]))

print(ans)

Measured memory_bytes: 82976
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int):
    ret = K * (K - 1) ** (N - 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main(void){
    string s;
    cin>>s;
    int ans;
    if(s=="RRR")ans=3;
    else if(s=="RRS")ans=2;
    else if(s=="SRR")ans=2;
    else if(s=="SSS")ans=0;
    else ans=1;
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <cstdio>

using namespace std;

int main()
{
	int n, m;
	
	scanf("%d %d", &n, &m);
	
	int a[1001], b[1001];
	
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	for (int j = 0; j < m; j++){
		scanf("%d", &b[j]);
	}
	
	int score[1001] = {0};
	int max = 0, num;
	
	for (int j = 0; j < m; j++){
		for (int i = 0; i < n; i++){
			if (a[i] <= b[j]){
				score[i]++;
				if (max < score[i]){
					num = i;
					max = score[i];
				}
				break;
			}
		}
	}
	
	printf("%d\n", num+1);
	
	return (0);
}

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

const int maxn = 50, mod = 1e9 + 7;
int n, C[maxn + 3][maxn + 3], dp[maxn + 3][maxn + 3];

int _abs(int x) {
	return x < 0 ? -x : x;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i <= n; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
	dp[1][0] = dp[1][1] = n;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = j == 0 ? 2 : j; k <= n - i; k += 2) {
				int x = (k - j) >> 1;
				for (int l = 0; l <= k; l++) {
					dp[i + k][_abs(l - x)] = (dp[i + k][_abs(l - x)] + 1ll * dp[i][j] * C[n - i][k] % mod * C[k][l]) % mod;
				}
			}
		}
	}
	printf("%d\n", dp[n][0]);
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

n, m, *a = map(int, sys.stdin.read().split())
a.sort()

ma = a[-1]
cnt = [0] * (ma + 1)
cur = ma
for i in range(n-1, -1, -1):
    if a[i] == cur:
        cnt[cur] += 1
    else:
        while True:
            cur -= 1
            cnt[cur] = cnt[cur+1]
            if cur == a[i]:
                cnt[cur] += 1
                break
for i in range(cur-1, -1, -1):
    cnt[i] = cnt[i+1]


def possible(border):
    pair_cnt = 0
    for i in range(n):
        aj = border - a[i]
        if aj < 0:
            aj = 0
        elif aj > ma:
            continue
        pair_cnt += cnt[aj]
    return pair_cnt >= m

def main():
    s = [0] + list(accumulate(a[::-1]))
    
    lo = 1; hi = a[-1] * 2 + 1
    while lo + 1 < hi:
        border = (lo + hi) // 2
        if possible(border):
            lo = border
        else:
            hi = border
    res = lo
    ans = 0
    minimum = float('inf')
    pair_cnt = 0
    for i in range(n):
        aj = res - a[i]
        if aj < 0:
            aj = 0
        elif aj > ma:
            continue
        c = cnt[aj]
        ans += s[c] + a[i] * c
        pair_cnt += c
        minimum = min(minimum, a[i] + a[-c])

    ans -= minimum * (pair_cnt - m)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 16740
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int main() {
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k; n -= 2;

    ll sm = 0;
    for (int i = 0; i < 11; i++) {
        int d = 0;
        for (int j = 0; j <= 4; j++) {
            int x = (4 + 9*j + 7*9*i)%11;
            if (x == k) {
                d++;
            } 
        }
        sm += ll(d) * (n-i+10)/11;
    }

    cout << sm << endl;
    return 0;
}


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

typedef long long ll;

using namespace std;
int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	K = K - 1;
	if (S[K] == 'A') {
		S[K] = 'a';
	}
	else if (S[K] == 'B') {
		S[K] = 'b';
	}
	else if (S[K] == 'C') {
		S[K] = 'c';
	}
	cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
  
bool search(int a[], int n, int t){
    int left=0, right=n;
    
    while(left < right){
    	int mid = (left + right)/2;
        if(a[mid] == t){
            return true;
        }else if(a[mid]<t){
            left = mid + 1;
        }else{
            right = mid;
        }
    }
    return false;
}
  
int main() {
    int n1;
    cin>>n1;
      
    int s[n1];
    for(int i=0 ; i<n1 ; i++){
        scanf("%d",&s[i]);
    }
      
    int n2;
    cin>>n2;
      
    int t,ans=0;
    for(int i=0 ; i<n2 ; i++){
        scanf("%d",&t);
        if(search(s,n1,t)) ans++;
    }
      
    cout<<ans<<endl;
      
    return 0;
}

Measured memory_bytes: 1632
#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m], c[m], a[n];
  for(int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for(int i = 0; i < n; i++) {
    a[i] = 10;
  }
  for(int i = 0; i < m; i++) {
    if(a[s[i] - 1] != 10 && a[s[i] - 1] != c[i]) {
      cout << -1;
      return 0;
    }
    a[s[i] - 1] = c[i];
  }
  
  for(int i = 0; i < n; i++) {
    if(a[i] == 10) {
      a[i] = 0;
      if(i == 0 && n != 1) {
        a[i] = 1;
      }
    }
  }
  if(a[0] == 0 && n != 1) {
    cout << -1;
  } else {
    for(int i = 0; i < n; i++) {
      cout << a[i];
    }
  }
}

Measured memory_bytes: 256
from typing import List


def answer(h: int, w: int, a: List[str]) -> List[str]:
    for i in range(2):
        white_line = '.' * w
        loop = a.count(white_line)
        for _ in range(loop):
            a.remove(white_line)
        a = [''.join(line) for line in (zip(*a))]
        if i == 0:
            w = h - loop

    return a


def main():
    h, w = map(int, input().split())
    a = [input() for _ in range(h)]
    for i in answer(h, w, a):
        print(i)


if __name__ == '__main__':
    main()


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

int main()
{
ll a , b , n ;
cin >> a >> b >> n ;
ll k=min(b-1,n);
ans=max(ans,(a*k)/b -a*(k/b));
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

for i in range(N-K):
    if T[i+K] == T[i]:
        T[i+K] = 0

print(T.count("r")*P+T.count("s")*R+T.count("p")*S)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<pair<ll,ll>> tasks;
vector <ll> data;
vector <ll> target;

int main(){
    ll i,j,n,m,temp,temp1,temp2;
    cin >> n >> m;
    priority_queue<pair<ll,ll>> q;
    //vector<pair<ll,ll>> tasks;
    for(i = 0; i < n; i++){
        cin >> temp;
        q.push({temp,1});
    }
    
    for(i = 0; i < m; i++){
        cin >> temp1 >> temp2;
        q.push({temp2,temp1});
    }

    ll ans = 0;
    ll count = 0;
    ll hoge;
    while(count < n){
        hoge = min(q.top().second,n-count);
        ans += q.top().first * hoge;
        count += q.top().second;
        q.pop();
    }

    /*while (!q.empty()) {
        ans += que.top();
        que.pop();
    }*/
    cout << ans << endl;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int n,m,h[100005],r;
bool ok[100005];
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n>>m;
  for(int i=1;i<=n;i++)
    cin>>h[i],ok[i]=1;
  for(int i=1;i<=m;i++)
  { int a,b;
    cin>>a>>b;
    if(h[a]>=h[b])
       ok[b]=0;
    if(h[a]<=h[b])
       ok[a]=0;
  }
  for(int i=1;i<=n;i++)
    r+=ok[i];
  cout<<r<<'\n';
  return 0;
}


Measured memory_bytes: 4104
#include <stdio.h>

int main(void)
{
	int l;
	int m, n;
	int sum;
	int ans;
	
	while (scanf("%d", &l) && l){
		int i;
		ans = 99999;
		sum = 0;
		for (i = 0; i < 12; i++){
			scanf("%d %d", &m, &n);
			l -= (m - n);
			if (l <= 0 && ans == 99999){
				ans = i + 1;
			}
		}
		
		if (ans != 99999){
			printf("%d\n", ans);
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

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

using namespace std;

typedef long long ll;

ll N, K, L, R;
ll a[40];

auto enumerate(int sidx, int size) {
  vector<pair<ll, ll>> ret;
  for(int i=0; i<1<<size; i++) {
    if(__builtin_popcount(i) > K) continue;
    int cnt = 0; ll sum = 0;
    for(int j=0; j<size; j++)
      if(i >> j & 1) cnt++, sum += a[sidx + j];
    ret.emplace_back(cnt, sum);
  }
  return ret;
}

ll solve() {
  auto v0 = enumerate(0, N / 2);
  auto v1 = enumerate(N / 2, (N + 1) / 2);
  sort(v0.begin(), v0.end());
  ll ret = 0;
  for(int i=0; i<(int)v1.size(); i++)
    ret +=  upper_bound(v0.begin(), v0.end(), make_pair(K - v1[i].first, R - v1[i].second))
          - lower_bound(v0.begin(), v0.end(), make_pair(K - v1[i].first, L - v1[i].second));
  return ret;
}

int main() {
  cin >> N >> K >> L >> R;
  for(int i=0; i<N; i++) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 43740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

void solve(long long N, std::vector<long long> X){
    vector<ll> s(100, 0);
    for(ll i = 0; i < 100; ++i){
        for(ll j = 0; j < N; ++j){
            s[i] += (i+1-X[j]) * (i+1-X[j]);
        }
    }
    ll ans = INF;
    for(int i = 0; i < 100; ++i) ans = min(ans, s[i]);
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 3696
x,y = map(int, input().split())
Z = [4,6,9,11]
if x in Z or y in Z:
    b = x in Z and y in Z
elif x == 2 or y == 2:
    b = x == y == 2
else:
    b = x not in ([2]+Z) and y not in ([2]+Z)
print("YNeos"[not b::2])

Measured memory_bytes: 3064
K = int(input())
cnt = 0
import math
from functools import reduce
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
 
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
 
            cnt += gcd_list([i,j,k])
print(cnt)

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

int main() {
  int K,S;cin>>K>>S;

  set<vector<int>> ts;
  REP(x,K+1)FOR(y,x,K+1) {
    int z = S-x-y;
    if (z<0 || z>K) continue;
    vector<int> t{x,y,z};
    sort(ALL(t));
    ts.insert(t);
  }

  int ans = 0;
  for (auto t:ts) {
    if (t[0]==t[1] && t[1]==t[2]) ans++;
    else if (t[0]==t[1] || t[1]==t[2]) ans += 3;
    else ans += 6;
  }
  OUT(ans);

  return 0;
}

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

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int ns[] = new int[1000], os[] = new int[1000];
		int dp1[] = new int [1000001], dp2[] = new int[1000001];
		int pos = 0;
		for(int i=1; ;i++){
			ns[i] = i*(i+1)*(i+2)/6;
			if(ns[i]%2 == 1){
				os[pos++] = ns[i];
			}
			if(ns[i] > 3000000) break;
		}
		for(int i=1; i<1000001;i++) dp1[i] = dp2[i] = 1<<29;
		for(int i=1; i<1000001;i++){
			for(int j=0; j<1000; j++){
				if(ns[j] > i) break;
				dp1[i] = Math.min(dp1[i], dp1[i-ns[j]]+1);
			}
			for(int j=0; j<1000; j++){
				if(os[j] > i) break;
				dp2[i] = Math.min(dp2[i], dp2[i-os[j]]+1);
			}
		}
		while(true){
			int n = in.nextInt();
			if(n==0) return ;
			System.out.printf("%d %d\n", dp1[n], dp2[n]);
		}
	}
}

Measured memory_bytes: 20000
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 出力
		System.out.println((a+b+c)-Math.max(a, Math.max(b, c)));
	}
}

Measured memory_bytes: 23124
def main():
    n = int(input())
    s = list(input())
    sr = [0] * n
    sg = [0] * n
    sb = [0] * n
    for i1 in range(n):
        ts = s[i1]
        if ts == 'R':
            sr[i1] = 1
        elif ts == 'G':
            sg[i1] = 1
        else:
            sb[i1] = 1
    if n <= 3:
        print(0)
        exit()
    r = 0
    for ia in range(0,n-3):
        ta = s[ia]
        if ta == 'R':
            r += sum(sg[ia+1:]) * sum(sb[ia+1:])
        elif ta == 'G':
            r += sum(sr[ia+1:]) * sum(sb[ia+1:])
        else:
            r += sum(sg[ia + 1:]) * sum(sr[ia + 1:])
        for ib in range((n - ia)//2+1):
            if ia + ib * 2 < n:
                if ta != s[ia + ib] and ta != s[ia + ib + ib] and s[ia+ib]!= s[ia + ib + ib]:
                    r -= 1
    print(r)

if __name__ == '__main__':
    main()


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, H, W;
    cin >> N >> H >> W;
    ll ans = 0;
    rep(i, N) {
        ll A, B;
        cin >> A >> B;
        if(H <= A && W <= B) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split;
    auto N = s[0].to!int;
    auto S = s[1].to!(dchar[]);

    bool f(dchar[] T) {
        foreach (i; 0..N) {
            if (T[i] != 'B') continue;
            for (int j = i+1, w = 0; j < N; ++j) {
                if (T[j] == '.') break;
                else if (T[j] == 'W') w += 1;
                else if (T[j] == 'B') {
                    if (w > 0) return true;
                    else break;
                }
            }
        }
        return false;
    }

    int g(dchar[] T) {
        int ans = 0;
        foreach (i; 0..N) {
            if (T[i] != 'W') continue;
            for (int j = i+1, b = 0; j < N; ++j) {
                if (T[j] == '.') break;
                else if (T[j] == 'B') b += 1;
                else if (T[j] == 'W') {
                    ans = max(ans, b);
                    break;
                }
            }
        }
        return ans;
    }

    int ans = 0;
    foreach (i; 0..N) {
        if (S[i] != '.') continue;
        S[i] = 'W';
        if (!f(S)) ans = max(ans, g(S));
        S[i] = '.';
    }

    ans.writeln;
}



Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int INF=(int)1e18+1,t=-1,till=0;
int gcd(int a, int b) { return b!=0 ? gcd(b, a % b) : a; }
// int digits(int n){return floor(log10(n))+1 ;}
// bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
//vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;
// map<pair<int,int>,int> vis;
// vector<int> row={-1,1,0,0};
// vector<int> col={0,0,-1,1};
// //map<pair<int,int>,int> dp;
// int n=1;
// int th=0;

// int dfs(int r,int c,vector<vector<int> > board,vector<vector<int> > &dp){
//     vis[{r,c}]=1;
//     if(dp[r][c]!=-1){
//         return dp[r][c];
//     }
//     int t=1;
//     for(int i=0;i<4;i++){
//         int r1=r+row[i],c1=c+col[i];
//         if(r1>=0 && r1<n && c1>=0 && c1<n && 
//           !vis[{r1,c1}] && board[r][c]<board[r1][c1]){
//           t=max(t,1LL + dfs(r1,c1,board,dp));
//         }
//     }
//     vis[{r,c}]=0;
//     return dp[r][c]=max(t,dp[r][c]);
    
    
// }




signed main(){
    fio;
    int n,wt;
    cin>>n>>wt;
    vector<int> w(n),v(n);
    int tv=0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    tv=accumulate(v.begin(),v.end(),0);
    vector<int> ans(tv+1,-1);
    ans[0]=0;
    int s=0,res=0;
    for(int i=0;i<n;i++){
        s+=v[i];
        for(int val=s;val>=v[i];val--){
            if(ans[val-v[i]]!=-1){
                int wtt=ans[val-v[i]]+w[i];
                if(wtt<=wt) res=max(res,val);
                if(ans[val]==-1 || ans[val]>wtt) ans[val]=wtt;
            }
        }
    }
    cout<<res<<endl;

    
    


    

    
    
     
    



    
    
    
    
    



    
    
    


    

    

    

    



    

    

    

    


    

    
    
}


Measured memory_bytes: 1024
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
typedef long long ll;
using namespace std;

int n, a[50];
pair<int,int> p;
int main() {
	cin>>n;
	p=mkp(0,-1);
	rep(n){
		cin>>a[i];
		if(abs(p.first)<=abs(a[i])){
			p=mkp(a[i],i);
		}
	}
	cout<<n*2-2<<endl;
	rep(n){
		if(i!=p.second){
			cout<<p.second+1<<sp<<i+1<<endl;
		}
	}
	if(p.first>=0){
		for(int i=0;i<n-1;++i)
			cout<<i+1<<sp<<i+2<<endl;
	}
	else{
		for(int i=n-2;i>=0;--i)
			cout<<i+2<<sp<<i+1<<endl;
	}
	return 0;
}


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

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))

//No.4
LLONG CalcSum(int start, int n)
{
	return (LLONG)(start + start + n - 1) * n / 2;
}

int main()
{
	INT N, K;
	cin >> N >> K;
	LLONG pattern = 0;

	for (int i = K; i <= N + 1; ++i) {
		LLONG min = 0, max = 0;

		min = CalcSum(0, i);
		max = CalcSum(N - (i - 1), i);
//		cout << max << ", " << min << endl;
		pattern += max - min + 1;
	}

	cout << pattern % 1000000007;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long X, ans = 0, dep = 100;
    cin >> X;
    while(dep < X){
        dep = dep * 1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
import sys
Field = []
for i in range(3):
    a, b, c = map(int, input().split(" "))
    local = [a,b,c]
    Field.append(local)
N = int(input())
for i in range(N):
    target = int(input())
    for i in Field:
        if target in i:
            k = i.index(target)
            i[k] = -1
        else:
            pass
if Field[0][0] == -1 and Field[1][1] == -1 and Field[2][2] == -1:
    print("Yes")
    sys.exit()
if Field[0][2] == -1 and Field[1][1] == -1 and Field[2][0] == -1:
    print("Yes")
    sys.exit()

for i in range(3):
    if Field[0][i] == -1 and Field[1][i] == -1 and Field[2][i] == -1:
        print("Yes")
        sys.exit()
    elif sum(Field[i]) == -3:
        print("Yes")
        sys.exit()
print("No")


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int boolean = 0;

    int i = 1;
    while(boolean==0&&i<b){
        if(i*a%b==c){
            boolean=1;
        }
        i++;
    }
    
    if(boolean==1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int x,y ;
  cin >> x >> y ;
  int ans = 0 ; 
  
  if(x == 1 ) ans += 300000 ;
  if(x == 2 ) ans += 200000 ; 
  if(x == 3 ) ans += 100000 ;
  if(y == 1 ) ans += 300000 ;
  if(y == 2 ) ans += 200000 ; 
  if(y == 3 ) ans += 100000 ;
  if(x == 1 && y == 1) ans += 400000 ;
  
  cout <<ans ;
     
  
  
}


Measured memory_bytes: 3616
S = input()
T = input()
MIN = len(T)

while len(T) <= len(S):
  cnt = 0
  for(SL,TL) in zip(list(S),list(T)):
    if SL != TL:
      cnt = cnt + 1
  
  if MIN > cnt:
   MIN = cnt
  
  S = S[1:]

print(MIN)

Measured memory_bytes: 9084
import sys
input = sys.stdin.readline
N = int(input())
S = list(map(int, list(input())[: -1]))
pp = sum(S)
Xp = 0
Xm = 0
S.reverse()
for i in range(N):
  Xp += pow(2, i, pp + 1) * S[i]
  Xp %= pp + 1
  Xm += pow(2, i, max(1, pp - 1)) * S[i]
  Xm %= max(1, pp - 1)
#print(Xp, Xm)
rres = [0] * N
for i in range(N):
  res = 1
  if S[i]:
    if pp == 1: res = 0
    else:
      X = (Xm - pow(2, i, max(1, pp - 1))) % max(1, pp - 1)
      while X:
        c = bin(X).count("1")
        X %= c
        res += 1
  else:
    X = (Xp + pow(2, i, pp + 1)) % (pp + 1)
    while X:
      c = bin(X).count("1")
      X %= c
      res += 1
  rres[i] = res
rres.reverse()
for r in rres: print(r)

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;

char str[N];
int len;
int w;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%s", str);
	len = strlen(str);
	scanf("%d", &w);
	for (int at = 0; at < len; at += w) {
		printf("%c", str[at]);
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    if (A+B > C+D) {
      cout << "Left";
    }else if(A+B == C+D){
      cout << "Balanced";
    }else{
      cout << "Right";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut v: Vec<i32> = Vec::new();
    for i in buf.trim().split_whitespace() {
        v.push(i.parse::<i32>().unwrap());
    }
    println!("{}", if (v[0] * v[1]) % 2 == 0 { "Even" } else { "Odd" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>

int main() {
	std::string s;
	std::vector<int> count(26, 0);
	
	while (std::cin >> s) {
		for (const char &c : s) {
			if (('a' <= c and c <= 'z') or ('A' <= c and c <= 'Z')) {
				count[tolower(c) - 'a']++;
			}
		}
	}
	
	for (char c = 'a'; c <= 'z'; c++) {
		int i = (c - 'a');
		std::cout << c << " : " << count[i] << '\n';
	}
	
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];

  int acnt=0;
  int uncnt=0;
  bool isok=true;
  for(int i=0;i<n;i++){
    if(s[i]=="A"){
      acnt++;
    }
    else{
      uncnt++;
    }
    if(acnt<uncnt) isok=false;
  }
  if(acnt!=uncnt) isok=false;
  cout<<(isok? "YES" : "NO")<<endl;
  return 0;
}

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

const int Maxn = 1005;

int n, m, a, b;
char B[Maxn][Maxn];

int main()
{
    scanf("%d %d %d %d", &n, &m, &a, &b);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++)
            if ((j < a) == (i < b)) B[i][j] = '0';
            else B[i][j] = '1';
        B[i][m] = '\0';
        printf("%s\n", B[i]);
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int w,h;
vector<Pi> vp;
ll ans=0;
int main(){
	cin>>w>>h;
	int cw,ch;
	cw=w+1;
	ch=h+1;
	REP(i,w){
		int w1;
		cin>>w1;
		vp.push_back(Pi(w1,0));
	}
	REP(i,h){
		int h1;
		cin>>h1;
		vp.push_back(Pi(h1,1));
	}
	sort(vp.begin(),vp.end());
	REP(i,vp.size()){
		if(vp[i].second==0){
			ans+=(ll)ch*vp[i].first;
			cw--;
		}else{
			ans+=(ll)cw*vp[i].first;
			ch--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <unordered_set>

using namespace std;

unordered_set<int> rec;

int main()
{
    int n;
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        if (rec.find(num) != rec.end())
        {
            cout << "NO" << endl;
            return 0;
        }
        rec.insert(num);
    }
    cout << "YES" << endl;
    return 0;
}

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

int main() {
	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	for(long i = 1; i<101; i++){
      if(c-b*i<=0){
        cout << "Yes" << endl;
        break;
      }
   	  else if(a-d*i<=0){
          cout << "No" << endl;
        break;
     }
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 300000;
const int INF = (1 << 30);

int s[2], sum[MAXN + 5], a[MAXN + 5], N;
bool check(int x) {
	int k = 0;
	for(int i=2;i<=N;i+=2) {
		if( sum[i-1] - k >= x )
			k = min(k, sum[i]);
	}
	return sum[N] - k >= x;
}

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%d", &a[i]), s[i & 1] += a[i];
	if( N % 2 == 0 )
		printf("%d %d\n", max(s[0], s[1]), min(s[0], s[1]));
	else {
		for(int i=1;i<=N;i++) sum[i] = sum[i-1] + (i & 1 ? a[i] : -a[i]);
		int le = 0, ri = s[0] + s[1];
		while( le < ri ) {
			int mid = (le + ri + 1) >> 1;
			if( check(mid) ) le = mid;
			else ri = mid - 1;
		}
		printf("%d %d\n", s[0] + le, s[1] - le);
	}
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,m;cin>>n>>m;
    vector<vector<ll>> v(m);
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(m-a<0) continue;
        v[m-a].push_back(b);
    }
    priority_queue<ll> que;
    ll ans=0;
    for(int i=m-1;i>=0;i--){
        for(auto x:v[i]){
            que.push(x);
        }
        if(que.empty()) continue;
        ans+=que.top();que.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    double r;
    cin >> r;
    double pi = 3.1415926535;
    cout << 2 * pi * r << endl;
    
}

Measured memory_bytes: 3760
#define ll long long
#define dd long double
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<bitset>
dd pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n
// ll seed;
//mt19937 rnd(seed=chrono::steady_clock::now().time_since_epoch().count()); // include bits
#define pll pair<ll, ll> 
ll n ;

void solve()
{
    cin >> n ;
    n %= 1000 ;
    if(n)
        n = (1000 - n) ;
    cout << n << '\n' ;
    return ;
}

int main()
{
    /*ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/

   
    
    ll t ;
    //cin >> t ;
    t = 1 ;
   
    while(t--)
    {
        solve() ;
    }
    
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int a, b, t;
void in(){
    cin >> a >> b >> t;
}

void solve(){
    cout << t/ a * b << endl;

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip> 

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	double a,b;
	double h,m;
	cin>>a>>b>>h>>m;
	double ang = acos(-1) * 2 * ((h+m/60)/12-m/60);
	if(ang<0)ang = -ang;
	if(ang>acos(-1))ang = acos(-1)*2-ang;
	double res = sqrt(a*a +b*b - a*b*2*cos(ang));
	cout<<fixed<<setprecision(15);
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 3604
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W = LI()
    h, w = LI()

    ans = (H - h) * (W - w)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9976
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    int K;
    string S;
    cin>>K>>S;
    int len=S.size();
    if(len<=K){
        cout<<S<<endl;
    }else{
        rep(i,0,K){
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }
    
}

Measured memory_bytes: 3624
s=input()
t=input()
n=len(s)
A='abcdefghijklmnopqrstuvwxyz'
i=0
while A:
	if s==t:
		print('Yes')
		exit()
	if i==n:
		print('No')
		exit()
	if s[i]!=t[i]:
		if s[i] in A and t[i] in A:
			s=s.replace(s[i],'X').replace(t[i],s[i]).replace('X',t[i])
			A=A.replace(s[i],'').replace(t[i],'')
	i+=1
print('No')

Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int a = Integer.parseInt(k[0]);
		int b = Integer.parseInt(k[1]);
		int g = a * b;
		int y = 2 * a + 2 * b;
		System.out.println(g + " " + y);
	}
}

Measured memory_bytes: 25976
nums = [int(x) for x in input().split()]
nums = [ [nums[0],nums[1]] ,
         [nums[2],nums[3]] ]
N = 100
imos = [0 for i in range(N+2)]

for num in nums:
    a,b = num[0],num[1]-1
    imos[a] += 1
    imos[b+1] -= 1
 
ans = []
j = 0
for i in imos:
    ans.append(j+i)
    j += i

print(ans.count(2))

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;

	s[k - 1] = s[k - 1] - 'A' + 'a';

	ANS(s);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)cout<<k<<endl;
    else{
        if((k-a)<=b)cout<<a<<endl;
        else{
            cout<<2*a+b-k<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+100;

ll a[N];
int32_t main(){
    ll ans=0;
    ll n;
    cin >> n;
    ll cnt=1;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        if (a[i]==cnt) cnt++;
        else ans++;
    }
    if (ans==n){
        cout << -1;
        return 0;
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cmath>
#include<utility>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 3e5 + 233;
char s[maxn];
int main()
{
	int n;cin>>n;
	scanf("%s",s+1);
	int ans = n-1,cur = 0;
	for(int i=n;i>=2;i--)
	if(s[i]!='W')cur++;
	for(int i=1;i<=n;i++)
	{
		ans = min(ans,cur);
		if(s[i]!='E')cur++;
		if(s[i+1]=='E')cur--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512