akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int len = s.length();
	int start = 0, end = len - 1;
	while (start < len && 'C' != s[start])
	{
		start++;
	}
	while (end >= 0 && 'F' != s[end])
	{
		end--;
	}
	if (start < end)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    # 濃度0%のケース
    if e == 0 or min(a, b) == f:
        print(a, 0)
        sys.exit()

    water = [0] * 6001
    water[0] = True
    for i1 in range(3001):
        if water[i1]:
            water[i1 + a] = True
            water[i1 + b] = True
    sugar = [0] * 6001
    sugar[0] = True
    for i1 in range(3001):
        if sugar[i1]:
            sugar[i1 + c] = True
            sugar[i1 + d] = True

    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if water[i1]:
            for i2 in range(f + 1):
                if i1 + i2 > f:
                    break
                if sugar[i2]:
                    if i1 * e >= i2 * 100:
                        if noudo < i2 / (i1 + i2):
                            noudo = i2 / (i1 + i2)
                            r1 = int(i1 + i2)
                            r2 = int(i2)
                    else:
                        break
    if noudo == 0:
        print(a, 0)
    else:
        print(r1, r2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9280
#include<stdio.h>
int main()
{
    char a,b,c=0,o,e,d=1,i,t,j,n,y,k,m,l,r=0;
    scanf("%c%c%c",&a,&b,&c);

    if(b=='R'){printf("ABC\n");}
    else if(b=='B'){printf("ARC\n");}


}


Measured memory_bytes: 1600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int cutup(int a,int b){
    return (a+b-1)/b;
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,n){
        cin>>aa[i];
        cnt++;
        if(aa[i]==1){
            ans=cnt-1;
            cnt=0;
        }
    }
    if(cnt%(m-1)+ans%(m-1)+1<=m&&cnt%(m-1)!=0&&ans%(m-1)!=0){
        cout<<cnt/(m-1)+ans/(m-1)+1;
    }else{
        cout<<cutup(cnt,m-1)+cutup(ans,m-1);
    }
}

Measured memory_bytes: 11148
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    unordered_map<Int, Int> m;
    rep(i, 0, N) {
        Int a; cin >> a;
        m[a]++;
    }

    Int res = 0;
    for(auto itr : m) {
        if (itr.first > itr.second) res += itr.second;
        if (itr.first < itr.second) res += itr.second - itr.first;
    }

    cout << res << endl;
}


Measured memory_bytes: 4260
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=input()
    ans=[]
    for s in S:
        if s=='B':
            if ans:
                ans.pop()
        else:
            ans.append(s)
    print(''.join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<string>
int main(void) {
		while (1) {
		std::string StringCalculate ;
		std::cin >> StringCalculate;
		if (StringCalculate == "0") { break; }
		long Result = 0;
		for (unsigned int i = 0; i < StringCalculate.size(); ++i) {
						Result += StringCalculate[i] - '0';
		}
		std::cout << Result << std::endl;
	}
	//system("pause");
	return 0;
}

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

int main(void){
    std::string S;
    char C;
    int Q, T, F;

    
    std::cin >> S >> Q;
    std::deque<char> dq;

    for(char c : S){
        //std::cout << *i << std::endl;
        dq.push_back(c);
    }

    //auto begin_iter = dq.begin();
    bool flag = false;
    
    for(int i=0; i<Q; i++){
        std::cin >> T;
        if(T == 1){
            flag = !flag;
        }else if(T == 2){
            std::cin >> F >> C;
            if(F == 1){
                if(!flag){
                    dq.push_front(C);
                }else{
                    dq.push_back(C);   
                }
            }else{
                if(!flag){
                    dq.push_back(C);
                }else{
                    dq.push_front(C);
                }
            }
        }
    }

    /*
    if(!flag){
        for(auto i = dq.begin(); i != dq.end(); i++){
            std::cout << *i;
        }
        std::cout << std::endl;
    }else{
        for(auto i = dq.rbegin(); i != dq.rend(); i++){
            std::cout << *i;
        }
        std::cout << std::endl;
    }
    */
    if (flag) std::reverse(dq.begin(), dq.end());
    std::string ans;
    for (char c : dq) ans += c;
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1412
x1, y1, x2, y2 = map(int, input().split())

a = x2-x1
b = y2-y1

x4 = x1 - b
y4 = y1 + a
x3 = x4 + a
y3 = y4 + b

print(x3, y3, x4, y4)

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int h,w,n;
	cin>>h>>w>>n;
	map<P,int> m;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		rep(j,a-2,a+1){
			rep(k,b-2,b+1){
				if(0<=j&&j<h-2&&0<=k&&k<w-2){
					if(m.count(P(j,k))){
						m[P(j,k)]++;
					}else{
						m[P(j,k)]=1;
					}
				}
			}
		}
	}
	int cnt[10]={};
	for(pair<P,int> v:m){
		cnt[v.second]++;
	}
	int s=0;
	rep(i,1,10){
		s+=cnt[i];
	}
	cnt[0]=(h-2)*(w-2)-s;
	rep(i,10)cout<<cnt[i]<<endl;
}

Measured memory_bytes: 56448
import sys
input = sys.stdin.readline


N = int(input())
A = [int(input()) for _ in range(N)]

mod = 10**9+7

dp = [0]*(N+1)
last_ind = [-1]*(2*10**5+1)

for i, a in enumerate(A):
    ind = last_ind[a]
    if ind == -1 or ind == i-1:
        dp[i+1] = dp[i]
    else:
        dp[i+1] = (dp[i] + dp[ind+1] + 1) % mod
    last_ind[a] = i

print((dp[N]+1)%mod)

Measured memory_bytes: 20528
#include <iostream>
#include<string>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D) cout << "Left" << "\n";
	else if (A + B == C + D) cout << "Balanced" << "\n";
	else cout << "Right" << "\n";


		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll n, k;
    cin >> n >> k;
    vector<int> A(n);
    for (auto& a : A) cin >> a;
    sort(A.begin(), A.end());
    cout << accumulate(A.begin(), A.begin() + k, 0LL) << endl;

    
  }
}


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

using namespace std;

int main()
{
    string s,t;
    char tmp;

    cin >> s;
    cin >> t;

    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();j++){
            if(s[i]>s[j]){
                tmp = s[j];
                s[j] = s[i];
                s[i] = tmp;
            }
        }
    }

    for(int i=0;i<t.size();i++){
        for(int j=i;j<t.size();j++){
            if(t[i]<t[j]){
                tmp = t[j];
                t[j] = t[i];
                t[i] = tmp;
            }
        }
    }

    if(s<t)
        printf("Yes\n");
    else
        printf("No\n");
            
    return 0;
            
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x, n;
  cin >> x >> n;
  vector<bool> b(102);
  while (n--) {
    int p;
    cin >> p;
    b[p] = true;
  }
  int res = -1;
  for (int i = 0; i <= 101; ++i) {
    if (b[i]) continue;
    if (abs(i - x) < abs(res - x)) {
      res = i;
    }
  }
  cout << res << '\n';
}
  

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    double a;
    double total=0;
    string u;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> u;
        if(u=="JPY"){
            total+=a;
        }else{
            total+=a*380000;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define A 0
#define B 1
#define C 2

int n,hi[N][N];
int de[N],fi[N],judge[N],count;

void Depth_visit (int st);
void depth();

int main(){
  int i,j,k,s,t;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      hi[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&s,&k);
    s--;

    for(j=0;j<k;j++){
      scanf("%d",&t);
      t--;
      hi[s][t]=1;
    }
  }

  depth();

  return 0;
}
      

void Depth_visit (int st){/*深さ優先探索*/
  int a;
  judge[st]=1;
  de[st]= ++count;

  for(a=0;a<n;a++){
    if(hi[st][a]==0)
      continue;
    if(judge[a]==0){
      Depth_visit(a);
    }
  }

  judge[st]=2;
  fi[st]=++count;
}
  
void depth(){
  int b;

  for(b=0;b<n;b++)
    judge[b]=0;
  count=0;

  for(b=0;b<n;b++){
    if(judge[b]==0)
      Depth_visit(b);
  }

  for(b=0;b<n;b++){
    printf("%d %d %d\n",b+1,de[b],fi[b]);
  }
}



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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll n_): num((n_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint pow(const modint x, ll r) {
        return x^r;
    }

    static modint fact(int n){
        if((int)factorial.size() <= n) {
            int size = factorial.size();
            factorial.resize(n+1);
            for (int i = size; i <= n; i++) {
                factorial[i] = fact(i-1) * modint(i);
            }
        }
        return factorial[n];
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial = {1};
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)



template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}


int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    map<ll, int> lcm;
    modint res = 0;
    rep(i,n) {
        res += modint(1)/modint(a[i]);
        auto f = factorize(a[i]);
        for (auto itr : f) {
            ll p = itr.first;
            int r = itr.second;
            lcm[p] = max(lcm[p], r);
        }
    }
    for (auto itr : lcm) {
        ll p = itr.first;
        int r = itr.second;
        rep(i,r){
            res *= p;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	int ans = INF;
	for (int p = 1; p <= 100; p++) {
		int total = 0;
		for (int j = 0; j < n; j++) {
			total += (x[j] - p) * (x[j] - p);
		}
		ans = min(ans, total);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  ll n;
  cin >> n;
  exrep(a,1,3500){
    exrep(b,1,3500){
      if(4*a*b-n*a-n*b>0 && (n*a*b)%(4*a*b-n*a-n*b)==0){
        ll c = (n*a*b)/(4*a*b-n*a-n*b);
        if(c>=1){
          cout << a << " "<< b  << " " << c << endl;
          return 0;
        }
      }
    }
  }
          
    
}


Measured memory_bytes: 12288
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  string S;
  cin >> S;

  long long ans = 0;
  for (int i = 0; i < (1 << S.size() - 1); i++) {
    long long temp = 0;
    for (int j = 0; j < S.size(); j++) {
      temp *= 10;
      if (i & (1 << j)) {
        ans += temp + (S[j] - '0');  
        temp = 0;
      } else {
        temp += S[j] - '0';
      }
    }
    ans += temp;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
import math

if __name__ == '__main__':
    n, k = map(int, input().split())
    a = [int(s) for s in input().split()]
    st = deque()

    if k == 0:
        print(sum(a))
        quit(0)

    log2k = int(math.log2(k))

    i = log2k
    while i >= 0 or any(x > 0 for x in a):
        lbits = [x & 1 for x in a]
        a = [x >> 1 for x in a]
        zeros = lbits.count(0)
        st.appendleft(zeros)
        i -= 1

    ans = 0
    mask = 1 << max(log2k, len(st) - 1)
    for zeros in st:
        ans <<= 1
        if zeros > n - zeros and k >= mask:
            ans += zeros
            k -= mask
        else:
            ans += n - zeros
        mask >>= 1
    print(ans)





Measured memory_bytes: 14996
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    int x; cin >> x;
    cout << (1000-x%1000)%1000 << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
    IOS;
    int n, m;
    cin >> n >> m;
    n = n*(n-1);
    n /= 2;
    m = m*(m-1);
    m /= 2;
    cout << n+m << endl;
    return 0;
}

Measured memory_bytes: 256
//18
#include<iostream>

using namespace std;

int main(){
  bool ns=false;
  for(int n;cin>>n;){
    char a[8][6]={{}};
    for(int i=4;i>=0;i--,n/=10){
      int m=n%10;
      a[0][i]=(m>=5)?' ':'*';
      a[1][i]=(m>=5)?'*':' ';
      a[2][i]='=';
      for(int j=0;j<5;j++){
	a[3+j][i]=(m%5==j)?' ':'*';
      }
    }
    if(ns){
      cout<<endl;
    }
    for(int i=0;i<8;i++){
      cout<<a[i]<<endl;
    }
    ns=true;
  }
  return 0;
}
    

Measured memory_bytes: 852
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    //final List<Integer> list = new ArrayList<>();
    //final List<String> list2 = new ArrayList<>();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if((a + b) % 2 == 1){
        System.out.println("IMPOSSIBLE");
    }else{
        System.out.println((a + b) / 2);
    }
    



















    
    






    

    



    
  

    


    


    

    
    
    



    





}
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll a = 0, b = 0;
	REP(i, n) {
		ll c, d;
		char s;
		cin >> c >> s >> d;
		if (s == ')')b += d;
		else a += d;
		if (a == b)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<limits.h>
#include<stack>
#include<string>
using namespace std;

vector< vector<int> > L(105);
vector<int> d(105,0);
vector<int> f(105,0);
vector<bool> c(105,0);
int count=0;

int out(vector<int> &A){
	int n=A.size();
	int i;
	if (n==0){
		cout << "nothing" <<endl;
	}else if(n==1){
		cout << A[0] << endl;
	}else{
		for (i=0;i<=n-2;i++){
			cout << A[i] << " ";
		}
		cout << A[n-1] <<endl;
	}
}

void dfs (int v){
	if(c[v]) return ;
	count++;
	c[v]=1;
	d[v]=count;
	for (int i=0;i<L[v].size();i++){
		dfs(L[v][i]);
	}
	count++;
	f[v]=count;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,i,j;
	cin >> n;
	
	int id, deg, v;
	for (i=0;i<n;i++){
		cin >> id >> deg;
		for (j=0;j<deg;j++){
			cin >> v;
			L[id-1].push_back(v-1);
		}
	}
	for (i=0;i<n;i++){
		dfs(i);
	}
	for (i=1;i<n+1;i++){
		cout << i << " " << d[i-1] << " " << f[i-1] <<endl;
	}
	return 0;
}

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

using namespace std;

int main (void)
{
  int N;
  cin >> N;
  if (1 > N || N > 100)
    return 1;
  float A = 0.0;
  for (int i = 1; i <= N; i++)
  {
    float a;
    cin >> a;
    A += (1 / a);
  }
  cout << 1 / A;
  return 0;
}

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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	int n;
	cin >> n;
	set<string> have;
	while (n--)
	{
		string s;
		cin >> s;
		have.insert(s);
	}
	cout << SZ(have) << endl;
}


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

int main(){

  int n,k;
  string s;
  cin >> n >> s >> k;
  for(int i=0;i<n;i++){
    if(s[i]!=s[k-1]){
      s[i] = '*';
    }
  }
  cout << s << endl;


}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long n,a,b,ans=0;
	scanf("%lld%lld%lld",&n,&a,&b);
	ans+=a*(n/(a+b));
	n=n-(a+b)*(n/(a+b));
	if(n>=a){
		ans+=a;
	}
	else{
		ans+=n;
	}
	printf("%lld\n",ans);
	return 0;
} 

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

int main(){

  long long N,K;
  cin>>N>>K;

  int A[N+1];
  int done[N+1];
  for(int i=0;i<N;i++){
    cin>>A[i];
    done[i]=0;
  }

  vector<int> v;
	
  done[0]=1;

  long long j=0;
  v.push_back(1);
  while(1){

    j=A[j]-1;
    if(done[j]==2){break;}
    done[j]++;
    v.push_back(j+1);

  }
  
  int S=v.size(); 
  if(K<S){cout<<v[K]<<endl;return 0;}

  int N_out=0;
  int N_loop=0;
  for(int i=0;i<N;i++){
    if(done[i]==1)N_out++;
    if(done[i]==2)N_loop++;
  }
  
  
  long long d=((K-N_out)%N_loop);
  cout<<v[N_out+d]<<endl;
  
}


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

int main(void){
	double x0,x1,y0,y1;
	double dis;
	
	scanf("%lf %lf %lf %lf",&x0,&y0,&x1,&y1);
	dis=sqrt(pow(x1-x0,2)+pow(y1-y0,2));
	printf("%.8f\n",dis);
	
	return 0;
}

Measured memory_bytes: 656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	
	if(abs(a-b)<=k&&
	   abs(a-c)<=k&&
	   abs(a-d)<=k&&
	   abs(a-e)<=k&&
	   abs(b-c)<=k&&
	   abs(b-d)<=k&&
	   abs(b-e)<=k&&
	   abs(c-d)<=k&&
	   abs(c-e)<=k&&
	   abs(d-e)<=k
	   )
	cout<<"Yay!"<<endl;
	else
	cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int k, n;
    cin >> k >> n;
    vi a(n+1);
    rep(i, n) cin >> a[i];
    a[n] = k + a[0];
    int m = 0;
    rep(i, n) {
        m = max(m, a[i+1] - a[i]);
    }
    cout << k - m << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue


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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n),b(n);
	int sum = 0; int sum2 = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	rep(i, n) {
		cin >> b[i]; sum2 += b[i];
	}
	int tmp = 0; int tmp2 = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			tmp += (b[i] - a[i]+1) / 2;
		}
		else if (a[i] > b[i]) {
			tmp2 += a[i] - b[i];
		}
	}
	if (max(tmp,tmp2) <= sum2 - sum)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
string get_str(string s) {
	s+=',';
	string ret="";
	for(int i=0; i<s.size(); i++) {
		if(s[i]==',') ret+="=%ld, ";
		else ret+=s[i];
	}
	return ret;
}
#define dump(...) printf(get_str(#__VA_ARGS__).c_str(),__VA_ARGS__);cout<<endl
 
#define endl '\n'
#define IOS()                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
 
//******************************************************************************
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int N;

bool f(int n,vint&a){
	vector<pair<int,int>>vec;
	int now = 0;
	rep(i,0,N){
		if(now<a[i])vec.push_back({0ll,a[i]-now});
		else{
			int t = now-a[i];
			int sz = vec.size();
			rrep(j,0,sz){
				auto tmp = vec.back();
				vec.pop_back();
				if(t >= tmp.se){
					t -= tmp.se;
				}else{
					vec.push_back({tmp.fi,tmp.se-t});
					break;
				}
			}
			sz = vec.size();
			vpint Vpush;
			rrep(j,0,sz){
				auto tmp = vec[j];
				vec.pop_back();
				if(j==0&&tmp.fi==n-1)return false;
				if(tmp.fi<n-1){
					if(tmp.se>1)vec.push_back({tmp.fi,tmp.se-1});
					vec.push_back({tmp.fi+1,1});
					break;
				}else{
					Vpush.push_back({0ll,tmp.se});
				}
			}
			rrep(j,0,Vpush.size()){
				vec.push_back(Vpush[j]);
			}
		}
		now = a[i];
	}
	return true;
}

signed main()
{
	//IOS();
	cin>>N;
	vint a(N);
	for(int i = 0;i < N;i++){
		cin>>a[i];
	}
	int l = 0, r = 1e18 + 1;
    while(r - l > 1){
        int c = (l + r) / 2;
        if(f(c,a)) r = c;
        else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
#define N 200006
struct edge{int to,nxxt;}e[N];
int n,X,D,head[N],cnt=1,fa[N];
int v[N],id[N];
ll dp[N],w[N];
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void dfs(int te)
{v[te]=1;
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;dfs(j);
		v[te]+=v[j];w[te]+=w[j];
	}
}
bool cmp(int x,int y){return 1ll*v[x]*w[y]>1ll*v[y]*w[x];}
int main()
{
	scanf("%d%d%d",&n,&X,&D);
	scanf("%lld",&w[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%lld%d",&w[i],&fa[i]);
		ins(fa[i],i);
	}dfs(1);
	for(int i=1;i<=n;i++)id[i]=i;sort(id+1,id+1+n,cmp);int tn=min(n,D),tm=n*n*n;
    for(int i=1;i<=tm;i++)dp[i]=1e18;
    for(int i=1;i<=n;i++)
    {
        int x=id[i],tt=tn;
        for(int j=0;(1<<j)<=tt;j++)
        {
            int tv=v[x]<<j;
            ll tw=w[x]<<j;
            for(int ii=tm;ii>=tv;ii--)dp[ii]=min(dp[ii],dp[ii-tv]+tw);
            tt-=1<<j;
        }
        if(tt)
        {
            int tv=v[x]*tt;
            ll tw=w[x]*tt;
            for(int ii=tm;ii>=tv;ii--)dp[ii]=min(dp[ii],dp[ii-tv]+tw);
        }
    }
    ll ans=0;
    for(int i=0;i<=tm;i++)if(dp[i]<=X)
    {
        ll sum=i,tv=dp[i];
        for(int j=1;j<=n;j++)
        {
            int x=id[j];
            if(x==1)
            {
                sum+=(X-tv)/w[x]*v[x];
                break;
            }
            int ct=min(1ll*D-tn,(X-tv)/w[x]);
            sum+=1ll*ct*v[x],tv+=1ll*ct*w[x];
        }
        ans=max(ans,sum);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4836
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int n;
vi hoge;
int a,b,c,d;
int main(){
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	string S;
	cin>>S;
	bool flag=true;
	if(c<d){
		for(int i=b;i<d;i++){
			if(S[i]=='#'&&S[i+1]=='#')flag=false;
		}
		for(int i=a;i<c;i++){
			if(S[i]=='#'&&S[i+1]=='#')flag=false;
		}
	}else{
		for(int i=b;i<d;i++){
			if(S[i]=='#'&&S[i+1]=='#')flag=false;
		}
		for(int i=a;i<c;i++){
			if(S[i]=='#'&&S[i+1]=='#')flag=false;
		}
		
		if(S[d+1]=='#'||S[d-1]=='#'){
			bool flag2=false;
			for(int i=b;i<d;i++){
				if(S[i-1]=='.'&&S[i+1]=='.'&&S[i]=='.')flag2=true;
			}
			if(flag)flag=flag2;
		}
	}
	
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 640
import java.util.*;class Main{public static void main(String[]g){int n,i,j,k,l,a[]=new int[51];for(n=0;n<51;n++){a[n]=0;for(i=0;i<10;i++)for(j=0;j<10;j++)for(k=0;k<10;k++)for(l=0;l<10;l++){if(i+j+k+l>n)break;if(i+j+k+l==n){a[n]++;break;}}}for(Scanner S=new Scanner(System.in);S.hasNext();System.out.println(a[S.nextInt()]));}}


Measured memory_bytes: 26296
N = int(input())

*A, = map(int, input().split())
A.insert(0,0)
A.append(0)

sum = 0

for i in range(1,N+2,1):

    sum = sum + abs(A[i]-A[i-1])


for i in range(1,N+1,1):
    print(sum + abs(A[i+1]-A[i-1]) - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]))


Measured memory_bytes: 14044
w,h,n = map(int,input().split())
data = list(input().split() for i in range(n))
x_1 = 0
x_2 = w
y_1 = 0
y_2 = h
for i in range(n):
    if int(data[i][2]) == 1:
        if int(data[i][0]) > x_1:
            x_1 = int(data[i][0])
    elif int(data[i][2]) == 2:
        if int(data[i][0]) < x_2:
            x_2 = int(data[i][0])
    elif int(data[i][2]) == 3:
        if int(data[i][1]) > y_1:
            y_1 = int(data[i][1])
    else:
        if int(data[i][1]) < y_2:
            y_2 = int(data[i][1])
if x_2 - x_1 <= 0 or y_2 - y_1 <= 0:
    print(0)
else:
    print((x_2 - x_1) * (y_2 - y_1))

Measured memory_bytes: 9248
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  vec b = a;

  sort(b.begin(), b.end(), greater<int>());

  int key[2] = {b[0], b[1]};

  REP(i, n){
    if(a[i] == key[0]){
      cout << key[1] << endl;
    }
    else{
      cout << key[0] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4736
N = int(input())
S = list(map(int,list(input())))
S_riv=S[::-1]
l_lis=[0]*N
r_lis=[0]*N
mat=([set([])for j in range(10)])
l_set=set([])
r_set=set([])
for i,s in enumerate(S):
  l_lis[i]=l_set.copy()
  l_set.add(s)
  
for i,s in enumerate(S_riv):
  r_lis[i]=r_set.copy()
  r_set.add(s)
  
r_lis.reverse()
ans=0
for i,s in enumerate(S):
  ans+=len(l_lis[i]-mat[s])*len(r_lis[i])
  mat[s]=l_lis[i]
  
print(ans)

Measured memory_bytes: 79964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] p = new int[n];
		int max = 0;
		int sum = 0;

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
			if (p[i] > max) {
				max = p[i];
			}
			sum += p[i];
		}

		System.out.println(sum - max / 2);

	}
}

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

#define N 100005

int n,k;
long long a[N];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);read(k);
	for(int i=1;i<=n;++i)
	read(a[i]);
}

int main(){
	init();
	long long Ans,tmp;
	Ans=100000000000000000;
	for(int i=1;i+k-1<=n;++i){
		if(a[i]<0)
		tmp=a[i+k-1]-a[i]*2;
		else tmp=a[i+k-1];
		if(tmp<Ans)
		Ans=tmp;
	}
	for(int i=n;i-k+1>=1;--i){
		if(a[i]>0)
		tmp=a[i]*2-a[i-k+1];
		else tmp=-a[i-k+1];
		if(tmp<Ans)
		Ans=tmp;
	}
	cout<<Ans<<endl;
	return 0;
}

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

using namespace std;

int a[105];

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

    int n;
    cin >> n;

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if  (a[i] % 2 == 0) {
            cnt++;
        }
    }

    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 == 0 || a[i] % 5 == 0) {
               res++;
            }
        }
    }

    if (res == cnt) {
        cout << "APPROVED";
    }
    else {
        cout << "DENIED";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<tuple>
using namespace std;

enum {DRY, LADDER, WET};
enum {LEFT, RIGHT};
enum {PLACE, FLOOR, JUMP};
typedef tuple<int, int, int> Node;
typedef tuple<int, int> Memo;

int n;
vector<int> b[2];

int bfs(int init) {
    queue<Node> q;
    q.push(Node(init, 0, 0));
    set<Memo> visited;

    while(!q.empty()) {
        int jump = get<JUMP>(q.front());
        int place = get<PLACE>(q.front());
        int floor = get<FLOOR>(q.front());
        q.pop();

        while(b[place][floor] == WET) --floor;
        while(b[place][floor] == LADDER) {
            if(floor == n - 1) break;
            if(b[place][floor + 1] != LADDER) break;
            ++floor;
        }
        if(floor == n - 1) return jump;

        if(visited.count(Memo(place, floor))) continue;
        visited.insert(Memo(place, floor));
        for(int i = 0; i < 3; ++i) {
            if(n <= floor + i) continue;
            q.push(Node(place ^ 1, floor + i, jump + 1));
        }
    }
    return -1;
}

int main() {
    while(cin >> n, n) {
        b[LEFT].resize(n); b[RIGHT].resize(n);
        for(int i = 0; i < n; ++i) cin >> b[LEFT][i];
        for(int i = 0; i < n; ++i) cin >> b[RIGHT][i];
        int answer = min(bfs(LEFT), bfs(RIGHT));
        if(answer == -1) cout << "NA" << endl;
        else cout << answer << endl;
    }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,count;
    count=0;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            while (n>1) {
                if (n%2==0) {
                    n=n/2;
                    count++;
                } else {
                    n=n*3+1;
                    count++;
                }
            }
        }
        cout<<count<<endl;
        count=0;
    }
}



Measured memory_bytes: 3004
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

#define int long long
int A[4000], B[4000], used[4000];
vector < int > al;

main()
{
	int a, b, c, d, e, f;
	scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f);
	int ans1 = 0, ans2 = 0;
	
	for(int i = 0; 1; i++)
	{
		if(i * c > f) break;
		int temp = i * c;
		al.emplace_back(temp);
		used[temp] = 1;
		
		for(int j = 1; 1; j++)
		{
			if(j * d + temp > f) break;
			if(used[j * d + temp]) continue;
			al.emplace_back(temp + j * d);
			used[j * d + temp] = 1;
			if(used[j * d] == 0) al.emplace_back(j * d), used[j * d] = 1;
		}
	}
	
	vector < pair < double, pair < int, int > > > ans;
	for(int i = 0; 1; i++)
	{
		int x = 100 * a * i;
		if(x > f)
		{
			if(x + 100 * b > f)
			break;
		}
		
		for(int j = 0; 1; j++)
		{
			int y = 100 * b * j;
			int can = x + y;
			if(can > f) break;
			for(int k = 0; k < al.size(); k++)
			{
				if(can + al[k] > f) continue;
				if(can / 100 * 100 >= ( ( al[k] + e - 1 ) / e * 100 ) )
				{
					//printf("%lld %lld\n", can, al[k]);
					//system("pause");
					if(al[k] == 0) continue;
					ans.emplace_back( make_pair ( ( al[k] + 0.0 ) / ( can + 0.0 + al[k] * 1.0 ) * 100.0,  make_pair ( can + al[k], al[k] ) ) );
				}
			}
		}
	}
	
	sort(ans.begin(), ans.end(), greater < pair < double, pair < int, int > > > () );
	//for(int i = 0; i < ans.size(); i++)
	//printf("%lld %lld %lld\n", ans[i].first, ans[i].second.first, ans[i].second.second), system("pause");
	//puts("");
	if(ans.size())
	printf("%lld %lld", ans[0].second.first, ans[0].second.second);
	else
	{
		printf("%lld 0", a * 100 );
	}
	return 0;
}


Measured memory_bytes: 856
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int x,a; cin>>x>>a;
	if(x<a) cout<<"0";
	else cout<<10;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N;
    cin >> N;
    string s;
    cin >> s;
    if(N % 2){
        cout << "No" << endl;
        return 0;
    }
    if(s.substr(0, N / 2) == s.substr(N / 2, N / 2)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
t = [0 for i in range(N)]
csf = [list(map(int, input().split())) for i in range(N - 1)]
for i in range(N - 1):
	tmp_t = 0
	for j in range(i, N - 1):
		c, s, f = csf[j]
		if s >= tmp_t:
			tmp_t += s - tmp_t + c
		else:
			a = (tmp_t - s + f - 1) // f
			tmp_t += s + f * a - tmp_t + c
	print(tmp_t)
print(0)

Measured memory_bytes: 3188
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<vector>
#define pi 3.1415926536
const int maxn = 1e5 + 5;
using namespace std;

int X,Y,n,m;
int x[105],y[105];
bool flag = 1;
int main()
{
	scanf("%d %d %d %d", &n, &m, &X, &Y);
	for(int i = 1; i <= n; i++){
		scanf("%d", &x[i]);
	}
	for(int i = 1; i <= m; i++){
		scanf("%d", &y[i]);
	}
	sort(x + 1, x + n + 1);
	sort(y + 1, y + m + 1);
	//printf("%d %d %d %d\n",X,Y,x[n],y[1]);
	if(X >= Y && x[n] >= y[1]){
		flag = 0; 
	//	printf("%d 1\n",flag);
	}
	else{
		if(x[n] >= y[1]) flag = 0;
	//	printf("%d 2\n",flag);
		else if(X >= y[1] || x[n] >= Y) flag = 0;
	//	printf("%d 3\n",flag);
	}
	if(flag) printf("No War\n");
	else printf("War\n");
	return 0;
}

Measured memory_bytes: 256