akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;
    
    vector<int> w(N+1);
    for(int i = 0; i < N; i++) {
        if (S[i] == '#') {
            w[i+1] = w[i] + 1;
        } else {
            w[i+1] = w[i];
        }
    }

    int ans = 2e5;
    for(int i = 0; i <= N; i++) {
        mins(ans, w[i]+N - i - (w[N]-w[i]));
    }

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

Measured memory_bytes: 1412
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef vector<int> vi;
typedef long double D;

int main(){
  int x,y,z;
  while(cin >> x >> y >> z, x){
    vi v(x);
    rep(i,x)cin >> v[i];

    vi e(y+1,0), a(y+1,0);
    rep(i,z){
      int n;
      cin >> n;
      cin >> e[n] >> a[n];
    }

    vector< vector<D> > prob(y+1, vector<D>(100*y+1,0));
    prob[0][0] = 1;

    rep(i,y){
      rep(j,100*y+1){
	rep(k,x){
	  int nxtp = min(y, i+v[k]);
	  int nxtm = j;
	  
	  if(e[nxtp] == 1){
	    nxtp = min(y, nxtp + a[nxtp]);
	  }else if(e[nxtp] == 2){
	    nxtm = min(100*y, j+a[nxtp]);	  
	  }else if(e[nxtp] == 3){
	    nxtm = max(0, j-a[nxtp]);	  
	  }

	  prob[nxtp][nxtm] += prob[i][j] / x;
	}
      }
    }

    D exp = 0;
    rep(i,100*y){
      exp += prob[y][i] * i;
    }
    cout << floor(exp) << endl;
  }
}

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

using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<long long int>
int main(){
   int n,x;
   cin >> n >> x;
   vector<int> d(n+1);
   vector<int> v(n);
   int ans=0;
   d[0]=0;
   for(int i=0;i<n;i++)
   	{   cin >>v[i];
        if(i)d[i]=d[i-1]+v[i-1];
   	}
   	d[n]=d[n-1]+v[n-1];
   	for(int x1:d){ans+=(x1<=x);}
 cout << ans;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 200100)

	N, mod := getInt(), getInt()
	S := getString()

	// 特殊処理
	if mod == 2 || mod == 5 {
		ans := 0
		for i := 0; i < N; i++ {
			val := int(S[i] - '0')
			if val%mod == 0 {
				ans += i + 1
			}
		}
		out(ans)
		return
	}

	m := make(map[int]int)
	cur := 0
	m[cur] = 1
	digit := 1
	ans := 0
	for i := N - 1; i >= 0; i-- {
		cur += digit * int(S[i]-'0')
		cur %= mod
		ans += m[cur]
		m[cur]++
		digit = digit * 10 % mod
	}
	out(ans)
}


Measured memory_bytes: 2048
//abc089_b.cpp
//Sun Mar  4 20:55:45 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

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

	string str;
	int gflag = 0;
	int wflag = 0;
	int yflag = 0;
	int pflag = 0;
	for (int i=0;i<n;i++){
		cin >> str;
		if (str=="G"){
			gflag++;
		}else if (str=="W"){
			wflag++;
		}else if (str=="Y"){
			yflag++;
		}else if (str=="P"){
			pflag++;
		}
	}

	int ans;

	if (gflag >= 1){
		ans++;
	}
	if (wflag >= 1){
		ans++;
	}
	if (yflag >= 1){
		ans++;
	}
	if (pflag >= 1){
		ans++;
	}

	if (ans==3){
		cout << "Three" << endl;
	}else if (ans==4){
		cout << "Four" << endl;
	}
}

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

int     main() {
        long A, B;
        cin >>A >>B;
        if (0!=(A+B)%2) {
                cout <<"IMPOSSIBLE" <<endl;
                return 0;
        }
        cout << (A+B)/2 << endl;
        return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

int A;
int B;
int C;

int main(){
	
	cin>>A>>B>>C;
	
	if( C-B == B-A ) puts("YES");
	else{		  puts("NO");}
	
	return 0;

}

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


int main(){
	
	int n;cin>>n;
	vector<tuple<int,int,int> > v(n);
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		v[i] = make_tuple(a,b,c);
	}
	vector<int> dp(3);
	dp[0] = get<0>(v[0]);
	dp[1] = get<1>(v[0]);
	dp[2] = get<2>(v[0]);
	
	for(int i=1;i<n;i++){
		vector<int> temp = dp;
		temp[0] = max(dp[2],dp[1]) + get<0>(v[i]);
		temp[1] = max(dp[0],dp[2]) + get<1>(v[i]);
		temp[2] = max(dp[0],dp[1]) + get<2>(v[i]);
		dp = temp;
	}
	int ans = max(dp[0],max(dp[1],dp[2]));
	cout<<ans;
	
	
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define REP(n)for(ll i=0;i<n;i++)
#define M make_pair
#define F first
typedef long long ll;
using namespace std;
int main(){
    ll n,k,s,t,a[50];cin>>n>>k>>s>>t;
    REP(n)cin>>a[i];
    map<pair<ll,ll>,ll> p[50];
    REP(n){
        for(ll j=k-2;j+1;j--){
            for(const auto&l:p[j]){
                p[j+1][M(l.first.first&a[i],l.first.second|a[i])]+=l.second;
            }
        }
        p[0][M(a[i],a[i])]=1;
    }
    n=0;
    REP(k)n+=p[i][M(s,t)];
    cout<<n;
}

Measured memory_bytes: 154092
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
	x=0;
	map<ll,ll> mp;
	Ff(i,0,n)
	{
		cin>>y;
		mp[y]++;
		x+=y;
	}

	cin>>t;
	Ff(i,0,t)
	{
		cin>>p>>q;
		if(mp[p]>0)
		{
			x=x-mp[p]*p+mp[p]*q;
			if(mp[q]>0)
			mp[q]+=mp[p];
			else
			mp[q]=mp[p];
			mp[p]=0;
		}
		cout<<x<<endl;
	}
    return 0;
}

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

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

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

Measured memory_bytes: 16376
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 3005;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m, dp[MAXN][MAXN][2], ans;

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}

void solve() {
	read(n); read(m);
	if (m <= n) {
		ans = 1;
		for (int i=1;i<=m*2;++i) {
			ans = ans * 2 % MOD;
		}
		printf("%d\n", ans);
		return;
	}
	dp[0][0][1] = 1;
	for (int i=1;i<=n;++i) {
		dp[0][i][0] = 1;
	}
	for (int i=0;i<m;++i) {
		for (int j=0;j<=n;++j) {
			for (int k=0;k<2;++k) {
				int x = dp[i][j][k];
				if (!x) continue;
				if (j) {
					Inc(dp[i+1][j-1][k|(j==1)], x);
					Inc(dp[i+1][j][k|(j==1)], x);
				}
				if (n-j) {
					Inc(dp[i+1][j][k], x);
					Inc(dp[i+1][j+1][k], x);
				}
			}
		}
	}
	for (int i=0;i<=n;++i) {
		Inc(ans, dp[m][i][1]);
	}
	printf("%d\n", ans);
}

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


Measured memory_bytes: 70144
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        //int w = stdIn.nextInt();
        //int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //String s = stdIn.next();
        
        System.out.println(Math.min(b / a, c));
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>

using namespace std;

int calc_upper_bound(int cx, int cy, int x, int y, int h) {
  return abs(cx - x) + abs(cy - y) + h;
}

int calc_lower_bound(int cx, int cy, int x, int y, int h) {
  if (h == 0) {
    return 1;
  }
  return abs(cx - x) + abs(cy - y) + h;
}

int main(void) {
  int N;
  cin >> N;
  vector<int> x;
  vector<int> y;
  vector<int> h;
  for (int i = 0; i < N; i++) {
    int tmp_x, tmp_y, tmp_h;
    cin >> tmp_x >> tmp_y >> tmp_h;
    x.push_back(tmp_x);
    y.push_back(tmp_y);
    h.push_back(tmp_h);
  }
  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      int upper_bound = calc_upper_bound(cx, cy, x[0], y[0], h[0]);
      int lower_bound = calc_lower_bound(cx, cy, x[0], y[0], h[0]);
      if (lower_bound == 0) continue;
      for (int i = 1; i < N; i++) {
        int tmp = calc_upper_bound(cx, cy, x[i], y[i], h[i]);
        if (tmp < upper_bound) upper_bound = tmp;
        tmp = calc_lower_bound(cx, cy, x[i], y[i], h[i]);
        if (tmp == 0) continue;
        if (lower_bound < tmp) lower_bound = tmp;
      }
      if (upper_bound >= 1 and upper_bound == lower_bound) {
        cout << cx << " " << cy << " " << upper_bound << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    ll ans = 0;

    srep(i,1,n+1){
        ll a;
        cin >> a;
        a -= i;
        ans += a;
    }

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



Measured memory_bytes: 3112
# ABC086 C Traveling

n = int(input())
t, x, y = 0, 0, 0
flag = True

for i in range(n):
    _t,_x,_y = map(int, input().split())
    _d = abs(x - _x) + abs(y - _y)
    _dt = abs(t - _t)
    if _d > _dt or ((_d - _dt)%2) == 1:
        flag = False
    t,x,y = _t,_x,_y

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N, K, Q = mi()
    A = [0] * N
    for i in range(Q):
        x = ii()
        A[x - 1] += 1
    # print(A)
    for i in range(N):
        if Q - A[i] < K:
            print('Yes')
        else:
            print('No')
    return


if __name__ == '__main__':
    if not __debug__:
        import doctest
        doctest.testmod()
    main()


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

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;

void solve(ll test_case)
{
    // Do your thing here :)
    cout << test_case << "\n";
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin>>k>>s;
    if(k>= s.length()){
        cout<<s;
        return 0;
    }
    s = s.substr(0,k);
    s = s+"...";
    cout<<s;

   return 0;
}


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

int main() {
  int N,K; cin >> N >> K;
  int ans = 1;
  while(N) {
    ans = min(ans*2,ans+K);
    N--;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, l;
  cin >> n >> l;
  vt<int> a(n + 1);
  rep(i, 0, n) cin >> a[i + 1];

  rep(i, 1, n) {
    if(a[i] + a[i + 1] >= l) {
      cout << "Possible\n";
      rep(j, 1, i) cout << j << endl;
      for(int j = n - 1; j > i; --j) cout << j << endl;
      return cout << i << endl, 0;
    }
  }
  cout << "Impossible\n";
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>

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


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

int main(){
  int n,k;
  double s=0;
  cin >> n>>k;
  vector<double>b(n);
  vector<double>dp(n);
  vector<double>z(n);
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
  for(int i=0;i<k;i++){
  dp.at(0)=dp.at(0)+b.at(i);
  z.at(0)=z.at(0)+b.at(i);
  }
  
  for(int i=1;i<n-k+1;i++){
    z.at(i)=z.at(i-1)+b.at(i+k-1)-b.at(i-1); 
  }
  for(int i=1;i<n-k+1;i++){
    dp.at(i)=max(z.at(i),dp.at(i-1)); 
  }
	cout<<fixed<<setprecision(12)<<(dp.at(n-k)+k)/2.000000<<endl;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
#define CAT(a,b)a b
#define VASIZE(a,b,N,...)N
template<class T>auto size(T&&a)->decltype(a.size(), int()) { return a.size(); }
template<class T, class = enable_if_t<is_integral<T>::value, T>>int size(T a) { return a; }
#define REP(t,a,N)for(int t=size(a),_l##t=size(N);t<_l##t;t++)
#define RREP(t,a,N)for(int t=size(N)-1,_l##t=size(a);t>=_l##t;t--)
#define rep(t,...)CAT(REP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define rrep(t,...)CAT(RREP,VASIZE(__VA_ARGS__,(t,__VA_ARGS__),(t,0,__VA_ARGS__)))
#define all(a)(a).begin(),(a).end()
typedef long long ll;
typedef unsigned long long ull;
void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  auto a = in.Array(3);
  sort(all(a));
  if (a[0] == 5 && a[1] == 5 && a[2] == 7)
    cout << ("YES") << endl;
  else cout << ("NO") << endl;

}


Measured memory_bytes: 764
// =====================================================================================
// 
//       Filename:  C.cpp
//        Created:  2017년 06월 03일 21시 01분 19초
//       Compiler:  g++ -O2 -std=c++14
//         Author:  baactree ,  bsj0206@naver.com
//        Company:  Chonnam National University
// 
// =====================================================================================

#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100];
int main(){
	scanf("%d", &n);
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d", &arr[i]);
		sum+=arr[i];
	}
	if(sum%10!=0){
		printf("%d\n", sum);
		return 0;
	}
	else{
		sort(arr, arr+n);
		for(int i=0;i<n;i++){
			if(arr[i]%10!=0){
				printf("%d\n", sum-arr[i]);
				return 0;
			}
		}
	}
	printf("0\n");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <sstream>
#include <string>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int n;

    cin >> n;

    vector<int> v(n);
    double tmp;
    rep(i, n) {
        cin >> v[i];
        tmp += 1.0/v[i];
    }

    cout << setprecision(8) << 1.0/tmp << endl;

    return 0;
}


Measured memory_bytes: 256
import Control.Monad

readIntLine :: IO ([Int])
readIntLine = do
    x <- getLine
    return $ map (read :: String -> Int) $ words x

main :: IO ()
main = do
    [n] <- readIntLine
    lines <- replicateM n getLine
    solve lines

solve lines =
    let inner = sum $ map countAB lines
        outer1 = (length $ filter (('A'==). last) lines)
        outer2 = (length $ filter (('B'==). head) lines)
        outer = min outer1 outer2
        yonder = if (length $ filter (\l -> (('A'==). last) l && (('B'==). head) l) lines) == (max outer1 outer2) && outer > 0 then 1
                                                                                                                               else 0
      in print $ inner + outer - yonder

countAB [] = 0
countAB [x] = 0
countAB ('A':'B':xs) = 1 + countAB xs
countAB (x:xs) = countAB xs


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
ll s, t, d;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m ;
	if(n == 0 && m == 0) cout<<0;
	else if(n == 0) {
		if((m+1)%4==0) {
			cout<<0;
		}
		else if((m+1)%2==0) {
			cout<<1;
		}
		else {
			m/=2;
			if(m&1) cout<<((2*m)^1); 
			else  cout<<(2*m);
		}
	}
	else {
		n--;
		ll L,R;

		if((n+1)%4==0) {
            L=0;
        }
        else if((n+1)%2==0) {
            L=1;
        }
        else {
            n/=2;
            if(n&1) L=((2*n)^1); 
            else  L=2*n;
        }

		if((m+1)%4==0) {
			R=0;
		}
		else if((m+1)%2==0) {
			R=1;
		}
		else {
			m/=2;
			if(m&1) R=((2*m)^1); 
			else    R=2*m;
		}	

		cout<<(L^R);
	}

}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200000], db[200000][80];
int main() {
    init();
    ll N, K;
    cin >> N >> K;
    rep(i, N) cin >> A[i], A[i]--;

    rep(i,N){
        db[i][0] = A[i];
    }

    rep(b, 60){
        rep(i,N){
            db[i][b + 1] = db[db[i][b]][b];
        }
    }

    ll to = 0;
    repr(b,60){
        if(K>=1LL<<b){
            K -= 1LL << b;
            to = db[to][b];
        }
    }

    cout << to+1 << endl;
}

Measured memory_bytes: 130212
#include<stdio.h>

typedef long long LL;
LL n,k;
const LL mof=1e9+7;
LL p=mof;
const LL maxn=100007;
inline LL pow_mod(LL a,LL k,LL mo)
{
    LL ans=1;
    while(k)
    {
        if(k%2) ans=ans*a%mo;
        a=a*a%mo;
        k>>=1;
    }
    return ans%mo;
}
LL jc[maxn+7];
inline LL inv(LL x)
{
    return pow_mod(x,mof-2,mof);
}
LL Inv[maxn+7];
LL C(LL N,LL k)
{
    if(k>N||k<0)return 0;
    if(k==0||k==N)return 1;
    LL ans=1;
    ans=ans*jc[N]*Inv[k]%mof*Inv[N-k]%mof;
    return ans;
}
void init()
{
    jc[1]=jc[0]=1;
    for(LL i=2; i<=maxn; ++i) jc[i]=jc[i-1]*i%mof;
    for(int i=0; i<=maxn; ++i) Inv[i]=inv(jc[i]);
}
int main()
{
    init();
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;++i)
    {
        LL div_acc = C(k-1,i-1);
        LL ana_acc = C(n-k+1,i);
        printf("%lld\n", div_acc * ana_acc % mof);
    }
}

Measured memory_bytes: 1664
#include <stdio.h>
#define NIL -1

int F[45];
int fibonacci(int);
int main(){
  int a,n,i;

  scanf("%d",&n);

  for(i=0; i < 45; i++){
    F[i] = NIL;
  }

  a = fibonacci(n);

  printf("%d\n",a);

  return 0;
}

fibonacci(int n){
  if(n == 0 || n == 1){
    return F[n] = 1;
  }
  if(F[n] != NIL){
    return F[n];
  }
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}



Measured memory_bytes: 2104
#include <stdio.h>

int main(void)
{
  int x,y,z;
  int temp;
  
  do{
    scanf("%d %d %d",&x,&y,&z);
  } while(((x<1 || x>100) || (y<1 || y>100)) || (z<1 || z>100));
  
  temp = x;
  x = y;
  y = temp;
  temp = x;
  x = z;
  z = temp;
  
  printf("%d %d %d\n",x,y,z);
  
  return 0;
}
  

Measured memory_bytes: 1684
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int N,D;
int X[105];


int main(void) {
  cin >> N >> D;
  for(int i=0; i<N*D; i++){
    cin >> X[i];
  }
  
  int count=0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int sum=0;
      for(int k=0; k<D; k++){
        sum = sum + (X[i*D+k]-X[j*D+k])*(X[i*D+k]-X[j*D+k]);
      }
      int s = sqrt(sum);
      if(s*s == sum){
        count=count+1;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

import sys
input = sys.stdin.readline 

N,M = map(int,input().split())
path = [[] for i in range(N)]
ans = [None for i in range(N)]
visited = [0 for i in range(N)]

for _ in range(M):
  a,b = map(int,input().split())
  a = a - 1
  b = b - 1
  path[a].append(b)
  path[b].append(a)

def bfs(path, root,visited):
  visited[root] = 1
  queue = deque([root])
  while queue:
    cur = queue.popleft()
    for chi in path[cur]:
      if visited[chi] == 1:
        continue
      else:
        ans[chi] = cur + 1
        visited[chi] = 1
        queue.append(chi)

  if all([i == 1 for i in visited]):
    return "Yes"
  else:
    return "No"
  
flag = bfs(path,0,visited)

print(flag)

if flag == "Yes":
  for i in range(1,N):
    print(ans[i])


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool ans;
    if(c < a + b){
        ans = false;
    }else{
        ans = 2*(a*b+b*c+c*a) < a*a + b*b + c*c;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

int main()
{
  int n;
  cin >> n;
  for (int k = 0; k < n; k++)
  {
    string X, Y;
    cin >> X >> Y;
    int N = X.size(), M = Y.size();
    vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < M; j++)
      {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        if (X[i] == Y[j])
        {
          dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
        }
      }
    }
    cout << dp[N][M] << endl;
  }
}


Measured memory_bytes: 6904
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	s := nextString()
	var ans bytes.Buffer

	for _ = range s {
		ans.WriteString("x")
	}

	_, _ = fmt.Fprintf(writer, "%s", ans.String())
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
N = int(input())
MAX = 3501
fin_flag = False
for i in range(1, MAX):
    for j in range(1, MAX):
        if (4 * i * j - N * i - N * j) <= 0:
            continue
        k = (N * i * j) / (4 * i * j - N * i - N * j)
        if not k % 1:
            print(i, j, int(k))
            fin_flag = True
        if fin_flag:
            break
    if fin_flag:
        break


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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%d",&a[i]);
	}

	int j = -1;
	long long xor_sum = 0, sum = 0;
	long long ret = 0;
	for (int i = 0; i < n; i++) {
		while (j + 1 < n && (xor_sum^a[j + 1]) == sum + a[j + 1]) {
			xor_sum ^= a[j + 1];
			sum += a[j + 1];
			j++;
		}
		ret += j - i + 1;
		xor_sum ^= a[i];
		sum -= a[i];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main{
	
	int high;
    int low;
    int sa;
	int i=0;
	
	public void solve(){
    Scanner sc=new Scanner(System.in);
		
        while(i<7){
			high=sc.nextInt();
			low=sc.nextInt();
			sa=high-low;
			System.out.println(sa);
			i++;
        }
	}
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17236
n=int(input())
cst=list(map(int,input().split()))
arr=[0]*10**5
arr[0]=0
arr[1]=abs(cst[1]-cst[0])
if n==2:
    print(arr[1])
else:
    for i in range(2, n):
        arr[i] = min(abs(cst[i - 1] - cst[i]) + arr[i - 1], abs(cst[i - 2] - cst[i]) + arr[i - 2])
    print(arr[i])



Measured memory_bytes: 13976
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int ptr = 0;
            int[] stack = new int[10];
            String str;
		    while((str=Console.ReadLine())!=null){
                int x = int.Parse(str); ;
			    if(x==0){
				    if(stack[ptr-1]!=0){
                        Console.WriteLine(stack[ptr - 1]);
					    stack[ptr-1]=0;
					    ptr--;
				    }
			    }else{
				    stack[ptr]=x;
				    ptr++;
			    }
		    }
        }
    }
}

Measured memory_bytes: 5600
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
  string r, a;
  int hit, brow;
  while(1)
  {
    hit = brow = 0;

    cin >> r >> a;
    if(r.length() == 1)
      break;

    for(int i = 0; i < 4; i++)
    {
      if(r[i] == a[i])
      {
        hit++;
        r[i] = a[i] = 'a';
      }
    }

    for(int i = 0; i < 4; i++)
    {
      for(int j = 0; j < 4; j++)
      {
        if(r[i] != 'a' && a[j] != 'a' && r[i] == a[j])
        {
          brow++;
          r[i] = a[j] = 'a';
        }
      }
    }

    printf("%d %d\n", hit, brow);
  }
  return 0;
}

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

using namespace std;

using ull = unsigned long long;

int main() {
    int n, p[20];
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int cnt = 0;
    for(int i = 1; i < n - 1; ++i) {
        if(p[i - 1] < p[i] && p[i] < p[i + 1])cnt++;
        if(p[i + 1] < p[i] && p[i] < p[i - 1])cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int S = fs.nextInt();
		int W = fs.nextInt();

		if(S > W) {
			System.out.println("safe");
		}else {
			System.out.println("unsafe");
		}
	}

}


Measured memory_bytes: 25308
N = int(input())

cnt = 0
for i in range(N):
    D_1, D_2 = map(int, input().split(" "))
    if D_1 == D_2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
double ans;
int n;
double a[1000100];
struct cmp{
	bool operator ()(double a,double b){
		return a>b;
	}
};
priority_queue<double,vector<double>,cmp> pq;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		double x;
		cin>>x;
		pq.push(x);
	}
	while(1){
		if(pq.size()==1){
			break;
		}
		double a,b;
		a=pq.top();
		pq.pop();
		b=pq.top();
		pq.pop();
		pq.push((a+b)/2);
	}
	printf("%lf\n",pq.top());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   int n,h,w;
   cin >> n >> h >> w;
   int x=n-h+1;
   int y=n-w+1;
   cout << x*y << endl;
}



    
   


Measured memory_bytes: 3516
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int m;

int main() {
  int n, max;
  cin >> n;
  cin >> m;
  max = m;

  REP(i, n) {
    int in, out;
    cin >> in >> out;
    m = m + in - out;
    if (m < 0) {
      cout << 0 << endl;
      return 0;
    } else if (m > max) {
      max = m;
    }
  }

  cout << max << endl;
}

Measured memory_bytes: 1160
<?php 
  
  	fscanf(STDIN, "%d", $N);
	
	$A = array_map('intval', explode(' ', fgets(STDIN)));
    $cards = count(array_count_values($A));	

	if($cards % 2 == 1){
      echo $cards;      
    }else{
      echo $cards - 1;
    }
    

?>

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,m;
  cin>>n>>m;
  int ans=n*(n-1)/2+m*(m-1)/2;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int>v[100005];
    priority_queue<int>pq;
    ll ans=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
    }
    for(int i=1;i<=m;i++){
        for(auto x: v[i])pq.push(x);
        if(!pq.empty()){
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9000
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll f(ll x,ll y)
{
    ll pro=1;
    for(ll i=x;i<=y;i++)
    {
        pro=((pro%M)*(i%M))%M;
    }
    return pro;
}
int main()
{
    ll ans=1e12;
    ll i,j;
    ll n;
    cin>>n;
    ll P[n];
    for(i=0;i<n;i++)
    {
        cin>>P[i];
    }
    for(i=-105;i<=105;i++)
    {
        ll res=0;
        for(j=0;j<n;j++)
        {
            ll z=P[j]-i;
            res+=(z*z);
        }
        ans=min(ans,res);
    }
    cout<<ans;


}












Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    x = int(input())
    ans = 0
    for b in range(1, 1000):
        for p in range(2, 10):
            if x >= b ** p:
                ans = max(ans, b ** p)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 
 

int main(){
	int n,m,max=0,b[100010],count=0;
	vector<int> v;
	cin>>n>>m;
	int dim=m;
	REP(i,n){
		int a;
		cin>>a>>b[i];
		max=std::max(max,a);
	}
	DEB(max)END
	sort(b,b+n,greater<int>());
	/*REP(i,n){
		if(b[i]>max)v.push_back(b[i]);
	}*/
	/*for(auto x:v){
		count++;
		m-=x;
		if(m<=0){
			cout<<count<<endl;
			return 0;
		}
	}*/
	REP(i,n){
		if(b[i]>max){
			count++;
			m-=b[i];
		}
		if(m<=0){
			cout<<count<<endl;
			return 0;
		}
		ARDEB(i,b)DEB(m)DEB(count)END
	}
	//int ans=;
	REP(i,n){ARDEB(i,b)END}
	DEB(m)DEB(count)END
	cout<<count+((m%max==0)?m/max:m/max+1)<<endl;
	return 0;
}

Measured memory_bytes: 640
import sys


def calc(s, x, i):
    if s[i] == "S":
        if x == "o":
            return s[i-1]
        elif s[i-1] == "S":
            return "W"
        else:
            return "S"
    else:
        if x == "x":
            return s[i-1]
        elif s[i-1] == "S":
            return "W"
        else:
            return "S"


n = int(input())
s = input()
for s1 in ["S", "W"]:
    for sn in ["S", "W"]:
        ans = [s1] + [""] * (n-2) + [sn]
        for i in range(n-1):
            ans[i+1] = calc(ans, s[i], i)
        zn = calc(ans, s[-2], n-2)
        z1 = calc(ans, s[-1], n-1)
        if zn == sn and z1 == s1:
            print("".join(ans))
            sys.exit()

print(-1)


Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pa;
int main(){
    long long A,B;
    cin>>A>>B;
    long long g=__gcd(A,B);
    int ans=0;
    for(int i=2;i<=g/i;i++){
        if(g%i==0){
            ans++;
            while(g%i==0)
                g/=i;
        }
    }
    if(g>1) ans++;
    printf("%d\n", ans+1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
	  fac[i] = fac[i-1] * i % MOD;
	  inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
	  finv[i] = finv[i-1] * inv[i] % MOD;
	}
}
//組み合わせ
long long COM (int n, int k) {
	if(n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int64 calc(int64 A) {
	if (A <= 0) return 0;
	A++;
	int64 ans = 0;
	for (int i = 0; i < 50; ++i) {
		int64 loop = 1LL << (i + 1);
		int64 cnt = 0;
		cnt = (A / loop) * (loop / 2);
		cnt += max(0LL, (A % loop) - (loop / 2));
		if (cnt % 2 == 1) {
			ans += 1LL << i;
		}	
	}
	return ans;
}

void solve() {
	int64 a,b; cin >> a >> b;
	int64 ans = calc(b) ^ calc(a - 1);
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int rectangles = 0;
                int lozenges = 0;
                while(sc.hasNext()){
                        String[] s = sc.nextLine().split(",");
                        int[] a = new int[3];
                        for(int i = 0; i < 3; i++){
                                a[i] = Integer.parseInt(s[i]);
                        }   
                        if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]){
                                rectangles++;
                        }   
                        if(a[0] == a[1]){
                                lozenges++;
                        }   
                }   
                System.out.println(rectangles+"\n"+lozenges);
        }   
}

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

static const int MAX = 200000;

int main(){
    int R[MAX], n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
    int n;
    cin >> n;
    VI a(n);
    rep(i,n)cin >> a.at(i);
    int no=0;
    rep(i,n){
        if(a.at(i)%2==1)no++;
    }
    if(no%2==0)cout << "YES"  << endl;
    else cout << "NO" << endl;
} 
    

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

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

  vector<int> d(100, 999);

  for(int i = 0; i < n; i ++){
    cin >> d.at(i);
  }

  int count = 0;

  int temp = 999;

  for(int i = 0; i < n; i ++){
    int min = *min_element(d.begin(), d.end());
    vector<int>::iterator minIt = min_element(d.begin(), d.end());
    int minIndex = distance(d.begin(), minIt);

    d.at(minIndex) = 999;
    
    if(min == temp) continue;
    else count ++;

    temp = min;
  }
  
  cout << count << endl;

  return 0;
}

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

#define MOD 1000000007
long long memo[2100000];

int n;
int a[30][30];

long long dp(int i, int bit){
  if(i == n) return 1;

  if(memo[bit] != -1) return memo[bit];

  long long ans = 0;

  for(int j = 0;j < n;j++){
    if(a[i][j] == 1 && (bit & (1 << j)) == 0){
      ans = (ans + dp(i+1, bit | (1 << j))) % MOD;
    }
  }

  return memo[bit] = ans;
}

int main(){
  cin >> n;

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

  memset(memo, -1, sizeof(memo));

  cout << dp(0, 0) << endl;

  return 0;
}


Measured memory_bytes: 16768
import numpy as np

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [10**9]*(n+k+2)
h = np.array(h)
h = np.insert(h, len(h), np.zeros(k+2))
dp = np.array(dp)
dp[0] = 0

for i in range(n):
    dp[i+1 : i+k+1] = np.minimum(dp[i+1:i+k+1], dp[i] + np.abs(h[i+1:i+k+1] - h[i]))

print(dp[n-1])

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int a[5];
    for(int i=0;i<5;i++)
        cin>> a[i];
    for(int i=0;i<5;i++){
        if(a[i]==0)cout << i+1;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  int C;
  cin >>A>>B>>C;
  bool answer=false;
  repl(i,1,B+1) {
    if((A*i)%B==C) {
      answer=true;
      break;
    }
  }
  
  if(answer) {
    cout<<"YES"<< endl;
  }
else {
cout<<"NO"<< endl;
}
  
  
}
 

Measured memory_bytes: 256