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

const int INF = 10000000;

int h, w;
int d[23][23][23][23];

void WarshallFloyd(){
    for(int k = 0; k < h * w; k++){
        for(int i = 0; i < h * w; i++){
            for(int j = 0; j < h * w; j++){
                d[i / w][i % w][j / w][j % w] = 
                    min(d[i / w][i % w][j / w][j % w], d[i / w][i % w][k / w][k % w] + d[k / w][k % w][j / w][j % w]);
            }
        }
    }
}

int main()
{
    cin >> h >> w;
    char s[23][23];
    for(int i = 0; i < h * w; i++) for(int j = 0; j < h * w; j++){
        if(i == j) continue;
        d[i / w][i % w][j / w][j % w] = INF;
    }
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> s[i][j];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w - 1; j++) if(s[i][j] == '.' && s[i][j + 1] == '.'){
            d[i][j][i][j + 1] = 1;
            d[i][j + 1][i][j] = 1;
        }
    }
    for(int j = 0; j < w; j++){
        for(int i = 0; i < h - 1; i++) if(s[i][j] == '.' && s[i + 1][j] == '.'){
            d[i][j][i + 1][j] = 1;
            d[i + 1][j][i][j] = 1;
        }
    }
    WarshallFloyd();
    int l = 0;
    for(int i = 0; i < h * w; i++){
        for(int j = 0; j < h * w; j++){
            if(s[i / w][i % w] != '.' || s[j / w][j % w] != '.') continue;
            l = max(l, d[i / w][i % w][j / w][j % w]);
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(int argc,const char * argv[])
{
    int W,H,x,y,r;
    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if (x+r>W || y+r>H || r>x || r>y) {
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


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

#define mi map<int, int>
#define pii pair<int, int>
#define mpi map<pii, int>
#define vi vector<int>
#define vpi vector<pii>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
#define fo(i, k, n) for (int i = k; i < n; i++)
#define fod(i, k, n) for (int i = k; i >= n; i--)
#define sz(x) (int)x.size()

#define PI 3.141592653

typedef long long ll;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vpl;
typedef pair<ll, ll> pll;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll stamina[n], ans = INT_MAX, total = 0;
    for (int i = 0; i < n; i++)
        cin >> stamina[i];
    for (int i = 0; i <= 100; i++)
    {
        total = 0;
        for (int j = 0; j < n; j++)
        {
            total += abs((stamina[j] - i) * (stamina[j] - i));
        }
        ans = min(ans, total);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;


signed main(){
    
    ll a,b,c;
    cin >> a >> b >> c;
    ll roopcnt = 1,memo = 0;

    while(roopcnt <= 1e6 && memo % b != c){
        memo = a*roopcnt++;
    }
    if(memo % b == c) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}
// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
   ll n,m,k;
   cin>>n>>m>>k;
   ll ans = (k/n);

   cout<<ans*m<<"\n";

}

// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
      //  compte++;
    //}
    return 0;
}


Measured memory_bytes: 3632
/* D-"Median of Medians" */
/*  */
//include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++) 
using namespace std;

int main(){
    ll h,w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1;
    } else{
        cout << (h * w + 1) /2;
    }
    return 0;
}
    

Measured memory_bytes: 256
li=[]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
n=int(input())
for num in range(n):
  j=int(input())
  li.append(j)
bingo=0
yoko1=(a in li) and (b in li) and (c in li)
yoko2=(d in li) and (e in li) and (f in li)
yoko3=(g in li) and (h in li) and (i in li)
yoko=yoko1 or yoko2 or yoko3
tate1=(a in li) and (d in li) and (g in li)
tate2=(b in li) and (e in li) and (h in li)
tate3=(c in li) and (f in li) and (i in li)
tate=tate1 or tate2 or tate3
nana1=(a in li) and (e in li) and (i in li)
nana2=(c in li) and (e in li) and (g in li)
nana=nana1 or nana2
if yoko or tate or nana:
    bingo=1
print("Yes" if bingo==1 else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int rank_judge(int A){
	int res = -1;
	for(int i = 0; i < 8; i++){
		if(400 * i <= A && A < 400 * (i + 1)){
			res = i;
			break;
		}
	}
	return res;
}

//color max = 8
int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A.at(i);
	vector<bool> exist(8, false);
	int tourist = 0;
	int color = 0;
	
	rep(i, N){
		int X = rank_judge(A.at(i));
		if(X == -1){
			tourist++;
		} else {
			if(exist.at(X)){
				continue;
			} else {
				exist.at(X) = true;
				color++;
			}
		}
	}
	
	int ans0 = max(1, color);
	int ans1 = color + tourist;
	
	cout << ans0 << " " << ans1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
	int m,i;
	string u,v,w,x,y;
	set<string>s;
	cin>>m;
	while(m--)
	{
		s.clear();
		cin>>u;
		for(i=1;i<u.size();++i)
		{
			v.assign(u.begin(),u.begin()+i);
			w.assign(u.begin()+i,u.end());
			x=v,reverse(x.begin(),x.end());
			y=w,reverse(y.begin(),y.end());
			s.insert(v+w);
			s.insert(w+v);
			s.insert(x+w);
			s.insert(w+x);
			s.insert(v+y);
			s.insert(y+v);
			s.insert(x+y);
			s.insert(y+x);
		}
		cout<<s.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
const int MX=100000000;
const double Pi=2*asin(1);
 
int segmax(int *seg,int i,int j,int k,int a,int b)
{
  int ret=0;
  if(a<=j&&k<=b){
    ret=seg[i];
  }
  else if(!(k<=a||b<=j)){
    ret=max(segmax(seg,2*i,j,(j+k)/2,a,b),segmax(seg,2*i+1,(j+k)/2,k,a,b));
  }
  return ret;
}
 
void segset(int *seg,int i,int v)
{
  int p=i+(1<<18);
  seg[p]=v;
  while(p>1){
    p/=2;
    seg[p]=max(seg[2*p],seg[2*p+1]);
  }
}
 
int main()
{
  int x1,y1,x2,y2;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  int n;
  scanf("%d",&n);
  static int X[200000],Y[200000];
  for(int i=0;i<n;i++){
    scanf("%d%d",X+i,Y+i);
  }
  if(x1>x2){
    swap(x1,x2);
    swap(y1,y2);
  }
  if(y1>y2){
    y1=MX-y1;
    y2=MX-y2;
    for(int i=0;i<n;i++){
      Y[i]=MX-Y[i];
    }
  }
  static pair<int,int> P[200000];
  int N=0;
  for(int i=0;i<n;i++){
    if(x1<=X[i]&&X[i]<=x2&&y1<=Y[i]&&Y[i]<=y2){
      P[N]=make_pair(X[i],Y[i]);
      N++;
    }
  }
  sort(P,P+N);
  static int YY[200000];
  for(int i=0;i<N;i++){
    YY[i]=P[i].second;
  }
  sort(YY,YY+N);
  int ans=0;
  static int seg[1<<19]={0};
  for(int i=0;i<N;i++){
    int k=lower_bound(YY,YY+N,P[i].second)-YY;
    int m=segmax(seg,1,0,1<<18,0,k);
    //printf("%d %d %d %d\n",P[i].first,P[i].second,k,m);
    ans=max(ans,m+1);
    segset(seg,k,m+1);
  }
  //printf("%d\n",ans);
  double p=0;
  if(ans==(x2-x1+1)||ans==(y2-y1+1)){
    ans--;
    p=10.*Pi-20;
  }
  printf("%.15lf\n",100.*(y2-y1+x2-x1)-(20.-10.*Pi/2)*ans+p);
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N,T;
	cin>>N>>T;
	
	vector<pair<int,int>> P(N);
	
	for(int i=0;i<N;i++){
		cin>>P[i].first>>P[i].second;
	}
	
	vector<vector<int>> dp1(N+1,vector<int>(T,0));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<T;j++){
			if(j!=T-1)dp1[i][j+1] = max(dp1[i][j+1],dp1[i][j]);
			dp1[i+1][j] = max(dp1[i+1][j],dp1[i][j]);
			int k = j + P[i].first;
			if(k<T){
				dp1[i+1][k] = max(dp1[i+1][k],dp1[i][j] + P[i].second);
			}
		}
	}
	
	reverse(P.begin(),P.end());
	
	vector<vector<int>> dp2(N+1,vector<int>(T,0));
	for(int i=0;i<N;i++){
		for(int j=0;j<T;j++){
			if(j!=T-1)dp2[i][j+1] = max(dp2[i][j+1],dp2[i][j]);
			dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j]);
			int k = j + P[i].first;
			if(k<T){
				dp2[i+1][k] = max(dp2[i+1][k],dp2[i][j] + P[i].second);
			}
		}
	}
	
	reverse(P.begin(),P.end());
	
	int ans = 0;
	T--;
	
	for(int i=0;i<N;i++){
		int maxi = 0;
		for(int j=0;j<=T;j++){
			int a = dp1[i][j] + dp2[N-1-i][T-j];
			maxi = max(a,maxi);
		}
		ans = max(ans,maxi + P[i].second);
	}
	/*
	for(int i=0;i<=N;i++){
		for(int j=0;j<=T;j++){
			cout<<dp1[i][j]<<',';
		}
		cout<<endl;
	}*/
	
	
	cout<<ans<<endl;
	
    return 0;
}


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


int main (){
    int a, b, c;
    string s, t;
    cin>>a>>b>>c;
    vector<int> Win(c);
    for(int i = 0; i<c; i++){
        cin>>Win.at(i);
    }
    vector<int> Point(a, b-c);
    for(int i=0; i<c; i++){
        Point.at(Win.at(i)-1) ++;
    }
    for(int i=0; i<a; i++){
        cout<<(Point.at(i)>0?"Yes":"No")<<endl;
    }
    
}

Measured memory_bytes: 1408
s=input()
t=input()
ans=10**10
for i in range(len(s)-len(t)+1):
    ss=s[i:i+len(t)]
    m=0
    for j in range(len(t)):
        if ss[j]!=t[j]:
            m+=1
    ans=min(ans,m)
print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <string>

class Baseball{
    u_int runner, out, point;
    
public:
    Baseball();
    ~Baseball(){}
        
    u_int get_runner() const {return runner;}
    u_int get_out() const {return out;}
    u_int get_point() const {return point;}
    void set_runner(const u_int r) {runner = r;}
    void set_out(const u_int o) {out = o;}
    void set_point(const u_int p) {point = p;}
    
    void event_hit();
    void event_homerun();
    void event_out();
    
private:
    void inc_runner() {++runner;}
    void inc_out() {++out;}
    void add_point(const u_int p) {point += p;}
};

Baseball::Baseball()
{
    runner = 0;
    out = 0;
    point = 0;
}

void Baseball::event_hit()
{
    if(get_runner() == 3){
        add_point(1);
    }
    else{
        inc_runner();
    }   
}

void Baseball::event_homerun()
{
    add_point(1 + get_runner());
    set_runner(0);
}

void Baseball::event_out()
{
    inc_out();
}

int main()
{
    u_int inning;
    std::cin >> inning;
    
    std::string event;
    for(u_int i = 0; i < inning; ++i){
        Baseball b_ball;
        while(b_ball.get_out() != 3){
            std::cin >> event;
            if(event == "HIT"){
                b_ball.event_hit();
            }
            else if(event == "HOMERUN"){
                b_ball.event_homerun();
            }
            else{
                b_ball.event_out();
            }
        }
        std::cout << b_ball.get_point() << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 110;
int n, k, a[maxn];
bool dp[100010];
int main()
{
    read(n), read(k);
    rep(i, 1, n) read(a[i]);
    sort(a + 1, a + 1 + n);
    rep(i, 0, a[1] - 1) dp[i] = 1;
    rep(i, a[1], k) {
        int tmp = 1;
        rep(j, 1, n)
            if(i - a[j] >= 0 && dp[i - a[j]] == 1) {
                tmp = 0;
                break;
            }
        dp[i] = tmp;
    }
    if(dp[k] == 1) puts("Second");
        else puts("First");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
const int mod = 1e9 + 7;
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
ll n,w[111],v[111],dp[105][100010],W;
int main(){
    ios::sync_with_stdio(0);
    cin >> n >> W;
    for(int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 0;i<105;i++)
        for(int j = 1;j<=100001;j++)dp[i][j] = 1e18;
    for(int j = n;j>=1;j--){
        for(int i=1e5;i>=0;i--){
            dp[j][i] = dp[j+1][i];
            if(i - v[j] >= 0)dp[j][i] = min(dp[j][i] , dp[j+1][i-v[j]] + w[j]);
        }
    }
    for(int i = 1e5;i >= 0;i--)if(dp[1][i] <= W){
        return cout << i << endl,0;
    }
    return 0;
}


Measured memory_bytes: 82304
Q, H, S, D = map(int, input().split()) # 0.25 0.5 1 2
N = int(input())

one_l = min([4 * Q, 2 * Q + H, H * 2, S])
two_l = min([one_l * 2, D])

if N % 2 == 0:
    print(two_l * (N // 2))
else:
    print(two_l * (N // 2) + one_l)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){

int n,i,ai,max,min;


double sum;


sum=0.0;


max=-1000000;


min=1000000;


scanf("%d",&n);


for(i=0;i<n;i++){


scanf("%d",&ai);


if(ai<min){


min=ai;


}


if(max<ai){


max=ai;


}


sum=sum+ai;


}


printf("%d %d %.0lf\n",min,max,sum);


return 0;


}

Measured memory_bytes: 632
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int count = 1;
		int max = h[0];
		for (int i = 1; i < n; i++) {
			if (h[i] >= max) {
				max = h[i];
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

    if(s == u){
        cout << a-1 << " " << b << endl;
    }

    else{
        cout << a << " " << b-1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n[10],max = 0,maxpoint;
  for(int i = 0; i < 10; i++)scanf("%d",&n[i]);

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 10; j++){
      if(max < n[j]){
        max = n[j];
        maxpoint = j;
      }
    }
    printf("%d\n",n[maxpoint]);
    max = 0;
    n[maxpoint] = 0;
  }
  return 0;
}


Measured memory_bytes: 2056
#include<stdio.h>

int main(void)
{
	int i,p[30],s;
	
	for(i=0;i<=29;i++)
	{
		p[i]=0;
	}
	for(i=1;i<=28;i++)
	{
		scanf("%d",&s);
		p[s-1]=1;
	}
	for(i=0;i<=29;i++)
	{
		if(p[i]==0)
		{
			printf("%d\n",i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 2147483647;
long long int MOD = 1000000007;
using namespace std;

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

#define MAX_N 200000

using namespace std;

int const TREE_SIZE = 1 << 20;
long long int seg_tree[TREE_SIZE];

void change(int a, long long int w){
	
	// a番目の要素をwに変更する O(log N)
	
	a += TREE_SIZE / 2;
	
	seg_tree[a] += w;
	
	for(int x = a / 2; x > 0; x /= 2){
		seg_tree[x] = seg_tree[2 * x] + seg_tree[2 * x + 1];
	}
}

long long int query(int a, int b, int index, int l, int r){
	
	// 区間 [a, b) の要素の最小値を返す O(log N)
	// 外からは query(a, b, 1, 0, TREE_SIZE / 2) のように呼ぶ
	
	if(r <= a || b <= l){
		return 0;
	}
	if(a <= l && r <= b){
		return seg_tree[index];
	}
	
	return query(a, b, index * 2, l, (l + r) / 2) + query(a, b, index * 2 + 1, (l + r) / 2, r);
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	for(int i = 0; i < TREE_SIZE; i++){
		seg_tree[i] = 0;
	}
	
	for(int i = 0; i < q; i++){
		long long int num, a, b, c;
		cin >> num;
		if(num == 0){
			cin >> a >> b >> c;
			change(a, c);
			change(b + 1, -c);
		}else{
			cin >> a;
			cout << query(0, a + 1, 1, 0, TREE_SIZE / 2) << endl;
		}
		/*
		for(int j = 0; j <= n; j++){
			cout << query(0, j + 1, 1, 0, TREE_SIZE / 2) << " ";
		}
		cout << endl;
		*/
	}
	
	return 0;
}


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

int main(){
    int k;
    cin>>k;
    queue<ll> q;
    for(int i=1;i<10;i++){
        q.push(i);
    }
    ll x;
    while(k--){
        x =q.front();
        q.pop();
        if (x%10!=0){
            q.push(x*10+x%10-1);
        }
        q.push(x*10+x%10);
        if( x%10!=9){
        q.push(x*10+x%10+1);
        }

    }
  cout << x;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define llinf ((long long)1e18)
#define inf int(1e9+1e6)
#define maxn (1000006)
ll n,psum[maxn];
string A;
int main(){
	FAST
	cin>>A;
	n=A.size();
	A='*'+A;
	FOR(i,1,n){
		psum[i]=psum[i-1]+(A[i] == '1' ? 1 : -1);
	}
	ll Z = *max_element(psum, psum+n+1);
	auto f=[&](ll x){
		mmst(psum,0);
		FOR(i,1,n){
			psum[i]=psum[i-1]+(A[i] == '1' ? 1 : -1);
		}
		vector<ll> suf_max(n+2, -llinf);
		DEC(i,n,1)suf_max[i]=max(suf_max[i+1], psum[i]);
		ll change=0;
		FOR(i,1,n){
			if(A[i] == '?'){
				if(suf_max[i] + 2 * (change+1) <= x) ++ change;
			}
			psum[i] += 2 * change;
		}
		return *min_element(psum, psum+n+1);
	};
	cout<<min(Z - f(Z), Z+1 - f(Z+1))<<'\n';
}


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

const int maxn = 1e5 + 5;
int b[maxn], l[maxn], u[maxn];

int main() {
    int n, x; scanf("%d%d", &n, &x);
    for (int i = 0; i < n; ++i) scanf("%d%d%d", &b[i], &l[i], &u[i]);

    vector<int> v(n);
    iota(v.begin(), v.end(), 0);
    sort(v.begin(), v.end(), [&](int i, int j) {
        return u[i] * 1ll * (x - b[i]) + l[i] * 1ll * b[i] > 
               u[j] * 1ll * (x - b[j]) + l[j] * 1ll * b[j];
    });

    long long sum = 0;
    for (int i = 0; i < n; ++i) sum += l[i] * 1ll * -b[i];
    int z = -1;
    for (int i = 0; i <= n; ++i) {
        if (sum >= 0) {
            z = i;
            break;
        }
        if (i < n) {
            sum += l[v[i]] * 1ll * b[v[i]];
            sum += u[v[i]] * 1ll * (x - b[v[i]]);
        }
    }

    assert(z != -1);
    if (z == 0) {
        puts("0");
        return 0;
    }

    --z;
    sum = 0;
    long long tans = x * 1ll * z;
    for (int i = 0; i < z; ++i) sum += u[v[i]] * 1ll * (x - b[v[i]]);

    long long tsum = 0;
    for (int i = z; i < n; ++i) tsum -= l[v[i]] * 1ll * b[v[i]];

    long long ans = 1e18;
    for (int i = z; i < n; ++i) {
        tsum += l[v[i]] * 1ll * b[v[i]];     
        int p = x + 1;
        for (int d = 20; d >= 0; --d) {
            if (p - (1 << d) >= 0) {
                int q = p - (1 << d);
                long long add = max(u[v[i]] * 1ll * (q - b[v[i]]),
                                    l[v[i]] * 1ll * (q - b[v[i]]));

                if (tsum + add + sum >= 0) p -= (1 << d);
            }
        }
        if (p <= x) 
            ans = min(ans, tans + p);
        tsum -= l[v[i]] * 1ll * b[v[i]];     
    }

    sum += tsum;

    for (int i = 0; i < z; ++i) {
        sum -= u[v[i]] * 1ll * (x - b[v[i]]);
        sum += l[v[z]] * 1ll * b[v[z]];
        sum += u[v[z]] * 1ll * (x - b[v[z]]);

        int p = x + 1;
        for (int d = 20; d >= 0; --d) {
            if (p - (1 << d) >= 0) {
                int q = p - (1 << d);
                long long add = max(u[v[i]] * 1ll * (q - b[v[i]]),
                                    l[v[i]] * 1ll * (q - b[v[i]]));
                if (sum + add >= 0) p -= (1 << d);
            }
        }
        if (p <= x)
            ans = min(ans, tans + p);

        sum -= u[v[z]] * 1ll * (x - b[v[z]]);
        sum -= l[v[z]] * 1ll * b[v[z]];
        sum += u[v[i]] * 1ll * (x - b[v[i]]);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
78786    print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(dead_code)]
fn vector_accumulation(vec: &Vec<i64>) -> Vec<i64> {
    let mut res = Vec::new();
    let size = vec.len();
    res.push(0);
    for i in 0..size {
        res.push(vec[i]);
    }
    for i in 0..size {
        res[i + 1] += res[i];
    }
    res
}
#[allow(dead_code)]
pub fn gcd(mut a: i64, mut b: i64) -> i64 {
    if (a < b) {
        let t = a;
        a = b;
        b = t;
    }
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve() {
    let (n, k) = readuu();
    let vec: Vec<i64> = read_vec();
    let mut g = 0;
    for i in 0..n {
        g = gcd(g, vec[i]);
        // println!("{:?}", g);
    }
    let mut flg = false;
    for i in 0..n {
        if (vec[i] - k as i64) >= 0 {
            if (vec[i] - k as i64) % g == 0 {
                flg = true;
            }
        }
    }
    // print!("{}", g);
    if flg {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 4188
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;


#define ll long long


long long A[100005] = {};


/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e, H, W;
long long B[2][100005] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;
vector <pl>vpl;

struct ST
{
	long long group;
	long long rank;
	long long tugi=-1;
	int siro;
};

vector <ST> vst;
double fl, fll;


int main() {

	cin >>N>>M;
	c = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		vl.push_back(A[i]);
		c += A[i];
	}

	sort(vl.begin(), vl.end());
	reverse(vl.begin(), vl.end());

	for (int i = 0; i < M; i++) {
		cin >> B[0][i]>>B[1][i];
		buf.first = B[1][i];
		buf.second = B[0][i];
		vpl.push_back(buf);
	}
	a = 0;
	sort(vpl.begin(), vpl.end());
	reverse(vpl.begin(), vpl.end());

	for (int i = 0; i < vpl.size(); i++) {
		for (int j = 0; j < vpl[i].second; j++) {
			if (vl[vl.size() - 1] < vpl[i].first) {
				c += vpl[i].first - vl[vl.size() - 1];
				vl.pop_back();
				if (vl.size() == 0) {
					a = 1;
					break;
				}

			}
			else {
				a = 1;
				break;
			}

		}
		if (a == 1) {
			break;
		}
	}

	cout << c << endl;

	return 0;

}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
int y,m,d;
char s='/';
int main()
{
	cin>>y>>s>>m>>s>>d;
	if(y<=2019 && m<=4)
		cout<<"Heisei\n";
	else
		cout<<"TBD\n";
	return 0;
}

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse = True)
    ret = 0
    for i in range(1,N):
        ret += A[i//2]
    print(ret)

if __name__ == '__main__':
    main()

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

long long mod = 1000000007;
long long power(long long x, long long y)
{
    long long ret = 1;
    while(y > 0)
    {
        if (y & 1)
        {
            ret = (ret * x) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return ret;
}

int main(void)
{
    long long N;
    cin >> N;

    vector<long long> vec(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> vec[i];
    } 

    long long ans = 0;
    long long pw = 0;
    while(1)
    {
        for (long long i = 0; i < N; i++)
        {
            if (vec[i] != 0)
            {
                break;
            }
            if (i == N - 1)
            {
                cout << ans << endl;
                exit(0);
            }
        }

        long long cnt = 0;
        for (long long i = 0; i < N; i++)
        {
            if (vec[i] & 1)
            {
                cnt ++;
            }
        }
        ans += (((cnt * (N - cnt)) % mod) * power(2, pw)) % mod;
        ans = ans % mod;
        pw ++;
        for (long long i = 0; i < N; i++)
        {
            vec[i] >>= 1;
        }
    }
}

Measured memory_bytes: 2560
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
void solve() {
    long long a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
}

int main() {
    init();
    solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for (auto &Ai : A) {
    cin >> Ai;
  }
  int total = 0;
  for (auto Ai : A) {
    total += Ai;
  }
  if (total >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>

typedef long long i64;

using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    int ans;
    if(N == 0){
        ans = M;
        if(M == 100){
            ans = 101;
        }
    }
    else if(N == 1){
        ans = 100*M;
        if(M == 100){
            ans = 10100;
        }
    }
    else{
        ans = 100*100*M;
        if(M == 100){
            ans = 1010000;
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static int solve(char[][] map){
		int count = 1;
		int max = 0;
		for(int i = 1; i < map.length-max; i++){
			for(int j = 1; j < map.length-max; j++){
				if( map[i][j] == '.' ){
					int k = 1;
					for(int l = 0; l < count; l++){
						while( map[i+l][j+k+l] == '.' && map[i+k+l][j+l] == '.' ){
							k++;
						}
						if( l == 0 ){
							count = k+l;
						} else if( count > k+l ){
							count = k+l;
						}
						
						if( k == 0 ){
							break;
						}
						k = 0;
					}
					if( count > max ){
						max = count;						
					}
					count = 1;
				}
				
			}
		}
		return max;
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int n;
		while( (n = stdIn.nextInt()) != 0 ){
			String[] s = new String[n];
			stdIn.nextLine();
			for(int i = 0; i < n; i++){
				s[i] = stdIn.nextLine();
			}
			char[][] map = new char[n+2][n+2];
			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){
					map[i][j] = s[i-1].charAt(j-1);
				}
			}
			System.out.println(solve(map));
		}
	}
}

Measured memory_bytes: 14000
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string n; cin >> n;
  long ans = 0;
  for ( int i = 0; i < 4; ++i )
    if ( n[i] == '2' ) ++ans;
  cout << ans << endl;
  return ( 0 );
}

Measured memory_bytes: 3176
#include<iostream>
using namespace std;
int main(){
int n,a,b,c,d,x,y;
cin>>n>>a>>b>>c>>d;
x=a/c;
if(a%c!=0)x++;
y=b/d;
if(b%d!=0)y++;
if(x>y)cout<<n-x<<endl;
else{
cout<<n-y<<endl;
}
}

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

using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    
    long long int w[N+1], v[N+1];
    w[0]=0;
    v[0]=0;
    vector<vector<long long int> > dp(N+1, vector<long long int>(W+1, 0));
    for(int i=1; i<=N; i++) {
        cin >> w[i] >> v[i];
    }
    
    for(int cur_w=1; cur_w<=W; cur_w++) {
        for(int i=1; i<=N; i++) {
            if(cur_w-w[i]>=0) {
                dp[i][cur_w] = max(dp[i-1][cur_w], dp[i-1][cur_w-w[i]]+v[i]);
            } else {
                dp[i][cur_w] = dp[i-1][cur_w];
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
    
}

Measured memory_bytes: 80256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];



unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい

int main()
{
	cin >> a >> b >> c ;

	for (int i = 1; i <= a; i++) {
		d = i;
		while (d) {
			counter = d % 10;
			ans += counter;
			d = d / 10;
		}
		if (b <= ans && ans <= c) {
			x += i;	
		}
		ans = 0;
	}
	cout << x << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{   int n,a,b,c,d;
    cin>>n>>a>>b;
    c=abs(a-n);
    d=abs(b-n);
    if(c>d)cout<<"B"<<endl;
    else cout<<"A"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll zer = 0;


int main(){
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  ll z = 0, o = 0;
  rep(i, n){
    cin >> a[i];
    a[i] %= 2;
    if(a[i] % 2 == 0)z++;
    else o++;
  }
  if(p == 1 && o == 0){
    cout << 0 << endl;
    return 0;
  }
  ll res = 1;
  while(z > 0){
    res *= 2;
    z--;
  }
  o--;
  while(o > 0){
    res *= 2;
    o--;
  }
  cout << res << endl;
}




Measured memory_bytes: 3604
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    l = il()
    print('Yes' if len(set(l)) == 1 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long long x,y,n,m;
int main()
{
	cin>>n;
	m=n*800;
	m-=200*(n/15);
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
let get_2_ints () = Scanf.scanf "%d %d" (fun u v -> u,v)

let () =
  let (n,y) = get_2_ints ()
  in let r = ref (-1,-1,-1)
  in
  for i=0 to n do
    for j=0 to n-i do
      let k = n-i-j
      in if i*10000+j*5000+k*1000=y then r:=(i,j,k)
    done
  done;
  !r |> (fun (u,v,w) -> Printf.printf "%d %d %d\n" u v w);


Measured memory_bytes: 2432
import heapq  # 優先度付きキュー
# def solve():  # TLE
#     n, m = map(int, input().split())
#     # O(nlog(n))
#     a = sorted(list(map(int, input().split())))
#     # 最大の値でチケットを使う
#     # まだ最大かどうか考慮Y：もう一度使うN:バイナリーサーチをかけてリストをソートする
#     # O(m)
#     for i in range(m):
#         a[len(a)-1] //= 2
#         if a[len(a)-1] < a[len(a)-2]:
#             # O(log2m)
#             a = binary_search(a, a[len(a)-1])
#     return sum(a)


def solve():
    n, m = map(int, input().split())
    a = list(map(lambda x: int(x)*-1, input().split()))
    heapq.heapify(a)  # aを優先度付きキューに変更
    for _ in range(m):  # _　iで注意が出ない(インスタンスを作らない)
        tmp_min = heapq.heappop(a)  # aの最大の値のpop
        heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差が生じるため(//2の返り値はintのため)
    return -sum(a)


def binary_search(lst, num):
    lst.pop(len(lst)-1)
    left, right = 0, len(lst)-1
    while left <= right:
        mid = (left + right)//2
        if lst[mid] < num:
            left = mid + 1
        else:
            right = mid-1
    lst.insert(mid, num)
    return lst


ans = solve()
print(ans)


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n,a,b;
int ans = 0;
int main() {
    scanf("%d%d%d",&n,&a,&b);
    
    rep(i,1,n+1){
        int c = i;
        int cnt = 0;
        while(c != 0){
            cnt += c%10;
            c /= 10;
        }
        if(a <= cnt && cnt <= b){
            ans += i;
        }
    }
    pout(ans);
    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int dp[100005];
int a[105];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i=0 ; i<n ; i++) {
		scanf("%d", a+i);
	}
	for (int i=0 ; i<=k ; i++) {
		bool ok = false;
		for (int j=0 ; j<n ; j++) {
			if (i-a[j] < 0) continue;
			if (dp[i-a[j]] == 0) ok = true;
		}
		if (ok) dp[i] = 1;
	}
	if (dp[k]) {
		printf("First\n");
	} else {
		printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z  << " " << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int mx = 0;
  int mn = 1000;
  int n;
  cin >> n;
  int a;
  REP(i,n){
      cin >> a;
      mx = max(mx,a);
      mn = min(mn,a);
  }
  cout << mx - mn << endl;
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [N, T] = input[0].split(' ').map(x => parseInt(x))

  let minCost = 99999999
  for (let i = 0; i < N; i++) {
    const [c, t] = input[i + 1].split(' ').map(x => parseInt(x))
    if (t <= T) {
      minCost = Math.min(minCost, c)
    }
  }

  if (minCost !== 99999999) {
    console.log(minCost)
  } else {
    console.log('TLE')
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29684
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;
	long N, M; cin >> N >> M;
	long A[100009]; for (int i = 1; i <= N; i++) cin >> A[i];
    
	A[0] = 0;
	for (int i = 1; i <= N; i++) A[i] = (A[i] + A[i - 1]) % M; //MOD累積和

	sort(A, A + N + 1);
	long mys = 0 , mycount = 1;

	for (int i = 1; i <= N; i++) { //A[i]の等しい二つ組は何通りか
		if (A[i] == mys) mycount++; else { mys = A[i]; res += max((long)0,( mycount * (mycount - 1) / 2)); mycount = 1; }

        if(i == N){ mys = A[i]; res += max((long)0, mycount * (mycount - 1) / 2); mycount = 0; }
	}

	cout << res << endl;

}

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

using namespace std;

int main(){
  int q,a,b;
  string str,order,s;

  cin >> str >> q;
  while(q--){
    cin >> order >> a >> b;
    if(order == "replace"){
      cin >> s;
      str.replace(str.begin()+a, str.begin()+b+1, s);
    }else if(order == "reverse"){
      reverse(str.begin()+a, str.begin()+b+1);
    }else{
      for(int i = a ; i <= b ; i++){
        cout << str[i];
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1216
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/arc102/tasks/arc102_a

//参考：https://drken1215.hatenablog.com/entry/2018/09/02/011000

//ポイント：剰余に注目する
//mod Kにおいて、
//a+b=0 && a+c=0 && b+c=0が成立することを利用する
//1~Nの数をKで割ったあまりがiになる数値の個数をnum[i]とおく

//aをKで割ったあまりをr_aとおくと
//b,cをKで割ったあまりはそれぞれb-r_a,c-r_a
//になっていなければならず、さらに(b-r_a)+(c-r_a)
//がKで割り切れる必要がある
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N,K;
 
LL ans = 0;
 
void solve(){
	// num[x] = kで割ってxあまる数が1以上N以下に何個あるか
	vector<LL> num(K,0);
	for (int i = 1; i <= N; ++i) num[i%K]++; 
    for (int a = 0; a < K; ++a) {
        int b = (K-a) % K;
        int c = (K-a) % K;
        if ((b+c) % K != 0) continue;
        ans += num[a] * num[b] * num[c];
    }
}
 
int main(){
    cin >> N >> K;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
from collections import deque
N = int(input())

x_list=deque()

for i in range(N):
    a = input().split()
    if a[0] == "insert":
        x_list.appendleft(a[1])
    elif a[0] == "delete":
        try:
            x_list.remove(a[1])
        except:
            pass
    elif a[0] == "deleteFirst":
        x_list.popleft()
    else:
        x_list.pop()

print(*x_list)


Measured memory_bytes: 69732
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define setbits __builtin_popcount 
#define big 1e9+7
using namespace std;
ll n,k,m,flag,mod = 1000005,cnt;
int a[1005];
double dp[505][505][505];
string s;
int main()
{
	IOS
	int x = 0,y = 0,z = 0;
	cin>>n;
	for(int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if(a[i] > 0)
		{
			if(a[i] > 1)
			{
				if(a[i] > 2)
					z++;
				else y++;
			}
			else x++;
		}
	}
	dp[0][0][0] = 0;
	for(int i = 0; i <= z; ++i)
	{
		for(int j = 0; j+i <= z+y; ++j)
		{
			for(int k = 0; k+j+i <= n; ++k)
			{
				if(i+j+k > 0)
					dp[i][j][k] = (double)n/(i+j+k);
				if(i)
					dp[i][j][k] += (dp[i-1][j+1][k]*i)/(i+j+k);
				if(j)
					dp[i][j][k] += (dp[i][j-1][k+1]*j)/(i+j+k);
				if(k)
					dp[i][j][k] += (dp[i][j][k-1]*k)/(i+j+k);
			}
		}
	}
	cout<<setprecision(20)<<dp[z][y][x]<<endl;
    return 0;
}

Measured memory_bytes: 597504
def main():
    N, M = (int(i) for i in input().split())

    def prime_factorize(n):
        res = []
        for i in range(2, n+1):
            if i*i > n:
                break
            if n % i != 0:
                continue
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    from math import gcd
    g = gcd(N, M)
    pf = prime_factorize(g)

    ans = 1 + len(pf)

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){

  int N;
    cin>>N;
    map<int,int> A;
    int cnt=0;
    for(int i=0;i<N;i++){
        int k;cin>>k;
        if(A[k-1]==0){
            A[k-1]++;
            cnt++;
        }
        else if(A[k-1]==1){
            A[k-1]--;
            cnt--;
        }
        }
    cout<<cnt<<endl;
    }


Measured memory_bytes: 4864