akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    for(int i=0; i<n; ++i){
        if(s[i] == 'a'){
            if(a > 0){
                cout << "Yes" << endl;
                -- a;
            }
            else if(b > 0){
                cout << "Yes" << endl;
                -- b;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(s[i] == 'b'){
            if(b > 0){
                cout << "Yes" << endl;
                -- b;
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, m, u, v, s, t;
int d[125252][3];
vi g[125252];
constexpr int INF=1e9;

void bfs(){
	queue<int> q;
	q.push(s);
	while(q.size()){
		int x=q.front();
		q.pop();
		for(auto y : g[x]){
			REP(i, 3){
				if(d[x][i]+1<d[y][(i+1)%3]){
					d[y][(i+1)%3]=d[x][i]+1;
					q.push(y);
				}
			}
		}
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n>>m;
	REP(i, m){
		cin>>u>>v;
		--u;
		--v;
		g[u].push_back(v);
	}
	cin>>s>>t;
	--s;
	--t;
	REP(i, n){
		REP(j, 3){
			d[i][j]=INF;
		}
	}
	d[s][0]=0;
	bfs();
	// REP(i, n){
	// 	REP(j, 3){
	// 		cout<<d[i][j]<<" \n"[j==2];
	// 	}
	// }
	if(d[t][0]!=INF){
		cout<<d[t][0]/3<<'\n';
	}
	else{
		cout<<-1<<'\n';
	}
	return 0;
}


Measured memory_bytes: 7552
#include <iostream>

using namespace std;

int main(){

	int H = 0;
	int W = 0;

	cin >> H >> W;

	while (H != 0 && W != 0) {

		for (int i = 0; i < H; i++) {

			for (int u = 0; u < W; u++) {

				cout << "#";

			}

			cout << endl;

		}

		cout << endl;

		cin >> H >> W;

	}

	return 0;

}



Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int l, r;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> l >> r;
	int ans = 2019;
	for (int i = l; i < min(l + 2019, r + 1); i++) {
		for (int j = i + 1; j < min(l + 2019, r + 1); j++) {
			ans = min(ans, ((i % 2019)*(j % 2019)) % 2019);
		}
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int sx,sy,tx,ty,x,y;
    cin >> sx >> sy >> tx >> ty;
    x=tx-sx;
    y=ty-sy;
    string res;
    for(int i=0;i<x;i++){
        res=res+"R";
    }
    for(int i=0;i<y;i++){
        res=res+"U";
    }
    for(int i=0;i<x;i++){
        res=res+"L";
    }
    for(int i=0;i<y;i++){
        res=res+"D";
    }
    res=res+"D";
    for(int i=0;i<x+1;i++){
        res=res+"R";
    }
    for(int i=0;i<y+1;i++){
        res=res+"U";
    }
    res=res+"LU";
    for(int i=0;i<x+1;i++){
        res=res+"L";
    }
    for(int i=0;i<y+1;i++){
        res=res+"D";
    }
    res=res+"R";
    cout << res << endl;
    
}


Measured memory_bytes: 384
// Last Change: 01/25/2020 16:49:17.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;
  ll penalty, ac;
  vector<ll> accepted(N, 0);
  vector<ll> countWA(N, 0);

  ll p;
  string s;
  penalty = ac = 0;
  for (ll i = 0; i < M; ++i) {
    cin >> p >> s;
    --p;
    if (accepted[p] == 0) {
      if (s == "AC") {
        accepted[p] = -1;
        penalty += countWA[p];
        ++ac;
      } else {
        ++countWA[p];
      }
    }
  }
  cout << ac << " " << penalty << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    int sum = 0;
    rep(i, 1, n + 1){
        cin >> a[i];
    }
    rep(i, 1, n + 1){
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n] - 0);
    rep(i, 1, n + 1){
        int ans = sum - abs(a[i] - a[i - 1]) - abs(a[(i + 1) % (n + 1)] - a[i]) + abs(a[i - 1] - a[(i + 1) % (n + 1)]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2048
N, A, B, C, D = list(map(int, input().split()))

price_x = 0
num_x = 0
price_y = 0
num_y = 0
while True:
    if num_x >= N:
        break
    num_x = num_x + A
    price_x = price_x + B
while True:
    if num_y >= N:
        break    
    num_y = num_y + C
    price_y = price_y + D

print(min(price_x,price_y))


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

int main(){
  vector<int> s(3);
  int a,b,c; cin >> a >> b >> c;
  s[0] = abs(a-b), s[1] = abs(b-c), s[2] = abs(c-a);
  sort(s.begin(), s.end());
  if(s[0]==0 && s[1]!=0 && s[2]!=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x% mod+mod)%mod){}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n):fact(n+1), ifact(n+1) {
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k) {
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
} comb(MAX_N);

vector<int> to[MAX_N];

struct DP {
	mint dp;
	int t;
	DP(mint dp=1, int t=0):dp(dp), t(t) {}
	DP& operator+=(const DP& a) {
		dp *= a.dp;
		dp *= comb(t+a.t, t);
		t += a.t;
		return *this;
	}
	DP operator-(const DP& a) const {
		DP res(*this);
		res.t -= a.t;
		res.dp /= comb(res.t+a.t, res.t);
		res.dp /= a.dp;
		return res;
	}
	DP addRoot() const {
		DP res(*this);
		res.t++;
		return res;
	}
};

DP dp[MAX_N];

void dfs(int v, int p=-1) {
	for(int u : to[v]) {
		if(u == p) continue;
		dfs(u, v);
		dp[v] += dp[u].addRoot();
	}
}
void bfs(int v, int p=-1) {
	for(int u : to[v]) {
		if(u == p) continue;
		DP d = dp[v] - dp[u].addRoot();
		dp[u] += d.addRoot();
		bfs(u, v);
	}
}

int main() {
	int n;
	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	dfs(0);
	bfs(0);
	rep(i, n) {
		cout << dp[i].addRoot().dp << endl;
	}
	return 0;
}


Measured memory_bytes: 20224
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        string S = ReadLine();
        string ans = "";
        for (int i = 0; i < S.Length; i++)
        {
            ans += "x";
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 25832
#include<stdio.h>
#include<stdlib.h>
int main()
{
int a[3];
  int i;
  for(i=0;i<3;i++)
  {
    scanf("%d",&a[i]);
  }
  int sum=0;
  for(i=0;i<3;i++)
  {
    sum=sum+a[i];
  }
  if(sum>=22)
    printf("bust");
  else
    printf("win");
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    int a[n * 3];
    rep(i, n * 3) { cin >> a[i]; }
    ll sum_l = 0, sum_r = 0;
    ll sum_array_l[n + 1], sum_array_r[n + 1];

    priority_queue<int, vector<int>, greater<int>> q_left;
    priority_queue<int> q_right;

    rep(i, n) {
        q_left.push(a[i]);
        sum_l += a[i];

        q_right.push(a[n * 3 - i - 1]);
        sum_r += a[n * 3 - i - 1];
    }

    vector<ll> sum_l_v;
    vector<ll> sum_r_v;
    sum_l_v.push_back(sum_l);
    sum_r_v.push_back(sum_r);

    repd(i, n, 2 * n) {
        int f = q_left.top();
        if (a[i] > f) {
            q_left.pop();
            sum_l -= f;

            q_left.push(a[i]);
            sum_l += a[i];
        }
        sum_l_v.push_back(sum_l);
    }

    for (int i = 2 * n - 1; i >= n; i--) {
        int f = q_right.top();
        if (a[i] < f) {
            q_right.pop();
            sum_r -= f;

            q_right.push(a[i]);
            sum_r += a[i];
        }
        sum_r_v.push_back(sum_r);
    }

    ll ans = -pow(10, 18);
    rep(i, n + 1) {
        ll temp = sum_l_v[i] - sum_r_v[n - i];
        // cout << sum_l_v[i] << " " << sum_r_v[n - i] << endl;
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


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

	const ll MOD = 1e9+7;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<vector<int>> v(n,vector<int>(26));
	for(int i = 0;i<n;i++)
	{
		v[i][s[i]-'a']++;
	}
	for(int i = n-1;i>0;i--)
	{
		for(int j=0;j<26;j++)
		{
			(v[i-1][j]+=v[i][j])%=MOD;
		}
	}
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		ll add = 1;
		for(int j = 0;j<26;j++)
		{
			if(s[i]==j+'a')continue;
			(add*=v[i][j]+1)%=MOD;
		}
		(ans+=add)%=MOD;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

void showVector(std::vector<int> readVec){
    int length = readVec.size();
    for(int i = 0; i < length; ++i){
        if(length - 1 != i){
            std::cout << readVec.at(i) << " ";
        }else{
            std::cout << readVec.at(i);
        }
    }
    
    std::cout << std::endl;
}

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

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    bool flg = true;
    int tmp;
    int count = 0;
    while(flg){
        flg = 0;
        for(int i = n - 1; 0 < i; --i){
            if(a.at(i) < a.at(i - 1)){
                a.at(i) += a.at(i - 1);
                a.at(i - 1) = a.at(i) - a.at(i - 1);
                a.at(i) = a.at(i) - a.at(i - 1);
                flg = true;
                ++count;
            }
        }
    }
    
    showVector(a);    
    std::cout << count << std::endl;

    return 0;
}



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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
vector<ll> A,B;

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

  cin>>N;
  A.resize(N);
  B.resize(N);
  rep(i,N)cin>>A[i];
  rep(i,N)cin>>B[i];

  priority_queue<P> que;
  rep(i,N)que.push(P(B[i],i));
  ll res=0;
  while(que.size()){
    //rep(j,N)cout<<B[j]<<" ";
    //cout<<endl;
    P p=que.top(); que.pop();
    ll i=p.se;
    ll a=B[(i-1+N)%N],b=p.fi,c=B[(i+1+N)%N];
    ll op=A[i];
    if(b<op){
      cout<<-1<<endl;
      return 0;
    }
    ll x=(b-op)/(a+c);
    B[i]-=x*(a+c);
    res+=x;
    if(x==0&&A[i]!=B[i]){
      cout<<-1<<endl;
      return 0;
    }
    if(B[i]>A[i]){
      que.push(P(B[i],i));
    }
  }

  rep(i,N)if(A[i]!=B[i]){
    cout<<-1<<endl;
    return 0;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define N 3011

using namespace std;

string s, t;
int n, m, opt[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> s >> t;
	n = (int)s.length();
	m = (int)t.length();
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=m; j++) {
			if(i == 0 || j == 0) opt[i][j] = 0;
			else if(s[i-1] == t[j-1]) opt[i][j] = opt[i-1][j-1] + 1;
			else opt[i][j] = max(opt[i-1][j], opt[i][j-1]);
		}
	}
	string ans = "";
	int len = opt[n][m];
	while(len > 0) {
        if(s[n-1] == t[m-1]) {
            ans += s[n-1];
            n--; m--; len--;
        }
        else if(opt[n][m] == opt[n-1][m]) n--;
        else m--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
vector<int> v[maxn];

int calc(vector<int> v) {
    int res = 0;
    forn (i, sz(v) - 1) {
        if (v[i] == v[i + 1]) {
            ++res;
            ++i;
        }
    }
    return res;
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    int n, m;
    cin >> n >> m;
    forn (i, n) {
        int x;
        cin >> x;
        v[x % m].push_back(x);
    }
    forn (i, m)
        sort(v[i].begin(), v[i].end());
    int res = 0;
    for (int i = 0; i * 2 <= m; ++i) {
        if (i * 2 == m || i == 0) {
            res += sz(v[i]) / 2;
            continue;
        }
        int a = calc(v[i]);
        int b = calc(v[m - i]);
        int sa = sz(v[i]);
        int sb = sz(v[m - i]);
        int cur = min(sa, sb);
        sa -= cur, sb -= cur;
        cur += min(sa / 2, a);
        cur += min(sb / 2, b);
        res += cur;
    }
    cout << res << '\n';
}


Measured memory_bytes: 5760
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  2 15:11:35 2020
//
package main

import (
	"fmt"
	"sort"
)

const MOD = 1e9 + 7

var N, K int
var H []int

func main() {
	fmt.Scan(&N, &K)
	H = make([]int, N)
	for i := range H {
		fmt.Scan(&H[i])
	}
	sort.Ints(H)

	ans := 0
	for i := 0; i < N-K; i++ {
		ans += H[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    let mut v = input_vector::<isize>();

    if n >= m {
        p(0);
        return;
    }

    let mut dist = vec![];

    v.sort();

    let mut sum = v.iter().last().unwrap() - v.iter().next().unwrap();
    for z in 0..m - 1 as usize {
        let buf = (v[z] - v[z + 1]).abs();
        dist.push(buf);
    }
    dist.sort();
    dist.reverse();
    for z in 0..n - 1 {
        sum -= dist[z];
    }
    p(sum);
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll n; cin>>n;
    string s;
    map<string, int> m;
    loop(i,n){
    	cin>>s;
    	m[s]++;
    }

    pts("AC x"); pt(m["AC"]);
    pts("WA x"); pt(m["WA"]);
    pts("TLE x"); pt(m["TLE"]);
    pts("RE x"); pt(m["RE"]);
}


/*


*/





Measured memory_bytes: 3652
using System;

class Program {
    static void Main( string[] args )
    {
        string[] s = Console.ReadLine().Split();

        int a = int.Parse( s[ 0 ] );
        int b = int.Parse( s[ 1 ] );

        int d = a / b;
        int r = a % b;
        double f = ( double )a / b;

        Console.WriteLine( "{0} {1} {2:f5}", d, r, f );
    }
}

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

int main() {
  // ここにプログラムを追記
  
  int N, K;
  int A = 1;
   cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (A * 2 < A + K) {
      A = A * 2;
    }else{
      A = A + K;
    }
  }
  cout << A << endl;
}     

Measured memory_bytes: 3588
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;


int main() {
    long long n;
    long long maxv=INF*-1, minv=INF, sum;
    cin >> n;
    vector<long long> A(n);
    for(int i=0; i<n; i++){
        cin >> A.at(i);
    }
    for(int i=0; i<A.size(); i++){
        sum += A.at(i);
        maxv = max(maxv, A.at(i));
        minv = min(minv, A.at(i));
    }
    cout << minv << " " << maxv << " " << sum << endl; 
}




Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ifstream cin (".in");
	//ofstream cout (".out")
	
	ll a;
	double b;
	cin >> a >> b;
	double c=b*100;
	cout << a*ll(c+0.5)/100 << '\n';
	
	return 0;
}


Measured memory_bytes: 3720
fun main(args: Array<String>) {
    val s = readLine()!!
    if (s.length % 2 == 1) {
        println("No")
        return
    }

    for (i in s.indices step 2) {
        if (!(s[i] == 'h' && s[i + 1] == 'i')) {
            println("No")
            return
        }
    }

    println("Yes")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 33604
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {

    int n;
    string s;
    cin >> n >> s;

    if(s.substr(0,n/2) == s.substr(n/2,n))
        cout << "Yes\n";
    else
        cout << "No\n";
    
  
    return 0;
}



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

using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    long long sum = 0;
    for(int i = 0; i < n - k; i++){
        sum += h[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int n, a[100000], b[100000], c[100000], dp[100000][4];

int f(int k, int p)
{
    if (k == n) return 0;
    if (dp[k][p] != -1) return dp[k][p];
    int bst = 0;
    if (p != 0) bst = max(bst, a[k] + f(k + 1, 0));
    if (p != 1) bst = max(bst, b[k] + f(k + 1, 1));
    if (p != 2) bst = max(bst, c[k] + f(k + 1, 2));
    return dp[k][p] = bst;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i] >> c[i];
    memset(dp, -1, sizeof dp);
    cout << f(0, 3);
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;string s;
    cin >> n >> s;
    int ans=0;
    REP(i,n-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;

    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var result = 0;
        var vals = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i < 2; i++)
        {
            if (vals[0] > vals[1])
            {
                result += vals[0];
                vals[0]--;
            }
            else if (vals[1] > vals[0])
            {
                result += vals[1];
                vals[1]--;
            }
            else
            {
                result += vals[0];
                vals[0]--;
            }
        }
        Console.WriteLine(result);
    }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int k, n; cin >> k >> n;
    V<int> a(n * 2);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        a[i + n] = a[i] + k;
    }

    int ans = IINF;
    for(int i = 0; i < n; i++){
        ans = min(ans, abs(a[i + n - 1] - a[i]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4824
//  Created by Sengxian on 2017/6/24.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MOD = 1e9 + 7;

int main() {
	int n = readInt(), m = readInt();
	if (n > m) swap(n, m);
	if (abs(n - m) > 1) return puts("0"), 0;
	ll res = 1;
	for (int i = 1; i <= n; ++i) (res *= i) %= MOD;
	for (int i = 1; i <= m; ++i) (res *= i) %= MOD;
	if (n == m) (res *= 2) %= MOD;
	printf("%lld\n", res); 
	return 0;
}


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

int main() {
  int H,A;
  cin >> H >> A;
  int count = 0;
  
  for(int i = 0;i<10000000;i++) {
    H-=A;
    count++;
    if(H<=0) {
      break;
    }
  }
  cout << count <<endl;
  return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll m, f, b;
  cin >> m >> f >> b;
  if(m < b) {
    if((m + f) >= b) {
      cout << b - m << endl;
    } else {
      cout << "NA" << endl;
    }
  } else {
    cout << 0 << endl;
  }
	return 0;
}


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

int a[6], sol, m, j;

int main()
{
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	m = 10;
	for (int i = 0; i < 5; ++i){
		if (a[i] % 10 < m && a[i] % 10 > 0){
			m = a[i] % 10;
			j = i;
		}
	}
	for (int i = 0; i < 5; ++i){
		if (i == j) continue;
		if (a[i] % 10 == 0) sol = sol + a[i];
		else sol = sol + a[i] + 10 - a[i] % 10;
	}
	cout << sol + a[j];
	return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))

check = 0
for i in range(n) :
  if a[i]%2 == 0 :
    if a[i]%3 == 0 or a[i]%5 == 0 :
      continue
    else :
      check = 1

if check == 0 :
  print('APPROVED')
else :
  print('DENIED')

Measured memory_bytes: 3060
#include <stdio.h>
#include <limits.h>
 
int main(){
    int n,a,min=INT_MAX,max=INT_MIN;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(max<a-min){
	  max=a-min;
	}
	if(min>a){
	  min=a;
	}
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2100
N = int(input()) 
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
  print(0)
  exit()
 
upp = 10**18
flag = 1
ans = 1
#print(A)
for a in A:
  ans *= a
  if ans > upp:
    ans = -1
    break
 
print(ans)

Measured memory_bytes: 95896
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
def dfs(cur,a,b,c):
    if cur ==N:
        return abs(a-A) + abs(b-B) + abs(c-C) -30 if min(a,b,c) > 0 else float('inf')
    r1 = dfs(cur+1,a,b,c)
    r2 = dfs(cur+1,a+l[cur],b,c) +10
    r3 = dfs(cur+1,a,b+l[cur],c) + 10
    r4 = dfs(cur+1,a,b,c+l[cur]) + 10
    return min(r1,r2,r3,r4)
print(dfs(0,0,0,0))
#全てのバリエーション試す、dfs

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	
	int n;
	cin>>n;
	long double x=1;
	long double p=1e18;
	int f=0;
	long long a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	long double y;
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		y=a[i];
		x*=y;
		if(x>p)
		{
			f=1;
			break;
		}
	}
	if(f==1)cout<<-1;
	else cout<<(long long)x;
	return 0;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//sb();
    ll k;
    string s;
    cin>>k;
    cin>>s;
    //cout<<s.size();
    if(k>=s.size())
    cout<<s;
    else{
     for(int i=0;i<k;i++){
         cout<<s[i];
     }
     cout<<"...";
    }




return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
int H,W;
char field[55][55];
bool kind[256], used[256];


// ·û`©Ç¤©B©ªæèºÌ¨Ìª êÎfalse
bool is_check(int x1, int y1, int x2, int y2, char mark){
    int i,j;
    for(i=y1; i<=y2; i++){
        for(j=x1; j<=x2; j++){
            if( field[i][j] == '.' ||
                (field[i][j] != mark && used[field[i][j]]) ) return false;
        }
    }
    return true;
}


bool solve(char mark){
    int i,j,x1,x2,y1,y2;

    x1 = y1 = 55;
    x2 = y2 = 0;
    rep(i,H){
        rep(j,W){
            if( field[i][j] == mark ){
                x1 = min(x1, j), y1 = min(y1, i);
                x2 = max(x2, j), y2 = max(y2, i);
            }
        }
    }

    //printf("mark=%c, rec=(%d,%d),(%d,%d)\n",mark,x1,y1,x2,y2);
    if( !is_check(x1,y1,x2,y2,mark) ) return false;
    //printf("   is_check = ok\n");

    bool tmp[256];
    rep(i,256) tmp[i] = used[i];

    // Ü¾²×ÄÈ¢©ªæè¢¨Ì©çÄA
    for(i=y1; i<=y2; i++){
        for(j=x1; j<=x2; j++){
            if( !tmp[field[i][j]] ){
                //printf("     %c -> %c\n",mark,field[i][j]);
                tmp[field[i][j]] = true;
                used[field[i][j]] = true;
                bool res = solve(field[i][j]);
                used[field[i][j]] = false;
                if( !res ) return false;
            }
        }
    }
    return true;
}

int main(){
    int T,i,j;
    cin >> T;

    while( T-- ){
        cin >> H >> W;
        memset(kind, false, sizeof(kind));

        rep(i,H) cin >> field[i];

        bool ok = true;
        rep(i,H){
            rep(j,W){
                if( field[i][j] != '.' && !kind[field[i][j]] ){
                    used[field[i][j]] = true;
                    ok &= solve(field[i][j]);
                    used[field[i][j]] = false;
                    kind[field[i][j]] = true;
                    //printf("___kinded %c, ok = %d\n",field[i][j],ok);
                }
            }
        }

        puts(ok ? "SAFE" : "SUSPICIOUS");
    }

    return 0;
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
using namespace std;
vector<int> to[100005];
const int INF=100010101;
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> pre(n,-1);
  vector<int> dist(n,INF);
  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF)continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++){
    if(i==0)continue;
    int ans=pre[i];
    ans++;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 10656
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>

int main()
{
long long int n, a, b;
std::cin >> n >> a >> b;
if(a > b){
    std::cout << 0 << std::endl;
} else if(n == 1){
    if(a != b){
        std::cout << 0 << std::endl;
    } else {
        std::cout << 1 << std::endl;
    }
} else if(n == 0){
    std::cout << 0 << std::endl;
} else {
   std::cout << (b - a) * (n - 2) + 1 << std::endl; 
}
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long count =0;
		String s = sc.next();

		int i=0;
		int black=0;
		for (;i<s.length();i++) {
			if (s.charAt(i)=='W') {
				count +=black;
			} else {
				black++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 40268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % n == 0) {
      cout << "OK" << '\n';
      return 0;
    }
  }
  cout << "NG" << '\n';
}

Measured memory_bytes: 3640
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

void solve() {
  int X, Y;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++) {
    if (i * 2 + (X-i)*4 == Y) {
      cout << "Yes" << endl;
      return;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>

#define N 200005

using namespace std;

int n;
int h[N], adj[N], nxt[N], o;

inline void add (int u, int v) {
	nxt[++o] = h[u];
	h[u] = o;
	adj[o] = v;
	return ;
}

int dfs (int u, int la) {
    int sum = 0;
    for (int i = h[u]; i; i = nxt[i]) {
    	int v = adj[i];
    	if (la != v)
    		sum ^= dfs (v, u) + 1; 
    }
    return sum;
}

int main () {
    scanf ("%d", &n);
    for (int i = 1, u, v; i < n; ++i) {
        scanf ("%d%d", &u, &v);
        add (u, v);
        add (v, u); 
    }
    if (dfs (1, 0))
    	puts ("Alice");
    else 
    	puts ("Bob");
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int gcd(int a,int b){
	if (a<b)	swap(a,b);
	int module=-1;
	while(module){
		module=a%b;
		a=b;
		b=module;
	}
	return a;
}
int main(){
	int n,x,tmp;
	cin>>n>>x;
	int a[n+1];
	for(int i=0;i<n;i++){
		cin>>tmp;
		a[i]=abs(x-tmp);
	}
	if (n==1)	cout<<a[0];
	else{
		int sol=gcd(a[1],a[0]);
		for (int i=2;i<n;i++){
			sol=gcd(sol,a[i]);
		}
		cout<<sol;
	}
	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
import sys
S=input()
N=len(S)
if N==3:
    if S[0]==S[1]:
        if S[1]==S[2]:
            print(1)
        else:
            print(6)
    else:
        if S[0]==S[2]:
            print(7)
        elif S[1]==S[2]:
            print(6)
        else:
            print(3)
    sys.exit()
a=S[0]
t=1
for i in range(N):
    if S[i]!=a:
        t=0
        break
if t==1:
    print(1)
    sys.exit()

mod=998244353
M=0
for s in S:
    if s=='b':
        M+=1
    elif s=='c':
        M+=2
    M%=3
dp=[]
for i in range(2):
    for k in range(3):
        for l in range(3):
            dp.append((i,k,l))
dd=[[[0]*3 for i in range(3)] for i in range(2)]
for i in range(3):
    dd[0][i][i]=1
for k in range(2,N+1):
    nd=[[[0]*3 for i in range(3)] for i in range(2)]
    for p in dp:
        con,moji,m=p
        n=dd[con][moji][m]
        #print(con,moji,m)
        if con==0:
            for k in range(3):
                if moji==k:
                    nd[1][k][ (m + k) % 3] += n
                    nd[1] [k ][(m + k) % 3] %=mod
                else:
                    nd[0][k][(m+k)%3]+=n
                    nd[0][ k] [(m+k) % 3] %=mod
        else:
            for k in range(3):
                nd[1][k][(m + k) % 3] += n
                nd[1][k][(m + k) % 3] %=mod
    #print(nd)
    dd=nd
flag=1
for i in range(N-1):
    if S[i]==S[i+1]:
        flag=0
ans=flag
for k in range(3):
    ans+=dd[1][k][M]
    ans%=mod
print(ans)






Measured memory_bytes: 45388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class205
    {
        static bool[] used;
        static bool[] used2;
        static int[] count;
        static List<int>[] G;
        static void Main()
        {
            var NXY = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NXY[0], X = NXY[1], Y = NXY[2];
            G = new List<int>[N];
            for (int i = 0; i < N; i++) G[i] = new List<int>();
            G[X - 1].Add(Y - 1);
            G[Y - 1].Add(X - 1);
            for(int i = 0; i < N-1; i++)
            {
                G[i].Add(i + 1);
                G[i + 1].Add(i);
            }

            count = new int[N];
            used2 = new bool[N];
            for(int i = 0; i < N; i++)
            {
                used = new bool[N];
                used2[i] = true;

                BFS(i);
            }
            for(int i = 0; i < N-1; i++)
            {
                
                Console.WriteLine(count[i]);
            }
        }
        static void BFS(int n)
        {
            used[n] = true;
            var que = new Queue<Tuple<int, int>>();
            que.Enqueue(Tuple.Create(n, 0));
            while (que.Count > 0)
            {
                var p = que.Dequeue();
                for(int i = 0; i < G[p.Item1 ].Count; i++)
                {
                    var e = G[p.Item1][i];
                    if (!used[e])
                    {
                        used[e] = true;
                        if (!used2[e]) count[p.Item2]++;
                        que.Enqueue(Tuple.Create(e, p.Item2 + 1));
                    }
                }
            }
        }
        static void DFS(int n,int c)
        {
            used[n] = true;
            if(!used2[n])
                count[c] += 1;
            for(int i = 0; i < G[n].Count; i++)
            {
                var e = G[n][i];
                if (used[e]) continue;
                DFS(e, c + 1);
            }
        }
    }
}


Measured memory_bytes: 19956
#include <stdio.h>
 
#define N 2000001
 
int B[N], C[N];
 
void Sort(int A[], int B[], int k, int n){
  int i, j;
   
  for(i = 0; i <= k; i++){
    C[i] = 0;
  }
  for(j = 1; j <= n; j++){
    C[A[j]]++;
  }   
  for(i = 1; i <= k; i++){
    C[i] = C[i] + C[i - 1];
  } 
  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
   
  for(i = 1; i <= n; i++){
    printf("%d", B[i]);
    if(i != n) printf(" ");
  }
  printf("\n");

}
 
int main(){
  int A[N];
  int i, j, n, k = 0;
   
  //input
  scanf("%d", &n); 
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(k < A[i]) k = A[i];
  }
   
  //sort and out
  Sort(A, B, k, n);
   
  return 0;
}

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

int main(){
  int N,p=0,q=0;
  cin>>N;
  vector<int> P(N),Q(N),A(N);
  for(int &i:P)
    cin>>i;
  for(int &i:Q)
    cin>>i;
  for(int i=0;i<N;i++)
    A.at(i)=i+1;
  int i=0;
  do{
    if(P==A)
      p=i;
    if(Q==A)
      q=i;
    i++;
  }while(next_permutation(A.begin(),A.end()));
  cout<<max(p,q)-min(p,q)<<endl;
}

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

int main() {
  int x, a, b;
  cin >> x >>  a >> b;
 
  int xa ,xb;
  
  if ( x > a ){
    xa = (x - a);
  }
  else {
    xa = (a - x);
  }
  
  if ( x > b ){
    xb = (x - b);
  }
  else {
    xb = (b - x);
  }
  
  
  if ( xa > xb ){
    cout << "B" <<endl;
  }
  else {
    cout << "A" <<endl;
  }
}


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

 int main() {
  int A, B, T;
  cin >> A >> B >> T;
  int res = 0;
  for (int i = 1; A* i <= T + 0.5 ; i++) {
    res++;
  }
   cout << res* B << '\n';
 }


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextInt()
    val x = sc.nextInt()
    println(problem150a(k, x))
}

fun problem150a(k: Int, x: Int): String {
    return if (k * 500 >= x) "Yes" else "No"
}

Measured memory_bytes: 29472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;

ll N;
vector<vector<ll>> V(17, vector<ll>(17));
vector<ll> DP;

int main() {
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> V[i][j];
        }
    }
    DP.resize(1<<N);
    for(int i = 0; i < (1<< N); i++){
        bitset<17> B = i;
        ll score = 0;
        for(int i = 0; i < N; i++){
            for(int j = i; j < N; j++){
                if(B[i] == 1 && B[j] == 1) score += V[i][j];
            }
        }
        DP[i] = score;
    }
    for(int i = 2; i <= N; i++){
        for(int i1 = 0; i1 < (1<<N); i1++){
            bitset<17> B = i1;
            ll cnt = B.count();
            if(cnt == i){
                for(int t = (i1-1)&i1; t > 0; t = (t-1)&i1){
                    DP[i1] = max(DP[i1], DP[t]+DP[i1-t]);
                }
            }

        }
    }


    cout << DP[(1<<N)-1] << endl;

}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {
	
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static int lcm (int a, int b) {return a*b/gcd(a,b);}
	public static int lower_bound(int vector[],int key){
		return 0;
	}
	public static int max(int a,int b) {
		if(a>b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if(a<b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
	public static long factorial (int i) {//階乗
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
	
	public static void main(String[] args){
	Scanner scan=new Scanner(System.in);
	String str=scan.next();
	char ch1=str.charAt(0),ch2=str.charAt(1),
		ch3=str.charAt(2),ch4=str.charAt(3);
	if(ch1==ch2||ch2==ch3||ch3==ch4) {
		System.out.println("Bad");
	}
	else {
		System.out.println("Good");
	}
	}
}

Measured memory_bytes: 21716