akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000

struct T{
  char mark;
  int num;
};


  
int p(struct T A[],int a,int b);
void q(struct T A[],int a,int b);
void merge(struct T  A[],int l,int m,int r);
void mergesort(struct T A[],int l,int r);

int n;
struct T L[MAX/2+2],R[MAX/2+2];

int main(){
  int i,m,st=1;
  struct T X[MAX],Y[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    getchar();
    scanf("%c %d",&X[i].mark,&X[i].num);
    Y[i]=X[i];
  }
  
  mergesort(X,0,n);
  
  q(Y,0,n-1);

  for(i=0;i<n;i++){
    if(X[i].mark!=Y[i].mark) st=0;
  }
  if(st==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++)printf("%c %d\n",Y[i].mark,Y[i].num);
  
  return 0;
}

int p(struct T A[],int a,int b){
  int i,j;
  struct T x,t;
  x=A[b];
  i=a-1;
  for(j=a;j<b;j++){
    if(A[j].num<=x.num){
      i=i+1;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[b];
  A[b]=t;
   return i+1;
}

void q(struct T A[],int a,int b){
  int m;
  if(a<b){
    m=p(A,a,b);
    q(A,a,m-1);
    q(A,m+1,b);
  }
}

void merge(struct T A[],int l,int m,int r){
  int n1,n2,i,j,k;
  n1=m-l;
  n2=r-m;
  for(i=0;i<n1;i++) L[i]=A[l+i];
  for(i=0;i<n2;i++) R[i]=A[m+i];
  L[n1].num=R[n2].num=2000000000;
  i=0,j=0;
  for(k=l;k<r;k++){
    if(L[i].num<=R[j].num){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }
}
void mergesort(struct T A[],int l,int r){
  if(l+1<r){
    int m;
    m=(l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}

  



Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a,b,k,x,y;
  
  cin >>a>>b>>k;
  
  if(a-k>=0){
    x = a-k;
    y = b;
  }
  else if(a-k<0 && a+b-k>0){
    x = 0;
    y = a+b-k;
  }
  else{
    x=0,y=0;
  }
  

  cout << x << " " << y <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,X,i,j,k,r;
    for(;scanf("%d%d",&N,&X),X+N;printf("%d\n",r))
    {
        for(i=1,r=0;i<=N;i++)
            for(j=i+1;j<=N;j++)
            {
                k=X-i-j;
                if(j<k&&k<=N)
                    r++;
            }
    }
    return 0;
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()


int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> T(N), A(N);
	REP(i, N) cin >> T[i];
	REP(i, N) cin >> A[i];

	vector<pair<ll, ll>> tt(N), aa(N);

	tt[0].first = tt[0].second = T[0];
	REP(i, N-1)
	{
		ll l, r;
		if (tt[i].second < T[i+1])
		{
			r = l = T[i+1];
		}
		else
		{
			r = tt[i].second;
			l = 1;
		}
		tt[i+1].first = l;
		tt[i+1].second = r;
	}

	reverse(ALL(A));
	aa[0].first = aa[0].second = A[0];
	REP(i, N-1)
	{
		ll l, r;
		if (aa[i].second < A[i+1])
		{
			r = l = A[i+1];
		}
		else
		{
			r = aa[i].second;
			l = 1;
		}
		aa[i+1].first = l;
		aa[i+1].second = r;
	}
	reverse(ALL(aa));

	ll res{1};
	REP(i, N)
	{
		auto &a = aa[i];
		auto &t = tt[i];

		ll tmp = min(a.second, t.second) - max(a.first, t.first);
		// std::coutr << "tmp : " << tmp << std::endl;
		(res *= max(0ll, tmp+1)) %= MOD;
	}
	
	std::cout << res << std::endl;
}

Measured memory_bytes: 4992
a = int(input())
s = set([a])

for i in range(10**6):
	if a % 2 == 0:
		# print("Process for even.")
		a = a//2
	else:
		# print("Process for odd.")
		a = 3*a + 1
	if a not in s:
		s.add(a)
	else:
		print(i+2)
		break


Measured memory_bytes: 9168
#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 1e9
#define INF 1000000000000000000

int main() {
    double a, b, x, ans;
    cin >> a >> b >> x;
    if (2 * x >= a * a * b) {
        double f = a, l = 2 * b - (2 * x) / (a * a);
        ans = atan2(l, f);
    } else {
        double f = b, l = (2 * x) / (a * b);
        ans = atan2(f, l);
    }

    ans = ans * 180 / M_PI;

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  int n,m;
  cin >> n >> m;
  map<ll,ll,greater<ll>>mp;
  rep(i,n){
    ll a;
    cin >> a;
    mp[a]++;
  }
  rep(i,m){
    ll b,c;
    cin >> b >> c;
    mp[c]+=b;
  }
  ll sum=0;
  ll num=0;
  for(auto p:mp){
    sum+=min(n-num,p.second)*p.first;
    num+=min(n-num,p.second);
    if(num==n)break;
  }
  cout << sum << endl;
}


Measured memory_bytes: 12800
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a<b){
        printf("a < b\n");
    }else if(a == b){
        printf("a == b\n");
    }else {
        printf("a > b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        int ans = 0;
        for(int i=0;i<4;i++){
            char cur = S.charAt(i);
            if(cur=='+') ans += 1;
            else ans-= 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
n = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
temp = []
for v,c in zip(V,C):
    temp.append(v-c)
temp.sort(reverse = True)
ans = 0

for t in temp:
    if t < 0:
        break
    ans += t
print(ans)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const lli inf = 1LL << 60;

template<typename T>
struct RMQ {
  int n;
  vector<T> dat;

  RMQ(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, inf);
  }

  void update(int k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  T query(size_t a, size_t b) {
    return query(a, b, 0, 0, n);
  }

  T query(size_t a, size_t b, size_t k, size_t l, size_t r) {
    if (r <= a || b <= l) return inf;
    if (a <= l && r <= b) return dat.at(k);

    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

    return min(vl, vr);
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> a(n);
    cin >> a;
    
    map<lli, int> idx;
    for (int i = 0; i < a.size(); ++i) {
      idx[a[i]] = i;
    }

    RMQ<lli> rmq(n);
    for (int i = 0; i < a.size(); ++i) {
      rmq.update(i, a[i]);
    }
    
    lli sum = 0;

    function<void(int, int)> rec = [&] (int begin, int end) {
      unless (begin < end) {
        return ;
      }
      lli x = rmq.query(begin, end);
      int i = idx[x];
      sum += x * (i - begin + 1) * (end - i);
      rec(begin, i);
      rec(i + 1, end);
      return ;
    };
    rec(0, n);

    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 46592
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef long long LL;
const LL D=1e9+7;
struct BIT
{
	// [0,size)
	vector<LL> tree;
	LL size;
	BIT(LL s){
		size=s;
		tree.resize(size+1);
	}
	void init(LL s){
		size=s;
		tree.clear();
		tree.resize(size+1);
	}
	void add(LL i,LL v){
		i++;
		while(i<=size){
			tree[i]+=v;
			tree[i]%=D;
			//cerr << i << ": " << tree[i] << ", " << v << endl;
			i+=(i&-i);
		}
	}

	// [0,i)
	LL collect(LL i){
		LL r=0;
		while(i>0){
			r+=tree[i];
			r%=D;
			i-=(i&-i);
		}
		return r;
	}

	// [a,b)
	LL collect(LL a, LL b){
		return collect(b)-collect(a);
	}
	void debug()
	{
		for(int i=0;i<tree.size();i++){
			cerr << tree[i] << " ";
		}
		cerr << endl;
	}
};
const int L=1e5+10;
LL x[L];
LL y[L];
int main() {
	int N,M;
	cin >> N >> M;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	for(int i=0;i<M;i++){
		cin >> y[i];
	}

	vector<LL> ls;
	vector<P> rs;
	int j=0;
	for(int i=0;i<N;i++){
		while(j+1<M&&y[j+1]<x[i]){
			j++;
		}
		//cerr << i << ", " << j << endl;
		if(j+1==M){
			break;
		}
		if(y[j]<x[i]){
			LL l=x[i]-y[j];
			LL r=y[j+1]-x[i];
			//cerr << l << ", " << r << endl;
			ls.push_back(l);
			rs.push_back(P(r,-l));
		}
	}
	sort(rs.begin(),rs.end());
	rs.resize(unique(rs.begin(),rs.end())-rs.begin());
	sort(ls.begin(),ls.end());
	ls.resize(unique(ls.begin(),ls.end())-ls.begin());
	BIT b(ls.size());
	for(auto p:rs){
		int k=lower_bound(ls.begin(),ls.end(),-p.second)-ls.begin();
		//cerr << p.first << ", " << p.second << ", " << k << ", " << b.collect(k) << endl;
		b.add(k,(b.collect(k)+1)%D);
		//cerr << b.collect(k+1) << endl;
		//b.debug();
	}

	cout << (b.collect(ls.size())+1)%D << endl;


	return 0;
}



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

int main(void){

    string s;
    int cnt=0;

    cin >> s;

    for(int i=0; i<s.size(); i++){
        if(s[i]==s[s.size()-i-1]){
            continue;
        } else{
            cnt++;
        }
    }

    cnt=cnt/2;

    cout << cnt << endl;
    
    return 0;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	comInit()

	r := n - k
	for i := 1; i <= k; i++ {
		a := com(r+1, i)
		b := com(k-1, i-1)
		fmt.Println(a * b % mod)
	}
}

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-二項係数-ncr

const max int = 1e6
const mod int = 1e9 + 7

var fac [max]int
var finv [max]int
var inv [max]int

// テーブルを作る前処理
func comInit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for 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
	}
}

// 二項係数計算
func com(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, x, t; std::cin >> n >> x >> t;
    std::cout << (n + x - 1) / x * t << "\n";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  int N,K;
  cin >> N >> K;
  vector<int> A;
  int ans=0;
  if(N==K) ans=1;
  else{
    for(;;){
      N-=K-1;
      if(N<=K){
        ans+=2;
        break;
      }
      ans++;
    }
  }
  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

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

    string ans = "";
    for (int i = 0; i < 3; i++) {
        ans += s[i];
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3632
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n;
    cin >> n;
    vector<int> v1;
    vector<int> v2;
    REP(i, n) { int tmp; cin >> tmp; v1.push_back(tmp); }
    REP(i, n) { int tmp; cin >> tmp; v2.push_back(tmp); }
    int res = -1;
    REP(i, n) {
        int tmp = 0;
        tmp += accumulate(v1.begin(), v1.begin()+i+1, 0);
        tmp += accumulate(v2.begin()+i, v2.end(), 0);
        res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	char s;
	cin >> s;
	if (s>='a' && s<='z') {
		cout << 'a' << endl;
	} else {
		cout << 'A' << endl;
	}
	return 0;
}

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

using namespace std;
#define ll long long int
//ll s,n,a[100005];

int main()
{
    double n,i,j,count=0;
  cin>>n;
  double x;
  x=ceil(1.0*n/2);
  cout<<std::fixed<<setprecision(10)<<x/n;
 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,a,sum=0;
	cin>>n>>m;
	while(m--){
		cin>>a;
		sum+=a;
	}
	if(sum>n){
		cout<<"-1";
	}
	else{
		cout<<n-sum;
	}
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5;
int a[N];
int info[N];
bool check_feasibility(int n)
{
	for(int i = 2; i < n; i++)
		a[i] = a[i-2]^a[i-1]^info[i-1];
	if((a[n-2]^a[n-1]^a[0])!=info[n-1] || (a[n-1]^a[0]^a[1])!=info[0])
		return false;
	else
		return true;
}
bool solve(int n)
{
	for(int i = 0; i <= 1; i++)
		for(int j = 0; j <= 1; j++)
		{
			a[0] = i;
			a[1] = j;
			if(check_feasibility(n))
				return true;
		}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n; cin >> n;
	for(int i = 0; i < n; i++)
	{
		char c; cin >> c;
		info[i] = c=='x';
	}
	if(solve(n))
	{
		for(int i = 0; i < n; i++)
			cout<<(a[i] ? "W" : "S");
		cout<<endl;
	}
	else
		cout<<-1<<endl;
	
	cout<<flush;
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, Y;
	cin >> N >> Y;
	int countA = -1; int countB = -1; int countC = -1;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; i+j <= N; ++j) {
			int k = N - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == Y) {
				countA = i, countB = j, countC = k;
			}
		}
	}
	cout << countA <<" "<< countB <<" "<< countC << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

int main()
{
	int n, d;
	cin >> n >> d;
	d = 2*d+1;
	int ans = n/d + (n%d>0);
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
typedef long long ll;
using namespace std;
const int k_mod = ( int )1e9 + 7;

int main( void ){
	int n;
	cin >> n;
	int* steps = new int[ n ]();
	rep( i, 0, n ){
		cin >> steps[ i ];
	}
	vector <int> dp_cost( n, k_mod );
	dp_cost[ 0 ] = 0;
	dp_cost[ 1 ] = abs( steps[ 1 ] - steps[ 0 ] );
	rep( i, 2, n ){
		dp_cost[ i ] = min( dp_cost[ i - 2 ] + abs( steps[ i ] - steps[ i - 2 ] ), dp_cost[ i - 1 ] + abs( steps[ i ] - steps[ i - 1 ] ));
	}
	printf( "%d\n", dp_cost[ n - 1 ] );
	return 0;
}


Measured memory_bytes: 1024
a=list(input())
b=list(input())
c=list(input())
a.reverse()
b.reverse()
c.reverse()
p="a"
while True:
    if p=="a":
        if len(a)==False:
            print("A")
            break
        p=a.pop()
    elif p=="b":
        if len(b)==False:
            print("B")
            break
        p=b.pop()
    elif p=="c":
        if len(c)==False:
            print("C")
            break
        p=c.pop()

Measured memory_bytes: 61912
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    if((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 10000
#define MOD 1000000007
inline int mp(int seg, int num) { return seg*32767 + num; };
struct SegTree {
  int MAX_N;
  vector<int> seg;
  SegTree(int n) {
    MAX_N = 1;
    while (n >= MAX_N) MAX_N <<= 1;
    seg.resize(2*MAX_N-1, mp(-INF, -1));
  }

  int query(int a, int b, int k=0, int l=0, int r=-1) {
    if (r == -1) r = MAX_N;
    if (r <= a || b <= l) return mp(-INF, -1);
    if (a <= l && r <= b) return seg[k];
    return max(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
  }

  void update(int k, P v) {
    k += MAX_N-1;
    seg[k] = mp(v._1, v._2);
    while (k) {
      k = (k-1)/2;
      seg[k] = max(seg[k*2+1], seg[k*2+2]);
    }
  }
};


int N;
long long X[4001];
short pre[4001][4001];
vector<long long> ks[4001];

inline long long key(int i, int j) { return X[j] - X[i]; }
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> X[i+1];
  for (int i=0; i<N; i++) X[i+1] += X[i];

  vector<SegTree> seg;
  rep(i, N+1) {
    rep(j, i) ks[i].pb(key(j, i));
    sort(all(ks[i])); uniq(ks[i]);
    seg.pb(SegTree(ks[i].size()));
  }

  for (int r=1; r<=N; r++) {
    pre[0][r] = -1;
    seg[r].update(index(ks[r], key(0, r)), P(1, 0));
  }
  for (int l=1; l<=N; l++) {
    for (int r=l+1; r<=N; r++) {
      int p = seg[l].query(0, index(ks[l], key(l, r)));
      int p2 = p%32767, p1 = p/32767;
      if (p2 == -1) continue;
      pre[l][r] = p2;
      seg[r].update(index(ks[r], key(l, r)), P(p1+1, l));
    }
  }
  int m = seg[N].query(0, seg[N].MAX_N);
  int m2 = m%32767, m1 = m/32767;
  vector<int> ans;
  int left = m2, right = N;
  while (left != 0) {
    ans.pb(left);
    int k = left;
    left = pre[left][right];
    right = k;
  }
  reverse(all(ans));
  assert(ans.size() == m1-1);
  cout << m1 << "\n";
  for (int x : ans) cout <<x << " "; cout << "\n";
  return 0;
}

Measured memory_bytes: 188680
#include<bits/stdc++.h>
#define mod (1000000007)
typedef long long ll;
using namespace std;
int a[110000];
int main()
{
	int n,x,ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&x),a[x]++;
	ans=a[0]+a[1];
	for(int i=1;i<100000;i++) ans=max(ans,a[i-1]+a[i]+a[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int main() {
	int n;
	cin >> n;
	map<string, int>blue;
	map<string, int>red;
	REP(i, n) {
		string a;
		cin >> a;
		blue[a]++;
	}
	int m;
	cin >> m;
	REP(i, m) {
		string b;
		cin >> b;
		red[b]++;
	}
	int ans = 0;
	for (auto a : blue) {
		ans =max(ans,a.second - red[a.first]);
	}
	cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD =998244353;
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll>l(k),r(k);
    for(ll i=0;i<k;i++) cin >> l[i] >> r[i];
    vector<ll>dp(2e5+20,0);
    vector<ll>sum(2e5+20,0);
    sum[1]=1;
    dp[1]=1;
    for(ll i=2;i<=n;i++){
        for(ll j=0;j<k;j++){
            ll li=i-r[j];
            ll ri=i-l[j];
            if(ri<0) continue;
            li=max(li,(ll)1);
            dp[i]+=(sum[ri]-sum[li-1]+MOD);
            dp[i]%=MOD;
        }
        sum[i]=sum[i-1]+dp[i];
        sum[i]%=MOD;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 6436
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    string s1,s2;
    while(cin>>s1)
    {
        s2="";
        for(int i=0;i<s1.size();i++)
        {
            if(s1[i]=='0')
            {
                s2+=s1[i];
            }
            if(s1[i]=='1')
            {
                s2+=s1[i];
            }
            if(s1[i]=='B')
            {
                s2=s2.substr(0,s2.size()-1);
            }
        }
        cout<<s2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#2018-03-11
#mokutou
import math
def digitsum(k):
    return len(str(k))


N = int(input())
m = int(math.sqrt(N))
result=10**10
for i in range(1,m+1):
    if N%i==0:
        A=i
        B=N//i
        F=max([digitsum(A),digitsum(B)])
        if F<result:
            result=F
print(result)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;
	int ans = 0;
	if (X == 1)ans += 300000;
	else if (X == 2)ans += 200000;
	else if (X == 3)ans += 100000;
	if (Y == 1)ans += 300000;
	else if (Y == 2)ans += 200000;
	else if (Y == 3)ans += 100000;
	if (X == 1 && Y == 1)ans += 400000;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
vector<ll> a;
ll dp[3010][3010][2];
ll dfs(int l,int r,int t){
    if(dp[l][r][t]!=-1)return dp[l][r][t];
    if(l==r){
        if(t==0){
            return a[l];
        }else{
            return -a[l];
        }
    }
    ll res;
    if(t==0){
        res=max(dfs(l+1,r,t^1)+a[l],dfs(l,r-1,t^1)+a[r]);
    }else{
        res=min(dfs(l+1,r,t^1)-a[l],dfs(l,r-1,t^1)-a[r]);
    }
    return dp[l][r][t]=res;
}
int main(){
    int n;cin>>n;
    memset(dp,-1,sizeof(dp));
    a.resize(n+10);
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<dfs(0,n-1,0)<<endl;
}   


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

int main(){
    int N;
    cin>>N;
    for(int i=1; i<=10; i++){
        if(i*1000>=N){
            cout<<i*1000-N<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include<bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class a {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, x;
        while(true){
            in >> n >> x;
            if(!n && !x) break;

            int cnt = 0;
            for(int i=1; i<=n-2; i++){
                for(int j=i+1; j<=n-1; j++){
                    for(int k=j+1; k<=n; k++){
                        if(x == (i+j+k)) cnt++;
                    }
                }
            }

            out << cnt << endl;
        }
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 3160
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		long a = Long.parseLong(st.nextToken());
 		long v = Long.parseLong(st.nextToken());
 		StringTokenizer st1 = new StringTokenizer(bf.readLine());
 		long b = Long.parseLong(st1.nextToken());
 		long w = Long.parseLong(st1.nextToken());
 		long t = Long.parseLong(bf.readLine());
 		if (v <= w){
 			out.println("NO");
 			
 		}
 		else{
 			if ((Math.abs(b-a)+0.0)/(v-w+0.0) <=t)
 				out.println("YES");
 			else
 				out.println("NO");
 		}
 				
		
 		out.close();
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25380
import itertools

N, K = map(int, input().split())

d = []
A = []

for i in range(K):
  d.append(int(input()))
  A.append(list(map(int,input().split())))
  
A = list(itertools.chain.from_iterable(A))
A = list(set(A))
kotae = N - len(A)
print(kotae)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  if (n % 2 == 1) {
    cout << 0 << endl;
  } else {
    long long ret = 0;
    long long den = 10;
    while (den <= n) {
      ret += n / den;
      den *= 5;
    }
    cout << ret << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
import math
N=int(input())
m=10**6+1
M=[0]*m
g=0
for i in map(int,input().split()):M[i]+=1;g=math.gcd(g,i)
if g>1:print('not coprime')
elif all(sum(M[i::i])<=1 for i in range(2,m)):print('pairwise coprime')
else:print('setwise coprime')


Measured memory_bytes: 107616
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int x,y,w,h,r;
    int x1,x2,y1,y2;
    cin>>w>>h>>x>>y>>r;
    x1 = x+r;
    x2 = x-r;
    y1 = y+r;
    y2 = y-r;
    if(x1<=w && x2>=0 && y1<=h &&y2>=0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	int a, b,c,d;
	cin >> a >> b>>c>>d;

	if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else
		cout << "Right" << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

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

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

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

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

    ll size(int x){
        return Size[root(x)];
    }
};

ll x[201000], y[201000];
ll imos[201000];
UnionFind uni;
ll N;
void f() {
    for(int i = 0; i <= N; i++) imos[i] = 0;
    vector<l_l> v;
    vector<int> vidx;
    for(int i = 0; i < N; i++) vidx.push_back(i);
    sort(vidx.begin(), vidx.end(), [&](int a, int b) {
        return x[a] < x[b];
    });
    for(auto idx : vidx) {
        if(v.empty()) {
            v.push_back({y[idx], idx});
            continue;
        }
        if(v.back().first < y[idx]) {
            v.push_back({y[idx], idx});
            continue;
        }
        l_l tmpcmp = {y[idx], -1};
        auto itr = lower_bound(v.begin(), v.end(), tmpcmp);
        int tmpidx = itr - v.begin();
        imos[tmpidx]++;
        imos[v.size() - 1]--;
        //cerr << "imos: " << idx << " " << tmpidx << " " << v.size() - 1 << endl;
        uni.merge(idx, v.back().second);
    }
    for(int i = 1; i <= v.size(); i++) {
        imos[i] += imos[i-1];
    }
    for(int i = 0; i < v.size(); i++) {
        //cerr << v[i].second << " ";
    }
    //cerr << endl;
    for(int i = 0; i + 1 < v.size(); i++) {
        if(imos[i] > 0) {
            uni.merge(v[i].second, v[i+1].second);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    uni.init(N);
    vector<l_l> v;
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
        y[i] = N - 1 - y[i];
    }
    f();
    for(int i = 0; i < N; i++) {
        cout << uni.size(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 12596
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<ctime>
#include<map>
#include<vector>
#include <tr1/unordered_map>
using namespace std;
#define N 200005
#define REP(i,a,b)	for(int i=a;i<=b;i++)
#define DOW(i,a,b)	for(int i=a;i>=b;i--)
#define MOD 1000000007
#define Mod(x)	((x)>=MOD?(x)-MOD:(x))
#define INF 0x3f3f3f3f
#define size_int (sizeof(int)) 
#define SP 1664515
#define magicnum 2147483647
using namespace std::tr1;

char s[N];
int cnt[2];

int main(){
//	freopen("read.in","r",stdin);
//	freopen("my.out","w",stdout);
    int n;
    scanf("%d%s",&n,s);
    for(int i=0;i<n;i++)if(s[i]=='.')cnt[0]++;else cnt[1]++;
    int sum=cnt[0],ans=sum;
    for(int i=0;i<n;i++){
    	if(s[i]=='.')sum--;else sum++;
    	ans=min(ans,sum);
    }
    printf("%d",ans);
    
    
    
    
    
    
    
    return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <queue>
using namespace std;

int main() {
  int t, n, k, x, pre_x, len, start;

  cin >> t;

  while(t--) {
    priority_queue<int> que;

    cin >> n >> k;

    for(int i = 0; i < n; i++) {
      cin >> x;
      if(i == 0){
	start = pre_x = x;
      } 
      else{
        que.push(x - pre_x);
        pre_x = x;
      } 
    }

    len = x - start;

    for(int i = 0; i < k-1 && que.size(); ++i){
      len -= que.top(), que.pop();
    }

    cout << len << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int i;
  int A;
  int B;
  int maximum = -10000;
  int arr[3];
  scanf("%d %d", &A, &B);
  arr[0] = A*B;
  arr[1] = A+B;
  arr[2] = A-B;
  for(i=0; i<3; i++){
    if(arr[i]>maximum){
      maximum = arr[i];
    }
  }
  printf("%d",maximum);
}
  

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int x[101];
int main(){
	int N,K,ans=0;
//	vector<pii> x;
	cin>>N>>K;
	rep(i,N){
		int t;
		cin>>x[i];
		ans+=min(abs(x[i]-0),abs(x[i]-K));
	//	x.push_back(make_pair(t,i));
	}
	cout<<ans*2<<endl;

	
	return 0;
}



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

int main() {

	int D;
	cin >> D;

	if (D == 25) {
		cout << "Christmas" << endl;
	}

	if (D == 24) {
		cout << "Christmas Eve" << endl;
	}

	if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}

	if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split("\n");

  for (let i = 0; i < args.length; i++) {
    let n, x;
    [n, x] = args[i].split(" ").map((x) => Number(x));
    if (n === 0 && x === 0) {
      break;
    }
    solve(n, x);
  }
}

function solve(n, x) {
  let ans = 0;
  for (let i = 1; i <= n; i++) {
    for (let j = i + 1; j <= n; j++) {
      for (let k = j + 1; k <= n; k++) {
        if (i + j + k == x) {
          ans++;
        }
      }
    }
  }
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 16344
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;
vector<int> sons[100001];
queue<int> q; 
int da[100001],db[100001];
bool v[100001];
int main(){
int n,a,b,x,u;
cin >> n;
for(int i=1;i<=n-1;i++){
cin >> a >> b;
sons[a].push_back(b);
sons[b].push_back(a);
}
a=1;
b=n;
memset(v,0,sizeof(v));
for(int i=1;i<=n;i++) da[i]=1e9;
da[a]=0; v[a]=1; q.push(a);
while(!q.empty()){
x=q.front();
for(int i=0;i<sons[x].size();i++){
u=sons[x][i];
if(!v[u]){
da[u]=da[x]+1;
v[u]=1;
q.push(u);
}}
q.pop();
}
memset(v, 0, sizeof(v));
for(int i=1;i<=n;i++) db[i]=1e9;
db[b]=0; v[b]=1; q.push(b);
while(!q.empty()){
x=q.front();
for(int i=0;i<sons[x].size();i++){
u=sons[x][i];
if(!v[u]){
db[u]=db[x]+1;
v[u]=1;
q.push(u);
}}
q.pop();
}
int snuke=0, fennec=0;
for(int i=1;i<=n;i++){
if(da[i]>db[i]) snuke++;
else if(da[i]<=db[i]) fennec++;
}
if(snuke>=fennec) cout << "Snuke" << endl;
else cout << "Fennec" << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define INF (1LL<<62)

LL slv(LL x,LL y,LL s)
{
    LL X = x/2,Y = y/2;
    return min (
        max( max(abs(X*y-s),abs((x-X)*y-s)), abs(X*y-(x-X)*y) ),
        max( max(abs(x*Y-s),abs((y-Y)*x-s)), abs(Y*x-(y-Y)*x) )
    );
}

int main()
{
    LL h,w;
    cin>>h>>w;
    LL ans = INF;
    for (int i=1;i<=h;i++)
        ans = min (ans,slv(h-i,w,i*w));
    for (int i=1;i<=w;i++)
        ans = min (ans, slv(w-i,h,i*h));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 130;
char grid[MAXN][MAXN];
int n, m;
int Cnt[26];

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cin >> grid[i][j];
      Cnt[grid[i][j] - 'a']++;
    }
  }
  int par[4] = {0};
  for(int i = 0; i < 26; i++) {
    par[Cnt[i] % 4]++;
  }
  if(m % 2) swap(n, m);
  // n is odd
  bool ok;
  if(n % 2 == 1 && m % 2 == 1) {
    int odd = par[1] + par[3];
    if(odd > 1) {
      ok = false;
    } else {
      assert(odd == 1);
      int up = (n/2) + (m/2);
      if(par[2] <= up) {
        ok = true;
      } else {
        ok = false;
      }
    }
  } else if(n % 2 == 1) {
    int up = (m/2);
    if(par[1] + par[3] > 0) {
      ok = false;
    } else if(par[2] <= up) {
      ok = true;
    } else ok = false;
  } else {
    if(par[1] + par[2] + par[3] > 0) {
      ok = false;
    } else {
      ok = true;
    }
  }
  if(ok) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2, int(n**0.5)+1):
        while not num%i: num //= i ; ans.append(i)
    if num != 1: ans.append(num)
    return col.Counter(ans)
    
n = int(input())
a = list(map(int,input().split()))

cnt = col.Counter()
for num in a:
    new = prime(num)
    for key,val in new.items():
        if val > cnt[key] : cnt[key] = val

LCM = 1
MOD = 10**9 + 7
for key,val in cnt.items(): LCM *= key**val %MOD

ans = 0
for num in a:
    b = LCM * pow(num, MOD-2, MOD) #割るのではなく逆元をかける
    ans += b
    
print(ans%MOD)





Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

uint tzcnt(uint x) {
    x = ~x & (x - 1);
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int grid[50][50];
int h, w;

//int search(int y, int x, int dir, int cost) {
//    if (y == h - 1 && x == w - 1) return cost;
//
//    if (y >= h || x >= w || y < 0 || x < 0) return 10000000;
//
//    int res = 10000000;
//
//    if (dir != 2 && y + 1 < h && grid[y + 1][x] == 0) {
//        res = min(res, search(y + 1, x, 0, cost + 1));
//    }
//
//    if (dir != 3 && x + 1 < w && grid[y][x + 1] == 0) {
//        res = min(res, search(y, x + 1, 1, cost + 1));
//    }
//
//    /*if (dir != 0 && y - 1 < h && grid[y - 1][x] == 0) {
//        res = min(res, search(y - 1, x, 2, cost + 1));
//    }
//
//    if (dir != 1 && x - 1 < w && grid[y][x - 1] == 0) {
//        res = min(res, search(y, x - 1, 3, cost + 1));
//    }*/
//
//    return res;
//}

struct square {
    int x;
    int y;
    int cost;
};

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

    cin >> h >> w;

    int bc = 0;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {

            char a;
            cin >> a;

            grid[i][j] = (a == '#') ? 1 : 0;

            if (grid[i][j] == 1) bc++;
        }
    }


    queue<square> q;
    int res = 1000000000;

    square f;
    f.x = f.y = f.cost = 0;

    q.push(f);

    while (q.size()) {
        square sq = q.front();
        q.pop();

        if (grid[sq.y][sq.x] != 0) continue;

        grid[sq.y][sq.x] = 2;

        if (sq.y == h - 1 && sq.x == w - 1) {
            res = min(res, sq.cost);

            break;
        }

        if (sq.y + 1 < h && grid[sq.y + 1][sq.x] == 0) {
            square t;
            t.y = sq.y + 1;
            t.x = sq.x;
            t.cost = sq.cost + 1;
            q.push(t);
        }

        if (sq.x + 1 < w && grid[sq.y][sq.x + 1] == 0) {
            square t;
            t.y = sq.y;
            t.x = sq.x + 1;
            t.cost = sq.cost + 1;
            q.push(t);
        }
        if (sq.y - 1 >= 0 && grid[sq.y - 1][sq.x] == 0) {
            square t;
            t.y = sq.y - 1;
            t.x = sq.x;
            t.cost = sq.cost + 1;
            q.push(t);
        }

        if (sq.x - 1 >= 0 && grid[sq.y][sq.x - 1] == 0) {
            square t;
            t.y = sq.y;
            t.x = sq.x - 1;
            t.cost = sq.cost + 1;
            q.push(t);
        }
    }

    int o = res > h * w ? -1 : (h * w - bc - res - 1);

    out(o);

    int aaa;
    cin >> aaa;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int A,B,C;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> A >> B >> C;
  if (A > B) swap(A,B);
  cout << (IN(C,A,B) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256