akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll h, w;
string a[1010];
ll dp[1010][1010];
int main(){
    cin>>h>>w;
    REP(i, 0, h) cin>>a[i];

    dp[1][1]=1;
    REP(i, 0, h){
        REP(j, 0, w){
            if(i==0 && j==0) continue;
            if(a[i][j]=='#') continue;

            dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%mod;
        }
    }

    cout<<dp[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>
int main(){
    int n,a[100],cnt,max,maxi;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        max=0;
        for(int j=0;j<n;j++) if(max<a[j]){
            max=a[j];
            maxi=j;
        }
        cnt+= max*((i%2)?-1:1);
        a[maxi]=0;
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include<cmath>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<algorithm>
#define MN 51
#define Cx 0.03
#define Cy 0.03
#define eps 1e-7
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
int n,m,map[10][10],dp[10][1<<10],a,b,mmh=0;
int main(){
	register int i,j,k;
	n=read();m=read();
	for (i=1;i<=m;i++) scanf("%d%d",&a,&b),map[a][b]=map[b][a]=1;
	dp[1][1]=1;
	for (i=1;i<(1<<n);i++){
		for (j=1;j<=n;j++)
		if (dp[j][i])
		for (k=1;k<=n;k++)
		if (map[j][k]&&!((i>>(k-1))&1)) dp[k][i|(1<<(k-1))]+=dp[j][i];
	}
	for (i=1;i<=n;i++) mmh+=dp[i][(1<<n)-1];
	printf("%d\n",mmh);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define sort(i,t) qsort(i.data(),i.size(),sizeof(t),[](const void*a, const void*b)->int{if((*(t*)a)>(*(t*)b))return 1;if((*(t*)a)<(*(t*)b))return -1;return 0;})
void din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void din(T& head, Args& ... rest) { cin >> head; din(rest...); }
template <typename T, typename ... Args> inline void dout(T& head, Args& ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
int main()
{
	int a, b;
	din(a, b);
	if (a*b % 2)
		dout("Yes");
	else
		dout("No");
}

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

template <typename T>
class weighted_quick_find {
	using pid = pair<int, T>;
	vector<pair<int, T>> data;
	vector<vector<int>> all;
public:
	weighted_quick_find(int n) : data(n), all(n, vector<int>(1)) {
		for (int i = 0; i < n; i++) {
			data[i].first = i;
			all[i][0] = i;
		}
	}
	void unite(int a, int b, T d) {
		if (same(a, b)) return;
		d += data[a].second - data[b].second;
		a = data[a].first;
		b = data[b].first;
		if (all[a].size() < all[b].size()) swap(a, b), d = -d;
		for (auto& id : all[b]) {
			data[id].first = a;
			data[id].second += d;
		}
		copy(all[b].begin(), all[b].end(), back_inserter(all[a]));
	}
	bool same(int a, int b) const {
		return data[a].first == data[b].first;
	}
	T dist(int a, int b) const {
		return data[b].second - data[a].second;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	weighted_quick_find<int> wqf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			int z;
			cin >> z;
			wqf.unite(x, y, z);
		}
		else if (wqf.same(x, y)) {
			printf("%d\n", wqf.dist(x, y));
		}
		else {
			puts("?");
		}
	}
	return 0;
}



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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,m;
    cin >> n >> m;
    vi p(m);
    vector<string> S(m);
    vector<bool> a(n, false);
    vector<ll> vwa(n, 0);
    ll ac = 0, wa = 0;
    rep(i, m) {
        cin >> p[i] >> S[i];
        p[i]--;

        if (S[i] == "WA" and a[p[i]] == false) {
            vwa[p[i]]++;
        } else if(S[i] == "AC" and a[p[i]] == false) {
            ac++;
            a[p[i]] = true;
        }
    }

    rep(i, n) if (a[i]) wa += vwa[i];
    cout << ac << " " << wa << endl;

    return 0;
}


Measured memory_bytes: 6912
N, M = map(int, input().split())
zahyo = list(map(int, input().split()))
zahyo.sort()
sa = [0 for _ in range(M-1)]

for i in range(M-1):
    sa[i] = zahyo[i+1] - zahyo[i]

sa.sort(reverse=True)
sa = sa[N-1:]

print(sum(sa))

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int H,W;cin>>H>>W;
    vector<vector<char>>vec(H,vector<char>(W));
    vector<vector<int>>co(H,vector<int>(W,0));
    REP(i,H){
        REP(j,W){
            cin>>vec[i][j];
            if(vec[i][j]=='#'){
                for(int k=-1;k<=1;k++){
                    for(int s=-1;s<=1;s++){
                        if(i+k>=0&&i+k<=H-1&&j+s>=0&&j+s<=W-1){
                            co[i+k][j+s]++;
                        }
                    }
                }
            }
        } 
    }
    REP(i,H){
        REP(j,W){
            if(vec[i][j]=='.') cout<<co[i][j];
    		else cout<<vec[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  string s;
  cin >> s;
  bool ret = true;
  ret &= s.size() >= 4 && s[0] == 'Y';
  ret &= s.size() >= 4 && s[1] == 'A';
  ret &= s.size() >= 4 && s[2] == 'K';
  ret &= s.size() >= 4 && s[3] == 'I';
  if(ret) cout << "Yes\n";
  else cout << "No\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

using namespace std;

const int P = 1000000007;
const long long inf = 1000000000000000;

long long power(long long x, long long t) {
	long long ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}

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

	int n, k;
	cin >> n >> k;

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

	long long t = 1;
	if(n == k) {
		for(int i = 0; i < n; ++i) {
			t = (t * a[i] % P + P) % P;
		}
		cout << t << '\n';
		exit(0);
	}

	bool pos = false;
	bool zero = false;
	for(int i = 0; i < n; ++i) {
		if(a[i] > 0) {
			pos = true;
		}
		if(a[i] == 0) {
			zero = true;
		}
	}

	sort(a.begin(), a.end(), [&] (long long i, long long j) {
		return abs(i) > abs(j);
	});

	if(!pos) {
		if(k % 2 == 1) {
			sort(a.begin(), a.end(), [&] (long long i, long long j) {
				return i > j;
			});
		} else {
			sort(a.begin(), a.end());
		}

		long long ans = 1;
		for(int i = 0; i < k; ++i) {
			ans = (ans * a[i] % P + P) % P;
		}
		
		cout << ans << '\n';
		exit(0);
	}

	long long ans = 1;
	int minus = 0;
	for(int i = 0; i < k; ++i) {
		ans = ans * abs(a[i]) % P;
		if(a[i] < 0) {
			minus += 1;
		}
	}

	if(minus % 2 == 0) {
		cout << ans << '\n';
		exit(0);
	}

	long long nxtpos = inf;
	long long nxtneg = inf;
	long long lastpos = inf;
	long long lastneg = inf;
	for(int i = k; i < a.size(); ++i) {
		if(a[i] >= 0) {
			nxtpos = a[i];
			break;
		}
	}
	for(int i = k; i < a.size(); ++i) {
		if(a[i] <= 0) {
			nxtneg = -a[i];
			break;
		}
	}
	for(int i = k - 1; i >= 0; --i) {
		if(a[i] >= 0) {
			lastpos = a[i];
			break;
		}
	}
	for(int i = k - 1; i >= 0; --i) {
		if(a[i] <= 0) {
			lastneg = -a[i];
			break;
		}
	}

	bool X = (nxtpos != inf) && (lastneg != inf);
	bool Y = (nxtneg != inf) && (lastpos != inf);

	if(X && Y) {
		if(nxtpos * lastpos > nxtneg * lastneg) {
			ans = ans * power(lastneg, P - 2) % P * nxtpos % P;
		} else {
			ans = ans * power(lastpos, P - 2) % P * nxtneg % P;
		}
	} else if(X) {
		ans = ans * nxtpos % P * power(lastneg, P - 2) % P;
	} else if(Y) {
		ans = ans * nxtneg % P * power(lastpos, P - 2) % P;
	} else if(zero) {
		ans = 0;
	}

	cout << ans << '\n';

	return 0;
}


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



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

	bool easy = true;

	for (int i = 0; i < n.size(); i++) {
		if (i % 2 == 1) {
			if (n[i] == 'R')
				easy = false;
		}
		else {
			if (n[i] == 'L')
				easy = false;
		}
	}

	cout << (easy ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
    string ans;
    if(x%3==0||y%3==0||(x+y)%3==0)ans="Possible";
    else ans = "Impossible";
      cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
if N==1:
  print(1)
else:
  A.sort()
  import numpy as np

  l = np.array([0] * (10**6 + 10))
  m = np.array([0] * (10**6 + 10))
  for i in range(N):
    l[A[i]] += 1
    m[A[i]] += 1

  ans = 0
  length = len(l)
  for i in range(length):
    if l[i]==1:
      ans += 1
    
    if m[i]>=1:
      l[i::i] = 0

  print(ans)

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

int main(){
    long long D,t=1,N;
    cin >> D >> N;
    for(int i=0;i<D;i++){
        t*=100;
    }
    if(N!=100)
    cout << t*N << endl;
    else
    cout << t*101 << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int N;
    cin >> N;
    int V[N], C[N];
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    int ans = 0;
    rep(i, N){
        int score = V[i] - C[i];
        if(score > 0) ans = ans + score;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{   
    int X, N;
    cin >> X >> N;
    if(N == 0) cout << X << endl;
    
    else {
    vector<int> P(210);
    for(int i = 0; i <= N; i++) {
        int a;
        cin >> a;
        P.at(a) = 1;
    }
    int ans = 10000;
    int check = 114514;
    for(int i = 0; i <= 200; i++)  {
      if (P.at(i) != 1 and chmin(check, abs(i - X))==true) {
          
          ans = i;
      }
          
    }  

    cout << ans << endl;
    }
}


Measured memory_bytes: 3660
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
ans = 0

for i in range(n):
  cnt = b[i] - a[i]
  if cnt > 0:
    ans += a[i]
    if a[i+1] >= cnt:
      ans += cnt
      a[i+1] -= cnt
    else:
      ans += a[i+1]
      a[i+1] =0
      
    
  else:
    ans += b[i]

print(ans)

Measured memory_bytes: 18476
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
        x: usize,
        y: usize,
    }

    if n<=k {
        println!("{}", x*n);
    } else {
        println!("{}", x*k+y*(n-k));
    }

}


Measured memory_bytes: 2164
//BigArray.cpp (B)
#include <iostream>
using namespace std;

int main(){
  int N;
  long long K;
  cin >> N >> K;
  long long num[110000] = {0};
  for(int i = 0; i < N; i++){
    int a,b;
    cin >> a >> b;
    num[a] += b;
  }

  for(int i = 1; i <= 100000; i++){
    K -= num[i];
    if(K <= 0){
      printf("%d\n",i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 169, task d, 2020/09/02
//ms,
/*
*/

int main(void){
  int64_t N;
  vector<int> e_array;
  int ans=0;

  cin >>N;
  for(size_t i=2;i*i<=N;i++){
    int div_num=i;
    int tmp_e=0;
    while(N%div_num==0){
      N/=div_num;
      tmp_e++;
    }
    if(tmp_e != 0) e_array.push_back(tmp_e);
    //cout <<i <<" "<<tmp_e <<endl;
  }
  if(N!=1) e_array.push_back(1);

  for(size_t i=0;i<e_array.size();i++){
    int e=e_array[i];
    int counter=1;
    do{
      ans++;
      e-=counter;
    }while(e-(++counter)>=0);
  }

  cout <<ans<<endl;

  return 0;
}
/*
factorizationさえできれば勝ちじゃない？
オーダーもrootNでしょ。→正解。
素因数分解したあと、各素因数について定数時間で計算できそう。
でも算数ができなかったし実際に計算させても間に合いそうなのでそちらでいきます。
素因数分解できてなくて草。
*/


Measured memory_bytes: 3640
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;

int A[10], a[50], b[50], c[50], d[50];
int ans;
int n, m, q;
void dfs(int k)
{
    if (k == n)
    {
        int sum = 0;
        for (int i = 0; i < q; ++i)
        {
            if (A[b[i]] - A[a[i]] == c[i])
                sum += d[i];
        }
        ans = std::max(ans, sum);
        return;
    }

    for (int i = A[k - 1]; i <= m; ++i)
    {
        A[k] = i;
        dfs(k + 1);
    }
}

int main()
{
    A[0] = 1;
    std::cin >> n >> m >> q;
    for (int i = 0; i < q; ++i)
    {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }
    dfs(1);
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3188
n = int(input())
ans_t, ans_a = map(int,input().split())
for i in range(n-1):
    t, a = map(int,input().split())

    if ans_t % t == 0:
        p = ans_t//t
    else:
        p = ans_t//t + 1
    if ans_a % a == 0:
        q = ans_a // a
    else:
        q = ans_a// a + 1

    r = max(p, q)
    ans_a = a * r
    ans_t = t * r


print(ans_a + ans_t)

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
string s,a,b;
int n,m,t;
int main()
{
	int op,x;
	char ch;
	cin>>s;
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d",&op);
		if(op==1)
		t^=1;
		else
		{
			scanf("%d",&x);
			ch=getchar();
			while(ch<'a'||ch>'z')
			ch=getchar();
			x--;
			if(x^t)
			b+=ch;
			else
			a+=ch;
		}
	}
	if(t^1)
	{
		for(int i=a.size()-1;i>=0;i--)
		cout<<a[i];
		cout<<s<<b;
	}
	else
	{
		for(int i=b.size()-1;i>=0;i--)
		cout<<b[i];
		for(int i=s.size()-1;i>=0;i--)
		cout<<s[i];
		cout<<a;
	}
    return 0;
}

Measured memory_bytes: 1088
#include<stdio.h>
int main()
{
    int mekazu,saikazu,iti=0;
    int k,me[1000]={0},sai[1000]={0},i,j,counts=0;
    while(scanf("%d %d",&mekazu,&saikazu))
    {
        if(mekazu==0)break;
        for(i=0;i<mekazu;i++)
        {
            scanf("%d",&me[i]);
        }
        for(j=0;j<saikazu;j++)
        {
            scanf("%d",&sai[j]);
        }
        for(k=0;k<saikazu;k++)
        {
            if(iti>=mekazu)break;
            iti = iti + sai[k];
            iti = iti + me[iti];
            counts++;
        }
        printf("%d\n",counts);
        counts=0;
        iti = 0;
    }
    return 0;
}

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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n;
    cin >> n;
    cout << (n + 999) / 1000 * 1000 - n;

    return 0;
}

Measured memory_bytes: 3632
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int i,j,l,h[n],a[n]={0};
    for(i=0;i<n;i++) {
        cin>>h[i];
    }
    for(i=1;i<n;i++) {
        //cout<<"i="<<i<<endl;
        j=i-k>=0?i-k:0;
        int mn=INT_MAX;
        while(i>j) {
            //cout<<"j="<<j<<endl;
            mn=min(mn,a[j]+abs(h[i]-h[j]));
            //cout<<"mn="<<mn<<endl;
            j++;
        }
        a[i]=mn;
    }
    cout<<a[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 4296
#include <iostream>
using namespace std;
int main(){
  int t;
  int c1=0,c2=0,c3=0,c4=0;
  cin>>t;
  while(t>0){
    string s;
    cin>>s;
    if(s=="AC")
      c1++;
    else if(s=="WA")
      c2++;
    else if(s=="TLE")
      c3++;
    else if(s=="RE")
      c4++;
    t--;
  }
  cout<<"AC x "<<c1<<endl;
  cout<<"WA x "<<c2<<endl;
  cout<<"TLE x "<<c3<<endl;
  cout<<"RE x "<<c4<<endl;
  return 0;
}


Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int a,b;
    cin>>a>>b;
    int c  = 0;
    if(a==1){
        if(b==2){
            c=3;
        } else {
            c=2;
        }

    } else if(a==2){
        if(b==1){
            c=3;
        } else {
            c=1;
        }
    } else {
        if(b==1){
            c=2;
        } else {
            c=1;
        }
    }
    cout<<c<<endl;

    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define INF 1100000000
#define int long long
using namespace std;
int A[500010];
int merge_sort(int A[], int left, int right);
int merge(int A[], int left, int mid, int right);
signed main()
{
	int n;
	cin >> n;
	for(int i=0; i<n; i++)
		scanf("%lld",&A[i]);
	int ans = merge_sort(A, 0, n);
	cout << ans << endl;
	return 0;
}
int merge_sort(int A[], int left, int right)
{
	if(left + 1 < right)
	{
		int mid = (left + right) / 2;
		int v1 = merge_sort(A, left, mid);
		int v2 = merge_sort(A, mid, right);
		int v3 = merge(A, left, mid, right);
		return v1+v2+v3;
	}
	else 
		return 0;
}
int merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right -mid;
	vector<int> L(n1+1),R(n2+1);
	for(int i=0; i<n1; i++)
		L[i] = A[left + i];
	for(int i=0; i<n2; i++)
		R[i] = A[mid + i];
	L[n1] = INF;
	R[n2] = INF;
	int i = 0, j = 0;
	int cnt = 0;
	for(int k=left; k<right; k++)
	{
		if(L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			j++;
			cnt += n1 - i;
		}
	}
	return cnt;
}



Measured memory_bytes: 5984
s = input()
out = False
if s[0] != 'A':
    out = True
C = False

if s[1].isupper():
    out = True

for ss in s[2:-1]:
    if ss == 'C':
        if C:
            out = True
        C = True
    elif s.isupper():
        out = True

if not C or s[-1].isupper():
    out = True

if out:
    print('WA')
else:
    print('AC')


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

int main(int argc, char *argv[]){
    std::string S,T;
    std::cin >> S >> T;
    int count = 0;
    for(int i=0; i<3; ++i){
        if(S[i] == T[i]){
            ++count;
        }
    }
    std::cout << count << std::endl;
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int i;
  int max = 0;
  int count = 0;
  for(i = 0; i < s.size(); i++)
  {
    if(s.at(i)!='A' && s.at(i)!='T' && s.at(i)!='C' && s.at(i)!='G')
    {
       if(count > max)
       {
         max = count;
       }
       count = 0;
    }
    else
    {
      count++;
    }
  }
  if(count > max)
    {
      max = count;
    }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 1e5 + 50;
ll N, M;
vector<ll> adj[max_N];
vector<ll> top_order;
bool vis[max_N];
ll DP[max_N];

void toposort_dfs_util(ll curr)
{
    vis[curr] = true;
    for (ll &neigh : adj[curr])
    {
        if (vis[neigh])
            continue;
        toposort_dfs_util(neigh);
    }
    top_order.push_back(curr);
}

void toposort_dfs()
{
    for (ll i = 1; i <= N; ++i)
    {
        if (vis[i])
            continue;
        toposort_dfs_util(i);
    }
    reverse(top_order.begin(), top_order.end());
}

int main()
{
    cin >> N >> M;
    ll x, y;
    for (int i = 0; i < M; ++i)
    {
        cin >> x >> y;
        adj[x].push_back(y);
    }
    toposort_dfs();
    ll res = 1;
    for (int i = N - 1; i >= 0; --i)
    {
        ll curr = top_order[i];
        DP[curr] = 0;
        for (ll &neigh : adj[curr])
        {
            DP[curr] = max(DP[curr], 1 + DP[neigh]);
        }
        res = max(res, DP[curr]);
    }
    cout << res << "\n";
    return 0;
}

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

int N, M;
vector<vector<int>> graph;

int dfs(int from, vector<bool> visited, int cnt) {
    if (cnt == N - 1) return 1;

    visited[from] = true;
    int res = 0;
    for (int to : graph[from]) {
        if (visited[to]) continue;
        res += dfs(to, visited, cnt + 1);
    }
    visited[from] = false;

    return res;
}

int main() {
    cin >> N >> M;
    graph.resize(N);
    for (int i = 0; i < M; i++) {
        int u, v; cin >> u >> v; u--, v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    vector<bool> visited(N, false);
    cout << dfs(0, visited, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    long long a[n];
    for(int i = 0; i < n; i++)
        scanf("%lld",&a[i]);
    long long ans = 0;
    for(int i = 0; i < n; i++)
        ans = ans^a[i];
    for(int i = 0; i < n; i++)
        printf("%lld ",ans^a[i]);
    return 0;
}

Measured memory_bytes: 4056
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

//		件数
		int n = sc.nextInt();
		//カウンター
		int c = 0;
		int d = 0;
		//入れ子
		int z = 0;
		int x = 0;
		int box[][][] = new int[4][3][10];
	//件の繰り返し
	while(n>c){
//		棟の数
		int b = sc.nextInt();
//		階数
		int f = sc.nextInt();
//		部屋数
		int r = sc.nextInt();
//		人数
		int v = sc.nextInt();
		//0ならそのまま入れる
		if(box[b-1][f-1][r-1]==0){
			box[b-1][f-1][r-1]=v;
			z=v;
		}
		//数字が入っていれば計算する
		else{
		//boxに人数入力
			x=box[b-1][f-1][r-1]+v;
			box[b-1][f-1][r-1]=x;
		}
		c++;
	}

		//人数出力
		//棟の繰り返し
		for(int i=0;i<4;i++){
		//階の繰り返し
			for(int j=0;j<3;j++){
		//部屋のの繰り返し
				for(int k=0;k<10;k++){
			System.out.print(" "+box[i][j][k]);
				}
				System.out.println("");
			}
		if(d<3){
			System.out.println("####################");
			d++;
			}
		}


	}


}



Measured memory_bytes: 29940
#include <bits/stdc++.h>
#define nl endl
#define dbg(a) cout << #a << "=" << a << endl
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define md 1000000007

using namespace std;

int solve()
{
    ll h, w,m;
    cin>>h>>w>>m;
    vector<pair<long long, long long> > v;
    vector<long long> mpr[h+10], mpc[w+10];
    for(int i=0;i<m;i++)
    {
        ll x, y;
        cin>>x>>y;
        v.push_back({x, y});
        mpr[x].push_back(y);
        mpc[y].push_back(x);
    }
    int r=0;
    for(int i=0;i<=h;i++)
    {
        if(mpr[i].size()>mpr[r].size()) r=i;
    }
    // sort(mpr[r].begin(), mpr[r].end());
    vector<long long>  vis(w+10);
    for(auto it:mpr[r]) vis[it]=1;
    ll mx=0;
    for(int i=0;i<=w;i++)
    {
        ll ct=mpr[r].size()+mpc[i].size();
        if(vis[i]) ct--;
        mx=max(mx, ct);
    }
    vis.clear();
     r=0;
    for(int i=0;i<=w;i++)
    {
        if(mpc[i].size()>mpc[r].size()) r=i;
    }
    vis.assign(h+10, 0);
    for(auto it:mpc[r]) vis[it]=1;

    for(int i=0;i<=h;i++)
    {
        ll ct=mpr[i].size()+mpc[r].size();
        if(vis[i]) ct--;
        mx=max(mx, ct);
    }
    cout<<mx<<endl;

    return 0;
}

int main()
{
    fast;
    solve();
    return 0;
}

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int main(void){
	int n;
	char a[10];
	scanf("%s",a);
	if(strcmp(a,"Sunny") == 0){
		printf("Cloudy\n");
	} else if(strcmp(a,"Cloudy") == 0){
		printf("Rainy\n");
	} else {
		printf("Sunny\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main() {
    int n, q;
    cin >> n >> q;
    queue<string> names;
    queue<int> times;
    while (n--) {
        string input1; int input2;
        cin >> input1 >> input2;
        names.push(input1);
        times.push(input2);
    }

    int total_time = 0;
    while ( ! names.empty()) {
        string name = names.front(); names.pop();
        int time = times.front(); times.pop();
        if (time > q) {
            times.push(time - q);
            names.push(name);
            total_time += q;
        } else {
            cout << name << " " << total_time + time << "\n";
            total_time += time;
        }
    }

    return 0;
}

Measured memory_bytes: 4172
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int N, M;
	cin >> N >> M;
	scc_graph g(N);
	REP(i, M) {
		int u, v;
		cin >> u >> v;
		g.add_edge(u, v);
	}
	auto scc = g.scc();
	out(scc.size());
	for(auto v: scc) {
		cout << v.size();
		for(auto e: v) {
			cout << " " << e;
		}
		cout << endl;
	}
}

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

int main(){
    int l,d,r;
    cin >> l >> r >> d;
    int cnt = 0;
    for(int i = l ; i <= r; i++){
        if(i % d == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    int k; cin >> k;
    vector<char> d(k);
    rep(i, k) cin >> d.at(i);

    int tmp = 10*n;
    for(int i=n; i<=tmp; i++){
        string t = to_string(i);
        bool ng = false;
        for(int j=0; j<t.size(); j++){
            for(int l=0; l<k; l++){
                if(t.at(j)==d.at(l)){
                    ng = true;
                    break;
                }
            }
            if(ng){
                break;
            }
        }
        if(ng){
            continue;
        }
        cout << i << endl;
        return 0;
    }
    return 0;
}


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

int d[11][11];

void init(){
  for(int i = 0; i < 11; i++){
    for(int j = 0; j < 11; j++){
      if(i == j) d[i][j] = 0;
      else d[i][j] = 1e9;
    }
  }
}

int main(void){
  int n;
  while(true){
    cin >> n;
    if(!n) break;
    int a, b, c, m = 0;
    init();

    for(int i = 0; i < n; i++){
      cin >> a >> b >> c;
      d[a][b] = c;
      d[b][a] = c;
      m = max(max(m, a), b);
    }

    for(int k = 0; k <= m; k++){
      for(int i = 0; i <= m; i++){
        for(int j = 0; j <= m; j++){
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }

    int town, mincost = 1e9;

    for(int i = 0; i <= m; i++){
      int sum = 0;
      for(int j = 0; j <= m; j++){
        sum += d[i][j];
      }
      if(sum < mincost){
        town = i;
        mincost = sum;
      }
    }

    cout << town << " " << mincost << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;

  priority_queue<ll> u, v, w;
  for(ll i = 0; i < a; i++) { ll x; cin >> x; u.push(x); }
  for(ll i = 0; i < b; i++) { ll x; cin >> x; v.push(x); }

  vector<ll> out; out.reserve(x + y + c);
  for(ll i = 0; i < x; i++) { out.push_back(u.top()); u.pop(); }
  for(ll i = 0; i < y; i++) { out.push_back(v.top()); v.pop(); }
  for(ll i = 0; i < c; i++) {
    ll z; cin >> z; out.push_back(z);
  }

  sort(out.rbegin(),out.rend());

  ll tot = 0;
  for(ll i = 0; i < (x + y); i++)
    tot += out[i];

  cout << tot << endl;

  return 0;
}


Measured memory_bytes: 4084
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    ll C[3]={0};
    ll mul=1;
    FORI(i,1,N+1)
    {
        READV(A);
        ll eq=0;
        FORI(j,0,3)
        {
            if(A==C[j])
            {
                eq++;
            }
        }
        mul=(mul*eq)%MOD;
        FORI(j,0,3)
        {
            if(A==C[j])
            {
                C[j]++;
                break;
            }
        }
    }
    cout<<mul<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

void solve() {
    std::vector<int> xs(4);
    for (auto& x : xs) std::cin >> x;
    std::sort(xs.begin(), xs.end());

    std::cout << std::abs((xs[3] + xs[0]) - (xs[2] + xs[1]))
              << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;main(int N){cin>>N;int A[N],B[N],c[N+1]={},n,t,i;rep(i,N)cin>>A[i];rep(i,N)cin>>B[i];rep(i,N)c[A[i]]++,c[B[i]]++;if(*max_element(c,c+N+1)>N)printf("No");else{printf("Yes ");queue<int> s;rep(i,N)if(A[i]==B[i])s.push(i);while(!s.empty()){n=s.front(),t=rand()%N;s.pop();if(A[n]!=B[t]&A[t]!=B[n])swap(B[n],B[t]);else s.push(n);}rep(i,N)cout<<B[i]<<" ";}}

Measured memory_bytes: 6848
from bisect import bisect

INF = 10**24

A, B, Q = map(int, input().split())
S, T, X = [[int(input()) for _ in range(m)] for m in [A, B, Q]]

S = [-INF] + S + [INF]
T = [-INF] + T + [INF]

for x in X:
    s_i = bisect(S, x)
    t_i = bisect(T, x)
    points = [S[s_i-1], S[s_i], T[t_i-1], T[t_i]]
    min_cost = INF
    for j, p_j in enumerate(points):
        for k, p_k in enumerate(points):
            if j//2 == k//2:
                continue
            cost = abs(p_j-x) + abs(p_k-p_j)
            min_cost = min(min_cost, cost)
    print(min_cost)


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

typedef long long ll;

ll f[88];

int main()
{
    f[0]=2;
    f[1]=1;
    for(int i=2; i<87; i++)
        f[i]=f[i-1]+f[i-2];

    int n;
    cin>>n;
    cout<<f[n]<<endl;

    return 0;
}


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

using namespace std;

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

	int n = s.length();
    int ans[n];
	for(int i = 0; i < n; i++){
        ans[i]=0;
    }

	int cnt = 1;
    int a = 0;
	for(int i = 1; i < n; i++){
		if(s[i] == s[i-1]){
            cnt++;
        }else{
			if(s[i]=='L'){
				ans[i] += cnt/2;
				ans[i-1] += (cnt+1)/2;
				a = i;
			}else{
				ans[a] += (cnt+1)/2;
				ans[a-1] += cnt/2;
			}
			cnt=1;
		}
	}
	ans[a] += (cnt+1)/2;
	ans[a-1] += cnt/2;


	for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
	cout << endl;


	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;

int main()
{
	char s;
	scanf("%c",&s);
	if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u') printf("vowel\n");
	else printf("consonant\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

#define int long long

int a[500000], b[500000], sa, t, ans;

signed main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
    	cin >> a[i] >> b[i];
    	sa += a[i];
    	if (a[i] != b[i]) t = 1;
    }
    for (int i = 0; i < n; i++)
    {
    	if (a[i] > b[i])
    	{
    		ans = max(ans, sa - b[i]);
    	}
    }
    cout << ans;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool d=true;
  for (int i=0;i<s.size();i++){
    for (int j=i+1;j<s.size();j++){
      if(s[i]==s[j]){
        d=false;
      }
    }
  }
  if(d){
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}

Measured memory_bytes: 256
from itertools import permutations


N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

for i, p in enumerate(permutations(range(1, N+1))):
    if list(p) == P:
        p_num = i
    if list(p) == Q:
        q_num = i
print(abs(p_num-q_num))


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

using namespace std;

int main(void) {

	int x;
	cin >> x;

	int max = 1;
	for (int i = 2; i < x; i++) {
		for (int j = 2; j < x; j++) {
			int value = pow(i, j);
			if (value > x)
				break;
			if (value > max)
				max = value;
		}
	}
	cout << max;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll res=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			int t=__gcd(i,j);
			for(int k=1;k<=n;k++){
				res+=__gcd(t,k);
			}
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
info = [0 for i in range(10**6)]
mid = 5*10**5

for i in range(n):
    if(a[i]<=2*10**5):
        num = a[i] - i
        info[mid + num] += 1
#print(info[mid-8:mid+8])
ans = 0
for i in range(n):
    if(a[i]<=2*10**5):
        num = a[i] - i
        ans += info[mid + num - a[i]*2]

print(ans)



Measured memory_bytes: 163296
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    struct Matrix
    {
        ll a[3][3];Matrix(){memset(a,0,sizeof a);}
        Matrix operator * (Matrix b) {Matrix c;for(int k=0;k<3;k++) for(int i=0;i<3;i++) for(int j=0;j<3;j++) (c.a[i][j]+=a[i][k]*b.a[k][j])%=MOD;return c;}
        friend Matrix operator ^ (Matrix x,int e)
        {
            Matrix ans;for(int i=0;i<3;i++) ans.a[i][i]=1;GG(e<0);
            while(e){if(e&1)ans=ans*x;x=x*x;e>>=1;}return ans;
        }
    };
    int pos[N];
    void main()
    {
        Matrix A,B;
        A.a[0][0]=A.a[0][2]=A.a[1][1]=A.a[2][0]=A.a[2][1]=1;A.a[1][0]=A.a[1][2]=A.a[2][2]=2;
        B.a[0][0]=B.a[1][1]=B.a[2][0]=B.a[2][1]=B.a[2][2]=1;B.a[1][0]=2;

        int n=qread(),m=qread();Matrix ans;ans.a[0][0]=ans.a[2][0]=1;ans.a[1][0]=2;
        for(int i=1;i<=m+1;i++)
        {
            pos[i]=(i>m?n:qread());
            ans=(A^(pos[i]-pos[i-1]-1))*ans;if(i<=m) ans=B*ans;
            // puts("");
        }write(ans.a[2][0]);
    }//(ans+MOD)%MOD
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define MX 32
using namespace std;

int n, m, c;
long long f1[MX+1], f2[MX+1], t = 1, ans = 1;

int main(){
  scanf("%d%d", &n, &m);
  f1[0] = 1;
  for(int i = 1; i <= MX; i++){
    t = t * i % MOD;
    f1[i] = f1[i-1] * (n-1+i) % MOD;
  }
  f2[MX] = 1;
  for(int i = MOD-2; i; i/=2){
    if(i&1) f2[MX] = f2[MX] * t % MOD;
    t = t*t % MOD;
  }
  for(int i = MX; i >= 1; i--){
    f2[i-1] = f2[i] * i % MOD;
    f1[i] = f1[i] * f2[i] % MOD;
  }
  for(int i = 2; i*i <= m; i+=2){
    for(c = 0; m%i == 0; c++, m/=i);
    if(c) ans = ans * f1[c] % MOD;
    if(i == 2) i--;
  }
  if(m-1) ans = ans * f1[1] % MOD;
  
  printf("%lld", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a, b, c, d;
  double x,y,z;
  scanf("%d %d", &a, &b);
  c = a / b;
  d = a % b;
  x = a;
  y = b;
  z = x /y;
  printf("%d %d %lf\n", c, d, z);
  return 0;
}


Measured memory_bytes: 2000
mod=998244353
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    exit()
z=[0]*n
for i in d:
    z[i]+=1
if z[0]!=1:
    print(0)
    exit()
ans=1
i=0
while n>0:
    if z[i]==0:
        print(0)
        exit()
    if i>0:
        ans*=pow(z[i-1],z[i],mod)
        ans%=mod
    n-=z[i]
    i+=1
print(ans)

Measured memory_bytes: 14396
<?php
$input = trim(fgets(STDIN));
list($n) = explode(' ', $input);

$inputs = [];
$count = 0;
while($count < $n) {
    $input = trim(fgets(STDIN));
    list($x, $y, $h) = explode(' ', $input);
    $inputs[$count]['x'] = $x;
    $inputs[$count]['y'] = $y;
    $inputs[$count]['h'] = $h;

    $count++;
}
for($cx=0; $cx<=100; $cx++) {
    for($cy=0; $cy<=100; $cy++) {
        foreach($inputs as $input) {
            if($input['h'] == 0) continue;
            $ch = max($input['h'] + abs($input['x'] - $cx) + abs($input['y'] - $cy), 0);
            if($ch > 0) break;
        }

        $ok = true;
        foreach($inputs as $input) {
            if($input['h'] != max($ch - abs($input['x'] - $cx) - abs($input['y'] - $cy), 0)) {
                $ok =false;
                break;
            }
        }

        if($ok) {
            echo $cx . ' ' . $cy . ' ' . $ch;
            exit;
        }
    }
}



Measured memory_bytes: 4604
#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>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int p,q,r;
    cin >> p >> q >> r;
    int ret = 0;
    if (p >= q && p >= r)
    {
        ret = q + r;
    } 
    else if ( q >= p && q >= r)
    {
        ret = p + r;
    }
    else 
    {
        ret = p + q;
    }

    cout << ret << endl;
}

Measured memory_bytes: 256