akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

typedef complex<int> P;
const int MAX_W = 11;
const int MAX_H = 61;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};

int W, H;
char G[MAX_H][MAX_W];
bool vis[MAX_H][MAX_W];


struct Piece : public vector<P> {
  vector<Piece> v;
  double getSumX() {
    double sum = 0;
    for(int i = 0; i < v.size(); ++i) {
      sum += v[i].getSumX();
    }
    for(int i = 0; i < this->size(); ++i) {
      sum += (*this)[i].real() + 0.5;
    }
    return sum;
  }
  int getOverNum() {
    int sum = 0;
    for(int i = 0; i < v.size(); ++i) {
      sum += v[i].getOverNum();
    }
    sum += 4;
    return sum;
  }

  int getXL() {
    int mini = MAX_W*2;
    for(int i = 0; i < this->size(); ++i) {
      P &p = (*this)[i];
      if(p.imag() == H-1 ||
	 (G[p.imag()+1][p.real()] != '.'
	  && G[p.imag()+1][p.real()] != G[p.imag()][p.real()])) {
	mini = min(mini, p.real());
      }
    }
    return mini;
  }
  int getXR() {
    int maxi = -1;
    for(int i = 0; i < this->size(); ++i) {
      P &p = (*this)[i];
      if(p.imag() == H-1 ||
	 (G[p.imag()+1][p.real()] != '.'
	  && G[p.imag()+1][p.real()] != G[p.imag()][p.real()])) {
	maxi = max(maxi, p.real());
      }
    }
    return maxi+1;
  }

  bool isStable() {
    for(int i = 0; i < v.size(); ++i) {
      if(!v[i].isStable()) return false;
    }
    double M = getSumX()/getOverNum();
    return getXL() < M && M < getXR();
  }
};

Piece head;


void getPiece(int x, int y, Piece &p, char c='.') {
  if(c == '.') c = G[y][x];
  vis[y][x] = true;
  p.push_back(P(x,y));
  for(int k = 0; k < 4; ++k) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    if(vis[ny][nx]) continue;
    if(G[ny][nx] != c) continue;
    getPiece(nx,ny,p,c);
  }
}

void makeTree(int x, int y, Piece &pp) {
  getPiece(x,y,pp);
  for(int i = 0; i < pp.size(); ++i) {
    P &b = pp[i];
    if(b.imag() == 0) continue;
    if(vis[b.imag()-1][b.real()]) continue;
    if(G[b.imag()-1][b.real()] != '.') {
      Piece np;
      makeTree(b.real(), b.imag()-1, np);
      pp.v.push_back(np);
    }
  }
}

string solve() {
  head = Piece();
  for(int j = 0; j < W; ++j) {
    if(G[H-1][j] != '.') {
      fill(vis[0], vis[MAX_H], false);
      makeTree(j,H-1,head);
      if(head.isStable()) return "STABLE";
      else                return "UNSTABLE";
    }
  }
}

int main() {
  while(cin >> W >> H && (W | H)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> G[i][j];
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/* Spreadsheet */
#include <stdio.h>

int main()
{
    int r, c, n, i, j;

    scanf("%d %d", &r, &c);
    int Sheet[r][c], SumSheet[r+1][c+1];
    for(i=0; i<r+1; i++){
        for (j=0; j<c+1; j++){
            SumSheet[i][j] = 0;
        }
    }
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d", &n);
            Sheet[i][j] = n;
            SumSheet[i][j] = n;
        }
    }
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            SumSheet[i][c] += SumSheet[i][j];
            SumSheet[r][j] += SumSheet[i][j];
        }
    }
    for(i=0;i<r;i++){
        SumSheet[r][c] += SumSheet[i][c];
    }
    for(i=0; i<r+1; i++){
        for(j=0; j<c+1; j++){
            if(j==c){
               printf("%d\n", SumSheet[i][j]);
            }
            else{
               printf("%d ", SumSheet[i][j]);
            }
        }
    }
}


Measured memory_bytes: 2096
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()


class Com{
  public:
  string name;
  int low,ave,high,num;
  bool operator<(const Com & a)const{
    return name < a.name;
  }
};

class Dea{
public:
  string name;
  int rec,pay;
  bool operator<(const Dea & a)const{
    return name < a.name;
  }
};

typedef struct{
  int cid,did;
  string cname,dname;
  bool used;
  bool isbuy;
  int price;
}info;

void solve(vector<info> & in,vector<Com> C,vector<Dea> D);

template<class T>
int getname(string a,map<string,int> & M,vector<T> &b,T in){
  int index = M.size();
  if (M.find(a) == M.end())b.push_back(in),M[a]=index;
  return M[a];
}

main(){
  int n;
  while(cin>>n && n){
    vector<info> in;
    vector<Com> C;
    vector<Dea> D;
    map<string,int> Dname,Cname;
    rep(i,n){
      info tmp;
      Com a=(Com){"",(1<<21),0,0,0};
      Dea b=(Dea){"",0,0};
      string order;
      cin>>tmp.dname>>order>>tmp.cname>>tmp.price;
      if (order == "SELL")tmp.isbuy=false;
      else tmp.isbuy=true;
      tmp.used=false;
      
      a.name=tmp.cname;
      b.name=tmp.dname;
      tmp.cid=getname(tmp.cname,Cname,C,a);
      tmp.did=getname(tmp.dname,Dname,D,b);
      
      in.push_back(tmp);
    }
    
    solve(in,C,D);
  }
}

void solve(vector<info> & in,vector<Com> C,vector<Dea> D){
  rep(i,in.size()){
    int price,index=-1;
    if (in[i].isbuy)price=(1<<21);
    else price = 0;

    if (in[i].used)continue;
    rep(j,i){
      if (in[j].used||in[i].did == in[j].did ||
	  in[i].cid != in[j].cid || in[i].isbuy==in[j].isbuy)continue;
      if (in[i].isbuy){//buy
	if (!(in[j].price<=in[i].price))continue;
	if (in[j].price  < price)price=in[j].price,index=j;
      }else {//sell
	if (!(in[i].price<=in[j].price))continue;
	if (price < in[j].price)price=in[j].price,index=j;
      }
    }

    if (index == -1)continue;

    in[i].used=in[index].used=true;

    info sell = in[i],buy=in[index];
    if (!buy.isbuy)swap(sell,buy);
    int ave = (sell.price+buy.price)/2;
    C[sell.cid].low=min(C[sell.cid].low,ave);
    //C[sell.cid].ave+=sell.price+buy.price;//critical
    C[sell.cid].ave+=ave;//
    C[sell.cid].high=max(C[sell.cid].high,ave);
    C[sell.cid].num++;
    
    D[sell.did].rec+=ave;
    D[buy.did].pay+=ave;
  }


  sort(ALL(C));
  sort(ALL(D));
  rep(i,C.size()){
    if (C[i].ave == 0)continue;
    printf("%s %d %d %d\n",C[i].name.c_str(),C[i].low,
	   C[i].ave/C[i].num,C[i].high);
  }
  puts("--");
  rep(i,D.size()){
    //if (D[i].rec == 0 && D[i].pay == 0)continue;
    printf("%s %d %d\n",D[i].name.c_str(),D[i].pay,D[i].rec);
  }
  puts("----------");
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
int n,m,t,p,ans;
int d[N],first[N],v[N],w[N],_next[N];
struct Node{
    int u,v;
}e[N];
void add(int x,int y)
{
	t++;
	_next[t]=first[x];
	first[x]=t;
	v[t]=y;
}
void dfs(int x,int father)
{
	int i,j;
	for(i=first[x];i;i=_next[i])
	{
		j=v[i];
		if(j==father)
		  continue;
		d[j]=d[x]+1;
		dfs(j,x);
	}
}
int main()
{
	int x,y,z,i,k,u;
	scanf("%d%d",&n,&k);
	m=k/2;
	ans=0x3f3f3f3f;
	for(i=2;i<=n;++i)
	{
		scanf("%d%d",&x,&y);
		e[i].u=x;
		e[i].v=y;
		add(x,y);
		add(y,x);
	}
	if ((k&1)==0){
		int res=0;
		for (int i=1;i<=n;i++){
			res = d[i] = 0;
			dfs(i,i);
            for (int j=1;j<=n;j++) if(d[j]>m) ++res;
            ans = min(ans,res);
		}
	}
	else{
		int res = 0;
       	for (int i=2;i<=n;i++){
            d[e[i].u] = d[e[i].v] = res = 0;
            dfs(e[i].u,e[i].v);
			dfs(e[i].v,e[i].u);
            for (int j=1;j<=n;j++) if(d[j]>m) ++res;
            ans = min(ans,res);
        }
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2304
from operator import itemgetter
n=int(input())
SP=[list(map(str,input().split())) for i in range(n)]
for sp in SP:
  sp[1] = -1*int(sp[1])
SPsort = sorted(SP,key=itemgetter(0,1))
for i in range(n):
  print(SP.index(SPsort[i])+1)

Measured memory_bytes: 9180
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n, k, sum = 0;
	cin >> n >> k;
  rep(i, n) {
    int a;
    cin >> a;
    if (a >= k) sum++;
  }
	cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

data = int(input())
array = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7
counter = 0
for i in range(60):
    tmp = array & 1
    array >>= 1
    x = np.count_nonzero(tmp)
    x *= data - x
    counter = (counter + pow(2, i, mod) * x) % mod
print(counter)

Measured memory_bytes: 49952
#   AtCoder abc076 a
#   ストレッチ課題

#   入力
#   ミス　r, g = map(int, input().split())
r = int(input())
g = int(input())

#   処理
#   G = (R + answer) / 2 -> answer = 2G - R
answer = 2 * g - r

#   出力
print(answer)


Measured memory_bytes: 9064
#include<iostream>
using namespace std;
int main(){
    string s;
    char s1, s2=0;
    int n1=1, n2=1, i;
    cin >> s;
    s1 = s[0];
    for(i=1;i<4;i++){
        if(s[i] == s1) n1++;
        else if(s2 == 0){
            s2 = s[i];
        }
        else if(s[i] == s2) n2++;
    }
    cout << (n1==2 && n2==2 ? "Yes": "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int D[30][30];
int C[500][500];
int c[3][30];
int main(){
	int N,M;
	cin>>N>>M;
	FOR(i,0,M){
		FOR(j,0,M){
			cin>>D[i][j];
		}
	}
	FOR(i,0,N){
		FOR(j,0,N){
			cin>>C[i][j];
			c[(i+j+2)%3][C[i][j]-1]++;
		}
	}
	int ans=INF;
	FOR(i,0,M){
		int a=0;
		FOR(j,0,30){
			a+=D[j][i]*c[0][j];
		}
		FOR(j,0,M){
			if(i==j){
				continue;
			}
			int b=0;
			FOR(k,0,30){
				b+=D[k][j]*c[1][k];
			}
			FOR(k,0,M){
				if(i==k||j==k){
					continue;
				}
				int d=0;
				FOR(l,0,30){
					d+=D[l][k]*c[2][l];
				}
				ans=min(ans,a+b+d);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <random>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define LLREP(i,n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef queue<int> QI;
typedef long long LL;

int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

typedef pair <pair<int, int>, string > ITEM;	// ACeÌd³AACeÌãÉu¯éd³ÌãÀAACe¼

int memo[10][10];		// s: ACe¼ ñ:½iÚ© -1: Ü¾ãÉÏßé©Ç¤©¢èA0:ÏßÈ¢ 1: Ïßé
vector <ITEM> list;
int N;
int minG;
vector <int> minorder;
int total;

int getG (vector <int> order )
{
	int res = 0;

	for (int i = 0; i < order.size(); ++i ){
		res += (i+1)*(list[order[i]].first.first);
	} // end for

	return res;
}

void bt (vector <int> & order, int curr )
{
	if (curr == N ){
		int currG = getG (order );
		if (currG < minG ){
			minorder = order;
			minG = currG;
		} // end if
		return;
	} // end if

	if (order[curr] != -1 && memo[order[curr]][curr] == 0 ){
		return;
	} // end if

	if (order[curr] == -1 ){
		vector <bool> used (N, false );
		for (int i = 0; i < curr; ++i ){
			used[order[i]] = true;
		} // end if

		for (int i = 0; i < N; ++i ){
			if (!used[i] ) {
				order[curr] = i;
				int curr_w = total;
				for (int j = 0; j <= curr; ++j ){
					curr_w -= list[order[j]].first.first;
				} // end for
				if (curr_w <= list[order[curr]].first.second ){
					memo[order[curr]][curr] = 1;
					bt (order, curr + 1 );
				}else{
					memo[order[curr]][curr] = 0;
				}// end if
				order[curr] = -1;
			} // end if
		} // end for
	} // end if

}

void init (int n )
{
	N = n;
	list.clear();
	list.resize(n);
	minorder.clear();
	minorder.resize(n);
	total = 0;
	minG = INT_MAX;
	memset (memo, -1, sizeof(memo) );
}	

int main()
{
//	cut here before submit 
//	freopen ("testcase.lunch", "r", stdin );
	int n;

	while (cin >> n && n ){
		init (n );
		for (int i = 0; i < n; ++i){
			cin >> list[i].second;
			cin >> list[i].first.first;	// w
			cin >> list[i].first.second;	// s
			total += list[i].first.first; 
		} // end for
		vector <int> order(n, -1 );

		bt (order, 0 );

		for (int i = 0; i < n; ++i ){
			cout << list[minorder[i]].second << endl;
		} // end for

	} // end loop
		
	return 0;
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

string res(string s, int shift, bool switched) {
    int n = s.size();
    string t(n,' ');
    DEC(i,n) {
        if (i >= n-shift)
            t[i] = 'A' + (n-i-1)%2;
        else {
            t[i] = s[i+shift];
            if (shift%2)
                t[i] = 'A'+'B'-t[i];
        }
    }
    if (switched)
        t[0] = 'B';
    return t;
}

signed main() {
    int n,k; cin>>n>>k;
    string s; cin>>s;
    int shift=0, step=0;
    bool switched=false;
    for (; shift<n; step++) {
        if (step == k) {
            P(res(s, shift, switched));
            return 0;
        }
        if (!switched && s[shift] == 'A'+(shift%2))
            switched = true;
        else {
            shift++;
            switched = false;
        }
    }
    P(res(s, n, switched ^ (k-step)%2));
}

Measured memory_bytes: 1156
import sys

input = sys.stdin.readline

def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))
    ans = T
    for i in range(1,N):
        if t[-i] - t[-(i+1)] >= T:
            ans += T
        else:
            ans += t[-i] - t[-(i+1)]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 30784
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    //ll a[100005]={0};
    ll n,ans=0;
    map<ll,ll>a;
    cin>>n;

    for(int i=0;i<n;i++)
    {
      ll x;
      cin>>x;
      a[x]++;
    }
    /*for(int i=1;i<100005;i++)
    {
      if(a[i]!=0&&a[i]>i)

      {
        ans+=(a[i]-i);
      }
      else if(a[i]!=0&&a[i]<i)
      {
        ans+=a[i];
      }
    }*/
    for(auto t:a)
    {
      if(t.fi!=t.se)
      {
        if(t.se>t.fi)
        {
          ans+=(t.se-t.fi);
        }
        else
        {
          ans+=t.se;
        }
      }
    }
    cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 6272
import itertools

n,m,q = list(map(int,input().split()))
abcd = [list(map(int,input().split())) for i in range(q)]

ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for i in range(q):
        a,b,c,d = abcd[i]
        if A[b-1] - A[a-1] == c:
            tmp += d
    ans = max(tmp, ans)

print(ans)


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define      fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define      debug       printf("\n<<CameHere>>\n")
#define      mem(x,y)    memset(x, y, sizeof(x))
#define      all(qz)     qz.begin(),qz.end()
#define      rall(qz)    qz.rbegin(),qz.rend()
#define      inf         1000000000000000000
#define      mod         1000000007
#define      Sqr(x)      ((x)*(x))
#define      ll          long long
#define      mk          make_pair
#define      pb          push_back
#define      pi          acos(-1.0)
#define      cos(a)      cos(a*pi/180)
#define      sin(a)      sin(a*pi/180)
#define      tan(a)      tan(a*pi/180)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    fastt

    ll a,b,c;
    cin>>a>>b>>c;
    ll x=a/b;
    if(a%b!=0) x+=1;
    cout<<x*c<<endl;
    return 0;
}
























Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793

/*vector<ll> c;
vector<vector<ll>> s;
vector<ll>last;
vector<ll>t;
vector<bool>did;*/

ll Score(ll d);
ll Score(ll d, vector<vector<ll>> &s, vector<ll> &c, vector<ll> &last, vector<ll> &t, vector<bool> &did) {
    ll S = 0;
    ll C;
    
        S += s.at(d).at(t.at(d));
        did.at(t.at(d)) = 1;
        
        rep(cnt, 0, 26) {
            last.at(cnt)++;
        }
        last.at(t.at(d)) = 0;
        rep(cnt, 0, 26) {
                S -= c.at(cnt) * last.at(cnt);
        }
    
    return S;
}



int main() {
    ll d;
    cin >> d;
    vector<ll> c(26);
    vector2(ll, s, d, 26);
    rep(cnt, 0, 26) {
        cin >> c.at(cnt);
    }
    rep(i,0,d){
        rep(cnt, 0, 26) {
            cin >> s.at(i).at(cnt);
        }
    }
    vector<ll> last(26,0);
    vector<ll> t(d,0);
    vector<bool> did(26);
    rep(cnt, 0, d) {
        cin >> t.at(cnt);
        t.at(cnt)--;
    }
    ll S = 0;
    rep(cnt, 0, d) {
        S += Score(cnt, s, c, last, t, did);
        cout << S << endl;
    }
    return 0;
}

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

using namespace std;

template<int SZ> struct MaxMatch {
  int N, flow = 0, match[SZ], rmatch[SZ];
  bitset<SZ> vis; vector<int> adj[SZ];
  MaxMatch() {
    memset(match,0,sizeof match);
    memset(rmatch,0,sizeof rmatch);
  }
  void connect(int a, int b, bool c = 1) {
    if (c) match[a] = b, rmatch[b] = a;
    else match[a] = rmatch[b] = 0;
  }
  void add(int a, int b) {adj[a].push_back(b);}

  bool dfs(int x) {
    if (!x) return 1;
    if (vis[x]) return 0;
    vis[x] = 1;
    for (auto &t : adj[x]) 
      if (t != match[x] && dfs(rmatch[t])) {
        connect(x,t);
        return 1;
      }
    return 0;
  }
  void init(int _N) { 
    N = _N;
    for (int i = 1; i < N+1; ++i) 
      if (!match[i]) {
        vis.reset(); 
        flow += dfs(i);
      }
  }
};

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

  int n, x, y;
  cin >> n;
  vector<pair<int, int>> red(n), blue(n);
  for (auto &r : red) {
    cin >> x >> y;
    r = {x, y};
  }
  for (auto &b : blue) {
    cin >> x >> y;
    b = {x, y};
  }
  MaxMatch<201> M;
  for (int i = 0; i < n; ++i) 
    for (int j = 0; j < n; ++j) {
      if (red[i].first < blue[j].first && red[i].second < blue[j].second)
        M.add(i+1, j+1);
    }
  M.init(2*n);

  cout << M.flow << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static int A[],B[];
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=Integer.parseInt(in.next());
		A=new int[n];
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			B=A.clone();
			int begin=Integer.parseInt(in.next()),middle=Integer.parseInt(in.next()),end=Integer.parseInt(in.next());
			rotate(begin,middle,end);
			A=B.clone();
		}
		for(int i=0;i<n-1;i++)System.out.print(B[i]+" ");
		System.out.println(B[n-1]);
	}
	
	static void rotate(int begin,int middle,int end) {
		int eb=end-begin,em=end-middle;
		for(int k=0;k<eb;k++) {
			int dist=begin+((k+em)%eb);
			//System.out.println((k+begin)+":"+A[k+begin]+"=>"+dist);
			B[dist]=A[k+begin];
		}
	}

}



Measured memory_bytes: 45380
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll V[3000][3000];
ll dp[3000][3000][4];

void solve()
{
    int R, C, K;
    scanf("%d%d%d", &R, &C, &K);
    int i, j, k;
    for (i = 0; i < K; i++) {
        int r, c, v;
        scanf("%d%d%d", &r, &c, &v); r--; c--;
        V[r][c] = v;
    }

    for (i = 0; i < R; i++) {
        for (j = 0; j < C; j++) {
            for (k = 0; k < 4; k++) {
                if (i == 0 && j == 0) {
                    if(k==0) dp[i][j][0] = 0;
                    else if (k==1 && V[i][j]) {
                        dp[i][j][1] = V[i][j];
                    }
                }
                else {
                    if (i > 0 && k==0) {
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][0]);
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][1]);
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][2]);
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][3]);
                    }
                    if (i > 0 && k==1 && V[i][j]) {
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][0]+V[i][j]);
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][1]+V[i][j]);
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][2]+V[i][j]);
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i-1][j][3]+V[i][j]);
                    }
                    if (j > 0) {
                        dp[i][j][k] = MAX(dp[i][j][k], dp[i][j-1][k]);
                        if (k > 0 && V[i][j]) {
                            dp[i][j][k] = MAX(dp[i][j][k], dp[i][j-1][k-1]+V[i][j]);
                        }
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (k = 0; k < 4; k++) {
        ans=MAX(ans,dp[R - 1][C - 1][k]);
    }
    printf("%lld\n", ans);
    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 353184
fun main(args: Array<String>) {
    var n = readLine()!!
    if (n.toCharArray().drop(1).all { it == '9' }) {
        println((n.length - 1) * 9L + n.take(1).toLong())
    } else {
        println((n.length - 1) * 9L + n.take(1).toLong() - 1)
    }
}





Measured memory_bytes: 35824
#include <stdio.h>
#define f(a)	a*a
int main(void)
{
	int a,b,c,i=0,count1=0,count2=0;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(f(a)+f(b)==f(c))		count1++;
		else if(c>=a && c>=b)	count2++;
	}
	printf("%d\n%d\n",count1,count2);
	
	return 0;
}

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

typedef long long ll;
//typedef ll int;
ll mod = 1000000007;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    for(int i=max(-1000000, x-k+1); i<=min(1000000, x+k-1); i++){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
using namespace std;
// using ll = long long;

signed main() {
    IO;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int ans = 0;
	int pt = 0, lf = 1;
	for(int i = 1; i < n; ++i) {
		if(lf > 0) {
			--lf;
		}
		else {
			++pt;
			lf = 1;
		}
		ans += a[pt];
		// DB(pt);
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> ds(N);
    for (int i = 0; i < N; ++i) {
        cin >> ds[i];
    }
    int s = 0;
    for (int a = 0; a < N; ++a) {
        for (int b = a+1; b < N; ++b) {
            s += ds[a] * ds[b];
        }
    }
    cout << s << '\n';
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

R, G, B, N = [int(x) for x in input().split()]

counter = 0
for r in range(N//R + 1):
    for g in range((N-R*r)//G + 1):
        if (N-R*r-G*g)%B == 0: counter += 1

print(counter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c=0,d=0;
  cin>>a>>b;
  if(a==2){
    c=1;
  }
  if(b==2){
    d=1;
  }
  if(a==4||a==6||a==9||a==12){
    c=2;
  }
  if(b==4||b==6||b==9||b==12){
    d=2;
  }
  if(c==d){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  } 
 cout<<"\n";
}


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

int top, S[1000];

int pop()
{
	top--;
	return S[top + 1];
}

void push(int x)
{
	S[++top] = x;
}

int main()
{
	int a, b;
	top = 0;
	char s[100];
	while(scanf("%s", s) != EOF)
	{
		if(s[0] == '+')
		{
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b);
		}
		else
		{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>

#define max(a, b) ((a) > (b))? (a):(b)

using namespace std;

int main() {
    string A, B, C; cin >> A >> B >> C;
    if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


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

int main(){
int K,N,i;
int min1,min2,pre;

cin >> K >> N;
 
vector<int> vec(N);
for(i=0;i<N;i++){
	cin >> vec.at(i);
}
min1 = K;

pre=max((vec.at(1)-vec.at(0)),(K-vec.at(N-1)+vec.at(0)));
min2=K-pre;
min1=min(min1,min2);

for(i=1;i<N-1;i++){
pre=max(vec.at(i+1)-vec.at(i),vec.at(i)-vec.at(i-1));
min2=K-pre;
min1=min(min1,min2);
}

cout << min1 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define mp(x,y)          make_pair(x,y)
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define loop(n,i,a)      for(int i=a;i<n;i++)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        loop(n,i,0){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define pp               pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
//int m=10000009;
//int arr[100000];
#define M                   1000000007
#define mm  998244353  
//set<int> st;
signed main()
{
    fast
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000
using namespace std;
int main() {
	int n;
	while (cin >> n,n) {
		int ans = -INF, cnt = 0;
		rep(i, n) {
			int a;
			cin >> a;
			if (cnt < 0) cnt = a;
			else cnt += a;
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
H,W=map(int,input().split())
while(H>0 and W>0):
    for i in range(H):
        for j in range(W):
            if(i+j==0 or (i+j)%2==0):
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()
    H,W=map(int,input().split())


Measured memory_bytes: 7000
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner cin = new Scanner(System.in)) {
			final int count = cin.nextInt();

			List<Integer> list = new ArrayList<>(count);
			while (cin.hasNext()) {
				list.add(cin.nextInt());
			}

			Collections.sort(list);

			System.out.println(list.get(count - 1) - list.get(0));
		} finally {
		}
	}

}


Measured memory_bytes: 20820
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    boolean[] b=new boolean[8];
    int r=0;
    for(int i=0;i<n;i++){
      int a=sc.nextInt();
      if(a>=3200){
        r++;
      }else{
        b[a/400]=true;
      }
    }
    int y=0;
    for(int i=0;i<8;i++){
      if(b[i]){
        y++;
      }
    }
    if(r==0){
      System.out.print(y+" ");
    }else{
      System.out.print(Math.max(y,1)+" ");
    }
    System.out.println(y+r);
  }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((a * b) & 1)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string str;
  cin >> str;
  int q,i;
  cin >> q;
  string s1,s2;
  int a,b;
  for(i=0;i<q;i++){
    //cout << str << endl;
    cin >> s1 >> a >> b;
    if(s1=="print"){
      cout << str.substr(a,b-a+1) << endl;
    }else if(s1=="reverse"){
      string s3=str.substr(a,b-a+1);
      reverse(s3.begin(),s3.end());
      str=str.substr(0,a)+s3+str.substr(b+1,str.size()-a-1);
    }else{
      cin >> s2;
      str=str.substr(0,a)+s2+str.substr(b+1,str.size()-a-1);
    }
  }
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    int ans[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)ans[i][j]=0;
    }
    for(int i=0;i<3;i++)ans[0][i]=arr[0][i];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k)continue;
                ans[i][j]=max(ans[i][j],ans[i-1][k]+arr[i][j]);
            }
        }
    }
    int final=0;
    for(int i=0;i<3;i++)final=max(final,ans[n-1][i]);
    cout<<final;
    return 0;
}

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

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

    int yen, ans = 2000000000;
    int maxAB = max(x, y) * 2;

    for (int i = 0; i <= maxAB; i++) {
        yen = max(0, x - i / 2) * a + max(0, y - i / 2) * b + i * c;
        ans = min(ans, yen);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;
const LL mod = 1000000007;

int main(){
    int n,t;
    cin >> n >> t;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    LL ans = 1;
    rep1(i, n){
        LL tmp = lower_bound(all(d), d[i]-t)-d.begin();
        (ans *= i-tmp+1) %= mod;
    }
    cout << ans << endl;

}




Measured memory_bytes: 3160
// ABC058 B - ∵∴∵
#include <stdio.h>

int main(void) {
    char O[51];
    char E[51];
    scanf("%s", O);
    scanf("%s", E);

    int i = 0;
    while (E[i] != '\0') {
        printf("%c", O[i]);
        printf("%c", E[i]);
        i++;
    }
    if (O[i] != '\0') {
        printf("%c", O[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for(int i =0; flag; i++){
        flag = 0;
        for(int j = N -1; j >=i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int A[100], N, sw;
    cin>>N;
    for(int i = 0; i< N; i++) cin >> A[i];
    sw = bubbleSort(A, N);
    for(int i = 0; i < N; i++){
        if(i) cout <<" ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}

Measured memory_bytes: 3068
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<int, int>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 3e5 + 10, mlg = 20, mod = 1e9 + 7;
int n, k;
vi t;
ll check(ll x) {
	ll ans = 0;
	for(auto i : t)
		ans += (i-x)*(i-x);
	return ans;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	t.resize(n);
	for(auto &i : t) cin >> i;
	ll ans = 1ll<<55;
	for(int i = 0; i <= 100; i++)
		ans =min(ans, check(i));
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace agc021_a
{
    class program
    {
        static void Main(string[] args)
        {
            ChangeLocalDebugInput();

            string str = Console.ReadLine();
            int ans = 0;
            bool allnine = true;
            if (str.Length == 1)
            {
                ans = int.Parse(str);
            } else
            {
                int head = int.Parse(str.Substring(0, 1));
                string rest = str.Substring(1);
                int rest_num = str.Length - 1;
                for (int i = 0; i < rest.Length; i++)
                {
                    if (rest[i] != '9')
                    {
                        allnine = false;
                    }
                }
                if (allnine)
                {
                    ans = head + rest_num * 9;
                } else
                {
                    ans = head - 1 + rest_num * 9;
                }
            }
            Console.WriteLine(ans);
        }


        [System.Diagnostics.Conditional("LOCAL_DEBUG")]
        static void ChangeLocalDebugInput()
        {
            Console.SetIn(new System.IO.StreamReader("../../stdin.txt"));
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e5 + 10;
int a[N];

bool check(int n, int k, int mx) {
    ll cnt = 0;
    for (int i = 1; i <= n; i++) {
        cnt += (a[i] + mx - 1) / mx - 1;
    }
    return cnt <= k;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int lef = 1, rig = 1000000000;
    while (lef < rig) {
        int mid = (lef + rig) / 2;
        if (check(n, k, mid)) {
            rig = mid;
        }
        else {
            lef = mid + 1;
        }
    }
    cout << lef << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4364
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a1 = sc.nextInt();
      int a2 = sc.nextInt();
      int a3 = sc.nextInt();
      if(a1+a2+a3>=22)System.out.println("bust");
      else System.out.println("win");
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}
class Pair{
    int a,b;

    Pair(int a, int b){
      this.a = a;
      this.b = b;
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
  int l, r, d;
  cin >> l >> r >> d;  

  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++;
  }
  cout << ans << endl;
}


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

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    int N, M;
    cin >> N >> M;
    vector<int> x(M);
    rep(i,0,M) {
        cin >> x[i];
    }
    vector<int> y;

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

    rep(i,0,M-1) {
        y.push_back(x[i+1]-x[i]);
    }

    sort(y.begin(),y.end(),greater<int>());
    int ans = x.back()-x.front();

    rep(i,0,min(N-1,(int)y.size())) {
        ans -= y[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll n;
	cin>>n;
	if(n%2==1)return cout<<0<<endl,0;
	ll p=5,sum=0;
	n/=2;
	while(n>=p){
		sum+=n/p;
		p*=5;
	}cout<<sum<<endl;
}/*『你强归你强，我永不示弱』*/





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P  pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int mod = 998244353;
class mint {
  long long x;
  public:
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const {
    return mint(-x);
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const  mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint& a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res/=a;
  }
 
  friend ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
  }
};
 
struct combination{
  vector<mint> fact,ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1;i <= n;i++) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1;i--) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n,int k){
    if(k < 0 || n < k) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

signed main(){
  int n,m,k;
  cin >> n >> m >> k;
  mint ans;
  combination comb(220202);
  mint key = m-1;
  rep(i,0,k+1){
    mint p = key.pow(n-1-i);
    ans += (mint)m*p*comb(n-1,i);
    // cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6696
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

	std::map<ll,ll> a;
	for(ll i = 0;i < n;++i)
	{
		ll tmp;
		std::cin >> tmp;
		++a[tmp];
	}
	
	if(static_cast<ll>(a.size()) == n) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;

	return 0;
}

Measured memory_bytes: 12800
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(date, LastDay, type, score):
  res = score
  res += s[date-1][type]
  for i in range(26):
    if i == type:
      continue
    res -= (date - LastDay[i]) *c[i]
  return res

def nasu():
  res = []
  for d in range(1,D+1):
    tmp1 = ["", 0]
    tmp2 = ["", 0]
    for i in range(26):
      if tmp1[1] < (d - LastDay[i]) * c[i]:
        tmp1 = [i, (d - LastDay[i]) * c[i]]
      if tmp2[1] < s[d-1][i]:
        tmp2 = [i, s[d-1][i]]
    if tmp1[1] > tmp2[1]:
      res.append(tmp1[0])
    else:
      res.append(tmp2[0])
    LastDay[res[-1]] = d
  return res

D = I()
c = IL()
s = [IL() for i in range(D)]

LastDay = [0]*26
score = 0
ans = nasu()

for i in ans:
  print(i+1)

"""
for d in range(D):
  score = tami(d+1, LastDay, ans[d]-1, score)
  LastDay[ans[d]-1] = d+1
  print(score)
"""

Measured memory_bytes: 79004
import re
a = str(input())
b = re.split('[,. ]',a)
c = len(b)
d = []
for i in range(c):
    e = b[i]
    if len(e) >= 3 and len(e) <= 6:
        d.append(e)
f = ' '.join(d)
print(f)


Measured memory_bytes: 6508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

const ll MOD = 998244353;

int main(){
  
  ll n,k;
  cin >> n >> k;
  vector<pair<int,int>> imos(k);
  rep(i,k){
    int L,R;
    cin >> L >> R;
    imos[i] = make_pair(L,R+1);
  }
  vector<ll> dp(500000,0);
  dp[1] = 1;
  dp[2] = -1;
  rep(i,n+1){
    if(i > 0) dp[i] += dp[i-1];
    dp[i] %= MOD;
    rep(j,k){
      int L = imos[j].first;
      int R = imos[j].second;
      dp[i+L] = (dp[i+L] + dp[i])%MOD;
      dp[i+R] = (dp[i+R] - dp[i] + MOD)%MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 7220
// D - Islands War
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,M; cin>>N>>M;
	vector<pair<int,int>> V;
	while(M--){
		int a,b; cin>>a>>b;
		V.emplace_back(b,a);
	}
	sort(V.begin(), V.end());
	int ans = 0, R = 0;
	for(auto p:V) if(p.second >= R){ R = p.first; ans++; }
	cout<< ans <<endl;
}

Measured memory_bytes: 1400