akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vl x(N), y(M);
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];

  stable_sort(x.begin(), x.end(), greater<ll>());
  stable_sort(y.begin(), y.end());

  if(x[0] > y[0]){
    cout << "War\n";
    return 0;
  }

  rep2(Z, X + 1, Y + 1){
    if((x[0] < Z) && (Z <= y[0])){
      cout << "No War\n";
      return 0;
    }
  }

  cout << "War\n";
  
  return 0;
}


Measured memory_bytes: 3624
n, a, b = [int(x) for x in input().split()]
participants = list(input())
passers = []
bs_rank = 1
#print(participants)

for i in range(len(participants)):
      if participants[i] == "a":          # aについて: 合格者数 < A+Bのとき合格
            if len(passers) < a+b:
                  print("Yes")
                  passers.append(i+1)
            else:
                  print("No")
      
      elif participants[i] == "b":        # bについて: 合格者数 < A+B and bの中での順位 <= B
            if len(passers) < a+b and bs_rank <= b:
                  print("Yes")
                  passers.append(i+1)
                  bs_rank += 1
            else:
                  print("No")
                  
      else: # participants[i] == "c"
            print("No")

Measured memory_bytes: 13460
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<PL> p(n);
    REP(i,n){
        ll x = in(), l = in();
        p[i] = PL(x + l, x - l);
    }
    sort(ALL(p));
    ll x = -1e18;
    int ans = 0;
    REP(i,n){
        if (p[i].second >= x){
            ans++;
            x = p[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
string s=RS(),s2="";
for(int i=0;i<s.size();++i){
  if(i%2==0)
   s2+=s[i];

}
 cout<<s2;
 }




Measured memory_bytes: 592
#include <stdio.h>
#include<math.h>
#include <algorithm>

#define EPS 1e-10

using namespace std;

int func(double x1,double y1,double x2, double y2, double xp, double yp){
	double naiseki,norm1,norm2,gaiseki;
	norm1 = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	norm2 = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
	naiseki = (xp-x1)*(x2-x1)+(yp-y1)*(y2-y1);
	gaiseki = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
	if(gaiseki > EPS){
		return 1;
	}else if(gaiseki < -EPS){
		return -1;
	}

	if(naiseki < -EPS){
		return 2;
	}

	if(norm1 < norm2){
		return -2;
	}
	return 0;
}


int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4;
	int q;
	scanf("%d",&q);

	for(int i=0;i<q;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);

		if(func(x1,y1,x2,y2,x3,y3)*func(x1,y1,x2,y2,x4,y4) <= 0 &&
				func(x3,y3,x4,y4,x1,y1) * func(x3,y3,x4,y4,x2,y2) <= 0){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}

    return 0;
}

Measured memory_bytes: 2684
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,t,l,b;cin>>n>>t>>l>>b,n|t|l|b;){
		vi ls(n+1),bs(n+1);
		rep(i,l){
			int x; cin>>x;
			ls[x]=1;
		}
		rep(i,b){
			int x; cin>>x;
			bs[x]=1;
		}
		
		vvd ps(t+2,vd(n+1)); ps[0][0]=1;
		rep(i,t) rep(j,n) repi(k,1,7){
			int next=j+k;
			if(next>n) next=n-(next-n);
			if(ls[next])      ps[i+2][next]+=ps[i][j]/6;
			else if(bs[next]) ps[i+1][0]+=ps[i][j]/6;
			else              ps[i+1][next]+=ps[i][j]/6;
		}
		
		double res=0;
		rep(i,t+1) res+=ps[i][n];
		printf("%f\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
deque<int> the_net(deque<int> ci)
{
	int pos = ci.size()-1;
	while(pos>=0&&ci[pos] == 9)
	{
		ci[pos] = 0;
		pos--;
	}
	if(pos == -1)
		ci.push_front(1);
	else
		ci[pos]++;
	while(1)
	{
		int tmp = -1;
		for(int i=0;i<ci.size()-1;i++)
		{
			if(abs(ci[i]-ci[i+1])>1)
			{
				tmp = i;
				break;
			}
		}
		if(tmp == -1)
		{
			break;
		}
		if(ci[tmp]<ci[tmp+1])
		{
			ci[tmp]++;
		}
		int x = max(ci[tmp]-1,0);
		for(int i=tmp+1;i<ci.size();i++)
		{
			ci[i] = x;
			x = max(0,x-1);
		}
	} 
	return ci;
}
int main()
{
	int n;
	cin>>n;
	deque<int> ans = {0};
	for(int i=0;i<n;i++)
	{
		ans = the_net(ans);
	}
	for(int i=0;i<ans.size();i++)
	{
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
var
i:longint;
s:string;
b:boolean;
begin
readln(s);
if (s[1]<>'A') or (s[2]='C') or (s[length(s)]='C') then
begin
writeln('WA');
halt;
end;
b:=false;
for i:=2 to length(s) do
 if s[i]='C' then
 begin
  if b then
  begin
  writeln('WA');
  halt;
  end;
 b:=true;
 end
 else
  if s[i] in ['A'..'Z'] then
  begin
  writeln('WA');
  halt;
  end;
if b then
writeln('AC')
else
writeln('WA');
end.


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{  int H,N,counter=0;
    cin>>H>>N;
    int * arr=new int[N];
    for(int i=0;i<N;i++)
        cin>>arr[i];
    for(int i=0;i<N;i++){
        H=H-arr[i];
    }
   if(H==0 || H<0)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int a = scan.nextInt();
      	int b = scan.nextInt();
      	int c = scan.nextInt();
      	int d = scan.nextInt();
      	int e = scan.nextInt();
      	int k = scan.nextInt();
      	if(e - a > k){
        	System.out.print(":(");
        }
      	else{
        	System.out.print("Yay!");
        }
    }

}

Measured memory_bytes: 22996
import java.util.Scanner;

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

	int a = scan.nextInt();
	int b = scan.nextInt();
	int c = scan.nextInt();

	
        if (a <= b && b <= c) {
            System.out.println(a + " " + b + " " + c);
        } else if (a <= c && c <= b) {
            System.out.println(a + " " + c + " " + b);
        } else if (b <= a && a <= c) {
            System.out.println(b + " " + a + " " + c);
        } else if (b <= c && c <= a) {
            System.out.println(b + " " + c + " " + a);
        } else if (c <= a && a <= b) {
            System.out.println(c + " " + a + " " + b);
        } else if (c <= b && b <= a) {
            System.out.println(c + " " + b + " " + a);
        }
	}
}

Measured memory_bytes: 26128
import bisect
s = input()
k = int(input())
n = len(s)
ans = []
for i in range(n):
  for j in range(k):
    l = s[i:(i+j+1)]
    if l in ans:
      continue
    bisect.insort_left(ans,l)
  ans = ans[:k]
print(ans[-1])

Measured memory_bytes: 41196
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long answer = 0;
    while(true)
    {
      bool finish = true;
      for(int i = 0; i < n; i++)
      {
        if(nums[i] >= n)
        {
          finish = false;
          answer += nums[i]/n;
          for(int j = 0; j < n; j++)
          {
            if(j != i) nums[j] += nums[i]/n;
          }
          nums[i] %= n;
        }
      }
      if(finish) break;
    }
    
		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{

	//input
	int n, l;
	cin >> n >> l;


	//calc
	int ans = 0;
	int eat = INT_MAX;
	for (int i = 0; i < n; i++){
		int taste = l + i;
		ans += taste;

		if (abs(taste) < abs(eat)){
			eat = taste;
		}

	}

	ans -= eat;




	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define NUM 55553
//#define MAXL 50

int main(){
    int n;
    cin >> n;
    int ar[NUM + 1] = {};
    for(int i = 2; i < NUM + 1; i++){
        if(ar[i] == 0){
            for(int j = i * i; j < NUM + 1; j += i){
                ar[j] = -1;
            }

            if(i % 5 == 1){
                cout << i;
                n--;
                if(n == 0){
                    break;
                }else{
                    cout << " ";
                }
            }
            //cout << i << endl;
        }
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
typedef long double ld;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int k,n;
int q[100010];
bool f[65][100010];
void bfs(int x){
	int he=0,ta=0;
	FOR(j,0,k-1)
		if (f[x][j]) q[++ta]=j;
	while (he!=ta){
		int t=q[++he];
		if (!f[x][t*10%k]){
			f[x][t*10%k]=1;
			q[++ta]=t*10%k;
		}
	}
}
int main(){
	cin>>k;
	FOR(i,1,9)
		f[i][i%k]=1;
	FOR(i,1,50){
		bfs(i);
		FOR(j,0,k-1){
			if (!f[i][j]) continue;
			FOR(p,0,9)
				f[i+p][(j*10+p)%k]=1;
		}
	}
	FOR(i,1,50)
		if (f[i][0]) return cout<<i<<endl,0;
	return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    ll side[3];
    REP(i, 3) cin >> side[i];
    sort(side, side+3, greater<ll>());

    if(side[0]&1 && side[1]&1 && side[2]&1)
        cout << side[1]*side[2] << endl;
    else
        cout << 0 << endl;


}



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

int main(){
  double a,b,x,ans;
  cin >> a >> b >> x;
  const double PI=3.14159265358979323846;
  if(x>=((pow(a,2)*b)/2)){
    ans=atan((2/pow(a,2)*(a*b-(x/a))));
  }else{
    ans=atan((a*pow(b,2))/(2*x));
  }
  ans*=(180/PI);
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
	return modpow(a, mod - 2, mod);
}
void solve()
{
	COMinit();
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 0;
	ans = modpow(2, n, M)%M - 1;
	ans %= M;
	ll mid = 1;
	FOR(i, 0, a)
	{
		mid *= n - i;
		mid %= M;
		mid *= modinv(i + 1, M);
		mid %= M;
	}
	ans -= mid;
	if (ans < 0)
	{
		ans += M;
	}
	mid = 1;
	FOR(i, 0, b)
	{
		mid *= n - i;
		mid %= M;
		mid *= modinv(i + 1, M);
		mid %= M;
	}
	ans -= mid;
	if (ans < 0)
	{
		ans += M;
	}
	cout << ans % M << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 12160
N = int(input())
words = []

for _ in range(N):
    words.append(input())

if len(words) != len(set(words)):
    print("No")
    exit()

for i in range(N-1):
    if words[i][-1] != words[i+1][0]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define int ll
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 400000+10;
const ll md = (ll) 1e9 + 7;
 
inline ll add(ll a, ll b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
 
inline ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
 
inline ll mul(ll a, ll b) {
  return (ll) ((long long) a * b % md);
}
 
inline ll power(ll a, long long b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline ll inv(ll a) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
int32_t main()
{

   IOS
   int n,k;
   cin>>k;
  n  = 3;
   int ans = 0;
   int f[k+1] = {0};
   for(int  i = k;i>=1;i--){
     f[i] = (power(k/i,n));
     
     for(int j = 2*i;j<=k;j+=i)
      f[i] = sub(f[i],f[j]);
     ans = add(ans,mul(i,f[i]));
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N;
int sx, sy;
typedef long long ll;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll cans,dans,cdans,cd;
    cans = b/c - a/c + (a%c==0);
    dans = b/d - a/d + (a%d==0);
    ll mx= max(c,d);
    ll mn= min(c,d);
    ll amali = 1;
    ll koyaku;
    while(amali){
        amali = mx%mn;
        if(amali ==0) koyaku = mn;
        mx = mn;
        mn = amali;

    }


     cd = c*d/koyaku;
    cdans = b/cd - a/cd +(a%cd==0);
    ll ans;
    ans = 1+b-a-cans-dans+cdans;
     cout << ans << endl;
    // cout << cans << endl;
    // cout << dans << endl;
    // cout << cdans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[1000000], n;


//A[]が昇順にソートされていることを前提とする
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    else if(key > A[mid]) left = mid + 1;
    else right = mid;
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++) {
    scanf("%d", &k);
    if(binarySearch(k)) sum++;
  }
  printf("%d\n", sum);

  return 0;
}



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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int main() {
  int n;
  cin >> n;
  cout << (n == 3 || n == 5 || n == 7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    while (1) {
        int n;
        scanf("%d", &n);
        if (n == 0) {
            break;
        }

        char conv[n][2];
        for (int i = 0; i < n; i++) {
            scanf(" %c %c", &conv[i][0], &conv[i][1]);
        }
        int m;
        scanf("%d", &m);
        while (m--) {
            char c;
            scanf(" %c", &c);
            for (int i = 0; i < n; i++) {
                if (c == conv[i][0]) {
                    printf("%c", conv[i][1]);
                    break;
                }
                if (i == n-1) {
                    printf("%c", c);
                }
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 2568
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

struct edge{
    ll to,rev,dp;
};

vector<vector<edge>> path;
ll mod_;

//辺edge->e : 逆辺edge->path[e.to][e.rev]
void add_edge(ll from,ll to){
    path[from].push_back((edge){to,path[to].size(),0});
    path[to].push_back((edge){from,path[from].size()-1,0});
}

void dfs(ll x,ll per,ll idx){
    rep(i,path[x].size()){
        edge &e=path[x][i];
        if(e.to!=per) dfs(e.to,x,i);
    }
    edge &E=path[per][idx];
    E.dp=1; //変更点
    for(edge &e:path[x]){
        if(e.to==per) continue; 
        E.dp=E.dp*e.dp%mod_; //変更点
    }
    E.dp++;
}

void bfs(ll x){
    queue<pair<ll,ll>> que;
    que.push(mk(x,-1));
    while(!(que.empty())){
        ll cx,par;
        tie(cx,par)=que.front();
        que.pop();
        vector<ll> mul1(path[cx].size(),1); //変更点
        vector<ll> mul2(path[cx].size(),1);
        rep(i,path[cx].size()-1){
            mul1[i+1]=(mul1[i]*path[cx][i].dp)%mod_; //変更点
            mul2[path[cx].size()-i-2]=(mul2[path[cx].size()-i-1]*path[cx][path[cx].size()-i-1].dp)%mod_;
        }
        rep(i,path[cx].size()){
            edge &e=path[cx][i];
            if(e.to==par) continue;
            path[e.to][e.rev].dp=(mul1[i]*mul2[i]+1)%mod_;
            que.push(mk(e.to,cx));
        }
    }
}

int main(){
    ll n; cin>>n>>mod_;
    path.assign(n,vector<edge>(0));
    if(n>1){
    rep(i,n-1){
        ll x,y; cin>>x>>y;
        x--; y--;
        add_edge(x,y);
    }
    rep(i,path[0].size()){
        edge &e=path[0][i];
        dfs(e.to,0,i);
    }
    bfs(0);
    rep(i,n){
        ll ans=1;
        for(edge &e:path[i]){
            ans=(ans*e.dp)%mod_;
        }
        cout<<(mod_+ans)%mod_<<endl;
    }
    }
    else cout<<1<<endl;
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	string ans="";
	while(n>0)
	{
		// deb(n)
		n-=1;
		ans+=('a'+(n)%26);
		n/=26;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
	
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    long long X = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        X ^= A[i];
    }
    X ^= (A[0] ^ A[1]);
    long long S = A[0] + A[1];
    long long D = (S - X) / 2;
    if (D < 0 || (D & X) != 0 || (D ^ 0) > A[0] || ((S + X) & 1) != 0)
        cout << -1 << endl;
    else
    {
        long long ans = D;
        for (long long i = 60; 0 <= i; i--)
        {
            if ((X >> i) & 1)
            {
                if ((ans | (1LL << i)) <= A[0])
                    ans |= (1LL << i);
            }
        }
        if (A[0] - ans >= 0 && ans > 0)
            cout << A[0] - ans << endl;
        else
            cout << -1 << endl;
    }
}

Measured memory_bytes: 3544
#include"bits/stdc++.h"

typedef long long ll;

using namespace std;

int main() {
	ll N;
	cin >> N;
	map<string, int>mp;
	for (int i = 0; i < N; i++)
	{
		string S;
		cin >> S;
		sort(S.begin(), S.end());
		mp[S]++;
	}
	ll ans = 0;
	for (auto& p : mp)
	{
		int tmp = p.second;
		ans += (ll)tmp * (tmp - 1) / 2;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 11136
from sys import exit
C = [list(map(int, input().split())) for _ in range(3)]
if not (C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]):
    print("No")
    exit()
if not (C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]):
    print("No")
    exit()
if not (C[0][2] - C[0][1] == C[1][2] - C[1][1] == C[2][2] - C[2][1]):
    print("No")
    exit()

print("Yes")


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 n, m;
    cin >> n >> m;

    vector<i32> a(m);
    vector<i32> c(m);
    for (i32 i = 0; i < m; i++) {
        i32 b;
        cin >> a[i] >> b;

        for (i32 j = 0; j < b; j++) {
            i32 ci;
            cin >> ci, ci--;
            c[i] |= 1 << ci;
        }
    }

    vector<i32> dp(1 << n, INT32_MAX / 2);
    dp[0] = 0;
    for (i32 i = 0; i < m; i++) {
        for (i32 j = (1 << n) - 1; j >= 0; j--) {
            dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i]);
        }
    }

    cout << (dp[(1 << n) - 1] == INT32_MAX / 2 ? -1 : dp[(1 << n) - 1]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(void){
  int n,k;cin >> n >> k;
  string s; cin >> s;
  for(int i = 0;i<n;i++){
    if(i == k-1){
      if(s.at(i) == 'A') cout << 'a';
      if(s.at(i) == 'B') cout << 'b';
      if(s.at(i) == 'C') cout << 'c';
      }else{
      cout << s.at(i);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

static const int MAX = 10000;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
  priority_queue<pair<int, int> > PQ;
  int color [MAX];
  int d[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while (!PQ.empty()) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;

    color[u] = BLACK;

    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if (color[v] == BLACK) {
        continue;
      }
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main() {
  cin >> n;

  int k, u, v, c;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}


Measured memory_bytes: 8000
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

static void D_task()
{
	LLONG N;
	get1int<LLONG>(N);

	printf("%lld\n", (N * (N - 1)) / 2LL);
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var tmp = input.split("\n");
  var line0 = tmp[0].split(" ");
  //var line1 = tmp[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var input1 = Number(line0[0]);
  var input2 = Number(line0[1]);
  var input3 = Number(line0[2]);
  var w = input1;
  var a = input2;
  var b = input3;

  var ans = 0;

  //console.log( input1+" "+ input2 +" "+ " hoge ")

  if (a<b){
    if(b>a+w) ans = b-a-w;
  }
  else if (b<a){
    if (a>b+w) ans = a-b-w;
  }




/*  
  for(var i=1; i <=n; i++){
    if(ans < k) ans *= 2;
    else ans += k;
  }
*/


  console.log(ans);
  
  


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int N,x,count =0,max=0;
    cin >> N >> x;
    vector<int> kodomo(N);

    for(int i = 0;i < N;i++)
        cin >> kodomo.at(i);

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

    for(int i = 0;i < N;i++)
        max +=kodomo.at(i);


    
    for(int i = 0;i < N;i++){
        if(x - kodomo.at(i) < 0)
            break;
        else{
            x -= kodomo.at(i);
            count++;
        }
    }
    
    if(x > 0 and count == N)
        count--;

    cout << count << endl;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
path = [0] * N
for i in range(N-1):
    path[i] = A[i+1] - A[i]
path[N-1] = K - A[N-1] + A[0]
print(K-max(path))

Measured memory_bytes: 32376
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    ll ans = 0, n = s.size(), m = t.size();
    map<char, ll> mps;
    vector<set<int>> st(26);
    rep(i, n){
        mps[s[i]]++;
        st[s[i]-'a'].insert(i+1);
    }
    bool ok = true;
    rep(i, t.size())if(!mps[t[i]])ok = false;
    if(ok){
        rep(i, m){
            auto it1 = st[t[i]-'a'].upper_bound(ans%n);
            if(it1 == st[t[i]-'a'].end()){
                ans += n-(ans%n);
                auto it2 = st[t[i]-'a'].begin();
                ans += *it2;
            }
            else{
                ans += *it1 - (ans%n);
            }
        }
    }
    cout << (ok ? ans : -1) << endl;
}   

Measured memory_bytes: 5248
import java.util.Scanner;

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

		String n = scan.nextLine();//nextLine

		int b = n.length();//文字数を代入
		char[] a; 
		a=new char[b]; //文字判定用の配列を作る
		String[] st;
		st=new String[b];//文字出力・変換用の配列を作る
		for(int i=0;i<b;i++){
			a[i]=n.charAt(i);
			if( Character.isUpperCase( n.charAt( i ) ) ){//大文字、小文字の判定
				st[i]=String.valueOf(a[i]);
				st[i]=st[i].toLowerCase( );//大文字なら小文字へ
			}
			else{
				st[i]=String.valueOf(a[i]);
				st[i]=st[i].toUpperCase( );//小文字なら大文字へ

			}
			System.out.print(st[i]);//一文字ずつ出力
			
		}
		System.out.println("");
	     scan.close();

	}
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    if(s.find("AC") == string::npos){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ss = S.size();
  string K, W;
  vector<int> number;
  vector<int> blank;
  vector<string> keys;
  
  for (int i = 0; i < S.size() - T.size() + 1; i++) {
    for (int j = 0; j < T.size(); j++) {
      if( S.at(i+j) != T.at(j) && S.at(i+j) != '?' ) {
        break;
      }
      if( j == T.size() - 1) {
        number.push_back(i);
      }
    }
  }
  if (number == blank ) {
    cout << "UNRESTORABLE" << endl;
  }
  else {
    for (int x : number) {
      for (int k = 0; k < ss; k++) {
        if ( k >= x && k < x + T.size() ) {
          K.push_back(T.at(k-x));
        }
        else if ( S.at(k) == '?') {
          K.push_back('a');
        }
        else {
          K.push_back(S.at(k));
        }
      }
      keys.push_back(K);
      K = W;
    }
    W = keys.at(0);
    for (string x : keys) {
      if ( W > x ) {
        W = x;
      }
    }
    cout << W << endl;
  }
}

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

typedef long long ll;

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

    ll ans=0;
    ll cnt=1;
    while(h>0)
    {
        if(h==1)
        {
            ans+=cnt;
            h=0;
        }
        else
        {
            ans+=cnt;
            cnt*=2;
            h=h/2;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

void out(ll i, ll j){ cout << i << " " << j << endl; }

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

    if((n & (n - 1)) == 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    ll n2 = n - (1 - n % 2);
    out(1, n + 2);
    out(n + 2, n + 3);
    out(n + 3, n + 1);
    out(n + 1, 2);
    out(2, 3);
    for(ll i = 3; i < n2; i+=2){
        out(n + 1, i + 1);
        out(i + 1, i + 2);
        out(n + 1, n + i + 2);
        out(n + i + 2, n + i + 1);
    }
    if(n % 2 == 0){
        ll x = n ^ (n - 1) ^ 1;
        out(n + n - 1, n + n);
        out(x, n);
    }
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
ll n,W,V,w[MAXN],v[MAXN],dp[MAXN],ans; 
int main()
{
	memset(dp,64,sizeof(dp));
	cin>>n>>W;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i],V+=v[i];
	dp[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=V;j>=v[i];j--)
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	for(int i=V;i>=1;i--)
		if(dp[i]<=W)
		{
			ans=i;
			break;
		}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
	int n, k, m;

	while(true) {
		cin >> n >> k >> m;
		if(!n && !k && !m) {
			break;
		}
		vector< int > s(n, 0);
		for(int i = 0; i < n; i++) {
			s[i] = i + 1;
		}
		
		s.erase( s.begin() + m - 1 );
		

		int a = m - 1;
		while(s.size() != 1) {
			//cout << s[((a - 1) + k) % s.size()] << endl;
			a = (a - 1 + k) % s.size();
			s.erase(s.begin() + a);
			// a = (a - 1 + k) % s.size();
		}

		cout << s[0] << endl;
	}
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000001]={false};


void makeERA(){
    for(int i=2;i<10000001;i++){
        if(era[i]!=true)continue;
        for(int j=2;;j++){
            if(i*j<=10000000)
                era[i*j]=false;
            else break;
        }
    }
    era[2]=true;
}



int main(){
    for(int i=0;i<10000001;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        
        if(n%2==0)n--;
        for(int i=n;i>=8;i-=2){
            if(era[i-8]&&era[i-6]&&!era[i-4]&&era[i-2]&&era[i]){
                cout<<i<<endl;
                goto next;
            }
        }
    next:;
    }
    
    
    return 0;
}

Measured memory_bytes: 10928
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H>>W;
  vector<vector<char>> vec(H,vector<char>(W));
  vector<vector<char>> mine(H,vector<char>(W,'0'));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> vec.at(i).at(j);
      if(vec.at(i).at(j)=='#'){
        mine.at(i).at(j)='#';
        for(int k:{-1,0,1}){
          for(int l:{-1,0,1}){
            if(-1<i+k and i+k<H and -1<j+l and j+l<W){
              if(vec.at(i+k).at(j+l) !='#'){
                int num;
                num=(int)mine.at(i+k).at(j+l);
                num+=1;
                mine.at(i+k).at(j+l)=(char)num;
              }}}}}}}
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
    cout<<mine.at(i).at(j);
    if(j==W-1){
      cout<<endl;
    }
  }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 4009
using namespace std;

int n,a[N][N],dp[N][N],fac[N<<1],inv[N];
int main(){
	scanf("%d",&n);
	int i,j,x,y;
	fac[0]=inv[0]=inv[1]=1;
	for (i=1; i<(N<<1); i++) fac[i]=(ll)fac[i-1]*i%mod;
	for (i=2; i<N; i++) inv[i]=mod-(ll)inv[mod%i]*(mod/i)%mod;
	for (i=2; i<N; i++) inv[i]=(ll)inv[i-1]*inv[i]%mod;
	int ans=0;
	for (i=1; i<=n; i++){
		scanf("%d%d",&x,&y);
		ans=(ans-(ll)fac[x+y<<1]%mod*inv[x<<1]%mod*inv[y<<1]%mod+mod)%mod;
		dp[2001-x][2001-y]++;
		a[2001+x][2001+y]++;
	}
	for (i=1; i<N; i++)
		for (j=1; j<N; j++){
			dp[i][j]=(dp[i][j]+(dp[i-1][j]+dp[i][j-1])%mod)%mod;
			ans=(ans+(ll)dp[i][j]*a[i][j])%mod;
		}
	printf("%lld\n",(ll)ans*(mod+1>>1)%mod);
	return 0;
}


Measured memory_bytes: 96896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		String input = reader.readLine();
		String str[] = input.split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);

		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 24336
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int n = scanner.nextInt();
		    int i = scanner.nextInt();
		    
		    System.out.println(n - i + 1);
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21716
rot = ((1,2,4,3),(2,0,3,5),(0,1,5,4))
f = input().split()

for i in range(int(input())):
    t, s = map(f.index, input().split())
    for j in rot:
        if t not in j or s not in j:
            continue
        d = rot.index(j)
        if (j.index(t) - j.index(s)) %4 == 1:
            d -= 5
    print(f[abs(d)])

Measured memory_bytes: 7612
s = input()
a = [-1] * (len(s) + 1)

if s[0] == "<":
    a[0] = 0
if s[-1] == ">":
    a[-1] = 0
    
for i in range(len(s) - 1):
    if s[i] == ">" and s[i + 1] == "<":
        a[i + 1] = 0 

for i in range(len(a)):
    if a[i] == 0:
        l = i - 1
        while 0 <= l - 1:
            if s[l] == ">" and s[l - 1] == ">":
                a[l] = a[l + 1] + 1
            else:
                break
            l -= 1
        r = i + 1
        while r + 1< len(a):
            if s[r - 1] == "<" and s[r] == "<":
                a[r] = a[r - 1] + 1
            else:
                break
            r += 1

for i in range(len(a)):
    if a[i] == -1:
        if i == 0:
            a[i] = a[i + 1] + 1
        elif i == len(a) - 1:
            a[i] = a[i - 1] + 1
        else:
            a[i] = max(a[i - 1], a[i + 1]) + 1
            
ans = sum(a)
print(ans)

Measured memory_bytes: 23452
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(4);

            Arrays.sort(a);

            int[] b = {1, 4, 7, 9};

            for (int i = 0; i < 4; i++) {
                if (a[i] != b[i]) {
                    out.println("NO");
                    return;
                }
            }

            out.println("YES");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 22740