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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A <= C && C <= B) {
        cout << "Yes" << endl;
    } else if (B <= C && C <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	ll n,k;
	cin>>n>>k;
	vll a(n);
	input(a,n);
	sort(all(a));
	ll ans=0;
	rep(i,0,n-k-1,1)
		ans+=a[i];
	cout<<ans;	
	return 0;
}




Measured memory_bytes: 1792
from collections import deque
N,M = map(int,input().split())
graph = [[] for _ in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

seen = [None]*N
ans = -1

for i in range(N):
    if seen[i]:
        continue
    seen[i] = True
    tmp = 0
    d = deque()
    d.append(i)
    while d:
        v = d.popleft()
        for i in graph[v]:
            if seen[i]:
                continue
            seen[i] = True
            d.append(i)
            tmp += 1
    ans = max(ans,tmp)
print(ans+1)

Measured memory_bytes: 107396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


int main(){
    ll n, k;
    cin >> n >> k;
    vll a(k), b(k);
    REP(i, k){
        cin >> a[i] >> b[i];
        b[i]--;
    }

    ll p1 = 0, p2 = 0, q1 = -1, q2 = -1;
    REP(i, k){
        if(a[i] == 1){
            p1 = 1, q1 = b[i];
        }
        if(a[i] == 2){
            p2 = 1, q2 = b[i];
        }
    }
    
    vector<vector<vector<ll>>> dp(110, vvll(3, vll(3, 0)));
    //i = 2に対して初期化
    REP(s2, 3){
        REP(s1, 3){
            if((p1 && q1 != s2) || (p2 && q2 != s1)) dp[2][s2][s1] = 0;
            else dp[2][s2][s1] = 1;
        }
    }
    //i+1文字目の更新を考えるとき, [p2(i-1文字目)][p1(i文字目)][p0(i+1文字目)]
    for(int i = 2; i < n; i++){
        REP(p2, 3){
            REP(p1, 3){
                REP(p0, 3){
                    ll flg = 0;
                    REP(j, k){
                        if(i + 1 == a[j] && p0 != b[j]) flg = 1;
                    }
                    if(flg) dp[i + 1][p1][p0] = 0;
                    else if((p2 != p0) || (p1 != p0)){
                        dp[i + 1][p1][p0] += dp[i][p2][p1];
                        dp[i + 1][p1][p0] %= 10000;
                    }
                }
            }
        }
    }
    ll res = 0;
    REP(p2, 3){
        REP(p1, 3){
            res += dp[n][p2][p1];
            res %= 10000;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3172
///
// File:  1192.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 08:29:23 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  while (true) {
    int32_t x, y, s;
    cin >> x >> y >> s;

    if (x == 0) break;
    // a * (100 + x) + b * (100 + x) = s * 100
    // max. a * (100 + x) / 100 + b * (100 + y) / 100
    int32_t max_val = 0;
    for (int32_t a = 1; a < s; a++) {
      for (int32_t b = 1; b < s; b++) {
        if (s == a * (100 + x) / 100 + b * (100 + x) / 100) {
          max_val = max(max_val, (a * (100 + y) / 100) + (b * (100 + y) / 100));
        }
      }
    }
    cout << max_val << endl;
  }

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  
  int cost = 10000000;
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    
    for (int j = 0; j < N; j++) {
      sum += abs(i - a[j]) * abs(i - a[j]);
    }
    
    if (cost > sum) {
      cost = sum;
    }
  }
  
  cout << cost << endl;
}

Measured memory_bytes: 3596
#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 main(){
  int n, c, m;
  while(cin>>m>>c>>n && m){
    int b[100][51];
    memset(b, -1, sizeof(b));
    REP(y, n){
      int k; cin>>k;
      REP(x, k) cin>>b[y][x];
    }
    vector<int> desk[11];
    int ans = 0;
    for(int x = 0; x < 51; x++){
      for(int y = 0; y < n; y++){
        int cost = 0;
        if(b[y][x] == -1) continue;
        int id = b[y][x];
        bool shelf = true;
        REP(i, m){
          vector<int>::iterator it = find(desk[i].begin(), desk[i].end(), id);
          if(it != desk[i].end()){
            shelf = false;
            desk[i].erase(it);
            cost += i + 1;
            break;
          }
        }
        if(shelf){
          cost += m + 1;
        }
        if(desk[0].size() < c){
          desk[0].push_back(id);
          cost += 1;
        }else{
          //temp
          int temp = m;
          FOR(i, 1, m){
            if(desk[i].size() < c){
              temp = i;
              desk[i].push_back(id);
              break;
            }
          }
          cost += temp + 1;
          //take
          int take_id = desk[0][0];
          desk[0].erase(desk[0].begin());
          cost += 1;
          //put
          cost += m + 1;
          FOR(i, 1, m){
            if(desk[i].size() < c){
              desk[i].push_back(take_id);
              cost -= m + 1;
              cost += i + 1;
              break;
            }
          }
          //put
          if(temp != m) desk[temp].erase(find(desk[temp].begin(), desk[temp].end(), id));
          cost += temp + 1;

          desk[0].push_back(id);
          cost += 1;
        }
        ans += cost;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b,c;
   cin>>a>>b;
   if(a>b)
    swap(a,b);
   c=a*b;
   for(int i=a;i<=b;i++){
    int temp=c*i;
    if(temp%2){
        cout<<"Yes"<<endl;
        return 0;
    }
   }
cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  vector<int> vec(n);
  int cnt = 1;
  rep(i, n - 1) {
    bool eq = true;
    rep(j, 10) {
      if(s[i][j] != s[i + 1][j]) {
        eq = false;
        break;
      }
    }
    if(eq) {
      cnt++;
    } else {
      vec.push_back(cnt);
      cnt = 1;
    }
  }
  vec.push_back(cnt);
  ll ans = 0;
  for(ll k : vec) {
    ans += k * (k - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8184
s = list(str(input()))
for i in range(len(s)):
    if s[i] in 'ATCG':
        s[i] = 1
    else:
        s[i] = 0
def shakutori(a, k):
    right, cnt = 0, 0
    for left in range(len(a)):
        while right < len(a) and a[right] == k:
            right += 1
        cnt = max(cnt, right - left)
        if right == left:
            right += 1
    return cnt
print(shakutori(s, 1))

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

using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long solve(int N, long long M, vector<long long>& a) {
	bool same = true;
	while (a[0] % 2 == 0) {
		for (int i = 0; i < N; i++) {
			if (a[i] % 2 != 0) return 0;
			a[i] /= 2;
		}
		M /= 2;
	}
	for (int i = 0; i < N; i++) if (a[i] % 2 == 0) return 0;

	long long lcm = 1;
	for (int i = 0; i < N; i++) {
		long long g = GCD(lcm, a[i]);
		lcm = lcm / g * a[i];
		if (lcm > M) return 0;
	}
	return (M / lcm + 1) / 2;
}



int main()
{
	int N; long long M;
	cin >> N >> M;
	vector<long long>a(N);

	for (int i = 0; i < N; i++) cin >> a[i], a[i] /= 2;
	cout << solve(N, M, a) << endl;

	return 0;
}

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

int main() {
    string str;cin>>str;
    int q;cin>>q;
    for(int i=0;i<q;i++){
        string order;cin>>order;
        if(order=="replace"){
            int a,b;cin>>a>>b;
            string s;cin>>s;
            str.replace(a,b-a+1,s);
        }else if(order=="reverse"){
            int a,b;cin>>a>>b;
            string copy=str.substr(a,b-a+1);
            reverse(copy.begin(),copy.end());
            str.replace(a,b-a+1,copy);
        }else if(order=="print"){
            int a,b;cin>>a>>b;
            string copy;
            copy=str.substr(a,b-a+1);
            cout<<copy<<endl;
        }
    }
}


Measured memory_bytes: 3216
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
a_list = [int(elem) for elem in fin().split()]

a_set = set(a_list)

all_xor = 0
for each_a in a_list:
    all_xor = all_xor ^ each_a

if len(a_list) % 3 == 0:
    if all_xor == 0:
        print('Yes')
    else:
        print('No')
else:
    if len(a_set) == 1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 57328
#include "bits/stdc++.h"

using namespace std;

int main() {
    int N, x;
    cin >> N;
    vector<int> A(N);
    vector<bool> D(N);

    for (int i = 0; i < N; ++i) {
        cin >> x;
        A[i] = x - 1;
        D[i] = false;
    }

    int failed = false;
    int cur = 0, ans = 0;
    while (cur != 1) {
        if (D[cur] == true) {
            failed = true;
            break;
        }
        D[cur] = true;
        cur = A[cur];
        ++ans;
    }

    if (failed)
        cout << -1 << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
l = [(int(input())-1) for _ in range(N)]
flag = [0]*N
flag[0] = 1
flag[1] = 2
cnt = 0
cur_b = 0
for i in range(N):
    cnt += 1
    next_b = l[cur_b]
    if flag[next_b] == 1:
        print(-1)
        break
    elif flag[next_b] == 2:
        print(cnt)
        break
    else:
        flag[next_b] == 1
        cur_b = next_b
else:print(-1)        


Measured memory_bytes: 80992
#include<iostream>
#include<algorithm>
using namespace std;
int N,A[200000],max1=-1,max2=-1;
int main(void){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
		if(max1<A[i]){
			max2=max1;
			max1=A[i];	
		}
		else max2=max(max2,A[i]);
	}
	for(int i=0;i<N;i++){
		if(A[i]==max1)cout<<max2<<endl;
		else if(A[i]==max2)cout<<max1<<endl;
		else cout<<max1<<endl;
	}
	return 0;
}


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> aa(m);
    int res = 0;
    for (int i = 0; i < m; i++) {
        cin >> aa.at(i);
        if (aa.at(i) < x)
            res++;
    }
    res = min(res, m - res);
    cout << res << endl;
    // for (int i = 0; i < m; i++)
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		mut a: [usize; n],
	}

	let mut b: Vec<usize> = vec![];
	for i in 0..n {
		if i % 2 == 0 {
			b.push(a[i]);
		}
		else {
			b.insert(0, a[i]);
		}
	}
	if n % 2 == 1 {
		b.reverse();
	}
	for i in 0..n {
		print!("{} ", b[i]);
	}
	println!("");
}



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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << (char)('A' + a[0] - 'a') << (char)('A' + b[0] - 'a') << (char)('A' + c[0] - 'a') << endl;
    return 0;
}

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

namespace _056_Goldbach_sConjecture
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;
			StringBuilder output = new StringBuilder (10000 * 3);

			while ((inputStr = Console.ReadLine ()) != "0")
			{
				int inputNum = int.Parse (inputStr);
				int count = 0;

				bool result = Conjecture.IsConjecture (2, inputNum - 2);
				if (result)
					count++;

				for (int lp = 3; lp <= inputNum / 2; lp += 2)
				{
					bool result2 = Conjecture.IsConjecture (lp, inputNum - lp);
					if (result2)
						count++;
				}

				output.AppendLine (count.ToString ());
			}

			Console.Write (output);
		}
	}

	class Conjecture
	{
		static Conjecture ()
		{
			PrimeNumberArray = new int[50000 + 1];

			//2????????°????????????????????????
			PrimeNumberArray[2] = PrimeNumber;
			for (int lp = 2 * 2; lp < PrimeNumberArray.Length; lp += 2)
			{
				PrimeNumberArray[lp] = NotPrimeNumber;
			}

			double limit = Math.Sqrt (50000);
			for (int lp = 3; lp <= limit; lp += 2)
			{
				if (PrimeNumberArray[lp] != NotPrimeNumber)
				{
					//?????????????????????
					for (int lp2 = lp * 2; lp2 < PrimeNumberArray.Length; lp2 += lp)
					{
						PrimeNumberArray[lp2] = NotPrimeNumber;
					}
				}
			}
		}

		private static int[] PrimeNumberArray;
		private const int PrimeNumber = 0;
		private const int NotPrimeNumber = int.MinValue;
		
		public static bool IsConjecture ( int num, int num2 )
		{
			return
				(PrimeNumberArray[num2] == PrimeNumber) &&
				(PrimeNumberArray[num] == PrimeNumber);
		}
	}
}

Measured memory_bytes: 9672
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        String s = sc.next();
        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38568
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Dec 29 21:10:08 2018
//
package main

import (
	"fmt"
	"sort"
)

func min(slice ...int) int {
	sort.Ints(slice)
	return slice[0]
}

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	n := min(A+B+1, C)
	fmt.Println(n + B)
}


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

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

    int n;
    cin >> n;

    int r = 0, t = 1 << 30;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        t = min(t, a);
        if (a <= t) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int a[100];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	ll sum = 0;
	for(int i = 1;i<=n;i++){
		for(int j = i+1;j<=n;j++){
			sum+=a[i]*a[j];
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 
 #define  int           long long
 #define pb                push_back
 #define ppb               pop_back
 #define pf                push_front
 #define ppf               pop_front
 #define all(x)            (x).begin(),(x).end()
 #define uniq(v)           (v).erase(unique(all(v)),(v).end())
 #define sz(x)             (int)((x).size())
 #define fr                first
 #define sc                second
 #define pint              pair<int,int>
 #define rep(i,a,b)        for(int i=a;i<b;i++)
 #define mem1(a)           memset(a,-1,sizeof(a))
 #define mem0(a)           memset(a,0,sizeof(a))
 #define ppc               __builtin_popcount
 #define ppcll             __builtin_popcountll
 #define vint			   vector<int>
 #define vpint			   vector<pair<int,int>>
 #define mp                make_pair


 void reader() 
 { 
 #ifndef ONLINE_JUDGE 
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout); 
 #endif
 }
 
 void fastIO() {ios_base::sync_with_stdio(false); cin.tie(NULL);}
 
 
 
 void solve()
 {
 
 string s;
 cin>>s;
 int sum=0;
 int n=s.length();
 for(int i=0;i<n;i++)	
 	sum+=s[i]-'0';
 
 if((sum%9)!=0)
 	cout<<"No";
 else
 	cout<<"Yes";
 }
 
 
 
 signed main()
 {
 	reader(); fastIO();
 	long long t=1;
 	//cin>>t;
 	while(t--) solve();
 	return 0;
 }

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int main(){
    cout << fixed << setprecision(12);
    int n,k;cin >> n >> k;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    for(int i=0; i<n; i++) p[i]++;
    queue<int> q;
    int s=0;
    int mx=0;
    for(int i=0; i<n; i++){
        s+=p[i];
        q.push(p[i]);
        if(q.size()>k){
            s-=q.front();q.pop();
        }
        if(q.size()==k){
            mx=max(mx,s);
        }
    }
    double ans=mx;
    ans/=2;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;

int main() {
        int n, m, x;
        scanf("%d%d%d", &n, &m, &x);
        x --;
        vector<int> a(n);
        for (int i = 0; i < m; i ++) {
                int b;
                scanf("%d", &b);
                b --;
                a[b] ++;
        }
        int ans = 1000000;
        int res = 0;
        for (int i = x; i >= 0; i --) {
                res += a[i];
        }
        ans = min(ans, res);
        res = 0;
        for (int i = x; i < n; i ++) {
                res += a[i];
        }
        ans = min(ans, res);
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(H, W) = reads()
A = []

for _ in range(H):
  A.append(input()+".")
A.append("." * (W+1))

walk = [(0, 0)]

for i in range(H + W - 2):
  (y, x) = walk[-1]
  if A[y][x+1] == "#":
      walk.append((y, x+1))
  elif A[y+1][x] == "#":
      walk.append((y+1, x))
  else:
    print("Impossible"); exit()

if all(A[y][x] == "." for y in range(H) for x in range(W) if not (y, x) in walk):
  print("Possible")
else:
  print("Impossible")


Measured memory_bytes: 4064
// AtCoder Beginner Contest 135
// Practice
// A - Harmony
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
const ll mxsize = 1e5 + 15;
const ll linf = 1e9;
const long double inf = 10000000000.0;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
const ll mod = 1e9 + 7;
/******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
 
ll pow(ll x, ll n) {
  if (n == 0)
    return 1ll;
  ll temp;
  temp = pow(x, n / 2);
  if (n % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
 
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
 
int sum_digit(int val) {
  if (val < 0)
    return -1;
  if (val == 0)
    return 0;
  int ans = 0;
  while (val > 0) {
    ans = ans + val % 10;
    val = val / 10;
  }
  return ans;
}
 
ll count_div(ll l, ll r, ll val) {
  if (l % val == 0)
    return (((r / val) - (l / val)) + 1);
  else
    return ((r / val) - (l / val));
}
 
int powmod(int x, int y, int m) {
  int res = 1;
  // x = x % mod;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % m;
    cout << res << endl;
    y = y / 2;
    cout << x << endl;
    x = (x * x) % m;
  }
  // cout << res << endl;
  return res;
}
/******************************************** CODE STARTS FROM HERE *************************************************/ 
 
int main()
{
  fastIO;
  ll A , B;
  cin >> A >> B;
  if(A == B) cout << 0 << endl;
  else
  {
    if((A + B) % 2 == 0) cout << (A + B) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,d,r;
	double f;
	scanf("%d%d",&a,&b);
	d = a / b;
	r = a % b;
	f = (double) a / b;
	printf("%d %d %.5lf\n",d,r,f);
	return 0;
}


Measured memory_bytes: 2716
#include "bits/stdc++.h"

using namespace std;

int main(void) {
  int r, g, b, n; cin >> r >> g >> b >> n;
  int sum = 0;
  for (int i = 0; i <= n / r; i++) {
    for (int j = 0; j <= n / g; j++) {
      int left = n - (r * i + g * j);
      if (left % b == 0 && 0 <= left) {
        sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll x;
    cin >> x;

    ll p = 100;
    ll t = 0;
    while(p < x) {
        p += (p / 100);
        t++;
    }
    cout << t << endl;

    return 0;
}


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

def f(n):
  if n == 1:
    return True
  elif n%2 == 0:
    return f(n/2)
  else:
    return False

n = int(input())
for i in range(n,0,-1):
  if f(i):
    print(i)
    break


Measured memory_bytes: 2940
import sys
from heapq import heappush,heappop
input=sys.stdin.readline
n,q=map(int,input().split())
e=[]
for i in range(n):
  s,t,x=map(int,input().split())
  e.append((s-x,1,x))
  e.append((t-x,-1,x))
for i in range(q):
  d=int(input())
  e.append((d,2,0))
e.sort()
s=set()
a=[]
for time_,type_,x_ in e:
  if type_==1:
    s.add(x_)
    heappush(a,x_)
  elif type_==-1:
    s.remove(x_)
  else:
    while a and a[0] not in s:
      heappop(a)
    if a:
      print(a[0])
    else:
      print(-1)

Measured memory_bytes: 89744
#
from math import gcd


def main():
    k = int(input())
    total = 0
    for i in range(1, k + 1):
        for j in range(1, k + 1):
            g = gcd(i, j)
            for l in range(1, k + 1):
                total += gcd(g, l)
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
main()
{
     long long int res=1,i,j=0,cur=1,ok,n,k,a=1,b=1;
     string s,t;
     vector<int>vect;
     cin>>s>>t;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            j++;
    }
    cout<<j<<endl;
}


Measured memory_bytes: 3920
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

def rui(a):
    ret = [0] * (len(a) + 1)
    for i in range(len(a)):
        ret[i + 1] = ret[i] + a[i]
    return ret

ra = rui(A)
rb = rui(B)

ans = 0
for i in range(N):
    ans = max(ans, ra[i + 1] + rb[N] - rb[i])
print(ans)


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0;i<n;i++)
    cin >> v[i];
  vector<int> dp(n);
  dp[n-2] = abs(v[n-1] - v[n-2]);
  for(int i = n-3;i >= 0;i--)
  {
    dp[i] = min(dp[i+1] + abs(v[i+1] - v[i]) , dp[i+2] + abs(v[i+2] - v[i]) );
  }
  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 3972
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n,m;scanf("%d %d",&n,&m);
    int p[m];
    char s[m][10];
    for(int i=0;i<m;i++)scanf("%d %s",&p[i],s[i]);

    int flg[200000]={};
    int ac[200000]={},pena[200000]={};
    for(int i=0;i<m;i++){
        if(!strcmp(s[i],"AC")){
            flg[p[i]]=1;
        }
        if(!strcmp(s[i],"WA")){
            if(!flg[p[i]]){
                pena[p[i]]++;
            }
        }
    }

    int all_ac=0,all_pena=0;
    
    for(int i=1;i<=n;i++){
         if(flg[i]){
            all_ac++;
            all_pena+=pena[i];
        }
    }
    printf("%d %d\n",all_ac,all_pena);
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int h[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1) cin>>h[i];
  h[n+1]=INT_MAX;
  repv(i,1,n+1)
    {
      if(h[i]<=h[i+1]) continue;
      h[i]--;
      if(h[i]>h[i+1])
	{
	  cout<<"No"<<endl;
	  exit(0);
	}
    }
  cout<<"Yes"<<endl;
  return 0 ;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		long A = scan.nextInt();
		long B = scan.nextInt();
		long C = scan.nextInt();

		long[] length = {A,B,C};

		long ans;

		if(A%2==0|B%2==0|C%2==0){
			ans =0;
		}else{
			Arrays.sort(length);
			ans =0L+ length[0]*length[1];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {
		cin >> A;
		int day = 1;
		while (day <= D) {
			day += A;
			ans++;
		}
	}
	cout << ans+X << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>
#include <map>
#include<iomanip>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}


int main() {
	long long N;
	cin >> N;
	auto *velocity = new long long[6];
	long long Limiting = LLONG_MAX;
	for (size_t i = 0; i < 5; i++) {
		cin >> velocity[i];
		Limiting = min(Limiting, velocity[i]);
	}	
	long long answer = (N / Limiting);
	if (N%Limiting != 0)answer++;
	cout << answer + 4 << endl;
}


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

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    if(s1.length() < s2.length()) swap(s1,s2);
    int lim = s2.length();

    int ans = 0;
    for(int d=lim; d>0; d--){
        set<vector<int> > cnum;
        vector<int> a(26, 0);
        for(int i=0; i<d; i++){
            a[s1[i]-'a']++;
        }
        cnum.insert(a);
        for(int i=0; i<(int)s1.length()-d; i++){
            a[s1[i]-'a']--;
            a[s1[i+d]-'a']++;
            cnum.insert(a);
        }

        a = vector<int>(26, 0);
        bool found = false;
        for(int i=0; i<d; i++){
            a[s2[i]-'a']++;
        }
        set<vector<int> >::iterator itr;
        if(cnum.find(a) != cnum.end()){
            found = true;
        }
        for(int i=0; i<(int)s2.length()-d && !found; i++){
            a[s2[i]-'a']--;
            a[s2[i+d]-'a']++;
            if(cnum.find(a) != cnum.end()){
                found = true;
            }
        }
        
        if(found){
            ans = d;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3900
SX, SY, TX, TY = gets.chomp.split(" ").map(&:to_i)

ans = ""
ans += 'R' * (TX-SX) + 'U' * (TY-SY)
ans += 'L' * (TX-SX) + 'D' * (TY-SY)
ans += 'D' + 'R' * (TX-SX+1) + 'U' * (TY-SY+1) + 'L'
ans += 'U' + 'L' * (TX-SX+1) + 'D' * (TY-SY+1) + 'R'

puts ans


Measured memory_bytes: 1916
n = int(input())
k = int(input())


def checker(num):	
	if num > k: # 変化する量はkかnumなので，そのその大小で区別すればよい
		return num+k
		
	else:
		return num*2
		

num = 1
for var in range(0,n):
	num = checker(num)
print(num)



Measured memory_bytes: 2940
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

temp=list(map(lambda x:int(x),input().split()))
A,B,C,D=temp[0],temp[1],temp[2],temp[3]
public_cd=gcd(C,D)

c_n_full=B//C
d_n_full=B//D
cd_n_full=B//((C*D)//public_cd)

c_n_par=(A-1)//C
d_n_par=(A-1)//D
cd_n_par=(A-1)//((C*D)//public_cd)

c_n=c_n_full-c_n_par
d_n=d_n_full-d_n_par
cd_n=cd_n_full-cd_n_par
counter=(B-A+1)-(c_n+d_n)+cd_n

print(counter)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

int dp[41][401][401];

void solve() {
  rep(i, 41) rep(j, 401) rep(k, 401) dp[i][j][k] = 1e9;
  dp[0][0][0] = 0;
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  rep(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    rep(j, 401) rep(k, 401) {
      if (dp[i][j][k] == 1e9) continue;
      amin(dp[i + 1][j][k], dp[i][j][k]);
      amin(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
    }
  }
  int ans = 1e9;
  int c = 1;
  while (c * Ma <= 400 && c * Mb <= 400) {
    int a = c * Ma, b = c * Mb;
    amin(ans, dp[N][a][b]);
    c++;
  }
  if (ans == 1e9) cout << -1 << '\n';
  else cout << ans << '\n';
}


Measured memory_bytes: 25984
#include<iostream>
#define PC 4
#define PD 7
using namespace std;

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

    if (N % PC == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    if (N % PD == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    if (N % (PC + PD) == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    int q = N / PC;
    if (q <= 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1; i < q; i++) {
        if ((N - PC * i) % PD == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        N -= PD;
    }
    cout << "No" << endl;

    return 0;
}

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


int ip[13];
int c[13];


int main(){
	
	int ds = 0;
	scanf(" %d",&ds);
	
	for(int i=0;i<ds;i++){
		for(int j=1;j<13;j++){
			c[j] = 100;
		}
		c[0] = -1;
		
		for(int j=0;j<10;j++){
			scanf(" %d",&ip[j]);
		}
		
		for(int j=9;j>-1;j--){
			
			for(int k=0;k<11;k++){
				if(c[k]<ip[j]){
					c[k+1] = min(c[k+1],ip[j]);
				}
			}
		}
		int ans = 1;
		while(c[ans]< 50) ans++;
		if(ans<4) printf("YES\n");
		else printf("NO\n");
	
	}
	
	
	return 0;
}

Measured memory_bytes: 1008
#include <stdio.h>

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


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,k;
    cin>>n>>k;
    ve <ll> arr(n);
    rep (i,0,n)
    {
        cin>>arr[i];
    }
    rep (i,k,n)
    {
        if (arr[i]>arr[i-k])
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
}


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


int main(){
  int64_t N,D,A,ans=0;
  cin >> N >> D >> A;
  vector<pair<int64_t,int64_t>> X(N);
  queue<pair<int64_t,int64_t>> P;
  for(int64_t i=0;i<N;i++){
    cin >> X.at(i).first >> X.at(i).second;
  }
  sort(X.begin(),X.end());
  int64_t a=0;
  for(int64_t i=0;i<N;i++){
    while(!P.empty()){
      if(P.front().first<X.at(i).first){
        a-=P.front().second;
        P.pop();
      }else{
        break;
      }
    }
    if(X.at(i).second<=a){
      X.at(i).second=0;
      continue;
    }else{
      X.at(i).second-=a;
    }
    ans+=(X.at(i).second-1)/A+1;
    a+=A*((X.at(i).second-1)/A+1);
    P.push(pair<int64_t,int64_t>(X.at(i).first+2*D,A*((X.at(i).second-1)/A+1)));
    
  
      
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int t;
    cin>>t;
    n-=t;
    if(n<0)
    {
      cout<<-1;
      return 0;
    }
  }
  cout<<n;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a[10001];
int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
	cin>>a[i];
	sum+=a[i];
	}
	if(k==n)
	{
	cout<<sum<<endl;
	return 0;
	}
	sort(a+1,a+n+1);
	int l=n-k,ans=0;
    for(int i=l+1;i<=n;i++)
	ans+=a[i];
	cout<<ans<<endl;
	return 0;	
}

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

typedef long long ll;
typedef vector<int> vi;

const int M = 1000000007, BIG = 0x3f3f3f3f;

int n;
ll d;
vector<ll> a, b;

int Process() {
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (a[i] * a[i] + b[i] * b[i] <= d * d)
      ans++;
  return ans;
}

void Output() { cout << Process() << "\n"; }

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

  while (cin >> n) {
    cin >> d;
    a.resize(n);
    b.resize(n);
    for (int i = 0; i < n; i++)
      cin >> a[i] >> b[i];

    Output();
  }

  return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush
import sys
def main():
    input = sys.stdin.readline
    N, M, S = map(int, input().split())
    G1 = [[] for _ in range(N)]
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u, v = u - 1, v - 1
        G1[u].append((b, a, v))
        G1[v].append((b, a, u))
    G2 = [tuple(map(int, input().split())) for _ in range(N)]

    q = [(0, (0, S))]
    T = [-1] * N
    lenT = 0
    visited = set()
    MX = 50 * (N - 1)
    while q:
        t, V = heappop(q)
        v, s = V
        if T[v] < 0:
            T[v] = t
            lenT += 1
            if lenT >= N: break
        if V in visited: continue
        visited.add(V)
        for dt, ds, to in G1[v]:
            if s < ds: continue
            nV = (to, s - ds)
            if nV in visited: continue
            heappush(q, (t + dt, nV))
        c, d = G2[v]
        if s + c <= MX:
            heappush(q, (t + d, (v, s + c)))
    for i in range(1, N):
        print(T[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 123168
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;

#define N 1100000

typedef long long LL;

LL pre[N];
map<LL, LL> ma;

int main() {
    LL n;
    while (scanf("%lld",&n) == 1) {
        LL x = 0;
        ma.clear();
        memset(pre, 0, sizeof(pre));
        for (int i = 1; i <= n; ++i) {
            scanf("%lld",&x);
            pre[i] = pre[i - 1] + x;
        }

        LL cnt = 0;
        for (int i = 1; i <= n; ++i) {
            if (pre[i] == 0) ++cnt;
            if (ma.count(pre[i]) == 0) ma[pre[i]] = 0;
            cnt += ma[pre[i]];
            ma[pre[i]]++;
        }
        printf("%lld\n", cnt);
    }
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	long long ans = 0;
	vector<long long> CChoose(N);
	CChoose[N - 1] = distance(upper_bound(C.begin(), C.end(), B[N - 1]), C.end());
	for (int i = N - 2; i >= 0; i--) CChoose[i] = CChoose[i + 1] + distance(upper_bound(C.begin(), C.end(), B[i]), C.end());

	for (int i = 0; i < N; i++) {
		int d = distance(B.begin(), upper_bound(B.begin(), B.end(), A[i]));
		if (d < N) ans += CChoose[d];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int a, b;
	cin >> a >> b;

	if (a == 1) a = 99;
	if (b == 1) b = 99;
	

	if (a < b) {
		cout << "Bob" << endl;
	} else if (a > b) {
		cout << "Alice" << endl;
	} else {
		cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.Scanner;

public class Main {

    static Scanner scanner;

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

        int N=gi();

        if(N==1) {
            System.out.println(0);
        } else {
        	System.out.println(1);
        }
    }

    // 文字列として入力を取得
    public static String gs() {
         return scanner.next();
    }

    // intとして入力を取得
    public static int gi() {
         return Integer.parseInt(scanner.next());
    }

    // longとして入力を取得
    public static long gl() {
         return Long.parseLong(scanner.next());
    }

    // doubleとして入力を取得
    public static double gd() {
         return Double.parseDouble(scanner.next());
    }
}

Measured memory_bytes: 35564
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    string s;
    cin >> s;
    int ans = -1;
    if(s.size() == 1) ans = s[0]-'0';
    else if(count(++s.begin(), s.end(), '9') == s.size()-1){
        ans = s[0]-'0' + 9*(s.size()-1);
    }else{
        ans = s[0]-'0'-1 + 9*(s.size()-1);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256