akhauriyash/Code-Regression huggingface dataset:
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
#include <cmath>

int main()
{
  double A, B, H, M, ans, tmp, ang1, ang2;
  cin >> A >> B >> H >> M;
  ang1 = 6.0 * M;
  ang2 = 30.0 * H + 0.5 * M;
  tmp = (A * A) + (B * B) - (2 * A * B) * cos(abs(ang1 - ang2) * M_PI / 180);
  ans = sqrt(tmp);
  cout << fixed;
  cout << setprecision(20) << ans << endl;
  return 0;
}


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

const int maxm=100010;
int n,m,pp;
struct ii{
	int p,y,num;
}a[maxm]; 
struct jj{
	int o1,o2;
}out[maxm];

bool operator<(const ii &b,const ii &c){
	if(b.p==c.p)return b.y<c.y;
	else return b.p<c.p;
} 
/*
void putout(int aa){
	int xx=out[aa].o1,lx=0;
	int yy=out[aa].o2,ly=0;
	while(xx){
		xx=xx/10;
		lx++;
	}
	for(int i=1;i<=6-lx;i++){
		cout<<"0";
	}
	cout<<out[aa].o1;
	while(yy){
		yy=yy/10;
		ly++;
	}
	for(int i=1;i<=6-ly;i++){
		cout<<"0";
	}
	cout<<out[aa].o2<<endl;
	return;
}
*/
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i].p>>a[i].y;
		a[i].num=i;
	}
	sort(a+1,a+1+m);
	for(int i=1;i<=m;i++){
		if(a[i].p!=a[i-1].p)pp=1;
		out[a[i].num].o1=a[i].p;
		out[a[i].num].o2=pp;
		pp++;
	}
	for(int i=1;i<=m;i++){
		printf("%06d%06d\n",out[i].o1,out[i].o2);
		//putout(i);
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
## coding: UTF-8
from decimal import *
s = input().split()
t = [int(p) for p in s]


#print(t)
if(t[0] == 1 or t[1] == 1):
    answer = 1
elif( Decimal(Decimal(t[0]) % 2 )== 1 and Decimal(Decimal(t[1]) % 2) == 1):
    n = Decimal( Decimal(Decimal(t[0]) - 1) // 2  )
    #print(n)
    m = Decimal( Decimal(Decimal(t[1]) - 1) // 2  )
    answer = Decimal(    Decimal(  Decimal(Decimal(m) + 1)     *    Decimal(Decimal(n) + 1)  )   + Decimal( Decimal(m) * Decimal(n) )       )
else:
    answer = Decimal(   Decimal(Decimal(t[0]) * Decimal(t[1])) // 2  )

print(int(answer))

'''
H = t[0]
W = t[1]
ans = 0
if( W % 2 == 0):
    for i in range(H):
        ans += W / 2
else:
    for i in range(H):
        if(i % 2 == 0):
            ans += W / 2.0 + 0.5
        else:
            ans += W / 2.0 - 0.5
print(int(ans))
'''


Measured memory_bytes: 5076
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        // 入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[][] s = new String[n][3];

        for (int i = 0; i < n; i++) {
            s[i][0] = String.valueOf(i + 1);
            s[i][1] = sc.next();
            s[i][2] = sc.next();
        }

        Arrays.sort(s, (a, b) -> {
            if (a[1].equals(b[1])) return Integer.parseInt(b[2]) - Integer.parseInt(a[2]);
            return a[1].compareTo(b[1]);
        });

        for (int i=0;i<n;i++) {
            System.out.println(s[i][0]);
        }
    }
}

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

int N,K,mini;
int* H;
int *opti;

int min(int a,int b)
{
    return (a>b)?b:a;
}

int func(int i)
{
    int mini = INFINITY;
    if(i == N)
        return 0;
    if(opti[i-1] != -1)
        return opti[i-1]; 

    for(int j=i+1;j<=i+K;j++)
    {
        if(j > N)
            break;
        mini = min(mini,abs(H[i-1] - H[j-1])+func(j));
    }    
    opti[i-1] = mini;
    return mini;    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif //*
    cin >> N;
    cin >> K;
    int H[N];
    for(int i = 1;i <= N;i++)
        cin >> H[i-1];
    int opti[N];  
    fill_n(opti,N,-1);
    ::H = H;
    ::opti = opti;
    cout << func(1);
}

Measured memory_bytes: 10644
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 26;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int a,b;
	cin >> a >> b;
	if((a+b)%2){
		cout << "IMPOSSIBLE" << endl;
	}
	else{
		cout << (a+b)/2 << endl;
	}






    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n;
long long m,finv[10010],rp[4][10010];
long long inverse(long long x){
	long long res=1LL,tms=m-2;
	while(tms){
		if(tms&1)
			res=(res*x)%m;
		x=(x*x)%m; 
		tms>>=1;
	}
	return res;
}
void init_finv(){
	finv[0]=1LL;
	for(int i=1;i<=10000;i++)
		finv[i]=(finv[i-1]*inverse(i))%m;
}
void init_rp(int po){
	rp[po][0]=1LL;
	for(int i=1;i<=10000;i++)
		rp[po][i]=(rp[po][i-1]*inverse(po))%m;
}
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	init_finv();
	init_rp(2);
	init_rp(3);
	long long s=0LL;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			s=(s+finv[i]*finv[j]%m*finv[3*n-3*i-2*j]%m*rp[3][i]%m*rp[2][j]%m)%m;
		}
	}
	for(int i=1;i<=n*3;i++)
		s=(s*i)%m;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>
#include<iomanip>

using namespace std;

int main(void)
{
    int n,k;
    cin>>n>>k;
    
    if(n<k){
        double pro=0;
        for(int i=1;i<=n;i++){
            int count=1;
            long int num=i*2;
            
            while(num<k){
                num*=2;
                count++;
            }
            pro+=(double)1/(n*pow(2,count));
        }
        cout<<fixed<<setprecision(10)<<pro<<endl;
        
    }
    
    else{
        double pro=(double)(n-k+1)/n;
        for(int i=1;i<k;i++){
            int count=1;
            long int num=i*2;
            
            while(num<k){
                num*=2;
                count++;
            }
            pro+=(double)1/(n*pow(2,count));
        }
        cout<<fixed<<setprecision(12)<<pro<<endl;
    }
}


Measured memory_bytes: 384
N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i

print(ans[::-1]) 

Measured memory_bytes: 61904
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define P pair<int,int>
const long long INF=1000000007;

//vars;
int W,H,ans=0,shortest_pass=0;
char s[55][55];

int BFS(){
	//前後左右に動くことを想定するため,
	//(x,y)を(x+dx[i],y+dy[i])に移動させることを考える.
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	queue<P> que;
	//初期位置からの距離(distance)を調べる;
	int dist[55][55];
	//わかりやすさのため,初期位置を(0,0)ではなく(1,1)にした.
	//すべての点をINF(=未訪であるというフラグ)にする.
	rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
	//最初の点をスタートでありゴールと考えると,
	//dist[1][1]==1である.
	dist[1][1]=1;
	//(1,1)はすでに訪れた,という指標を立てる.
	que.push(P(1,1));
	//s[i][j]がゴール,もしくはゴールに行けないと
	//わかったときに終了する.
	while(que.size()){ 
		P p=que.front();
		que.pop();
		rep(i,0,4){
			//まず(1,1)の前後左右を調べる.
			int next_x=p.first+dx[i];
			int next_y=p.second+dy[i];
			if(s[next_x][next_y]=='.'&&
				next_x>0&&next_x<=W&&
				next_y>0&&next_y<=H&&
				dist[next_x][next_y]==INF){
				que.push(P(next_x,next_y));
				dist[next_x][next_y]=dist[p.first][p.second]+1;
			}
		}
	}
	return dist[W][H];
}

int main() {
	//input;
	cin>>H>>W;
	rep(j,1,H+1)rep(i,1,W+1){
		cin>>s[i][j];
		//'.'の点を数える.
		if(s[i][j]=='.')ans++;
	}

	//output;
	shortest_pass=BFS();
	//ゴールに行けないとき,dist[W][H]は更新されず
	//INFのままなので,"-1"を出力する.
	if(shortest_pass==INF)cout<<"-1"<<endl;
	//ゴールに行けるとき、その最短コース以外の'.'は
	//全て'#'にしても問題ない.
	else cout<<ans-shortest_pass<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;



int main() {
    fast;
    int n;
    string s;
    unordered_map< string, int > CNT;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s;
        CNT[s]++;
    }


    cout << "AC x " << CNT["AC"] << "\n";
    cout << "WA x " << CNT["WA"] << "\n";
    cout << "TLE x " << CNT["TLE"] << "\n";
    cout << "RE x " << CNT["RE"] << "\n";
}

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

long long p, nr[3009][3009], a[3009], b[3009];

void init() {
	for (int i = 0; i <= p; i++) {
		for (int j = 0; j <= p; j++) {
			if (i == 0 || j == 0) nr[i][j] = 1;
			else nr[i][j] = (nr[i - 1][j] + nr[i][j - 1]) % p;
		}
	}
}

int main() {
	cin >> p; init();
	for (int i = 0; i < p; i++) {
		cin >> a[i];
		if (a[i] == 1) {
			long long r = 1;
			for (int j = p - 1; j >= 0; j--) {
				b[j] -= r * nr[p - 1 - j][j];
				b[j] += p * p; b[j] %= p;
				r *= -i; r += p * p; r %= p;
			}
			b[0] = (b[0] + 1) % p;
		}
	}
	for (int i = 0; i < p; i++) {
		if (i >= 1) cout << " ";
		cout << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 70912
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn main() {
    let n = read::<usize>();
    let mut v = vec![];
    for i in 0..n {
        v.push(read::<usize>() - 1);
    }
    let mut cur = 0;
    for i in 0..n + 1 {
        if cur == 1 {
            println!("{}", i);
            return;
        }
        cur = v[cur];
    }
    println!("-1");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
from sys import stdin
N,M = map(int, input().split())
#pS = [stdin.readline().split() for _ in range(n)]
#print(pS)
AC=[0]*N
WA=[0]*N
#print(AC,WA)
for _ in range(M):
    p,S=stdin.readline().split()
#    print('p={},S={}'.format(p,S))
    if S=='AC':
#        print('SはAC')
        if AC[int(p)-1]==0:
#            print('問題{}でACはまだないのでACに1加えます'.format(p,))
            AC[int(p)-1]+=1
        else:
#            print('問題{}で既にACがあるのでACには1加えません'.format(p,))
            pass
    elif S=='WA':
#        print('SはWA')
        if AC[int(p)-1]==0:
#            print('問題{}でACはまだないのでWAに1加えます'.format(p,))
            WA[int(p)-1]+=1
        else:
#            print('問題{}で既にACがあるのでWAに1加えません'.format(p,))
            pass
for i in range(N):
    if AC[i]==0:
        WA[i]=0
#print(AC,WA)
print(sum(AC), sum(WA))

Measured memory_bytes: 4596
N, K = map(int, input().split())
A = [ ]
D = [ ]
for i in range(K):
  D.append(int(input()))
  A.append(list(input().split()))
B = [ ]
c = 0
for i in range (K):
  B += A[i]
F = [int(B[i]) for i in range(len(B))]
for j in range (1,N+1):
  if F.count(j) == 0:
    c += 1
print(c)

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

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

    ll l = lcm(n, m);
    map<int, char> x;

    for (int i = 0; i < n; i++) {
        x[l / n * i] = s[i];
    }
    for (int i = 0; i < m; i++) {
        x[l / m * i] = t[i];
    }
    for (int i = 0; i < n; i++) {
        if (x[l / n * i] != s[i]) {
            cout << -1 << endl;
            ret();
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 8192
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    ld d, b, x;
    cin >> d >> b >> x;
    ld h = x / (d * d);
    if (h < (b / 2.0 ) ) {
        ld ans = atan ( (2 * d * h) / ( b * b) );
        ans = ans * 180;
        ans = ans / 3.1415926535;
        cout << setprecision (10) << fixed << (90.0000000000 - ans) << '\n';
    } else {
        ld ans = atan ( (d ) / (2 * (b - h) ) );
        ans = ans * 180;
        ans = ans / 3.1415926535;
        cout << setprecision (10) << fixed << (90.0000000000 - ans) << '\n';
    }
}


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

#define RANGE 100001

int count[RANGE];

int main(){
	int n, a, b;
	scanf("%d\n", &n);
	if(n == 1) printf("Hello World\n");
	else {
		scanf("%d\n", &a);
		scanf("%d\n", &b);
		printf("%d\n", a + b);
	}
	return 0;
}


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

long long s[400][30]; 
const int Shurui=26;//今回は26種類
int Date;//今回は1年間なので365日
long long Seigenjikan=1800000;//実行時間

int main() {
  clock_t start = clock();
  cin >>Date;
  vector<long long>c(Shurui);
  vector<int>last(Shurui,0);//前回の日にち
  vector<int>t(Date,0);//開催する順番
  for(int i=0;i<Shurui;i++)t[i]=i%Shurui;//とりあえずの値
  long long wa=0;
  for(int i=0;i<Shurui;i++){
    cin>>c[i];
    wa+=c[i];
  }
  for(int i=0;i<Date;i++){
    for(int j=0;j<Shurui;j++){
      cin>>s[i][j];
    }
  }
  long long kotae=0;
  long long hikukazu=0;
  long long atai=0;
  for(int i=0;i<Date;i++){
    atai=0;
    for(int j=0;j<Shurui;j++){
      if(s[i][j]>atai){
        t[i]=j;
        atai=s[i][j];
      }
    }
  }
  for(int i=0;i<Date;i++){
    atai=0;
    atai=s[i][t[i]];
    hikukazu+=wa-c[t[i]]*(i+1-last[t[i]]);
    last[t[i]]=i+1;
    kotae+=atai-hikukazu;
    //cout<<kotae<<endl;
  }  
  clock_t end = clock();
  long long time = end - start;
  //cout<<start<<" "<<end<<" "<<time<<endl;
  while(time<Seigenjikan){
    long long d=rand()%Date;
    long long q=rand()%Shurui;
    long long old=t[d];
    t[d]=q;
    long long new_kotae=0;
    hikukazu=0;
    for(int i=0;i<Date;i++){
      atai=0;
      atai=s[i][t[i]];
      hikukazu+=wa-c[t[i]]*(i+1-last[t[i]]);
      last[t[i]]=i+1;
      new_kotae+=atai-hikukazu;
    }
    if(new_kotae<kotae){
      t[d]=old;
      //cout<<":"<<new_kotae<<":";
    }else{
      //cout<<":yokunatta:";
      kotae=new_kotae;
    }
    end = clock();
    time = end - start;
    //if(time>1500000)cout<<time<<endl;
  }
  for(int i=0;i<Date;i++){
    cout<<t[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
int main(void)
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if ((A<C&&B>C)||( A>C&&B<C)){
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
vector<int>p;
bool prime[N];
int main(){
	//freopen("readin.txt","r",stdin);
	for(int i = 2;i*1LL*i <= N;i++)
		if(!prime[i])
			for(int j = i + i;j < N;j+=i)prime[j] = 1;
	for(int i = 2;i < N;i++)if(!prime[i])p.push_back(i);
	int x,y;
	scanf("%d%d",&x,&y);
	long long ans = 0;
	for(auto i : p){
		int temp = __gcd(x*1LL*i,y*1LL);
		if(temp < y)return cout << x*1LL*i << endl,0;
	}
	puts("-1");
}

Measured memory_bytes: 1916
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N, X;
    cin >> N >> X;
    int D;
    vector<int> v;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        v.push_back(abs(x-X));
    }
    sort(v.begin(), v.end());
    for(int i = 1; i <= v[0]; i++){
        D = v[0] / i;
        for(int j = 0; j < N; j++){
            if(v[j] % D != 0){
                break;
            }
            if(j == N-1){
                cout << D << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 892
<?php

(new Main)->execute();


class Rectangle
{
    private $height;
    private $width;
    private $style;

    private $rectangle = [];

    public function __construct($height, $width, $style)
    {
        $this->height = $height;
        $this->width  = $width;
        $this->style  = $style;

        $this->rectangle = $this->make();
    }

    private function make()
    {
        $rectangle = [];
        for ($height = 0; $height < $this->height; $height++) {
            $rectangle[$height] = str_repeat($this->style, $this->width);
        }
        return $rectangle;
    }

    private function setColsInnerFrame($thickness, $style)
    {
        foreach ($this->rectangle as $height => $_) {
            for ($width = 0; $width < $thickness; $width++) {
                $this->rectangle[$height][$width]                    = $style;
                $this->rectangle[$height][$this->width - $width - 1] = $style;
            }
        }
    }

    private function setRowsInnerFrame($thickness, $style)
    {
        foreach ($this->rectangle as $height => $_) {
            if ($height >= $thickness) { return; }

            $this->rectangle[$height]                     = str_repeat($style, $this->width);
            $this->rectangle[$this->height - $height - 1] = str_repeat($style, $this->width);
        }
    }

    public function setCheckerboardPattern($style = '#')
    {
        $checkLine = str_pad('', $this->width + 1, $style.$this->style);

        foreach ($this->rectangle as $height => $_) {
            $row = substr($checkLine, $height % 2, $this->width);
            $this->rectangle[$height] = $row;
        }

        return $this;
    }

    public function setInnerFrame($thickness = 1, $style = '#')
    {
        if ($thickness > $this->width) {
            $thickness = $this->width;
        }

        $this->setRowsInnerFrame($thickness, $style);
        $this->setColsInnerFrame($thickness, $style);

        return $this;
    }

    public function get()
    {
        return implode(PHP_EOL, $this->rectangle).PHP_EOL;
    }
}

class Main
{
    public function execute()
    {
        while (true) {
            list($height, $width) = $this->getStdinExplodedBy(' ');
            if ($this->invalid($height, $width)) { return; }

            $rectangle = (new Rectangle($height, $width, '.'))
                ->setInnerFrame(1, '#')
                ->get();

            $this->draw($rectangle);
        }
    }

    private function getStdinExplodedBy($delimiter)
    {
        return explode($delimiter, trim(fgets(STDIN)));
    }

    private function invalid($height, $width)
    {
        return $height == 0 && $width == 0;
    }

    public function draw($shape)
    {
        echo $shape, PHP_EOL;
    }
}

Measured memory_bytes: 15408
using System;

namespace ConsoleApp20
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());
            double a = r * r * Math.PI;
            double c = 2 * r * Math.PI;
            Console.WriteLine("{0} {1}", a, c);
        }
    }
}

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

ll N;

int h(int n, int w){
  ll x=N*n*w;
  ll y=4*n*w-N*(n+w);
  if(y==0) return -1;
  if(x%y!=0) return -1;
  int ans=x/y;
  if(ans>0&&ans<3501) return ans;
  else -1;
}

int main(){
  cin>>N;
  for(int i=1;i<=3500;i++){
    for(int j=1;j<=3500;j++){
      int x=h(i, j);
      if(x!=-1){
        cout<<x<<" "<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 20;
int N;
int dp[MN][3];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N;
    for (int i = 1, a, b, c; i <= N; i++) {
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2]));
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX/3
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    vector<LL> sum(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end());
    sum[0] = a[0];
    for(int i=1;i<n;i++){
        sum[i] = sum[i-1]+a[i];
    }
    int ans = 1;
    for(int i=n-2;i>=0;i--){
        //cout << sum[i] << endl;
        if(2*sum[i] >= a[i+1]) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    cout << n*n*n;
    return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,a,b,c,d = m();
ss = list(input())
if c < d:
	k = s(ss[b-1:d])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	k = s(ss[a-1:c])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	print("Yes")
	exit()
else:
	# c > d
	count = 0
	k = s(ss[b-2:d])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
		if k[i][0] == "." and k[i][1] >= 3:
			count = 1
	if count == 1:
		k = s(ss[a-1:c])
		for i in range(len(k)):
			if k[i][0] == "#" and k[i][1] >= 2:
				print("No")
				exit()
		print("Yes")
		exit()
	else:
		ss[d-1] = "#"
		k = s(ss[a-1:c])
		for i in range(len(k)):
			if k[i][0] == "#" and k[i][1] >= 2:
				print("No")
				exit()
		print("Yes")
		exit()


Measured memory_bytes: 80640
using System;
using System.Collections.Generic;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc148_d();
        }

        static void abc148_d()
        {
            // D - Brick Break
            long n = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            // 満たさない場合は-1
            long ans = -1;
            // 左から1,2,3,..と探していく
            long mark = 0;
            for (int i=0; i<n; i++)
                if (A[i] == mark + 1) mark += 1;
            // 該当するもの以外は砕く
            if (mark > 0) ans = n - mark;
            Console.WriteLine(ans);
        }
    }
}

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

int main(){

	int s, h, m;

	cin >> s;

	h = s / 3600;
	m = (s % 3600) / 60 ;
	s = s % 3600 % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;

}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int M, G, dp[2][1010];

signed main() {
    while(cin >> M, M) {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;

        rep(s,0,M) {
            int mo = s % 2;
            int a, b; cin >> a >> b;
            repq(k,0,b) {
                int cost = a * k;
                repq(i,0,1000) {
                    if(i-cost < 0) continue;
                    dp[mo^1][i] += dp[mo][i-cost];
                }
            }
            repq(i,0,1000) dp[mo][i] = 0;
        }

        cin >> G;
        rep(s,0,G) {
            int N; cin >> N;
            cout << dp[M%2][N] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3004
S = list(input())
alphabet = list('abcdefghijklmnopqrstuvwxyz')
bucket = {}
for a in alphabet:
  bucket[a] = 0
for s in S:
  bucket[s] += 1
for a in alphabet:
  if bucket[a] == 0:
    print(a)
    break
else:
    print('None')


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

void dfs(vector<vector<ll>>&tree, ll place, ll from, ll k, ll depth, ll&ans) {
  if (ans == -1) ans = k;
  depth++;
  ll j = 0;
  for (int i = 0; i < tree[place].size(); i++) {
    ll nx = tree[place][i];
    if (from == nx) continue;
    if (depth < 2) ans = (ans * (k-1-j)) % MOD;
    else ans = (ans * (k-2-j)) % MOD;
    j++;
    dfs(tree, nx, place, k, depth, ans);
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)

  ll n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << k << endl;
    return 0;
  }
  vector<vector<ll>> tree(n);
  for (int i = 0; i < n-1; i++) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].emplace_back(b);
    tree[b].emplace_back(a);
  }
  ll root;
  for (int i = 0; i < n; i++) if (tree[i].size() == 1) root = i;

  ll ans = -1;
  dfs(tree, root, -1, k, 0, ans);
  cout << ans << endl;
}


Measured memory_bytes: 17904
#include<bits/stdc++.h>
#include <cctype>
#define ll          long long int
#define PB          push_back
#define GO          ll t; cin>>t; while(t--)
#define G(t)        cin>>t; while(t--)
#define ALLR(x)     x.rbegin(), x.rend()
#define PII         pair<ll ,ll >
#define VI          vector<ll >
#define ALL(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define PI          3.141592653589793238
#define SZ(x)       (ll )x.size()
#define hell2        998244353
#define hell        1000000007
#define FO(i,a,b)    for(i=a;i<b;i++)
#define FOREV(i,a,b)    for(i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define BS          binary_search
#define MP          make_pair
#define LIM         100005
#define ARR(n,i,a)    ll n,i;cin>>n;ll a[n];FO(i,0,n)cin>>a[i];
#define ARRK(k,n,i,a) int n,k,i;scanf("%d%d",&n,&k);ll a[n];FO(i,0,n)scanf("%lld",&a[i]);
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
/*ll powM(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll POW(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
int LIS(std::vector<int>& v)
{
    if (v.size() == 0)
        return 0;
    std::vector<int> tail(v.size(), 0);
    int length = 1;
    tail[0] = v[0];
    for (int i = 1; i < v.size(); i++)
    {
        auto b = tail.begin(), e = tail.begin() + length;
        auto it = lower_bound(b, e, v[i]);
        if (it == tail.begin() + length)
            tail[length++] = v[i];
        else
            *it = v[i];
    }
    return length;
}
ll modInverse(ll n, ll p)
{
    return powM(n, p - 2, p);
}
ll fac[500000] = {0};
ll done = 1;
ncrModP(ll n, ll r, ll p)
{
    if (r == 0)
        return 1;
 
    fac[0] = 1;
    if (n > done)
    {    for (ll i = done ; i <= n; i++)
            fac[i] = (fac[i - 1] * i) % p;
    }
    done = max(done, n);
 
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
 
}
ll ncrM(ll n, ll r)
{
    if (r > n - r)
        r = n - r;
    ll C[r + 1];
    memset(C, 0, sizeof(C));
    C[0] = 1;
    for (ll i = 1; i <= n; i++) {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j - 1]);
    }
    return C[r];
}
map<ll, ll>f;
ll fib(ll k)
{
    ll i; f[0] = 1; f[1] = 1; f[2] = 2;
    if (k <= done)return f[k];
    for (i = done; i <= k; i++)f[i] = (f[i - 1] % hell + f[i - 2] % hell) % hell;
    done = k;
    return f[k] % hell;
}void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;
 
}*/

int t;
int main()
{
fio
int i,y;
int a[5];FO(i,0,5){cin>>a[i];if(a[i]==0){y=i+1;}}
cout<<y;
    return 0;
    }



Measured memory_bytes: 3648
import sys

def gcd(a, b):
    if b == 0:
        return a
    else:
        r = a % b
        return gcd(b, r)

def calc(a, b):
    gcd_val = gcd(a, b)
    lcm_val = a * b / gcd_val
    return (gcd_val, lcm_val)


for line in sys.stdin.readlines():
    line = line.strip()
    a, b = map(int, line.split())
    print "{0[0]:d} {0[1]:d}".format(calc(a, b))

Measured memory_bytes: 4232
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-03 20:18:25
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int64> a(n); cin >> a;

  map<int, int> mp;

  int64 ans = 0;

  for (int i = 0; i < n; ++i) {
    int cur = i - a[i];
    ans += mp[cur];
    ++mp[a[i] + i];
  }

  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
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
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int f=1;
        while(1){
            if(c<=0){
                cout<<"Yes";
                break;
            }
            if(a<=0){
                cout<<"No";
                break;
            }
            if(f){
                c-=b;
                f=0;
                continue;
            }
            f=1;
            a-=d;
        }

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n,y;
  scanf("%d %d",&n,&y);
  int a = -1;
  int b = -1;
  int c = -1;
  int i,j,k;
  for(i=0;i<y+1;i=i+10000) {
    for(j=0;j<y-i+1;j=j+5000) {
      k = n - i/10000 - j/5000;
      if(i+j+k*1000 == y) {
        a = i/10000;
        b = j/5000;
        c = k;
        goto LABEL;
      }
    }
  }
  LABEL:
  printf("%d %d %d\n",a,b,c);
  return 0;
}


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

bool endswith(string& s, string t) {
    int s_len = s.size(),
        t_len = t.size();
    return s_len >= t_len && s.substr(s.size() - t_len, t_len) == t;
}

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

    while (S.size() >= 5) {
        cerr << "S: " << S << endl;

        if (endswith(S, "erase") || endswith(S, "dream")) {
            S = S.substr(0, S.size() - 5);
        } else if (endswith(S, "eraser")) {
            S = S.substr(0, S.size() - 6);
        } else if (endswith(S, "dreamer")) {
            S = S.substr(0, S.size() - 7);
        } else {
            break;
        }
    }
    if (S.size() == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

int N,A,i,s;
int g[10],f[10];
int main(){
    fornum(i,0,3){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a]++;
        g[b] ++;
        
    }
    fornum(i,1,5){
        f[g[i]]++;
    }
    if(f[1]==2&&f[2]==2){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] a = new int[m];
		int[] b = new int[m];

		int[][] c = new int[m][n];

		for(int i=0;i<m;i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			for(int j=0;j<b[i];j++) {
				c[i][j] = sc.nextInt();
			}
		}

		int[] d = new int[(int) Math.pow(2,n)];
		d[0]=0;	
		for(int j =1;j<Math.pow(2,n);j++) {
			d[j]=(int) 1e9;
		}
		

		int index=0;
		for(int j=0;j<b[0];j++) {
			 index+= Math.pow(2,c[0][j]-1);
		}
		d[index]=a[0];
		
		int[] pow = new int[n+1];
		for(int i = 0;i<n+1;i++) {
			pow[i] = (int) Math.pow(2,i);
		}
		

		for(int i =1;i<m;i++) {
			for(int j=0;j<(int) Math.pow(2,n);j++) {
				if(d[j]<1e9) {
					int target = j;
					for(int k =0;k<b[i];k++) {
						if(j%pow[c[i][k]]>=pow[c[i][k]-1]) {
						}else {
							target += pow[c[i][k]-1];
						}
					}
					if(d[target]>d[j]+a[i])d[target]=d[j]+a[i];

				}
			}

		}
		if( d[(int) Math.pow(2,n)-1]<1e9) {
			System.out.println( d[(int) Math.pow(2,n)-1]);
		}else {
			System.out.println(-1);
		}



		/*
		TreeMap<Integer,Integer> treeMap = new TreeMap<>();
		treeMap.put(b[n], n);
		*/

	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 33492
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mx=10777;
const int inf=1e9;
vector<ll> cost(mx,inf);

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int h, n; cin>>h>>n;
	cost[0]=0;
	for (int i=0; i<n; i++) {
		ll a,b; cin>>a>>b;
		for (int j=1; j<=a; j++)
			cost[j]=min(cost[j],b);
		for (int j=a+1; j<mx; j++)
			cost[j]=min(cost[j],cost[j-a]+b);
	}
	cout<<cost[h]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
string s;
int main(void){
    int n;
    cin>>n;
    int a[]={3,13,23,43,53,73,83,103,113,163,173,193,223,233,263,283,293,313,353,373,383,433,443,463,503,523,563,593,613,643,653,673,683,733,743,773,823,853,863,883,953,983,1013,1033,1063,1093,1103,1123,1153,1193,1213,1223,1283,1303,1373};
    cout<<3;
    rep(i,1,n)cout<<' '<<a[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import os
import math
import string
import collections

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

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

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N = iss()
    sm = sum(map(int, N))
    print('Yes' if int(N) % sm == 0 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll h,w;
  std::cin>>h>>w;

  std::vector<std::vector<ll>> map(h,std::vector<ll>(w));

  rep(i,0,h)rep(j,0,w)std::cin>>map[i][j];

  rep(i,0,h){
    rep(j,0,w){
      ll a;
      std::cin>>a;
      map[i][j]=std::abs(map[i][j]-a);
    }
  }

  std::vector<std::vector<std::bitset<25610>>> dp(h,std::vector<std::bitset<25610>>(w));

  ll MID=12805;

  dp[h-1][w-1][MID+map[h-1][w-1]]=1;
  dp[h-1][w-1][MID-map[h-1][w-1]]=1;

  for(ll i=h+w-3;i>=0;i--){
    rep(j,0,h){
      if(0<=i-j&&i-j<w){
        ll he=j,we=i-j;
        if(he<h-1){
          dp[he][we]|=(dp[he+1][we]<<map[he][we])|(dp[he+1][we]>>map[he][we]);
        }
        if(we<w-1){
          dp[he][we]|=(dp[he][we+1]<<map[he][we])|(dp[he][we+1]>>map[he][we]);
        }
      }
    }
  }

  rep(i,0,12800){
    if(dp[0][0][MID+i]|dp[0][0][MID-i]){
      std::cout<<i<<"\n";
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 20736
#include <stdio.h>

int main(){
    int S,h,m,s;
    scanf("%d", &S);
    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}
    


Measured memory_bytes: 2136
#include<stdio.h>
#include<string.h>

using namespace std;

int main(){

  char str[222];
  scanf("%s" , str);
  int n = strlen(str);
  for(int i=n-2; i>0; i-=2){
      if(strncmp(str,str+i/2, i/2) == 0){
        printf("%d\n",i);
        return 0;
      }
  }
  return 0;
}


Measured memory_bytes: 128