akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

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

	int d = 0;
	int e = 0;
	
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				e = 500 * i + 100 * j + 50 * k;
				if (e == x) d++;
			}
		}
	}
	cout << d << endl;

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {

    int i;
    int x[9];
    int a, b, c;
    
    a = b = c = 0;

    for(i=0; i<=9; i++){
        scanf("%d", &x[i]);
    }
    
    for(i=0; i<=9; i++){
        if (x[i]>c){
            if(x[i]>b){
                if(x[i]>a){
                    c=b;
                    b=a;
                    a=x[i];}
                 else{
                     c=b;
                     b=x[i];}
            }
            else{
                c=x[i];}
        }
    }

    printf("%d\n",a);
    printf("%d\n",b);
    printf("%d\n",c);
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	string time;
	cin >> time;
	int y=stoi(time.substr(0,4));
	int m=stoi(time.substr(5,2));
	int d=stoi(time.substr(8,2));
	string result="TBD";
	if(m<3){
		result="Heisei";
	}else if(m==4){
		if(d<=30){
			result="Heisei";
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace	std;
int result,w,h;
int d1[4]={-1,0,1,0},d2[4]={0,1,0,-1};
string a[21];

void dfs(int x,int y){

  int i;

  result++;
  a[y][x]='#';
  for(i=0;i<4;i++) if(0<=y+d2[i] && y+d2[i]<h && 0<=x+d1[i] && x+d1[i]<w) if(a[y+d2[i]][x+d1[i]] == '.') dfs(x+d1[i],y+d2[i]);

}

int main(){

  int x1,y1,i,j;

  while(cin>>w>>h,w){

    result=0;
    for(i=0;i<h;i++) cin>>a[i];

    for(i=0;i<h;i++) for(j=0;j<w;j++) if(a[i][j] == '@'){
          x1=j;
          y1=i;
	}

    dfs(x1,y1);

    cout<<result<<endl;


  }

  return 0;

}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
#define int long long
long long read(){
    long long ret=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}
priority_queue<int >q;
vector<int > a[1000001];
int ans,n,m;
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		if(x>m){
			continue;
		}
		a[m-x+1].push_back(y);
	}int z;
	for(int i=1;i<=m;i++){
		for(int j=0;j<a[i].size();j++){
			q.push(-a[i][j]);
			ans+=a[i][j];
		}while(q.size()>i){
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27896
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define let const auto
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

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

   int D, X;

   int a[128];

   cin >> N >> D >> X;

   int cnt = 0;
   rep(i, N) {
      cin >> a[i];
      for (int k = 1; k <= D; k += a[i])
      {
         cnt++;
      }
   }

   outl(cnt+X);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char c[100005][10];
ll f[100005]= {0},ans[100005];
int main ()
{
    ll A,B,k=0,n,i,j,x;
    scanf("%lld",&n);
    for(i=0; i<n; i++)
    {
        scanf("%s",c[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<=9; j++)
        {
            if(c[i][j]>='m')
            {
                f[k]+=((ll)pow(13,c[i][j]-'m'+1));
            }
            else if(c[i][j]>='a')
            {

                f[k]+=((ll)pow(10,c[i][j]-'a'+1));
            }
        }//printf("%lld",f[k]);printf("\n");
        k++;
    }
    sort(f,f+k);
    x=0;
    for(i=0; i<k; i++)
    {
        //printf("%lld",f[i]);printf("\n");
        if(f[i]==f[i+1])
        {
            ans[x]++;
        }
        else
        {
            x++;
        }
    }
    ll an=0;
    for(i=0; i<x; i++)
    {
        //printf("%lld",ans[i]);printf("\n");
        if(ans[i])
            an+=(ans[i]+1)*ans[i]/2;
    }
    printf("%lld",an);
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  string s, t;
  cin >> s >> t;
  ll ans = 0;
  rep(i, 0, sz(s)){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3792
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n;
  cin>>n;
  set<string>s;
  while(n--)
  {
    string a;
    cin>> a;
    s.insert(a);
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 19088
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int pcnt(int x) {
    return __builtin_popcount(x);
}

int f(int x) {
    if(x == 0) return 0;
    return f(x%pcnt(x))+1;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> xvec(n, 0);
    for(int i = 0; i < n; ++i) xvec[i] = s[i] - '0';
    int pc = 0;
    for(int i = 0; i < n; ++i) pc += xvec[i];
    vector<int> ans(n, 0);
    for(int bit = 0; bit < 2; ++bit) {
        int npc = pc;
        if(bit == 0) npc++; else npc--;
        if(npc <= 0) continue;
        int res = 0;
        for(int i = 0; i < n; ++i) {
            res = (res*2)%npc;
            res += xvec[i];
        }
        int k = 1;
        for(int i = n-1; i >= 0; --i) {
            if(xvec[i] == bit) {
                int r = res;
                if(bit == 0) r = (r+k)%npc;
                else r = (r-k+npc)%npc;
                ans[i] = f(r)+1;
            }
            k = (k*2)%npc;
        }
    }

    for(int i = 0; i < n; ++i) cout << ans[i] << endl;
}

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

int64_t n,res=1e15,a[200005];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        a[i]+=a[i-1];
    for(int i=1;i<n;i++)
        res=min(res,abs(a[i]-(a[n]-a[i])));
    cout<<res;
}


Measured memory_bytes: 1792
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int N,A,B;
int dp[105][105][2];

bool solve(int a, int b, int who) {
	if (dp[a][b][who] != -1) return dp[a][b][who];
	int res;
	if(who==0) {
		res = 0;
		if( (a-1 != b) && (a-1 >= 1) ) res |= solve(a-1,b,1);
		if( (a+1 != b) && (a+1 <=N) ) res |= solve(a+1,b,1);
		return dp[a][b][who]=res;
	} else{
		res = 1;
		if( (b-1 != a) && (b-1) >=1 ) res &= solve(a,b-1,0);
		if( ((b+1)!=a) && (b+1 <=N) ) res &= solve(a,b-1,0);
		return dp[a][b][who]=res;
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> N >> A >> B;
	for(int i=0;i<105;++i) for(int j=0;j<105;++j) for(int k=0;k<2;++k) dp[i][j][k]=-1;
	dp[1][2][0] = dp[N][N-1][0] = 0;
	dp[2][1][1] = dp[N-1][N][1] = 1;
	auto res = solve(A,B,0);
	cout << (res?"Alice":"Borys") << endl;
}









Measured memory_bytes: 1920
S = input()
T = input()
lens = len(S)
lent = len(T)

DP = [[0]*(lent+1) for _ in range(lens+1)]

for i in range(1,lens+1):
    for j in range(1,lent+1):
        if S[i-1] == T[j-1]:
            DP[i][j] = max(DP[i][j],DP[i-1][j-1]+1)
        DP[i][j] = max(DP[i][j],DP[i][j-1])
        DP[i][j] = max(DP[i][j],DP[i-1][j])
ans = ""
i = lens
j = lent
while i > 0 and j > 0:
    if DP[i][j] == DP[i-1][j]:
        i -= 1
    elif DP[i][j] == DP[i][j-1]:
        j -= 1
    else:
        ans += S[i-1]
        i -= 1
        j -= 1
print(ans[::-1])


Measured memory_bytes: 113500
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  a=list(map(int,input().split()))
  b=sorted([abs(i) for i in a])
  cnt=0
  for i in a:
    if i<0:
      cnt+=1
  print(sum(b) if cnt%2==0 else sum(b)-2*b[0])
if __name__=='__main__':
  main()

Measured memory_bytes: 15180
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;

  cout << (a < b ? string(b, '0' + a) : string(a, '0' + b));
}
#endif


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

int x,y;
char s[233][233];
char Out[233][233];

int main(){
	std::cin >> x >> y;
	for(int i = 1; i <= x; i++) 
		for(int j = 1; j <= y; j++)
			std::cin >> s[i][j];
	
	for(int i = 1; i <= 2 * x; i++){
		for(int j = 1; j <= y; j++){
			std::cout << s[(i+1)/2][j];
		}
		std::cout << std::endl;
	}	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll f[1001];
ll dp1[1001],dp2[1001];
int mn[1001];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,K;
    cin >> a >> b >> K;
    vl t(K+1);
    rep(i,K+1){
        cin >> t[i];
    }
    rep(i,b-a+1){
        f[i] = INF;
    }
    f[1] = 0;
    srep(i,2,b-a+1){
        rep(j,i+1){
            mn[j] = 0, dp1[j] = INF;
        }
        dp1[0] = 0;
        rep(j,K+1){
            rep(k,i+1){
                dp2[k] = INF;
            }
            srep(k,j+1,i+1){
                srep(l,max(mn[k],j),k){
                    if(dp2[k] > dp1[l]+(k-l)*t[j]+f[k-l]){
                        dp2[k] = dp1[l]+(k-l)*t[j]+f[k-l];
                        mn[k] = l;
                    }
                }
            }
            if(j) cmn(f[i],dp2[i]);
            swap(dp1,dp2);
        }
    }
    printf("%.12lf\n",(double)f[b-a]/(b-a));
    return 0;
}



Measured memory_bytes: 3280
p=998244353
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N = int(input())
D = list(map(int,input().split()))
D.insert(0,0)
C = {i:0 for i in range(N)}
for i in range(1,N+1):
    C[D[i]] += 1
if C[0]!=1 or D[1]!=0:
    cnt = 0
else:
    ind = 0
    for i in range(N):
        if C[i]==0:
            ind = i
            break
    flag = 0
    if ind>0:
        for i in range(ind+1,N):
            if C[i]>0:
                flag = 1
                break
    if flag==1:
        cnt = 0
    else:
        C = sorted(list(C.items()),key=lambda x:x[0])
        cnt = 1
        for i in range(1,N):
            if C[i][1]==0:break
            c0 = C[i-1][1]
            c1 = C[i][1]
            cnt = (cnt*(pow(c0,c1)))%p
print(cnt)

Measured memory_bytes: 93040
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;
long long T;

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N >> T;
  long long res, last = 0ll;
  cin >> res;
  res = T;
  for(int i=1; i<N; ++i){
    long long x;
    cin >> x;
    res += min(x-last, T);
    last = x;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 10;
const int MAXM = 600010;
const int MAXK = 110;
const int MAXQ = 200010;

int n;
II a[MAXN];
int z[MAXN];

ld dist(II a, II b) {
    return sqrt((a.FI - b.FI) * (a.FI - b.FI) + (a.SE - b.SE) * (a.SE - b.SE));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    ld res = 0;
    FOR(i,1,n) cin >> a[i].FI >> a[i].SE;

    FOR(i,1,n) z[i] = i;
    int cnt = 0;
    do {
        cnt++;
        FOR(i,1,n-1) res += dist(a[z[i]], a[z[i+1]]);
    } while (next_permutation(z+1, z+n+1));

    cout << fixed << setprecision(9) << res / cnt;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,total=0,mean,mean2,mean3;
    cin >> n;
    vector<int>a(n);
    REP(i,n){
        cin >> a[i];
        total += a[i];
    }
    mean = total/n;
    mean2 = mean+1;
    mean3 = mean-1;

    total = 0;
    int answer = 1000000000;
    REP(i,n){
        total+=(a[i]-mean)*(a[i]-mean);
    }
    answer = min(total,answer);
    total = 0;
    REP(i,n){
        total+=(a[i]-mean2)*(a[i]-mean2);
    }
    answer = min(total,answer);
    total = 0;
    REP(i,n){
        total+=(a[i]-mean3)*(a[i]-mean3);
    }
    answer = min(total,answer);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n , d;
    cin>>n>>d;
    int c = 0;
    for(int i=0;i<n;i++) {
        ll x1, x2;
        cin>>x1>>x2;
        double v = sqrt(pow(-x1, 2)+pow(-x2, 2));

        if(v <= d ) c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i,x[n+1],c=0;
	string s;
	cin>>s;
	x[n]=0;
	for(i=0;i<n;i++)
	{ 	
		if(s[i]=='I')
		{
			c++;
		}
		else if(s[i]=='D')
		{
			c--;
		}
		x[i]=c;
	}
	sort(x,x+(n+1));
	cout<<x[n]<<endl;
	
}

Measured memory_bytes: 3636
program main
  implicit none
  integer :: N
  integer :: i,j
  integer :: iskip
  read(*,*) N

  if (mod(N,2)==0) then ! even
     write(*,'(i0)' ) N*(N-1)/2 - N/2
     iskip = N
     do i = 1,N-1
        do j = i+1,N
           if (j==iskip) then
              iskip = iskip-1
              cycle
           end if
           write(*,'(i0,x,i0)') i,j
        end do
     end do
  else  ! odd
     write(*,'(i0)' ) N*(N-1)/2 - (N-1)/2
     iskip = N-1
     do i = 1,N-1
        do j = i+1,N
           if (j==iskip) then
              iskip = iskip-1
              cycle
           end if
           write(*,'(i0,x,i0)') i,j
        end do
     end do
  end if
  stop
end program main


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, t, l, b;
        cin >> n >> t >> l >> b;
        if(n == 0)
            return 0;

        vector<bool> lose(n+1, false);
        vector<bool> back(n+1, false);
        for(int i=0; i<l; ++i){
            int a;
            cin >> a;
            lose[a] = true;
        }
        for(int i=0; i<b; ++i){
            int a;
            cin >> a;
            back[a] = true;
        }

        vector<vector<double> > prob(t+2, vector<double>(n+1, 0.0));
        prob[0][0] = 1.0;
        for(int i=0; i<t; ++i){
            prob[i+1][n] = prob[i][n];
            for(int j=0; j<n; ++j){
                for(int k=1; k<=6; ++k){
                    int pos = j + k;
                    if(pos > n)
                        pos = 2*n - pos;
                    if(lose[pos]){
                        prob[i+2][pos] += prob[i][j] / 6;
                    }else{
                        if(back[pos])
                            pos = 0;
                        prob[i+1][pos] += prob[i][j] / 6;
                    }
                }
            }
        }

        printf("%.10f\n", prob[t][n]);
    }
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

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

Measured memory_bytes: 256
n = int(input())
cs = input()
nr = cs.count("R")
nw = cs.count("W")
cnt = 0
cnt1 = 0
for i in range(nr):
    if cs[i] == "W":
        cnt += 1
# for i in range(nr,n):
#     if cs[i] == "R":
#         cnt1 += 1

print(cnt)

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

using namespace std;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  for(int i=0;i!=b;i++){
    if(a*(i+1)%b==c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
s=gets.chomp
a=[1,0,0,0]
s.chars{|x|
  m=x==???3:1
  a=[
    a[0]*m,
    a[1]*m+("A?"[x]?a[0]:0),
    a[2]*m+("B?"[x]?a[1]:0),
    a[3]*m+("C?"[x]?a[2]:0)
  ].map{|i|i%(10**9+7)}
}
p a[3]


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

int main(){
  int a[3];

  for(int i=0;i<3;i++) cin >> a[i];

  int maxIndex = 0;
  int maxValue = a[0];

  for(int i=1;i<3;i++){
    if(a[i] > maxValue){
      maxIndex = i;
      maxValue = a[i];
    }
  }

  int sum = 0;

  for(int i=0;i<3;i++){
    if(i != maxIndex){
      sum += a[i];
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

class union_find {
public:
	union_find(int n)
	: par_(n, -1)
	{}
	void init(int n) {
		par_.assign(n, -1);
	}

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

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if(x == y) {
			return false;
		} else {
			if(par_[x] < par_[y]) {
				par_[x] += par_[y];
				par_[y] = x;
			} else {
				par_[y] += par_[x];
				par_[x] = y;
			}
			return true;
		}
	}

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

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

private:
	std::vector<int> par_;
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<ll> p(n);
	REP(i,n) cin>>p[i];
	REP(i,n) p[i]--;
	union_find uf(n);
	REP(i,m) {
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		uf.unite(x,y);
	}
	ll ans=0;
	REP(i,n) {
		if(uf.same(i,p[i])) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1408
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

vector<int>vec[M+6];
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        vec[u].pb(v);
    }
    priority_queue<int>pq;
    int ses=0;
    for(int i=1;i<=M;i++)
    {
        ll rmn=inf;
        if(!pq.empty())
        {
            rmn=-pq.top();
        }
        if(rmn==i)
        {
            ses++;
            while(!pq.empty())pq.pop();
        }
        for(auto x:vec[i])
        {
            pq.push(-x);
        }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 6144
using System;

namespace AtCoder_20190218
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);

            int kake = a * b;

            if(kake%2==0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


Measured memory_bytes: 13140
import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

fac=[0 for _ in range(n)]   #n!
finv=[0 for _ in range(n)]  #1/n!
inv=[0 for _ in range(n)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

for i in range(2,n):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

def ncr(n,k):
    if(n < k):
        return 0
    elif(n < 0 or k < 0):
        return 0
    else:
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


print(ncr(n-1,k-1))

Measured memory_bytes: 82200
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,K;
const int N=12;
string s[N];
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>K;
	
	int white=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(auto x:s[i]){
			if(x=='1')	white++;
		}
	}
	
	if(white<=K){
		cout<<0<<"\n";
		return 0;
	}

	if(n==1){
		int ans=0,white=0;
		for(int i=0;i<m;i++){
			if(s[0][i]=='1')	white++;
			if(white>K){
				ans++;
				white=1;
			}
		}
		cout<<ans<<"\n";
		return 0;
	}
	
	int ans=n*m;
	
	for(int mask=0;mask<(1ll<<(n-1));mask++){
		
		int row=1,start=0;
		vector<pair<int,int>>rows;
		int cuts=0;
		
		for(int j=0;j<(n-1);j++){
			if(mask&(1ll<<j)){
				cuts++;
				rows.push_back({start,row});
				start+=row;row=1;
			}else{
				row++;
			}
		}
		rows.push_back({start,row});

		int col=0,imposs=0,steps=0;
		
		while(col<m){

			steps++;
			int overal_mi=m;
			for(int i=0;i<rows.size();i++){

				int mi=m-1,flag=1,white=0;
				for(int k=col;k<m && flag;k++){
					for(int j=rows[i].first;j<=(rows[i].first+rows[i].second-1);j++){
						if(s[j][k]=='1')	white++;
						if(white>K){
							mi=k-1;flag=0;break;
						}
					}	
				}
				
				overal_mi=min(mi,overal_mi);

			}
			// cout<<col<<" "<<overal_mi<<"\n";
			// cout<<cuts<<" "<<bitset<3>(mask)<<" "<<steps-1<<" "<<overal_mi<<"\n";
			// for(auto x:rows){
			// 	cout<<x.first<<" "<<x.second<<"\n";
			// }cout<<"\n";


			if(col==overal_mi+1){
				imposs=1;
				break;
			}		
			col=overal_mi+1;
		}
		if(!imposs){
			// cout<<cuts<<" "<<bitset<3>(mask)<<" "<<steps-1<<"\n";
			// for(auto x:rows){
			// 	cout<<x.first<<" "<<x.second<<"\n";
			// }cout<<"\n";
			ans=min(ans,cuts+steps-1);
		}

	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict

s = Counter(input())
t = Counter(input())
unused_nums_s = defaultdict(int)
unused_nums_t = defaultdict(int)
for v in s.values():
  unused_nums_s[v] += 1
for v in t.values():
  unused_nums_t[v] += 1
print('Yes' if all(unused_nums_s[k] == unused_nums_t[k] for k in unused_nums_s) else 'No')

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

#define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll MOD = 1e9+7;

void dfs(int p,int d,vector<int>& dis,vector<vector<int>>& lis){

    dis[p] = d;
    if (d < 2){
        rep(i,0,lis[p].size()){
            if (dis[lis[p][i]] > dis[p] + 1) dfs(lis[p][i],d+1,dis,lis);
        }
    }
}

int main(){

    int N,M,a,b;
    cin >> N >> M;

    vector<vector<int>> lis(N,vector<int> (0));

    rep(i,0,M){
        cin >> a >> b;
        a -= 1;
        b -= 1;
        lis[a].push_back(b);
        lis[b].push_back(a);
    }

    vector<int> dis(N,1000000000);

    dfs(0,0,dis,lis);

    //rep(i,0,N){
    //    cout << dis[i] << endl;
    //}

    if (dis[N-1] == 2){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 12784
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, H, W = map(int, readline().split())
    ans = 0
    for _ in range(N):
        A, B = map(int, readline().split())
        if H<=A and W<=B:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
//k_tourist
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 200005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll n, k, r, s, p, i, j;
    string t, an;

    cin>>n>>k>>r>>s>>p>>t;

    map<char, ll> mp;
    mp['r']= 0;
    mp['s'] = 2;
    mp['p'] = 1;
    
    ll pt[]= {r, p, s};//, r};

    vl vec;
    rep(i, 0, n)
    {
        vec.pb(mp[t[i]]);
        vec[i]++;
        vec[i]%=3;
    }

    vl st[mx];

    rep(i, 0, n)
    st[i%k].pb(vec[i]);

    rep(i, 0, k)
    st[i].pb(3);

    ll awr=0;
    rep(i, 0, n)
    awr+= pt[vec[i]];

    ll aw=0;
    rep(i, 0, k){

        ll cn=1;
        rep(j, 1, st[i].size()){

            if(st[i][j] != st[i][j-1]){

                aw+= ((cn/2) * pt[st[i][j-1]]);
                cn = 1;
            }
            else
            {
                cn++;
            }
            
        }
    }

    awr-=aw;
    cout<<awr;
	
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 8772
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,q,a,b,p,x;
cin>>n>>q;
vector<int> g[n+1];
for(int i=0;i<n-1;i++){
cin>>a>>b;
g[a].push_back(b);
}
vector<int> inc(n+1,0);
while(q--){
    cin>>p>>x;
    inc[p]+=x;
}
queue<int> qq;
qq.push(1);
while(!qq.empty()){
    int t=qq.front();
    qq.pop();
    for(int i=0;i<g[t].size();i++){
        int u=g[t][i];
        qq.push(u);
    }
    if(inc[t]==0){
        continue;
    }
    int ct=inc[t];
    for(int i=0;i<g[t].size();i++){
        int u=g[t][i];
        inc[u]+=ct;
    }
}
for(int i=1;i<=n;i++){
    cout<<inc[i]<<" ";
}
cout<<endl;
return 0;
}

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

void solve(void){

long long int n,l,r;
cin >> n >> l >>r;
  
  l--;r--;
  
  vector<vector<int>> dist(n,vector<int>(n));
  rep(i,n)rep(j,n)dist[i][j]=abs(i-j);
  rep(i,n)rep(j,n){
  	dist[i][j] =min(dist[i][j],dist[i][l] + dist[r][j]+1);
    dist[i][j] =min(dist[i][j],dist[i][r] + dist[l][j]+1);
  }
  vector<int> cnt(n);
  rep(i,n)rep(j,n) cnt[dist[i][j]]++;
  rep(i,n-1)cout << cnt[i+1]/2 << endl;
  /*
  long long int i,j;
  long long int sum[N];
  
  for(i=1;i<N;i++) sum[i]=0;
  
  for(i=0;i<N-1;i++){
  	for(j=i+1;j<N;j++){
 	if(j>=X&&i<=X||j>=Y&&i<=Y){
    sum[min(j-i,abs(X-i)+abs(j-Y)+1)]++;
    }else{
      sum[j-i]++;
      }
//          cout << distance[i][j] <<endl;
    }
  }
  
  for(i=1;i<N;i++){
	
    cout << sum[i] <<endl;
  }
	*/
  
  return;
  
}

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

Measured memory_bytes: 16000
#include <bits/stdc++.h>
    using namespace std;
    int main() {
      string str;
      
      cin >> str;
      
      int size = (int)(str.length());
      
      int sum =0;
      
      for(int i=0; i<size ; i++){
        sum += (int)(str.at(i)) - '0';
      }
      
 
      if(sum % 9 == 0){
      cout << "Yes" <<endl;
      }else{
      cout << "No" <<endl;
      }

    }

Measured memory_bytes: 3684
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.AssertionError
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N= ni()
    val A= na(N)
    var cnt = 0L
    for (i in 1 until N) {
      if (A[i - 1] > A[i]) {
        val v = A[i - 1] - A[i]
        A[i] += v
        cnt += v
      }
    }
    out.println(cnt)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private inline fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private inline fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private inline fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private inline fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private inline fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }

  private inline fun assert(b: Boolean) = run{if (!b) throw AssertionError()}
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 57136
package main

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

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 100000000)

	s := scanText()

	c1,c2 := 0,0

	for i := 0; i < len(s); i++ {
		if i%2 == 0 {
			if s[i]=='1' {
				c1++
			} else {
				c2++
			}
		} else {
			if s[i]=='0' {
				c1++
			} else {
				c2++
			}
		}
	}

	if c1 < c2 {
		fmt.Println(c1)
	} else {
		fmt.Println(c2)
	}

}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

void factor(map<int,int> &m, int num){
    for(int i=2; i*i <= num; i++){
        int p = 0;
        while(num%i==0){
            num /= i;
            p++;
        }
        if(p > 0){
            if(!m.count(i)) m[i] = 0;
            m.at(i) += p;
        }
    }
    if(num != 1){
        if(!m.count(num)) m[num] = 0;
        m.at(num)++;
    }
}

signed main() {
    int n; cin >> n;
    map<int,int> m;
    reps(i,1,n) factor(m, i);
    
    int ans = 1;
    for(auto p : m){
        ans = (ans * (p.second + 1)) % MOD;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
function main()
  
  (N, M) = map(x -> parse(Int, x), split(readline()))
  H = map(x -> parse(Int, x), split(readline()))
  
  check = [[] for i in 1:N]
  
  for i in 1:M
    (A, B) = map(x -> parse(Int, x), split(readline()))
    push!(check[A], B)
    push!(check[B], A)
  end
  
  cnt = 0
  cnt_check = true
  
  for i in 1:N
    cnt_check = true
    for j in check[i]
      if H[i] <= H[j]
        cnt_check = false
      end
    end
    if cnt_check
      cnt += 1
    end
  end
  
  println(cnt)
  
end

main()

Measured memory_bytes: 220184
#!/usr/bin/env python3
N = int(input())
lists = list(map(int, input().split()))
if lists[0] % N == 0 or lists[1] % N == 0:
    print("OK")
elif ((lists[0]//N) * N) + N < lists[1]:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9048
N, Y = gets.split.map(&:to_i)

0.upto(N) do |x|
  sum_x = 0
  sum_x += 10000 * x
  if Y < sum_x
    puts "-1 -1 -1"
    exit
  end

  0.upto(N - x) do |y|
    sum_x_y = sum_x + 5000 * y
    break if Y < sum_x_y

    z = N - x - y
    if Y - sum_x_y == 1000 * z
      puts [x, y, z].join("\s")
      exit
    end
  end
end

puts "-1 -1 -1"


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

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

    int s;
    cin>>s;

    int cnt=1;
    int n=s;

    while(!(n==4||n==2||n==1))
    {
        if(n%2)n=3*n+1;
        else n/=2;
        cnt++;
    }

    cnt+=3;

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 3644
class UnionFind:
    def __init__(self, n):
        self.v = [-1] * n

    def find(self, x):
        if self.v[x] < 0:
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            if self.v[x] > self.v[y]:
                x, y = y, x
            self.v[x] += self.v[y]
            self.v[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.v[self.find(x)]


def main():
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    N = int(input())

    ps = []
    xs = set()
    ys = set()
    for i in range(N):
        x, y = map(int, input().split())
        ps.append((x, y))
        xs.add(x)
        ys.add(y)

    xs = tuple(sorted(xs))
    ys = tuple(sorted(ys))

    dx = {e: i for i, e in enumerate(xs)}
    dy = {e: i for i, e in enumerate(ys)}

    uf = UnionFind(N * 2)
    for x, y in ps:
        uf.unite(dx[x], dy[y] + N)

    def make_edges(xs, d, *, add_val=0):
        xes = []
        for x0, x1 in zip(xs, xs[1:]):
            xes.append((abs(x1 - x0), d[x0] + add_val, d[x1] + add_val))
        return xes

    xes = make_edges(xs, dx)
    yes = make_edges(ys, dy, add_val=N)

    # Kruskal
    # 最小コストの辺から順に使用する
    # 同じ連結成分に属していればつながない(閉路を作らない)
    # コスト昇順ソート済みの辺リストを使用する
    ret = 0
    joined = set()
    for cost, a, b in sorted(xes + yes, key=itemgetter(0)):
        if (a in joined) or (b in joined): continue
        if uf.same(a, b): continue
        uf.unite(a, b)
        ret += cost
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81364
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  int ans = 0;
  if(A >= B){
    ans += A;
    A--;
  }else{
    ans += B;
    B--;
  }
  if(A >= B){
    ans += A;
    A--;
  }else{
    ans += B;
    B--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int k,n,i;
  int max=0,first,tmp,tm;
  scanf("%d",&k);
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&tmp);
    if(i==0)first=tm=tmp;  
    else{
      
      if(max<(tmp-tm)){
       max = tmp-tm; 
      }
      tm = tmp;
    }
  }
  if(max < (first+(k-tmp)))max = first+(k-tmp);
  printf("%d\n",k-max);
 return 0; 
}


Measured memory_bytes: 128
#!/usr/bin/python3
# -*- coding: utf-8 -*-

s = input()
t = input()

sd = {}
td = {}

for si, ti in zip(s, t):
    if si in sd:
        sd[si] += 1
    else:
        sd[si] = 1
    if ti in td:
        td[ti] += 1
    else:
        td[ti] = 1

sl = list(sd.values())
tl = list(td.values())
sl.sort()
tl.sort()

if sl == tl:
    print('Yes')
else:
    print('No')


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

int main() {
  string s; cin >> s;
  int L = s.size();
  int idx = 0;
  while (idx < L) {
    if (s.at(idx) == 'C') break;
    idx++;
  }
  while (idx < L) {
    if (s.at(idx) == 'F') {
      cout << "Yes" << endl;
      return 0;
    }
    idx++;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char **argv){
	std::vector<int> h_vec(10);

	for(int i = 0; i < 10; i++){
		std::cin >> h_vec[i];
	}
	std::sort(h_vec.begin(), h_vec.end());

	for(int i = 9; i >= 7; i--){
		std::cout << h_vec[i] << std::endl;
	}
	return 0;
}

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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

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

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif



void solve()
{
	int n;
	cin >> n;

	long long ans = 0;

	for (int i = 1; i <= n; i++) {

		long long temp = n / i;

		if (n % i == 0) {
			temp--;
		}

		ans += temp;
	}

	cout << ans << nl;
}

int main()
{
	FIO;

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}

	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>x>>p;
	ll val = x*10+p;
	if(val%4) cout<<"NO";
	else cout<<"YES";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

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

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

int main() {

  ll n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= n; ++j)
      for(int k = 1; k <= n; ++k)
        ans += gcd(gcd(i,j),k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636