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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int X[1010];
int Y[1010];
ll X2[1010];
ll Y2[1010];

void solve_large(){
    int freq[2] = {};
    for(int i = 0; i < N; i++) freq[(X[i] + Y[i]) % 2] |= 1;
    // 和が奇数のみ or 偶数のみ でないと不可能
    if(freq[0] + freq[1] >= 2){
        cout << -1 << endl;
        return;
    }

    for(int i = 0; i < N; i++){
        X2[i] = X[i] + Y[i];
        Y2[i] = X[i] - Y[i];
    }

    vector<ll> D;
    // Dとしては 2^31 ぐらいまであれば十分なので、それで構築する
    for(int i = 0; i < 32; i++) D.push_back(1LL << i);
    if(X2[0] % 2 == 0) D.push_back(1);
    reverse(D.begin(), D.end());

    cout << (int)D.size() << endl;
    for(ll a : D) cout << a << " ";
    cout << endl;

    for(int i = 0; i < N; i++){
        vector<bool> ang[2];
        ll tmp[] = {X2[i], Y2[i]};
        for(int k = 0; k < 2; k++){
            const ll a = tmp[k];
            // 大きい数字から順番に利用する
            ll pos = 0;
            for(int j = 0; j < (int)D.size(); j++){
                if(a >= pos){
                    ang[k].push_back(true);
                    pos += D[j];
                }
                else{
                    ang[k].push_back(false);
                    pos -= D[j];
                }
            }
            if(pos < a) ang[k].push_back(true);
            else if(pos > a) ang[k].push_back(false);
        }
        for(int s = 0; s < (int)ang[0].size(); s++){
            if(ang[0][s] && ang[1][s]) cout << "R";
            else if(ang[0][s] && !ang[1][s]) cout << "U";
            else if(!ang[0][s] && ang[1][s]) cout << "D";
            else cout << "L";
        }
        cout << endl;
    }
    
}

void solve_small(){
    int freq[2] = {};
    for(int i = 0; i < N; i++){
        freq[(X[i] + Y[i]) % 2] |= 1;
        if(abs(X[i]) + abs(Y[i]) >= 21) return;
    }
    
    if(freq[0] + freq[1] >= 2){
        cout << -1 << endl;
    }
    else{
        int m = 0;
        if(freq[0] > 0) m = 40;
        else m = 39;

        cout << m << endl;
        for(int i = 0; i < m; i++){
            cout << 1 << " ";
        }
        cout << endl;

        for(int i = 0; i < N; i++){
            string ans;
            for(int j = 0; j < abs(X[i]); j++){
                if(X[i] >= 0) ans += 'R';
                else ans += 'L';
            }
            for(int j = 0; j < abs(Y[i]); j++){
                if(Y[i] >= 0) ans += 'U';
                else ans += 'D';
            }
            // 残った要素数で計算
            for(int j = 0; j < m - (abs(X[i]) + abs(Y[i])); j++){
                if(j % 2 == 0) ans += 'L';
                else ans += 'R';
            }
            cout << ans << endl;
        }
    }
}

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    solve_large();

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

using namespace std;

char input[1000000 + 5];
int dp[1000000 + 5][2];

int main()
{
	scanf("%s", input + 1);
	input[0] = '0';

	dp[0][0] = 0;
	dp[0][1] = 1;
	int i;

	for (i = 1; input[i]; ++i)
	{
		dp[i][0] = min(dp[i - 1][0] + input[i] - '0', dp[i - 1][1] + 10 - (input[i] - '0'));
		dp[i][1] = min(dp[i - 1][0] + input[i] + 1 - '0', dp[i - 1][1] + 10 - (input[i] - '0' + 1));
	}

	printf("%d\n", dp[i - 1][0]);

	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    unordered_map<ll,ll> mpp ;
    forn(i , 1 , 31623){
       ll foo= i* i ;
       mpp[i] = foo ;
    }
    ll n ;
    cin >> n ;
    ll ans = 0 ;
    for(ll i = 31623 ; i >= 1 ; --i){
        if(mpp[i] <= n){
            ans = mpp[i];
            br ;
        }
    }
    cout << ans << el ;

}



































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

int main()
{
    ll i,j,k,n,q,t,c=0;
    cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=i+1;
        if(a[i]!=b[i])c++;
    }
    if(c<3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<double> A(N);
  for(double &d:A)
    cin>>d;
  vector<vector<long double>> B(N+1,vector<long double>(N+1));
  B[0][0]=1.0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(j==0)
        B[i][j]=B[i-1][j]*(1.0-A[i-1]);
      else
        B[i][j]=B[i-1][j]*(1.0-A[i-1])+B[i-1][j-1]*A[i-1];
    }
  }
  long double ans=0;
  for(int i=N/2+1;i<=N;i++)
    ans+=B[N][i];
  cout<<fixed<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 144000
#include<iostream>

int main()
{
	using namespace std;
	int t;
	int i;
	long long int T=1000000001;
	long long int a,b;
	int minus_=0;
	cin>>t;
	long long int counter=0;
	for(i=0;i<t;i++)
	{
		cin>>a>>b;
		if(a<=b)
		{
		counter+=a;
		minus_+=b-a;
		}
		else
		{
			if(T>b)
			T=b;
			counter+=a;
		}
		
	}
	if(minus_==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	cout<<counter-T<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int H,W,M;
  cin>>H>>W>>M;
  vector<int64_t>h(H),w(W);
  set<pair<int,int>>q;
  for(int i=0;i<M;i++){
    int y,x;
    cin>>y>>x;
    y--;x--;
    h[y]++;w[x]++;
    q.insert(make_pair(y,x));
  }
  int64_t MXh=*max_element(h.begin(),h.end());
  int64_t MXw=*max_element(w.begin(),w.end());
  vector<int>hmx,wmx;
  for(int i=0;i<H;i++){
    if(h[i]==MXh){hmx.push_back(i);}
  }
  for(int j=0;j<W;j++){
    if(w[j]==MXw){wmx.push_back(j);}
  }
  for(int i:hmx){
    for(int j:wmx){
      if(!q.count(make_pair(i,j))){
        cout<<MXh+MXw<<endl;return 0;//全部使っていたとするときのループが最悪のケースだが、それはMケースのみ
      }
    }
  }
  cout<<MXh+MXw-1<<endl;
  return 0;
}

Measured memory_bytes: 26212
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
vector<pii> g[MAX];
int pa[MAX], d[MAX], E[101][101];

int main() {
    int n, m;
    cin >> n >> m;
    REP(i, m){
    	int u, v, w;
    	cin >> u >> v >> w;
    	g[u].pb(mp(v, w));
    	g[v].pb(mp(u, w));
    	E[u][v] = E[v][u] = 1;
    }

    FOR(i,1,n){
    	FOR(j,1,n){
    		d[j] = 1e9; 
    		pa[j] = -1;
    	}
    	d[i] = 0;
    	priority_queue< pii , vector< pii >, greater< pii > > pq;
        pq.push(mp(d[i],i));
        while(!pq.empty()){
        	int u = pq.top().S;
        	pq.pop();
        	for(int j=0;j<g[u].size();j++){
        		int v = g[u][j].F, w = g[u][j].S;
        		if(d[v] > d[u] + w){
        			d[v] = d[u] + w;
        			pa[v] = u;
        			pq.push(mp(d[v], v));
        		}
        	}
        }
        FOR(i,1,n){
        	if(pa[i] == -1) continue;
        	E[i][pa[i]] = E[pa[i]][i] = 0;
        }
    }

    int cnt = 0;
    FOR(i,1,n){
    	FOR(j,i+1,n){
    		cnt += E[i][j];
    	}
    }
    cout << cnt;
}

Measured memory_bytes: 2816
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto n = readln.chomp.to!int;
    auto vs = readln.split.to!(int[]);
    int[] a, b;
    vs.chunks(2).each!((v) {
        a ~= v[0];
        if (v.length > 1) b ~= v[1];
    });
    auto ga = a.sort().group().array.sort!((a,b) => a[1] < b[1]);
    auto gb = b.sort().group().array.sort!((a,b) => a[1] < b[1]);

    auto aMax = ga[$-1];
    auto bMax = gb[$-1];

    if (aMax[0] != bMax[0]) {
        writeln(a.length - aMax[1] + b.length - bMax[1]);
    } else {
        auto res = size_t.max;
        if (gb.length > 1) res = min(res, a.length - aMax[1] + b.length - gb[$-2][1]);
        if (ga.length > 1) res = min(res, a.length - ga[$-2][1] + b.length - bMax[1]);
        if (res == size_t.max) res = b.length;
        writeln(res);
    }
}



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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c; cin >> a >> b >> c;
	
	cout << (a * b * c == 175 && a + b + c == 17 ? "YES" : "NO");
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var ans = 0.0
    for (i in 0 until n-1) {
        if (i == 0) ans = (v[0] + v[1]) / 2.0
        else ans = (ans + v[i+1]) / 2.0
    }
    println(ans)
}


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

typedef pair<int, int> P;

int main() {
  int n;
  while ( cin >> n, n ) {
    int ans = 0;
    int ma = 0;
    vector<P> dat(n);    
    for ( int i = 0; i < n; i++ ) {      
      string s;
      cin >> s;
      dat[i].first = (int)s.size()-1;
      if ( s[s.size()-1] == '+' ) dat[i].second = -1;
      else if ( s[s.size()-1] == '*' ) dat[i].second = -2;
      else dat[i].second = s[s.size()-1]-'0';
      ma = max(ma, (int)s.size()-1);      
    }

    while ( 1 ) {      
      /*for ( int i = 0; i < dat.size(); i++ ) {
	if ( i ) cout << " ";
	cout << dat[i].first << " " << dat[i].second;
      }
      cout << endl << endl;;*/
      if ( dat.size() == 1 ) break;
      bool flag = false;
      for ( int i = 0; i < dat.size()-2; i++ ) {
	if ( dat[i].second >= 0 ) continue;
	if ( dat[i].first != ma ) continue;	
	int c = dat[i].second;
	int d = dat[i].first;	
	int sum;
	int cnt = 2;	
	if ( d != dat[i+1].first-1 ) continue;
	if ( dat[i+1].second >= 0 && dat[i+2].second >= 0 && dat[i+1].first == dat[i+2].first ) {
	  flag = true;
	  //cout << 'a' << endl;	    	 
	  sum = dat[i+1].second;
	  cnt = 2;
	  for ( int j = i+2; j < dat.size(); j++ ) {
	    //cout << sum << endl;
	    if ( dat[j].second < 0 ) break;
	    if ( dat[j].first != dat[i+1].first ) break; 
	    if ( c == -1 ) {
	      sum += dat[j].second;
	    } else {
	      sum *= dat[j].second;
	    }
	    cnt++;
	  }
	}	
	if ( flag ) {
	  //cout << i << " " << sum << " " << cnt << endl;
	  int tmp = dat[i].first;
	  for ( int j = i; j < i+cnt; j++ ) dat.erase(dat.begin()+i);
	  dat.insert(dat.begin()+i, P(tmp, sum));	  
	  break;
	}
      }
      if ( !flag ) {
	ma--;
      }
		    
      if ( dat.size() == 1 ) break;
    }

    //cout << "end" << endl;
    cout << dat[0].second << endl;
  }
}



Measured memory_bytes: 3192
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

ll to_N[NUM+1],from_1[NUM+1],ans[NUM+1];


int main(){

	ll N;
	scanf("%lld",&N);

	to_N[N] = 0;
	for(ll left = N-1; left >= 1; left--){
		printf("? %lld %lld\n",left,N); fflush(stdout);
		scanf("%lld",&to_N[left]);
	}

	from_1[1] = 0;

	for(int right = 2; right <= N; right++){
		printf("? 1 %d\n",right); fflush(stdout);
		scanf("%lld",&from_1[right]);
	}

	ans[1] = to_N[1]-to_N[2]+1;
	for(int i = 2; i <= N-1; i++){
		ans[i] = (to_N[i]-to_N[i+1])+((ll)i-(from_1[i]-from_1[i-1]+1))+1;
	}
	ans[N] = N-(from_1[N]-from_1[N-1]+1)+1;

	printf("!");
	for(int i = 1; i <=N; i++)printf(" %lld",ans[i]);
	printf("\n");

	return 0;
}



Measured memory_bytes: 288940
#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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    string S; cin >> S;

    bool flag = false;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '9') flag = true;
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;
   long int ans = n / 4;
   long int left = n % 4;
   ans *= 2;
   ans += (left > 0) + (left > 2);
   cout<<ans;
   return 0;
}

Measured memory_bytes: 256
def main():
    alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    n = int(input())
    s_list = list(input())

    s_list_n = [0] * len(s_list)
    ans_list = [0] * len(s_list)
    for i, s in enumerate(s_list):
        temp = (alphabet.find(s) + n) % len(alphabet)
        ans_list[i] = alphabet[temp]

    ans = ''.join(ans_list)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  char c;
  cin >> c;
  c++;
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C, K = map(int, read().split())

ans = 0


ans += min(A, K)
K -= A
if K <= 0:
    print(ans)
    sys.exit()

K -= B
if K <= 0:
    print(ans)
    sys.exit()

ans -= min(C, K)


print(ans)


Measured memory_bytes: 9088
##########################################
#
# 10,000 * A + 5,000 * B + 1,000 * C = Y
# A + B + C = N
#
# C = N -A -B
# 10,000A + 5,000B + 1,000(N -A -B) = Y
# 9,000A + 4,000B + 1,000N = Y
# Y > 1000, Y mod 1000 = 0 =>  9A + 4B = y - N (y = Y/1000)
#
# A = (y -N -4B)/9
# B = (y -N -9A)/4
#
# d = (y -N)
# A = (d -4B)/9
# B = (d -9A)/4
#
# 0 <= A <= N, and 0 <= B <= N, and (A, B) integer
#
##########################################

[N,Y] = map(int,raw_input().split())

#print N, Y

d = (Y/1000) - N

ercd = -1

for i in range(N+1):
#    print i
    B = ((d - 9*i)/4)
    C = (N - i - B)
#    print i, B, C
    if(((d - (9*i)) % 4) == 0 )and( B <= N) and (B >= 0)and(C <= N) and (C >= 0):
        ercd  = 1
        break

if ercd != -1:
    print i, ((d - 9*i)/4) , (N - i - B)
else:
    print -1, -1, -1


Measured memory_bytes: 2692
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, a);
	IN(string, s);
	

	cout << (a >= 3200 ? s : "red") << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
char symbol[3] = {'+', '-', '*'};

int calc(int x, int y, char c)
{
	switch(c)
	{
		case '+':
			return(x + y);
		case '-':
			return(x - y);
		case '*':
			return(x * y);
	}
}

void solve()
{
	vector<int> num(4);
	while(cin >> num[0] >> num[1] >> num[2] >> num[3], num[0] || num[1] || num[2] || num[3])
	{
		bool flag = false;
		sort(num.begin(), num.end());
		do
		{
			for(int i = 0; i < 3; ++i)
			{
				for(int j = 0; j < 3; ++j)
				{
					for(int k = 0; k < 3; ++k)
					{
						int result = calc(num[0], num[1], symbol[i]);
						result = calc(result, num[2], symbol[j]);
						result = calc(result, num[3], symbol[k]);
						if(result == 10)
						{
							printf("((%d %c %d) %c %d) %c %d\n", num[0], symbol[i], num[1], symbol[j], num[2], symbol[k], num[3]);
							flag = true;
							goto END;
						}
						
						result = calc(num[1], num[2], symbol[j]);
						result = calc(num[0], result, symbol[i]);
						result = calc(result, num[3], symbol[k]);
						if(result == 10)
						{
							printf("(%d %c (%d %c %d)) %c %d\n", num[0], symbol[i], num[1], symbol[j], num[2], symbol[k], num[3]);
							flag = true;
							goto END;
						}
						
						result = calc(num[2], num[3], symbol[k]);
						result = calc(num[1], result, symbol[j]);
						result = calc(num[0], result, symbol[i]);
						if(result == 10)
						{
							printf("%d %c (%d %c (%d %c %d))\n", num[0], symbol[i], num[1], symbol[j], num[2], symbol[k], num[3]);
							flag = true;
							goto END;
						}
						
						result = calc(num[0], num[1], symbol[i]);
						int result2 = calc(num[2], num[3], symbol[k]);
						result = calc(result, result2, symbol[j]);
						if(result == 10)
						{
							printf("(%d %c %d) %c (%d %c %d)\n", num[0], symbol[i], num[1], symbol[j], num[2], symbol[k], num[3]);
							flag = true;
							goto END;
						}

						result = calc(num[1], num[2], symbol[j]);
						result = calc(result, num[3], symbol[k]);
						result = calc(num[0], result, symbol[i]);
						if(result == 10)
						{
							printf("%d %c ((%d %c %d) %c %d)\n", num[0], symbol[i], num[1], symbol[j], num[2], symbol[k], num[3]);
							flag = true;
							goto END;
						}
					}
				}
			}
		}while(next_permutation(num.begin(), num.end()));
END:;
		if(!flag)
		{
			cout << "0" << endl;
		}
	}
}

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

Measured memory_bytes: 1232
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	int n;
	cin >> n;
	while (n--)
	{
		int ball[10];
		
		for (int i = 0; i < 10; ++i)
		{
			cin >> ball[i];
		}
 
		bitset<10> direction;
		int all = 1024;
		while (all-- > 0)
		{
			direction = static_cast<bitset<10> >(all);
			bool perfect = true;
			int left = 0;
			int right = 0;
			for (int i = 0; i < 10; ++i)
			{
				if (direction[i])
				{
					if (ball[i] > left)
					{
						left = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
				else
				{
					if (ball[i] > right)
					{
						right = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
			}
			if (perfect)
			{
				break;
			}
		}
	
		if (all >= 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
const int INF=1000000007;
int n;
vector<int>G[200000];
int used[200000];//1→黒2、→白
bool visit[200000];

vector<int>keiro;//0→n-1に向かう時の経路

bool dfs(int now){
	visit[now]=true;
	//cout<<now<<endl;
	if(now==n-1){
		return true;
	}
	rep(i,G[now].size()){
		int next=G[now][i];
		if(visit[next])continue;
		bool che=dfs(next);
		if(che){keiro.pb(next);return true;}
	}
	return false;
}

void cnt(int now,int c){
	//cout<<"N"<<now<<endl;
	visit[now]=true;
	if(used[now]==0)used[now]=c;

	int ret=0;
	rep(i,G[now].size()){
		int next=G[now][i];
		if(visit[next])continue;

		if(used[next]==0||used[next]==c)cnt(next,c);
	}

}
int main(){
	cin>>n;
int a,b;
rep(i,n-1){
	cin>>a>>b;
	a--;b--;
	G[a].pb(b);
	G[b].pb(a);

}

dfs(0);
keiro.pb(0);
//
reverse(keiro.begin(),keiro.end());
//rep(i,keiro.size())cout<<keiro[i]<<" ";

for(int i=0;i<(keiro.size()+1)/2;i++)used[keiro[i]]=1;
for(int i=(keiro.size()+1)/2;i<keiro.size();i++)used[keiro[i]]=2;
int snuke=0,fennec=0;

rep(i,200000)visit[i]=0;
cnt(0,1);

rep(i,200000)visit[i]=0;
cnt(n-1,2);

rep(i,n){
	if(used[i]==1){//cout<<"B:"<<i;
		fennec++;}
	if(used[i]==2){//cout<<"W:"<<i;
		snuke++;}
}

	//cout<<snuke<<" "<<fennec<<endl;
	if(fennec>snuke)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;

	return 0;
}

Measured memory_bytes: 13816
#include<bits/stdc++.h>
using namespace std;
long long int a[3005];
long long int ans[3005][3005][2];
long long int game(int i, int j, int player){
    if(i>j)
        return 0;
    if(ans[i][j][player-1]!=-1)
        return ans[i][j][player-1];
    if(player==1)
        return ans[i][j][player-1] = max(game(i+1,j,2)+a[i],game(i,j-1,2)+a[j]);
    return ans[i][j][player-1] = min(game(i+1,j,1)-a[i],game(i,j-1,1)-a[j]);
}
int main(){
    int n;
    cin >> n;
    for(int i=0;i<3005;i++)
        for(int j=0; j<3005; j++)
            for(int k=0; k<2; k++)
                ans[i][j][k] = -1;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    cout << game(1,n,1);
}

Measured memory_bytes: 144940
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

int main(){
  int n; string s; cin >> n >> s;
  long mod = 1e9 + 7;
  map<char, long> mp;
  rep(i, n) mp[s[i]]++;
  long ans = 1;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    long t = itr->second == 1 ? 2 : itr->second+1;
    ans = ans * t % mod;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;
int a[110]; 
int main() {
	int n;
	cin>>n;
	int res=0;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		if((i&1)&&(a[i]&1)) res++;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3160
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), k = in();
    if (k == 1) {
        cout << 0 << endl;
    } else {
        cout << n - k << endl;
    }
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N;
vector<int> A;

string solve(void) {
    int s = 0;
    for(int i = 0;i < N;i++) {
        s = (s^A[i]);
    }

    if(s == 0) {
        return "Yes";
    } else {
        return "No";
    }
}

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.push_back(a);
    }

    cout<<solve()<<endl;
    return 0;
}




Measured memory_bytes: 892
package main

import "fmt"

func main() {
  var k, x int
  fmt.Scanf("%d %d", &k, &x)
  min := x - (k-1)
  max := x + (k-1)
  for i:= min; i <=max; i++ {
  fmt.Printf("%d", i)
    if (i != max) {
      fmt.Print(" ")
    }
  }
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] S = new String[H];
        for (int i=0; i<H; i++) {
            S[i] = sc.next();
        }

        System.out.println(solve(H, W, S) ? "Yes" : "No");
    }

    private static boolean solve(int H, int W, String[] S) {
        int[][] d = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
        for (int h=0; h<H; h++) {
            for (int w=0; w<W; w++) {
                if (S[h].charAt(w) == '#') {
                    boolean ok = false;

                    for (int idx=0; idx<d.length; idx++) {
                        int nextH = h + d[idx][0];
                        int nextW = w + d[idx][1];

                        if (nextH < 0 || nextH >= H || nextW < 0 || nextW >= W) continue;

                        if (S[nextH].charAt(nextW) == '#') {
                            ok = true;
                        }
                    }

                    if (!ok) return false;
                }
            }
        }


        return true;
    }
}

Measured memory_bytes: 23380
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 32;
const int MOD = 998244353;

void solve() {
    int n, k;
    cin >> n >> k;
    n %= k;
    
    cout << min(n, k - n);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
   // freopen("C:\\Users\\Иван\\Desktop\\output.txt", "w", stdout);
    //int t;
    // cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

int dp[11][331][1<<10];
int main(){
  memset(dp,0,sizeof(dp));
  dp[0][0][0] = 1;
  for(int multiply=1;multiply<=10;multiply++){
    for(int used = 0; used <= (1<<10) - 1; used++){
      for(int base = 330;base >= 0; base--){
        if(dp[multiply-1][base][used] == 0) continue;
        for(int to=0; to<=9; to++){
          if(used & (1 << to)) continue;
          if(to * multiply + base > 330) continue;

          dp[multiply][to * multiply + base][used | (1<<to)]
            += dp[multiply - 1][base][used];
        }
      }
    }
  }
  
  int n,target_sum;
  while(~scanf("%d %d",&n,&target_sum)){
    if(target_sum > 330 || n >= 11){
      printf("0\n");
    }
    else{
      int res = 0;
      for(int S=0;S<=(1<<10) - 1;S++){
        res += dp[n][target_sum][S];
      }
      printf("%d\n",res);
    }
  }
  return 0;
}

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

using namespace std;

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

int PLen, CNum, Width, CSpace;
vector<string> lines;

int currColumn;
pair<int, int> currPos;
int N, M;
vector<string> output;
bool dirty;

void printPage() {
  rep(i, N) cout << output[i] << endl;
  cout << "#" << endl;
  fill(output.begin(), output.end(), string(M, '.'));
  currColumn = 0;
  currPos = {0, 0};
  dirty = 0;
}

void print(char c) {
  if(currPos.second >= (currColumn * Width + CSpace * currColumn) + Width) {
    currPos.first ++;
    if(currPos.first >= PLen) {
      currPos.first = 0;
      currColumn ++;
    }
    currPos.second = currColumn * Width + CSpace * currColumn;
  }
    
  if(currColumn >= CNum) {
    printPage();
  }
  
  dirty = 1;
  output[currPos.first][currPos.second++] = c;
}

void nextLine() {
  currPos.first ++;
  if(currPos.first >= PLen) {
    currColumn ++;
    currPos.first = 0;
    if(currColumn >= CNum && dirty) printPage();
  }
  currPos.second = currColumn * Width + CSpace * currColumn;
}

void solve() {
  
  output.clear();
  output.resize(PLen);
  dirty = 0;
  
  N = PLen, M = Width * CNum + CSpace * (CNum - 1);
  
  rep(i, N) output[i] = string(M, '.');

  currColumn = 0;
  currPos = {0, 0};
  
  rep(i, lines.size()) {    
    int LLen = lines[i].size();
    dirty = 1;
    rep(j, LLen) {
      print(lines[i][j]);
    }
    nextLine();
  }
  
  if(dirty) printPage();
  cout << "?" << endl;
}

int main() {

  while(1) {
    
    lines.clear();    
    cin >> PLen >> CNum >> Width >> CSpace; cin.ignore();

    if(PLen == 0) break;
    
    for(int i=0;; i++) {
      string in;
      getline(cin, in);
      if(in == "?") break;
      else {
	lines.push_back(in);
      }
    }
    
    solve();
    
  }
  
  return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);

  cout << a << " " << b <<" "<< c << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var S string

func main() {
	fmt.Scan(&S)

	for i := 1; i < len(S); i++ {
		if string(S[i]) == string(S[i-1]) {
			fmt.Println("Bad")
			return
		}
	}
	fmt.Println("Good")
}

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

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


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

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;

        int v[25][25] = {};
        for(int i=0; i<n; i++){
            int d,t;
            cin >> d >> t;
            for(int j=0; j<d; j++){
                int vol;
                cin >> vol;
                v[d][(j-t+d)%d] += vol;
            }
        }

        int ans = 0;
        // 13,17,19,23以外の周期
        for(int i=0; i<55400; i++){
            int sub = 0;
            for(int j=1; j<=24; j++){
                if(j==13 or j==17 or j==19 or j==23){
                    continue;
                }
                sub += v[j][i%j];
            }
            ans = max(ans, sub);
        }
        for(int i=0; i<=24; i++){
            if(i==13 or i==17 or i==19 or i==23){
                ans += *max_element(v[i], v[i]+i);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3052
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int ABCD;
    cin >> ABCD;
    int A, B, C, D;
    A = ABCD/1000;
    B = (ABCD/100)%10;
    C = (ABCD/10)%10;
    D = (ABCD/1)%10;
    REP(i, 8){
        int n = A;
        if(i&1){
            n += B;
        }else{
            n -= B;
        }
        if(i&2){
            n += C;
        }else{
            n -= C;
        }
        if(i&4){
            n += D;
        }else{
            n -= D;
        }
        if(n == 7){
            cout << A << ((i&1)?'+':'-')
                 << B << ((i&2)?'+':'-')
                 << C << ((i&4)?'+':'-')
                 << D << "=7" << el;
            return;
        }
    }
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
int i,j;

int main()
{
  bool ans=true;
  P tori;
  int n,now,mi,k,top;
  cin >> n;
  string s;
  multiset<P> sei;
  multiset<P> hu;
  for(i=0;i<n;i++)
  {
    now=0;
    mi=0;
    cin >> s;
    for(j=0;j<s.size();j++)
    {
      if(s.at(j)=='(')
      {
        now++;
      }
      else
      {
        now--;
        mi=min(mi,now);
      }
    }
    mi=(-1)*mi;
  if(now>=0)
   {
      sei.insert({mi,now});
   }
else
   {
      hu.insert({mi+now,0-now});
    }
  }
  now=0;
  mi=0;
  auto itr=sei.begin();
  tori=*itr;
  mi=0-tori.first;
  now=tori.second;
 // cout << mi << " " << now << endl;
  if(mi<0) ans=false;
  
  
  for(i=1;i<sei.size();i++)
  {
    itr++;
    tori=*itr;
    mi=now-tori.first;
    now+=tori.second;
//    cout << mi << " " << now << endl;
    if(mi<0) 
    {
      ans=false;
      break;
    }
  }
//  cout << " " << endl;
  top=now;
  now=0;
  mi=0;
  auto itra=hu.begin();
  tori=*itra;
  mi=0-tori.first;
  now=tori.second;
  //cout << mi << " " << now << endl;
  if(mi<0) ans=false;
   for(i=1;i<hu.size();i++)
  {
    itra++;
    tori=*itra;
    mi=now-tori.first;
    now+=tori.second;
   // cout << mi << " " << now << endl;
    if(mi<0) 
    {
      ans=false;
      break;
    }
  }
  if(top!=now) ans=false;
  
  if(ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
 
}

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

long long lcm(long long a,long long b){
	long long x = a * b;
  if(a<b){
    long long tmp = a;
    a = b;
    b = tmp;
  }
  long long r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return x / b;
}

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long LCM = lcm(c, d);
    long long x = a-1;

    cout << b-a+1 - ((b/c + b/d - b/LCM) - (x/c + x/d - x/LCM)) << endl;
    return 0;
}

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

int n, k;
int a[200010];
char check(const int &n);

int main() {
	scanf("%d%d", &n, &k);
	int maxv = 0;
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		sum += a[i], maxv = max(maxv, a[i]);
	}

	
	int l = (sum + n + k - 1) / (n + k), r = maxv;
	while (l <= r) {
		int m = l + r >> 1;
		if (check(m))
			r = m - 1;
		else
			l = m + 1;
	}
	printf("%d\n", l);
	return 0;
}

char check(const int &m) {
	int sum = 0;
	for (int i = 0; i < n; ++i)
		sum += (a[i] - 1) / m;
	return sum <= k;
}



Measured memory_bytes: 4444
N = int(input())
A_list = list(map(int, input().split()))

sum_A = sum(A_list)
acc_A = [0] * N
acc_A[0] = A_list[0]
border = sum_A / 2
for i in range(1, N):
    acc_A[i] += A_list[i] + acc_A[i-1]

for i in range(N):
    if acc_A[i] > border:
        border_i = i
        break

left = abs(2 * acc_A[border_i - 1] - sum_A)
right = abs(2 * acc_A[border_i] - sum_A)

if left > right:
    ans = right
else:
    ans = left

print(ans)

Measured memory_bytes: 89164
M=10**6+1
f=lambda p: exit(print(['pairwise','setwise','not'][p]+' coprime'))
n,*l=map(int,open(0).read().split())
from math import *
g=l[0]
for x in l: g=gcd(g,x)
if g>1: f(2)
C=[0]*M
for x in l: C[x]=1
for i in range(2,M):
  if sum(C[j] for j in range(i,M,i))>1: f(1)
f(0)

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

int main(){
//1910
  	int H,W;
  	char l;
  cin>>H>>W;
	vector< vector<char>> grid(H+2,vector<char>(W+2));
  
 	for(int i=0;i<=W+1;i++) grid.at(0).at(i)='.';
	for(int i=0;i<=W+1;i++) grid.at(H+1).at(i)='.';
 	for(int i=0;i<=H+1;i++) grid.at(i).at(0)='.';
 	for(int i=0;i<=H+1;i++) grid.at(i).at(W+1)='.';
    
  	for(int i=1;i<=H;i++){
      for(int k=1;k<=W;k++){
        cin>>l;
      	grid.at(i).at(k)=l;
      }
    }
  
  for(int i=1;i<=H;i++){
    for(int k=1;k<=W;k++){
      if(grid.at(i).at(k)=='#'){
      	if(grid.at(i).at(k-1)=='#'||grid.at(i).at(k+1)=='#'
         ||grid.at(i+1).at(k)=='#'||grid.at(i-1).at(k)=='#'){
          continue;
        }else {cout<<"No"<<endl; return 0;}
      }
    }
  }
   cout<<"Yes"<<endl;
}
         
  
  
 

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

int main(){
  int i,j,cnt=0;
  int n,k;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  int b[200001];
  for(i=0;i<=200000;i++)b[i]=0;
  for(i=0;i<n;i++)b[a[i]]++;
  int c[200001];
  for(i=0;i<=200000;i++){
    if(b[i]!=0){
      c[cnt]=b[i];
      cnt++;
    }
  }
  sort(c,c+cnt);
  if(cnt<=k){
    cout<<0<<endl;
  }else{
    int sum=0;
    for(i=0;i<cnt-k;i++){
      sum+=c[i];
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 2560
/* Author: Prasun Biswas */
/*	|-0-0-|
 *	|  <  |
 *	|_\_/_| */

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#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 FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

void solve() {
	string s;
	cin >> s;
	int in = 0, ans = 0, count = 0; 
	for (char &i : s) {
		if (i == 'R') {
			if (in) ++count;
			else {
				in = 1;
				count = 1;
			}
			ans = max(count, ans);
		} else in = 0;
	}
	cout << ans;
}

int main() {
	FIO;
	int tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
		cout << '\n';
	}
	return 0;
}



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n);
	for (int i=0; i<n; i++)
		cin>>a[i];
	int ret=a[0];
	for (int i=1; i<n; i++)
		ret=__gcd(ret,a[i]);
	cout<<ret<<"\n";
	return 0;
}

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

long gcd(long a, long b){
  long r;
  while(true){
    if(a < b){
      r = a;
      a = b;
      b = r;
    }
    if(!b) break;
    a %= b;
  }
  return a;
}

long lcm(long a, long b){
  return a * b / gcd(a, b);
}

int main(){
  long A, B;
  cin >> A >> B;
  long ans = lcm(A,B);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();
    ll int n,m,res=0;
    cin>>n;

    VEC(n);
    sort(v.begin(),v.end());

    queue<ll int>q;
    q.push(v[n-1]);
    for(int i=v.size()-2;i>=0;i--)
    {
        res+=q.front();
        q.pop();
        q.push(v[i]);
        q.push(v[i]);
    }
    cout<<res<<endl;


}



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


const long long INF = 1LL << 60;

int main()
{
   string s;
   ll ans=0;
   cin >> s;
   rep(i, s.size()) if(s[i]=='1') ans++;
   cout << ans << endl;
   return 0;
}


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

using namespace std;

vector<pair<int, long long>> arr[1100];

const long long INF = LLONG_MAX - 2000000000LL;
int isReached[1100];
int isUsed[1100];
long long dis[1100];
int cnt[1100];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		long long c;
		cin >> a >> b >> c;
		arr[a].emplace_back(b, c);
	}
	
	dis[1] = 0;
	isReached[1] = 1;
	
	while (true) {
		int tar = -1;
		for (int i = 1; i <= n; ++i) {
			if (isReached[i] == 1 && isUsed[i] == 0) {
				if (tar == -1) tar = i;
				else if(dis[i] > dis[tar]) tar = i;
			}
		}
		if (tar == -1) break;
		isUsed[tar] = 1;
		for (const auto &p : arr[tar]) {
			long long ndis = min(dis[tar] + p.second, INF);
			int nxt = p.first;
			if (isReached[nxt] == 0) {
				isReached[nxt] = 1;
				dis[nxt] = ndis;
			} else if(ndis > dis[nxt]) {
				dis[nxt] = ndis;
				++cnt[nxt];
				isUsed[nxt] = 0;
				if (cnt[nxt] > n) {
					dis[nxt] = INF;
				}
			}
		}
	}
	
	if (dis[n] == INF) puts("inf");
	else cout << dis[n] << endl;
	
	return 0;
}


Measured memory_bytes: 384
N, K, Q = map(int, input().split())
A = list(int(input()) for i in range(Q))

HP = [0] * N

for i in range(Q):
    AC = A[i] - 1
    HP[AC] += 1

for i in range(N):
    if K - Q + HP[i] > 0:
        print('Yes')
    else:
        print('No')

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;

signed main(){
    i64 n;
    cin >> n;
    vector<vector<i64>> v(n);
    vector<i64> siz(n);
    for(i64 i = 0; i < n; ++i){
        cin >> siz[i];
        v[i].resize(siz[i]);
        for(i64 j = 0; j < siz[i]; ++j)
            cin >> v[i][j];
    }
    i64 sum = 0;
    priority_queue<i64> que;
    for(i64 i = n - 1; i >= 0; --i){
        for(auto& x : v[i]){
            que.emplace(x);
        }
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
}



Measured memory_bytes: 21440