akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int q;
	cin>>q;
	while(q--){
		ll a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		if(a==b){
			cout<<2*(a-1)<<endl;
			continue;
		}
		ll c=sqrt(a*b);
		ll ans=0;
		if(c*(c+1)<a*b){
			ans=c-1+c;
		}else{
			ans=c-2+c;
		}
		if(c*c==a*b) ans--;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  // cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  double ans = 0;
  while (n--) {
    double x; cin >> x;
    string u; cin >> u;
    if (u == "JPY") ans += x;
    else ans += x * 380000.0;
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
	int n,res=0;
	cin >> n;
	if(n == 0) return 0;
	long long a[1000];
	long long b[1000];
	for(int i=0;i<n+1;i++){
		cin >> a[i];
	}
	for(int i=0;i<n+1;i++){
		int c=0;
		for(int j=0;j<n+1;j++){
			if(i!=j){
				b[c]=a[j];
				c++;
			}
		}
		bool bo=true;
		long long tmp=b[1]-b[0];
		for(int j=2;j<n;j++){
			if(b[j]-b[j-1]!=tmp) bo=false;
		}
		if(bo) res=i;
	}
	cout<<a[res]<<endl;
	}
	return 0;
}

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

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

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

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

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

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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    ll c[3];
    c[0] = a+b;
    c[1] = a-b;
    c[2] = a*b;
    sort(c,c+3);
    cout << c[2] << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import java.lang.Math.min

fun main(args:Array<String>){
    val strS = readLine()!!
    var strT = readLine()!!
    var ans = strT.length
    for(start in 0..strS.length-strT.length){
        var count = 0
        for(i in 0..strT.length-1){
            if(strT[i] != strS[start + i]){
                count++
            }
        }
        ans = min(ans, count)
    }
    print(ans)
}

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

typedef long long ll;
const int maxn=200010;
int n;
int a[maxn];

ll ans;
bool check(){
	if(a[1]) return false;
	for(int i=1;i<=n;i++){
		if(a[i]>a[i-1]+1) return false;
	}
	return true;
}

int main(){

	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	if(!check()){ puts("-1"); return 0; }
	ans+=a[n];
	for(int i=n-1;i>=1;i--){
		if(a[i]!=a[i+1]-1) ans+=a[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
 public static void main(String args[]){
  Scanner scn = new Scanner(System.in);
  int N = scn.nextInt();
  String s = scn.next();
  int R =0;
  int B =0;

for(int i=0;i<N;i++){
if(s.charAt(i)=='R'){
R++;
}else{
B++;
}
}
if(R-B>0){
System.out.print("Yes");
}else{
System.out.print("No");
}

    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define ld 	 long double
#define F 	 first
#define S 	 second
#define P 	 pair<int,int>
#define pb 	 push_back
#define mod  1000000007
#define inf  1e18
#define endl '\n'
const int N = 2e3 + 5; //change it when needed
int cache[N][N];
P a[N];
int n;
int dp(int i, int l, int r) {
	if (l > r) {
		return 0;
	}
	int &ans = cache[i][l];
	if (ans != -1)return ans;
	ans = 0;
	//put it at left part
	ans = dp(i + 1, l + 1, r) + a[i].F * abs(a[i].S - l);
	//put it at right part
	ans = max(ans, dp(i + 1, l , r - 1) + a[i].F * abs(a[i].S - r));

	return ans;
}
void solve() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[i] = {x, i};
	}
	memset(cache, -1, sizeof(cache));
	sort(a, a + n);
	reverse(a, a + n);

	cout << dp(0, 0, n - 1);
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 35184
//
//  main.cpp
//  A - One out of Three
//
//  Created by Charles on 2017/10/14.
//  Copyright © 2017年 Charles. All rights reserved.
//

#include <iostream>
#include <map>
using namespace std;
int a,b,c;
map<int,int> m;
int main(int argc, const char * argv[]) {
    scanf("%d%d%d",&a,&b,&c);
    m[a]++;
    m[b]++;
    m[c]++;
    if(m[a]==1) cout<<a<<endl;
    else if(m[b]==1) cout<<b<<endl;
    else if(m[c]==1) cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

rest_left_parenthesis = 0
rest_right_parenthesis = 0
for i in range(n):
  if s[i] == "(":
    rest_left_parenthesis += 1
  else:
    if rest_left_parenthesis > 0:
      rest_left_parenthesis -= 1
    else:
      rest_right_parenthesis += 1

result = "(" * rest_right_parenthesis + s + ")" * rest_left_parenthesis
print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n,a,b;
	C3(n,a,b);
	int ans = 0;
	rep(i,1,n+1){
		int num = i;
		int sum = 0;
		while( num > 0 ){
			sum += num % 10;
			num /= 10;
		}
		if(sum >= a && sum <= b ){
			ans += i;
		}
	}

	P(ans);
	ret 0;
}

Measured memory_bytes: 256
program sample
    implicit none
    character(100)::s
    integer(8) :: i,j,k,m,n,t
    integer(8)::a,b,c,d,ans
    integer(8),allocatable::x(:),y(:)
  
    read(*,*)n 
    read(*,*)t,a
    allocate(x(n))
    read(*,*)x
    t=1000*t
    a=1000*a
    do i=1,n
       if(abs(t-6*x(i)-a)<m)then
            m=abs(t-6*x(i)-a)
            ans=i
       end if
    end do
    write(*,*)ans
    stop
end program sample
  



Measured memory_bytes: 2892
# coding: utf-8
n, m, x, y = map(int, input(). split())
city_x = list(map(int, input().split()))
city_y = list(map(int, input().split()))
if max(city_x) < min(city_y) and x < min(city_y) and max(city_x) < y:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int ret[1000009];

void init() {
	for (int i = 1; i <= 200; i++) {
		for (int j = 1; j <= 200; j++) {
			for (int k = 1; k <= 200; k++) {
				int val = i * i + j * j + k * k + i * j + j * k + k * i;
				ret[val] += 1;
			}
		}
	}
}

int main() {
	init();
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cout << ret[i] << endl;
	return 0;
}

Measured memory_bytes: 4488
import sys
sys.setrecursionlimit(10 ** 6)

import functools
import operator
n = int(input())
p = list(map(float, input().split()))
half = n // 2 + 1

dp = [[None] * (n + 1) for _ in range(n + 1)]
# def dfs(n, depth=n - 1):
#     if depth < 0:
#         return 0
#
#     if dp[n][depth] is not None:
#         return dp[n][depth]
#
#     if n == 0:
#         r = functools.reduce(operator.mul, map(lambda x: 1 - x, p[:depth + 1]))
#     elif (n - 1) == depth:
#         r = functools.reduce(operator.mul, p[:depth + 1])
#     else:
#         r = dfs(n - 1, depth - 1) * p[depth] + dfs(n, depth - 1) * (1 - p[depth])
#     dp[n][depth] = r
#     return r
#
# print(sum(dfs(i) for i in range(half, n + 1)))

for i in range(0, n + 1):
    for depth in range(-1, n):
        if depth == -1:
            dp[i][depth] = 0
        elif i == 0:
            dp[i][depth] = functools.reduce(operator.mul, map(lambda x: 1 - x, p[:depth + 1]))
        elif (i - 1) == depth:
            dp[i][depth] = functools.reduce(operator.mul, p[:depth + 1])
        else:
            dp[i][depth] = dp[i - 1][depth - 1] * p[depth] + dp[i][depth - 1] * (1 - p[depth])

print(sum(dp[i][n - 1] for i in range(half, n + 1)))


Measured memory_bytes: 237576
#include <iostream>
#include <utility>
#include <cmath>

using namespace std;

int main() {
  int n;
  double x[5], y[5], ep;
  pair<double, double> AB, CD;
  cin >> n;
  while(n--) {
    for(int i = 1; i <= 4; i++) {
      cin >> x[i] >> y[i];
    }
    AB.first = x[2] - x[1];
    AB.second = y[2] - y[1];
    CD.first = x[4] - x[3];
    CD.second = y[4] - y[3];
    ep = AB.first * CD.second - AB.second * CD.first;
    if (fabs(ep) < 1e-10) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;

void print_vector(vector<int>& v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << "\n";
    return;
}

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

    bool ans = false;
    int slen = s.length();
    for (int i = 0; i < slen; i++) {
        string ss = s.substr(i, slen) + s.substr(0, i);
        if (ss == t) ans = true;
        if (ans) break;
    }
    if (ans) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a[10];
	int i, j, k;
	for(i=0; i<10; ++i)
		scanf("%d", &a[i]);
	for(i=0; i<10; ++i){
		for(j=i+1; j<10; ++j){
			if(a[i] < a[j]){
				k = a[i];
				a[i] = a[j];
				a[j] = k;
			}
		}
	}
	for(i=0; i<3; ++i)
		printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(Math.max(0, A-2*B));
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<int> s(n);rep(i,n) cin >> s[i];
    sort(s.begin(),s.end(),greater<int>());
    int ans = 0;
    ans = SUM(s,0);
    while(ans%10 ==0 && s.size()>0){
        if (s.back()%10 !=0) ans-=s.back();
        else{
            s.pop_back();
        }
    }
    if (!s.empty())cout << ans << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        100005
#define mod         1000000007
using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,x,y,count=0,mx=0;
    cin>>n>>m;
    ll a[MAXN],l[MAXN],r[MAXN];
    memset(a,0,sizeof(a));
    memset(l,0,sizeof(l));
    memset(r,0,sizeof(r));
    for(i=0;i<m;i++){
        cin>>x>>y;
        l[x]++;
        r[y]++;
    }
    a[1]=l[1];
    for(i=2;i<=n;i++){
        a[i]=l[i]-r[i-1]+a[i-1];
    }
    for(i=1;i<=n;i++){
        if(a[i]==m){
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 2560
#include<cstdio>

using namespace std;

const int maxn=200010;
int fa[maxn],siz[maxn],ans=0;
inline int getf(int x){
	return x==fa[x]?x:fa[x]=getf(fa[x]);
}

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

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		int fx=getf(x),fy=getf(y);
		if(fx==fy) continue;
		fa[fx]=fy;
		siz[fy]+=siz[fx];
		ans=Max(ans,siz[fy]);
	}
	printf("%d\n",Max(1,ans));
	return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
string s[101],ans;
int n,k;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> s[i];
	sort(s+1,s+1+n);
	for (int i = 1; i <= n; i++) ans += s[i];
	cout << ans << endl;
	return 0;	
 } 

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char[] a = N.toCharArray();
    int n = a.length;
    int[][] f = new int[n][2];
    f[n - 1][0] = a[n - 1] - '0';
    f[n - 1][1] = 6 - (a[n - 1] - '5');
    for(int i = n - 2; i > -1; --i) {
      int cur = Math.min(f[i+1][0], f[i+1][1]);
      f[i][0] = cur + (a[i] - '0');
      f[i][1] = Math.min(f[i+1][1] + ('9' - a[i]), f[i+1][0] + 6 - (a[i] - '5'));
    }
    System.out.println(Math.min(f[0][0], f[0][1]));
  }
}
    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int n,k;cin>>n>>k;
  char x;
  REP(i,n){
    cin>>x;
    if(i!=k-1)cout<<x;
    else if(x=='A')cout<<'a';
    else if(x=='B')cout<<'b';
    else cout<<'c';
  }
  cout<<endl;
 
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
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; }

int main(){
    long long n;
    cin>>n;
    long long temp=0;
    vector<long long> a(n),ans(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
        temp^=a[i];
    }

    for(int i=0;i<n;++i){
        long long temp2=temp;
        ans[i]=temp^a[i];
    }

    for(int i=0;i<n;++i) cout<<ans[i]<<" ";
    cout<<endl;
}

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

int main() {
    int A,B,C,X,sum,cnt=0;
    int a=500,b=100,c=50;
    cin >> A >> B >> C >> X;
    
    for(int i = 0; i <=A; i++){
        for(int j = 0; j<=B; j++){
            for(int k = 0; k<=C; k++){
                sum = a*i + b*j + c*k;
                if(sum == X){
                    cnt++;
                }
            }
        }
    }

  cout << cnt << endl;
  
}


Measured memory_bytes: 3540
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

ll thick[55];
ll cont[55];

ll solve(ll n, ll x) {
  if (n == 0) {
    return x <= 0 ? 0 : 1;
  } else if (x <= 1 + thick[n - 1]) {
    return solve(n - 1, x - 1);
  } else {
    return 1 + cont[n - 1] + solve(n - 1, x - 2 - thick[n - 1]);
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;
  thick[0] = 1;
  cont[0] = 1;
  for (int i = 1; i < n; ++i) {
    thick[i] = 3 + thick[i - 1] * 2;
    cont[i] = 1 + cont[i - 1] * 2;
  }
  cout << solve(n, x) << endl;
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c >= 22 ? "bust" : "win") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;

	int a, b;
	cin >>a >> b;
	if(b % a == 0) cout << a+b << endl;
	else cout << b - a << endl;	
	
}



Measured memory_bytes: 256
for(r={I:1,V:5,X:10,L:50,C:100,D:500,M:1000},k=n=s=0,j=require("fs").readFileSync("/dev/stdin","utf8");p=n,i=j[k];k++)i=='\n'?(console.log(s),n=s=0):s+=(n=r[i]),n>p?s-=p*2:0

Measured memory_bytes: 7908
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
	if (a > b) {
		swap(a, b);
	}

	if (a == 0) {
		return b;
	}

	return gcd(b % a, a);
}

ll pow(int k) {
	ll p = 2;
	ll a = 1;

	for (int i = 0; i < 32; i++) {
		if (((k >> i) & 1) == 1) {
			a = (a * p) % MOD;
		}
		p = (p * p) % MOD;
	}
	return a;
}

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

	map<pll,int> s;
	ll ans = 0;
	int num = n;

	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {
			
			num--;
			ans++;
			continue;
		}

		ll g = gcd(abs(a), abs(b));
		a /= g;
		b /= g;
		if (a < 0) {
			a *= -1;
			b *= -1;
		}

		if (a == 0 || b == 0) {
			a = abs(a);
			b = abs(b);
		}

		s[make_pair(a, b)]++;
	}

	
	
	
	queue<ll> q;
	
	
	
	for (auto it = s.begin(); it != s.end(); it++) {
		ll a = it->first.first;
		ll b = it->first.second;
		int n0 = it->second;
		//cout << a << " " << b << " " << n0 << endl;

		auto it1 = s.find(make_pair(-b, a));
		if (a == 0) {
			continue;
			
		}

		if (it1 == s.end()) {
			continue;
		}
		int n1 = it1->second;
		//cout << n1 << endl;
		
		q.push((pow(n0) + pow(n1) - 1) % MOD);
		num -= (n1 + n0);

	}
	ll a = 1;
	while (!q.empty()) {
		a = (a * q.front()) % MOD;
		q.pop();
	}
	a = (a * pow(num)) % MOD;
	a = (a - 1 + MOD) % MOD;
	ans = (ans + a) % MOD;
	
	cout << ans << endl;
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    double W, H, x, y;
    cin >> W >> H >> x >> y;

    if (x * 2 == W && y * 2 == H) {
        printf("%.9f %d\n", W * H / 2.0, 1);
    } else {
        printf("%.9f %d\n", W * H / 2.0, 0);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


struct UnionFind {
    vector<int> par;
    vector<int> sizes;
    vector<int> maxs;
    vector<int> mins;

    UnionFind(int n) :
            par(n), sizes(n, 1), maxs(n), mins(n) {
        rep(i, n) par[i] = i;
        rep(i, n) maxs[i] = i;
        rep(i, n) mins[i] = i;
    }

    int root(int x) {
        if (x == par[x]) return x;
        else return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        maxs[x] = max(maxs[y], maxs[x]);
        mins[x] = min(mins[y], mins[x]);
        sizes[x] += sizes[y];
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return sizes[root(x)];
    }

    int getMax(int x) {
        return maxs[root(x)];
    }

    int getMin(int x) {
        return mins[root(x)];
    }

};


int main(){
    int n, m, k;
    cin >> n >> m >> k;

    vector<int> f(n);
    UnionFind uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
        f[a]++;
        f[b]++;
    }

    vector<int> block(n);
    rep(i, k){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(uf.same(a, b)){
            block[a]++;
            block[b]++;
        }
    }

    rep(i, n){
        cout << uf.size(i) - f[i] - block[i] - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9)
	 cout<<"hon"<<endl;
	else if(n==3)
	 cout<<"bon"<<endl;
	else
	 cout<<"pon"<<endl;
	return 0;
}

Measured memory_bytes: 3636
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

string s;
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    cin >> s;

    int count = 0;
    int result = 0;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0'){
            count++;
        }else{
            result++;
        }
    }



    cout << 2 * min(count, result) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int t,n,s,f;
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		int sum=0;
		rep(i,0,n){
			cin>>s>>f;
			sum+=f-s;
		}
		if(sum>=t) o("OK");
		else o(t-sum);
	}
}

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

signed main() {
  string s; cin >> s;
  int n = s.size();

  int ans1 = 0;
  int ans2 = 0;
  rep(i,n) {
    int c = s[i] - '0';
    if(c == i%2) ans1++;
  }
  rep(i,n) {
    int c = s[i] - '0';
    if(c != i%2) ans2++;
  }
  cout << min(ans1, ans2) << endl;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

const long long mod = 1000000007;

long long powMod(long long x, long long y) {
  long long r = 1, a = x % mod;
  while (y) {
    if (y & 1) r = (r * a) % mod;
    a = a * a % mod;
    y /= 2;
  }
  return r;
}

#define FACT_MAX 200001
long long fact[FACT_MAX];
long long revFact[FACT_MAX];

void setFact() {
  const int N = FACT_MAX;
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  revFact[N - 1] = powMod(fact[N - 1], mod - 2);
  for (int i = N - 2; i >= 0; i--) {
    revFact[i] = revFact[i + 1] * (i + 1);
    revFact[i] %= mod;
  }
}

long long getC(int a, int b) {
  return (((fact[a] * revFact[b]) % mod) * revFact[a - b]) % mod;
}

void Main() {
  setFact();
  int H, W, A, B;
  scanf("%d%d%d%d", &H, &W, &A, &B);

  int y = H - A - 1;
  int x = B;
  ll ans = 0;
  while (y >= 0 && x < W) {
    ll fr = getC(y + x, y);
    ll to = getC(H - y - 1 + W - x - 1, H - y - 1);
    (ans += fr * to % mod) %= mod;
    y--; x++;
  }

  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>

int main(){

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n;
    std::cin >> n;

    std::vector<int> act(3);
    std::vector<int> dp(3);
    for(int day = 0 ; day < n ; ++day){
        for(int j = 0 ; j < 3 ; ++j){
            std::cin >> act[j];
        }
        std::vector<int> new_dp(3 , 0);
        for(int i = 0 ; i < 3 ; ++i){
            for(int j = 0 ; j < 3 ; ++j){
                if(i != j){
                    new_dp[j] = std::max(new_dp[j] , dp[i] + act[j]);
                }
            }
        }
        dp = new_dp;
    }

    std::cout << *std::max_element(dp.begin() , dp.end()) << '\n';
    
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void calc(int *b,int *e){
  int res[3];
  for(int i=0;i<3;i++)res[i]=e[i]-b[i];
  for(int i=2;i>0;i--)
    if(res[i]<0)res[i-1]--,res[i]+=60;
  
  cout << res[0] << " " << res[1] << " " << res[2] << endl;
}

int main(void){
  int b[3],e[3];

  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++)cin >> b[j];
    for(int j=0;j<3;j++)cin >> e[j];
    calc(b,e);
  }
  
  return 0;
}

Measured memory_bytes: 1156
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
'+'とかは問題ない
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        out.println((sc.nextLong()-2)*180);
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    //クラスカル法(0-indexed) n頂点m辺
    static HashSet<Integer> Kruskal(int[] u, int[] v, int[] cost, int n) {
        int m = u.length;
        UF.Init(n);
        PriorityQueue<Integer> S = new PriorityQueue<>((p1, p2) -> cost[p1] - cost[p2]);
        for (int i = 0; i < m; i++) {
            S.add(i);
        }
        //最小全域木をなす辺
        HashSet<Integer> F = new HashSet<>();
        while (!S.isEmpty()) {
            int e = S.poll();
            if (!UF.same(u[e], v[e])) {
                F.add(e);
                UF.unite(u[e], v[e]);
            }
        }
        return F;
    }

    //Union Find木(0-indexed)
    static class UF {
        static int[] d;

        static void Init(int size) {
            d = new int[size];
            for (int i = 0; i < size; i++) {
                d[i] = -1;
            }
        }

        static boolean unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return false;
            if (d[x] > d[y]) {
                int t = d[y];
                d[y] = d[x];
                d[x] = t;
            }
            d[x] += d[y];
            d[y] = x;
            return true;
        }

        static boolean same(int x, int y) {
            return find(x) == find(y);
        }

        static int find(int k) {
            return d[k] < 0 ? k : (d[k] = find(d[k]));
        }

        static int size(int k) {
            return -d[find(k)];
        }
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

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

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

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

        static boolean hasNext() {
            return s.hasNext();
        }

        static boolean hasNextInt() {
            return s.hasNextInt();
        }

    }

    static long gcd(long a, long b) {
        return a % b == 0 ? b : gcd(b, a % b);
    }

}

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

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

int main()
{
    ll n, k;
    cin >> n >> k;
    ll m = 1000000007;
    ll sum = 0;
    for (int i = k; i <= n + 1; i++)
    {
        sum += (((n + 1 - i) * i) + 1)%m;
    }
    sum %= m;
    cout << sum << endl;
}

Measured memory_bytes: 3568
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};



//ll sum[2010][2010];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  vvl sum(2010,vl(2010));
  ll n,m;cin>>n>>m;
  vl s(n);
  rep(i,n)cin>>s[i];
  vl t(m);
  rep(i,m)cin>>t[i];
  rep(i,n){
    rep(j,m){
      if(i!=0)sum[i][j]+=sum[i-1][j];
      sum[i][j]%=MOD;
      if(j!=0)sum[i][j]+=sum[i][j-1];
      sum[i][j]%=MOD;
      if(i!=0&&j!=0)sum[i][j]+=MOD-sum[i-1][j-1];
      sum[i][j]%=MOD;
      if(s[i]==t[j]&&i!=0&&j!=0){
        sum[i][j]+=sum[i-1][j-1];
        sum[i][j]%=MOD;
      }
      if(s[i]==t[j]){
        sum[i][j]++;
        sum[i][j]%=MOD;
      }
    }
  }
  // rep(i,n){
  //   rep(j,m)cout<<sum[i][j]<<" ";
  //   cout<<endl;
  // }
  cout<<(sum[n-1][m-1]+1)%MOD<<endl;
}


  

Measured memory_bytes: 35116
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{ 
  int n,p[20],i,j,k,ans=0;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>p[i]; 
  }
  for(i=1;i<n-1;i++)
  {
    if(min(p[i-1],p[i+1])<p[i]&&p[i]<max(p[i-1],p[i+1]))
    {
      ans++;
      
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  S += S;

  string ans = "No";
  rep(i,0,T.size()) {
    if (S.substr(i, T.size()) == T) ans = "Yes";
  }

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


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

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

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    int N; cin >> N;
    int ac = 0, wa = 0, re = 0, tle = 0;
    for(int i = 0; i < N; i++){
        string s; cin >> s;
        if(s.compare("AC") == 0) ac++;
        else if(s.compare("WA") == 0) wa++;
        else if(s.compare("RE") == 0) re++;
        else tle++;
    }
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int[] numbers = new int[length];
		numbers[0] = scanner.nextInt();
		int xor = numbers[0];
		for(int i = 1; i < length; i++) {
			numbers[i] = scanner.nextInt();
			xor ^= numbers[i];
		}
		
		for(int i = 0; i < length; i++) 
			System.out.print((xor ^ numbers[i]) + " ");
		
	}
}


Measured memory_bytes: 53772
import sys

tyou = 0
hishi = 0

for line in sys.stdin:
    L = map(int, line.split(","))
    
    if L:
        if (L[2] ** 2 == L[0] ** 2 + L[1] ** 2):
            tyou += 1

        if (L[0] == L[1]):
            hishi += 1
    else:
        break

print tyou
print hishi

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

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

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

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

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

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


vector<pl> v;
ll x[MX];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,m;
    cin >> n >> m;
    ll sum = 0;
    F0R(i,m) {cin >> x[i];}
    if(n >= m){ cout <<0<<endl;return 0; }
    sort(x,x+m);
    if(n == 1){ cout << x[m-1]-x[0] << endl; return 0;}

    F0R(i,m-1){
      v.pb(mp(x[i+1] - x[i],i));
    }
    sort(v.begin(),v.end());
    vl peregors;
    ll cnt = 1;
    for (auto it = v.crbegin(); it != v.crend(); it++) {
      // cout << (*it).s << " it.s "<<endl;
      peregors.pb(it->s);
      if(cnt == n-1) break;
      cnt ++;
    }
    ll ans = 0;
    peregors.pb(-1);
    peregors.pb(m-1);
    sort(peregors.begin(),peregors.end());
    F0R(i,peregors.size()-1){
      ans += x[peregors[i+1]] - x[peregors[i]+1];
    }
    cout << ans<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
int arr[2][104];
int n;
int main() {
	cin>>n;
	for (int i = 0;i<2;i++)
		for(int j = 1;j<=n;j++)
		{
			cin>>arr[i][j];
			if(i==0)	arr[i][j]+=arr[i][j-1];
			else{
				arr[i][j] = max(arr[i][j-1],arr[i-1][j])+arr[i][j];
			}
		}
	cout<<arr[1][n];
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<n; ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=n; i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}
vector<int> v[NAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m; cin >> n >> m;
    forn(i, n) {
       int x, y; cin >> x >> y;
       if(m-x >= 0)
        v[m-x].pb(y); 
    }
    priority_queue<ll> pq;
    ll res = 0;
    fornd(i, m) {
       forn(j, (int)v[i].size())
         pq.push(v[i][j]);
       if(!pq.empty()) {
         res += pq.top();
         pq.pop();
       }
    }
    cout << res << "\n";
    return 0;
}


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

int main(){
  int i,j,p,q,n,m;
  char N[50][50], M[50][50];
  cin>>n>>m;
  for(i=0; i<n; i++) cin>>N[i];
  for(i=0; i<m; i++) cin>>M[i];
  for(i=0; i+m<=n; i++){
    for(j=0; j+m<=n; j++){
      for(p=0; p<m; p++){
        for(q=0; q<m; q++){
          if(N[i+p][j+q]!=M[p][q]) break;
        }
        if(q<m) break;
      }
      if(p==m && q==m){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

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

using namespace std;

typedef long long ll;

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

  int n, m;
  cin >> n >> m;

  priority_queue<int> que;

  rep(i, n) {
    int a; cin >> a;
    que.push(a);
  }

  rep(i, m) {
    int t = que.top();
    que.pop();
    que.push(t/2);
  }

  ll ans = 0;
  while (!que.empty()) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int p,q,r,min;
    scanf("%d",&p);
    scanf("%d",&q);
    scanf("%d",&r);
    min=p+q;
    if(p+r<min){
        min=p+r;
    }
    if(q+p<min){
        min=q+p;
    }
    if(q+r<min){
        min=q+r;
    }
    if(r+p<min){
        min=r+p;
    }
    if(r+q<min){
        min=r+q;
    }
        printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,c,k] <- getIntList
    ts <- sort <$> replicateM n getInt
    print $ solve c k ts

solve _ _ [] = 0
solve c k ts | length k1 <= c = 1 + solve c k k2
             | otherwise = 1 + solve c k (drop c ts)
    where t = head ts
          (k1,k2) = span (<=t+k) ts

Measured memory_bytes: 30972
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let a = in_vec[0];
    let b = in_vec[1];

    // a $B$,(B [8.0, 9.0)
    // b $B$,(B [10.0, 11.0)
    // $B$N6h4V$rAv::$9$k(B

    let mut res = 0;

    let base_margin = (a as f64) / 0.08;
    let mut base = if base_margin.fract() == 0. {
        ((a as f64) / 0.08) as usize
    } else {
        ((a as f64) / 0.08) as usize + 1
    };

    while (base as f64 * 0.08) as usize == a {
        if (base as f64 * 0.1) as usize == b {
            res = base;
            break;
        }
        base += 1;
    }

    if res == 0 {
        println!("-1");
    } else {
        println!("{}", res);
    }
}

Measured memory_bytes: 4352
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

    divisors.sort()
    return divisors
lst=make_divisors(n)

ans=float('inf')
for i in lst:
    # print(i)
    ans=min(ans,max(len(str(i)),len(str(n//i))))
print(ans)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

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

ll d[202][202], rr[202];
signed main() {
	ll n, m, r;
  cin >> n >> m >> r;
  rep(i, r) cin >> rr[i];
  rep(i, n) {
    rep(j, n) {
      if (i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  rep(k, n) {
    rep(i, n) {
      rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  vector<int> v;
  rep(i, r) v.pb(rr[i] - 1);
  sort(v.begin(), v.end());
  ll ans = INF;
  do {
    ll sum = 0;
    rep(i, r - 1) {
      sum += d[v[i]][v[i + 1]];
    }
    ans = min(ans, sum);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int64_t intpow(int64_t n, int64_t i)
{
	int64_t ans = 1;
	FOR_LT(j, 0, i) {
		ans *= n;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n; cin >> n;
	if (n % 2 == 0) {
		n /= 2;
		int64_t i = 1;
		int64_t ans = 0;
		while (true) {
			int64_t d = intpow(5, i);
			if (n < d) break;

			ans += (n / d);
			i++;
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256