akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j=0,N,M,K,cnt=0,ans=0,a,b,x;
  cin>>N>>M;
  vector<data> v(N);
  priority_queue<ll> que;
  rep(i,N){
    cin>>a>>b;
    v[i]=data(a,b);
  }
  vsort(v);

  rep(i,M){
    while(j<N&&v[j].first<=i+1){
      que.push(v[j].second);
      j++;
    }
    if(que.size()>0){
      x=que.top();que.pop();
      ans+=x;
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i = a; i < b; ++i)
#define rep_(i,a,b) for (ll i = a; i > b; --i)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 1e5;

ll n, m;
ll a[maxn];
string s;

// #include "debug.h"
void solve() {
	cin >> n >> s;
	int i;
	bool has_a_w = false;
	for (i = 0; i < n - 1; ++i) {
		if (s[i] == 'W' && s[i + 1] == 'R') {
			has_a_w = true;
			break;
		}
	}
	if (!has_a_w) {
		cout << 0;
		return;
	}
	while (i >= 0 && s[i] == 'W') --i;
	++i;
	deque<int> v;
	while (i < n) {
		int j = i;
		while (j < n && s[j] == s[i]) ++j;
		if (j == n && s[i] == 'W') break;
		v.pb(j - i);
		i = j;
	}
	int ans = 0;
	while (v.size()) {
		n = v.size();
		if (v[0] == v[n - 1]) {
			ans += v[0];
			v.pop_front();
			v.pop_back();
			if (!v.size()) continue;
			v.pop_front();
			v.pop_back();
		}
		else if (v[0] < v[n - 1]) {
			ans += v[0];
			v[n-1] -= v[0];
			v.pop_front();
			v.pop_front();
		}
		else {
			ans += v[n - 1];
			v[0] -= v[n - 1];
			v.pop_back();
			v.pop_back();
		}
	}
	cout << ans;
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3912
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    a=[int(input()) for i in 1:5]
    println(maximum(a)-minimum(a)>int(input())?":(":"Yay!")
end
main()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int X[100],Y[100];
int C[100],D[100];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>X[i]>>Y[i];
	FOR(i,M) cin>>C[i]>>D[i];
	FOR(i,N) {
		int id=0;
		FOR(j,M) if(abs(X[i]-C[j])+abs(Y[i]-D[j])<abs(X[i]-C[id])+abs(Y[i]-D[id])) id=j;
		cout<<id+1<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sll(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=============================================================================

vi g[N];
int a[N];

int main() {
    int n;
    cin>>n;
    cout<<(2*n)*PI;

    return 0;
}






/*int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}*/


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int cnt=0;
  for(int a=0;a<=A;a++){
    for(int b=0;b<=B;b++){
      for(int c=0;c<=C;c++){
        if(500*a+100*b+50*c==X){cnt++;}
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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

//#include <atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;

map<ll, int> mg;

// map<ll, int> prime_fact(ll n) {
void prime_fact(ll n) {
  // map<ll, int> m;
  for (ll p = 2; p * p <= n; p++) {
    if (n % p) continue;  // 素因数でない
    int num = 0;
    while (!(n % p)) {  // 素因数で何回割れるかを計算する
      num++;
      n /= p;
    }
    // m[p] = num;
    mg[p] += num;
  }
  if (n > 1) {  // n自身が素因数
    // m[n] = 1;
    mg[n] += 1;
  }

  // return m;
}

int main() {
  ll n;
  cin >> n;
  for (int l = 1; l <= n; l++) {
    prime_fact((ll)l);
  }

  ll ans = 1;
  for (auto mm : mg) {
    ans *= (mm.second + 1L);
    ans %= 1000000007;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
const int N=110,mod=1e9+7;
int n,x,a[N*5],f[N][N][N*5];
void add(int &x,int y)
{
    x=(x+y)%mod;
    if(x<0) x+=mod;
}
main()
{
    //freopen("EE.inp","r",stdin);
    n=in,x=in;
    forinc(i,1,n) a[i]=in;
    sort(a+1,a+1+n,greater<int>());
    f[0][0][0]=1;
    forinc(i,0,n-1)
    {
        int m=min(i,x/a[i+1]);
        forinc(j,0,m) forinc(k,0,x) if(f[i][j][k])
        {
            if(k+a[i+1]<=x) add(f[i+1][j+1][k+a[i+1]],f[i][j][k]*(j+1));
            add(f[i+1][j][k],f[i][j][k]*(k-j*(a[i+1]-1)));
            forinc(_k,1,a[i+1]-1) if(k+_k<=x) add(f[i+1][j][k+_k],f[i][j][k]*2*j);
            if(j>=1) forinc(_k,0,a[i+1]-2) if(k+_k<=x) add(f[i+1][j-1][k+_k],f[i][j][k]*(a[i+1]-1-_k)%mod*(j-1));
        }
    }
    int ans=0;
    forinc(i,0,min(n,x/a[n])) ans=(ans+f[n][i][x])%mod;
    cout<<ans<<"\n";
}


Measured memory_bytes: 47360
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
//#define double long double
using namespace std; const int N=2000010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int a[6];
signed main()
{
    for(ri int i=1;i<=5;i++) a[i]=read();
    for(ri int i=1;i<=5;i++) if(!a[i]) { printf("%lld\n",i); break; }
    return 0;
}

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

void call(int n) {
  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      while (true) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
        if (!x) break;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  call(n);
  cout << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    cout<<"2018/01/"<<s[8]<<s[9]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Including Policy Based DS
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI (2.0*acos(0.0))

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

//typedef tree<
//int,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)

// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=1000000007LL;
LL modMul(LL a, LL b){

    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
	if(b%2==1)x = (x%mod*a%mod)%mod;
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 100095;
//-------------------------------------------------------------------------------

LL dp[mx];
LL h[mx];

int main(){
//  READ;
//  WRITE;
//	BOOST;

    LL t,l,x,k,n,m;

    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];

    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

    for(int i=3;i<=n;i++)
		dp[i] = min( dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]) );

	cout<<dp[n]<<endl;




    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
	   public static void main(String args[] ) {
		     Scanner sc = new Scanner(System.in);

		     int n = sc.nextInt();
			 for (int i = 1 ; i <= n; i++ ){
				 int x = i;
				        if(x % 3 == 0){
				            System.out.print(" "+i);
				        } else {
				        for(x = i ; x != 0;x /= 10){
				        	if(x % 10 == 3){
				        	System.out.print(" "+i);
				        	break;
				        	}
				        }
				        }
			 }
		System.out.println("");
		}
}



Measured memory_bytes: 28536
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  int max_L = 0, min_R = 100001;
  for(int i = 0;i < M;i++){
    int L, R;
    cin >> L >> R;
    
    max_L = max(max_L, L);
    min_R = min(min_R, R);
  }
  
  cout << max(0, min_R - max_L + 1) << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
// #include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int popCnt(int x) { return __builtin_popcount(x); }
int f(int x) {
  if (x == 0) return 0;
  return f(x % popCnt(x)) + 1;
}

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  vector<int> x(n);
  rep(i, n) x[i] = s[i] - '0';
  int pc = 0;
  rep(i, n) pc += x[i];
  vector<int> ans(n);
  rep(b, 2) {
    int npc = pc;
    if (b == 0) {
      npc++;
    } else {
      npc--;
    }
    if (npc <= 0) continue;
    int r = 0;
    rep(i, n) {
      r = (r * 2) % npc;
      r += x[i];
    }
    int k = 1;
    for (int i = n - 1; i >= 0; i--) {
      if (x[i] == b) {
        int nr;
        if (b == 0) {
          nr = (r + k) % npc;
        } else {
          nr = (r - k + npc) % npc;
        }
        ans[i] = f(nr) + 1;
      }
      k = (k * 2) % npc;
    }
  }
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 5180
using System;
using System.Linq;

namespace B___ATCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int[] count = new int[S.Length + 1];

            count[0] = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T')
                    count[i + 1] = ++count[i];
                else
                    count[i + 1] = 0;
            }

            Console.WriteLine(count.Max());
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    // まずAとBをmin(X, Y)枚を用意
    int min_XY = (X < Y) ? X : Y;
    // この時AとBを1枚ずつ買うか，ABを買うかを選択
    int result = 0;
    if (A+B < C*2) {
        result += min_XY * (A + B);
    } else {
        result += min_XY * C * 2;
    }

    // 残りのAまたはBを購入
    if (X < Y) {
        // B
        int need = Y - X;
        if (B < C*2) {
            result += need * B;
        } else {
            result += need * C*2;
        }
    } else {
        // A
        int need = X - Y;
        if (A < C*2) {
            result += need * A;
        } else {
            result += need * C*2;
        }
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
int main(void)
{
	int num[10000],tmp,i;
	for(i=0;;i++){
		scanf("%d",&num[i]);
		if(num[i]==0){
			tmp=i;
			break;
		}
	}
	for(i=0;i<tmp;i++){
		printf("Case %d: %d\n",i+1,num[i] );
	}
	return 0;
	
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

C = input()

print(ascii_lowercase[ascii_lowercase.index(C)+1])


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

int n;
int m;
int t;
int ans;
int as[114514];

int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i=0; i<n; i++) {
    scanf("%d", &as[i]);
  }

  ans += as[0]-m;
  for (int i=0; i<n-1; i++) {
    ans += max(0, as[i+1] - as[i] - m*2);
  }
  ans += max(0, t-as[n-1]-m);

  printf("%d\n", ans);
}

Measured memory_bytes: 3208
# ABC128 - B - Guidebook

N = int(input())
List = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    S,P=input().split()
    List[i][0] = i+1
    List[i][1] = S
    List[i][2] = int(P)
    
List.sort(key=lambda x:x[2], reverse=True)  # 点数について降順
List.sort(key=lambda x:x[1])  # 市名について昇順

for i in range(N):
    print(List[i][0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int n, k, tmp, hssize;
  long count = 0;
  scanf("%d %d", &n, &k);
  vector<int> hs;
  rep(i, n) {
    scanf("%d", &tmp);
    hs.push_back(tmp);
  }
  sort(hs.begin(), hs.end(), greater<int>());
  hssize = hs.size();
  if (hssize <= k) {
    printf("0\n");
  }
  else {
    for (int i = k; i < hssize; i++)  count += hs[i];
    printf("%ld\n", count);
  }
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long a, b, c, k;
  	cin >> a >> b >> c >> k;
  	long long res = min (k, a);
  	k -= min (k, a);
  	k -= min (k, b);
  	k = max (k, 0ll);
  	cout << res - min (k, c);
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=5005;
int dp[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),mod=read();
	dp[n]=1;
	int t=(n-1)/2;
	For(i,1,(n+1)/2){
		Rep(j,n-i,1)dp[j]=(dp[j]+dp[j+i])%mod;
	}
	For(i,1,n/2){
		Rep(j,n-i,1)dp[j]=(dp[j]+dp[j+i])%mod;
	}
	ll ans=0;
	For(i,1,n)ans+=dp[i];
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 3580
N = int()
M = int()

N,M=(int(x) for x in input().split())

lis = []
for a in  range(M):
    lis.append(0)

for i in range(N):
    answer = [int(x) for x in input().split()]
    for x in range(1,answer[0]+1):
        lis[answer[x]-1] += 1

print(lis.count(N))


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

using namespace std;

int n, m;
int graph[20][20];
int dist[20][20];

int compute () {
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			dist[i][j] = graph[i][j];

	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (dist[i][k] + dist[k][j] < dist[i][j])
					dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
}

int main() {
	scanf ("%d %d", &n, &m);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++)
			scanf("%d", &graph[i][j]);
	}
	compute ();
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int x;
			scanf ("%d", &x);
			if (x != -1)
				sum += dist[x][1]; 
		}
	}
	printf("%d\n", sum);
	return 0;
} 

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

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

    bool ok = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ok = false;
    }

    if (ok)
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 3624
n,m=map(int,input().split())
left=[]
right=[]
nums=[]

for  i  in  range(m):
    nums.append([int(s)  for  s  in  input().split()])
for  j  in  range(m):
    left.append(nums[j][0])
    right.append(nums[j][1])
if  min(right)-max(left)>=0:
    print(min(right)-max(left)+1)
else:
    print(0)

Measured memory_bytes: 22836
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp;
use std::num::Wrapping; // overflowを回避
use std::f64::consts;


fn main() {
    let s: String = read();
    let b = Bit::new(s);
    b.exec();
}


// Bit全探索
struct Bit {
    num: String,
}

impl Bit {
    fn new(num: String) -> Bit {
        Bit {
            num: num,
        }
    }

    fn exec(&self) {
        let vec: Vec<char> = self.num.chars().collect();
        let intNum = self.num.parse::<i64>().unwrap();
        let mut sum: i64 = 0;


        for bit in 0..(1 << (vec.len()-1)) {
            let mut str: String = String::from("");

            for i in 0..vec.len() {
                if (1&bit>>i) == 1 {
                    str = format!("{}{}+", str, vec[i as usize]);
                } else if i == vec.len()-1{
                    str = format!("{}{}", str, vec[i as usize]);
                } else {
                    str = format!("{}{}-", str, vec[i as usize]);
                }
            }

            let mut each_sum: i32 = 0;
            let mut op = '*';
            for c in str.chars() {
                if c == '-' {
                    op = '-';
                } else if c == '+' {
                    op = '+';
                } else {
                    match op {
                        '-' => each_sum -= c.to_string().parse::<i32>().unwrap(),
                        '+' => each_sum += c.to_string().parse::<i32>().unwrap(),
                        '*' => each_sum = c.to_string().parse::<i32>().unwrap(),
                        _ => each_sum = each_sum
                    }
                }
            }

            if each_sum == 7 {
                println!("{}=7", str);
                return;
            }
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int idx = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a == 1){
            idx = i;
            break;
        }
    }
    cout << (n + k - 3) / (k - 1) << '\n';
    return 0;
    int l = idx, r = n - idx - 1;
    if(l && k - 1 - l > 0){
        r -= k - 1 - l;
    }else if(r && k - 1 - r > 0){
        l -= k - 1 - r;
    }
    prints(l, r);
    cout << (l + k - 2) / (k - 1) + (r + k - 2) / (k - 1) << '\n';
    // vector<int> as(n); cin >> as;
    // int mi = *min_element(as.begin(), as.end());
    // int l, r;
    // for(int i = 0; i < n; i++){ if(as[i] == mi){ l = i; break; } }
    // for(int i = 0; i < n; i++){ if(as[i] == mi){ r = i; } }
    // int idx = r, ans = 0;
    // while(idx < n){
    //     while(idx < n && as[idx] == mi){ idx++; }
    //     if(idx >= n){ break; }
    //     ans++;
    //     idx += k - 1;
    // }
    // idx = r;
    // while(idx >= 0){
    //     while(idx >= 0 && as[idx] == mi){ idx--; }
    //     if(idx < 0){ break; }
    //     ans++;
    //     idx -= k - 1;
    // }
    // cout << ans << '\n';
}


Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun, 19th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

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

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n,m;
	cin >> n >> m;
	if(n == m) ret("Yes")
	ret("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

#define int long long
#define deb(x) cerr << #x << " " << x << endl;
#define debb(x, y) cerr << #x << " = " << x << "," << #y << " = " << y << endl <<endl;
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const long double Pie = acos(-1);

signed main() 
{		
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	char ch;
	cin >> ch;
	
	if (ch >= 'A' and ch <= 'Z')
		cout << 'A';
	else
		cout << 'a';
		
	return 0;
}


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

int main(){
    int N; cin >> N;
    vector<pair<int,int>> v;
    for (int i = 1; i < N+1; i++)
    {
        int a; cin >> a;
        v.push_back(make_pair(a, i));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < N; i++)
    {   
        if(i!=N-1)
            cout << v[i].second << " ";
        else
            cout << v[i].second << endl;
    }
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;
    using ll = long long;
    using P = pair<int,int>; // 1 つの証言を表す構造体 // 「人」と「0 or 1」
    using Graph = vector<vector<int>>;
    
    int main() {
    string s;
    cin >> s;
    
    int ans = 0;
    int count = 0;

    
    rep(i,s.size()){
    	if(s[i] == 'A' ||s[i] == 'C' ||s[i] == 'G' ||s[i] == 'T') count++;
    	else count = 0;
    	
    	ans = max(count,ans);
    }
    
    cout << ans << endl;
     return 0;
    }
    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

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

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

    string s[N];
    for(int i = 0; i < N; i++)cin >> s[i];

    int countA = 0;
    int countB = 0;
    int pair = 0;

    int count = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < s[i].size(); j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B'){
                count++;
            }
        }
        if(s[i][s[i].size() - 1] == 'A')countA++;
        if(s[i][0] == 'B')countB++;
        if(s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A'){
            pair++;
            countB--;
            countA--;
        }
    }
    if(pair > 0){
        count += pair - 1;
        countA++;
        countB++;
    }
    if(countA < countB)count += countA;
    else count += countB;

    if(pair > 0 && countA == 1 && countB == 1)count--;
    cout << count;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<(a+b)%24<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=int(input())
def fun(b,n):
    if n<b:
        return n
    else:
        return fun(b,n//b)+n%b
if n<s:
    print(-1)
elif n==s:
    print(n+1)
else:
    for b in range(2,int(n**0.5)+1):
        if fun(b,n)==s:
            print(b)
            exit()
    yaku=set()
    for x in range(1,int((n-s)**0.5)+1):
        if (n-s)%x==0:
            yaku|={x,(n-s)//x}
    ans=n+2
    for k in yaku:
        b=(n-s)//k+1
        l=s-k
        if 0<=l<b and n<b**2 and k+l==s:
            ans=min(ans,b)
    if ans>n:
        print(-1)
    else:
        print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int w,h,x,y,r;

int main(){
	cin.sync_with_stdio(false);
	cin>>w>>h>>x>>y>>r;
	if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    string s;
    cin>>s;
    for(char c:s)if(c==',') cout<<" "; else cout<<c;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int a,b,k;
vector<int>vec;
int main() {
	cin>>a>>b>>k;
	for(int i=1;i<=min(a,b);++i)
		if(a%i==0&&b%i==0)
			vec.push_back(i);
	sort(vec.begin(),vec.end(),greater<int>());
	cout<<vec[k-1]<<endl;
}

Measured memory_bytes: 256
def f(x,y):
    if x==1:
        return(y)
    if x%2==0:
        return(f(x/2,y+1))
    else:
        return(f(3*x+1,y+1))

while True:
    x=int(input().strip())
    if x==0:
        break
    print(f(x,0))


Measured memory_bytes: 5612
#include <iostream>
using namespace std;
int p[11],c[11];
int d,g;
int mn = 1000000000;
int dfs(int n,int np,int nw,int ko){
  if(d+1 == n){
    //cout << n << " " << np << " " << nw << " " << ko << endl;
    if(nw >= g){
      mn = min(mn,ko);
    }else{
      if(p[np]*np+nw >= g){
        int tmp = ((g-nw)%np == 0 ? (g-nw)/np :(g-nw)/np+1);
        mn = min(mn,ko+tmp);
      }
    }
    return mn;
  }
  return min(mn,min(dfs(n+1,np,nw+p[n]*n+c[n],ko+p[n]),dfs(n+1,n,nw,ko)));

}
int main(){
  cin>>d>>g;g/=100;
  for(int i = 1; d >= i; i++){
    cin>>p[i]>>c[i];
    c[i] /= 100;
  }
  cout << dfs(1,0,0,0) << endl;//今の状態,解いてないもので一番高い点数,今の点数

}

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

int main() {
  string S, T;
  int count = 0;
  cin >> S >> T;
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == T.at(i)) count++;
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int idxA=0, idxZ=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      idxA=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      idxZ=i;
      break;
    }
  }

  cout << idxZ-idxA+1 << endl;
  }


Measured memory_bytes: 640
import sys
import socket

hostname = socket.gethostname()

if hostname in ['F451C', 'N551J']:
    sys.stdin = open('e1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()

def solve(N, K):
  s = list(reversed(str(N)))
  a = [i for i in range(len(s)) if s[i] != '0']
  c = [int(s[i]) for i in range(len(s)) if s[i] != '0']

  # print(a)
  # print(c)
  res = 0
  if K == 1:
    for p in range(100):
      if p == a[-1]:
        res += c[-1]
      if p < a[-1]:
        res += 9

  if K == 2:
    for p in range(100):
      for q in range(p):
        if p < a[-1]:
          res += 9 * 9
        if p == a[-1]:
          if len(a) >= 2:
            if q < a[-2]:
              res += c[-1] * 9
            if q == a[-2]:
              res += (c[-1] - 1) * 9 + c[-2]
            if q > a[-2]:
              res += (c[-1] - 1) * 9
          if len(a) == 1:
            res += (c[-1] - 1) * 9

  if K == 3:
    for p in range(100):
      for q in range(p):
        for r in range(q):
          if p < a[-1]:
            res += 9 * 9 * 9
          if p == a[-1]:
            if len(a) >= 3:
              if q < a[-2]:
                res += c[-1] * 9 * 9
              if q == a[-2]:
                if r < a[-3]:
                  res += (c[-1] - 1) * 9 * 9
                  res += 1 * (c[-2] - 1) * 9
                  res += 1 * 1 * 9
                if r == a[-3]:
                  res += (c[-1] - 1) * 9 * 9
                  res += 1 * (c[-2] - 1) * 9
                  res += 1* 1 * c[-3]
                if r > a[-3]:
                  res += (c[-1] - 1) * 9 * 9
                  res += 1 * (c[-2] - 1) * 9
                  
              if q > a[-2]:
                res += (c[-1] - 1) * 9 * 9
            if len(a) == 2:
              if q < a[-2]:
                res += c[-1] * 9 * 9
              if q == a[-2]:
                res += (c[-1] - 1) * 9 * 9
                res += 1 * (c[-2] - 1) * 9
              if q > a[-2]:
                res += (c[-1] - 1) * 9 * 9
            if len(a) == 1:
              res += (c[-1] - 1) * 9 * 9


  return res


def solve_correct_but_slow(N, K):
  res = 0
  for i in range(1, N+1):
    s = str(i)
    nonzero = len(s) - s.count('0')
    if nonzero == K:
      res += 1
  return res


def find_mismatch():
  N = 1
  while True:
    for K in range(1, 4):
      expected = solve_correct_but_slow(N, K)
      output = solve(N, K)


      if output == expected:
        # print('   N, K, expected, output:', end=' ')
        # print(N, K, expected, output)
        continue

      print()
      print('N, K, expected, output:', end=' ')
      print(N, K, expected, output)
      return
    N += 1




def main():
    N = read_int()
    K = read_int()
    res = solve(N, K)
    print(res)

# find_mismatch()
main()


Measured memory_bytes: 3760
nums = sorted(list(map(int, input().split())))
ans = 0
while nums[0] != nums[-1]:
  if nums[-1] - nums[0] >= 2:
    nums[0] += 2
    nums = sorted(nums)
    ans += 1
  else:
    nums[0] += 1
    nums[1] += 1
    nums = sorted(nums)
    ans += 1
print(ans)

Measured memory_bytes: 3060
N, M, R = gets.split.map(&:to_i)
r = gets.split.map(&:to_i).map{ |i| i-=1 }

d = Array.new(N){ Array.new(N,10**9) }

M.times do
  a, b, c = gets.split.map(&:to_i)
  a-=1
  b-=1
  d[a][b] = c
  d[b][a] = c
end

(0...N).each{ |i| d[i][i] = 0 }

N.times do |k|
  N.times do |i|
    N.times do |j|
      v = d[i][k]+d[k][j]
      d[i][j] = v if d[i][j] > v
    end
  end
end

p = r.permutation(R).to_a
ans = 10**9

p.each do |k|
  dist = 0
  (1...R).each do |i|
    dist += d[k[i]][k[i-1]]
  end
  ans = dist if ans > dist
end

p ans

Measured memory_bytes: 8572
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var x = int.Parse(line[1]);
        var m = int.Parse(line[2]);
        getAns(n, x, m);
    }
    static void getAns(long n, int x, int m)
    {
        var a = new long[m];
        var b = new long[m];
        a[0] = x;
        b[0] = x;
        var d = new Dictionary<long, int>();
        d[x] = 0;
        var p = 1;
        while (p < m)
        {
            var w = (a[p - 1] * a[p - 1]) % m;
            a[p] = w;
            b[p] = b[p - 1] + w;
            if (!d.ContainsKey(w)) d[w] = p;
            else
            {
                var dw = d[w];
                if (dw != 0)
                {
                    var loopc = p - dw;
                    var loopv = b[p - 1] - b[dw - 1];
                    var toloopv = b[dw - 1];
                    var time = (n - dw) / loopc;
                    var toend = (n - dw) % loopc;
                    var toendv = b[dw + toend - 1] - b[dw - 1];
                    var ans = toloopv + time * loopv + toendv;
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    var loopc = p;
                    var loopv = b[p - 1];
                    var toloopv = 0;
                    var time = n / loopc;
                    var toend = n % loopc;
                    var toendv = toend == 0 ? 0 : b[toend - 1];
                    var ans = toloopv + time * loopv + toendv;
                    Console.WriteLine(ans);
                    return;
                }
            }
            p++;
        }
        Console.WriteLine(b[m - 1]);
    }
}


Measured memory_bytes: 31856
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[2010101], rui[2010101];
int main()
{
	ll num;
	scanf("%lld", &num);
	dp[0] = rui[0] = 1;
	ll ans = 0;
	for (int i = 0; i <= num; i++)
	{
		if (i <= num - 2)ans = (ans + dp[i] * (num - 1) % mod*(num - 1) + dp[i] * (i + 1)) % mod;
		else if (i == num - 1)ans = (ans + dp[i] * (num - 1)) % mod;
		else ans = (ans + dp[i]) % mod;
		dp[i + 1] = ((i >= 2) ? (rui[i - 2] + dp[i]) % mod : dp[i]);
		rui[i + 1] = (rui[i] + dp[i + 1]) % mod;
		//printf("%d %lld %lld\n", i, dp[i], ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int inf=1e18;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int x,p=100,c=0;
    cin >> x;
    while(p<x){
    	p+=p/100;
    	c++;
    }
    cout << c;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <limits>
using namespace std;

int s[500000];
int c = 0;
void merge(int left , int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;

	int *l = new int[n1 + 1];
	int *r = new int[n2 + 1];

	for (int i = 0; i < n1; i++)
	{
		l[i] = s[left + i];
	}

	for (int i = 0; i < n2; i++)
	{
		r[i] = s[mid + i];
	}

	l[n1] = numeric_limits<int>::max();
	r[n2] = numeric_limits<int>::max();

	int i = 0;
	int j = 0;

	for (int k = left; k < right; k++)
	{
		if (l[i] <= r[j])
		{
			s[k] = l[i];
			i++;
		}
		else
		{
			s[k] = r[j];
			j++;
		}
		c++;
	}
	delete[] l;
	delete[] r;

}

void mergeSort(int left,int right)
{
	int mid;

	if (left + 1 < right)
	{
		mid = (left + right) / 2;
		mergeSort(left,mid);
		mergeSort(mid,right);
		merge(left, mid, right);
	}
}
void B()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}


	mergeSort(0,n);
	for (int i = 0; i < n; i++)
	{
		cout << s[i];
		if (i != n - 1)
		{
			cout << " ";
		}
	}

	cout << endl;
	cout << c << endl;
}
int main()
{
	//A();
	B();
	return 0;
}

Measured memory_bytes: 5052
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	void Solve() {
		UL N, K, C; cin >> N >> K >> C;
		string S; cin >> S;
		vector<UL> J(K);
		vector<UL> L(K);
		UL i = 0;
		rep(k, K) {
			while (S[i] == 'x') i++;
			J[k] = i;
			i += C + 1;
		}
		reverse(S.begin(), S.end());
		i = 0;
		rep(k, K) {
			while (S[i] == 'x') i++;
			L[k] = N - i - 1;
			i += C + 1;
		}
		reverse(L.begin(), L.end());
		rep(k, K) {
			if (J[k] == L[k]) cout << (J[k] + 1) << endl;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3332
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())

for i in range(k,n):
    if t[i] == t[i-k]:
        t[i] = "0"

ans = [0] * n

for i in range(n):
    if t[i] == "r":
        ans[i] = p
    elif t[i] == "s":
        ans[i] = r
    elif t[i] == "p":
        ans[i] = s

print(sum(ans))


Measured memory_bytes: 10516
#include<stdio.h>
#include <string.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int N, D1, D2;
    int count = 0;
    int ans = 0;


    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> D1 >> D2;
        if (D1 == D2)
            count++;
        else
            count = 0;
        if (count == 3) {
            ans = 1;
            break;
        }
    }

    if (ans == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>
int prime(int);

int main(){

  int n,p,i,j,count=0;

  scanf("%d",&j);
  
  for(i = 1; i <= j; i++)
    {
      scanf("%d",&n);
      p = prime(n);
      if(p == 1){
        count++;
      }
    }
  printf("%d\n",count);
  return 0;
}

int prime(int n)
{
  int i;

  if(n < 2)return 0;
  else if(n == 2)return 1;

  if(n % 2 == 0)return 0;

  for(i = 3; i <= n/i; i += 2){
    if(n % i == 0)return 0;
  }
  return 1;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int M=1010;
char a[M],b[M];
int n,m,ans=M+10;

int main()
{
	
	scanf("%s",a+1);n=strlen(a+1);
	scanf("%s",b+1);m=strlen(b+1);
	for(int i=1;i+m-1<=n;i++)
	{
		int sum=0;
		for(int j=1;j<=m;j++)
			if(a[i+j-1]!=b[j])
				sum++;
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	
	return 0;
	
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     int n,m,i,j,mask,a,b,c;
     cin>>n>>m;
	 vector<vector<int>>dp(2,vector<int>(1<<n,-1));
	 dp[1][0]=0;
	 for(i=0;i<m;i++)
	 {
		 cin>>a>>b;
		 mask=0;
		 for(j=0;j<b;j++)
		 {
			 cin>>c;
			 mask|=1<<(c-1);
		 }
		 dp[i&1]=dp[(i&1)^1];
		 for(j=0;j<(1<<n);j++)
			 if((dp[(i&1)^1][j]!=-1) && (dp[i&1][j|mask]==-1 || dp[i&1][j|mask]>dp[(i&1)^1][j]+a))dp[i&1][j|mask]=dp[(i&1)^1][j]+a;
	 }
	 cout<<dp[(i&1)^1][(1<<n)-1]<<'\n';
}


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

int main()
{
    char s[200010];
    long long result = 0, b = 0, w = 0;

    scanf("%s", s);
    int i;

    for(i = strlen(s) - 1; i >= 0; i--) {
        if(s[i] != s[i + 1] && s[i] == 'W') {
            result += w * b;
            b = 0;
        } if(s[i] == 'W'){
            w++;
        } else if(s[i] == 'B') {
            b++;
        } if (i == 0) {
            result += w * b;
            b = 0;
        }
    }
    printf("%lld", result);
}


Measured memory_bytes: 384