akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
struct Point{
    long long x,y;
    Point():x(0),y(0){}
    Point(long long _x,long long _y):x(_x),y(_y){}
    bool operator<(Point other)const{
        if(x==other.x)return y<other.y;
        return x<other.x;
    }
};
struct Vector{
    long long x,y;
    Vector(long long _x,long long _y):x(_x),y(_y){}
};
Vector to_vector(Point a,Point b){
    return Vector(b.x-a.x,b.y-a.y);
}
long long cross(Vector a,Vector b){
    return (a.x*b.y)-(a.y*b.x);
}
bool ccw(Point a,Point b,Point c){
    return cross(to_vector(a,b),to_vector(b,c))>0;
}
bool collinear(Point a,Point b,Point c){
    return cross(to_vector(a,b),to_vector(b,c))==0;
}
vector<Point> convex_hull(vector<Point> point){
    vector<Point> hull;
    sort(point.begin(),point.end());
    for(int i=0;i<2;i++){
        int start=hull.size();
        for(auto p:point){
            while(hull.size()>=start+2
                &&!ccw(hull[hull.size()-2],hull[hull.size()-1],p)
                &&!collinear(hull[hull.size()-2],hull[hull.size()-1],p))hull.pop_back();
            hull.push_back(p);
        }
        hull.pop_back();
        reverse(point.begin(),point.end());
    }
    return hull;
}
int n;
int main(){
    scanf("%d",&n);
    assert(n>=3);
    vector<Point> point;
    for(int i=0;i<n;i++){
        long long x,y;
        scanf("%lld %lld",&x,&y);
        point.push_back(Point(x,y));
    }
    vector<Point> hull=convex_hull(point);
    int start=0;
    for(int i=1;i<hull.size();i++){
        if(hull[i].y<hull[start].y||(hull[i].y==hull[start].y&&hull[i].x<hull[start].x))start=i;
    }
    printf("%d\n",hull.size());
    for(int i=start;i<hull.size();i++){
        printf("%lld %lld\n",hull[i].x,hull[i].y);
    }
    for(int i=0;i<start;i++){
        printf("%lld %lld\n",hull[i].x,hull[i].y);
    }
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  cout << s.substr(0, s.size()-8) << endl;

  return 0;
}


Measured memory_bytes: 764
a, b = list(map(int, input().split()))
# x = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
# n, m = list(map(int, input().split()))
if a < 6:
    print(0)
elif a <= 12:
    print(int(b/2))
else:
    print(b)


Measured memory_bytes: 2940
#include<stdio.h>

//this file is not a C file but a C++ file                                      

int main(void){
    int stnum;//the number of the student                                       
    int pm, pe, pj;//ある生徒の点数                                             
    char grade;//成績                                                           
    while(1) {
        scanf(" %d", &stnum);
        if(stnum == 0) {
            break;
        }
        for(int i = stnum - 1;i >= 0;i -= 1) {
            scanf(" %d %d %d", &pm, &pe, &pj);
            if((pm == 100 || pe == 100 || pj == 100) ||
               (pm + pe) / 2 >= 90                   ||
               (pm + pe + pj) / 3 >= 80) {
                grade = 'A';
            }else if((pm + pe + pj) / 3 >= 70 ||
                     (((pm + pe + pj) / 3 >= 50) && (pm >= 80 || pe >= 80))){
                grade = 'B';
            }else{
                grade = 'C';
            }
            printf("%c\n", grade);
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
// */
using namespace std;
#define int long
#define match(a,b) (a=='?'||b=='?'||a==b)
signed main(){
  string s,t,r;
  cin>>s>>t;
  if(s.size()>=t.size()){
    for(int h=s.size()-t.size();h>=0;--h){
      bool f=true;
      for(int i=0;f&&i<t.size();++i)if(!match(s[i+h],t[i]))f=false;
      if(f){
        for(int i=0;i<t.size();++i)s[i+h]=t[i];
        for(int i=0;i<s.size();++i)if(s[i]=='?')s[i]='a';
        return cout<<s,0;
      }
      f=false;
    }
  }
  cout<<"UNRESTORABLE";
}

Measured memory_bytes: 256
use std::cmp;
#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let s = read_as_string().chars().collect::<Vec<char>>();
    let n = s.len() + 1;

    let mut v = vec![0; n];
    let mut acc: u64 = 0;

    for i in 1..n {
        if s[i - 1] == '<' {
            acc += 1;
        } else {
            acc = 0;
        }
        v[i] = acc;
    }
    acc = 0;
    for i in (0..n - 1).rev() {
        if s[i] == '>' {
            acc += 1;
        } else {
            acc = 0;
        }
        v[i] = cmp::max(v[i], acc);
    }
    println!("{}", v.into_iter().sum::<u64>());
}


Measured memory_bytes: 10996
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dp[2][5002][2];
int main(){
  int N;
  cin>>N;
    vector<int> v(N-1);
    REP(i, N-1) cin>>v[i];
    REP(i, 2)REP(j, 5002)REP(k, 2) dp[i][j][k] = INF;
    dp[0][1][0] = 0;
    REP(i, N-1){
      REP(j, N/2+1){
        dp[(i+1) % 2][j+1][0] = min(dp[i%2][j][0], dp[i%2][j][1] + v[i]);
        dp[(i+1) % 2][j][1] = min(dp[i%2][j][0] + v[i], dp[i%2][j][1]);
      }
      REP(j, N/2+1)dp[i%2][j][0] = dp[i%2][j][1] = INF;
    }
    cout<<min(dp[(N-1)%2][N/2][0], dp[(N-1)%2][N/2][1])<<endl;
  return 0;
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  // int N;
  // int K;
  // cin>>N;
  // cin>>K;
  // set<int> s;
  // for(int i = 1;i <= N;i++){
  //   s.insert(i);
  // }
  // for(int i = 1;i <= K;i++){
  //   int num;
  //   cin>>num;
  //   //set<int> s;
  //   for(int i = 1;i < num;i++){
  //     int a;
  //     cin>>a;
  //     //s.insert(a);
  //     if(s.lower_bound(a) == a){

  //     }
  //   } 
  // }

  long long int N;
  long long int sum = 0;
  cin>>N;
  deque<long long int> dq;
  for(long long int i = 1;i <= N;i++){
    dq.push_back(i);
  }
  for(long long int i = 0;i < N;i++){
    if(dq[i] % 3 == 0 || dq[i] % 5 == 0){
      dq[i] = 0;
    }
    sum += dq[i];
  }
  cout<<sum<<'\n';
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[201],s=0;
    cin>>n;
    for(int i=1;i<=2*n;i++) cin>>a[i];
    sort(a+1,a+2*n+1);
    for(int i=1;i<2*n;i+=2) s+=a[i];
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n,l;
	string s[100];
	string ans;
	
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)
		ans+=s[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,x,c = 0;
    scanf("%lld%lld%lld",&a,&b,&x);
        if(a%x == 0)
        {
            c++;
        }
        c = c+((b/x)-(a/x));
    printf("%lld",c);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int ac=0;
    int wa=0;
    int[] a=new int[n];
    for(int i=0;i<m;i++){
      int p=sc.nextInt()-1;
      String st=sc.next();
      if(a[p]==-1){
        
      }else if(st.equals("AC")){
        wa+=a[p];
        ac++;
        a[p]=-1;
      }else if(st.equals("WA")){
        a[p]++;
      }
    }
    System.out.println(ac+" "+wa);
  }
}

Measured memory_bytes: 64232
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    L,R,d=mi()
    ans = 0
    for i in range(L,R+1):
        if i % d == 0:
            ans += 1

    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 61748
#include<iostream>

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
    IOS;

    int n;
    cin >> n;
   // vector<int> a(n);
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    lln ans = 0;
    for(int i=1;i<n;i++){
        if(a[i] < a[i-1]){
            ans = ans + a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;    
}



Measured memory_bytes: 4380
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int h,w;
	int a[55][55]={};
	int s[55][55]={};
	int di[4]={-1,0,1,0};
	int dj[4]={0,1,0,-1};

	cin>>h>>w;
	int all=0;
	FORQ(i,1,h){
		FORQ(j,1,w){
			a[i][j]=0;
			s[i][j]=mod;
		}
	}
	//s[1][1]=1;
	FORQ(i,1,h){
		FORQ(j,1,w){
			char ch;
			cin>>ch;
			if(ch=='.'){
				a[i][j]=1;
				all++;
			}
		}
	}
	//cout<<all<<endl;
	priority_queue<pair<int,pair<int,int>>> pq;
	pq.push(make_pair(1,make_pair(1,1)));
	while(!pq.empty()){
		pair<int,pair<int,int>> pr=pq.top();
		pq.pop();
		int nx=pr.ND.ST,ny=pr.ND.ND,dist=pr.ST;
		if(dist<s[nx][ny])s[nx][ny]=dist;
		else continue;
		//cout<<nx<<" "<<ny<<" "<<dist<<endl;
		FOR(i,0,4){
			int x=pr.ND.ST+di[i],y=pr.ND.ND+dj[i];
			if(a[x][y]){
				pq.push(make_pair(pr.ST+1,make_pair(x,y)));
			}
		}
	}
	if(s[h][w]==mod){
		cout<<-1<<endl;
	}else cout<<all-s[h][w]<<endl;
    return 0;
}


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

int main() {
  int n;
  string s;
  map<string, int> m;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> s, m[s]++;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s, m[s]--;

  int ans = 0;
  for (auto x : m) ans = max(ans, x.second);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007

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

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited = true;

    for(int i = 0; i < N; i ++){
        if(visited[i]==false){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }

    int ret = 0;

    for(int i = 0; i < N; i++){
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i,N,visited);
        visited[i] = false;
    }

    return ret;

}

int main(){
    ll N,M;
    cin >> N >> M;

    for (int i = 0; i < M; i++){
        int A,B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }

    bool visited[nmax];
    for(int i = 0; i < N; i++){
        visited[i]=false;
    }

    visited[0] = true;

    cout << dfs(0,N,visited) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>

const long long INF = 1000000007;

using namespace std;

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

int n;
int h[200011];
ll arr[200011];
ll seg[800011];
int MAX = pow(2, 18);

void update(ll x, int idx) {
	int k = idx + MAX;
	seg[k] = x;
	while (k > 0) {
		k = k / 2;
		seg[k] = max(seg[2 * k], seg[2 * k + 1]);
	}

}

ll find(int l, int r, int node_l, int node_r, int idx) {
	if ((node_l >= r) || (node_r <= l)) return 0;
	if ((l<=node_l) && (node_r<=r)) return seg[idx];
	int mid = (node_l + node_r) / 2;
	return max(find(l, r, node_l, mid, 2 * idx), find(l, r, mid, node_r, 2 * idx + 1));
}

int main() {
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", h + i);
		h[i] --;
	}
	for (int i = 0; i < n; i++) scanf("%lld", arr + i);
	for (int i = 1; i < 2 * MAX; i++) seg[i] = 0;

	update(arr[0], h[0]);
	
	
	for (int i = 1; i < n; i++) {
		update(arr[i] + find(0, h[i],0,MAX,1), h[i]);
	}
	


	printf("%lld", find(0, n, 0, MAX, 1));

}


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>>v(N);
    int A,B;
    for (int i = 0; i < N; ++i) {
      cin >> A >> B;
      v[i] = make_pair(A,B);
    }

    sort(v.begin(), v.end());
    ll ans = 0;
    int price, rest;
    for (int i = 0; i < N; ++i) {
        price = v[i].first;
        rest = v[i].second;
        while(rest){
            ans += price;
            rest--;
            M--;
            if(M==0) break;
        }
        if(M==0) break;
    }
    cout << ans;
    return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a, b;
  cin >> a >> b;
  if(a == b) cout << a << endl;
  if(a > b) cout << a - (a - b) * 2 << endl;
  if(a < b) cout << a + (b - a) * 2 << endl;
}


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

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

    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i=1; i<n; i++) {
        dp[i][0] = a[i]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i]+max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i]+max(dp[i-1][0], dp[i-1][1]);
    }

    printf("%d\n", max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}));
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int x,a;
  cin >> x >>a;
  cout << max(x-a,0) << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
	int a,b,c,sum=0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i=a;i<=b;i++)
	{
		if(c%i==0) sum=sum+1;	
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<set>

long nPr(int n, int r){
  long ans = 1;
  for(int i = 0; i < r; i++){
    ans *= n-i;
    ans %= 1000000007;
  }
  return ans;
}

int main(){
  int N, M;
  std::cin >> N >> M;
  int big = M, small = N;
  if(N > M){
    big = N;
    small = M;
  }
  if(big - small > 1) std::cout << 0 << std::endl;
  else{
    long ans = 1;
    ans *= nPr(big, big);
    ans %= 1000000007;
    ans *= nPr(small, small);
    ans %= 1000000007;
    if(big - small == 0) ans *= 2;
    ans %= 1000000007;
    std::cout << ans << std::endl;
  }
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  string s, t;
  cin >> s >> t;
  int ans = INF;
  for (int i = 0; i < s.size(); i++) {
    int cur = 0;
    bool ok = true;
    for (int j = 0; j < t.size(); j++) {
      if (i + j >= s.size()) ok = false;
      cur += (s[i + j] != t[j]);
    }
    if (ok) ans = min(ans, cur);
  }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


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

using namespace std;

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

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    bool ans = true;

    if(x+r > w || x-r < 0 || y+r > h || y-r < 0)ans = false;
    cout << ((ans)? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 3100
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut r2: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    let mut cnt = 1;
    while !rems.is_empty() {
        if !r2.is_empty() {
            cnt += 1;
        }
        while let Some(s_idx) = q.pop_front() {
            r2.remove(&s_idx);
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            // if let Some(destv) = dests.remove(&s_num) {
            //     for dest in destv {
            //         q.push_back(dest);
            //     }
            // }
            if let Some(destv) = dests.get_mut(&s_num) {
                for &dest in destv.iter() {
                    q.push_back(dest);
                }
                destv.clear();
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&r) = r2.iter().next() {
            // q.push_back(r);
            cnt += r;
        }
    }
    if cnt > 1e18 as usize{
        println!("{}", "hoge");
    }
    println!("{}", ans);
    std::process::exit(0);
}


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

n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=sum(arr)
ans=1
d=div(s)
for val in d:
  arr=sorted(arr,key=lambda x:x%val)
  parr=[]
  narr=[]
  for num in arr:
    narr.append(num%val)
    parr.append(val-num%val)
  for i in range(n-1):
    parr[i+1]+=parr[i]
    narr[i+1]+=narr[i]
  for i in range(n-1):
    ncnt=narr[i]
    pcnt=parr[-1]-parr[i]
    if ncnt!=pcnt:
      continue
    else:
      if pcnt<=k:
        ans=max(ans,val)
print(ans)

Measured memory_bytes: 45296
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  VEC<LL>a(n);
  REP(i,0,n)cin>>a[i];
  sort(ALL(a));
  LL ma = a[n-1];
  VEC<LL>diff(n,0);
  LL difma=-1;
  int right = -1;
  REP(i,0,n-1){
    diff[i]=min(a[i],ma-a[i]);
    if(diff[i]>difma){
      right=i;
      difma=diff[i];
    }
  }
  cout<<ma<<" "<<a[right]<<endl;


  return 0;
}


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


int main()
{

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

	int ans = 0;
	int i = 0,st = 0;
	while(i < n)
	{
		if(i+1 < n && a[i] >= a[i+1]){
		while(i+1 < n && a[i] >= a[i+1])
			i++;

		ans = max(ans, i-st);
		}
		else{
			i++;
			st = i;
		}
	}

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

Measured memory_bytes: 640
package main

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

func main() {
	var N, M, K int
	fmt.Scan(&N, &M, &K)

	A := make([]int, N)
	B := make([]int, M)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := range A {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	for i := range B {
		sc.Scan()
		B[i], _ = strconv.Atoi(sc.Text())
	}

	asum := make([]int, N+1)
	for i := 0; i < N; i++ {
		asum[i+1] = asum[i] + A[i]
	}
	bsum := make([]int, M+1)
	for i := 0; i < M; i++ {
		bsum[i+1] = bsum[i] + B[i]
	}
	max := 0
	for i := 0; i < N+1; i++ {
		sum := asum[i]
		if sum > K {
			continue
		}
		left := 0
		right := len(bsum)
		for right-left > 1 {
			mid := left + (right-left)/2
			if sum+bsum[mid] <= K {
				left = mid
			} else {
				right = mid
			}
		}
		count := i + left
		if count > max {
			max = count
		}
	}
	fmt.Println(max)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int t,x;
  cin>>t>>x;
  cout << (1.0 * t / x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

vector<bool> primenumbers(int n){
  vector<bool> prime(n+1,1);
  for(int i = 2;i <= n;i++){
    if(prime[i]){
      for(int j = 2 * i;j <= n;j += i){
        prime[j] = 0;
      }
    }
  }
  return prime;
}

//データ数 < 2^(log2n)
constexpr ll log2n = 20;
constexpr ll sizeofn = 1 << log2n+1;
ll SegmentTree[sizeofn];
ll STconvert(ll i,ll j){
  return (1<<log2n)/(j-i+1) + i/(j-i+1);
}

ll STmerge(ll i,ll j){
  return i+j;
}

ll STquery(ll i,ll j){
  if(i > j)swap(i,j);
  REP(rep,0,log2n+1){
    ll p = 1 << rep;
    if(i%p == 0 && i+p-1 < j){
      return STmerge(STquery(i+p,j),SegmentTree[STconvert(i,i+p-1)]);
    }
    else if(i%p == 0 && i+p-1 <= j){
      return SegmentTree[STconvert(i,j)];
    }
  }
}

void STchange(ll i,ll j){
  SegmentTree[STconvert(i,i)] = j;
  FOR(rep,1,log2n+1){
    ll p = 1 << rep;
    SegmentTree[STconvert(i/p*p,i/p*p+p-1)] = STmerge(SegmentTree[STconvert(i/p*p,i/p*p+p/2-1)],SegmentTree[STconvert(i/p*p+p/2,i/p*p+p-1)]);
  }
}

signed main(){
  vector<bool> v = primenumbers(100010);
  FOR(i,3,100010){
    if(v[i] && v[(i+1)/2]){
      STchange(i,1);
    }
  }
  int Q;
  cin >> Q;
  int l,r;
  FOR(i,0,Q){
    cin >> l >> r;
    cout << STquery(l,r) << endl;
  }
}


Measured memory_bytes: 7040
#include <stdio.h>

int main()
{
    long long int health;
    int n, move, i, j, top = -1;
    _Bool iswin = 0;

    scanf("%lld %d", &health, &n);
    int ara[n];

    for(i = 0; i<n; i++)
    {
        scanf("%d", &move);

        for(j = 0; j<=top; j++)
        {
            if(move == ara[j])
            {
                iswin = 0;
                break;
            }
        }

        /*Stack entry*/
        top++;
        ara[top] = move;

        health-=move;

        if(health<=0)
        {
            iswin = 1;
            break;
        }
    }

    if(health<=0 || iswin == 1)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  char a; cin >> a;
  if ('A' <= a && a <= 'Z') cout << "A" << endl;
  else cout << "a" << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <set>
 
using namespace std;
 
#define FOR( i, k, n ) for ( int i = ( k ); i < ( int )( n ); ++i )
#define REP( i, n ) FOR( i, 0, n )
 
int main() {
    int n, q;
    set< int > nums;
    scanf( "%d", &n );
    REP( i, n ) {
        int num;
        scanf( "%d", &num );
        nums.insert( num );
    }
    scanf( "%d", &q );
    int ans = 0;
    REP( i, q ) {
        int num;
        scanf( "%d", &num );
        if( nums.find( num ) != nums.end() ) ++ans;
    }
    printf( "%d\n", ans );
    return 0;
}

Measured memory_bytes: 3056
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
        int a,b;
        cin>>a>>b;
        cout<<(a-b+1)<<endl;
        return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c_max[i][1] != max_num:
        break
    else:
        ans_list.append(c_max[i][0])

print(*sorted(ans_list), sep='\n')


Measured memory_bytes: 63700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)2147483647
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;

void pyn(bool ans){
    p(ans?"Yes":"No");
}


struct SegmentTree {
private:
    int n;
    VL node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(VL v) {
    // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
    // セグメント木全体で必要なノード数は 2n-1 個である
    int sz = v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1, inf);
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(int x, int val) {
    x += (n-1);
    node[x] = val;
    while(x > 0) {
        x = (x - 1) / 2;
        node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    // 要求区間 [a, b) 中の要素の最小値を答える
    // // k := 自分がいるノードのインデックス
    // // 対象区間は [l, r) にあたる
    // get a,b+1で呼び出す
    int get(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;

        if(r <= a || b <= l) return inf;
        // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
        if(a <= l && r <= b) return node[k];
        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        int vl = get(a, b, 2*k+1, l, (l+r)/2);
        int vr = get(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,mi=inf,ma=-inf,ans,sum,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
P pa;
bool fl;

int main(void){
    cin>>n>>m;
    VL v(n,inf);
    SegmentTree ST(v);
    rep(i,m){
       cin>>fl>>x>>y;
       if(fl){
           p(ST.get(x,y+1));
       }
       else{
           ST.update(x,y);
       }
    }
    return 0;
}


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

 
int main() {
   int n;
   cin>>n;
   int ans=0;
   for(int i=1;i<=n;i++){
       string s=to_string(i);
       if(s.length()%2)ans++;
   }
   cout<<ans<<endl;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cout << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";
const ll inf=9187201950435737471;

int main() {
	IOS
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,k-(n%k))<<endl;
}

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

int main() {
  int K, N, min;
  cin >> K >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  min = vec.at(N-1) - vec.at(0);
  for (int i = 1; i < N; i++) {
    if (K-(vec.at(i)-vec.at(i-1)) < min) {
      min = K-(vec.at(i)-vec.at(i-1));
    }
  }
  cout << min << endl;
}


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

const int MAX_N=10;
const int MAX_M=10;
int N;
int swiches[MAX_M];
int ps[MAX_M];

bool on_check(int light, int swich, int p) {
  int use = (light&swich);
  int on=0;
  for(int i=0; i<MAX_N; i++) {
    on ^= ((use & (1 << i)) >> i);
  }
  return on == p;
}

int main() {
  int N, M, k;
  cin >> N >> M;
  rep(i, M) {
    cin >> k;
    int use=0;
    int s;
    rep(j, k) {
      cin >> s;
      use += (1 << (s-1));
    }
    swiches[i] = use;
  }
  rep(i, M) cin >> ps[i];
  long long ans=0;
  for(int light=0; light<(1 << N); light++) {
    bool flag=true;
    for(int j=0; j<M; j++) {
      if(!on_check(light, swiches[j], ps[j])) flag=false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#define fora(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T> void UNIQUE(vector<T> &a){ SORT(a);a.erase(unique(ALL(a)),a.end());}
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll K,A,B;
    cin>>K>>A>>B;
    reps(i,A,B+1){
        if(i%K==0){
            cout<< "OK" <<"\n"; return;
        }
    }
    cout<< "NG" <<"\n";
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; rep(QQ,Qkai) Main();
    Main();
}
//-----------------------------------------

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

int main( void )
{
	// prime numbers table
	vector <bool> isPrime( 60000 + 1, false );
	isPrime[2] = true;
	for ( int i = 3; i < 60000; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( int i = 3; i < 60000; i += 2 )
	{
		for ( int j = i + i; j < 60000; j += i )
		{
			isPrime[j] = false;
		}
	}

	vector <int> primes;
	primes.push_back( 2 );
	for ( int i = 3; i < 60000; i += 2 )
	{
		if ( isPrime[i] )
			primes.push_back( i );
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( int i = 0; i < primes.size(); i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime.at( n-primes[i] ) )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

}

Measured memory_bytes: 972
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 800 * n - 200 * (n / 15);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*n
b = [None]*n
for i in range(n):
    a[i],b[i] = map(int, input().split())
    
ab = [(a[i]+b[i], i) for i in range(n)]
ab.sort()
takahashi = 0
aoki = 0
for i in range(n):
    if i%2==0:
        takahashi += a[ab[n-1-i][1]]
    else:
        aoki += b[ab[n-1-i][1]]
print(takahashi-aoki)

Measured memory_bytes: 87188
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int mod=1000000007;

int main(){
	LL n,a,b,c,d;
	int f=0;
	cin>>n>>a>>b>>c>>d;
	FOR(i,0,n){
		int neg=i,pos=n-1-i;
		LL bb=a-neg*d+pos*c;
		int gap=d-c;
		if(bb<=b&&b<=bb+1LL*gap*(n-1))f=1;
	}
	if(f==1)cout<<"YES";
	else cout<<"NO";
    return 0;
}


Measured memory_bytes: 504
#include<stdio.h>
int table[55000];
 
int main(){
    for(int i=2;i<1000;i++){
        if(table[i]==0){
            for(int j=i*2;j<=55000;j+=i){
                table[j]=1;
            }
        }
    }
    int a;
    while(~scanf("%d",&a)){
        int i;
        for(i=a-1;table[i]==1;i--);
        printf("%d ",i);
        for(i=a+1;table[i]==1;i++);
        printf("%d\n",i);
    }
}



Measured memory_bytes: 2904
N = int(input())
a = N % 10
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9 :
  print ("hon")
elif a == 0 or a == 1 or a == 6 or a == 8 :
  print ("pon")
else :
  print ("bon")

Measured memory_bytes: 9100
K = int(input())
if K < 9:
  print(K)
else:
  K -= 9
  i = 0
  L = [1,2,3,4,5,6,7,8,9]
  M = []
  while K > 0:
    x = L[i]
    if  0 < x%10 < 9:
      if K > 3:
        L.append(x*10+ x%10 - 1)
        L.append(x*10 + x%10)
        L.append(x*10 + x%10 + 1)
        K -= 3
      elif K == 3:
        ans = x*10 + x%10 + 1
        K = 0
      elif K == 2:
        ans = x*10 + x%10
        K = 0
      elif K == 1:
        ans = x*10 + x%10 - 1
        K = 0
    elif x%10 == 0:
      if K > 2:
        L.append(x*10 + x%10)
        L.append(x*10 + x%10 + 1)
        K -= 2
      elif K == 2:
        ans = x*10 + x%10 + 1
        K = 0
      elif K == 1:
        ans = x*10 + x%10
        K = 0
    else:
      if K > 2:
        L.append(x*10+ x%10 - 1)
        L.append(x*10 + x%10)
        K -= 2
      elif K == 2:
        ans = x*10 + x%10
        K = 0
      elif K == 1:
        ans = x*10 + x%10 - 1
        K = 0
    i += 1
  print(ans)

Measured memory_bytes: 7264
w,h,x,y,r=map(int,input().split())
yoko=0
tate=0
if x-r>=0 and x+r<=w:
	yoko=1
if y-r>=0 and y+r<=h:
	tate=1
if yoko==1 and tate==1:
	print("Yes")
else:	
	print("No")



Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef unsigned int uint;
typedef pair<uint, int> P;

int main() {
	uint N, X;
	cin >> N >> X;
	vector<P> b(N); //first: cost, second: dist
	for (uint i = 0; i < N; i++) {
		cin >> b[i].second >> b[i].first;
	}
	priority_queue<P, vector<P>, greater<P> > q;
	vector<uint> d(300000, -1);
	d[0] = 0;
	q.push(P(0, 0));
	while (!q.empty()) {
		P e = q.top();
		q.pop();
		if (e.first > d[e.second]) {
			continue;
		}
		for (uint i = 0; i < N; i++) {
			uint cost = b[i].first + e.first;
			uint x = b[i].second + e.second;
			if (x < 300000 && cost < d[x]) {
				d[x] = cost;
				q.push(P(cost, x));
			}
			int y = e.second - b[i].second;
			if (y >= 0 && cost < d[y]) {
				d[y] = cost;
				q.push(P(cost, y));
			}
		}
	}
	cout << (signed)d[X] <<endl;
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>graph(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		graph.at(i) = x;
	}
	vector<int>alr(n, -1);
	int pos = 0;
	alr.at(0) = 1;
	int ans = 1;
	//graph={1,1};
	//alr = {-1,-1};
	//pos = 0
	//ans = 1
	if (graph.at(0) == 1) {
		cout << 1 << endl;
		return 0;
	}
	while (true) {
		int pos = graph.at(pos);
		if (alr.at(pos) == -1) {
			if (graph.at(pos) == 1) {
				ans++;
				cout << ans << endl;
				return 0;
			}
			else {
				ans++;
				alr.at(pos) = 1;
			}
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n >> m >> l;
  if(m > l)puts("0");
  else if(n == 1){
    if(m == l)puts("1");
    else puts("0");
  }else{
    ll ans = l - m;
    ans *= n-2;
    ans++;
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	while (k--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		--x; --y;
		printf("%d\n", min(min(x, n-1 - x), min(y, n-1 - y)) % 3 + 1);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

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

int main() {

    int n;
    cin >> n;
    vector <long> a(n); 
    vector <long> x (n,0);

    rep(i,n){
        cin >> a[i];
        if (i%2==0) {
            x[0] += a[i];
        } else {
            x[0] -= a[i];
        }
    }

    cout << x[0] << " ";
    rep(i,n-1) {
        x[i+1] = 2*a[i] - x[i];
        cout << x[i+1] << " ";
    }
    cout << endl;


}

Measured memory_bytes: 2944