akhauriyash/Code-Regression huggingface dataset:
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#define endl "\n"
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

#define int long long

const int nmax = 2e5+7;
const int mod = 1e9+7;

template <class T>
T bm(T b, T p, T m ) /// Faster than recursive one
{
    T res = 1 % m, x = b % m;
    while ( p )
    {
        if ( p & 1 )
            res = ( res * x ) % m;
        x = ( x * x ) % m;
        p >>= 1;
    }
    return res;
}

int32_t main()
{
    optimizeIO();

    int tc = 1;

    while(tc--)
    {
        int n;
        cin>>n;

        vector<int>v(n+1);
        for(int i=1;i<=n;i++) cin>>v[i];

        vector<int>cnt(n+1,0);

        bool ok = true;

        for(int i=1;i<=n;i++)
        {
//            if((n%2) == (v[i]%2))
//            {
//                ok = false;
//                continue;
//            }

            int x = (n-v[i]-1)/2;
            int y = (n+v[i]-1)/2;

            cnt[x+1]++;
            cnt[y+1]++;

        }

        for(int i=1;i<=n;i++) if(cnt[i]!=2) ok = false;

        if(ok) cout<<bm(2LL,n/2,mod)<<endl;
        else cout<<0<<endl;
    }

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    ll n,a,b;
    cin>>n;
    ll m = n + 1;
    ll mons[m],hero[n];
    for (ll i = 0; i < m;i++){
        cin >> mons[i];
    }
    for (ll i = 0; i < n;i++){
        cin >> hero[i];
    }
    ll ans = 0;
    for (ll i = 0; i < n;i++){
        if(mons[i]>0){
            ans+=min(hero[i],mons[i]);
            if(mons[i]<=hero[i]){
                hero[i]-=mons[i];
                ans+=min(hero[i],mons[i+1]);
                mons[i + 1] -= hero[i];
            }
        }else{
            ans += min(hero[i], mons[i + 1]);
            mons[i + 1] -= hero[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
x=[0]*n
c=0
for i in range(1,n-1):
  if i%2!=0:
    c+=a[i]
x[0]=s-2*c
for i in range(1,n):
  x[i]=2*a[i-1]-x[i-1]
print(" ".join(map(str,x)))

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

l=[]
for i in range(1,N+1):
    x=0
    for j in range(len(str(i))):
        x+=int(str(i)[j])
    if x>=A and x<=B:
        l.append(i)
#print(l)
print(sum(l))

Measured memory_bytes: 3404
N=int(input())
v_list=[int(x) for x in input().split()]
v_sort=sorted(v_list)
        
for i in range(N):
    if len(v_sort)<2:
        break
    else:
        v_sort=[(v_sort[0]+v_sort[1])/2]+v_sort[2:]

print(v_sort[0])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

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

	cout << ((N / 10 == 9 || N % 10 == 9) ? "Yes" : "No") << endl;

	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

char itoc(int i) { return char(48 + i); }
int ctoi(char c) { return int(c - '0'); }

string next(string num) {
    int n = num.size();
    vector<bool> kuriage(n, false);

    if (n == 1) {
        if (num[0] != '9') {
            num[0] = itoc(ctoi(num[0]) + 1);
        } else {
            num.push_back('1');
            num[0] = '0';
        }
        return num;
    }

    rep(i, 0, n) {
        // 後ろからi桁目．

        // 先頭の桁．
        if (i == n - 1) {
            if (num[i] != '9' && ctoi(num[i - 1]) - ctoi(num[i]) <= 1) {
                num[i] = itoc(ctoi(num[i]) + 1);
            } else {
                kuriage[i] = true;
                num.push_back('1');
                kuriage.push_back(false);
            }
            break;
        }

        // 上の桁だけをみて判断する．
        if (num[i] != '9' && ctoi(num[i]) - ctoi(num[i + 1]) <= 0) {
            num[i] = itoc(ctoi(num[i]) + 1);
            if (i >= 1 && ctoi(num[i - 1]) - ctoi(num[i]) <= 0) { kuriage[i - 1] = true; }
            break;
        }
        kuriage[i] = true;
    }

    rrep(i, 0, (int)num.size()) {
        if (kuriage[i]) {
            while (i >= 0) {
                if (num[i + 1] == '0') {
                    num[i] = '0';
                } else {
                    num[i] = itoc(ctoi(num[i + 1]) - 1);
                }
                --i;
            }
            break;
        }
    }
    return num;
}

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

    int k;
    cin >> k;

    string num = "1";

    rep(i, 0, k - 1) { num = next(num); }

    reverse(num.begin(), num.end());
    cout << num << endl;

    return 0;
}

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

void input()
{ 
    #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) ll a[n]; rep(i,0,n) cin>>a[i];
#define vector(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a,n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //


int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
  // input();
   int n,k;
   cin>>n>>k;
   vector(a,n);
   sortall(a);
   vector<bool>dp(k+1);

    rep(i,1,k+1)
    {
        rep(j,0,n)
        {
            if(a[j]<=i&&!dp[i-a[j]])
            {
                dp[i]=true;
            }
        }
    }
    cout<<(dp[k]?"First":"Second")<<endl;
}  


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll> > links(n);
    for(int i = 0; i < m; ++i){
        ll u, v;
        cin >> u >> v;
        links.at(u - 1).push_back(v - 1);
    }
    ll s, t;
    cin >> s >> t;
    s--; t--;

    vector<bool> visited(n, false);
    visited.at(s) = true;
    set<ll> cur;
    cur.insert(s);
    ll ans = 0;
    while(cur.size()){
        for(int i = 0; i < 3; ++i){
            set<ll> next;
            for(ll x : cur){
                for(ll y : links.at(x)){
                    next.insert(y);
                }
            }
            cur = next;
        }
        ans++;
        if(cur.count(t)){
            cout << ans << endl;
            return 0;
        }
        set<ll> next_cur;
        for(ll x : cur){
            if(!visited.at(x)){
                next_cur.insert(x);
            }
            visited.at(x) = true;
        }
        cur = next_cur;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 vector<int>P(N);
 vector<int>Q(N);
 for(int i=0;i<N;i++){A.at(i)=i+1;}
 for(int i=0;i<N;i++){cin>>P.at(i);}
 for(int i=0;i<N;i++){cin>>Q.at(i);}

map<vector<int>, int>T;int i=0;
do {T[A]=T.size();
} while (next_permutation(A.begin(), A.end()));
cout<<abs(T[P]-T[Q])<<endl;
 return 0;}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    string n; cin >> n;
    REP(i,3){
        if(n[i] == '1') n[i] = '9';
        else n[i] = '1';
    }
    cout << n << endl;
}


Measured memory_bytes: 3592
#include<iostream>

using namespace std;
int main()
{
    float n,m,a[101];
    cin>>n>>m;long long sum=0;
    for(int i=0;i<n;i+=1){
        cin>>a[i];
        sum = sum+a[i];
    }
    float s1=0,m1,m2 = (1/(4*m));
    ///cout<<m2<<endl;
    m1 = (sum*m2);
    ///cout<<sum<<endl;
    ///cout<<m1<<endl;
    for(int i=0;i<n;i+=1){
        if(m1==a[i] || m1<a[i]){
           s1++;
        }
    }
    ///cout<<s1<<endl;
    if(s1==m || s1>m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
main = do
  n:a:b:_ <- map read . words <$> getLine :: IO [Integer]
  putStrLn $ show $ dist n a b

dist n a b | b < a              = dist n b a
           | mod (b - a) 2 == 0 = div (b - a) 2
           | otherwise          = min (a + b - 1) (n - b + n - a + 1) `div` 2


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

int main() {
	int i, j, n, q, s[10000], t, cnt = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	for (j = 0; j < q; j++) {
		cin >> t;
		for (i = 0; i < n; i++) {
			if (t == s[i]) {
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1196
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
double dp[310][310][310];//1,2,3かんの皿の数
double rec(int a,int b, int c){
    if(dp[a][b][c]>=0) return dp[a][b][c];
    double res=0;
    if(a>0) res+=rec(a-1,b,c)*a;
    if(b>0) res+=rec(a+1,b-1,c)*b;
    if(c>0) res+=rec(a,b+1,c-1)*c;
    res+=n;
    res*=1.0/(a+b+c);
    dp[a][b][c]=res;
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int a=0;
    int b=0;
    int c=0;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        if(temp==1)
        a++;
        else if(temp==2)
        b++;
        else
        c++;
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                dp[i][j][k]=-1;
            }
        }
    }
    dp[0][0][0]=0.0;
    cout << setprecision(15)<<rec(a,b,c) << "\n";
}



Measured memory_bytes: 227584
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T>inline void read(T &x){
	int p=1;x=0;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')p=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<3)+(x<<1)+(c^'0');
		c=getchar();
	}
	x*=p;
}
char c[4][4];
int main(){
	for(register int i=1;i<=3;++i)
		cin>>c[i];
	cout<<c[1][0]<<c[2][1]<<c[3][2]<<endl;
	return 0;
}

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

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;

int main()
{
	int a, b, c;
	cin >> a >> b >> c ;
	if (a + b >= c)
	{

		cout << "Yes" << endl;
	}else{

		cout << "No" << endl;
	}
	
	return 0;
}

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

int main() {
    int N;
    int a[110]; 
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N); 
    cout << a[N-1] - a[0] << endl;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll S, W; cin >> S >> W;
    string res = (S>W) ? "safe" : "unsafe";
    cout <<  res << endl;
    return 0;
}


Measured memory_bytes: 3616
var
    n,k,tot,tot1,tot2:int64;
begin
    readln(n,k);
    if odd(k) then 
        begin
            tot:=n div k;
            writeln(tot*tot*tot);
        end
    else
        begin
            tot1:=n div k;
            tot2:=n div (k div 2)-tot1;
            writeln(tot1*tot1*tot1+tot2*tot2*tot2);
        end;
end.

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

int main()
{
  int A[3], B[3];
  int C[3][3];
  rep(i, 3) {
    rep(j, 3) {
      cin >> C[i][j];
    }
  }

  rep(a1, 101) {
    rep(a2, 101) {
      rep(a3, 101) {
        int b1 = C[0][0] - a1;
        int b2 = C[0][1] - a1;
        int b3 = C[0][2] - a1;

        A[0] = a1;
        A[1] = a2;
        A[2] = a3;
        B[0] = b1;
        B[1] = b2;
        B[2] = b3;

        int ok = 1;
        rep(i, 3) {
          rep(j, 3) {
            if (A[i] + B[j] != C[i][j]) ok = 0;
          }
        }
        if(ok) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout <<"No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long a = x / 500;
        long b = (x - a * 500) / 5;
        System.out.println(a * 1000 + b * 5);
    }

}


Measured memory_bytes: 23764
#include <cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({ a, ex });
    }

    if (N != 1) res.push_back({ N, 1 });
    return res;
}

int main() {
	int n;
	cin >> n;
	ll ans = 1;
    vector<P>p;
    map<ll, ll>mp;
	for (int i = 2; i <= n; i++) {
        
        p = prime_factorize(i);
        for (auto id : p) {
            mp[id.first]+=id.second;
        }

	}
    for (auto x : mp) {
        
        ans *= (mp[x.first] + 1);
        ans %= inf;
    }
 
    cout << ans%inf << endl;
    return 0;
}

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

p = [i%2 for i in N]

ans = 0

if sum(p) == 0 or sum(p) == 3:
    m = max(N)
    for i in N:
        ans += (m-i)//2
elif sum(p) == 1:
    for i in range(3):
        if N[i]%2 == 0:
            N[i] += 1
    ans += 1
    m = max(N)
    for j in N:
        ans += (m-j)//2
else:
    for i in range(3):
        if N[i]%2 == 1:
            N[i] += 1
    ans += 1
    m = max(N)
    for j in N:
        ans += (m-j)//2

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
   int a, b, temp, i;
   
   for(i = 1; i <= 3000; i++)
   {
       cin >> a >> b;
       if (a == 0 && b == 0) {break;};
       if(a > b)
       {
            temp = a; 
            a = b;
            b = temp; 
       }
       cout << a << " " << b << endl; 
      }
   }


Measured memory_bytes: 3044
#include <iostream>
#include <string>
using namespace std;
 
void A()
{
    string S;
    cin >> S;
    
    string answer = "Yes";
    if( S[0] == S[1] && S[1] == S[2] )
        answer = "No";
    
    cout << answer << endl;
}
 
int main()
{
    A();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(0 <= x-r &&  x + r<= W && 0 <= y-r && y + r <= H){
           System.out.println("Yes"); 
        }else{
            System.out.println("No"); 
        }
    }
}


Measured memory_bytes: 26380
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if (A+B>C+D){
    cout<<"Left"<<endl;
  }
  if (A+B==C+D){
    cout<<"Balanced"<<endl;
  }
  if (A+B<C+D){
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N, M) = listOfInt()
    val INF = (1L).shl(50)
    val A = IntArray(M); val B = IntArray(M)
    val C = LongArray(M)
    for (m in 0 until M) {
        val (a, b, c) = tripleIntIntLong()
        A[m] = a; B[m] = b; C[m] = -c
    }
    val dist = LongArray(N) { INF }
    dist[0] = 0L
    repeat (N - 1) {
        for (m in 0 until M) {
            if (dist[A[m] - 1] == INF) continue
            if (dist[B[m] -1] > dist[A[m] - 1] + C[m]) {
                dist[B[m] -1] = dist[A[m] - 1] + C[m]
            }
        }
    }
    var ans = dist[N - 1]
    val negative = BooleanArray(N)
    repeat (N) {
        for (m in 0 until M) {
            if (dist[A[m] - 1] == INF) continue
            if (dist[B[m] - 1] > dist[A[m] - 1] + C[m]) {
                dist[B[m] - 1] = dist[A[m] - 1] + C[m]
                negative[B[m] - 1] = true
            }
            if (negative[A[m] - 1]) negative[B[m] - 1] = true
        }
    }

    println(if (negative[N - 1]) "inf" else -ans)
}

fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    i64 g = __gcd(n, m);
    for (i64 si = 0, ti = 0; si < n && ti < m; si += n / g, ti += m / g) {
        if (s[si] != t[ti]) {
            cout << -1 << endl;
            return;
        }
    }
    cout << n * m / g << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String SORT_LENGTH=br.readLine();
		int LENGTH=Integer.parseInt(SORT_LENGTH);
		while (true){
			try{
				int[] hako=new int[LENGTH];
				String obj=br.readLine();

				StringTokenizer st=new StringTokenizer(obj," ");
				int i=0;
			     while (st.hasMoreTokens()) {
			    	 hako[i]=Integer.parseInt(st.nextToken());
			    	 i++;
			     }i=0;

			     String nakami=""+hako[0];
					for(int s=1; s<hako.length; s++){
						nakami=nakami+" "+hako[s];
					}
					System.out.println(nakami);
					nakami="";

				int[] res=Insert_srt(hako);
			}
			catch(Exception e){
				System.exit(0);
			}
		}
	}

	public static int[] Insert_srt(int[] a){		//????????????????????????????????°??¨????????£??\
		int[] ary=a;
		for(int i=1; i<ary.length; i++){
			int v=ary[i];
			int j=i-1;

			while(j>=0 && ary[j]>v){
				ary[j+1] = ary[j];
				j--;
			}
			ary[j+1]=v;
			String ketsugou=""+ary[0];
			for(int s=1; s<ary.length; s++){
				ketsugou=ketsugou+" "+ary[s];
			}
			System.out.println(ketsugou);
			ketsugou="";
		}
		return ary;
	}
}

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

int main() {
    int k,a,b;
    cin>>k>>a>>b;
    int tmp = a/k;
    if(tmp*k==a||(tmp+1)*k<=b){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <vector>
using namespace std;
int main()
{
	int e[101] = { 1 };
	for (int i = 1;i < 101;i++)
	{
		e[i] = 1;
		
	}
	e[0] = 0;
	int a, b;
	cin >> a >> b;
	for (int i = 0;i < b;i++)
	{
		int c;
		cin >> c;
		for (int j = 0;j < c;j++)
		{
			int d;
			cin >> d;
			e[d] = 0;
		}

	}
	int counter = 0;
	for (int i = 1;i < a + 1;i++)
	{
		counter = counter + e[i];
	}
	cout << counter;
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	string ans = "AGC";
	int n;
	cin >> n;
	if (n < 1200) ans = "ABC";
	if (n >= 1200 && n < 2800) ans = "ARC";


	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll unsigned long long
#define N 123451

int r, c, g[501][501];
vector<pair<int, int>> f, to;

int main() {
        cin >> r>> c;
        lp (i, 0, r) {
                lp (j, 0, c) {
                        cin >> g[i][j];
                }
        }
        lp (i, 0, r) {
                lp (j, 0, c) {
                        if (g[i][j] & 1) {
                                if (i == r - 1 && c - 1 == j) continue;
                                f.push_back({i + 1, j + 1});
                                if (j == (c - 1)) {
                                        g[i + 1][j]++;
                                        to.push_back({i + 2, j + 1});
                                } else {
                                        g[i][j + 1]++;
                                        to.push_back({i + 1, j + 2});
                                }
                        }
                }
        }
        cout << sz(f) << endl;
        lp (i, 0, sz(f)) cout << f[i].first << " "<< f[i].second<< " "<< to[i].first<< " "<< to[i].second<< endl;
        return 0;
}


/*
long long
constrain N
*/


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

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N); for (ll i = 0; i < N; ++i) cin >> A[i];
    ld l = 1, r = *max_element(A.begin(), A.end()) + 1;
    while (r - l > 1e-10) {
        ld m = l + (r - l) / 2;
        ll cnt = 0;
        for (ll i = 0; i < N; ++i) {
            cnt += ceil(A[i] / m) - 1;
            if (cnt > K) break;
        }
        // cout << "m = " << m << " cnt = " << cnt << endl;
        if (cnt <= K) {
            r = m;
        } else {
            l = m;
        }
    }
    std::cout << std::setprecision(15);
    cout << ceil(l) << endl;
    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
typedef long long lint;
const int N=2e5+5;
const int mod=1e9+7;
int n,dp[N];//前缀和
std::vector <int> m_ls[N];
struct _pair{
	int x,y;
}dt[N],spc[N];
//dt: pos,v
//spc: l,r

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline bool _pr_cmp_y(const _pair &a,const _pair &b){
	return a.y<b.y;
}

template <class T> inline void apx(T &x,const T y){
	x<y?x=y:0;
}

namespace B{
	int tr[N];
	inline void clear(){
		memset(tr+1,0,n*sizeof(int));
	}
	inline void apl(int x,const int v){
		for(; tr[x]<v&&x<=n; x+=x&-x) tr[x]=v;
	}
	inline int ask(int x){
		int ans=0;
		for(; x; x-=x&-x) apx(ans,tr[x]);
		return ans;
	}
}

template <class T> class _Disc{
	public:
		T buk[N],*pt;
		int tot;

		_Disc(){pt=buk;}
		inline void insert(const T &v){
			*pt++=v;
		}
		inline void build(){
			std::sort(buk,pt);
			pt=std::unique(buk,pt);
			tot=pt-buk;
		}
		inline int ask(const T &v){
			return std::lower_bound(buk,pt,v)-buk+1;
		}
};
_Disc <int> D;

template <class T> inline int fpow(int x,T t){
	int ans=1;
	for(; t; x=(lint)x*x%mod,t>>=1){
		if(t&1) ans=(lint)ans*x%mod;
	}
	return ans;
}

int solve(const int t){
	static int buk[N];
	const int sz=m_ls[t].size();
	if(!sz) return 0;
	std::sort(m_ls[t].begin(),m_ls[t].end());
	for(std::vector <int> ::iterator it=m_ls[t].begin(); it!=m_ls[t].end(); ++it){
		++buk[*it];
	}
	int lst_dp=0,res=0,psum=0;
	for(std::vector <int> ::iterator it=m_ls[t].begin(); it!=m_ls[t].end(); ++it){
		if(!buk[*it]) continue;
		if(psum){
			int wgt=(dp[*it-1]-lst_dp+mod)%mod;
			res=(res+(lint)wgt*(fpow(2,psum)-1)%mod*fpow(2,sz-psum))%mod;
		}
		psum+=buk[*it];
		buk[*it]=0;
		lst_dp=*it?dp[*it-1]:0;
	}
	int wgt=dp[t-1]-lst_dp+mod;
	res=(res+(lint)wgt*(fpow(2,sz)-1+mod))%mod;
	return res;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("d.in","r",stdin);
#endif
	n=nxi();
	for(int i=1; i<=n; ++i){
		dt[i].x=nxi(),dt[i].y=nxi();
		D.insert(dt[i].x);
	}
	D.build();
	for(int i=1; i<=n; ++i){
		dt[i].x=D.ask(dt[i].x);
	}
	std::sort(dt+1,dt+n+1,_pr_cmp_y);
	for(int i=1; i<=n; ++i){
		int res=B::ask(n-dt[i].x+1);
		spc[i].x=res?n-res+1:i;
		B::apl(n-dt[i].x+1,n-i+1);
	}
	B::clear();
	for(int i=n; i>=1; --i){
		int res=B::ask(dt[i].x);
		spc[i].y=res?res:i;
		B::apl(dt[i].x,i);
	}
	for(int i=1; i<=n; ++i){
		//printf("%d %d\n",spc[i].x,spc[i].y);
		m_ls[spc[i].y].push_back(spc[i].x-1);
	}
	dp[0]=1;
	for(int i=1; i<n; ++i){
		dp[i]=(dp[i-1]+solve(i))%mod;
	}
	printf("%d\n",solve(n));
	return 0;
}


Measured memory_bytes: 17408
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for h in range(0,c+1):
  for i in range(0,b+1):
    for j in range(0,a+1):
      if (x == ((500 * j) + (100 * i) + (50 * h))):
      	cnt = cnt +1

print(cnt)


Measured memory_bytes: 3060
s = input()
isOdd = True
for i in range(len(s)):
    if isOdd == False and s[i] == 'R':
        print('No')
        exit()
    if isOdd == True and s[i] == 'L':
        print('No')
        exit()
    isOdd = not isOdd

print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin>>n;
	vector<ll> a(n+2,0);
	a[0] = 10000;
	rep(i,0,n) cin>>a[i+1];
	ll m=1000;
	ll kabu=0;
	rep(i,1,n+1){
		if(a[i-1] >= a[i] and a[i] <= a[i+1]){
			ll buy_kabu = m/a[i];
			kabu += buy_kabu;
			m -= buy_kabu * a[i];
		}else if(a[i-1] <= a[i] and a[i] >= a[i+1]){
			ll sell_money = kabu * a[i];
			kabu = 0;
			m += sell_money;
		}
		// debug(kabu);
		// debug(m);
	}
	cout<<m<<endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(s1: Vec<char>, s2: Vec<char>, s3: Vec<char> ) -> String {
    let mut res = String::new();
    res.push(s1[0].to_uppercase().collect::<Vec<_>>()[0]);
    res.push(s2[0].to_uppercase().collect::<Vec<_>>()[0]);
    res.push(s3[0].to_uppercase().collect::<Vec<_>>()[0]);
    res
}

fn main() {
    input!{
        s1: chars,
        s2: chars,
        s3: chars,
    }
    println!("{}", solve(s1, s2, s3));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define inf 0x3f3f3f3f 
int main(){
	ll t , a , b , c , dp[3] = {0};
    cin >> t ;
	for(int i = 0 ; i < t ; ++i){
        cin >> a >> b >> c;
        ll aa , bb , cc;
        aa = max(dp[1] + a , dp[2] + a);
        bb = max(dp[0] + b , dp[2] + b);
        cc = max(dp[0] + c , dp[1] + c);
        dp[0] = aa; dp [ 1] = bb ; dp[2] = cc;
    }
    cout<<max(max(dp[0] , dp[1]) , dp[2]);
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()



int main(){
  ll N,ans=0;
  cin >> N;
  vector<int64_t> P(1000000,0),W(1000000,0);
  P.at(0)=2;
  ll t=0;
  for(ll i=3;i<=1000000;i++){
    ll a=0;
    for(ll j=0;j<=t;j++){
      if(P.at(j)*P.at(j)>i){
        break;
      }
      if(i%P.at(j)==0){
        a=1;
        break;
      }
    }
    if(a==0){
      t++;
      P.at(t)=i;
    }
  }
  for(ll i=0;i<=t;i++){
    while(N%P.at(i)==0){
      N/=P.at(i);
      W.at(i)++;
    }
    ll x=1;
    while(W.at(i)>0){
      if(W.at(i)>=x){
        ans++;
        W.at(i)-=x;
        x++;
      }else{
        W.at(i)=0;
      }
    }
  }
  if(N!=1){
    ans++;
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 18840
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define f(i,a,n) for(i=a;i<n;i++)
#define rf(i,a,n) for(i=a;i>=n;i--)
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define umii unordered_map<int,int>
#define umci unordered_map<char,int>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define all(v) begin(v),end(v)
#define mkp make_pair
#define M 1000000007
#define TakeInput freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);


using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	//TakeInput
	#endif
	fast;
	int i,j,n;
	cin >> n;
	int a[10][10] = {0};
	f(i,1,n+1)
	{
		ll t = i;
		ll f,l,r;
		bool flag = true;
		while (t>0)
		{
			r = t%10;
			if (flag == true)
			{
				l = r;
				flag = false;
			}
			t = t/10;
		}
		f = r;
		a[f][l]++; 
	}
	ll cnt=0;
	f(i,0,10)
	{
		f(j,0,10)
		{
			cnt += a[i][j]*a[j][i];
		}
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := []int{}
	y := []int{}
	for i := 0; i < n; i++ {
		x = append(x, nextInt())
		y = append(y, nextInt())
	}
	xa := 0
	for j := n - 1; j >= 0; j-- {
		if xy := (x[j] + xa) % y[j]; xy != 0 {
			xa += y[j] - xy
		}
		//fmt.Println(xa)
	}
	fmt.Println(xa)
}


Measured memory_bytes: 7552
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
min = 1000
for i in range(n):
  T = t - h[i] * 0.006
  if abs(T-a) < min:
    min = abs(T-a)
    ans = i + 1
print(ans)


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())
#define endl '\n'

#ifdef SANJU
    #define localsys 1
#else
    #define localsys 0
#endif

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;

long long int cons=1e9+7;

#define min2(a,b)  ((a)<(b)?(a):(b))

void sanjeev(int kkkk)
{
    long long int n,k;
    cin>>n>>k;
    vector<long long int>A;
    A.push_back(0);
    for(long long int i=0;i<n;i++)
    {
        long long int t;
        cin>>t;
        A.push_back(t);
    }

    long long int dp[n+1][k+1]={0};
    for(long long int i=0;i<=A[n];i++)dp[n][i]=1;

    long long int pre[n+1][k+1]={0};
    pre[n][0]=dp[n][0];

    for(long long int i=1;i<=k;i++)pre[n][i]=pre[n][i-1]+dp[n][i];    

    for(long long int i=n-1;i>=1;i--)
    {
        for(long long int j=0;j<=k;j++)
        {
           long long int l=j-min2(j,A[i]);
           long long int r=j;
           if(l==0)
           {
            dp[i][j]+=pre[i+1][r];
            dp[i][j]%=cons;
           }
           else 
           {
            dp[i][j]+=(cons+pre[i+1][r]-pre[i+1][l-1])%cons;
            dp[i][j]%=cons;
           }

           if(j==0)
           {
            pre[i][j]=dp[i][j];
           }
           else
           {
            pre[i][j]=pre[i][j-1]+dp[i][j];
            pre[i][j]%=cons;
           }
        }
    }
    cout<<dp[1][k];    
}

int main()
{
    if(!localsys) ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { sanjeev(i+1); }
    if(localsys) system("pause");
}


Measured memory_bytes: 156800
#include<iostream>
#include<algorithm>

using namespace std;
int n, l, a[108000];
int main(){
  cin >> n >> l;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  int p = -1;
  for(int i = 0;i < n - 1;i++){
    if(a[i] + a[i+1] >= l)p = i;
  }
  if(p == -1){
    cout << "Impossible" << endl;
    return 0;
  }
  p++;
  cout << "Possible" << endl;
  for(int i = 1;i < p;i++)cout << i << endl;
  for(int i = n-1;i > p;i--)cout << i << endl;
  cout << p << endl;
  return 0;
}


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n = 1, a;
	string s;
	if ( cin >> n >> a );
	else return false;
	
	if ( n < a ) cout << 0 << '\n';
	else cout << 10 << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define fio ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(ll i=a;i<n;i++)
#define foir(a,n) for(ll i=a;i>=n;i--)
#define foj(a,n) for(ll j=a;j<n;j++)
#define fok(a,n) for(ll k=a;k<n;k++)
using namespace std;
int main() 
{
	fio;
	ll x,y;
  cin>>x>>y;
  ll min = x*2;
  ll max = x*4;
  if(!(y >= min && y <= max))
    cout<<"No";
  else
  {
   if(y%2==0)
     cout<<"Yes";
    else
        cout<<"No";
  }
}


Measured memory_bytes: 3568
#include<stdio.h>
int main(void){
char x[200001];
scanf("%s",x);
int a,b;
for(a=0;a<200001;a++){
if(x[a]=='A')break;
}
for(b=200001;b>0;b--){
if(x[b]=='Z')break;
}
a = b - a + 1;
printf("%d",a);
return 0;
}

Measured memory_bytes: 384
m={"E":[3,1,0,5,4,2], "N":[1,5,2,3,0,4], "W":[2,1,5,0,4,3], "S":[4,0,2,3,5,1]}
d=map(int, raw_input().split())
nd=[0]*6
for x in raw_input():
    for j in range(6): nd[j]=d[m[x][j]]
    d=list(nd)
print d[0]

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  int d=0;
  for(int i=0;i<a;i++){
    if(k>d){
      ans++;
      d++;
    }
    else
      break;
  }
   for(int i=0;i<b;i++){
    if(k>d){
      d++;
    }
    else
      break;
  }
   for(int i=0;i<c;i++){
    if(k>d){
      ans =ans-1;
      d++;
    }
    else
      break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
 int n;
 cin>>n;
 if(n<1200)
    cout<<"ABC"<<endl;
 else if(n<2800)
    cout<<"ARC"<<endl;
 else
    cout<<"AGC"<<endl;
    return 0;

}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n, k;
    cin >> n >> k;

    vector< long long int > a;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        in--;
        a.push_back( in );
    }

    vector< long long int > p( 214514, -1 );

    long long int cnt = 0;
    long long int x = 0;
    p[x] = cnt;

    while( true ) {
        x = a[x];
        cnt++;
        if ( cnt == k ) {
            cout << x + 1 << endl;
            break;
        }
        if ( p[x] == -1 ) {
            p[x] = cnt;
            continue;
        }
        long long int lo = cnt - p[x];
        k %= lo;
        while( k < cnt ) { k += lo; }
    }

    return 0;

}


Measured memory_bytes: 6672
#include <iostream>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
using namespace std;



int main(void){

	for (int i = 1; i < 10; i++){
	
		for (int j = 1; j < 10; j++){
		

			cout << i << "x" << j << "=" << i*j << endl;

		}

	}

	

	
	return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
int main() {
 string a,b;
  cin >> a >> b;
  int hit = 0;
  if(a.at(0)==b.at(0)) hit++;
  if(a.at(1)==b.at(1)) hit++;
  if(a.at(2)==b.at(2)) hit++;
  cout << hit << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <queue>
#include <memory>
#include <fstream>
#include <strstream>


#pragma GCC optimize("no-stack-protector,Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,abm,mmx,tune=native,avx,avx2")

#define int long long
#define ld long double
#define eb emplace_back
#define pb pop_back
#define mp make_pair
#define ss second
#define ff first
#define sqr(x) (x) * (x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef int(*func)(int a, int b);

using namespace std;

const int INF = 1e9 + 7;
const int B = 299;
const int MOD = 1e9 + 123;
const ld EPS = 1e-7;
const ld PI = 3.14159265358979323;
const int MAXN = 2100;

random_device rd;
mt19937 get_rand(rd());

int gcd(int a, int b) {
	return (!a ? b : gcd(b % a, a));
}

vector < vector < int > > g;
bool u[2010], c[2010];

bool dfs(int v, bool z) {
	u[v] = 1;
	c[v] = z;
	for (auto i : g[v]) {
		bool k = 1;
		if (!u[i])
			k = dfs(i, !z);
		if (c[i] == z || !k)
			return 0;
	}
	return 1;
}


signed main() {
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
#ifdef _LOCAL
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(0);
	srand(time(NULL));

	int t = 1;
	//cin >> t;
	while (t--) {
		int a, b;
		cin >> a >> b;
		int n = b - a - 1;
		cout << n * (n + 1) / 2 - a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import fractions
import math


def run(n, m, s, t):
    ret = -1
    if s[0] != t[0]:
        return ret
    g = fractions.gcd(n, m)
    if g == 1:
        big = max([n, m])
        small = min([n, m])
        if small == 1:
            for i in range(math.sqrt(n)):
                if big % i == 0:
                    return i
        else:
            return n*m
    n_s = n//g
    m_s = m//g
    mn = n_s * m_s
    small = min([g, mn])
    for j in range(1, g+1):
        if n_s * m_s < j:
            return -1
        n_eval = j*n_s
        m_eval = j*m_s
        eval = True
        for i in range(1, g):
            if i*n_eval >= n:
                eval = False
                continue
            if i*m_eval >= m:
                eval = False
                continue
            if s[i*n_eval] != t[i*m_eval]:
                eval = False
                continue
        if eval:
            return n_eval * m_eval * g
    return -1


def main():
    n, m = map(int, input().split())
    s = input()
    t = input()
    print(run(n, m, s, t))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5372
while n = gets.to_i
    break if n == 0
    arr = gets.split.map(&:to_i)
    hsh = Hash.new(0)
    arr.each {|m| hsh[m] += 1}
    puts hsh.each_value.all?{|v| v <= n - v} ? "NO COLOR" : hsh.key(hsh.each_value.max)
end

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 3000 + 100;

int N, M, Dp[Maxn][Maxn];
char S[Maxn], T[Maxn];

stack <char> Stack;

inline void Solve ()
{
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
		{
			Chkmax(Dp[i][j], Dp[i - 1][j]);
			Chkmax(Dp[i][j], Dp[i][j - 1]);
			if (S[i] == T[j]) Chkmax(Dp[i][j], Dp[i - 1][j - 1] + 1);
		}
	int tmp = Dp[N][M];
	for (int i = N; i >= 1; --i)
		for (int j = M; j >= 1; --j)
		{
			if (S[i] == T[j] && Dp[i][j] == tmp)
			{
				--tmp, Stack.push(S[i]);
				break;
			}
		}
	while (!Stack.empty()) printf("%c", Stack.top()), Stack.pop();
}

inline void Input ()
{
	scanf("%s", S + 1); scanf("%s", T + 1);
	N = strlen(S + 1), M = strlen(T + 1);
}

int main()
{
#ifdef hk_cnyali
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


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

int main() {
  int N; string S; cin >> N >> S;
  int a = 0, b = 0;
  for( int i = 0; i < N; i++ ) {
    if( S.at(i) == '.' )
      b++;
  }
  a = b;
  for( int i = 0; i < N; i++ ) {
    if( S.at(i) == '.' )
      b--;
    else
      b++;
    a = min(a,b);
  }
  cout << a << endl;
}

Measured memory_bytes: 640
N, K = map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort(reverse = True)
ans=10**9
#print(h)
for i in range(N-K+1):
    ans = min(ans,h[i]-h[i+K-1])
#    print(ans)
print(ans)
    

Measured memory_bytes: 7384
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
    int N,Y;
    scanf("%d %d",&N,&Y);
    for(int i=0;i<=N && 10000*i<=Y;i++){
            for(int j=0;i+j<=N && 10000*i+5000*j<=Y;j++){
                if(i*10000+j*5000+(N-i-j)*1000 == Y){
                    printf("%d %d %d",i,j,N-i-j);
                    return 0;
                }
          }
    }
printf("-1 -1 -1");
return 0;        
}


Measured memory_bytes: 128
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
  l=len(list(group))
  if l >= 2:
    s+=l*(l-1)/2
  dic[x]=l

for k in range(N):
  l=dic[A[k]]
  if l >= 2:
    print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
  else:
    print(int(s))
    

Measured memory_bytes: 94172