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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> Q(M);
    rep(i, M) { cin >> Q[i].first >> Q[i].second; }
    sort(all(Q));

    int ans = 0;
    int cur_l, cur_r;
    tie(cur_l, cur_r) = Q[0];
    for (int i = 1; i < M; i++) {
        int left, right;
        tie(left, right) = Q[i];
        if (cur_r <= left) {
            ans++;
            cur_l = left, cur_r = right;
        } else {
            cur_l = left;
            cur_r = min(cur_r, right);
        }
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ll l,r;
    cin >> l >> r;
    ans+=(r-l+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N;
        static int[] A, B, C;
        

        public static void Input()
        {
            var cin = new Scanner();
            N = int.Parse(Console.ReadLine());
            A = cin.SplitReader();
            B = cin.SplitReader();
            C = cin.SplitReader();
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            Sort(A);
            
            Sort(C);
            var s = new Solve();
            long ans = 0;
            for(var i = 0; i < N; i++)
            {
                int a = 1 + s.LowerBound(A, B[i]);
                int c = N - s.UpperBound(C, B[i]);
                ans += (long)a * c;
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

        public int LowerBound(int[] array, int b)
        {
            int l = -1;
            int r = array.Length;

            while (r - l > 1)
            {
                int c = (l + r) / 2;
                if (array[c] >= b)
                {
                    r = c;
                }
                else
                {
                    l = c;
                }
            }

            return l;
        }

        public int UpperBound(int[]array,int b)
        {
            int l = -1;
            int r = array.Length;

            while (r - l > 1)
            {
                int c = (l + r) / 2;
                if (array[c] > b)
                {
                    r = c;
                }
                else
                {
                    l = c;
                }
            }
            return r;
        }
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 34892
/*  union_find_tree_size.cpp
    素集合系を union-find tree で管理するライブラリ
    併合時の工夫：union by size

    verified: AtCoder ABC157 D - Friend Suggestions
        https://atcoder.jp/contests/abc157/tasks/abc157_d
*/

#include <bits/stdc++.h>
using namespace std;

/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N + M);  // Union-Find Tree で考える
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int L;
            cin >> L;
            uf.unite(i, N + L - 1);
        }
    }
    bool flag = true;
    for (int i = 0; i < N - 1; i++) {
        if (!uf.isSame(i, i + 1)) flag = false;
    }
    if (flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1792
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			set.add(s);
		}
		System.out.println(set.size());

		sc.close();
	}

}

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

int main()
{
    int t=1;
    //cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        ll a[n+1];
        for(int i=1;i<=n;i++) cin>>a[i];
        ll prod[n+1];
        prod[0]=1;
        for(int i=1;i<=k;i++) prod[i]=prod[i-1]*a[i];
        for(int i=k+1;i<=n;i++){
            if(a[i]>a[i-k]) cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 6712
import sys
input = sys.stdin.readline
H, W = [int(x) for x in input().split()]
a = []
for _ in range(H):
    a.append(list(input().rstrip()))
import numpy as np
a = np.array(a, np.object)
a = a.T
retsu = []
gyou = []
for i in range(W):
    if "#" not in a[i]:
        retsu.append(i)
a = a.T
for i in range(H):
    if "#" not in a[i]:
        gyou.append(i)
a = np.delete(a, retsu, 1)
a = np.delete(a, gyou, 0)
for j in a:
    j = list(j)
    print("".join(j))

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 1010;
const int MM = 200010;

int N, M;
int a[MM], b[MM];

vector<pii> g[MN];

bool no_need[MM];
bool vis[MN];
bool can[MN][MN];

void dfs(int v, int st) {
	vis[v] = 1;
	for (auto e : g[v]) {
		if (!vis[e.fi] && e.fi != st) {
			dfs(e.fi, st);
		} 
	}
}

int main() {
	scanf("%d%d", &N, &M);

	rep(i, M) {
		scanf("%d%d", &a[i], &b[i]);
		--a[i]; --b[i];
		g[a[i]].eb(b[i], i);
	}

	rep(i, N) {
		queue<int> que;
		can[i][i] = 1;
		que.push(i);

		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (auto e : g[v]) {
				if (!can[i][e.fi]) {
					can[i][e.fi] = 1;
					que.push(e.fi);
				}
			}
		}
	}

	rep(i, N) {
		rep(t, 2) {
			memset(vis, 0, sizeof(vis));

			for (auto e : g[i]) {
				if (vis[e.fi]) {
					no_need[e.se] = true;
				} else {
					dfs(e.fi, i);
				}
			}
			reverse(ALL(g[i]));
		}
	}

	rep(i, M) {
		puts(no_need[i] == can[b[i]][a[i]] ? "same" : "diff");
	}

	return 0;
}

Measured memory_bytes: 7040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] a = new int[n];
			int[] b = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = cin.Int();
				b[i] = cin.Int();
			}

			long ans = 0;
			long sum = 0;
			for (int i = n - 1; i >= 0; --i) {
				long mod = (a[i] + sum) % b[i];
				long temp = mod == 0 ? 0 : b[i] - mod;
				sum += temp;
				ans += temp;
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 17312
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
ll ca[100005];
bool getnext(ll& l,ll& r,ll a){
	l=(l-1)/a+1;
	r=r/a;
	if(l>r)return false;
	l*=a;
	r=(r+1)*a-1;
	return true;
}
int main(){
	int n;
	ll l=2LL,r=2LL;
	scanf("%d",&n);
	rep(k,n)scanf("%lld",&ca[k]);
	for(int k=n-1;k>=0;k--)
	if(!getnext(l,r,ca[k])){
		printf("-1\n");
		return 0;
	}
	printf("%lld %lld\n",l,r);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define MAX 1e9+7
#define MIN -MAX
#define i(a) cin>>a
#define in(a,b) cin>>a>>b
#define o(a) cout<<a
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loop1(i,a,b) for(ll i=a;i<=b;i++)
#define v(a) vector<ll>a
#define mp(a,b) make_pair(a,b)
#define NO_OF_CHARS 256
using namespace std;
int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;

            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
int power(int x,int y)
{
    int temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
int lenOfLongIncSubArr(int arr[], int n)
{
    // 'max' to store the length of longest
    // increasing subarray
    // 'len' to store the lengths of longest
    // increasing subarray at diiferent
    // instants of time
    int max = 1, len = 1;

    // traverse the array from the 2nd element
    for (int i=1; i<n; i++)
    {
        // if current element if greater than previous
        // element, then this element helps in building
        // up the previous increasing subarray encountered
        // so far
        if (arr[i] <= arr[i-1])
            len++;
        else
        {
            // check if 'max' length is less than the length
            // of the current increasing subarray. If true,
            // then update 'max'
            if (max < len)
                max = len;

            // reset 'len' to 1 as from this element
            // again the length of the new increasing
            // subarray is being calculated
            len = 1;
        }
    }

    // comparing the length of the last
    // increasing subarray with 'max'
    if (max < len)
        max = len;

    // required maximum length
    return max;
}
//In one operation u can choose any element in an array
//and divide it by 2.The value of K is given and we can divide
//K times.We have to find the minm sum.
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    cout<<lenOfLongIncSubArr(a,n)-1;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define F first
#define S second
#define MAX_N 5050
using namespace std;
typedef pair<int,int>pii;
typedef pair<pii,int>piii;
const int INF=1e9;
int d[MAX_N][MAX_N];
int main(){
    int N,K,C,R;
    pii taxi[MAX_N];
    cin>>N>>K;
    vector<vector<int> >G(N);
    priority_queue<piii,vector<piii>,greater<piii> >que;
    for(int i=0;i<N;i++){
        cin>>C>>R;
        taxi[i]=pii(C,R);
    }
    for(int i=0;i<K;i++){
        int a,b;
        cin>>a>>b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    fill(d[0],d[0]+MAX_N*MAX_N,INF);
    d[0][0]=0;
    que.push(piii(pii(0,0),0));
    while(!que.empty()){
        piii CQ=que.top();que.pop();
        int town=CQ.F.S,r=CQ.S;
        if(d[town][r]<CQ.F.F)continue;
        if(r>0){
            for(int i=0;i<G[town].size();i++){
                int to=G[town][i];
                if(d[to][r-1]>d[town][r]){
                    d[to][r-1]=d[town][r];
                    que.push(piii(pii(d[to][r-1],to),r-1));
                }
            }
        }
        pii t=taxi[town];
        for(int i=0;i<G[town].size();i++){
                int to=G[town][i];
                if(d[to][t.S-1]>d[town][r]+t.F){
                    d[to][t.S-1]=d[town][r]+t.F;
                    que.push(piii(pii(d[to][t.S-1],to),t.S-1));
                }
        }
    }
    int ans=*min_element(d[N-1],d[N-1]+N);
    cout<<ans<<endl;
}

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

int a[100005];

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

    for (int x = 1; x * x <= n; x++) {
        for (int y = 1; y * y <= n; y++) {
            for (int z = 1; z * z <= n; z++) {
                int v = x * x + y * y + z * z + x * y + y * z + z * x;
                if (v <= n) a[v]++;
            }
        }
    }

    rep(i, n) cout << a[i + 1] << endl;
    return 0;
}


Measured memory_bytes: 3540
N, K = map(int, input().split())
x = list(map(int, input().split()))

# R = [x[i] for i in range(N) if x[i] >= 0]
# L = [abs(x[i]) for i in range(N-1, -1, -1) if x[i] < 0]

# len_R = len(R)
# len_L = N - len_R
# r = 0
# l = 0
# time = 1e10

# dp_r = [0] * (len_R + 1) #右サイドでi個選んだ時のコストdp[i]
# dp_l = [0] * (len_L + 1)

# for i in range(1, N-1):
#     dp_r[i] = min(dp_r[i-1] + R[i])
def cost(i):
    l = i
    r = i+K
    if x[l] >= 0:
        return abs(x[r-1])
    elif x[r-1] <= 0:
        return abs(x[l])
    else:
        if abs(x[l]) < abs(x[r-1]):
            return 2*abs(x[l]) + abs(x[r-1])
        else:
            return 2*abs(x[r-1]) + abs(x[l])
ans = 1e12
for i in range(0, N-K+1):
    ans = min(ans, cost(i))
print(ans)

Measured memory_bytes: 85420
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestApp2
{
    class Program
    {
        static void Main()
        {
            var str = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();
            var anti = Console.ReadLine()
                .Split(new[] { ' ' },StringSplitOptions.RemoveEmptyEntries)
                .Select(x => int.Parse(x))
                .ToList();
            var n = str[0];
            var count = n;
            while (true)
            {
                if (IsOk(anti, count))
                {
                    Console.WriteLine(count);
                    break;
                }
                else
                {
                    count++;
                }
            }
            Console.ReadLine();
        }

        static bool IsOk(List<int> ls, int num)
        {
            var st = num.ToString();
            foreach (var item in ls)
            {
                st = st.Replace(item.ToString(), "");
            }
            if (st.Length == 0 || st.Replace("0","").Length == 0 || st[0] == '0' || int.Parse(st) < num)
                return false;
            else
                return true;
        }
    }

}

Measured memory_bytes: 15420
if __name__ == '__main__':
    N=int(input())

    dp=[100000000000]*(N+1)
    for i in range(min(6,N+1)):
        dp[i]=i
    for i in range(N+1):
        for j in range(1,7):
            if i+6**j<=N:
                dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        for j in range(1, 6):
            if i + 9 ** j <= N:
                dp[i + 9 ** j] = min(dp[i + 9 ** j], dp[i] + 1)


    print(dp[N])




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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  int m = (c-a) * 60 + (d-b);
  int ans = m - k;
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <unordered_map>
#include <queue>
#include <array>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//const int mod = ;

void fail() {
  cout << -1 << endl;
  exit(0);
}

int main() {
  //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  vii a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  vi q;
  int pr = -1;
  for (int t = 0; t <= k; ++t) {
    sort(a.rbegin(), a.rend());
    int last = -1;
    for (pii& p : a) {
      if (p.second == pr) continue;
      --p.first;
      if (p.first < 0) fail();
      last = p.second;
      q.push_back(last);
    }
    pr = last;
  }
  cout << q.size() << endl;
  for (int i : q) cout << i << ' ';
  return 0;
}


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

using namespace std;

int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    string s;
    bool flag = true;
    int A[30];
    cin >> s;
    for (int i = 0; i < 30; i++) {
        A[i] = 0;
    }
    for (int i = 0; i < s.length(); i++) {
        A[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (A[i] == 0) {
            flag = false;
            cout << (char)(i+'a') << endl;
            break;
        }
    }
    if (flag) cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MAX_V 20
using namespace std;

struct edge { 
  int to, cost;
  edge(){}
  edge(int to,int cost):to(to),cost(cost){};
};
typedef pair<int ,int> P;
const int INF = 1 << 30;
int V; //ノードの数
vector<edge> Graph[MAX_V];
int min_cost[MAX_V];

void Dijkstra(int s){ // s:スタートからの最小コストをmin_costに設定
  priority_queue<P,vector< P >, greater<P> > que;
  fill(min_cost,min_cost + V,INF);
  min_cost[s] = 0;
  que.push(P(0,s));
  
  while(!que.empty()){
    P p = que.top();que.pop();
    int now = p.second;
    int cost = p.first;
    if(min_cost[now] < cost) continue;
    
    for(int i = 0; i < Graph[now].size(); i++){
      edge e = Graph[now][i];
      if(min_cost[e.to] > min_cost[now] + e.cost){
	min_cost[e.to] = min_cost[now] + e.cost;
	que.push(P(min_cost[e.to], e.to));
      }
    }
  }
}

int main(){
  int m;
  cin>>V;
  cin>>m;
  int ans;
  for(int i=0;i<m;i++){
    int a,b,c,d;
    char ch;
    cin>>a>>ch>>b>>ch>>c>>ch>>d;
    a--;b--;
    Graph[a].push_back(edge(b,c));
    Graph[b].push_back(edge(a,d));
  }
  int s1,s2,money,cst;
  char ch;

  cin>>s1>>ch>>s2>>ch>>money>>ch>>cst;
  s1--;s2--;
  ans = money - cst;
  
  Dijkstra(s1);
  ans -= min_cost[s2];
  Dijkstra(s2);
  ans -= min_cost[s1];
  
  cout << ans << endl;
}
  

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


typedef long long ll;
typedef double ld;
const int N=300100;
ll x[N],y[N],f[N],g[N],h[N],p[N],q[N],tmp[N];
int a[N],n,m,Q[N];

ld K(int i,int j){return (ld)(y[i]-y[j])/(x[i]-x[j]);}

void calc(int*a,ll*f){
	ll sum=f[0]=0;
	int t=0,w=0;Q[0]=0;
	for(int i=1;i<=n;++i){
		sum+=1-2*a[i];
		for(;t<w&&K(Q[w],Q[w-1])<=i;--w);
		f[i]=max(f[i-1],sum+(ll)i*i+y[Q[w]]-(ll)x[Q[w]]*i);
		x[i]=2*i;y[i]=f[i]+(ll)i*i-sum;
		for(;t<w&&K(Q[w],Q[w-1])<=K(Q[w],i);--w);
		Q[++w]=i;
	}
	for(int i=1;i<=n;++i)f[i]/=2;
}

void trans(ll*a,ll*b,int n,int m,ll*c){
	int t=0,w=-1;
	for(int i=1;i<=m;++i){
		y[i]=b[i];x[i]=-i;
		for(;t<w&&K(Q[w],Q[w-1])>=K(Q[w],i);--w);
		Q[++w]=i;
	}
	for(int i=1;i<=n;++i){
		for(;t<w&&K(Q[t],Q[t+1])<=i;++t);
		c[i]=a[i]+y[Q[t]]-(ll)i*x[Q[t]];
	}
	for(int i=n-1;i;--i)c[i]=max(c[i],c[i+1]);
}

void solve(int l,int r){
	if(l==r){
		h[l]=max(h[l],f[l-1]+g[l+1]+1-a[l]);
		return;
	}
	int mid=(l+r)/2;
	int nl=mid-l+1,nr=r-mid;ll sum=0;
	for(int i=1;i<=nl;++i)sum+=a[mid-i+1],p[i]=f[mid-i]+(ll)i*(i+1)/2-sum;
	sum=0;
	for(int i=1;i<=nr;++i)sum+=a[mid+i],q[i]=g[mid+i+1]+(ll)i*(i+1)/2-sum;
	trans(p,q,nl,nr,tmp);for(int i=1;i<=nl;++i)h[mid-i+1]=max(h[mid-i+1],tmp[i]);
	trans(q,p,nr,nl,tmp);for(int i=1;i<=nr;++i)h[mid+i]=max(h[mid+i],tmp[i]);
	solve(l,mid);solve(mid+1,r);
}


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i],h[i]=1-a[i];
	calc(a,f);reverse(a+1,a+n+1);
	calc(a,g);reverse(a+1,a+n+1);reverse(g+1,g+n+1);
	solve(1,n);
	for(cin>>m;m --> 0;){
		int x,y;cin>>x>>y;
		cout<<max(f[x-1]+g[x+1],h[x]+a[x]-y)<<'\n';
	}
	return 0;
}


Measured memory_bytes: 22656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int a, b, c;

int main() {
	cin >> a >> b >> c;
	int dd = b / a;
	int ans = min(dd, c);
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding:utf-8


def main():
    N = int(input())
    s_list = []
    for i in range(N):
        s_list.append(input().rstrip())

    ans = 0
    a_last = 0
    ab_count = 0
    b_start = 0
    for si in s_list:
        if si[0] == "B" and si[-1] == "A":
            ab_count += 1
        elif si[0] == "B":
            b_start += 1
        elif si[-1] == "A":
            a_last += 1

        for i in range(len(si)-1):
            if si[i] == "A" and si[i+1] == "B":
                ans += 1

    if ab_count > 0:
        ans += ab_count - 1
        if a_last == 0 and b_start == 0:
            pass
        else:
            ans = ans + min(a_last, b_start) + 1
    else:
        ans = ans + min(a_last, b_start)
    # print(ab_count, a_last, b_start)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 46296
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
	int N, A, B; cin >> N >> A >> B;
	string S; cin >> S;
	int passed = 0, passed_B = 0;
	for(int i = 0; i < N; i++) {
		if(S[i] == 'a') {
			if(passed < A + B) {
				passed++;
				puts("Yes");
			} else puts("No");
		} else if(S[i] == 'b') {
			if(passed < A + B && passed_B+1 <= B) {
				passed++, passed_B++;
				puts("Yes");
			} else puts("No");
		} else puts("No");
	}
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int a,b;

	cin>>a>>b;
	cout<<(b-a)*(b-a+1)/2-b<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <set>

using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> P(N), C(N);
  for (int i = 0; i < N; i++) cin >> P[i];
  for (int i = 0; i < N; i++) cin >> C[i];

  vector<vector<ll>> R, T;
  set<int> s;
  for (int i = 0; i < N; i++) s.insert(i);
  while(!s.empty()) {
    int x = *s.begin();
    s.erase(x);
    R.push_back({});
    T.push_back({});
    auto &r = R.back();
    auto &t = T.back();
    r.push_back(x);
    t.push_back(C[x]);
    while(P[x] - 1 != r.front()) {
      x = P[x] - 1;
      r.push_back(x);
      t.push_back(C[x]);
      s.erase(x);
    }
  }

  ll ans = -1e18;
  for (auto t: T) {
    //    for (auto x: t) cout << x << " ";
    //        cout << endl;
    if (K > (int)t.size()) {
      ll tot = accumulate(begin(t),end(t),0ll);
      if (tot > 0) {
        ll lans = tot * ((K-1)/t.size());
        for (int i = 0, n = t.size(); i != n; ++i) {
          ll sum{};
          for (int j = 0; j != (K-1)%n+1; ++j) {
            sum += t[(i+j)%n];
            ans = max(sum+lans,ans);
          }
        }        
      } else {
        for (int i = 0, n = t.size(); i != n; ++i) {
          ll sum{};
          for (int j = 0; j != n; ++j) {
            sum += t[(i+j)%n];
            ans = max(sum,ans);
          }
        }
      }
    } else {
      for (int i = 0, n = t.size(); i != n; ++i) {
        ll sum{};
        for (int j = 0; j != K; ++j) {
          sum += t[(i+j)%n];
          ans = max(sum,ans);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4052
type hyper_int = Fin of int | Inf
let str_of_hyper_int = function Fin i -> string_of_int i | Inf -> "Inf"
let min x y = if x = Inf then y else if y = Inf then x else min x y
let min_of_list ls =
  let rec inner acc = function [] -> acc | l::ls -> inner (min l acc) ls
  in inner Inf ls
let add x y = match x, y with Fin x, Fin y -> Fin (x + y) | _, _ -> Inf

let solve bamboos a b c =
  let rec inner bamboos a' b' c' =
    match bamboos with
    | [] ->
       if a' = 0 || b' = 0 || c' = 0 then Inf
       else Fin ((abs @@ a - a') + (abs @@ b - b') + (abs @@ c - c') - 30)
    | l::ls -> 
       let use_as_a = add (Fin 10) (inner ls (a' + l) b' c') in
       let use_as_b = add (Fin 10) (inner ls a' (b' + l) c') in
       let use_as_c = add (Fin 10) (inner ls a' b' (c' + l)) in
       let not_use  = inner ls a' b' c' in
       min_of_list [use_as_a; use_as_b; use_as_c; not_use]
  in inner bamboos 0 0 0

let _ =
  let n, a, b, c = Scanf.scanf "%d %d %d %d\n" (fun n a b c -> n, a, b, c) in
  let bamboos = ref [] in
  for i = 0 to n - 1 do
    Scanf.scanf "%d\n" (fun b -> bamboos := b::!bamboos)
  done;
  solve !bamboos a b c
  |> str_of_hyper_int
  |> print_string

Measured memory_bytes: 2560
def gcd(x, y):
  #assert x >= y
  return gcd(y, x%y) if y else x
 

N, X = [int(i) for i in input().split()]
Xn = [int(i) for i in input().split()]

dx =[abs(x-X) for x in Xn]

gcd_num = dx[0]
for x in dx:
  a, b = (gcd_num, x) if gcd_num > x else (x, gcd_num)
  gcd_num = gcd(a, b)
print(gcd_num)







Measured memory_bytes: 14224
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		
		for(int i = 0; i<n; i++){
			a[i] = sc.nextInt();
			b[i]=1000000000;
		}
		b[0]=0;
		for(int i = 0; i<n; i++){
			for(int j = 1; j<=s; j++){
				if(i+j<=n-1){
				if(b[i+j]>(Math.abs(a[i]-a[i+j])+b[i])){
					b[i+j]=(Math.abs(a[i]-a[i+j])+b[i]);
				}
				}
			}
		}
		System.out.println(b[n-1]);
	}
}

Measured memory_bytes: 60628
#include <cstdio>

int ds[][2]={{0,0},{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1},{2,0},{0,2},{-2,0},{0,-2}};
int map[10][10],kosa,rest=100;

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

int drop(int x,int y){
  if(x>=0 && x<10 && y>=0 && y<10){
    if(map[x][y]++==0) rest--;
    kosa=max(map[x][y],kosa);
  }
}

int main(){
  int x,y,size;
  while(~scanf("%d,%d,%d",&x,&y,&size))
    for(int i=0; i<=4*size; i++)
      drop(x+ds[i][0],y+ds[i][1]);

  printf("%d\n%d\n",rest,kosa);
}

Measured memory_bytes: 1028
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}


int main(){
int a,b;
    cin>>a>>b;
    int ans=a+b;
    if(ans>=10)cout<<"error"<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	long long n, tot = 0;
	cin >> n;
	vector<long long> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		tot ^= A[i];
	}

	for (int i = 0; i < n; i++) {
		A[i] ^= tot;
		cout << A[i] << " ";
	}
}


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

int main(void)
{
    vector<int> dishes(5, 0);
    for (int i = 0; i < 5; i++)
    {
        cin >> dishes.at(i);
    }

    vector<int> time(5, 0);
    for (int i = 0; i < 5; i++)
    {
        if (dishes.at(i) >= 10 && dishes.at(i) < 100)
        {
            time.at(i) = dishes.at(i) % 10;
        }
        else if (dishes.at(i) >= 100)
        {
            time.at(i) = dishes.at(i) % 10;
        }
        else
        {
            time.at(i) = dishes.at(i);
        }
    }

    // for (int i = 0; i < 5; i++)
    // {
    //     cout << time.at(i) << endl;
    // }

    int min = time.at(0) != 0 ? time.at(0) : 1;
    int location = 0;
    for (int i = 0; i < 5; i++)
    {
        if (min >= time.at(i) && time.at(i) != 0)
        {
            min = time.at(i);
            location = i;
        }
    }

    int sum = 0;
    int temp;
    for (int i = 0; i < 5; i++)
    {
        if (i != location)
        {
            sum += dishes.at(i);
        }
        if (sum % 10 != 0)
        {
            temp = sum % 10;
            sum += (10 - temp);
        }
    }
    sum += dishes.at(location);
    cout << sum << endl;
    return (0);
}

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

int main() {
	int d;
	while (cin >> d, d) {
		unsigned int n, m;
		cin >> n >> m;
		vector<int> dn(n + 1);
		vector<int> km(m);
		dn[0] = 0;
		for (unsigned i = 1; i < n; i++) {
			int x;
			cin >> x;
			dn[i] = x;
		}
		dn[n] = d;
		sort(dn.begin(), dn.end());
		long long int res = 0;
		for (unsigned i = 0; i < m; i++) {
			int x;
			cin >> x;
			vector<int>::iterator l = lower_bound(dn.begin(), dn.end(), x);
			res += min((*l) - x, x - (*(l - 1)));
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1528
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n;
		ArrayList<Integer> num = new ArrayList<Integer>();
		int ans = 0, isPrime;
		
		n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			num.add(sc.nextInt());
		}
		
		for(int i : num){
			isPrime = 1;
			for(int j = 2; j <= (int)Math.sqrt(i); j++){
				if(i % j == 0){
					isPrime = 0;
					break;
				}
			}
			
			if(isPrime != 0){
				ans ++;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 42920
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

struct Node{
    bool visited;
    vector<pair<ll, ll> > par;
    ll depth;
};

Node node[200000];

void dfs(ll index, ll depth){
    node[index].visited=true;
    node[index].depth=depth;
    rep(i, node[index].par.size()){
        if(!node[node[index].par[i].first].visited) dfs(node[index].par[i].first, depth+node[index].par[i].second);
    }
}

int main(void){
    ll N;
    cin>>N;
    rep(i,N) node[i].visited=false;
    rep(i, N-1){
        ll a, b, c;
        cin>>a>>b>>c;
        node[a-1].par.push_back({b-1, c});
        node[b-1].par.push_back({a-1, c});
    }
    ll Q, K;
    cin>>Q>>K;
    dfs(K-1, 0);
    rep(j, Q){
        ll x, y;
        cin>>x>>y;
        cout<<node[x-1].depth+node[y-1].depth<<endl;
    }
            
    return 0;
}


Measured memory_bytes: 18944
/*
  AUTHOR:SOURABH
  CREATED:06:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

ll modex(ll x,ll y)
{
    x=x%mod;
    ll r=1;
    while(y>0)
    {
        if(y%2==1)
            r=(r*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return r;
}

ll mm(ll x,ll y)
{
    return (x*y)%mod;
}
ll fact[200001];
ll inv_fact[200001];
void build(void)
{
    fact[0]=1;
    ll i;
    fs(i,1,200001)
    {
        fact[i]=mm(fact[i-1],i);
    }
    inv_fact[200000]=modex(fact[200000],mod-2);
    fr(i,199999)
    {
        inv_fact[i]=mm(inv_fact[i+1],i+1);
    }
}

ll C(ll n,ll r)
{
    if(n<r)
        return 0;
    ll res=fact[n];
    res=mm(res,inv_fact[n-r]);
    return mm(res,inv_fact[r]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,m,k,i,ans=0;
    build();
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>m>>k;
        fn(i,k+1)
        {
            ans=(ans+mm(m,(C(n-1,i)*modex(m-1,n-i-1))%mod))%mod;
        }
        cout<<ans;
    }
    return 0;
}



















Measured memory_bytes: 6780
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

ll a, b, c, d;

ll solve(){
    return max(max(a * c, b * d), max(a*d, b * c));
}

int main(){
    //freopen("in.txt", "r", stdin);
    cin>>a>>b>>c>>d;
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,p;
  bool flag=true;
  p=0;
  cin >> n;
  vector <pair<int,int> >v(n);
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    v[i]=make_pair(b,a);
  }
  sort(v.begin(),v.end());

  for(auto z:v){
    p+=z.second;
    if(p>z.first){
      flag=false;
      break;
    }
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<string>
#include<sstream>
using namespace std;
int ps(int n)
{
    int i,flag=0;
    for (i=2;i<=n/2;i++)
    {
        if (i*i==n)
        {
            flag=1;
            break;
        }
    }
    return flag;
}
int main()
{
    int a,b;
    cin>>a>>b;
    string x= to_string(a);
    string y= to_string(b);
    string str= x+y;
    stringstream geek(str);
    long int c=0;
    geek>>c;
    if (ps(c))
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(((abs(a-b)<=d)&&(abs(b-c)<=d))||(abs(a-c)<=d)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    int a, b; cin >> a >> b;

    cout << (a+b)%24 << endl;
}

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

#define ALL(x) begin(x), end(x)

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> v(S.size()+1,0);
  int c{};
  for (int i = 0, n = S.size(); i != n; ++i) {
    if (S.substr(i,2) == "AC") ++c;
    v[i+1] = c;
  }
  int l,r;
  for (int i = 0; i != Q; ++i) {
    cin >> l >> r;
    cout << v[r-1]-v[l-1] << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin, n, m;
    vector<vector<int>> g(n);
    for (ll i : Range(m)) {
        int a, b;
        cin, a, b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    queue<P> q;
    q.emplace(0, 0);  // cost, vertex;
    vector<int> prev(n, -1);
    vector<int> used(n, 1000000);
    while (q.size()) {
        auto [cost, v] = q.front();
        q.pop();
        if (cost > used[v]) continue;
        used[v] = cost;
        for (auto vv : g[v]) {
            if (cost + 1 < used[vv]) {
                prev[vv] = v;
                used[vv] = cost + 1;
                q.emplace(cost + 1, vv);
            }
        }
    }

    print("Yes");
    for (ll i : Range(1, n)) {
        print(prev[i] + 1);
    }

    return 0;
}


Measured memory_bytes: 11592
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){

}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> S;
	for (int i = 0; i < S.size(); ++i)
	{
		if(S[i] != ','){
			cout << S[i];
		}else{
			cout << " ";
		}
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
m=abs(X-x[0])

for i in range(1,N):
    #print(m,abs(x[i]-X),gcd(m,abs(x[i]-X)))
    if gcd(m,abs(x[i]-X))<m:
        m=gcd(m,abs(x[i]-X))
print(m)

Measured memory_bytes: 88172
#include <iostream>
using namespace std;
#define ll long long int

int main() {
    ll x,y;
	cin>>x>>y;
	if(y%2!=0)
	{
		cout<<"No";
		return 0;
	}
	if(y>=x*2 && y<=x*4)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
nums = list(map(int, input().split()))
x = nums[0]
y = sum(nums[1:])
ans = abs(x - y)
for i in range(1, n - 1):
    x += nums[i]
    y -= nums[i]
    ans = min(ans, abs(x - y))
print(ans)

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

int main(){
    int n;
    int i=1;
    bool endflag = true;
    
    while (endflag){
        cin >> n;
        if(n==0){
            endflag = false;
            break;
        }
        
        cout << "Case "<<i<<": "<<n<<endl;
        i++;
    }
    return 0;
}




Measured memory_bytes: 3072
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_copy = [x for x in A]
B_copy = [y for y in B]

for i in range(N-1, -1, -1):
  if A_copy[i+1] >= B_copy[i]:
    A_copy[i+1] -= B_copy[i]
    B_copy[i] = 0
  else:
    B_copy[i] -= A_copy[i+1]
    A_copy[i+1] = 0
    if A_copy[i] > B_copy[i]:
      A_copy[i] -= B_copy[i]
      B_copy[i] = 0
    else:
      B_copy[i] -= A_copy[i]
      A_copy[i] = 0

    #A_copy[i+1] = max(A_copy[i+1]-B[i], 0)
    #B_copy[i] = max(B_copy[i]-A[i+1], 0)
  #if B_copy[i] > 0:
   # a = A_copy[i]
    #A_copy[i] = max(A_copy[i]-B_copy[i], 0)
    #B_copy[i] = max(B_copy[i]-a, 0)

n = sum(B) - sum(B_copy)
print(n)

Measured memory_bytes: 18476