akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <vector>
#include <map>
#include <unordered_map>

using namespace std;

struct Edge;
using Edges = vector<Edge*>;
struct Vertex;
typedef vector<Vertex*> Vertices;

using Color = int;
struct Vertex {
	int id;
	Edges edges;
	vector<int> ids_dst;
	Vertices dsts;
	Color color;
	Vertex(int id) :
		id(id), color(0) { }
	void add_edge(Edge *p_e);
};
typedef vector<Vertex*> Vertices;

struct Edge {
	Vertex *p_src, *p_dst;
	Edge(Vertex *p_src, Vertex *p_dst) :
		p_src(p_src), p_dst(p_dst) { }
};

void Vertex::add_edge(Edge *p_e) {
	edges.push_back(p_e);
	dsts.push_back(p_e->p_dst);
}

struct Graph {
	Vertices vertices;
	Edges edges;
	Graph(int nvertices) {
		for (int id = 0; id < nvertices; id++) {
			vertices.push_back(new Vertex(id));
		}
	}
	~Graph() {
		for (auto &p_vertex : vertices) {
			delete p_vertex;
		}
		for (auto &p_edge : edges) {
			delete p_edge;
		}
	}
	void add_edge(Edge *p_edge) {
		(*vertices[p_edge->p_src->id]).add_edge(p_edge);
		edges.push_back(p_edge);
	}
	void add_edge(int edge_src, int edge_dst) {
		add_edge(new Edge(vertices[edge_src], vertices[edge_dst]));
	}
	int get_nblacks() { //color=1
		int count = 0;
		for (auto &p_vertex : vertices) {
			if (p_vertex->color == 1) {
				count++;
			}
		}
		return count;
	}
};

bool is_bipartite(Vertex *p_v, const Color c) {
	p_v->color = c;
	for (auto p_dst : p_v->dsts) {
		if (p_dst->color == 0 && !is_bipartite(p_dst, -c)) {
			return false;
		}
		else if (p_dst->color == c) {
			return false;
		}
	}
	return true;
}

int N, M;
int A, B;

void solve() {
	long long ans;

	cin >> N >> M;
	Graph g(N + 1);
	for (int i = 0; i < M; i++)
	{
		cin >> A >> B;
		g.add_edge(A, B);
		g.add_edge(B, A);
	}
	long long nedges_possible;
	if (is_bipartite(g.vertices[1], 1)) {
			const int nblacks = g.get_nblacks();
			nedges_possible = (long long)nblacks * (N-nblacks);
	}
	else {
		nedges_possible = (long long)N * (N - 1) / 2;
	}
	ans = nedges_possible - M;

	cout << ans << endl;

	return;
}

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

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

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

void bin(int x) {
	int left = -1, right = ANS.size() - 1;
	int mid = (left + right) / 2;
	if (ANS.at(right) >= x) {
		pb(ANS, x)
		return;
	}
	if (ANS.at(0)<x) {
		ANS.at(0) = x;
		return;
	}


	while (right - left > 1) {
		mid = (left + right) / 2;
		if (ANS.at(mid)>=x) {
			left = mid;
		}
		else {
			right = mid;
		}
	}

	if (ANS.at(mid) < x) {
		ANS.at(mid) = x;
	}
	else {
		if (mid == ANS.size() - 1) {
			pb(ANS, x)
		}
		else {
			ANS.at(mid+1) = x;
		}
	}

}

int main()
{

	int N;
	vec(A)
		cin >> N;
	int maxi = 0;
	int sub = 0;
	map<int, int> S;

	fx(N) {
		vecp(A)
	}
	pb(ANS, A.at(0))

		fx(N - 1) {
		bin(A.at(x + 1));
	}

	ce(ANS.size())




    return 0;
}



Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
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;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int n;
LL a[MAX], b[MAX];

int main(void) {
    cin >> n;
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    VL v;
    REP(i, n) {
        v.EB(a[i] - b[i]);
    }
    SORT(v);
    LL must = 0;
    REP(i, n) {
        if (v[i] > 0) must += v[i];
        else if (v[i] < 0) {
            must += v[i] / 2;
        }
    }
    cout << (must <= 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
require("fs").readFileSync("/dev/stdin","utf8").split('\n\n').map(function(i){l=/1(\d|\n)*1/m.exec(i)[0].length%11;console.log(l?l==6?'B':l==4?'C':l==7?'D':l==1?'E':l==9?'F':'G':'A')})

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

int n,q;
int a[1000010];
typedef tuple<int,int> state;
set<state> s;

int main(void){
	cin >> n >> q;
	rep(i,n) s.insert(state(0,i)),a[i]=0;
	rep(i,q){
		int w,v;
		cin >> w >> v;
		w--;
		auto it=s.find(state(-a[w],w));
		s.erase(it);
		a[w]+=v;
		s.insert(state(-a[w],w));
		int res[2];
		tie(res[1],res[0])=*(s.begin());
		cout << res[0]+1 << " " << -res[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 51976
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[10],b[10],c[10];
	scanf("%s %s %s",a,b,c);
	if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0]){
		cout<<"YES"<<endl;
	}
	else if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]!=c[0]){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

class dice_class:
    def __init__(self, top, front, right, left, back, bottom):
        self.top    =   top
        self.front  =   front
        self.right  =   right
        self.left   =   left
        self.back   =   back
        self.bottom =   bottom

    def sut(self, t):  #set_up_top
        while True:
            if self.top == t:
                break
            else:
                dice.roll('E')
            if self.top == t:
                break
            else:
                dice.roll('N')

    def suf(self, f):   #set_up_front
        while True:
            if self.front == f:
                break
            else:
                dice.roll("SEN")

    def roll(self, s):
        for i in s:
            if i == 'E':
                self.rollE()
            elif i == 'N':
                self.rollN()
            elif i == 'S':
                self.rollS()
            elif i == 'W':
                self.rollW()

    def rollE(self):
        tmp         =   self.top
        self.top    =   self.left
        self.left   =   self.bottom
        self.bottom =   self.right
        self.right  =   tmp

    def rollN(self):
        tmp         =   self.top
        self.top    =   self.front
        self.front  =   self.bottom
        self.bottom =   self.back
        self.back   =   tmp

    def rollS(self):
        tmp         =   self.top
        self.top    =   self.back
        self.back   =   self.bottom
        self.bottom =   self.front
        self.front  =   tmp

    def rollW(self):
        tmp         =   self.top
        self.top    =   self.right
        self.right  =   self.bottom
        self.bottom =   self.left
        self.left   =   tmp

if __name__ == "__main__":
    a = map(int, raw_input().split())
    dice = dice_class(a[0], a[1], a[2], a[3], a[4], a[5])
    n = int(raw_input())
    for i in range(n):
        t, f = map(int, raw_input().split())
        dice.sut(t)
        dice.suf(f)
        print dice.right

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

using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define ll long long
#define fi first
#define se second
const int N = 1e6+5;
const int p = 1e9+7;
ll modexp(ll a,ll b,ll p){
    ll ans=1LL;a%=p;
    while(b){if(b&1)ans=ans*a%p;b>>=1;a=a*a%p;}
    return ans;
}
int vis[N];
vector<int>v;
void init(){
    for(int i=2;i<N;i++){
        if(vis[i])continue;
        for(int j=i*2;j<N;j+=i){
            vis[j]=1;
        }
    }
    for(int i=2;i<N;i++){
        if(!vis[i])v.pb(i);
    }
}
ll C(ll a,ll b){
    ll ans=1;
    for(ll i=a;i>a-b;i--){
        ans=ans*i%p;
    }
    for(int i=2;i<=b;i++)
        ans=ans*modexp(i,p-2,p)%p;
    return ans;
}
int main()
{
    init();
    int n,m;scanf("%d%d",&n,&m);
    vector<pair<int,int> >t;
    for(int i=0;v[i]*v[i]<=m;i++){
        if(m%v[i]==0){
            int cnt=0;
            while(m%v[i]==0){
                cnt++;m/=v[i];
            }
            t.pb({v[i],cnt});
        }
    }
    if(m!=1)t.pb({m,1});
    ll ans=1LL;
    for(auto &x:t){
        ans=ans*C(n+x.se-1,x.se)%p;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int H,W;
string S[444];
vector<vector<int>> G(444*444);
int color[444*444];
int visit[444*444];
ll whi,bla;

void bfs(int v){
  visit[v]=1;
  if(color[v]) bla++;
  else whi++;
  for(int u:G[v]) if(!visit[u]){
    bfs(u);
  }
}

int main(){
  cin>>H>>W;
  rep(i,H) cin>>S[i];
  rep(i,H) rep(j,W){
    int cur=i*W+j,d=(i+1)*W+j, r=i*W+j+1;
    color[cur]=(S[i][j]=='#');
    if(S[i][j]!=S[i+1][j]&&i+1<H){
      G[cur].push_back(d);
      G[d].push_back(cur);
    }
    if(S[i][j]!=S[i][j+1]&&j+1<W){
      G[cur].push_back(r);
      G[r].push_back(cur);
    }
  }
  ll ans=0;
  rep(i,H*W) if(!visit[i]){
    whi=0,bla=0;
    bfs(i);
    ans+=whi*bla;
  }
  cout<<ans<<endl;
  return 0;
}



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

void Main() {
  int A, B, T;
  cin >> A >> B >> T;
  cout << T / A * B << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;

int N;
int A[4][222];
int res[222];
int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++) scanf("%d",&A[j][i]);
  }
  memset(res,0,sizeof(res));
  for(int j=0;j<3;j++){    
    for(int i=0;i<N;i++){
      bool f=false;
      for(int l=0;l<N;l++){
	if(i==l) continue;
	if(A[j][i]==A[j][l]) f=true;
      }
      if(!f) res[i]+=A[j][i];
    }
  }
  for(int i=0;i<N;i++) printf("%d\n",res[i]);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#ifdef tester
    #include "prettyprint.hpp"
#endif
using namespace std;

#define hell 1000000007
#define ll long long
#define all(C) begin(C),end(C)
#define tr(C,it,cond) for(auto it = begin(C); cond and it!=end(C); ++it)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define hash unordered_map
#define vi vector<ll>
#define pii pair<ll,ll>
#define index(V, ele) distance(V.begin(), find(all(V), ele))
#define N 100005

#define whats(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {} template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
#ifdef tester 
    cerr << *it << " = " << a << endl;	err(++it, args...); 
#endif 
}

ll t,n,k,m,q;
string s;

// vim cli: !g++ -Dtester sol.cpp ; ./a.out ; rm a.out
int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(20);

    cin >> s;
    const int x=753;
    n=0;
    rep(i,0,s.size()-2)
        if (abs(x-n) > abs(x-strtol(s.substr(i,3).c_str(),NULL,10)))
            n = strtol(s.substr(i,3).c_str(),NULL,10);
    cout << abs(x-n);
    // whats(t,v);
    return 0;
}

Measured memory_bytes: 256
A = list(map(int,input().split()))
A += list(map(int,input().split()))
A += list(map(int,input().split()))
Z = [False]*9

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

for i in range(N):
  for j in range(9):
    if A[j] == B[i]:
      Z[j] = True
      
if (Z[0] and Z[1] and Z[2]) or (Z[3] and Z[4] and Z[5]) or (Z[6] and Z[7] and Z[8]) or (Z[0] and Z[3] and Z[6]) or (Z[1] and Z[4] and Z[7]) or (Z[2] and Z[5] and Z[8]) or (Z[0] and Z[4] and Z[8]) or (Z[2] and Z[4] and Z[6]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#include<stdio.h>
int main(void){
    int i,j,date[366],month[12],m,d,ans;
    month[0]=month[2]=month[4]=month[6]=month[7]=month[9]=month[11]=31;
    month[3]=month[5]=month[8]=month[10]=30;
    month[1]=29;
    for(i=0;i<366;i++){
        date[i]=i+3;
    }
    while(scanf("%d %d",&m,&d),m!=0){
        int work=0;
        for(i=0;i<m-1;i++){
            work+=month[i];
        }
        work+=d;
        ans=date[work-1]%7;
        switch(ans){
            case 0:puts("Monday");
            break;
            case 1:puts("Tuesday");
            break;
            case 2:puts("Wednesday");
            break;
            case 3:puts("Thursday");
            break;
            case 4:puts("Friday");
            break;
            case 5:puts("Saturday");
            break;
            case 6:puts("Sunday");
            break;

            default:break;
        }
    }
    return 0;
}

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

typedef pair<int, int> pi;

const int N = 300005;

int n, v[N], w[N], L, id[25], mx[N], top1, top2;
pi sta1[N], sta2[N], tmp[N];

void get(int x, int y, int & top1, pi * sta1)
{
	top1 = 1;
	sta1[0] = make_pair(0, 0);
	for (int i = x; i <= y; i++)
	{
		int top = 0, p = 0, q = 0, vv = v[id[i]], ww = w[id[i]];
		while (p < top1 && q < top1)
			if (sta1[p].second < sta1[q].second + ww) tmp[top++] = sta1[p++];
			else tmp[top++] = make_pair(sta1[q].first + vv, sta1[q].second + ww), q++;
		while (p < top1) tmp[top++] = sta1[p++];
		while (q < top1) tmp[top++] = make_pair(sta1[q].first + vv, sta1[q].second + ww), q++;
		for (int j = 0; j < top; j++) sta1[j] = tmp[j];
		top1 = top;
	}
}

bool cmp(pi a, pi b)
{
	return a.second < b.second;
}

void solve()
{
	int p = top2 - 1, ans = 0;
	mx[0] = sta2[0].first;
	for (int i = 1; i < top2; i++) mx[i] = max(mx[i - 1], sta2[i].first);
	for (int i = 0; i < top1; i++)
	{
		int vv = sta1[i].first, ww = sta1[i].second;
		while (p >= 0 && sta2[p].second + ww > L) p--;
		if (p >= 0) ans = max(ans, mx[p] + vv);
	}
	printf("%d\n", ans);
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &v[i], &w[i]);
	int q;
	scanf("%d", &q);
	while (q--)
	{
		int x; scanf("%d%d", &x, &L);
		int tot = 0;
		while (x) id[++tot] = x, x /= 2;
		get(1, tot / 2, top1, sta1);
		get(tot / 2 + 1, tot, top2, sta2);
		solve();
	}
	return 0;
}

Measured memory_bytes: 5848
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()
int res, n, a, b, c;
vector<int> l;

void calc(vector<int> v)
{
	int lenA, lenB, lenC;
	lenA = lenB = lenC = 0;
	bool flagA, flagB, flagC;
	flagA = flagB = flagC = false;
	int temp = 0;
	rep(i, 0, n - 1)
	{
		switch (v[i])
		{
		case 0:
			if (flagA) temp += 10;

			lenA += l[i];
			flagA = true;
			break;
		case 1:
			if (flagB) temp += 10;

			lenB += l[i];
			flagB = true;
			break;
		case 2:
			if (flagC) temp += 10;

			lenC += l[i];
			flagC = true;
			break;
		}
	}
	if (flagA && flagB && flagC)
	{
		temp += abs(a - lenA) + abs(b - lenB) + abs(c - lenC);
		res = min(res, temp);
	}
}

void dfs(int depth, vector<int> v)
{
	if (depth == n)
	{
		calc(v);
		return;
	}
	rep(i, 0, 3)
	{
		v[depth] = i;
		dfs(depth + 1, v);
	}
}

int main()
{
	cin >> n >> a >> b >> c;
	l.resize(n);
	rep(i, 0, n - 1)
	{
		cin >> l[i];
	}
	vector<int> v(n);
	res = (int)1e9;
	dfs(0, v);
	cout << res << endl;
}

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

int main()
{
        int a,b;
        cin>>a >> b;
      int arr[100001];
      int sum=0;
      for(int i=0; i<b; i++){
          cin >> arr[i];
          sum += arr[i];
      }
      int tmp = a - sum;
      if(tmp<0)
        cout <<-1 <<endl;
      else

    cout << tmp <<endl;
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
#define ll long long
int main(void){
    int h, w, dp[100][100];
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
        	scanf("%1d",&dp[i][j]);
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i == 0 && j == 0){
            	
            }else if(i == 0){
                dp[i][j] += dp[i][j-1];
            }else if(j == 0){
                dp[i][j] += dp[i-1][j];
            }else{
                dp[i][j] += min(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    
    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> p;
vector<long long int> q;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C - (A - B) < 0)cout << 0 << "\n";
	else cout << C - (A - B) << "\n";
	return 0;
}

Measured memory_bytes: 256
def main():
    N, Y = map(int, input().split())

    for tho in range(N+1):
        for fif in range(N+1-tho):
            ten = N - fif - tho
            if ten*10000 + fif*5000 + tho*1000 == Y:
                print(ten, fif, tho)
                return

    print("-1 -1 -1")

main()

Measured memory_bytes: 2940
"use strict";

const main = arg => {
  const n = parseInt(arg.split("\n")[0], 10)
  if (n % 2 !== 0) {
  	console.log("No")
    return
  }
  const s = arg.split("\n")[1]
  if (s.slice(0, n/2) == s.slice(n/2)) {
  	console.log("Yes")
  } else {
  	console.log("No")
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

vector<pair<ll,ll>> prime;
vector<ll> can;
void DFS(int cnt,ll res) {
  if (cnt == prime.size()) {
    can.push_back(res);
    return ;
  } else {
    ll x = 1;
    for (int i = 0; i <= prime[cnt].second; i++) {
      DFS(cnt+1,res*x);
      x *= prime[cnt].first;
    }
  }
}

int main() {
  ll N,K;
  cin >> N >> K;
  ll A[N];
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  // 素因数分解
  int cnt = -1;
  for (int i = 2; i * i <= sum; i++) {
    if (sum % i == 0) {
      prime.push_back(make_pair(i,0));
      cnt++;
      while (sum % i == 0) {
        sum /= i;
        prime[cnt].second++;
      }
    }
  }
  if (sum != 1) {
    prime.push_back(make_pair(sum,1));
  }

  DFS(0,1LL);
  ll ans = 1;
  ll num = 0;
  vector<pair<ll,ll>> p;

  for (int i = 0; i < can.size(); i++) {
    num = 99999999999999;
    p.clear();
    if (can[i] == 1) {
      continue;
    }
    for (int j = 0; j < N; j++) {
      if (A[j] % can[i] != 0) {
        p.push_back(make_pair(can[i] - (A[j] % can[i]),A[j] % can[i]));
      }
    }
    if (p.size() == 0) {
      ans = max(can[i],ans);
      continue;
    }
    sort(p.begin(),p.end());
    ll R1[p.size()];
    ll R2[p.size()];
    R1[0] = p[0].first;
    R2[p.size()-1] = p[p.size()-1].second;
    for (int j = 1; j < p.size(); j++) {
      R1[j] = R1[j-1] + p[j].first;
    }
    for (int j = p.size() - 2; j >= 0; j--) {
      R2[j] = R2[j+1] + p[j].second;
    }
    
    for (int j = 0; j < p.size() - 1; j++) {
      if (R1[j] == R2[j+1]) {
        num = R1[j];
        break;
      }
    }
    if (num <= K) {
      ans = max(can[i],ans);
    }
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
    ll N;
    cin >> N;
    vector<ll> P(N);
    for(ll i=0;i<N;i++){
        cin >> P[i];
    }


    ll count=0;
    
    ll mini=P[0];
    for(ll i=0;i<N;i++){
      mini=min(mini,P[i]);
      if(mini==P[i]){
        count++;
      }
    }
        

    cout << count << endl;

}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	double v ;
	while(cin >> v)
	{
		int N=1;
		while(1)
		{
			int y=N*5-5;
			if(v*v<=19.6*y) break;
			else N++;
		}
		cout << N << '\n' ;
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

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

	int a,b,c;
	cin>>a>>b>>c;
	bool flg=false;
	int n=a;
	while (!flg) {
		if(n%b==c) {
			cout<<"YES"<<endl;
			return 0;
		}
		n+=a;
		if(a%b==n%b) {
			cout<<"NO"<<endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >>c;
  set<int> ans;
  ans.insert(a);
  ans.insert(b);
  ans.insert(c);

  cout<<ans.size()<<endl;
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 bool arr[100000+5]={false};
 int cnt[100000+5]={0};

 bool is_prime(int x)
 {
   if(x==1) return false;
   else if(x==2) return true;
   else
   {
     for(int i=2;i<=(int)(sqrt(x));i++)
     {
       if((x%i)==0) return false;        
     }    
     return true;
   }     
 }
 
 void init()
 {
   for(int i=1;i<=100000;i=i+2)
   {
     if((is_prime(i))&&(is_prime((i+1)/2))) arr[i]=true;
     else arr[i]=false;        
   }
   for(int i=1;i<=99999;i=i+2)
   {
     if((arr[i]==true)&&(i==1)) cnt[i]++;
     else
     {
       if(arr[i]==true) cnt[i]=cnt[i-2]+1;
       else cnt[i]=cnt[i-2];    
     }        
   }
   return;
 }

 int main()
 {
   init();
   int q;
   //for(int i=1;i<=53;i=i+2) cout<<cnt[i]<<endl;
   while(cin>>q)
   {
     int l,r;
     while(cin>>l>>r)
     {
       if(l==1) cout<<cnt[r]<<endl;
       else cout<<(cnt[r]-cnt[l-2])<<endl;               
     }             
   }
   return 0;
 }
 

        

Measured memory_bytes: 1152
#include<stdio.h>
int main(){
    int A,B;
    scanf("%d %d",&A ,&B);
    if(1<=A && A<=3 && 1<=B && B<=3){
        if( A==1 && B==2  || A==2 && B== 1){
            printf("3");
        }
        else if(A==2 && B==3 || A==3 && B==2){
            printf("1");
        }
        else{
            printf("2");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, K, ans;

int main()
{
	in >> N >> K;
	if (K == 0) ans = N * N;
	else
	{
		for (LL b = K + 1; b <= N; ++b)
		{
			LL res1 = (b - K)*(N / b);
			LL res2 = (K > N - N / b * b ? 0 : N - N / b * b - (K - 1));
			ans += res1 + res2;
		}
	}
	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int fib[50];

int  fibonacci(int i){
  if(i == 0 || i == 1){
    fib[i] = 1;
    return fib[i];
  }
  if(fib[i] != 0)
    return fib[i];
  fib[i] = fibonacci(i-1) + fibonacci(i-2);
  return fib[i];
}

int main(){
  int i,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    fib[i]=0;
  }

  printf("%d\n",fibonacci(n));

  return 0;
}



Measured memory_bytes: 2112
/*
 * 隣接リスト表現のグラフのプリム法 (優先度付きキューを使用)
 * 計算量は O(|E| log |V|)
 *
 */
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

const int MAX_V = 10000;
const int INF = 1e+8;
// first : コスト, second : 頂点番号
typedef pair<int,int> P;

struct edge{
	int to, cost;
	edge(int v, int cost_){
		to = v;
		cost = cost_;
	}
};

// 頂点数
int V;
// G[u][i] = ノード u に接続している i 番目の edge が返ってくる
vector<edge> G[MAX_V];
// 頂点の集合 X からの辺の最小コスト
int mincost[MAX_V];
// used[i] := 頂点 i が集合に含まれているか
bool used[MAX_V];

// 初期化
void init(int n){
	V = n;
	for(int i = 0 ; i < MAX_V ; i++ ){
		G[i].clear();
	}
}

// 最小全域木のコストの総和を返す (プリム法)
int prim(){
	// greater<P> を指定することで first が小さい順に取り出せる
	priority_queue<P, vector<P>, greater<P> > q;
	// 初期化
	fill( mincost , mincost+V , INF );
	fill( used , used+V , false );
	mincost[0] = 0;
	int res = 0;
	q.push( P(0,0) );
	
	while( !q.empty() ){
		P p = q.top(); q.pop();
		int v = p.second;
		
		if( mincost[v] < p.first ) continue;
		used[v] = true;
		res += mincost[v];
		
		for(int i=0 ; i < G[v].size() ; i++ ){
			edge e = G[v][i];
			if( !used[e.to] && mincost[e.to] > e.cost ){
				mincost[e.to] = e.cost;
				q.push( P(e.cost,e.to) );
			}
		}
	}
	return res;
}

// 重み cost の辺 (u,v) の追加
void add_edge(int u, int v, int cost){
	edge e( v , cost );
	G[u].push_back( e );
	// 有向グラフなら以下の処理は不要
	e.to = u;
	G[v].push_back( e );
}

int main(){
	int n,m;
	while( cin >> n >> m , n || m ){
		// 初期化
		init( n );
		for(int i = 0 ; i < m ; i++ ){
			int u, v, c ;
			cin >> u >> v >> c;
			add_edge( u , v , c );
		}
		cout << prim() << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX_V 1000
#define INF 100000000
typedef pair<int,int> P;

struct edge { int to,cap,cost,rev; };

int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init_edge(){
  for(int i=0;i<V;i++)G[i].clear();
}

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,G[to].size()});
  G[to].push_back((edge){from,0,-cost,G[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+V,0);
  while(f>0){

    priority_queue< P, vector<P>, greater<P> >  que;
    fill( dist, dist+V , INF );
    dist[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v = p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)G[v].size();i++){
	edge &e = G[v][i];
	if(e.cap>0&&dist[e.to] > dist[v]+e.cost+h[v]-h[e.to]){
	  dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
	  prevv[e.to]=v;
	  preve[e.to]=i;
	  que.push(P(dist[e.to],e.to));
	}
      }
    }

    if(dist[t]==INF){
      return -1;
    }
    for(int v=0;v<V;v++)h[v]+=dist[v];

    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int n,t[101];
int main(){
  cin>>n;
  V=n+n+2;
  for(int i=1;i<=n;i++){
    cin>>t[i];
    for(int j=1;j<=n;j++){
      if(j==t[i])continue;
      add_edge(i,n+j,1,t[i]*abs(i-j));
    }
    add_edge(0,i,1,0);
    add_edge(n+i,n+n+1,1,0);
  }
  cout<<min_cost_flow(0,n+n+1,n)<<endl;
  return 0;
}

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


int main() {
    string n;
    cin >> n;
    if (n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
    else if (n[1] == n[2] && n[2] == n[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
} 


Measured memory_bytes: 3568
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

T = input()
T = T.replace("?", "D")
print(T)

# ans = T.count("D")
# ans += T.count("PD")
# print(ans)





Measured memory_bytes: 11048
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> H;
	H.push_back(0);
	int c = 0;
	for (int i = 0; i < N; i++)
	{
		int x;
		cin >> x;
		H.push_back(x);
		if (c != 0)
		{
			c++;
		}
	}
	H.push_back(0);
	int ans = 0;
	int a = 0, b = N;
	int ck = 0;
	for (int i = 0; i < N+2; i++)
	{
		if (ck == 0)
		{
			if (H[i] != 0)
			{
				a = i;
				ck = 1;
			}
		}
		if (ck == 1)
		{
			if (H[i] == 0)
			{
				b = i - 1;
				int min = 101;
				for (int j = a; j <= b; j++)
				{
					if (H[j] < min)
					{
						min = H[j];
					}
				}
				ans = ans + min;
				for (int j = a; j <= b; j++)
				{
					H[j] = H[j] - min;
				}
				ck = 0;
				a = 0;
				b = 0;
				i = -1;
			}
		}
		
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int N; cin >>N;
  string s; cin >>s;
  N *= 2;
  int n2 = N/2;
  vector<string> ps(1 << n2);
  string tmp = "";
  rep(i, n2+1) tmp += '!';
  rep(i, 1 << n2){
    int head = 0, tail = n2;
    string st = tmp;
    rep(j, n2){
      if ((i >> j) & 1) st[head++] = s[j];
      else st[tail--] = s[j];
    }
    ps[i] = st;
  }
  sort(all(ps));
  ll res = 0;
  rep(i, 1 << N-n2){
    int head = 0, tail = n2;
    string st = tmp;
    rep(j, n2){
      if ((i >> j) & 1) st[tail--] = s[N-1-j];
      else st[head++] = s[N-1-j];
    }
    int num = upper_bound(all(ps), st) - lower_bound(all(ps), st);
    res += num;
  }
  cout <<res <<endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


void solvenewR() {
    int n;
    string s;
    cin >> n >> s;

    int cntE = 0, cntW = 0;
    // 1人目から東側で東向いている人数（向き直る人数）を求める
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'E') {
            cntE++;
        }
    }
    int ans = cntE;

    // リーダーをずらしながら向き直る人数を求める
    for (int newR = 1; newR < n; ++newR) {
        // 旧リーダーの向き直りカウント
        if (s[newR - 1] == 'W') {
            cntW++;
        }
        // 新リーダーのカウントを除く
        if (s[newR] == 'E') {
            cntE--;
        }
        ans = min(ans, cntE + cntW);
    }

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


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

    solvenewR();
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << 2*b - a << "\n";
    return 0;
}


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

int main()
{
    int n, m, ans;
    scanf("%d%d", &n, &m);
    ans = m;
    for(int i = 0; i < n-1; i++)ans*=(m-1);
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
void Repair(int ,int );
int Preorder[100],Inorder[100],Postorder[100],postnode=0,nownode=0,n;
int main(void){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&Preorder[i]);
  for(i=0;i<n;i++)
    scanf("%d",&Inorder[i]);

  Repair(0,n);

  for(i=0;i<n;i++){
    printf("%d",Postorder[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  return 0;
}
void Repair(int left,int right){
  int rootnode,distance;
  if(left<right){
    rootnode=Preorder[nownode++];
    distance=0;
    while(distance<n){
      if(Inorder[distance++]==rootnode)
        break;
    }
    Repair(left,distance-1);
    Repair(distance,right);
    Postorder[postnode++]=rootnode;
  }
}


Measured memory_bytes: 2104
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int a[n];
	int bcnt = 0;
	REP(i, n){
		cin >> a[i];
	}

	while (1){
		int cnt = 0;
		sort(a, a+n);
		FOR(i, bcnt, n){
			if (i == bcnt) continue;
			else {
				a[i] %= a[bcnt];
				if (a[i] == 0) cnt++;
			}
		}
		bcnt += cnt;
		if (bcnt == n-1) break;
	}

	sort(a, a+n);

	cout << a[n-1] << endl;

}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int psize = 0;
int prime[400000];
bool bprime[400000];

int main() {
  memset(bprime, true, sizeof(bprime));
  FOR(i, 2, 310000) {
    if (i % 7 != 1 && i % 7 != 6) { continue; }
    if (!bprime[i]) { continue; }
    prime[psize++] = i;
    for (int j = i + i; j < 310000; j += i) {
      bprime[j] = false;
    }
  }
  int n;
  while (cin >> n, n != 1) {
    printf("%d:", n);
    REP (i, psize) {
      if (prime[i] > n) { break; }
      if (n % prime[i] == 0) { printf(" %d", prime[i]); }
    }
    puts("");
  }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  REP(i,1,n+1) {
    if( to_string(i).size()&1 ) ++cnt;
  }
  cout << cnt << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(){
    char s[4];
    int n=0;
    cin>>s;

    for(int i=0;i<4;i++){
        for(int j=i+1;j<4;j++){
        if(s[i]==s[j]){
            n++;
        }
        }
    }
    if(n!=2){
            cout<<"No"<<endl;
            
        }
    
    else if(n==2){
    cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  int u,v,n,m;
  ll x;
  cin>>n>>m;
  vector<int> G[n+1];
  vector<ll> V;
  V.pb(0);
  for(int i=0;i<n;i++)
  {
    cin>>x;
    V.pb(x);
  }
  for(int i=0;i<m;i++)
  {
    cin>>u>>v;
    G[u].pb(v);
    G[v].pb(u);
  }
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    int flag=0,val=V[i];
    if(G[i].size()==0)
    {
      cnt++;
      continue;
    }
    for(int j=0;j<G[i].size();j++)
    {
      int s=G[i][j];
      int v=V[s];
      if(v>=val)
      {
        flag=1;
        break;
      }
    }
    if(flag==0)
    cnt++;
  }
  cout<<cnt<<endl;
}

int main()
{
  fastio
  solve();
}


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

int main(){
    int n,x;
    cin >> n >> x;
    for(int i=0; i<(n-1)*2+1; i++){
        if(i!=0){
            cout << " " ;
        }
        cout << x-(n-1-i) ;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <vector>
#include <cstdio>
using namespace std;
unordered_map<int,long long>memo;
vector<vector<long long>>B={{1}};
long long f(int n,int k,int m){
	if(!n||!k)return 1;
	int ky=n*1000+k;
	if(memo.find(ky)!=memo.end())return memo[ky];
	long long r=0;
	for(int j=1;j<=n;j++)r=(r+B[n-1][j-1]*f(j,k-1,m)%m*f(n-j,k,m))%m;
	return memo[ky]=r;
}
int main(){
	int n,k,m;
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i<=n;i++){
		B.push_back({1});
		for(int j=1;j<i;j++)B[i].push_back((B[i-1][j-1]+B[i-1][j])%m);
		B[i].push_back(1);
	}
	printf("%lld\n",f(n+1,k-1,m));
}

Measured memory_bytes: 4772
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!

n,m=[int(i) for i in input().split()]

yaku1=[]

for i in range(1,10**5):
    if m%i==0:
        yaku1.append(i)

yaku2=[]
for i in yaku1:
    if m//i not in yaku1:
        yaku2.append(m//i)

yaku=yaku1+yaku2

#print(yaku)
print(max([i for i in yaku if m//i >= n]))




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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] += 32;
  cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a=1;
	int b=1;

	while(1){
		scanf("%d %d",&a,&b);

		if(a==0 && b==0) break;

		for(int j=0;j<a;j++){

			for(int i=0;i<b;i++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;

}

Measured memory_bytes: 1756
#include <stdio.h>
int main(void){
  int A, B,charge; 
  printf(" ");
  scanf("%d", &A);
  printf(" ");
  scanf("%d", &B);

  if(A <= 100 && A >= 0 && B <= 1000 && B >= 1 && B%2 == 0){
  if(A >= 13){charge = B;}
  if(A <= 12 && A >= 6){charge = B/2;}
  if(A <= 5){charge = 0;}
  printf("%d\n", charge); 
  }
 return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



void solve(std::string S){
    REP(i,0,S.size()) cout<<'x';
    cout<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int K, N;
	cin >> K >> N;
	vector<int> A(N, 0);	
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	vector<int> D(N, 0);
	int dmax = 0;
	int total = 0;
	for (int i = 0; i < N-1; i++)
	{
		D[i] = A[i+1] - A[i];
		if(D[i] > dmax) dmax = D[i];
		total += D[i];
	}
	D[N-1] = K - A[N-1] + A[0];
	total += D[N-1];
	if(D[N-1] > dmax) dmax = D[N-1];
	int ans = total - dmax;
	cout << ans << endl;
}

Measured memory_bytes: 1792
from collections import defaultdict


# all_split("abc") -> [['abc'], ['ab', 'c'], ['a', 'bc'], ['a', 'b', 'c']]
def all_split(s):
    if len(s) == 1:
        return [s]

    ans = []
    for i in range(2 ** (len(s) - 1)):
        b = list(map(int, format(i, "0" + str(len(s) - 1) + "b")))
        ans.append(split(s, b))
    return ans


def split(s, split_positions):
    assert len(s) - 1 == len(split_positions)

    ans = []
    pre = 0
    for i, is_split in enumerate(split_positions, start=1):
        if is_split:
            ans.append(s[pre:i])
            pre = i

    ans.append(s[pre:])
    return ans


def main():
    s = input()
    ans = 0
    for x in all_split(s):
        ans += eval("+".join(x))
    print(ans)


if __name__ == '__main__':
    main()


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

long f[2222222] = {1};
long inv(int a, int m) {
    long i = 1, j = 0;
    for(int b = m; a > 1; swap(i, j), swap(a, b)) {
        j = (j + b / a * (m - i)) % m;
        b %= a;
    }
    return i;
}
int main() {
    int k, p = 1e9 + 7;
    string s;
    cin >> k >> s;
    int n = k + s.length();
    for(int i = 1; i <= n; i++)
        f[i] = f[i - 1] * i % p;
    auto c = [&](int n, int r) {
        return f[n] * inv(f[r] * f[n - r] % p, p) % p;
    };
    long t = 1, r = 1;
    for(int i = 0; i < k; i++)
        (t *= 25) %= p, (r += c(n, i + 1) * t) %= p;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 20084