akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int a, b, c;

	cin >> a >> b >> c;
	int s[] = { a,b,c };

	if (a==b && b== c)cout << "Yes";
	else cout << "No";
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextInt();
        long b = scan.nextInt();
        long max = Math.max(a, b);
        long temp = a * b;
        long ans = 0;
        for(long i = max; i <= temp; i += max) {
        	if(i % a == 0 && i % b == 0) {
        		ans = i;
        		break;
        	}
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include<stdio.h>
#include<stdlib.h>
typedef struct stu{
	int n,p[22],fp,sp[22];
}STU;
int comp(const void *p,const void *q){
	STU *a=(STU *)p,*b=(STU *)q;
	if(a->fp == b->fp)return a->n - b->n;
	else return b->fp - a->fp;
}
int main(){
	STU x[42];
	int n,i,j,k,f,a;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d",&x[i].n);
			x[i].fp=0;f=0;a=0;
			for(j=0;j<9;j++){
				//scanf("%d%d",&x[i].p[j][0],&x[i].p[j][1]);
				scanf("%d",&x[i].p[a]);
				if(x[i].p[a]<10)a++,scanf("%d",&x[i].p[a]);
				a++;
			}
			scanf("%d%d",&x[i].p[a],&x[i].p[a+1]);f=2;
			if(x[i].p[a]+x[i].p[a+1]>=10)scanf("%d",&x[i].p[a+2]),f=3;
			a+=f;
			for(j=0;j<a-f;j++){
				x[i].fp+=x[i].p[j];
				if(x[i].p[j]==10){
					x[i].fp+=x[i].p[j+1]+x[i].p[j+2];
					//printf("%3d",x[i].p[j]+x[i].p[j+1]+x[i].p[j+2]);
				}else if(x[i].p[j]+x[i].p[j+1]==10){
					x[i].fp+=x[i].p[j+1]+x[i].p[j+2];
					//printf("%3d",x[i].p[j]+x[i].p[j+1]+x[i].p[j+2]);
					j++;
				}else{
					x[i].fp+=x[i].p[j+1];
					//printf("%3d",x[i].p[j]+x[i].p[j+1]);
					j++;
				}
				//printf(" %3d\n",x[i].fp);
			}
			x[i].fp+=x[i].p[j]+x[i].p[j+1];
			if(f==3)x[i].fp+=x[i].p[j+2];
			//printf("%d\n",x[i].fp);
		}
		qsort(x,n,sizeof(STU),comp);
		for(i=0;i<n;i++)printf("%d %d\n",x[i].n,x[i].fp);
	}
	return 0;
}

Measured memory_bytes: 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append((i,n//i))
            if i != n // i:
                divisors.append((n//i,i))

    # divisors.sort()
    return divisors
N=int(input())
div=make_divisors(N)
ans=float("inf")
for x, y in div:
  ans=min(ans,(x-1)+(y-1))
print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
LL N, K;

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%lld%lld", &N, &K) != EOF) {
        if(K == 0) {
            printf("%lld\n", N * N);
            continue;
        }
        LL ans = 0;
        for(LL x = K + 1; x <= N; ++x) {
            ans += (N / x) * (x - K);
            if(N % x >= K) {
                ans += N % x - K + 1;
            }
//            printf("x = %lld ans = %lld\n", x, ans);
        }
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<ctime>
    #include<cctype>
    #include<climits>
    #include<iostream>
    #include<string>
    #include<vector>
    #include<map>
    #include<list>
    #include<queue>
    #include<deque>
    #include<algorithm>
    #include<numeric>
    #include<utility>
    #include<complex>
    #include<memory>
    #include<functional>
    #include<set>
     
    using namespace std;
     
    #define ALL(g) (g).begin(),(g).end()
    #define REP(i, x, n) for(int i = x; i < n; i++)
    #define rep(i,n) REP(i,0,n)
    #define F(i,j,k) fill(i[0],i[0]+j*j,k)
    #define P(p) cout<<(p)<<endl;
    #define INF 1<<25
     
    typedef long long ll;
     
    int dy[8]={1,1,1,0,0,-1,-1,-1};
    int dx[8]={-1,0,1,-1,1,-1,0,1};
    struct S{
    	int a,b,c;
    };
    bool asc(const S& left,const S& right){
    	return left.c > right.c;
    }
     
    int memo[100];
    int main(){
    	string S,T,ans;
    	vector<string>TMP;
    	int cnt=0;
    	cin>>S>>T;
    	rep(k,S.size()){
    		string ans;
    		cnt=0;
    	rep(i,S.size()){
    		if(S[i]=='?')ans+='a';
    		else ans+=S[i];
    		if(cnt==0&&memo[i]==0){
    		rep(j,T.size()){
    			if(!(S[i+j]==T[j]||S[i+j]=='?')){
    				goto fal;
    			}
    		}
    		ans.pop_back();
    		ans+=T;
    		cnt=1;
    		memo[i]=1;
    		i+=T.size()-1;
    		}
    	fal:;
    	}
    	if(cnt==1){
    		TMP.push_back(ans);
    	}
     
    	}
    	sort(TMP.begin(),TMP.end());
    	if(!(TMP.empty()))cout<<TMP[0]<<endl;
    	else	cout<<"UNRESTORABLE"<<endl;
    	return 0;
    }
     

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

int main(){
int n;
std :: cin >> n;

if(n & 1)
std :: cout << std :: fixed << std :: setprecision(10) << (double) (n / 2 + 1 ) / ((double)n) << '\n';
else
std :: cout << std :: fixed << std :: setprecision(10) << (double) (n / 2 ) / ((double)n) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P; 
LL H, W, N, a, b, ans[10];
map<P, bool> mp1, mp2;
int main()
{
	cin >> H >> W >> N;
	ans[0] = (H - 2) * (W - 2);
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		a--, b--;
		mp2[P(a, b)] = true;
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++)
				if (0 <= a - j && a - j <= H - 3 && 0 <= b - k && b - k <= W - 3)
					mp1[P(a - j, b - k)] = true;
	}
	for (map<P,bool>::iterator it = mp1.begin(); it != mp1.end(); it++) {
		int x = it->first.first, y = it->first.second;
		int count = 0;
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				if (mp2[P(x + i, y + j)]) count++;
		ans[0]--;
		ans[count]++;
	}
	for (int i = 0; i < 10; i++)
		cout << ans[i] << endl;
}

Measured memory_bytes: 212736
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
#define SEGMAX 131072
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int number_split(ll num)
{
	ll i=0;

	while(num>0){
		num/=10;
		i++;
	}
	return i;
}
int main(void)
{
	int min=11;

	ll n;

	cin>>n;

	for(ll i=1; i<=100000; i++){
		ll b=n/i;
		if(b!=0&&i*b==n){
			int fa=number_split(i), fb=number_split(b);
			int ans=max(fa, fb);
			//cout<<i<<" "<<b<<" "<<ans<<endl;
			if(min>ans) min=ans;
		}
	}
	cout<<min<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
     Scanner sc=new Scanner(System.in);
     int n=sc.nextInt();
     if(n==1){
       System.out.println("Hello World");
     }else{
        System.out.println(sc.nextInt()+sc.nextInt());
     }
  }
}

Measured memory_bytes: 20816
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

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

    bool has9 = false;
    for (auto i : s) {
        if (i == '9') {
            has9 = true;
            break;
        }
    }

    cout << (has9 ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
  int a;
  int b;
  int c;
  cin >> a >> b;
  
  c = a * b;
  if (c % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, sum = 0, num = 0, ans = 999999999999; cin >> n;
	int test[223456] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a;
		num += test[h];
	}
	sum += test[0]; num -= test[0];
	ans = min(ans, abs(sum - num));
	for (int h = 1; h < n - 1; h++) {
		sum += test[h];
		num -= test[h];
		ans = min(ans, abs(sum - num));
	}
	cout << ans << endl;
	cin >> n;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int d=365, n=26, score;
int c[27];
int s[366][27];
int a[366];
int sat[366]={};
int last[27]={};
ofstream fout("out.txt"), flog("log.txt");
uint64_t get_rand_range( uint64_t min_val, uint64_t max_val ) {

    srand((int)time(NULL));
    static mt19937_64 mt64(rand());

    uniform_int_distribution<uint64_t> get_rand_uni_int( min_val, max_val );

    return get_rand_uni_int(mt64);
}

int calcdiff(int t, int q){
    int p=a[t];
    int lp=0,rp=d+1,lq=0,rq=d+1;
    For(i,1,d+1){
        if(a[i]==p){
            if(i<t) lp=max(lp,i);
            else if(i>t) rp=min(rp,i);
        }
        if(a[i]==q){
            if(i<t) lq=max(lq,i);
            else if(i>t) rq=min(rq,i);
        }
    }
    int diff=s[t][q]-s[t][p];
    diff -= (t-lp) * (rp-t) * c[p];
    diff += (t-lq) * (rq-t) * c[q];
    return diff;
}

void greedy(){
    For(i,1,d+1){
        int mx = -(1<<30), acc = -1;
        For(con,1,n+1){
            int sati = sat[i-1] + s[i][con];
            For(j,1,n+1){
                if(j != con) sati -= (i-last[j]) * c[j];
            }
            if(mx<sati){
                mx = sati;
                acc = con;
            }
        }
        last[acc] = i;
        sat[i] = mx;
        a[i]=acc;
    }    
    score = sat[d];
}

void Main(){
    clock_t start = clock();
    cin >> d;
    For(i,1,n+1) cin >> c[i];
    For(i,1,d+1) For(j,1,n+1) cin >> s[i][j];
    greedy();
    double time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    while(time < 1950){
        int t = get_rand_range(1,d);
        int q = a[t];while(q==a[t])q=get_rand_range(1,n);
        int diff = calcdiff(t,q);
        //flog << diff << endl;
        if(diff>0){
            a[t] = q;
            score += diff;
        }
        time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    }
    For(i,1,d+1) cout << a[i] << endl;

}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


Measured memory_bytes: 3672
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
// use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;

fn gcd(a: i32, b: i32) -> i32 {
    if a % b == 0 {
        b
    } else {
        return gcd(b, a % b);
    }
}

fn main() {
    input! {
        x: i32,
    }
    let y = 360;
    let lcm = x * y / gcd(x, y);
    let ans = lcm / x;
    println!("{}", ans);
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll  long long
ll a[3000000];
int main()
{
    IO;
    ll i, j=1, k = 0, mod = 1e18, m, n, n1, m1,l1, l = 0, p, t, h, cnt=0;
    cin>>n;
    for(i=2; i*i<=n; i++){
        cnt=0; j = i;
        while(n%j==0){
            n/=j; cnt++;
        }
        n1=sqrt(2*cnt);
        for(int l1=n1-2; l1<=n1+2; l1++)
            if(l1*(l1+1)<=2*cnt) m1 = l1;
        l+=m1;
    }
    if(n!=1) l++;
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define double long double
using namespace std;
const double EPS = 1e-8;
const double INF = 1e9;

struct p3{
  double x,y,z,r;
  p3(){x=y=z=r=0;}
  p3(double x,double y,double z):x(x),y(y),z(z){};
  p3(double x,double y,double z,double r):x(x),y(y),z(z),r(r){};
  p3 operator + (const p3 a)const {return p3(x+a.x,y+a.y,z+a.z,r);}
  p3 operator - (const p3 a)const {return p3(x-a.x,y-a.y,z-a.z,r);}
  p3 operator * (const double a)const{return p3(x*a,y*a,z*a,r);}
  p3 operator / (const double a)const{return p3(x/a,y/a,z/a,r);}
  bool operator == (const p3 a)const {return abs(x-a.x)<EPS&&abs(y-a.y)<EPS&&abs(z-a.z)<EPS;}
  double Abs()const{return sqrt(x*x+y*y+z*z);}
  double dis(const p3 a)const{return sqrt((a.x-x)*(a.x-x)+(a.y-y)*(a.y-y)+(a.z-z)*(a.z-z));}
};

double dot(p3 a,p3 b){return a.x*b.x+a.y*b.y+a.z*b.z;}

struct L3{
  p3 s,t;
  L3(){s=t=p3();}
  L3(p3 s,p3 t):s(s),t(t){};
  bool operator == (const L3 a)const{return s==a.s&&t==a.t;}
};

L3 getRay(L3 a,p3 b){
  a.t = a.t-a.s;
  b = b-a.s;
  p3 e = a.t / a.t.Abs(); 
  p3 s = e*dot(e,b); //|b|cosx = a*b/|a|
  
  double d = s.dis(b);
  if(dot(e,b)<EPS||d>b.r+EPS)return L3();
  s = e * (s.Abs()-sqrt(b.r*b.r-d*d));
  
  p3 n = (b-s)/(b-s).Abs(); //??????????????????
  n = n*dot(a.t*(-1),n)*2; //??????????????????????°???±
  p3 t = a.t+n+s;
  return L3(s+a.s,t+a.s);
}

int n;
vector<p3> A;
p3 calc(L3 ray){
  while(1){
    double mn = INF;
    L3 nray;
    for(int i=0;i<n;i++){
      L3 res = getRay(ray,A[i]);
      double dis = ray.s.dis(res.s);
      if(res==L3())continue;
      if(mn>dis) mn=dis,nray = res;
    }
    if(mn==INF) return ray.s;
    ray = nray;
  }
}

int main(){
  while(cin>>n,n){
    L3 start;
    cin>>start.t.x>>start.t.y>>start.t.z;
    
    A.resize(n);  
    for(int i=0;i<n;i++)cin>>A[i].x>>A[i].y>>A[i].z>>A[i].r;

    p3 ans = calc(start);
    printf("%Lf %Lf %Lf\n",ans.x,ans.y,ans.z);
  }
  return 0;
}

Measured memory_bytes: 3140
// AtCoder Beginner Contest 151 C.cpp
 
#include <iostream>
#include <vector>
#include <string>
 
using namespace std;
 
int main()
{
	int n, m, ac = 0, wa = 0, qu_number;
	cin >> n >> m;
	string eva;
 
	vector<bool>a(n, false);
	vector<int>b(n,0);
 
	for (int i = 0; i < m; i++) {
		cin >> qu_number >> eva;
		if (a[qu_number - 1] == false) {
 
			if (eva == "AC") {
				ac++;
				a[qu_number - 1] = true;
                wa += b[qu_number - 1];
			}
			else {
				b[qu_number - 1]++;
			}
		}
	}
 
	cout << ac << " " << wa << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    int s = 0;
    REP(i,N) s ^= a[i];

    REP(i,N){
        int ans = s ^ a[i];
        cout << ans << " ";
    }
    cout << en;
    
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3984
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {

	int n;
	cin >> n;

	VI v(n);
	REP(i, n) {
		cin >> v[i];
	}

	SORT(v);
	v[n - 1] = v[n - 1] / 2;
	int sum = 0;

	REP(i, n) {
		sum += v[i];
	}

	ANS(sum);


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main()
{
	int a;
	scanf("%d",&a);

	int Time = a / 3600 + 0.5;
	double dblTime = a / 3600.0;
	int Minutes = (dblTime - Time) * 60;
	double dblMinutes = (dblTime - Time) * 60;
	int Seconds = ((dblMinutes - Minutes) * 60 + 0.5);

	printf("%d:%d:%d\n", Time, Minutes, Seconds);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <set>

int main() {
    std::set< int > s;
    int x;
    int res = 1;
    std::cin >> x;
    s.insert( x );
    while (true) {
        ++res;
        if (x%2) {
            x = 3*x + 1;
        } else {
            x /= 2;
        }
        if (s.find(x) != s.end() ) break;
        s.insert( x );
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,K;
    int num[9];
    int i,j,digits,tmp;
    
    scanf("%d%d",&N,&K);
    
    for(i=0;i<K;i++){
        scanf("%d",&num[i]);
    }
    
    tmp = N;
    i=0;
    while(1){
        while(tmp){
            digits = tmp%10;
            for(j=0;j<K;j++){
                if(digits == num[j]){
                    break;
                }
            }
            if(j!=K){
                //printf("j!=K\n");
                break;
            }
            tmp/=10;
        }
        if(tmp == 0){
            break;
        }
        tmp = N + ++i;
    }
    
    printf("%d\n",N+i);
}

Measured memory_bytes: 128
N, H = gets.split.map(&:to_i)
arrs = N.times.map { gets.split.map(&:to_i) }

max_first = arrs.map { |arr| arr[0] }.max
seconds = arrs.map { |arr| arr[1] }.select { |second| second > max_first }.sort.reverse

counter = 0
hp = H
while hp > 0
  if !seconds.empty?
    hp -= seconds.shift
    counter += 1
  else
    counter += (hp + (max_first - 1)) / max_first
    break
  end
end

puts counter

Measured memory_bytes: 13448
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;
 
const int Inf = 1000000007;
//const int mod = 998244353;//1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

string s;

void Solve()
{
	cin >> s;
	if(s == "ABC")
	{
		cout << "ARC";
	}
	else
	{
		cout << "ABC";
	}	
}
 
int main()
{
	Fastio();
	Solve();
}

Measured memory_bytes: 3612
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}
typedef vector<int> Node;
typedef vector<Node> Graph;
const int MAX_N = 1e5 + 10;
vector<int> bfs(const Graph& G, vector<bool>& used, int s) {
    vector<int> res;
    queue<int> que;
    que.push(s);
    used[s] = true;
    while(!que.empty()) {
        int u = que.front(); que.pop();
        res.push_back(u);
        for(int v : G[u]) {
            if(!used[v]) {
                used[v] = true;
                que.push(v);
            }
        }
    }
    return res;
}
int bipartite_color[MAX_N];
bool bipartite(const Graph& G, vector<int> vs) {
    for(int v : vs) bipartite_color[v] = -1;
    bipartite_color[vs[0]] = 0;
    for(int v : vs) {
        for(int w : G[v]) {
            if(bipartite_color[w] == bipartite_color[v]) {
                return false;
            } else {
                bipartite_color[w] = !bipartite_color[v];
            }
        }
    }
    return true;
}
LL solve(Graph G) {
    int V = G.size();
    vector<bool> used(V, false);
    LL N = 0;
    LL M = 0;
    LL P = 0;
    REP(i, V) if(!used[i]) {
        vector<int> vs = bfs(G, used, i);
        if(vs.size() == 1) {
            P++;
        } else {
            if(bipartite(G, vs)) {
                N++;
            } else {
                M++;
            }
        }
    }
    error(N, M, P);

    LL answer = 0;
    answer += N * N * 2;
    answer += N * M;
    answer += M * N;
    answer += M * M;
    answer += (V-P) * P;
    answer += P * (V-P);
    answer += P * P;
    return answer;
}
Graph random(int N, int p) {
    Graph G(N);
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            if(rand() <= p) {
                G[i].push_back(j);
                G[j].push_back(i);
            }
        }
    }
    return G;
}
int main(){
    iostream_init();
    int V, E;
    while(cin >> V >> E) {
        Graph G(V);
        REP(i, E) {
            int u, v;
            cin >> u >> v;
            u--; v--;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        cout << solve(G) << endl;
    }

    return 0;
}



Measured memory_bytes: 13304
while True:
    try:
        xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=map(float,input().split())
    except EOFError:
        break
    if xb2<xa1 or xb1>xa2 or yb2<ya1 or yb1>ya2:
        print("NO")
    else:
        print("YES")


Measured memory_bytes: 5572
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, y, ans = 0;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				if (i + j + k>n) break;
				if (10 * i + 5 * j + k ==y&& i + j + k == n) {
					cout << i << ' ' << j << ' ' << k;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1";
	return 0;
}


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

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string S;
  cin >> S;
  int N=S.size();
  vector<int> count(N), ch(1);
  rep(i,N-1) {
    if(S[i]!=S[i+1]) ch.push_back(i+1);
  }
  ch.push_back(N);
  int l=ch.size();
  rep(i,l/2) {
    int a=ch[2*(i+1)]-ch[2*i];
    if(a%2==0) {
      count[ch[2*i+1]]+=a/2;
      count[ch[2*i+1]-1]+=a/2;
    } else {
      if((ch[2*i+1]-ch[2*i])%2==0) {
        count[ch[2*i+1]]+=a/2+1;
        count[ch[2*i+1]-1]+=a/2;
      } else {
        count[ch[2*i+1]]+=a/2;
        count[ch[2*i+1]-1]+=a/2+1;
      }
    }
  }
  rep(i,N) cout << count[i] << ' ';
}

Measured memory_bytes: 1528
x = int(input())

if x >= 400 and 599 >= x:
    print("8")
elif x >= 600 and 799 >= x:
    print("7")
elif x >= 800 and 999 >= x:
    print("6")
elif x >= 1000 and 1199 >= x:
    print("5")
elif x >= 1200 and 1399 >= x:
    print("4")
elif x >= 1400 and 1599 >= x:
    print("3")
elif x >= 1600 and 1799 >= x:
    print("2")
elif x >= 1800 and 1999 >= x:
    print("1")

Measured memory_bytes: 9132
#include<cstdio>
int a, b, c, d;
int main() {
	scanf("%1d%1d%1d%1d", &a, &b, &c, &d);
	if(a+b+c+d==7) printf("%d+%d+%d+%d=7", a, b, c, d);
	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7", a, b, c, d);
	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7", a, b, c, d);
	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7", a, b, c, d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7", a, b, c, d);
	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7", a, b, c, d);
	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7", a, b, c, d);
	else if(a-b-c-d==7) printf("%d-%d-%d-%d=7", a, b, c, d);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

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

Measured memory_bytes: 1768
def main():
    N = int(input())
    S = [input() for i in range(N)]

    sortS = sorted(S)


    count = 0
    for i in range(len(sortS)):
        if i == 0:
            count += 1
            continue
        else:
            if sortS[i-1] == sortS[i]:
                continue
            else:
                count += 1

    print(count)








if __name__ == '__main__':
    main()



Measured memory_bytes: 25592
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
static const int MAX = 100;

int main() {
    int N, B[MAX];
    cin >> N;

    for (int i = 0; i < N - 1; ++i) cin >> B[i];

    int sum = B[0];
    for (int i = 1; i < N - 1; ++i) {
        sum += min(B[i - 1], B[i]);
    }
    sum += B[N - 2];

    cout << sum;
    return 0;
}


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

#define PI 3.14159265358979323846

// #define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 10000010
#define MOD 1000000007

int bexp(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            for (int k = j + 1; k < n; ++k)
            {
                if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && (a[i] + a[j] > a[k]) && a[i] + a[k] > a[j] && a[k] + a[j] > a[i])
                    ans++;
            }
        }
    }

    cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3648
def binarySearch(e, n, A):
    if e<A[0] or e>A[-1]:
        return False
    l, r = 0, n
    while l<=r:
        m = (r+l)//2
        if m == r or m == l:
            return False
        if e == A[m]:
            return True
        elif e < A[m]:
            r = m
        else:
            l = m
    return False


def ALDS1_4B():
    n, S = int(input()), list(map(int, input().split()))
    q, T = int(input()), list(map(int, input().split()))
    print(sum([1 for e in T if binarySearch(e, n, S)]))


if __name__ == '__main__':
    ALDS1_4B()

Measured memory_bytes: 18736
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

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

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String s = sc.next();
    int[][] questions = new int[q][2];
    for (int i = 0; i < q; i++) questions[i] = sc.nextIntArray(2);
    int[] acs = new int[n + 1];
    acs[0] = 0;
    acs[1] = 0;
    for (int i = 2; i <= n; i++) {
      if(s.substring(i - 2, i).equals("AC")) acs[i] = acs[i - 1] + 1;
      else acs[i] = acs[i - 1];
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < q; i++) {
      if (i > 0) sb.append("\n");
      sb.append(acs[questions[i][1]] - acs[questions[i][0]]);
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 47160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CMultiplication3 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            long d = Math.round(in.nextDouble() * 100);
            out.println(x * d / 100);
        }

    }
}



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

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> l(n);
    for(int i = 0; i < n; i++)
        cin >> l[i];

    sort(l.rbegin(), l.rend());

    int max = l[0];
    int sum = 0;
    for(int i = 1; i < l.size(); i++)
        sum += l[i];
    
    if(max - sum < 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string[] data;
            while((data = Console.ReadLine().Split())[0] != "0" || data[1] != "0") {
                int hit = 0, blow = 0;
                for(int i=0; i < data[0].Length; ++i) {
                    hit += data[0][i] == data[1][i] ? 1 : 0;
                    blow += data[0].Contains(data[1][i]) ? 1 : 0;
                }
                Console.WriteLine("{0} {1}", hit, blow - hit);
            }
        }
    }
}

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

int main() {
    int64_t n,m;
    cin >> n >> m;
    vector<int64_t> h(n),flag(n);
    int64_t ans = n;
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        int tmp;
        if(h.at(a-1)<=h.at(b-1)){
            tmp = a-1;
            if(flag.at(tmp)==0){
            flag.at(tmp) = 1;
            ans--;
            }
        }
        if(h.at(b-1)<=h.at(a-1)){
            tmp = b-1;
            if(flag.at(tmp)==0){
            flag.at(tmp) = 1;
            ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int N;
ll binarysearch(vector<ll> &A, ll b) {
  ll tmp = 0;
  REP(i, N) { tmp += abs(A[i] - (b)-i - 1); }
  return tmp;
}
int main() {
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> vec(N);
  ll avg = 0;
  /*REP(i, N) {
    vec[i] = A[i] - i - 1;
    avg += vec[i];
  }
  ll l = avg / N, r = (avg + N - 1) / N;
  ll ans = 1e10;
  ll tmp = 0;
  REP(i, N) { tmp += abs(A[i] - (l)-i - 1); }
  ans = min(ans, tmp);
  tmp = 0;
  REP(i, N) { tmp += abs(A[i] - (r)-i - 1); }
  ans = min(ans, tmp);*/
  ll l = -1e10, r = 1e10;
  ll ans = 0;
  while (true) {
    if (r - l <= 2) {
      ans = (r + l) / 2;
      break;
    }
    ll midl = l + (r - l) / 3, midr = l + 2 * (r - l) / 3;

    if (binarysearch(A, midl) < binarysearch(A, midr)) {
      r = midr;
    } else {
      l = midl;
    }
  }
  cout << binarysearch(A, ans) << endl;
}

Measured memory_bytes: 6392
#include <stdio.h>
int main(void){
    // Your code here!
    int i, j, H, W; 
    scanf("%d%d", &H, &W); 
    while(H != 0 && W != 0) { 
        for(i = 0; i < W; i++) { 
            printf("#"); } 
            printf("\n"); 
            for(i = 0; i < H - 2; i++) { 
                printf("#"); 
                for(j = 0; j < W - 2; j++) { 
                    printf("."); } 
                    printf("#\n"); } 
                    for(i = 0; i < W; i++) { 
                        printf("#"); } 
                        printf("\n"); 
                        printf("\n"); 
                        scanf("%d%d", &H, &W); } 
                        return 0; 
}



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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int  n;
    cin >> n;
    ll A[n+1];
    rep(i,n+1) cin >> A[i];
    unsigned long long lim[n+1];
    lim[0] = 1;
    if(n==0){
        if(A[0]<=1) cout << A[0] << endl;        
        else cout << -1 << endl;
        return 0;
    }
    rep(i,n){
        if(lim[i]<A[i]){
            cout << -1 << endl;
            return 0;
        }
        lim[i+1] = (lim[i] - A[i])*2;
        if(lim[i+1]>100000000000000) lim[i+1] = 100000000000000;
    }
    if(lim[n]<A[n]){
        cout << -1 << endl;
        return 0;        
    }
    ll cnt = 0;
    unsigned long long cnt_tot = 0;
    for(int i = n;i>=0;i--){
        cnt = MIN(lim[i],cnt+A[i]);
        cnt_tot += cnt;
    }
    cout << cnt_tot << endl;
    return 0;
}

Measured memory_bytes: 5208
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long a = fs.nextLong(), b = fs.nextLong(), c = fs.nextLong();
		long t = c - a - b;
		if(t<=0) {
			System.out.println("No");
			return;
		}
		
		t = t * t;
		
		long s = 4 * a * b;
		
		if(s < t)  System.out.println("Yes");
		else System.out.println("No");
		
		//		double ra = Math.sqrt(a);
//		double rb = Math.sqrt(b);
//		double rc = Math.sqrt(c);
	
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <deque>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int weight(int i, int j) {
  if (abs(i)+abs(j) == 1) return 0;
  else return 1;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int R, C; cin >> R >> C;
  int Sr, Sc; cin >> Sr >> Sc;
  Sr--, Sc--;
  int Gr, Gc; cin >> Gr >> Gc;
  Gr--, Gc--;
  vector<string> world(R);
  rep (i, R) cin >> world[i];

  vector<vector<int>> score(R, vector<int>(C, inf));
  score[Sr][Sc] = 0;
  deque<pair<int, int>> q;
  q.push_front({Sr, Sc});
  while (!q.empty()) {
      auto point = q.front();
      int r = point.first;
      int c = point.second;
      q.pop_front();

      for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
          if (i != 0 || j != 0) {
            if (0 <= i+r && i+r < R && 0 <= j+c && j+c < C) { // valid field
              if (world[r+i][c+j] != '#') { // can go
                int w = weight(i, j);
                if (score[r][c] + w < score[r+i][c+j]) {
                    score[r+i][c+j] = score[r][c] + w;
                    if (w) q.push_back({r+i, c+j});
                    else q.push_front({r+i, c+j});
                }
              }
            }
          }
        }
      }
  }
  if (score[Gr][Gc] != inf) {
    cout << score[Gr][Gc] << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 8752
#include<stdio.h>
int main(){
  int H,N,i,S=0;
  scanf("%d%d",&H,&N);
  int A[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    S+=A[i];
   }
  if(S>=H)printf("Yes");
  else printf("No");
  
  
  return 0;
 }

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

using namespace std;

int main()
{
    long long n , x , sum = 0;
    cin>>n>>x ;
    long long arr[n] ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i] ;
    sort(arr , arr + n) ;
    int idx = -1 , cnt = 0;
    for(int i = 0 ; i < n ; ++i)
    {
        if(x >= arr[i])
            x -= arr[i] , cnt++ , idx = i ;
    }
    if(idx == n-1 && x > 0)
        cnt--;
    return cout<<cnt , 0 ;
}


Measured memory_bytes: 256
S = input()

Q = int(input())

from collections import deque
ans = deque()

for s in S:
    ans.append(s)

rev = False
for _ in range(Q):
    q = input().split()
    if q[0] == "1":
        rev = not rev
    else:
        is_right = (q[1] =="2") ^ rev
        if is_right:
            for s in q[2]:
                ans.append(s)
        else:
            for s in q[2]:
                ans.appendleft(s)
if rev:
    ans.reverse()
print("".join(ans))

Measured memory_bytes: 8820
n, m = map(int, input().split())
s = input()
if '1' * m in s:
    print(-1)
else:
    p = n
    t = []
    while p > 0:
        for r in range(m, 0, -1):
            if p - r >= 0 and s[p - r] == '0':
                t.append(r)
                p -= r
                break
    print(" ".join([str(r) for r in reversed(t)]))

Measured memory_bytes: 10484
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

ll f(ll b) {
    if (b == 2) return 1;
    if ((b & (b - 1)) == 0) return 0;
    ll t = 0;
    for (int i = 50; i >= 0; i--) {
        if (b & 1LL << i) {
            t = 1LL << i;
            break;
        }
    }
    b ^= t;
    return t * (b % 2) ^ f(b) ^ f(t);
}

int main() {
    ll a, b;
    cin >> a >> b;
    b++;

    cout << (f(b) ^ f(a)) << endl;

    //for (int i = 0; i < 5; i++) {
    //    cout << f(i) << endl;
    //}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdlib.h>

using namespace std;
int main(void){
    int N;
    int A[100000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    // 通常ルート
    int now=0;
    int sum=0;
    for(int i=0;i<N;i++){
        sum+=abs(now-A[i]);
        now=A[i];
    }
    sum+=abs(A[N-1]);
    
    int moto=0;
    int tugi=0;
    
    for(int i=0;i<N;i++){
        if(i==0){
            moto=abs(0-A[i])+abs(A[i+1]-A[i]);
            tugi=abs(A[i+1]);
            cout << sum-(moto-tugi) << endl;
            continue;
        }
        if(i==N-1){
            moto=abs(A[i-1]-A[i])+abs(0-A[i]);
            tugi=abs(A[i-1]);
            cout << sum-(moto-tugi) << endl;
            continue;
        }
        moto=abs(A[i-1]-A[i])+abs(A[i+1]-A[i]);
        tugi=abs(A[i+1]-A[i-1]);
        cout << sum-(moto-tugi) << endl;
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
#define MAXN 450
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int A[MAXN];
int dp[MAXN][MAXN];

int solve(int i,int j){
		if(i==j)return 0;
		if(dp[i][j]!=-1)return dp[i][j];
		
		int res=1000000000;
		res*=MAXN;
		res*=MAXN;
	for(int k=i;k<j;k++){
		int atual = A[j]-A[i-1] + solve(i,k) + solve(k+1,j);
		res=min(res,atual);
	}
		
		return dp[i][j]=res;
		
}

int32_t main(){
	fastio;
	memset(dp,-1,sizeof(dp));
	int n;
	cin>>n;
	A[0]=0;
	for(int i=1;i<=n;i++){
		cin>>A[i];
		A[i]+=A[i-1];
	}
	cout<<solve(1,n)<<endl;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;


int main() {
    ll n, k;
    scanf("%lld%lld", &n, &k);
    ll ans = 0;
    //kが奇数の時は、abc全部kの倍数の時のみ
    //kが偶数だと、abcすべて、kで割ってk/2余るのでもいい
    if (k%2 == 1) {
        ans += (n/k) * (n/k) * (n/k); 
    } else {
        ans += (n/k) * (n/k) * (n/k);
        ans += ((n+k/2)/k) * ((n+k/2)/k) * ((n+k/2)/k);
    }
    printf("%lld", ans);
    return 0;
} 

Measured memory_bytes: 256
#33
import sys
A,B = map(int,input().split())
S = input()
Ans = "No"
if S[A] != "-":
    print(Ans)
    sys.exit()
    
for i in range(A):
    if S[i] == "-":
        print(Ans)
        sys.exit()

for i in range(A+1,A+B+1):
    if S[i] == "-":
        print(Ans)
        sys.exit()

Ans = "Yes"
print(Ans)



Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n,pos[maxn],a[maxn];
#define mid (l+r>>1)
#define ls u<<1
#define rs u<<1|1
#define lc ls,l,mid
#define rc rs,mid+1,r
int l[maxn],r[maxn];

void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		pos[a[i]]=i;
		l[i]=i-1;
		r[i]=i+1;
	}
	l[0]=-1;
	r[0]=1;
	l[n+1]=n;
	r[n+1]=n+2;
	
	ll ans=0;
	for(int i=1,tmp,L,R,ll,rr;i<=n;++i){
		L=l[pos[i]];
		R=r[pos[i]];
		if(L<=0&&R>n)goto G;
		else if(L<=0){
			rr=r[R];
			tmp=(pos[i]-L)*(rr-R);
		}
		else if(R>n){
			ll=l[L];
			//cerr<<R-pos[i]<<"   "<<L-ll<<endl;
			tmp=(R-pos[i])*(L-ll);
		}
		else{
			rr=r[R];
			ll=l[L];
			tmp=(pos[i]-L)*(rr-R);
			tmp+=(R-pos[i])*(L-ll);
		}
		//cerr<<i<<" "<<tmp<<endl;
		//cerr<<tmp<<endl;
		ans=ans+1ll*i*tmp;
		
		G:;
		l[r[pos[i]]]=l[pos[i]];
		r[l[pos[i]]]=r[pos[i]];
	}
	cout<<ans<<endl;
}
int main(){
	solve();
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;

    while (b <= a) {
        --k;
        b *= 2;
    }

    while (c <= b) {
        --k;
        c *= 2;
    }

    cout << (k >= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3648