akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
const int MAX = 510000;
const int MOD = 1000000007;
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;
}
int main(){
    long long N,M;
    cin>>N>>M;
    //abs(N-M)>=2なら問答無用で0
    if(abs(N-M)>=2){
        cout << 0 << endl;
        return 0;
    }

    //N!=Mなら犬とサルの場所は確定
    //N>Mなら犬が外、M>Nならサルが外
    //並べ方はN!*M!
    //N=Mならば、犬サル犬サル・・・OR サル犬サル犬・・・の2パターン
    //よってN!*M!*2
    long long ans=1;

    rep2(i,1,N+1){
        ans*=i;
        ans=ans%MOD;
    }
    rep2(i,1,M+1){
        ans*=i;
        ans=ans%MOD;
    }

    if(N==M){
        ans=(ans*2)%MOD;
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3624
def main():
    
    inp = input()
    dat = inp.strip().split(" ")

    pa = int(dat[0])
    pb = int(dat[1])
    pc = int(dat[2])
    maxd = int(dat[3])

    if (abs(pa-pc) <= maxd):
        print("Yes")
    elif (abs(pa-pb) <= maxd) and (abs(pb-pc) <= maxd):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n,a,b; cin>> n >> a >> b;
    if((b-a-1)%2!=0) cout << "Alice" << endl;
    else cout << "Borys" << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    int ans=0;
    rep(i,n+1){
      if(i*i>n) break;
      rep(j,i+1){
        if(i*i+j*j>n) break;
        rep(k,j+1){
          if(i*i+j*j+k*k>n) break;
          rep(l,k+1){
            if(i*i+j*j+k*k+l*l>n) break;
            if(i*i+j*j+k*k+l*l==n) ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

const LL MAXN = 1e6+10;
bool isPrime[MAXN];
VLL primes;

void sieve() {
	rep(p, 2, (LL)MAXN)	isPrime[p] = true;
	rep(p, 2, (LL)MAXN) {
		if(isPrime[p]) {
			primes.push_back(p);
			for(LL j = p*p; j < MAXN; j += p)	isPrime[j] = false;
		}
	}
}

int main() {
	sieve();
	sll(n);
	map<LL,LL> cnt;
	for(LL p : primes) {
		while(n % p == 0) {
			n /= p;
			cnt[p]++;
		}
	}

	LL ans = 0;
	for(auto it : cnt) {
		LL c = it.second;
		rep(i, 1, 100) {
			if((i*(i+1)/2) > c) {
				ans += i-1;
				break;
			}
		}
	}
	if(n != 1)	ans++;
	pll(ans); nl;
}


Measured memory_bytes: 5096
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define read	freopen("input.txt", "r", stdin)
#define write	freopen("output.txt", "w", stdout)

using namespace std;

int main()
{
	// read;
	// write;

    int n;
    cin>>n;

    int h[n], ans[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    ans[0] = 0;
    ans[1] = abs(h[0]-h[1]);

    for(int i=2;i<n;i++){
        ans[i] = min( abs(h[i]-h[i-1])+ans[i-1], abs(h[i]- h[i-2])+ans[i-2] );
    }
    cout<<ans[n-1];


}
    



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[10005];
int main(){
	int ans = 0;
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		while(a[i]%2 == 0){
			a[i]/=2;
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#!/usr/bin/ruby

N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P  = gets.chomp.split(" ").map(&:to_i)
T  = gets.chomp.split("")

k = []
total = 0
T.each_with_index{|t, i|
  n = ''
  #puts "k = #{k.join("")}"
  if k.size == K
     n = k.shift(1)[0]
  end
  if t == 'r'
     # p
     if n == 'p'
       if i + K < T.size
          k << T[i+K]
       else
          k << 'r'
       end
     else
       total += P
       k << 'p'
     end
  elsif t == 's'
     # r
     if n == 'r'
       if i + K < T.size
          k << T[i+K]
       else
          k << 's'
       end
     else
       total += R
       k << 'r'
     end
  elsif t == 'p'
     # s
     if n == 's'
       if i + K < T.size
          k << T[i+K]
       else
          k << 'p'
       end
     else
       total += S
       k << 's'
     end
  end

}


puts total


Measured memory_bytes: 16252
/* *>>>>>Anshit_Bhardwaj<<<<<* */
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << ' ' << y << endl
#define dbg3(x, y, z) cout << x << ' ' << y << ' ' << z << endl
#define mod 1000000007
using namespace std;

const ll mx = 1e18;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, a;
    cin >> n;
    vector<ll> in(n);
    f(i, 0, n){
        cin >> in[i];
    }
    int zeros = 0;
    f(i, 0, n){
        if(in[i] == 0){
            zeros++;
        }
    }
    if(zeros > 0){
        cout << 0 << endl;
    }else{
        ll tmp, ans = 1;
        f(i, 0, n){
            if(__builtin_mul_overflow(in[i], ans, &tmp)){
                cout << -1 << endl;
                return 0;
            }
            tmp = ans * in[i];
            ans = tmp;
        }
        if(ans <= mx){
            cout << ans << endl;
        }else{
            cout << -1 << endl;
        }
    }
}

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

const int MAXN = 1010;
typedef long long LL;
int pri[MAXN], bak, n;
int ispri(int x) {
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0) return false;
	return true;
}
LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
LL get(int x, int y) {
	if (x < 1 || y < 1 || x > n || y > n) return 1;
	if ((x & 1) == (y & 1))
		return pri[x + y >> 1] * pri[x + n * 3 - y + 1 >> 1];
	return lcm(lcm(get(x - 1, y), get(x, y - 1)), lcm(get(x + 1, y), get(x, y + 1))) + 1;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n; n += 2;
	int now = 2;
	while (bak < n * 2) {
		if (ispri(now)) pri[++bak] = now;
		++now;
	}
	for (int i = 2; i < n; ++i, std::cout << '\n')
		for (int j = 2; j < n; ++j)
			std::cout << get(i, j) << ' ';
	return 0;
}


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

int main() {
  int N, K;
  int sum = 0;
  cin >> N;
  cin >> K;
  rep(i, N){
  int X;
  cin >> X;
  if(X <= K){
   if(X <= K - X){
    sum += X * 2;
     }else{
    sum += (K - X) * 2;}
    }
  if(X > K){
    sum += (X - K) * 2;
   }
  }
  cout << sum <<endl;
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second


void solve(){
	
	int n,k;
	cin>>n>>k;
	int arr[n+1];
	rep(i,1,n+1)
		cin>>arr[i];

	int dp[n+1][k+1];

	dp[0][0]=1;

	rep(j,1,k+1)
		dp[0][j]=0;

	rep(i,1,n+1){
		int pref_sum[k+1];
		pref_sum[0] = dp[i-1][0];
		rep(j,1,k+1){
			pref_sum[j] = (dp[i-1][j] + pref_sum[j-1])%hell;
		}
		rep(j,0,k+1){
			// if(j==0){
			// 	dp[i][j]=1;
			// }
			int temp = pref_sum[j];
			int unr = j-arr[i]-1;
			if(unr>=0)
				temp = (temp - pref_sum[unr]+hell)%hell;
			dp[i][j]=temp;

		}
	}
	cout<<dp[n][k]<<endl;
}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 80000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;

    while(scanf("%d%d",&a,&b)==2)
    {
        if(a<b)
        {
            cout<<"a < b"<<endl;
        }
        else if(a>b)
        {
            cout<<"a > b"<<endl;
        }
        else
        {
            cout<<"a == b"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

//ここから書き始める
//実験

int gcd_2(int a , int b){
	int A = max(a,b); //大きいほう
	int B = min(a,b);//小さいほう
	int c =-1;
	int ans = 1 ;
	while(c!=0){
		c = A % B;
		if(c==0){//Bが最大公約数
			ans = B;
			break;
		}
		else{//B大公約数ではないので，AをBに，BをCにしてもう一度
			A = B; 
			B = c; 
		}
	}
	return ans;//cが最大公約数 
}
int main(){
	ll a,b, c, d;// A以上B以下のうち CでもDでも割り切れないものの個数	
	cin >> a>> b >> c >> d;
	ll ans = 0;
	ll whole = b - a +1  ;//考えられる個数 ここからcかdで割り切れる物の数を引くわけだ。
	ll revans = 0;
	// c 
	revans += b / c - (a-1) / c;
	// d
	revans += b / d - (a-1) / d;
	//c*d
	ll cd = c*d/gcd_2(c,d);
	revans -= b/(cd) -(a-1)/(cd);
	ans = whole - revans ;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long mod = 1LL * 1e9 + 7;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> in;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x--;
    if (i == 0 || in.back() != x) in.push_back(x);
  }
  int siz = (int) in.size();
  vector<long long> dp(siz), cnt(200005);
  for (int i = 0; i < siz; i++) {
    assert(in[i] >= 0);
    if (i == 0) {
      dp[i] = 1;
      cnt[in[i]] = dp[i];
      continue;
    }
    assert(i > 0);
    dp[i] = dp[i - 1] + cnt[in[i]];
    dp[i] %= mod;
    cnt[in[i]] = dp[i];
    cnt[in[i]] %= mod;
  }
  cout << dp.back() << endl;
  return 0;	
}


Measured memory_bytes: 5104
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
S=get_i
Q=gets.to_i
T=get_i
ans=0
T.each do|t|
  head=0
  tail=N-1
  while head<=tail
      mid=(head+tail)/2
      if S[mid]==t
          ans+=1
          break
      elsif S[mid]>t
          tail=mid-1
      else
          head=mid+1
      end
  end
end
puts ans


Measured memory_bytes: 15652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] mochi = new int[n];
        for (int i = 0; i < n; i++){
            mochi[i] = sc.nextInt();
        }
        Arrays.sort(mochi);
        int count = 0;
        int now = 101;
        for (int i = n - 1; 0 <= i; i--){
            if (mochi[i] < now) {
                count++;
                now = mochi[i];
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22356
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<Pll> V(N);
    REP(i, N) {
        ll x, l;
        cin >> x >> l;

        V[i] = {x+l, x-l};
    }

    sort(V.begin(), V.end());

    ll ans = 0;
    ll cur = -INF;
    REP(i, N) {
        if (V[i].se >= cur) {
            ++ans;
            cur = V[i].fi;
        }
    }

    cout << ans << endl;


}


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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> m;
  vector<int> b(m);
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  vector<int> v;
  set_difference(begin(a), end(a), begin(b), end(b), inserter(v, end(v)));
  for(int i = 0; i < v.size(); i++){
    cout << v[i] << "\n";
  }
  return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
char S[111];
ll i, j, k;
int main(){
    scanf("%lld%s", &N,S);
    if(N%2==1){
        printf("No");
        return 0;
    }
    fornum(i,0,N/2){
        if(S[i]!=S[i+N/2]){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{
  public static void main(String[] args){
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = br.readLine();
      String[] str2 = str.split(" ");
      int[] x = {Integer.parseInt(str2[0]), Integer.parseInt(str2[1]), Integer.parseInt(str2[2])};
      Arrays.sort(x);
      System.out.println(x[0] + " " + x[1] + " " + x[2]);
    } catch (IOException e){
      System.err.println(e.toString());
    }
  }
}


Measured memory_bytes: 24332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
ll INF = 1e9+7;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n+2);
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    priority_queue<P> que;
    for(int i = 1; i <= n; i++)
    {
        cin >> b[i];
        que.push(P(b[i], i));
    }
    b[0] = b[n];
    b[n+1] = b[1];
    ll ans = 0;
    while(que.size())
    {
        P p1 = que.top();
        que.pop();
        ll pos = p1.second;
              if(p1.first == a[pos]) continue;
        ll cand, up1;
        ll dec = b[pos-1] + b[pos+1];
        if(p1.first <= dec)
        {
          cout << -1 << endl;
          return 0;
        }
        if(que.size() == 0)
        {
            cand = a[pos];
            ll x = p1.first - cand;
            up1 = p1.first - dec * (x/dec);
            ans += (x/dec);
            if(x % dec != 0)
            {
                cout << -1 << endl;
                return 0;
            }
            else
            {
              cout << ans << endl;
              return 0;
            }
        }
        else
        { 
            P p2 = que.top();
            cand = max(dec, a[pos]);
            ll x = p1.first - cand;
            x--;
            up1 = p1.first - dec * (x/dec + 1);
            ans += (x/dec + 1);
        }
        if(up1 < a[pos])
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            b[pos] = up1;
            if(pos == n) b[0] = b[pos];
            if(pos == 1) b[n+1] = b[pos];
            if(a[pos] != b[pos])
            {
                que.push(P(b[pos], pos));
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e9;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

int main() {
    int a;
    cin >> a;
    int ans = a + pow(a, 2) + pow(a, 3);
    cout << ans;
    return 0;
}

Measured memory_bytes: 4032
// https://atcoder.jp/contests/abc051/tasks/abc051_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K, S;
    cin >> K >> S;
    ll ans = 0;
    REP(a, K + 1) REP(b, K + 1) {
        if (a + b <= S && a + b + K >= S)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>      
#include <numeric> 
#include <iterator>
#include <map> 
#include <boost/math/common_factor.hpp>
using namespace std; 
#define ll long long int
int main()
{
  ll a,b;
  cin>>a>>b;
  cout<<boost::math::lcm(a,b)<<endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d,e,f,X,Y;
	double x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
		x=(double)(c*(a*e-b*d)-b*(a*f-c*d))/(double)(a*(a*e-b*d));
		y=(double)(a*f-c*d)/(double)(a*e-b*d);
		x*=10000;y*=10000;
		X=x;Y=y;
		if(X%10>=5){
			X+=10;
		}
		X/=10;
		X*=10;
		if(Y%10>=5){
			Y+=10;
		}
		Y/=10;
		Y*=10;
		x=X;y=Y;
		x/=10000;
		y/=10000;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}


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

// @@ !! LIM(sieve)
// --> sieve
// ---- inserted library file sieve.cc

// sieve(upto) returns the list of prime numbers up to upto.
//   Size: upto(1e8).size() ... 5.7e6,  upto(1e9).size() ... 5.1e7
//   Performance: upto(1e8) ... 0.7sec,   upto(1e9) ... 9.2sec
vector<int> sieve(int upto) {
  vector<int> res;
  vector<bool> tbl(upto+1);
  ll lim = (int)(sqrt((double)upto)) + 1;
  for (int x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (int y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

/*
  Prime Factorization
    Two versions:
      - prfac(n)
      - prfac(n, primes)
 */

vector<pair<ll, int>> prfac(ll n, const vector<int>& primes) {
  //      primes should contain prime numbers at least up to sqrt(n)
  vector<pair<ll, int>> res;
  ll x = n;
  for (ll p : primes) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    int c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

vector<pair<ll, int>> prfac(ll n) {
  return prfac(n, sieve((int)(sqrt((double)n)) + 1));
}

/*
    List of divisors
      - getDivisors(n)
    Note: the results are NOT sorted
 */

// gdsub ... aux function used in getDivisors()
vector<ll> gdsub(int i, int n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll p  = fs.at(i).first;
  int r = fs.at(i).second;
  ll pp = p;    // pp = p^m, for m \in [1, r]
  int partOrigLen = part.size();
  for (int m = 1; m <= r; m++) {
    for (int j = 0; j < partOrigLen; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n) {
  auto fs = prfac(n);
  return gdsub(0, fs.size(), fs);
}

// ---- end sieve.cc
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll cnt = 0;
  for (auto [p, r] : prfac(N)) {
    ll loc = 1;
    while (true) {
      if (r >= loc) {
	cnt++;
	r -= loc;
	loc++;
      }else {
	break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 4016
S_p = input()
T = input()
S_len = len(S_p)
T_len = len(T)

if S_len < T_len:
    print("UNRESTORABLE")
    exit(0)

ans = []
for offset in range(S_len - T_len + 1):
    isRestorable = True
    for d in range(T_len):
        if S_p[offset+d] == "?":
            continue
        elif S_p[offset+d] != T[d]:
            isRestorable = False
            break
        else:
            pass
    if isRestorable:
        tmp = S_p[:offset] + T + S_p[offset+T_len:]
        ans.append(tmp.replace("?", "a"))
if len(ans) == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])


Measured memory_bytes: 8968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;
ll n,k,ans;
int main()
{
	scanf("%lld%lld",&n,&k);
	for(ll i=k,x,y;i<=n+1;++i){
		x=((i-1)*i>>1);
		y=((n*2-i+1)*i>>1);
		ans+=(y-x)+1;
		ans%=M;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int a = 100 * r + 10 * g + b;
  if (a % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, Q;
  cin >> N >> Q;
  vector<char> S(N);
  vector<int> memo(N);
  cin >> S.at(0);
  memo.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> S.at(i);
    if (S.at(i) == 'C' && S.at(i - 1) == 'A') {
      memo.at(i)++;
    }
    memo.at(i) += memo.at(i - 1);
  }
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << memo.at(r - 1) - memo.at(l - 1) << endl;
  }
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n, k;
ll s;
void solve() {
    cin >> n >> k >> s;

    rep(i, k) cout << s << " ";
    rep(i, n - k) cout << (s != 1 ? s - 1 : 2) << " ";
    cout << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int h,w; cin >> h >> w;
  vector<vector<char> > f(h,vector<char>(w));
  vector<vector<int> > g(h,vector<int>(w));
  rep(i,h)rep(j,w) cin >> f[i][j];
  int cnt;
  rep(i,h){
    rep(j,w){
      if(j==0) cnt=1;
      if(f[i][j]=='#') cnt=0;
      g[i][j]+=cnt;
      cnt++;
    }
  }
  rep(i,h){
    for(int j=w-1;j>=0;j--){
      if(j==w-1) cnt=1;
      if(f[i][j]=='#') cnt=0;
      g[i][j]+=cnt;
      cnt++;
    }
  }
  rep(j,w){
    rep(i,h){
      if(i==0) cnt=1;
      if(f[i][j]=='#') cnt=0;
      g[i][j]+=cnt;
      cnt++;
    }
  }
  rep(j,w){
    for(int i=h-1;i>=0;i--){
      if(i==h-1) cnt=1;
      if(f[i][j]=='#') cnt=0;
      g[i][j]+=cnt;
      cnt++;
    }
  }
  int mx=0;
  rep(i,h)rep(j,w){
    chmax(mx,g[i][j]);
  }
  cout << mx-3 << endl;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
bool used[10];
int cnt;
vector<int> P,Q;
int N;
int a,b;
void dfs(int d,int now,vector<int> v){
    if(d==N){
        cnt++;
        //for(auto x:v)cout << x;
        //cout << cnt << endl;
        if(v==P)a = cnt;
        if(v==Q)b = cnt;
        return;
    }
    for(int i=1;i<=N;i++){
        if(!used[i]){
            used[i] = 1;
            v.push_back(i);
            dfs(d+1,i,v);
            v.pop_back();
            used[i] = 0;
        }
    }
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    cin >> N;
    P.resize(N);
    Q.resize(N);
    rep(i,N)cin >> P[i];
    rep(i,N)cin >> Q[i];    
    for(int i=1;i<=N;i++){
        vector<int> v;
        used[i] = 1;
        v.push_back(i);
        dfs(1,i,v);
        v.pop_back();
        used[i] = 0;
    }
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#Python Competetive Programming Template

from sys import stdin, stdout
from math import *

testing = True

def tp(s="\n"):
	if testing:
		stdout.write(str(s))

def main():
	prime = 998244353
	n, k = [int(i) for i in stdin.readline().split()]
	llist = []
	rlist = []
	for i in range(k):
		l, r = [int(i) for i in stdin.readline().split()]
		llist.append(l)
		rlist.append(r)
	dp = [0]*(n+1)
	dp[1] = 1
	cumul = [0]*(n+1)
	cumul[1] = 1

	for i in range(2, n+1):
		for j in range(k):
			lower = max(1, i-rlist[j])
			upper = i-llist[j]
			#print(lower)
			#print(upper)
			if upper < 0:
				#print("Continuing")
				continue
			out = (cumul[upper] - cumul[lower - 1] + prime) % prime
			dp[i] += out
			dp[i] %= prime

		cumul[i] = (cumul[i - 1] + dp[i])%prime

	#print(dp)
	#print(cumul)
	stdout.write("{0}\n".format(dp[n]))



main()

Measured memory_bytes: 24536
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    word = input()
    if word == "AC":
        ac += 1
    elif word == "WA":
        wa += 1
    elif word == "TLE":
        tle += 1
    elif word == "RE":
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9236
from itertools import permutations

n, m = map(int, input().split())
graph = [set(map(lambda n: int(n) - 1, input().split())) for _ in range(m)]

per_list = permutations(i for i in range(1, n))

ans = 0

for per in per_list:
    for i in range(n - 1):
        target = {0, per[i]} if not i else {per[i - 1], per[i]}
        if target not in graph:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>
#include <climits>
#include <map>
#include <queue>
#include <math.h>
#include <iomanip>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 2e5 + 20;
vector<int> G[N];
bool visited[N];
int n, m, A[N], B[N];
string s;
queue<int> q;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> s;
	s = '*' + s;
	for (int i = 0, v, u; i < m; i++) {
		cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
		if (s[v] == 'A')
			A[u]++;
		else
			B[u]++;
		if (s[u] == 'A')
			A[v]++;
		else
			B[v]++;
	}
	for (int v = 1; v <= n; v++)
		if (!A[v] || !B[v])
			visited[v] = 1, q.push(v);
	while (q.size()) {
		int v = q.front(); q.pop();
		for (int u : G[v]) {
			if (s[v] == 'A')
				A[u]--;
			else
				B[u]--;
			if ((!A[u] || !B[u]) && !visited[u])
				visited[u] = 1, q.push(u);
		}
	}
	for (int v = 1; v <= n; v++)
		if (!visited[v])
			return cout << "Yes" << endl, 0;
	cout << "No" << endl;
}































Measured memory_bytes: 12564
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll gcd(ll a, ll b);


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

	vector<ll> a(n + 1, 0);

	ll tmp;
	bool flag = true;

	rep(i, n) {
		cin >> tmp;
		a[tmp]++;
		if (a[tmp] > 2) flag = false;
		if (n % 2 == 0 && tmp % 2 == 0) flag = false;
		if (n % 2 == 1 && tmp % 2 == 1) flag = false;
	}

	ll ans = 1;
	if (a[0] > 1) flag = false;

	rep(i, n / 2) {
		ans *= 2;
		if (ans > mod) ans %= mod;
	}

	if (flag) cout << ans;
	else cout << 0;

	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

int main() {
	int repeat;
	cin >> repeat;
	int num;
	int total=0;
	int max=0;
	int old=0;

	while (repeat--) {
		cin >> num;
		old = max;
		
		if (num >= max) {
			max = num;
		}
		if (old!=max) {
			total += old;
		}
		else {
			total+=num;
		}
		
	}

	if (max<total) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
import math
from itertools import product
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def sums(a, N):
    ans = ((N//a)*((N//a)+1)//2)*a
    return ans


colors = ['R', 'G', 'B']

def complement(A, B):
    for color in colors:
        if A != color and B != color:
            return color
    

def solve():
    N = read_int()
    S = input().strip()
    right = Counter(S)
    left = Counter()
    total = 0
    for i in range(N):
        take = S[i]
        right[take] -= 1
        #
        for j in range(i):
            if S[j] != S[i]:
                color = complement(S[j], S[i])
                k = 2*i-j
                total += right[color]
                if k < N and S[k] == color:
                    total -= 1
        #
        left[take] += 1
    return total


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 69396
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

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

    std::string s;
    std::cin >> s;

    std::cout << (std::count(s.begin(), s.end(), 'R') > std::count(s.begin(), s.end(), 'B') ? "Yes" : "No") << std::endl;
}


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(15)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)

double x = 6.28318530717958623200;

int32_t main() { fastio;
	int n; cin >> n;
	pout << n * x << endl;
	return 0;
}


Measured memory_bytes: 3736
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

#define MAX_N 100

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
    int N, L[2 * MAX_N];
    cin >> N;
    REP(i, 2 * N) cin >> L[i];
    sort(L, L + 2 * N);
    int ret = 0;
    REP(i, N) ret += L[2 * i];
    cout << ret << endl;
    return 0;
}

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

int32_t main()
{
    int n;
    cin>>n;
     vector<pair<int,int>> red(n),blue(n);
     for(int i=0;i<n;i++) cin>>red[i].second>>red[i].first;
     for(int i=0;i<n;i++) cin>>blue[i].first>>blue[i].second;
     sort(red.begin(),red.end());
     sort(blue.begin(),blue.end());
     int ans=0;
     for(int i=0;i<n;i++)
     {
         for(int j=n-1;j>=0;j--)
         {
             if(!(blue[i].first>red[j].second && blue[i].second>red[j].first))continue;
             ans++;
             red[j].first=INT_MAX;
             red[j].second=INT_MAX;
             break;
         }
     }
     cout<<ans<<endl;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::map<string, int> map;
    int n;
    cin>>n;
    string s;
    int max=0;
    std::deque<string> deq;
    for (int i=0;i<n;i++) {
        cin>>s;
        if (map.find(s)==map.end()) {
            map.emplace(make_pair(s,1));
        } else {
            map.at(s)++;
        }
        if (map.at(s)>max) {
            max=map.at(s);
            deq.clear();
            deq.emplace_back(s);
        } else if (map.at(s)==max) {
            deq.emplace_back(s);
        }
    }
    sort(deq.begin(),deq.end());
    for (int j=0;j<deq.size();j++) {
        cout<<deq[j]<<endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll try1=0;//010101
    ll try2=0;//101010101
    rep(i,s.length()){
        if(i%2==0){
            if(s[i]=='1'){
                try1++;
            }
        }else{
            if(s[i]=='0'){
                try1++;
            }
        }
    }

    rep(i,s.length()){
        if(i%2==1){
            if(s[i]=='1'){
                try2++;
            }
        }else{
            if(s[i]=='0'){
                try2++;
            }
        }
    }
    cout<<min(try1,try2)<<endl;
    return  0;
}


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

int main(void) {
  ll D, N;
  cin >> D >> N;

  if (D == 0) {
    if (N == 100) {
      cout << N + 1 << endl;
    } else {
      cout << N << endl;
    }
    return 0;
  }

  if (D == 1) {
    if (N == 100) {
      cout << N * 100 + 100 << endl;
    } else {
      cout << N * 100 << endl;
    }
    return 0;
  }

  if (N == 100) {
    cout << N * 10000 + 10000 << endl;
  } else {
    cout << N * 10000 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3620
if __name__ == '__main__':
	N = int(input())
	S = input()
	w = [0 for _ in range(N)]
	e = [0 for _ in range(N)]

	for i in range(1,N):
		w[i] = w[i-1] + 1 if S[i-1] == 'W' else w[i-1]
		e[-i-1] = e[-i] + 1 if S[-i] == 'E' else e[-i]

	res = [0 for _ in range(N)]
	for i in range(N):
		res[i] = w[i] + e[i]

	print(min(res))

Measured memory_bytes: 29696
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string s;
	cin>>s;
	cout<<s.at(0)<<s.size()-2<<s.at(s.size()-1)<<endl;
}


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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll X;
    cin >> X;
    vector<ll> yakusu = enum_divisors(X);
    for (auto a : yakusu) {
        for (int i = -120; i < 120; i++) {
            ll x = a + i;
            ll y = i;
            if (pow(x, 5) - pow(y, 5) == X) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4048
#include <stdio.h>

int main()
{
  int x;
  scanf("%d",&x);
  int j;
  while (x <= 1000000)
  {
    j = 2;
    while (j <= x)
    {
      if (x == j)
      {
        printf("%d",j);
        return (0);
      }
      else if (x % j == 0)
      {
        break;
      }
      j++;
    }
    x++;
  }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	if (n == 1) {
		cout << 1 << endl;

		return 0;
	}

	int ans = 0;
	int i = 0;
	for (i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			i++;
		}
		else {
			ans++;
		}
	}
	if (i == n - 1) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
using System;

namespace ITP1_11_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            Dice dice1 = new Dice(int.Parse(str[0]), int.Parse(str[1]), int.Parse(str[2]), int.Parse(str[3]), int.Parse(str[4]), int.Parse(str[5]));
            string way = Console.ReadLine();

            foreach(char ch in way)
            {
                if (ch == 'N') { dice1.MoveNorth(); }
                else if (ch == 'S') { dice1.MoveSouth(); }
                else if (ch == 'W') { dice1.MoveWest(); }
                else if (ch == 'E') { dice1.MoveEast(); }
            }

            Console.WriteLine("{0}", dice1.topPip);
        }
    }

    class Dice
    {
        public int topPip { get; private set; }
        public int southPip { get; private set; }
        public int eastPip { get; private set; }
        public int westPip { get; private set; }
        public int northPip { get; private set; }
        public int bottomPip { get; private set; }
        
        public Dice(int topPip,int southPip,int eastPip,int westPip,int northPip,int bottomPip)
        {
            this.topPip = topPip;
            this.southPip = southPip;
            this.eastPip = eastPip;
            this.westPip = westPip;
            this.northPip = northPip;
            this.bottomPip = bottomPip;
        }


        public void MoveNorth()
        {
            int temp = this.northPip;
            this.northPip = this.topPip;
            this.topPip = this.southPip;
            this.southPip = this.bottomPip;
            this.bottomPip = temp;
        }

        public void MoveSouth()
        {
            int temp = this.southPip;
            this.southPip = this.topPip;
            this.topPip = this.northPip;
            this.northPip = this.bottomPip;
            this.bottomPip = temp;
        }

        public void MoveWest()
        {
            int temp = this.westPip;
            this.westPip = this.topPip;
            this.topPip = this.eastPip;
            this.eastPip = this.bottomPip;
            this.bottomPip = temp;
        }

        public void MoveEast()
        {
            int temp = this.eastPip;
            this.eastPip = this.topPip;
            this.topPip = this.westPip;
            this.westPip = this.bottomPip;
            this.bottomPip = temp;
        }

    }
}

Measured memory_bytes: 17920