akhauriyash/Code-Regression huggingface dataset:
/*
 * zyrch - Rupanshu Yadav
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) 

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 1e18;
//=========================CODE STARTS HERE=============================//


int main() {
	
	ll n, a, b;
	cin >> n >> a >> b;
	
	cout << n/(a + b) * a + min(n % (a + b), a) << endl;
	return 0; 
}


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

int main()
{
    int A,B,i,ans=0,p,q,r,s;
    cin >> A >> B;
    for(i=A;i<=B;i++){
        p=i%10;
        q=(i/10)%10;
        r=(i/1000)%10;
        s=(i/10000)%10;
        if(p==s&&q==r){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int a[110];
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) scanf ("%d", &a[i]);
	int t = 0;
	for (int i = 1; i <= n; i++) if (a[i] == a[i - 1]) t++, a[i] = -1;
	printf ("%d\n", t);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
rest = sorted(s)
parent = [rest.pop()]

for _ in range(n):
    next_parent = []
    next_rest = []
    for i in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < i:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest += next_rest
    rest.sort()

if len(parent) == 2**n:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 34404
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll dp[100008][2];
//jは余裕がある

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	dp[0][0]=1;
	rep(i,n){
		rep(j,2){
			rep(k,2){
				rep(l,2){
					if((j==1&&k==1)||!l&&s[i]-'0'<j+k)continue;
					dp[i+1][l|(s[i]-'0'>j+k)]+=dp[i][l];
					dp[i+1][l|(s[i]-'0'>j+k)]%=MOD;
				}
			}
		}
	}
	cout<<(dp[n][0]+dp[n][1])%MOD<<endl;

}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,A=26;
  scanf("%d",&D);
  vector<int> C(A);
  for(int i=0;i<A;i++){
    scanf("%d",&C[i]);
  }
  vector<vector<int>> S(D,vector<int>(A));
  for(int i=0;i<D;i++){
    for(int j=0;j<A;j++){
      scanf("%d",&S[i][j]);
    }
  }
  vector<int> X(A,0);
  vector<int> XX(A,0);
  vector<vector<pair<int,int>>> Q(D,vector<pair<int,int>>(A));
  for(int i=0;i<D;i++){
    for(int j=0;j<A;j++){
      X[j]+=C[j];
      XX[j]+=X[j];
      Q[i][j]=make_pair(-S[i][j]-X[j],j);
    }
    sort(Q[i].begin(),Q[i].end());
    XX[Q[i][0].second]-=X[Q[i][0].second];
    X[Q[i][0].second]=0;
  }
  vector<vector<int>> P(D,vector<int>(A));
  for(int i=0;i<D;i++){
    for(int j=0;j<A;j++){
      P[i][j]=Q[i][j].second;
    }
  }
  int SC=0,SC2;
  for(int i=0;i<D;i++){
    SC+=S[i][P[i][0]];
  }
  vector<int> Y;
  vector<int> YY;
  int Z;
  int SX,SY;
  int z=-1;
  for(int l=0;l<123;l++){
    for(int k=0;k<25;k++){
      while(k==z){
        k=rand()%25;
      }
      z=k;
      for(int i=0;i<D;i++){
        SC2=SC;
        YY=XX;
        Y=X;
        SC2-=S[i][P[i][0]];
        SC2+=S[i][P[i][k+1]];
        for(int j=0;j<A;j++){
          Y[j]=0;
        }
        YY[P[i][0]]=0;
        YY[P[i][k+1]]=0;
        for(int j=0;j<D;j++){
          if(i==j){
            Z=P[j][k+1];
          }else{
            Z=P[j][0];
          }
          Y[P[i][0]]+=C[P[i][0]];
          Y[P[i][k+1]]+=C[P[i][k+1]];
          Y[Z]=0;
          YY[P[i][0]]+=Y[P[i][0]];
          YY[P[i][k+1]]+=Y[P[i][k+1]];
        }
        SX=0;
        SY=0;
        for(int j=0;j<A;j++){
          SX+=XX[j];
          SY+=YY[j];
        }if((SC2-SY+(rand()%200))>(SC-SX)){
          P[i].insert(P[i].begin(),P[i][k+1]);
          P[i].erase(P[i].begin()+k+2,P[i].begin()+k+3);
          XX=YY;
          SC=SC2;
        }
      }
    }
  }
  /*
  int uku=0;
  for(int i=0;i<A;i++){
    X[i]=0;
  }
  for(int i=0;i<D;i++){
    uku+=S[i][P[i][0]];
    for(int j=0;j<A;j++){
      X[j]+=C[j];
    }
    X[P[i][0]]=0;
    SX=0;
    for(int i=0;i<A;i++){
      SX+=X[i];
    }
    uku-=SX;
  }
  cout<<uku<<endl;
  */
  for(int i=0;i<D;i++){
    cout<<P[i][0]+1<<"\n";
  }
}

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

int main(){

    int n;
    cin >> n;
    ll ans = LONG_MAX;
    vector<int> x;
    rep(i,n){
        int a;
        cin >> a;
        x.push_back(a);
    }
    sort(x.begin(),x.end());
    
    rep(j,100){

        ll tmp = 0;
        rep(i,n){
            tmp += (j+1-x[i])*(j+1-x[i]);
        }

        ans = min(ans,tmp);
    }

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n) for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
using pii = pair<int, int>;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n, vector<int>());
    vector<vector<int>> y(n, vector<int>());
    rep(i, n)
    {
        cin >> a[i];
        rep(j, a[i])
        {
            int xij, yij; cin >> xij >> yij;
            x[i].push_back(xij - 1); y[i].push_back(yij);
        }
    }
    int maxhon = 0;
    bitrep(t, n)
    {
        set<int> s;
        bitset<15> bs(t);
        bool inconsistent = false;
        rep(i, n)
        {
            if (bs[i] == 1)
            {
                s.insert(i);
                rep(j, a[i])
                {
                    if (y[i][j] == 1)
                    {
                        if (bs[x[i][j]] == 1)
                        {
                            s.insert(x[i][j]);
                        }
                        else
                        {
                            s.clear();
                            inconsistent = true;
                            break;
                        }
                    }
                    else
                    {
                        if (bs[x[i][j]] == 1)
                        {
                            s.clear();
                            inconsistent = true;
                            break;
                        }
                    }
                }
            }
            if (inconsistent) break;
        }
        maxhon = max((int)s.size(), maxhon);
    }
    cout << maxhon << endl;
}

Measured memory_bytes: 3596
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 21-Jun-2020 18:32:38
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    int n; Int(n);
    vector<int> a(n);
    int xr = 0;
    for (int &x : a) {
        Int(x);
        xr ^= x;
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            putchar(' ');
        }
        printf("%d", xr ^ a[i]);
    }

    printf("\n");

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3888
#include<stdio.h>
int main(void){
	double x1,y1;
	double x2,y2;
	double x3,y3;
	double xp,yp;
	double a,b,c;
	int count = 0;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp) != EOF){
		a = ((yp - y1) * x3 - (yp - y1) * x1 - (xp -x1) * y3 + (xp -x1) * y1) / ((xp - x1) * y2 - (xp - x1) * y3 - (yp - y1) * x2 + (yp - y1) * x3);
		b = 1 - a;
		c = (xp - x1) / (a * (x2 - x1) + b * (x3 - x1));
		if(1 >= a && a >= 0){
			count++;
		}
		if(1 >= b && b >= 0){
			count++;
		}
		if(1 >= c && c >= 0){
			count++;
		}
		if(count == 3){
			printf("YES\n");
			count = 0;
		}
		else{
			printf("NO\n");
			count = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 612
import numpy as np

N, M, C = map(int, input().split())
b = input().split()
a = [input().split() for i in range(N)]

b_arr = np.asarray(list(b), int)
a_arr = np.asarray(list(a), int)
counter = 0

for i in range(N):
    if np.sum(b_arr * a_arr[i]) > -C:
        counter += 1

print(counter)


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

int main()
{
    int N,K;
    char S[51];
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> S[i];
    K--;
    if(S[K] == 'A') S[K] = 'a';
    else if(S[K] == 'B') S[K] = 'b';
    else if(S[K] == 'C') S[K] = 'c';
    for(int i = 0; i < N; i++) cout << S[i];
    return 0;
}


Measured memory_bytes: 256
W,a,b = map(int,input().split())
if b>a :
    if (W+a)>=b :
        print(0)
    elif b>(W+a) :
        print(b-(W+a))
elif a==b :
    print(0)
else :
    if (W+b)>=a :
        print(0)
    elif a>(W+b) :
        print(a-(W+b))

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

#define N 1000500
#define int long long

int lpf[N], mobius[N];
void least_prime_factor()
{
    for (int i = 2; i < N; i++)
        if (!lpf[i])
            for (int j = i; j < N; j += i)
                if (!lpf[j])
                    lpf[j] = i;
}
void Mobius()
{
    for (int i = 1; i < N; i++) {
        if (i == 1)
            mobius[i] = 1;
        else {
            if (lpf[i / lpf[i]] == lpf[i])
                mobius[i] = 0;
            else
                mobius[i] = -1 * mobius[i / lpf[i]];
        }
    }
}
int gcd_pairs(int a[], int n)
{
    int maxi = 0;
    int fre[N] = { 0 };
    for (int i = 0; i < n; i++) {
        fre[a[i]]++;
        maxi = max(a[i], maxi);
    }

    least_prime_factor();
    Mobius();
    int ans = 0;
    for (int i = 1; i <= maxi; i++) {
        if (!mobius[i])
            continue;

        int temp = 0;
        for (int j = i; j <= maxi; j += i)
            temp += fre[j];

        ans += temp * (temp - 1) / 2 * mobius[i];
    }
    return ans;
}
int32_t main()
{
    int n; cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int num = gcd_pairs(arr, n);
    if(num == n*(n - 1)/2){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int s = __gcd(arr[0], arr[1]);
    for(int i = 2; i < n; i++){
        s = __gcd(s, arr[i]);
    }
    if(s == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 34884
#include<bits/stdc++.h>
using namespace std;
int n;
deque<int>que;
signed main() {
	cin>>n;
	for(int i=1;i<=n;++i){
		int x;cin>>x;
		if(i&1)que.push_front(x);
		else que.push_back(x);
	}
	while(!que.empty())
		if(n&1)cout<<que.front()<<" ",que.pop_front();
		else cout<<que.back()<<" ",que.pop_back();
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main(){
	int w,h,a;
	while(1){
	cin>>h>>w;
	a=w;
	if(h==0&&w==0){
		break;
	}
	for(;h>0;h--){	
		for(w=a;w>0;w--){
			cout<<'#';
		}
		cout<<endl;
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n;
	 while(cin>>n)
	 {  int maxx=n/4;
	 int maxy=n/7;
	 int flag=0;
	   if(n<4)
	   {
	   	 printf("No\n");
	   	 continue;
	   }
	 	 for(int i=0;i<=maxx;i++)
	 	   {
	 	   	  for(int j=0;j<=maxy;j++)
	 	   	  {
	 	   	  	 if(i*4+j*7==n)
	 	   	  	   {
	 	   	  	   	 flag=1;
	 	   	  	   	 break;
						 }
				  }
				  if(flag)break;
			}
			if(flag)printf("Yes\n");
			else printf("No\n");
	 }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define sz(obj) ((int)(obj).size())
#define pf push_front
#define pb push_back

int main()
{
  int a[101] = {0}, n, m = 0;
  while (cin >> n){
    a[n]++;
  }
  REP(i, 101) m = max(m, a[i]);
  REP(i, 101) if (a[i] == m) cout << i << endl;
}

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

int main() {
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length()-1;i++){
        if(s[i]!=s[i+1])count++;
    }
    cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 **/

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y) {
        x=root(x), y=root(y);
        if (x!=y) {
            if (data[y]<data[x]) {
                swap(x, y);
            }
            data[x]+=data[y], data[y]=x;
        }
        return x!=y;
    }

    bool find(int x, int y) {
        return root(x)==root(y);
    }

    int root(int x) {
        return data[x]<0 ? x : data[x]=root(data[x]);
    }

    int size(int x) {
        return -data[root(x)];
    }
};


int main(){
    int n,q,ans=0;
    scanf("%d %d",&n,&q);
    UnionFind uf(n);
    for (int i=0;i<q;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        uf.unite(a-1,b-1);
    }
    set<int> s;
    for (int i=0;i<n;i++) {
        s.insert(uf.root(i));
        //printf("%d\n",uf.root(i));

    }
    printf("%ld\n",s.size()-1);
    return 0;
}

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

int main(){
  int year, month, day;
  char c1, c2;
  cin >> year >> c1 >> month >> c2 >> day;
  
  if (month <= 4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int n = scanInt();
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < n; i++) {
            String s = scanString();
            if (!set.contains(s)) set.add(s);
        }
        out.print(set.size());
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 72124
using System;

namespace ABC060_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var A = num[0];
            var B = num[1];
            var C = num[2];
            for (var i = 0; i <= B; i++)
            {
                if ((A * i) % B == C)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn count(row: &Vec<usize>, column: &Vec<usize>, grid: &Vec<Vec<char>>) -> u64 {
    let mut sum = 0;
    let h = grid.len();
    let w = grid[0].len();
    for i in 0..h {
        for j in 0..w {
            if (row.contains(&i) || column.contains(&j)) && grid[i][j] == '#' {
                sum += 1;
            }
        }
    }
    sum
}

fn main() {
    let (h, w, k) = input_tuple();
    let mut grid: Vec<Vec<char>> = Vec::new();
    let mut black = 0;
    for i in 0..h {
        let row = input_char_vec();
        grid.push(row);
    }
    for row in &grid {
        for c in row {
            if *c == '#' {
                black += 1;
            }
        }
    }
    // println!("black = {}", black);
    
    let mut ans = 0;
    for bit in 0..1 << h + w {
        let mut exclude_row: Vec<usize> = Vec::new();
        let mut exclude_column: Vec<usize> = Vec::new();
        for i in 0..h + w {
            if bit & (1<<i) != 0 {
                if i <h  {
                    exclude_row.push(i as usize);
                } else {
                    exclude_column.push(i as usize - h as usize);
                }
            }
        }

        // println!("{:?}, {:?}", exclude_row, exclude_column);
        let black_exclude = count(&exclude_row, &exclude_column, &grid);
        // println!("{}", black_exclude);
        if black - black_exclude == k {
            ans += 1;
        }
    }
    println!("{}", ans);
    
}


Measured memory_bytes: 2160
#include <iostream>
#include <set>
#include <string>
#define llint long long

using namespace std;

llint h, w, n;
llint x, y;
llint l, r, u, d;
string s, t;

int main(void)
{
	cin >> h >> w >> n;
	cin >> y >> x;
	cin >> s >> t;
	s = "#" + s, t = "#" + t;
	
	l = 1, r = w, u = 1, d = h;
	for(int i = n; i >= 1; i--){
		if(t[i] == 'L') r = min(w, r+1);
		if(t[i] == 'R') l = max(1LL, l-1);
		if(t[i] == 'U') d = min(h, d+1);
		if(t[i] == 'D') u = max(1LL, u-1);
		if(l > r || u > d){
			cout << "NO" << endl;
			return 0;
		}
		if(s[i] == 'L') l++;
		if(s[i] == 'R') r--;
		if(s[i] == 'U') u++;
		if(s[i] == 'D') d--;
		if(l > r || u > d){
			cout << "NO" << endl;
			return 0;
		}
	}
	if(x >= l && x <= r && y >= u && y <= d) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.ArrayList;

// main

public class Main {
  static class Foo {
    private int val;

    Foo(int a, int b) {
      val = a + b;
    }

    int getVal() { return val; }
  }

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line;

    while ((line = br.readLine()) != null) {
      String[] nums = line.split(" ");
      int a = Integer.parseInt(nums[0]);
      int b = Integer.parseInt(nums[1]);

      Foo foo = new Foo(a, b);
      System.out.println(foo.getVal());
    }
  }
}

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



Measured memory_bytes: 3076
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
k,c = 0,0
for i in range(int(ceil(2*N))+1):
    if i*(i+1)//2>=N:
        k = i
        c = k*(k+1)//2-N
        break

for i in range(1,k+1):
    if i != c:
        print(i)


Measured memory_bytes: 42584
#include <iostream>
#include <array>
#include <map>
#include <algorithm>

using ll = long long;
using namespace std;

inline int bsr32(uint32_t a) {
  int r;
  __asm__("bsrl %1, %0;" :"=r"(r) : "r"(a));
  return r;
}

int main() {
  string S;
  ll N = 0;
  array<ll, 200000> A;
  cin >> N;
  for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.begin() + N, greater<ll>());
  map<ll, int> M;
  for (ll i = 0; i < N; i++) M[A[i]] += 1;
  ll pair = 0;
  for (ll i = 0; i < N; i++) {
    ll a = A[i];
    if (M[a] == 0) continue;
    M[a] -= 1;
    ll opp;
    if (!(a & (a - 1))) {
      opp = a;
    } else {
      opp = (1 << (bsr32(a) + 1)) - a;
    }
    //cerr << a << "," << opp << endl;
    if (M.find(opp) != M.end() && M[opp] > 0) {
      pair += 1;
      M[opp] -= 1;
    }
  }
  cout << pair << endl;
}


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

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

  int b[n-1];
  for(int i = 0; i < n-1; i++){
    cin >> b[i];
  }

  int max = 0;
  for(int i = 0; i < n; i++){
    if(i == 0){
      max += b[i];
    }
    else if(i == n - 1){
      max += b[n - 2];
    }
    else{
      max += min(b[i], b[i-1]);
    }
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <set>
using namespace std;
int main()
{
	int N;
	cin >> N;
	std::string S;
	set<std::string> list;
	
	while(N--){
		cin >> S;
		list.insert(S);
	}
	
	cout << list.size() << endl;
	
	return 0;
}


Measured memory_bytes: 19164
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int64_t N;
  cin >> N;
  
  if(N == 0){
    cout << 2 << endl;
    return 0;
  }
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  vector<int64_t> Lyca(N + 1);
  Lyca.at(0) = 2;
  Lyca.at(1) = 1;
  for(int i = 2; i <= N; i++){
  	Lyca.at(i) = Lyca.at(i - 1) + Lyca.at(i - 2);
  }
  cout << Lyca.at(N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
const int N = 24;
bool grid[24][24];
long long n , mod = 1e9 + 7 , dp[24][1<<22];
int solve(int m, int w)
{
	if (m == n)
	{
		if (w == 0)
			return 1;
		return 0;
	}
	if (dp[m][w] != -1)
		return dp[m][w];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		bool okay = ((((1 << i) & w) == 0) ? 0 : 1);
		if (okay && grid[m][i])
			ans = (ans + solve(m + 1, (1 << i) ^ w)) % mod;
	}
	return dp[m][w] = ans;
}
int main(){
	cin>>n;
	for(int i=  0; i < n  ; i++)
		for(int j = 0; j < n ;j++)
			cin>>grid[i][j];
			
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,(1<<n)-1);
	return 0;
}  


Measured memory_bytes: 786688
#include<iostream>
#include<math.h>
#include<string.h>

using namespace std;

int main() {
	long int x;
	cin >> x;
	long int ans, ans2, x2;
	ans = x / 500;
	ans *= 1000;
	x2 = x % 500;
	ans2 = x2 / 5;
	ans2 *= 5;
	cout << ans + ans2 << endl;

	return 0;
}

Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    int len = str.length();
    int start = -1, end = -1;
    for (int i = 0; i < len - 1; i++) {
      if (str.charAt(i) == str.charAt(i + 1)) {
        start = i + 1;
        end = i + 2;
        break;
      }
      if (i + 2 < len && str.charAt(i) == str.charAt(i + 2)) {
        start = i + 1;
        end = i + 3;
        break;
      }
    }
    System.out.println(start + " " + end);
  }
}

Measured memory_bytes: 22612
n , k = int(input()), int(input())
res = 1 << 63

def getAns(now, step):
    global res
    if step == n:
        res = min(res, now)
    if step <= n and now < res:
        getAns(now + k, step + 1)
        getAns(now * 2, step + 1)
getAns(1, 0)
print(res)


Measured memory_bytes: 2940
N = int(input())
ls_L = list(map(int,input().split()))
ls_L.sort()
  
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a = ls_L[i]
            b = ls_L[j]
            c = ls_L[k]
            if c < a + b:
                if (a - b) * (b - c) * (c - a) != 0:
                    ans += 1
                    
print(ans) 

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1e9+7;
ll inv(ll);
ll power(ll x, ll n){
    if (n==0) return 1;
    if (n<0) return power(inv(x), -n);
    auto pow_harf = power(x, n/2);
    if (n%2==0) return (pow_harf * pow_harf) % MOD;
    return ((pow_harf * pow_harf) % MOD * x) % MOD;
}
ll inv(ll x){
    // フェルマーの小定理から x^(p-2) == x^(-1) (mod p)
    return power(x, MOD - 2);
}
auto fact(ll x){
    // 再帰だとスタックオーバーフローするので
    ll ret = 1;
    for(ll a=2; a<=x; ++a){
        ret = (ret * a) % MOD;
    }
    return ret;
}
/*
【解法】
A = [1, 2, ..., n] と固定する（求める場合の数は、固定した場合の数の mPn 倍）。B を長さ n の数列とする

ある集合 S \subset {1, ..., n} の上で値が一致する（そのほかにも一致する値のある可能性がある）ような B の場合の数は g(S) = (m-|S|)P(n-|S|) 通り
（まだ決まっていない n-|S| 箇所の値を、使っていない m-|S| 個の値から重複しないように決める）

ある集合 S \subset {1, ..., n} の上でちょうど値が一致する（ S に属さない点 i ではA[i] != B[i] となる）ような
B の場合の数を f(S) 通りとすると、g(S) = \sum_{S\subset T} f(T) となる。

F(S) = f({1, ..., n} \setminus S), G(S) = g({1, ..., n} \setminus S) とおくと、
G(S) = \sum_{T\subset S} F(S) なので、包除原理から F(S) = \sum_{T\subset S} (-1)^|S\setminus T| G(T) が成り立つ。

求めるのは f(\emptyset)
= F({1, ..., n})
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| G(T)
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| g({1, ..., n} \setminus T)
= \sum_{T\subset {1, ..., n}} (-1)^|T| g(T)
（ T -> T\setminus {1, ..., n} で置換）
ここで g は size の関数なので g(T) = g(|T|) とおくと、 k 元集合の選び方が nCk 通りなので 
= \sum_{k=0}^n (-1)^k nCk g(k)
= \sum_{k=0}^n (-1)^k n! / (n-k)! / k! * (m-k)! / (m-n)!
となる。

これを高速に計算する。 k == 0 のとき m! / (m-n)! で、

    n! (m-k)!             n! (m-(k-1))!          n-k+1
---------------- == ------------------------ * ---------
(n-k)! k! (m-n)!    (n-(k-1))! (k-1)! (m-n)!   (m-k+1) k

なので、 k がふえるたびに (n-k+1) / (m-k+1) / k 倍すればよい
*/
ll inv_table[500001] = {};
int main()
{
    ll n, m;
    cin >> n >> m;

    const ll mpn = fact(m) * inv(fact(m-n)) % MOD;
    ll tmp = mpn;
    ll sum = tmp;
    const ll sign[2] = {1, MOD-1};
    for(int k=1; k<=m; ++k)inv_table[k] = inv(k);
    for(int k=1; k<=n; ++k){
        tmp = ((tmp * inv_table[m-k+1]) % MOD * inv_table[k] % MOD) * (n-k+1) % MOD;
        sum = (sum + sign[k%2] * tmp) % MOD;
    }
    cout << (sum * mpn) % MOD;
    return 0;
}


Measured memory_bytes: 7504
#include<stdio.h>

int main(){
	int N = 0;
  	scanf("%d",&N);
  	int C = N % 10;
  	if(C == 2||C == 4||C == 5||C == 7||C == 9)
		printf("hon");
  	else if(C == 3)
		printf("bon");
  	else
      	printf("pon");
return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
ll c,d;
ll cnt(ll a){
    return a-(a/c+a/d-a/(c*d/gcd(c,d)));
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b >> c >> d;
    PRINT(cnt(b)-cnt(a-1));
}


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

int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> p(N);
    rep(i,N) cin >> p.at(i);
    
    vector<long double> s(N-K+1);
    s.at(0) = accumulate(p.begin(), p.begin()+K, 0.0);
    long double max = s.at(0);
    for(ll i = 1; i<N-K+1; i++){
        s.at(i) = s.at(i-1)-p.at(i-1)+p.at(i+K-1);
        if(s.at(i)>max) max = s.at(i);
    }

    cout << fixed << setprecision(10) << (long double)(max+K)/2 << endl;
    return 0;
}


Measured memory_bytes: 4992
fn main() {
    let n = read::<usize>();
    let v = read_vec::<i32>();

    println!("{}", solve(n, v));
}

fn solve(n: usize, v: Vec<i32>) -> i32 {
    let mut dp = vec![0; n];
    dp[1] = (v[0] - v[1]).abs();

    for i in 2..n {
        let n_1 = (v[i] - v[i-1]).abs() + dp[i-1];
        let n_2 = (v[i] - v[i-2]).abs() + dp[i-2];
        dp[i] = std::cmp::min(n_1, n_2);
    }

    dp[n-1]
}

#[test]
fn test1() {
    let n = 4;
    let v = vec![10, 30, 40, 20];
    assert_eq!(30, solve(n, v));
}

#[test]
fn test2() {
    let n = 2;
    let v = vec![10, 10];
    assert_eq!(0, solve(n, v));
}

#[test]
fn test3() {
    let n = 6;
    let v = vec![30, 10, 60, 10, 60, 50];
    assert_eq!(40, solve(n, v));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] & 1) cnt++;
    }
    if (cnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut a: Vec<i64> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let n: f64 = buf.trim_end().parse().unwrap();
        let mut s = format!("{:.9}", n);
        s.retain(|c| c!= '.');
        a.push(s.parse().unwrap())
    }

    let mut map = std::collections::HashMap::new();
    for i in 0..n {
        let (mut two, mut five) = (0, 0);
        while a[i] % 2 == 0 {
            two += 1;
            a[i] /= 2;
        }
        while a[i] % 5 == 0 {
            five += 1;
            a[i] /= 5;
        }
        *map.entry((two, five)).or_insert(0i64) += 1;
    }

    let mut ans = 0;
    for (key1, val1) in &map {
        for (key2, val2) in &map {
            if key1.0 + key2.0 < 18 || key1.1 + key2.1 < 18 {
                continue;
            }
            if key1 == key2 {
                ans += val1 * (val1 - 1) / 2;
            } else if key1 < key2 {
                ans += val1 * val2;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 3688
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,ok;

signed main()
{
    cin>>n;
    cout<<(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <bitset>
#include <algorithm>
  
using namespace std;
  
const double eps=1e-10;
const double pi=3.1415926535897932384626433832795;
const double eln=2.718281828459045235360287471352;
  
#define LL long long
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define scan(x) scanf("%d", &x)
#define scan2(x, y) scanf("%d%d", &x, &y)
#define scan3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sqr(x) (x) * (x)
#define pr(x) printf("Case %d: ",x)
#define prn(x) printf("Case %d:\n",x)
#define prr(x) printf("Case #%d: ",x)
#define prrn(x) printf("Case #%d:\n",x)
#define lowbit(x) (x&(-x))
 
const int maxn=100005;

vector<int> g[maxn],son[maxn];
LL x[maxn],y[maxn],z[maxn],a[maxn],o[maxn],ch[maxn];
int du[maxn];
int n,m;

void mt(int now,int fa)
{
    for(unsigned int t=0;t<g[now].size();t++)
    {
        int v=g[now][t];
        if(v==fa)continue;
        son[now].push_back(v);
        mt(v,now);
    }
}

bool cmp(LL p,LL q)
{
    return p>q;
}

void solve(int now)
{
    if(son[now].size()==0)
    {
        x[now]=o[now]=0;
        y[now]=a[now];
        z[now]=a[now];
        return;
    }
    LL ss=0,ma=0,tot=0;
    for(unsigned int t=0;t<son[now].size();t++)
    {
        solve(son[now][t]);
        ss+=x[son[now][t]];
        ma=max(ma,y[son[now][t]]);
        tot+=y[son[now][t]];
        z[now]+=z[son[now][t]];
    }
    LL temp=z[now]-2*ss;
    LL su=min(tot/2,tot-ma);
    x[now]=temp-a[now];
    o[now]=x[now];
    y[now]=a[now]-x[now];
    ch[now]=su-x[now];
    x[now]+=ss;
}

int main()
{   
    while(scanf("%d",&n)==1){
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    for(int i=0;i<=n;i++)
    {
        g[i].clear();
        son[i].clear();
        x[i]=y[i]=z[i]=o[i]=ch[i]=0;
        du[i]=0;
    }
    for(int i=1;i<=n-1;i++)
    {
        int p,q;
        scanf("%d%d",&p,&q);
        g[p].push_back(q);
        g[q].push_back(p);
        du[p]++;du[q]++;
    }
    if(n==2)
    {
        if(a[1]==a[2])printf("YES\n");else printf("NO\n");
        continue;
    }
    for(int i=1;i<=n;i++)
        if(du[i]>1){m=i;break;}
    mt(m,0);
    solve(m);
    bool f=true;
    for(int i=1;i<=n;i++)
        if(o[i]>a[i] || o[i]<0 || y[i]<0 || y[i]>a[i] || ch[i]<0){f=false;break;}
    if(y[m]!=0)f=false;
    if(f)printf("YES\n");else printf("NO\n");}
    return 0;
}



Measured memory_bytes: 22912
s = input()
n = len(s)
ans = [0]*n
cnt = [0,0]
inv = 0
for i in range(n):
    if s[i] == "R":
        cnt[inv] +=1
        inv = (inv+1)%2
    if s[i] =="L" and cnt!=[0,0]:
        ans[i-1] = cnt[(inv+1)%2]
        ans[i] = cnt[inv]
        cnt=[0,0]
        inv=0

cnt = [0,0]
inv = 0
for i in range(n-1,-1,-1):
    if s[i] == "L":
        cnt[inv] +=1
        inv = (inv+1)%2
    if s[i] =="R" and cnt!=[0,0]:
        ans[i+1] += cnt[(inv+1)%2]
        ans[i] += cnt[inv]
        cnt=[0,0]
        inv=0
print(*ans)


Measured memory_bytes: 6400
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    h,w = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]
    b = [list(map(int, input().split())) for _ in range(h)]
    c = [[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            c[i][j] = abs(a[i][j] -b[i][j])

    mid = 12800
    dp = [[0]*w for _ in range(h)]
    dp[0][0] = (1<<(mid+c[0][0])) | (1<<(mid-c[0][0]))
    for x in range(h):
        for y in range(w):
            for dx, dy in [[0, 1], [1, 0]]:
                nx = x + dx
                ny = y + dy
                if 0<=nx<h and 0<=ny<w:
                    dp[nx][ny] = dp[nx][ny] | (dp[x][y]<<c[nx][ny])
                    dp[nx][ny] = dp[nx][ny] | (dp[x][y]>>c[nx][ny])
    
    for i in range(mid+1):
        if (dp[-1][-1]>>i) & 1:
            res = mid - i

    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 20724
from collections import defaultdict
n, m = map(int, input().split())
city_dict = defaultdict(list)

for i in range(m):
    p, y = map(int, input().split())
    city_dict[p].append((i, y))

# print(city_dict)

result_list = []
for k, v in city_dict.items():
    v.sort(key=lambda x: x[1])
    mae = ("00000" + str(k))[-6:]
    # print(v)
    for i,tup in enumerate(v):
        ato= ("00000" + str(i+1))[-6:]
        result_list.append((tup[0], mae + ato))
result_list.sort(key=lambda x: x[0])

for i,j in result_list:
    print(j)

Measured memory_bytes: 53108
import sys
 
sys.setrecursionlimit(1000000)
n, m, *a = map(int, open(0).read().split())
dp = [1] + [-1] * n
dp[1] = 1
for i in a:
    dp[i] = 0
 
def count(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = (count(n - 1) + count(n - 2)) % (10**9 + 7)
    return dp[n]
 
 
print(count(n))

Measured memory_bytes: 91540
N = int(input())
A = [int(_) for _ in input().split()]

def p(n):
    x = 1
    for i in range(1, n + 1):
        x *= i
    return x

def comb(n, r):
    return p(n) // p(n - r) // p(r)

xs = sorted(A)

m1 = xs[-1]
m0 = m1 / 2

ys = sorted(xs, key=lambda x:abs(x-m0))
print(m1, ys[0])

Measured memory_bytes: 14052
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

// 各桁の和
template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main() {
  int x1,y1,x2,y2;cin>>x2>>y2>>x1>>y1;
  int x = x2 - x1;
  int y = y2 - y1;
  cout<<x2+y-x<<" "<<y2-x-y<<" ";
  cout<<x2 + y<<" "<<y2 - x<<endl;

  return 0;
} 

Measured memory_bytes: 768
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
	int N;
	int L;
	cin >> N >> L;
	priority_queue<string, vector<string>, greater<string>> pq;

	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		pq.push(s);
	}

	for (int i = 0; i < N; i++) {
		string s = pq.top();
		pq.pop();
		cout << s;
	}
	return 0;
}


Measured memory_bytes: 256
n = input()
d=len(n)
if d==1:
    print(n)
elif n[0]!="9":
    if n[1:]=="9"*(d-1):
         ans=int(n[0])+int(9*(d-1))
    else:
        ans=int(n[0])-1+int(9*(d-1))
    print(ans)
else:
    if n=="9"*d:
        print(9*d)
    else:
        print(9*(d-1) +8)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        int sum = 0;
        int max = 0;
        int min = 100000;
        for (int i = 0; i < n; ++i) {
            int a;
            cin >> a;
            sum += a;
            if (max < a) max = a;
            if (min > a) min = a;
        }
        sum -= min + max;
        cout << sum / (n - 2) << endl;
    }
}

Measured memory_bytes: 3072
n = int(input())
Xs = list(map(int, input().split()))

sum = 0
for i in range(len(Xs)):
    sum += Xs[i]
average = sum / n
surpls = sum % n

ans = 0
if surpls == 0:
    for i in range(len(Xs)):
        ans += (Xs[i]-int(average))**2
else:
    diff1 = 0
    diff2 = 0
    for i in range(len(Xs)):
        diff1 += (Xs[i]-int(average))**2
    for i in range(len(Xs)):
        diff2 += (Xs[i]-int(average)-1)**2
    if diff1 >= diff2:
        ans = diff2
    else:
        ans = diff1
print(ans)

Measured memory_bytes: 3064
n,m,c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0
n.times do |i|
  a = gets.split.map(&:to_i)
  sum = m.times.map{|i| a[i]*b[i]}.inject(:+) + c
  ans += 1 if sum > 0
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL A, B;
    string sB;
    cin >> A >> sB;
    B = (sB[0]-'0') * 100 +(sB[2]-'0') * 10 + (sB[3]-'0');

    LL ans = (A * B) / 100;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)

int main()
{
	long long int L, R;
	long long int ans = 1000000000000;

	scanf("%lld%lld", &L, &R);

	for (long long int i = L; i < R; i++)
	{
		for (long long int j = i + 1; j <= R; j++)
		{
			if ((i * j) % 2019 < ans)
				ans = (i * j) % 2019;

			if (ans == 0)
			{
				printf("0\n");
				return 0;
			}
		}
	}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  cout << x - (x / b * b) << endl;
}


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

int main (){
	int N,K;cin>>N>>K;
	int *h=new int[N];
	for(int i=0;i<N;i++)cin>>h[i];
	int ans=0;
	for(int i=0;i<N;i++){
		if(h[i]>=K)ans++;
	}
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640