akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 310 
#define mod1 1000000007
#define mod2 1000000009
#define base1 19260817
#define base2 20010911
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
int M1(int x){return x>=mod1?x-mod1:x;}
int M2(int x){return x>=mod2?x-mod2:x;}
struct Hash{
	int a,b;
	Hash(){a=b=0;}
	Hash(int a,int b):a(a),b(b){}
	bool operator<(const Hash& h)const{return a==h.a?b<h.b:a<h.a;} 
	bool operator!=(const Hash& h)const{return a!=h.a||b!=h.b;}
	bool operator==(const Hash& h)const{return a==h.a&&b==h.b;}
	Hash operator+(const Hash& h)const{return Hash(M1(a+h.a),M2(b+h.b));}
	Hash operator-(const Hash& h)const{return Hash(M1(a-h.a+mod1),M2(b-h.b+mod2));}
	Hash operator*(const Hash& h)const{return Hash(((ll)a*h.a)%mod1,((ll)b*h.b)%mod2);}
	Hash inv()const{return Hash(M1(mod1-a),M2(mod2-b));}
	void print(){printf("[%d,%d]\n",a,b);}
}pw[maxn],h[maxn][maxn],g[maxn][maxn],B(base1,base2);
int n,ans=0;
char s[maxn][maxn];
Hash cal(Hash h[],int l,int r){
	return h[r]-(l?h[l-1]:Hash(0,0))*pw[r-l+1];
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)
		scanf("%s",s[i]);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			h[i][j]=(j?h[i][j-1]:Hash(0,0))*B+Hash(s[i][j],s[i][j]);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			g[i][j]=(j?g[i][j-1]:Hash(0,0))*B+Hash(s[j][i],s[j][i]);
	pw[0]=Hash(1,1);
	for(int i=1;i<=n;++i)pw[i]=pw[i-1]*B;
	for(int a=0;a<n;++a)
		for(int b=0;b<n;++b){
			int flg=1;
			for(int i=0;i<n&&flg;++i){
				int fra=(i-a+n)%n;
				Hash lef=(b==0?h[fra][n-1]:cal(h[fra],n-b,n-1)*pw[n-b]+cal(h[fra],0,n-b-1));
				int frb=(i-b+n)%n;
				Hash rig=(a==0?g[frb][n-1]:cal(g[frb],n-a,n-1)*pw[n-a]+cal(g[frb],0,n-a-1));
				flg&=lef==rig;
			}
			ans+=flg;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      map.put(a, map.getOrDefault(a, 0) + 1);
    }
    
    PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
      if (entry.getValue() >= 4) {
        pq.offer(entry.getKey());
        pq.offer(entry.getKey());
      } else if (entry.getValue() >= 2) {
        pq.offer(entry.getKey());
      }
    }
    
    if (pq.size() >= 2) {
      int a = pq.poll();
      int b = pq.poll();
      System.out.println((long)a*b);
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 60796
N = int(input())
S = input()
ans = S.count("R")*S.count("G")*S.count("B")

for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    cin >> n;
    cout << 180*(n-2) << endl;
    return 0;
}

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

int strongness(int n) {
  return (n + 11) % 13;
}

int main() {
  int a, b;
  cin >> a >> b;
  int sa = strongness(a);
  int sb = strongness(b);
  string ans;
  if (sa > sb) {
    ans = "Alice";
  } else if (sa == sb) {
    ans = "Draw";
  } else {
    ans = "Bob";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[200001], invf[200001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(x<y) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, m; cin>>n>>m;
    string s; cin>>s;
    if(s[0]=='B'){
        for(int i=0; i<m; i++){
            if(s[i]=='B') s[i]='R';
            else s[i]='B';
        }
    }
    int j=-1;
    vector<int> v;
    bool nuo=1;
    for(int i=0; i<m-1; i++){
        if(s[i+1]=='B'){
          nuo=0;
            v.push_back(i-j);
            j=i+1;
        }
    }
    if(nuo){
        ll dp[2][200002]={};
        dp[0][0]=1;
        for(int i=1; i<n; i++){
            dp[1][i]+=dp[0][i-1];
            dp[0][i]+=(dp[0][i-1]+dp[1][i-1]);
            dp[0][i]%=MOD;
            dp[1][i]%=MOD;
        }
        ll ans=dp[0][n-1]+dp[1][n-1];
        fill(dp[0], dp[0]+n+1, 0);
        fill(dp[1], dp[1]+n+1, 0);
        dp[1][0]=1;
        for(int i=1; i<n; i++){
            dp[1][i]+=dp[0][i-1];
            dp[0][i]+=(dp[0][i-1]+dp[1][i-1]);
            dp[0][i]%=MOD;
            dp[1][i]%=MOD;
        }
        ans+=dp[0][n-1];
        ans%=MOD;
        cout<<ans<<endl;
        return 0;
    }
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    int mx=v[0]+1-v[0]%2;
    for(int i=1; i<v.size(); i++){
        if(v[i]&1) mx=min(mx, v[i]);
    }
    ll dp[200002]={}, sum[200002];
    dp[0]=1;
    sum[0]=1;
    for(int i=1; i<=n; i++){
        if(i&1) sum[i]=sum[i-1];
        else{
            if(i-mx-3>=0) dp[i]=(sum[i-2]-sum[i-mx-3]+MOD)%MOD;
            else dp[i]=sum[i-2];
            sum[i]=(sum[i-1]+dp[i])%MOD;
        }
    }
    ll ans=0;
    for(int i=1; i<=min(mx, n-1); i+=2){
        ans+=(ll)(i+1)*dp[n-i-1];
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5628
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,N,M,V,P,ans,bo,ng,mid,res;
  cin>>N>>M>>V>>P;
  ng=N+1;
  vec v(N);
  rep(i,N)cin>>v[i];
  vrsort(v);
  bo=v[P-1];
  ans=P;
  if(V<=P){
    For(i,P,N){
      if(v[i]+M>=bo)ans++;
    }
    cout<<ans<<endl;
    return 0;
  }
  while(ng-ans>1){
    mid=(ng+ans)/2;
    res=0;
    if(bo>v[mid-1]+M){
      ng=mid;
      continue;
    }
    rep(i,N){
      if(i<P-1){
        res+=M;
        continue;
      }
      res+=min(M,v[mid-1]+M-v[i]);
    }
    if(res>=V*M){
      ans=mid;
    }else{
      ng=mid;
    }
  }
  cout<<ans<<endl;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int a,b;
	cin>>a>>b;
	if(a<=5)
		cout<<"0\n";
	else if(a>=13)
		cout<<b<<endl;
	else
		cout<<b/2<<endl;
	return 0;
}

Measured memory_bytes: 3664
S = input()

N = len(S)
#make 010101... and 101010... of length N
A = "" #010101...
B = "" #101010...

for i in range(N):
    if i % 2 == 0:
        A += "0"
        B += "1"
    else:
        A += "1"
        B += "0"

#compare the difference between S and A,B and count
difA = 0
difB = 0
for i in range(N):
    if S[i] != A[i]:
        difA += 1
    if S[i] != B[i]:
        difB += 1

#the answer is the smaller of difA and difB
print(min(difA,difB))


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main(){
	long long x,y,c;
	cin>>x>>y;
	if(x<y){
		c=y;
		y=x;
		x=c;
	}
	c=0;
	while(x!=0&&y!=0){
		if(c%2==0){
			x=x%y;
		}else{
			y=y%x;
		}
		++c;
	}
	cout<<x+y<<endl;
	return 0;
}

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

int main()
{
	int n, h, w, i, br=0;
	scanf("%d%d%d", &n, &h, &w);
	int a[n], b[n];

	for(i=0; i<n; i++){
		scanf("%d%d", &a[i], &b[i]);
		if(a[i]>=h && b[i]>=w) br++;
	}

	printf("%d", br);

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  vector<ll> sum(n+1);
  ll ans = 0, idx = 0;
  rep (i, n) {
    ll num = max((p[i].second-sum[i]+a-1)/a, 0LL);
    ans += num;
    while (idx < n && p[idx].first <= p[i].first+d*2)
      idx++;
    sum[idx] -= num*a;
    sum[i+1] += sum[i]+num*a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
N = int(input())
S = input()
m = S.count('R')*S.count('G')*S.count('B')
n = 0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2 * j - i
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                n += 1
print(m-n)  


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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int n, card[16];
    int field;
    char c;

    scanf("%d", &n );

    while ( n != 0 ) {
        for ( int i = 0; i < 16; ++i ) {
            card[i] = 0;
        }

        field = 0;
        for ( int i = 0; i < 100; ++i ) {
            cin >> c;
            if ( c == 'M' ) {
                card[ i % n ] += 1;
            } else if ( c == 'S' ) {
                field += card[ i % n ] + 1;
                card[ i % n ] = 0;
            } else if ( c == 'L' ) {
                card[ i % n ] += field + 1;
                field = 0;
            }
        }

        sort ( card, card + n );
        for ( int i = 0; i < n; ++i ) {
            printf("%d ", card[i] );
        }
        printf("%d\n", field );

        scanf("%d", &n );
    }

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}




Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  int n ;
  cin >> n ;
  
  if(n<105){
    cout << 0 <<endl ;
  }
  else if(n<135){
    cout << 1 <<endl ;
  }
  else if(n<165){
    cout << 2 <<endl ;
  }
  else if(n<189){
    cout << 3 <<endl ;
  }
  else if(n<195){
    cout << 4 << endl ;
  }
  else{
    cout << 5 <<endl ;
  }

  return 0 ;
}


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

namespace sqn {

    inline const long double func(const long double x_, const long double num_) { return x_ * x_ - num_; }
    inline const long double func2(const long double x_) { return 2 * x_; }
    const bool abs_eps(long double num_) {
        constexpr long double EPS{ 1.0e-10 };
        if (num_ < 0.0) num_ *= -1;
        return (num_ < EPS);
    }
    //平方根を求める
    long double sqrtn(long double num_) {
        long double a{ 1.0 };
        const long double c{ num_ };
        int i{};
        while (true) {
            num_ = a - func(a, c) / func2(a);
            if (abs_eps(a - num_)) break;
            else a = num_;
            ++i;
            if(i >= 200000) break;
        }
        return num_;
    }
}

int main() {
    long double a, b, c;
    cin >> a >> b >> c;
 
    long double x;
    x = sqn::sqrtn(a * b);
 
    if(x < (c - a - b) / 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

typedef long long LL;
#define MAXN 2000002
#define _MOD 1000000009

int N;
map<LL, int> M;

int main() {
#ifdef OJ
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    std::ios_base::sync_with_stdio(false);

    scanf("%d", &N);
    LL cur = 0;
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);

        cur += a;
        M[cur]++;
    }

    LL ans = 0;
    for (map<LL, int>::iterator it = M.begin(); it != M.end(); ++it) {
        LL v = it->first;
        LL c = it->second;

        ans += 1LL * c * (c-1) / 2;
        if (v == 0) {
            ans += c;
        }
    }

    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   if(n==1){
       puts("Hello World");
   }
   else {
       ll a,b;cin >>a>>b;
       cout <<a+b<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[301];
double dp[301][301][301];
int n;
double f(int x,int y,int z)
{
  if(x==0 && y==0 && z==0) return 0.0;
  if(x<0 || y<0 || z<0) return 0.0;
  if(dp[x][y][z] != -1) return dp[x][y][z];
  double ans =  (double)(n+x*f(x-1,y,z) + y*f(x+1,y-1,z) + z*f(x,y+1,z-1))/(x+y+z);
  dp[x][y][z] = ans;
  return ans;
}



int main() {
  cin>>n;
  for(int i=0;i<301;i++)
  {
    for(int j=0;j<301;j++)
    {
      for(int k=0;k<301;k++)
      {
        dp[i][j][k] = -1;
      }
    }
  }
  int x=0,y=0,z=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i] == 1) x++;
    else if(a[i] == 2) y++;
    else if(a[i] == 3) z++;
  } 
  cout<<fixed<<setprecision(10)<<f(x,y,z)<<endl;
  return 0;
}

Measured memory_bytes: 213376
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])

bl = False
for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M] == B).all():
      bl = True

answer = 'Yes' if bl else 'No'
print(answer)


Measured memory_bytes: 12440
N = int(input())
X = list(map(int, input().split()))
ans1, ans2 = 0, 0
p1 = -(-sum(X)//N)
p2 = sum(X)//N

for i in range(N):
    ans1 += abs((X[i]-p1)**2)
    ans2 += abs((X[i]-p2)**2)
print(min(ans1, ans2))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
const int MOD = 1000000007;
using mint = ModInt<MOD>;

const int MAX = 2000100;
long long fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  rep(i, min(k+1, n)) {
    mint res = 1;
    int rem = n-i;
    res *= comb(n, i);
    res *= comb(i+rem-1, i);
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

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

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N,D;

int main()
{
    cin >> N >> D;
    int d = D*2+1;
    int ans = (N%d)?N/d+1:N/d;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N, M, X = map(int, input().split())
    a = np.array([list(map(int, input().split())) for i in range(N)], dtype=int)

    ans = int(1e15)
    for i in range(2**N):
        tmp = np.zeros(M+1, dtype=int)
        for j in range(N):
            if i&1:
                tmp += a[j]
            i >>= 1
        if np.all(tmp[1:] >= X):
            ans = min(ans, tmp[0])
    
    if ans > int(1e9):
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27328
#include<stdio.h>
int main(){
  int n,a,b,i,c;
  while(scanf("%d %d %d",&n,&a,&b),n||a||b){
    char d[2000000]={1};
    for(i=c=0;i<=n;i++){
      if(d[i])d[i+a]=d[i+b]=1;
      else    c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;


int main() {

	int A[3];

	scanf("%d %d %d",&A[0],&A[1],&A[2]);

	sort(A,A+3);

	int ans=0;

	while(1){

		if(A[0]==A[1]&&A[1]==A[2]){break;}
		if(A[1]<A[2]){
			A[0]++;
			A[1]++;
			ans++;
		}
		else{
			while(1){
				if(A[0]>=A[2]){break;}
				A[0]+=2;
				ans++;
			}
			if(A[0]>A[2]){
			A[1]++;
			A[2]++;
			ans++;
			}
		}

	}

	printf("%d\n",ans);

	return 0;
}

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

using namespace std;
typedef long long ll;
const int N=2e5+10;

int mp[N];

int a[N];
int c[15];


int Time[N];

int main()
{

    memset(mp,0,sizeof(mp));
    int n;
    ll k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    int pos=1;
    int cou=1;
    int x;
    int start;
    int startpos;
    if(k<n+10){
        int ans=1;
        while(k--){
            ans=a[ans];
        }
        cout<<ans<<endl;
        return 0;
    }

    while(1){
        if(Time[pos]>0){
            x=cou-Time[pos];
            start=Time[pos]-1;
            startpos=pos;
            break;
        }
        //cout<<pos<<endl;
        Time[pos]=cou;
        pos=a[pos];
        cou++;
    }
    //cout<<x<<endl;
    //cout<<startpos<<endl;
    if(k>start){
        k-=start;
        k%=x;
        int ans=startpos;
        //cout<<k<<endl;
        while(k--){

           ans=a[ans];
        }
        cout<<ans<<endl;
    }
    else{
        int ans=1;
        while(k--){
            ans=a[ans];
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 5968
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static char c;

	public static void main(String[] args) throws Exception {
		int k = sc.nextInt();
		int[] arr = new int[k];
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		int maxIdx = -1;
		int minIdx = -1;
		for (int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextInt();
			if (arr[i] > max) {
				max = arr[i];
				maxIdx = i;
			}
			if (arr[i] < min) {
				min = arr[i];
				minIdx = i;
			}
		}
		System.out.println(k*2-1);
		if(Math.abs(min)>max){
			for(int i=0;i<k;i++){
				System.out.println((minIdx+1)+" "+(i+1));
			}
			for(int i=k;i>1;i--){
				System.out.println(i+" "+(i-1));
			}
		}
		else{
			for(int i=0;i<k;i++){
				System.out.println((maxIdx+1)+" "+(i+1));
			}
			for(int i=1;i<k;i++){
				System.out.println(i+" "+(i+1));
			}
		}

	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int c[200005];
vector<int> G[200005];
ll ans[200005];
ll cnt[200005];
ll val[200005];
ll all=0;

int dfs(int v,int p){
	int su=1;
	ll tmp=val[c[v]];
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(nv==p)continue;
		ll prv=all-val[c[v]];
		su+=dfs(nv,v);
		ll nxt=all-val[c[v]];
		ans[c[v]]-=(nxt-prv)*(nxt-prv-1)/2LL;
	}
	all++;
	val[c[v]]=tmp+su;
	return (cnt[v]=su);
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&c[i]);
		c[i]--;
	}
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		ans[i]=(ll)n*(n-1)/2LL;
	}
	dfs(0,-1);
	for(int i=0;i<n;i++){
		ll prv=0,nxt=n-val[i];
		ans[i]-=(nxt-prv)*(nxt-prv-1)/2LL;
	}
	for(int i=0;i<n;i++){
		ans[c[i]]++;
	}
	for(int i=0;i<n;i++){
		printf("%lld\n",ans[i]);
	}
	return 0;
}


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

bool binary_search(int A[], int n, int key) {
  int left = 0, right = n, center;

  while (left < right) {
    center = (left + right) / 2;
    if (A[center] == key) return true;
    else if (A[center] > key) right = center;
    else left = center + 1;
  }
  return false;
}

int main() {
  int i, n, q, C = 0, S[100000], T[50000];

  cin >> n;
  for (i = 0; i < n; i++) cin >> S[i];
  cin >> q;
  for (i = 0; i < q; i++) cin >> T[i];

  // search
  for (i = 0; i < q; i++) C += binary_search(S, n, T[i]);

  cout << C << endl;
  
  return 0;
}



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

#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi (3.14159265358979323846264338327950288419716939937510)
#define fo(i, n) for(int i = 0; i < n; ++i)
#define ro(i, n) for(int i = n - 1; i >= 0; --i)
#define fill(x, y) memset(x, y, sizeof(x))


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef double D;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

int main() {
    int x, y;
    cin >> x >> y;
    if (x % y) cout << x << endl;
    else cout << -1 << endl;
    re 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ss := strings.Split(sc.Text(), "")

	ct := 0
	max := 0
	for _, s := range ss {
		if s == "R" {
			ct++
			if max < ct {
				max = ct
			}
		} else {
			ct = 0
		}
	}
	fmt.Println(max)
}


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

using namespace std;

int bingo(vector<vector<int> > A, vector<int> b, int N){
    int flag = 0;
    vector<vector<int> >atari ;
    atari.resize(3);
    for ( int i = 0 ; i < 3; i++){
        atari[i].resize(3);
    }
    for(int i = 0; i < 3; i++){
        for(int k = 0; k < 3; k++){
            for(int l = 0; l < N; l++){
                if (A[i][k] == b[l]){
                    atari[i][k] = 1;
                }
            }
        }
    }

    int line = 0;
    for(int i = 0;i < 3; i++ ){
        for(int k = 0; k < 3 ; k++){
            if (atari[i][k] == 0){
                line++;
                break;
            }
        }
    }
    for(int i = 0;i < 3; i++ ){
        for(int k = 0; k < 3 ; k++){
            if (atari[k][i] == 0){
                line++;
                break;
            }
        }
    }
    
    for(int i = 0;i < 3; i++ ){
        if(atari[i][i] == 0) {
            line++;
            break;
        }          
    }
    for(int i = 0;i < 3; i++){
        if(atari[2-i][i] == 0) {
            line++;
            break;
        }
    }

    if (line < 8){flag = 1;}

    return flag;

}

int main(){

    vector<vector<int> > A;
    A.resize(3);
    for ( int i = 0 ; i < 3; i++){
        A[i].resize(3);
    }

    for(int i = 0; i < 3; i++){
        for(int k = 0; k < 3; k++){
            cin >> A[i][k];
        }
    }

    int N;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++){
        cin >> b[i]; 
    }

    int ans = bingo(A,b,N);
    
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;

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


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

    int x, y, z; cin >> x >> y >> z;

    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	
	ll L, R,d,an=0;
	cin >> L >> R>>d;
	for (ll i = L; i <= R; i++) {
		if (i % d == 0)an++;
	}
	cout << an << endl;
	
}



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

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

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  string o,e;
  cin >> o >> e;
  REP(i,e.size()){
    cout << o[i] << e[i];
  }
  if(o.size()-e.size()>0){
    cout << o[o.size()-1];
  }
  cout << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    ll ans=0;
    for(ll x=0;x<s.length();x++){
        ans+=s[x]!=t[x];
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3812
#include<iostream>
using namespace std;
int main(){
    int H,W,i,j;
    while (1){
        cin>>H>>W;
        if (H==0 && W==0) break;
        else{
           for (i=0;i<H;i++) {
               for (j=0;j<W;j++){
                   cout<<"#";
               }
               cout<<endl;
           }
           cout<<endl;
        }
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> C(9, 0);
    REP(i, N){
        ll a;
        cin >> a;
        
        if(a < 400){
            C[0]++;
            continue;
        }
        if(a < 800){
            C[1]++;
            continue;
        }
        if(a < 1200){
            C[2]++;
            continue;
        }
        if(a < 1600){
            C[3]++;
            continue;
        }
        if(a < 2000){
            C[4]++;
            continue;
        }
        if(a < 2400){
            C[5]++;
            continue;
        }
        if(a < 2800){
            C[6]++;
            continue;
        }
        if(a < 3200){
            C[7]++;
            continue;
        }
        if(a >= 3200){
            C[8]++;
            continue;
        }
    }
    ll min_ans = 0;
    ll max_ans = 0;
    REP(i, 8){
        if(C[i] > 0) min_ans++;
    }
    if(min_ans == 0){
        cout << 1 << " " << min_ans + C[8] << endl;
        return 0;
    }

    cout << min_ans << " " << min_ans + C[8] << endl;

    return 0;
}

Measured memory_bytes: 256
read*,in,iy
  do i=0,in
     do j=0,in-i
        isum=10000*i+5000*j+1000*(in-i-j)
        if (isum==iy) then
           print*,i,j,in-i-j
           stop 
        end if
     end do
  end do
  print*,-1,-1,-1
end program


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
a = []
for i in range(q):
	b = input().split()
	b[0] = int(b[0]) - 1
	b[1] = int(b[1]) - 1
	a.append(b)
counter = [0]
for i in range(1,len(s)):
	if s[i - 1] == "A" and s[i] == "C":
		counter.append(counter[i - 1] + 1)
	else:
		counter.append(counter[i - 1])

result = 0
for i in range(q):
	num = counter[a[i][1]] - counter[a[i][0]]
	result += num
	print(num)

Measured memory_bytes: 30660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b) cout<<c<<endl;
	else if(b==c) cout<<a<<endl;
	else if(a==c) cout<<b<<endl;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <tgmath.h>
#include <queue>
#include <cstring>
#include <map>
#include <set>
typedef long long ll;
using namespace std;


struct edge{
    int to;
    int cost;
};
int N;

vector<vector<edge>> edges;
vector<int> ans;


void dfs(int v, int color){
    // cout << "v=" << v<< "color=" << color<<endl;
    ans[v] = color;
    for(int i=0;i<edges[v].size();i++){
        edge a = edges[v][i];
        int to = edges[v][i].to;
        int cost = edges[v][i].cost;
    if(ans[to] != -1){
            continue;
        }
        dfs(to,(ans[v]+cost)%2);
    }
}

int main(){
    cin >> N;
    int a,b,c;
    edges.resize(N);

    for(int i=0;i<N-1;i++){
        cin >> a>>b>>c;
        a--;
        b--;
        edges[a].push_back({b,c});
        edges[b].push_back({a,c});
    }
    ans.resize(N,-1);
    dfs(0,0);
    for(int i=0;i<N;i++){
        cout << ans[i] << "\n";
    }

    
    
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

int main(){
	int a,b;

	cin>>a>>b;
	
	if(a%3==0||b%3==0||(a+b)%3==0){
		cout<<"Possible"<<endl;
		return 0;
	}

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


Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun a b c ->
    let arr = [| a; b; c |] in
    Array.sort compare arr;
    let a, b, c = arr.(0), arr.(1), arr.(2) in

    let ac = c - a in
    let bc = c - b in

    Printf.printf "%d\n" @@ (ac + bc + ((ac + bc) mod 2) * 3) / 2
)

Measured memory_bytes: 384
n = int(input())

l = []


def dfs(num: list, nset: set, depth: int):
    global l
    if depth == 0:
        #print(num, nset, depth)
        if "3" in nset and "5" in nset and "7" in nset:
            l.append(int("".join(num)))
    else:
        for c in ["3", "5", "7"]:
            _num = num.copy()
            _nset = nset.copy()
            _num.append(c)
            _nset.add(c)
            dfs(_num, _nset, depth-1)

for i in range(3,11):
    dfs([], set(), i)

ans = 0

for i in range(len(l)):
    if n >= l[i]:
        ans += 1

print(ans)

Measured memory_bytes: 12204
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   var [r0, w0, c, r] = arr.shift().split(" ").map(Number);
   if (r0 + w0 + c + r == 0) break;
   var cnt = 0;
   while (true) {
      if (r0 / w0 >= c) {
         console.log(cnt);
         break;
      }
      cnt++;
      r0 += r;
   }
}


Measured memory_bytes: 16680
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#import numpy as np
#n = int(input())
n, x, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))


li = [0]*(m+1)
a = []
p = x
a.append(x)
li[x] = 1
for i in range(m):
    p *= p
    p %= m
    if li[p] == 0:
        li[p] = 1
        a.append(p)
    else:
        d = p
        break

b = a.index(d)
bef = sum(a[:b])
afe = sum(a[b:])
loop = len(a) - b
c = n - b

f = c // loop
g = c % loop
rest = sum(a[b:b + g])

ans = bef + afe * f + rest
print(ans)
        
    
    
    


        


Measured memory_bytes: 13108
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
typedef unsigned long long int ull;
typedef long long int ll;

int main()
{
   string s,t;
   cin>>s>>t;
   int cnt=0;
   for(int i=0;i<s.size();i++)
   {
       if(s[i]!=t[i])
        cnt++;
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 3844
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

// ?????????????????????????????????
void TopologicalSort(const vector<vi>& G, vi& order, int& flag) {
	int n = G.size();
	vector<int> degree(n);
	for (int v = 0; v < n; v++) {
		for (int u : G[v]) 
			degree[u]++;
	}
	flag = 0;
	queue<int> que;
	for (int i = 0; i < n; i++) {
		if (degree[i] == 0) {
			que.push(i);
		}
	}
	while (!que.empty()) {
		flag |= (que.size() > 1);
		int now = que.front(); que.pop();
		order.push_back(now);
		for (int ch : G[now]) {
			if (degree[ch] == 0) continue;
			if (--degree[ch] == 0) {
				degree[ch] = 0;
				que.push(ch);
			}
		}
	}
	reverse(order.begin(), order.end());
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vi> G(n);
    for (int i = 0; i < m; i++) {
    	int a, b;
    	cin >> a >> b;
    	a--; b--;
    	G[b].push_back(a);
    }
    vi order;
    int flag = 0;
    TopologicalSort(G, order, flag);
    for (int i = 0; i < n; i++) 
    	cout << order[i]+1 << endl;
    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  ll m = 0;
  rep(i,0,n) {
    ll a;
    cin >> a;
    if (i == 0) {
      m = a;
      continue;
    }
    if (m > a) {
      ans += m-a;
    }
    m = max(m,a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

/*??°?????????*/
void swap(int& x, int& y) {
	int temp = x;
	x = y;
	y = temp;
}

int main(void) {
	int N, a[100], i, j, k=0;
	/*printf("??´??°?????\????????????????????????");*/
	scanf("%d", &N);
	/*printf("%d??????????´??????\????????????????????????",N);*/
	for (i = 0; i < N; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < N; i++) {
		for (j = N - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				k++;
			}
		}
	}
	for (i = 0; i < N; i++)
		printf("%d%s", a[i], i < N-1 ? " " : "\n");
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 2696
/*
ID:greenty2
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b>=10)
	{
		cout<<"error"<<endl;
	}
	else
	{
		cout<<a+b<<endl;
	}
}

Measured memory_bytes: 256
X = gets.to_i

puts 1 if (X == 1 || X == 2 || X == 3)

X.downto(0).each do |i|
  1.upto(i).each do |b|
    2.upto(i/b).each do |p|
        if b ** p == i
          puts i
          exit
        elsif b ** p > i
          next
        end
    end
  end
end


Measured memory_bytes: 1916
//2014
#include<iostream>
using namespace std;
int main(void){
	int h,w,i,j,cnt=0;
	bool a=false;
	cin>>h>>w;
	char str[100][100]={};
	int num[100][100]={-1};
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>str[i][j];
			if(str[i][j]=='c'){
				num[i][j]=0;
				a=true;
				cnt=0;
			}
			else if(str[i][j]=='.'&&a==true){
				cnt++;
				num[i][j]=cnt;
			}
			else{
				num[i][j]=-1;
			}
		}
		a=false;
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(j==w-1){
				cout<<num[i][j];
			}
			else{
				cout<<num[i][j]<<" ";
			}
		}
		cout<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long ll;

const int MOD = 1000000007;

int cal(int n) {
  ll ans = 1;
  for (int i = 1; i <= n; i++) 
    ans = (ans * i) % MOD;
  return ans;
}

int main()
{
  int n, m;
  cin >> n >> m;
  if (abs(n-m) > 1)
    cout << "0" << endl;
  else {
    int a = min(n, m);
    int b = max(n, m);
    ll ans;
    if (a == b) 
      ans=((ll)2*(((ll)cal(a)*cal(b))%MOD)%MOD)%MOD;
    else
      ans = ((ll)cal(a) * cal(b)) % MOD;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#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<<"Balanced " ;}
else if(a+b>c+d){cout<< "Left " ;}
else if(c+d>a+b){cout<< "Right " ;}


	return 0 ;

	}


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

using namespace std;

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

const int N = 1e5 + 5;

int n,ans,a[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i];

  for (int i = 1 ; i <= n ; i++) {
    ans++;
    if (i == n) break;
    int t1 = i + 1,t2 = i + 1;
    if (a[i] >= a[i + 1])
      while (t1 < n && a[t1 + 1] <= a[t1])
        t1++;
    if (a[i] <= a[i + 1])
      while (t2 < n && a[t2 + 1] >= a[t2])
        t2++;
    i = max(t1,t2);
  }

  cout << ans << endl;

}

Measured memory_bytes: 640