akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<string> v(2);
  vector<vector<ll>> v2(2,vector<ll>(n+2,0));
  rep(i,2){
    cin >> v[i];
  }
  ll x = 0;
  ll ans = 1;
  if(v[0][0] == v[0][1]){
    ans = 6;
    x += 2;
  }
  else{
    ans = 3;
    x += 1;
  }
  while(x < n){
    if(v[0][x] == v[1][x]){
      if(v[0][x-1] == v[1][x-1]){//1
        ans = (ans * 2) % mod;
        ++x;
      }
      else{//2
        ans = (ans * 1) % mod;
        x += 1;
      }
    }
    if(v[0][x] != v[1][x]){
      if(v[0][x-1] == v[1][x-1]){//3
        ans = (ans * 2) % mod;
        x += 2;
      }
      else{//4
        ans = (ans * 3) % mod;
        x += 2;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair<INT, INT> II;
typedef long long LL;
const string OUT[3] = {
	"perfect number",
	"deficient number",
	"abundant number"
};
LL N;
bool input() {
	return cin >> N && N;
}
int solve() {
	LL sum = 0;
	for ( LL i = 1; i * i < N; ++ i ) {
		if ( N % i == 0 ) {
			if ( i != N / i && i != 1 ) {
				sum += i + N / i;
			} else {
				sum += i;
			}
		}
	}
	if ( N == sum ) return 0;
	return N < sum ? 2 : 1;
}
void output( int result ) {
	cout << OUT[result] << endl;
}
int main() {
    while ( input() ) {
        output( solve() );
    }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll x;cin >>x;
  ll ans = 0;
  ll money = 100;
  while(money < x){
    ans++;
    money *= 1.01;
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 3644
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0276();
	}
	
	class AOJ0276{
		public AOJ0276() {
			while(in.hasNext()){
				int a = in.nextInt();
				int b = in.nextInt();
				System.out.println(a-b);
			}
		}
	}


}

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

class Node{
    public:
    int location;
    int p,l,r;
    Node(){}
};

class Point{
    public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y): id(id),x(x),y(y){}
    bool operator < (const Point &p) const{
        return id < p.id;
    }
    void print(){
        printf("%d\n",id);//cout より　高速な printfを使っている
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){
    return p1.x < p2.x;
}
bool lessY(const Point &p1,const Point &p2){
    return p1.y < p2.y;
}

int makeKDTree(int l,int r,int depth){
    if(!(l<r)) return NIL;
    int mid = (l+r)/2;
    int t = np++;
    if(depth%2==0){
        sort(P+l,P+r,lessX);
    }else{
        sort(P+l,P+r,lessY);
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l,mid,depth+1);
    T[t].r = makeKDTree(mid+1,r,depth+1);
    return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if(sx <= x && x <= tx && sy <= y && y <= ty){
        ans.push_back(P[T[v].location]);
    }
    if(depth%2 == 0){
        if(T[v].l != NIL){
            if(sx <= x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[v].r != NIL){
            if(x <= tx) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
        }
    }else{
        if(T[v].l != NIL){
            if(sy <= y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[v].r != NIL){
            if(y <= ty) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
        }
    }
}

int main(){
    int x,y;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d %d",&x,&y);
        P[i] = Point(i,x,y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;

    int root = makeKDTree(0,N,0);
    //std::cout << "root:" << root << std::endl;
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    for(int i=0;i<q;i++){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j=0;j<ans.size();j++){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;

}


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

using ll=long long;



void solve(){
    int n;
    int a,b;
    cin>>n>>a>>b;

    if(n==1)cout<<"Hello World"<<endl;
    else cout<<a+b<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
import math
a, b, x=map(int,input().split())
if x <= ((a**2)*b)/2:
    y = (2*x)/(a*b)
    print(90-math.degrees(math.atan(y/b)))
else:
    z = 2*(a*a*b-x)/(a*a)
    print(math.degrees(math.atan(z/a)))


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, c, k;
	cin >> n >> c >> k;
	vector<int> t(n);
	for(int i = 0; i < n; ++i){ cin >> t[i]; }
	sort(t.begin(), t.end());
	int answer = 1;
	for(int i = 0, j = 0; i < n; ++i){
		if(t[i] > t[j] + k || (i - j) == c){
			++answer;
			j = i;
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        a: [i64; 5],
    }

    let m = *a.iter().min().unwrap();

    let ans = (n + m - 1) / m + 4;

    println!("{}", ans);
}


Measured memory_bytes: 4352
// finish date: 2019/1/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//fact定義
vi fact;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int modpow(int a, int b) {
    if (b == 0) return 1;
    int temp = modpow(a, b / 2);
    if (b % 2 == 1) return mul(mul(temp, temp), a);
    else {
        return mul(temp, temp);
    }
}


//割り算(分母だけ)  -  逆元(求めたい数とbigmodを渡す)
int divide(int a, int p = bigmod, int b = -1) {
    if (b < 0) b = p - 2;  //int gyakugen(int a, int p, int b = p - 2とできなかったため。)
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        int d = divide(a, p, b / 2);
        return mul(d, d);
    } else {
        return mul(a, divide(a, p, b - 1));
    }
}

//nやkが大きな場合nCkをO(1)で求めるようにプログラムを適切に変更する。
int nCk_gyakugen(int n, int k, int p = bigmod) {
    if (k == 0) return 1;
    if (n == 0) 0;
    if (n < k) return 0;
    int denominator = fact[n];
    int molecule1 = fact[k];
    int molecule2 = fact[n - k];
    return mul(denominator, mul(divide(molecule1), divide(molecule2)));
}


int main() {
    int N, K;
    cin >> N >> K;
    vi A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    //fact定義
    fact = vi(N + 1, 0);
    fact[0] = 1;
    FOR(i, 1, fact.size()) {
        fact[i] = mul(fact[i - 1], i);
    }

    ll total = 0;
    rep(i, N) {
        if (N - i >= K) {
            total = sub(total, mul(A[i],nCk_gyakugen(N - i - 1, K - 1)));
        }
        if (i + 1 >= K) {
            total = add(total, mul(A[i],nCk_gyakugen(i + 1 - 1, K - 1)));
        }
    }
    cout << total << endl;

    return 0;
}


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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

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


int main() {
  
  int Tc; cin >> Tc;
  int grid[5][5];
  
  while(Tc--) {
    rep(i, 5) rep(j, 5) cin >> grid[i][j];
    int ans = 0;
    rep(i, 5) {
      rep(j, 5) {
	REP(k, i, 5) {
	  REP(l, j, 5) {
	    bool ok = true;
	    REP(a, i, k+1) {
	      REP(b, j, l+1) {
		if(grid[a][b] == 0) {
		  ok = false;
		  break;
		}
	      }
	      if(!ok) break;
	    }
	    if(ok) ans = max(ans, (k-i+1)*(l-j+1));
	  }
	}
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		List<int[]> ab = new ArrayList<>();
		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			ab.add(new int[] {a, b, b-a});
		}
		sc.close();
		
//		ab.sort((x,y) -> Integer.compare(x[2], y[2]));
//		
//		int t = 0;
//		for(int i=0;i<N;i++) {
//			int a = ab.get(i)[0];
//			int b = ab.get(i)[1];
//			t += a;
//			if(t>b) {
//				out.println("No");
//				return;
//			}
//		}
//		
//		out.println("Yes");

		Comparator<int[]> c1 = (x,y) -> Integer.compare(x[1], y[1]);
		Comparator<int[]> c2 = c1.thenComparing((x,y) -> Integer.compare(x[0], y[0]));
		ab.sort(c2);
		
		int t = 0;
		for(int i=0;i<N;i++) {
			int a = ab.get(i)[0];
			int b = ab.get(i)[1];
			t += a;
			if(t>b) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
		
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 104748
queue=[]
ans=''
al=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
cou=-1

while 1:
    try:
        string=input().lower()
        queue.append(string)
    except EOFError:
        break
    
for i in queue:
    ans+=i

for i in al:
    cou+=1
    print(al[cou]+' '+ ':'+' '+str(ans.count(i)))


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

int main(){
  string s;
  cin >>s;
  string s1 = "YAKI";
  bool can = true;
  rep(i,4){
    if(s[i]!=s1[i]) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main()
{
    int N, L, S;
    while(cin>>N, N) {
        vector<int> v(4);
        int ans = N;
        for(int i=0; i<4; i++) {
            v[i] = ans%10;
            ans /= 10;
        }
        if(v[0]==v[1] && v[1]==v[2] && v[2]==v[3]) {
            cout<<"NA\n";
            continue;
        }
        while(N != 6174) {
            ans++;
            for(int i=0; i<4; i++) {
                v[i] = N%10;
                N /= 10;
            }
            sort(v.begin(), v.end());
            L = v[0]*1 + v[1]*10 + v[2]*100 + v[3]*1000;
            S = v[3]*1 + v[2]*10 + v[1]*100 + v[0]*1000;
            N = L-S;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1216
import java.util.*;

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

        int r = sc.nextInt();
        int D = sc.nextInt();
        int[] x = new int[11];
        x[0] = sc.nextInt();

        for(int i=1; i<=10; i++){
            x[i] = x[i-1] * r - D;
            System.out.println(x[i]);
        }

    }
}

Measured memory_bytes: 22228
from fractions import gcd

def prime_factors(n):
    lst = []
    while n % 2 == 0:
        lst.append(2)
        n //= 2
    while n % 3 == 0:
        lst.append(3)
        n //= 3
    f = 5
    limit = int(n ** .5)
    while f <= limit:
        while n % f == 0:
            lst.append(f)
            n //= f
        f += 2
    if n != 1:
        lst.append(n)
    return lst

a, b = map(int, input().split())
print(len(set(prime_factors(gcd(a, b)))) + 1)

Measured memory_bytes: 5688
#include <bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long int ll;
ll A[SIZE],B[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	cin >>A[i];
	for(int i=0;i<n;i++)
	cin >>B[i];
	ll sa=0,sb=0;
	for(int i=0;i<n;i++)
	{
		sa+=A[i];
		sb+=B[i];
	}
	if(sa<sb)
	{
		puts("-1");
		return 0;
	}
	int cnt=0;
	ll d=0;
	vector <ll> vx;
	for(int i=0;i<n;i++)
	{
		if(A[i]<B[i])
		{
			d+=B[i]-A[i];
			cnt++;
		}
		else
		vx.push_back(A[i]-B[i]);
	}
	sort(vx.begin(),vx.end(),greater <ll>());
	for(int i=0;i<vx.size();i++)
	if(d>0)
	{
		d-=vx[i];
		cnt++;
	}
	cout <<cnt<<endl;
	return 0;
}

Measured memory_bytes: 2808
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> >g(n + 3);
    vector<int>p(n + 3), vis(n + 3, 0);
    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int r = 1;
    queue<int>q;
    q.push(1);
    vis[1] = 1;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(auto v : g[u]){
            if(vis[v] == 0){
                vis[v] = 1;
                r++;
                p[v] = u;
                q.push(v);
            }
        }
    }
    if(r == n){
        cout << "Yes\n";
        for(int i = 2; i <= n; i++){
            cout << p[i] << '\n';
        }
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 10736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,K;
    cin >> N >> K;
    vector<bool> hate(10);
    for(int i = 0;i < K;i++) {
        int A;
        cin >> A;
        hate.at(A) = true;
    }
    for(int i = N;i < 1000000000;i++) {
        int cnt = i;
        bool cnt2 = true;
        while(cnt > 0) {
            if(hate.at(cnt % 10) == true) {
                cnt2 = false;
                break;
            }
            cnt /= 10;
        }
        if(cnt2 == true) {
            cout << i << endl;
            break;
        }
    }
}

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

int num_spot;
#define ARRAY_SIZE 1000000
int array[ARRAY_SIZE];
int normal_length[ARRAY_SIZE];
int skip_length[ARRAY_SIZE];

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

#define QUEUE_SIZE 0x10000
typedef int Item;
Item queue[QUEUE_SIZE];
size_t queue_in = 0;
size_t queue_out = 0;
int queue_is_full = 0;

size_t inc_queue_index(size_t index)
{
  return (index + 1) % QUEUE_SIZE;
}

void queue_push(const Item* item)
{
  if(queue_is_full) {
    fputs("Queue is full.\n", stderr);
    exit(1);
  }
  memcpy(&queue[queue_in], item, sizeof(Item));
  queue_in = inc_queue_index(queue_in);
  queue_is_full = queue_in == queue_out;
}

void queue_pop(Item* result)
{
  if(queue_in == queue_out && !queue_is_full) {
    fputs("Queue is empty.\n", stderr);
    exit(1);
  }
  memcpy(result, &queue[queue_out], sizeof(Item));
  queue_out = inc_queue_index(queue_out);
  queue_is_full = 0;
}

void clear_queue()
{
  queue_in = 0;
  queue_out = 0;
  queue_is_full = 0;
}

void compute_normal_length()
{
  for(int i = 0; i <= num_spot; i++) {
    normal_length[i] = abs(array[i] - array[i+1]);
  }
}

void compute_skip_length()
{
  for(int i = 1; i <= num_spot; i++) {
    skip_length[i] = abs(array[i+1] - array[i-1]);
  }
}

long long compute_total_length()
{
  long long total_length = 0;
  for(int i = 0; i <= num_spot; i++) {
    total_length += normal_length[i];
  }
  return total_length;
}

long long compute_skip_total_length(long long total_length, int index)
{
  long long result = total_length;
  result += skip_length[index] - normal_length[index-1] - normal_length[index];
  return result;
}

int main()
{
  scanf("%d", &num_spot);
  array[0] = 0;
  for(int i = 1; i <= num_spot; i++) {
    scanf("%d", &array[i]);
  }
  array[num_spot+1] = 0;

  compute_normal_length();
  compute_skip_length();
  long long total_length = compute_total_length();
  for(int i = 1; i <= num_spot; i++) {
    printf("%lld\n", compute_skip_total_length(total_length, i));
  }

  return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

template<class F>
i64 bisect(i64 l, i64 r, F f) { // (l, r]
  if (r - l <= 1) return r;
  i64 m = l + (r - l) / 2;
  return f(m) ? bisect(l, m, f) : bisect(m, r, f);
}

i64 n, k;
vector<i64> a;

int main() {
  cin >> n >> k;
  read_n(a, n);
  sort(begin(a), end(a));

  i64 x = bisect(-1, n, [&](i64 l) {
    if (l == n) return true;
    vector<int> dp(k + 1);
    dp[0] = 1;
    for (i64 i = 0; i < n; ++i) {
      if (i == l) continue;
      auto dp_new = dp;
      for (i64 j = 0; j + a[i] < k; ++j) {
        dp_new[j + a[i]] |= dp[j];
      }
      dp = dp_new;
    }
    for (i64 j = k - 1; j >= k - a[l]; --j) {
      if (dp[j] > 0) return true;
    }
    return false;
  });

  cout << x << endl;
  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val(h,w) = readLine()!!.split(" ").map { it.toInt() }
    val s = (1..h).map { readLine()!! }
    val board = Array(h+2){ BooleanArray(w+2) }
    for(i in 1..h)for(j in 1..w) board[i][j]=s[i-1][j-1]=='#'

    val sb = StringBuilder()
    for(i in 1..h){
        for(j in 1..w){
            if(board[i][j]) {
                sb.append("#")
            } else {
                (-1..1).map { dx ->
                    (-1..1).map { dy ->
                        board[i + dy][j + dx]
                    }
                }.flatten().count { it == true }.let { sb.append(it) }
            }
        }
        sb.append("\n")
    }
    println(sb)
}

Measured memory_bytes: 42488
#include<stdio.h>

#define MOD 1000000007
#define ll long long int

int pm(int x,ll y){
    ll a=1;
    for(int i=0;i<y;i++){
        a*=x;
        a%=MOD;
    }
    return a;
}

int main(){
    ll n;
    scanf("%lld",&n);

    ll sum=pm(10,n)-2*pm(9,n)+pm(8,n);
    sum%=MOD;
    sum=(sum+MOD)%MOD;
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1696
#include<stdio.h>

int main(void){
        int w, h, x, y, r;
        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

        if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h) puts("Yes");
        else puts("No");
        return 0;
}


Measured memory_bytes: 2120
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i, c) for(int i = 0; i < int(c); i++)

using namespace std;

int main() {
  string r,b,u;
  int i, k;
  cin >> r >> b >> i >> k >> u;
  if (r==u) i--;
  else k--;
  cout << i << " " << k << endl;
}


Measured memory_bytes: 888
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()

    val ans = IntArray(n){0}
    repeat(n-1) {
        ans[sc.nextInt()-1]++
    }

    ans.forEach {
        println(it)
    }
}


Measured memory_bytes: 61256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int input, ans = 0;
    cin >> input ;
    
    vector<int> cnt(input + 2);
    int num;
    
    for(int i = 0; i < input; i++){
        cin >> num;
        if(num <= input){
            cnt.at(num)++;
        } else {
            cnt.at(input + 1)++;
            ans++;
        }
    }
    
    for(int i = 0; i <= input; i++){
        if(cnt.at(i) < i){
            ans += cnt.at(i);
        } else if (cnt.at(i) > i){
            ans += cnt.at(i) - i;
        }
    }
    
    cout << ans << endl;
    
    return 0;    
}


Measured memory_bytes: 3728
let N = Int(readLine()!)!
var graph: [[Int]] = .init(repeating: [], count: N + 1)

for _ in 0..<N-1 {
  let input = readLine()!.split(separator: " ").map { Int($0)! }
  let x = input[0]
  let y = input[1]
  graph[x].append(y)
  graph[y].append(x)
}
let mod = 1000000007
var dp: [(white: Int, black: Int)] = .init(repeating: (-1, -1), count: N+1)

print(dfs(1, graph, &dp, mod))

func dfs(_ i: Int, _ graph: [[Int]],
         _ dp: inout [(white: Int, black: Int)], _ mod: Int) -> Int {
  if dp[i] != (-1, -1) {
    return (dp[i].white + dp[i].black) % mod
  }
  dp[i] = (1, 1)
  for nei in graph[i] {
    if dp[nei] != (-1, -1) {
      continue
    }
    _ = dfs(nei, graph, &dp, mod)
    dp[i].white = dp[i].white * (dp[nei].white + dp[nei].black) % mod
    dp[i].black = dp[i].black * dp[nei].white % mod
  }
  return (dp[i].black + dp[i].white) % mod
}



Measured memory_bytes: 27020
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	double t, a, h, now, min = 100000;
	int n, ans;
	cin >> n >> t >> a;
	for (int i = 0; i < n; ++i)
	{
		cin >> h;
		now = abs(a - (t - h * 0.006));
		if (now < min)
		{
			min = now;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    using namespace std;
    int n;
    cin >> n;
    int given, cnt;
    cnt = 0;
    for (int i=1; i<=n; i++){
        cin >> given;
        if (given != i) cnt++;
    }
    if (cnt == 2 || cnt == 0) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long;
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main()
{
	int n;
	int a[100000];
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	int b[100001] = {};
	for (i = 0; i < n; i++){
		b[a[i]]++;
		b[a[i] + 1]++;
		b[a[i] + 2]++;
	}
	int max = 0;
	for (i = 0; i < 100001; i++){
		if (max < b[i]){
			max = b[i];
		}
	}
	cout << max << endl;
	return 0;
}

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

int main() {
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (S == U) {
		cout << A-1<<" " <<B<< endl;
	}
	else {
		cout << A << " " << B-1 << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    double n;
    cin >> n;
    double odd;
    if (static_cast<int>(n) % 2 == 0) {
        odd = n / 2;
    } else {
        odd = (n + 1) / 2;
    }
    cout << odd / n << endl;
}


Measured memory_bytes: 256
arr = gets.chomp.split(' ').map(&:to_i)
a = []
b = 1..arr[0]
c = b.collect{|i| i}
d = []
arr[1].times do
  n = gets.to_i
  abc = gets.chomp.split(' ').map(&:to_i)
  d = d | abc
end
print (c - d).size



Measured memory_bytes: 14376
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s.length() % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < s.length() / 2; i++)
    {
        if (s.substr(2 * i, 2) != "hi")
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int n, a[2010][2010], k;

int main(void) {
	for(k = 1; k * (k - 1) + 1 < 1334; k++);
	n = k * (k - 1) + 1;
	for(int i = 1, p = 2; i <= k; i++) {
		a[i][1] = 1;
		for(int j = 2; j <= k; j++)
			a[i][j] = p++;
	}
	for(int i = k + 1, p = 0; i <= n; i++) {
		int w = (i - k - 1) / (k - 1) + 2;
		a[i][1] = w;
		for(int j = 2, o = (i - k - 1) % (k - 1); j <= k; j++, o = (o + p) % (k - 1))
			a[i][j] = a[j][o + 2];
		if((i - k - 1) % (k - 1) == (k - 2)) p++;
	}
	printf("%d %d\n", n, k);
	for(int i = 1; i <= n; i++, puts(""))
		for(int j = 1; j <= k; j++)
			printf("%d ", a[i][j]);
	return 0;
}

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

int main(){
    long N, M;
    cin >> N >> M;
    vector<pair<long, long>> S(N);
    for(auto& i : S)cin >> i.first >> i.second;
    sort(S.begin(), S.end());

    long ans(0);
    for(const auto& i : S){
        long k = min(M, i.second);
        ans += k * i.first;
        M -= k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def kansu(s):
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
    return s

s = int(input())
ansFlg = True

if s == 4 or s == 1 or s == 2:
    print(4)
    exit()

ans = 1
while ansFlg:
    if s == 4:
        ans += 3
        break
    s = kansu(s)
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;
const int N_MAX = pow(10,5);

int p_nums[N_MAX+1] = {};

void sieve() {
  bool IsPrime[N_MAX+1];
  rep(i, N_MAX+1) IsPrime[i] = true;
  IsPrime[0] = false;
  IsPrime[1] = false;
  for (int i=2; i*i<=N_MAX; i++) {
    if (IsPrime[i]) {
      for (int j=2; i*j<=N_MAX; j++) {
        IsPrime[i*j] = false;
      }
    }
  }
  for(int i=3; i<= N_MAX; i+=2) {
    if ( IsPrime[i] && IsPrime[(i+1)/2] ) p_nums[i] = p_nums[i-2]+1;
    else p_nums[i] = p_nums[i-2];
  }
}

int main() {
  sieve();
  int Q; cin >> Q;
  rep(i, Q) {
    int l, r; cin >> l >> r;
    int result = p_nums[r] - p_nums[max(1, l-2)];
    cout << result << endl;
  }
  return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int res = x / 500 * 1000;
  x %= 500;
  res += x / 5 * 5;
  cout << res << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
const ll MOD=1e9+7;

/*

*/

int main(void){
	ll mdp[1000010],cdp[1000010],p[1000010];//累積和
	mdp[0]=0;
	cdp[0]=0;
	p[0]=0;
	int n,q,x[110];
	vector<int>d,m,c;
	string s;
	cin>>n;
	cin>>s;
	cin>>q;
	rep(i,q)cin>>x[i];
	s=" "+s;
	reg(i,1,n){
		mdp[i]=mdp[i-1];
		cdp[i]=cdp[i-1];
		p[i]=p[i-1];
		if(s[i]=='D'){
			d.push_back(i);
		}else if(s[i]=='M'){
			m.push_back(i);
			mdp[i]++;
		}else if(s[i]=='C'){
			c.push_back(i);
			cdp[i]++;
			p[i]+=mdp[i];
		}
	}
	// cout<<"d ";
	// rep(i,d.size())cout<<d[i]<<" ";
	// cout<<endl;
	// cout<<"m ";
	// rep(i,m.size())cout<<m[i]<<" ";
	// cout<<endl;
	// cout<<"c ";
	// rep(i,c.size())cout<<c[i]<<" ";
	// cout<<endl;
	//DMC
	rep(i,q){
		ll ans=0;
		rep(k,d.size()){
			ans+=p[min(d[k]+x[i]-1,n)] - p[d[k]] - (mdp[d[k]]) * (cdp[min(d[k]+x[i]-1,n)]-cdp[d[k]]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 29736
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
ass = []
tmp = ''
cnt = 0
for i in range(n):
    if i == 0:
        tmp = s[i]
        cnt = 1
        continue
    if tmp == s[i]:
        cnt += 1
    else:
        tmp = s[i]
        ass.append(cnt)
        cnt = 1
ass.append(cnt)
l = len(ass)
res = 0
if s[0] == '<':
    for i in range(l)[::2]:
        if i == l-1:
            res += (ass[i]+1)*ass[i]//2
            continue
        mm = max(ass[i],ass[i+1])
        nn = min(ass[i],ass[i+1])
        # print(mm,nn)
        res += (mm+1)*mm//2 + (nn-1)*nn//2
else:
    res += (ass[0]+1)*ass[0]//2
    for i in range(1,l)[::2]:
        if i == l-1:
            res += (ass[i]+1)*ass[i]//2
            continue
        mm = max(ass[i],ass[i+1])
        nn = min(ass[i],ass[i+1])
        res += (mm+1)*mm//2 + (nn-1)*nn//2
print(res)

Measured memory_bytes: 55580
import java.util.Scanner;

public class Main {

	private final static String[] S = new String[]{
			"SUN","MON","TUE","WED","THU","FRI","SAT"
			};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		for(int i = 0;i < S.length;i++){
			if(s.equals(S[i])){
				System.out.println(7-i);
				break;
			}
		}
	}

}

Measured memory_bytes: 24404
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define DEBUG(x) cout << #x << " : " << x << endl;
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
//check the limits, man
// read the constraint properly (ll vs int)
const int N = 1005;
typedef long long int ll;
vvi ad(N);
int vis[N],par[N],lev[N];
int dp[N][N];
int order[N];
vi ans;
int cycle;
void path(int s,int p)
{
    if(cycle)
        return ;
    cycle=1;
    int i,j,a,k=0;
    while(s!=p)
        order[k++]=s,s=par[s];
    order[k++]=s;
    reverse(order,order+k);
    i=0;
    while(i<k)
    {
        a=k;
        lp(j,i+1,k)
            if(dp[order[i]][order[j]])a=j;
        ans.pb(order[i]);
        i=a;
    }
    return ;
}
void dfs(int s)
{
    int i,a,x=ad[s].size();
    vis[s]=1;
    int b=-1,m=-1;
    rep(i,x)
    {
        a=ad[s][i];
        if(vis[a]==1)
        {
            if(lev[a]>m)
                b=i,m=lev[a];
        }
    }
    if(b>=0)
        path(s,ad[s][b]);
    rep(i,x)
    {
        a=ad[s][i];
        if(vis[a]==0)
            par[a]=s,lev[a]=lev[s]+1,dfs(a);
    }
    vis[s]=2;
    return ;
}
int main()
{
    int n,m,a,b,i;
    in2(n,m);
    while(m--)
    {
        in2(a,b);
        a--,b--;
        ad[a].pb(b);
        dp[a][b]=1;
    }
    rep(i,n)
        if(vis[i]==0)par[i]=-1,dfs(i);
    if(cycle)
    {
        out(ans.size());
        n=ans.size();
        rep(i,n)
            out(ans[i]+1);
    }
    else
        out(-1);

}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC139A()
{
	string S, T;
	cin >> S;
	cin >> T;
	int ct = 0;
	for (int i = 0; i < 3; ++i)
	{
		if (S[i] == T[i])
			++ct;
	}
	cout << ct << endl;
}

int main()
{
	ABC139A();
	return 0;
}

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

#define ll long long int

using namespace std;

int main()
{
     ll n,i,j,s=0,x;
     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>x;
         s+=x;
     }
     cout<<s-n<<endl;
    return 0;
}




Measured memory_bytes: 3636
program main
	implicit none
	character(100010) :: s
	integer :: K, i
	
	read(*, *) s
	read(*, *) K
	
	do i = 1, len_trim(s)
		if(K-search(s(i:i)) >= 0) then
			K = K - search(s(i:i))
			s(i:i) ="a"
		end if
	end do
	s(len_trim(s):len_trim(s)) = search_out(mod((26-(search(s(len_trim(s):len_trim(s)))-mod(K,26))),26))
	
	write(*, *) trim(s)
	
	contains
	integer function search(moji)
		character(1) :: moji
		if(moji == "a")  search = 0
		if(moji == "b")  search = 25
		if(moji == "c")  search = 24
		if(moji == "d")  search = 23
		if(moji == "e")  search = 22
		if(moji == "f")  search = 21
		if(moji == "g")  search = 20
		if(moji == "h")  search = 19
		if(moji == "i")  search = 18
		if(moji == "j")  search = 17
		if(moji == "k")  search = 16
		if(moji == "l")  search = 15
		if(moji == "m")  search = 14
		if(moji == "n")  search = 13
		if(moji == "o")  search = 12
		if(moji == "p")  search = 11
		if(moji == "q")  search = 10
		if(moji == "r")  search = 9
		if(moji == "s")  search = 8
		if(moji == "t")  search = 7
		if(moji == "u")  search = 6
		if(moji == "v")  search = 5
		if(moji == "w")  search = 4
		if(moji == "x")  search = 3
		if(moji == "y")  search = 2
		if(moji == "z")  search = 1
	end function search
	
	character(1) function search_out(kazu)
		integer :: kazu
		if(kazu == 0)  search_out = "a"
		if(kazu == 1)  search_out = "b"
		if(kazu == 2)  search_out = "c"
		if(kazu == 3)  search_out = "d"
		if(kazu == 4)  search_out = "e"
		if(kazu == 5)  search_out = "f"
		if(kazu == 6)  search_out = "g"
		if(kazu == 7)  search_out = "h"
		if(kazu == 8)  search_out = "i"
		if(kazu == 9)  search_out = "j"
		if(kazu == 10)  search_out = "k"
		if(kazu == 11)  search_out = "l"
		if(kazu == 12)  search_out = "m"
		if(kazu == 13)  search_out = "n"
		if(kazu == 14)  search_out = "o"
		if(kazu == 15)  search_out = "p"
		if(kazu == 16)  search_out = "q"
		if(kazu == 17)  search_out = "r"
		if(kazu == 18)  search_out = "s"
		if(kazu == 19)  search_out = "t"
		if(kazu == 20)  search_out = "u"
		if(kazu == 21)  search_out = "v"
		if(kazu == 22)  search_out = "w"
		if(kazu == 23)  search_out = "x"
		if(kazu == 24)  search_out = "y"
		if(kazu == 25)  search_out = "z"
	end function search_out
end program main

Measured memory_bytes: 700
#include<stdio.h>
#include<stdlib.h>
#define N 100000

int line1[N],line2[N];

int main(){
  int i,left=0,right,mid,point1,point2,n=0;
  scanf("%d",&point1);
  for(i=0 ; i<point1 ; i++){
    scanf("%d",&line1[i]);
  }
  scanf("%d",&point2);
  for(i=0 ; i<point2 ; i++){
    scanf("%d",&line2[i]);
  }
  for(i=0 ; i<point2 ; i++){
    left=0;
    right = point1;
    while(left<right){
      mid = (left+right)/2;
      if(line2[i] == line1[mid]){
	n++;
	break;
      }
      if(line2[i] > line1[mid]) left = mid+1;
      else if(line2[i] < line1[mid]) right = mid;
    }
  }
  printf("%d\n",n);
  return 0;
}



Measured memory_bytes: 2328
#include<stdio.h>
#include<string.h>
const long long int mod = 1000000007;
char s1[200],s2[200];
int a[100];
int main(){
	int n,i,top=1;
	long long ans=0;
	scanf("%d",&n);
	scanf("%s",s1);
	scanf("%s",s2);
	for(i=0;i<n;i++){
		if(s1[i]==s2[i]) {a[top]=1;top++;}
		else {a[top]=2;top++;i++;}
	}
	if(a[1]==1) ans=3;
	else ans=6;
	for(i=2;i<top;i++) {
		if(a[i]==1&&a[i-1]==1) {ans=1ll*ans*2;ans%=mod;}
		if(a[i]==1&&a[i-1]==2) {ans%=mod;}
		if(a[i]==2&&a[i-1]==1) {ans=1ll*ans*2;ans%=mod;}
		if(a[i]==2&&a[i-1]==2) {ans=1ll*ans*3;ans%=mod;}
		}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
string s, t;
vector<int> vec[26];
signed main() {
	cin >> s >> t;
	rep(i, s.size())vec[s[i] - 'a'].push_back(i);
	int ans = 0;
	rep(i, t.size()) {
		if (vec[t[i] - 'a'].empty()) {
			cout << -1 << endl;
			return 0;
		}
		int p = (ans-1) % (int)s.size();
		auto next = upper_bound(vec[t[i] - 'a'].begin(), vec[t[i] - 'a'].end(), p);
		if (next == vec[t[i] - 'a'].end())ans = (ans + (int)s.size() - 1) / (int)s.size() * (int)s.size() + vec[t[i] - 'a'][0]+ 1;
		else ans = ans / s.size() * s.size() + *next + 1;
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
  ll n; cin >> n;
  ll sum = 0;
  set <ll> can;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      can.insert(i), can.insert(n / i);
    }
  }
  for(auto x : can) {
    if(x == 1) continue;
    ll c= x - 1;
    if((n / c) == n % c) sum += c;
  }
  cout << sum << '\n';
}

Measured memory_bytes: 512
import sys
N = int(input())
K = []
for i in range(N):
    a, b = map(int, input().split())
    K.append([a, b])
for i in range(N-2):
    if K[i][0] == K[i][1] and K[i+1][0] == K[i+1][1] and K[i+2][0] == K[i+2][1]:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 62396
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,d,a;
    cin>>n>>d>>a;
    pair<ll,int> mon[n];
    for(int i=0;i<n;i++){
        int x,h;
        cin>>x>>h;
        mon[i]={x,h};
    }
    sort(mon,mon+n);
    int r[n];
    for(int i=0;i<n;i++){
        ll x=mon[i].first;
        auto it=upper_bound(mon,mon+n,make_pair(x+2*d,INF));
        r[i]=it-mon;
    }
    ll ans=0;
    ll dm[n+1]={};
    for(int i=0;i<n;i++){
        if(i)dm[i]+=dm[i-1];
        ll hp=mon[i].second-dm[i];
        if(hp<=0)continue;
        ll c=(hp+a-1)/a;
        ans+=c;
        dm[i]+=c*a;
        dm[r[i]]-=c*a;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
//Equal Sum Sets
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int n, k, s;
ll cnt;
//x:ここから使える sum:これまでの合計 dep:残り深さ
void solve(int x, int sum, int dep){
  if(dep==0){
    if(s==sum)cnt++;
    return;
  }
  if(s<sum)return;
  for(int i=x; i<=n; i++){
    solve(i+1, sum+i, dep-1);
  }
}

int main(){
  while(true){
    cin>>n>>k>>s;
    if(n==0&&k==0&&s==0)break;
    cnt=0;
    solve(1, 0, k);
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int a,b,c;
int main(){
	inc>>a>>b>>c;
	int sum=c*3;
	printf("%d %d %d\n%d %d %d\n%d %d %d\n",a,b,sum-a-b,2*sum-2*a-b-2*c,c,2*a+b+c-sum,a+b+2*c-sum,sum-b-c,sum-a-c);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc165/tasks/abc165_a
 */

class Main {

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

        int k = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        System.out.println(canCarry(k, a, b) ? "OK" : "NG");

        scanner.close();

    }

    public static boolean canCarry(int k, int a, int b) {
        if (a % k == 0 || b % k == 0) return true;

        int c = a + (k - (a % k));
        if (c <= b) return true;
        return false;
    }
}

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

int main(int argc, char const *argv[])
{
	int n,m,x;
	cin>>n>>m>>x;
	int a,cnt1=0,cnt2=0;
	for (int i = 0; i < m; ++i)
	{
		cin>>a;
		if (a<x)
		{
			++cnt1;
		}
		else
		{
			++cnt2;
		}
	}
	cout<<min(cnt1,cnt2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i).first;
        A.at(i).second = i;
    }
    sort(A.begin(), A.end());
    for(int i = 0; i < N; i++){
        if(i == A.at(N - 1).second){
            cout << A.at(N - 2).first<< endl;
        }
        else{
            cout << A.at(N - 1).first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

//int cnt[1<<20];
map<int, int> cnt;
int32_t main(){ fast;
               string s, t; cin>>s>>t;
               int answer = 0;
               rep(i, sz(s)){
                   answer += (s[i] != t[i]);
                   
               }
               cout<<answer;
}


Measured memory_bytes: 3832