akhauriyash/Code-Regression huggingface dataset:
import numpy as np
nkq = list(map(int, input().split()))


n = nkq[0]
k = nkq[1]
q = nkq[2]
aes = []
for _ in range(q):
    aes.append(int(input()))
    


points = np.zeros(n)  + (k - q)
for a in aes:
    points[a-1] = points[a-1] + 1

for p in points:
    if p > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 17628
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	if (s == "SUN") {
		cout << 7 << endl;
	}
	else if(s == "SAT"){
		cout << 1 << endl;
	}
	else if (s == "MON") {
		cout << 6 << endl;
	}
	else if (s == "TUE") {
		cout << 5 << endl;
	}
	else if (s == "WED") {
		cout << 4 << endl;
	}
	else if (s == "THU") {
		cout << 3 << endl;
	}
	else {
		cout << 2 << endl;
	}

	return 0;
}

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

int main(){
    ll n, d;
    cin >> n >> d;
    ll x[n][d];
    rep(i, 0, n){
        rep(j, 0, d){
            cin >> x[i][j];
        }
    }

    ll ans = 0;
    rep(i, 0, n-1){
        rep(j, i+1, n){
            ll dist = 0;
            rep(k, 0, d){
                dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            rep(k, 1, 1e5){
                if(dist == k*k){
                    ans++;
                    break;
                }
            }
        }
    }

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

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

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

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

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

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
       ll h,w;
       cin>>h>>w;
       string s[h];
       for(ll i=0;i<h;i++)
        cin>>s[i];
       ll ans=0; 
       for(ll i=0;i<h;i++)
       {
           for(ll j=0;j<w;j++)
           {
               if(s[i][j]=='.')
               {
                   queue<pair<ll,pair<ll,ll>> >q;
                   vector<vector<ll> >visited(h,vector<ll>(w,0));
                   q.push({0,{i,j}});
                   ll mx=0;
                   while(!q.empty())
                   {
                     pair<ll,pair<ll,ll> >q1=q.front();
                     q.pop();  
                     ll d=q1.first;
                     ll x=q1.second.first;
                     ll y=q1.second.second;
                     if(visited[x][y]==1)
                      continue;
                     visited[x][y]=1;
                     mx=max(mx,d);
                     if(y<w-1&&s[x][y+1]=='.')
                      q.push({d+1,{x,y+1}});
                     if(y>0&&s[x][y-1]=='.')
                      q.push({d+1,{x,y-1}});
                     if(x<h-1&&s[x+1][y]=='.')
                      q.push({d+1,{x+1,y}});
                     if(x>0&&s[x-1][y]=='.')
                      q.push({d+1,{x-1,y}});   
                   }
                   ans=max(ans,mx);   
               }
           }
       }
       cout<<ans;
    }
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
 
map<string, int> dp;
int direction[4] = { 1, -1, 4, -4 };
 
//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public 
// Returns:   void
// Qualifier: ???0????????´?????????
//************************************
void bfs()
{
	queue<string> que;
	que.push("01234567");
	dp["01234567"] = 0;
	while (!que.empty())
	{
		string now = que.front(); que.pop();
		// p???'0'?????????
		int p = 0;
		for (int j = 0; j < 8; ++j)
		{
			if (now[j] == '0')
			{
				p = j;
				break;
			}
		}
 
		for (int i = 0; i < 4; ++i)
		{
			int n = p + direction[i];
			if (0 <= n && n < 8 && 
				!(p == 3 && i == 0) && // ???????§???????????????????
				!(p == 4 && i == 1))   // ???????§???????????????????
			{
				string next = now;
				swap(next[p], next[n]);
				if (dp.find(next) == dp.end())
				{
					dp[next] = dp[now] + 1;
					que.push(next);
				}
			}
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	bfs();
	string line;
	while (getline(cin, line))
	{
		line.erase(remove(line.begin(), line.end(), ' '), line.end());
		cout << dp[line] << endl;
	}
 
	return 0;
}

Measured memory_bytes: 5348
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,T,A;
  cin>>N>>T>>A;
  double temp=1e9;
  int ans;
  REP(i,N){
    double h;
    cin>>h;
    double t=abs(A-(T-h*0.006));
    if(t<temp){
      temp=t;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 888
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll& a , ll b){a =  (a + b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
const ll nax = 1e5 + 5 ;
vector<bool>visited(nax) ; 
vector<ll>memo(nax,-1);
vector<ll> v[nax];
ll ans =  0;
ll dfs(ll x , ll parent = -1){
	// cout<<x<<endl;
	if(memo[x]!=-1)return memo[x];
	assert(!visited[x]);
visited[x] = true;
ll res = 0 ;
for(auto child : v[x]){
	if(child == parent)continue;
	max_self(res , dfs(child,x));
}
if(v[x].empty()||(v[x].size()==1 && v[x][0] == parent))return memo[x] = 0;
max_self(ans,res+1);
return memo[x] = res + 1;



}


signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
ll n , m ; cin>>n>>m ;
for(ll i = 0 ; i< m  ; i++){
	ll AAA , BBB;
	cin>>AAA>>BBB;
	// AAA--;BBB--;
	v[AAA].push_back(BBB);
	// v[BBB].push_back(AAA);
}

for(auto i = 1 ; i <= n ; i++){
	if(!visited[i])dfs(i);
}

cout<<ans;



	
}

Measured memory_bytes: 9984
#include<stdio.h>

int main () {
	int a, b, d, r;
	double f;
	
	scanf ( "%d %d", &a, &b );
	
	d = a / b;
	r = a % b;
	f = ( double ) a / ( double ) b;
	
	printf ( "%d %d %f\n", d, r, f );
	
	return 0;
}


Measured memory_bytes: 2112
#include  <stdio.h>
#include <string.h>

int main(void) {
    char s[4];
    scanf("%s",s);
    if(strcmp(s, "SUN") == 0)printf("%d\n", 7);
    else if(strcmp(s, "MON") == 0) printf("%d\n", 6);
    else if(strcmp(s, "TUE") == 0) printf("%d\n", 5);
    else if(strcmp(s, "WED") == 0) printf("%d\n", 4);
    else if(strcmp(s, "THU") == 0) printf("%d\n", 3);
    else if(strcmp(s, "FRI") == 0) printf("%d\n", 2);
    else if(strcmp(s, "SAT") == 0) printf("%d\n", 1);
    return 0;
}


Measured memory_bytes: 128
import numpy as np
X, Y, A, B, C = map(int, input().split())
P = np.array(list(map(int, input().split())))
Q = np.array(list(map(int, input().split())))
R = np.array(list(map(int, input().split())))

P.sort()
Q.sort()
R.sort()

orig = np.concatenate([P[::-1][:X],Q[::-1][:Y]])
orig.sort()
for i in range(C):
	if R[-(i+1)] > orig[i]:
		orig[i] = R[-(i+1)]
	else:
		break

print(orig.sum())



Measured memory_bytes: 24876
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
        Scanner sc=new Scanner(System.in);
        double n=sc.nextInt();

        if(n%2==0){
            System.out.println(0.5);
        }
        else{
            System.out.println((n+1)/(2*n));
        }
    }
}

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

int main() {
	int h, w;
	while(h+w)
	{
		cin >> h >> w;
		for(int i =0; i < h; i++){
			for(int j = 0; j < w; j++){
				cout << "#";
			}
			cout << endl;
		}
		if(h+w)cout << endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long H, W;
  int N;
  cin >> H >> W >> N;
  vector<pair<int, int>> pos(N);
  for (int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    pos[i] = make_pair(a, b);
  }
  set<pair<int, int>> st1;
  for (int i = 0; i < N; i++){
    st1.insert(pos[i]);
  }
  set<pair<int, int>> st2;
  for (int i = 0; i < N; i++){
    int a = pos[i].first;
    int b = pos[i].second;
    for (int j = -1; j <= 1; j++){
      for (int k = -1; k <= 1; k++){
        if (1 <= a + j && a + j < H - 1 && 1 <= b + k && b + k < W - 1){
          st2.insert(make_pair(a + j, b + k));
        }
      }
    }
  }
  vector<long long> cnt(10, 0);
  cnt[0] = (H - 2) * (W - 2) - st2.size();
  for (auto P : st2){
    int y = P.first;
    int x = P.second;
    int tmp = 0;
    for (int j = -1; j <= 1; j++){
      for (int k = -1; k <= 1; k++){
        if (st1.count(make_pair(y + j, x + k))){
          tmp++;
        }
      }
    }
    cnt[tmp]++;
  }
  for (int i = 0; i < 10; i++){
    cout << cnt[i] << endl;
  }
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
string S;

int main()
{
	cin >> S;
	N = S.size();

	int l = 0,r = N,ans = 0;
	while(r - l > 1){
		if(S [l] == S [r - 1]){
			l++;
			r--;
		}
		else if(S [l] == 'x'){
			l++;
			ans++;
		}
		else if(S [r - 1] == 'x'){
			r--;
			ans++;
		}
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while a != 0:
        a,b = b%a,a
    return b
#最小公約数
def lcm(a,b):
    return a*b // gcd(a,b)
print(lcm(a,b))

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;

struct node{
	int t,v;
}t;

vector<node> g[200001];
queue<int> q;
int k,i,dis[500001],x;
bool vis[500001];

int main(){
	cin >> k;
	for(i=0;i<k;i++){
		t.t=(i+1)%k;
		t.v=1;
		g[i].push_back(t);
		t.t=(i*10)%k;
		t.v=0;
		g[i].push_back(t);
	}
	for(i=0;i<k;i++)
		dis[i]=99999999;
	q.push(1);
	dis[1]=0;
	while(!q.empty()){
		x=q.front();
		q.pop();
		vis[x]=false;
		for(i=0;i<g[x].size();i++)
			if(dis[g[x][i].t]>dis[x]+g[x][i].v){
				dis[g[x][i].t]=dis[x]+g[x][i].v;
				if(!vis[g[x][i].t]){
					vis[g[x][i].t]=true;
					q.push(g[x][i].t);
				}
			}	
	}
	cout << dis[0]+1;
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007; // 1e9 + 7
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

ll N, Q;
string S;
ll res = 0;

int main(int argc, char *argv[]){
    int l, r;
    cin >> N >> Q >> S;
    vec NUM(N + 1, 0);
    rep(i, N){
        if(i + 1 < N && S[i] == 'A' && S[i + 1] == 'C')
            NUM[i + 1] = NUM[i] + 1;
        else
            NUM[i + 1] = NUM[i];
    }

    rep(i, Q){
        cin >> l >> r;
        l--; r--;
        cout << NUM[r] - NUM[l] << endl;
    }
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s1>>s2;

	reverse(s2.bb,s2.ee);

	if(s1==s2) cout<<"YES"<<endl;
	else{
        cout<<"NO"<<endl;
	}



}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int A, B;
	int K;

	cin >> K;

	cin >> A >> B;
	int flag = 0;

	for (int i = A; i <= B; ++i){
		if(i%K == 0)
			flag = 1;
	}
	
	if (flag)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

#define MAX 50001
int main(){
  int n, i, j, c, prime[MAX] = {};
  prime[0] = prime[1] = 1;
  for(i = 2;i < MAX;i++){
    if(prime[i] != 1){
      for(j = i * 2;j < MAX;j += i)
        prime[j] = 1;
    }
  }

  while(scanf("%d", &n) && n){
    c = 0;
    for(i = 0;i <= n / 2;i++)
      if(!prime[i] && !prime[n - i]) c++;
    printf("%d\n", c);
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, K;
	cin >> A >> B >> K;
	ll count = 0;
	for(int i=200;i>-1;i--){
		if(A%(i+1)==0 && B%(i+1)==0) count++;
		if(count==K){
			cout << (i+1) << endl;
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: i64,
        xu: [(f64, String); n],
    }
    let mut ans: f64 = 0.0;
    for (x, u) in xu {
        ans += if u == "JPY" {
            x as f64
        } else {
            380000.0 * x as f64
        };
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define db double
#define ld long db
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
const int p=1e9+7;
inline int ksm(ri x,ri y){
	ri z=1;
	while(y){
		(y&1)?z=(ll)z*x%p:0;
		x=(ll)x*x%p;
		y>>=1;
	}
	return z;
}
inline void sub(ri &x,ri y){
	x-=y;x<0?x+=p:0;
}
int main()
{
	ri n=read(),a=read(),b=read(),s=ksm(2,n),s1=1;
	rep(i,1,a)s1=(ll)s1*i%p;s1=ksm(s1,p-2);
	rep(i,n-a+1,n)s1=(ll)s1*i%p;
	sub(s,s1);sub(s,1);s1=1;
	rep(i,1,b)s1=(ll)s1*i%p;s1=ksm(s1,p-2);
	rep(i,n-b+1,n)s1=(ll)s1*i%p;sub(s,s1);cout<<s;
	return 0; 
}

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

int main(){
  string S;
  cin>>S;
  int f,e;
  f=2;
  if ((S.at(0)=='0')&&(S.at(1)=='0')) f=3;
  if((S.at(0)=='0')&&((S.at(1)>='1')&&(S.at(1)<='9'))) f=1;
  if((S.at(0)=='1')&&((S.at(1)>='0')&&(S.at(1)<='2'))) f=1;
  e=2;
  if ((S.at(2)=='0')&&(S.at(3)=='0')) e=3;
  if((S.at(2)=='0')&&((S.at(3)>='1')&&(S.at(3)<='9'))) e=1;
  if((S.at(2)=='1')&&((S.at(3)>='0')&&(S.at(3)<='2'))) e=1;  
  
  if((f==1)&&(e==1)){
    cout<<"AMBIGUOUS"<<endl;
    return 0;
  }
  if((f==1)&&((e==2)||(e==3))){
    cout<<"MMYY"<<endl;
    return 0;
  }
  if(((f==2)||(f==3))&&(e==1)){
    cout<<"YYMM"<<endl;
    return 0;
  }
  cout<<"NA"<<endl;
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// Union-Find木
// union by size + path having
class UnionFind {
  public:
  vector <ll> par; // 各元の親を表す配列
  vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
  // Constructor
  UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
    for (ll i=0; i<sz_; ++i) par[i] = i; // 初期では親は自分自身
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
    for (ll i=0; i<sz_; ++i) par[i] = i; // 初期では親は自分自身
  }
  // Member Function
  // Find
  ll root(ll x) { // 根の検索
    while (par[x]!=x) {
      x = par[x] = par[par[x]]; // x の親の親を x の親とする
    }
    return x;
  }
  // Union(Unite, Merge)
  bool merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x==y) return false;
    // merge technique（データ構造をマージするテク．小を大にくっつける）
    if (siz[x]<siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(ll x, ll y) { // 連結判定
    return root(x) == root(y);
  }
  ll size(ll x) { // 素集合のサイズ
    return siz[root(x)];
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int i=0; i<M; i++) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    UF.merge(A, B);
  }
  int res = 0;
  for (int i=0; i<N; i++) res = max(res, (int)UF.size(i));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6352
def counting_sort(A):
    # init
    bucket = []
    for i in range(10000):
        bucket.append(0)

    for a in A:
        bucket[a] += 1

    k = 0
    for i in range(10000):
        for j in range(bucket[i]):
            A[k] = i
            k += 1

n = int(input())
A = list(map(int, input().split()))

counting_sort(A)

print(*A)


Measured memory_bytes: 224468
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) (int)a.size()
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;

int32_t main()
{
	IOS;
	int tak_a,tak_h,ao_a,ao_h;
	cin>>tak_h>>tak_a>>ao_h>>ao_a;
	while(true)
	{
		ao_h-=tak_a;
		if(ao_h<=0)
		{
			cout<<"Yes";
			break;
		}
		tak_h-=ao_a;
		if(tak_h<=0)
		{
			cout<<"No";
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3648
n = int(input())
h = list(map(int , input().split()))
h.append(100000000000)
count = 0
ans = []
for i in range(n):
  if h[i] - h[i + 1] >= 0:
    count += 1
  else:
    ans.append(count)
    count = 0

print(max(ans))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp
const ll mod=1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans=0;
    sort(rall(a));
    rep(i,n-1){
        if(i==0)ans+=a[i];
        else ans+=a[(i+1)/2];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4760
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Greatest Common Divisor and Least Common Multiple
ll GCD(ll x, ll y) {
    if (!y) return x;
    return GCD(y, x % y);
}

const int MAX = 1000010;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    vector<int> p(MAX + 1, 1);
    p[0] = p[1] = 0;
    rep(i, 2, MAX + 1) {
        if (not p[i]) continue;
        for (int j = i * 2; j <= MAX; j += i) p[j] = 0;
    }
    vector<int> cnt(MAX + 1, 0);
    rep(i, n) ++cnt[a[i]];
    
    bool pairwise = true, setwise = true;
    rep(i, 2, MAX + 1) {
        if (not p[i]) continue;
        int c = 0;
        for (int j = i; j <= MAX; j += i) c += cnt[j];
        if (c >= 2) pairwise = false;
        if (c == n) setwise = false;
    }
    if (pairwise) {
        cout << "pairwise coprime\n";
        return 0;
    }
    if (setwise) {
        cout << "setwise coprime\n";
        return 0;
    }
    cout << "not coprime\n";
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i, n) {
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i, m) {
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    ll ans = 0;
    rep(i, n) {
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
# 164_b
A, B, C, D = map(int, input().split())
if (1 <= A and A <= 100) and (1 <= B and B <= 100) and (1 <= C and C <= 100) and (1 <= D and D <= 100):

    while True:
        C = C - B
        A = A - D

        if A <= 0 or C <= 0:
            break
    if C <= 0:
        print('Yes')
    elif A <= 0:
        print('No')

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

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

map <int, vector < pair <ll, ll> > > wxw;
vector < pair <ll, ll> > tmp;
int n, x, d;
ll ans;

ll s(int x) { return 1ll * x * (x + 1) / 2; }

int main() {
    read(n); read(x); read(d);
    if(d == 0) {
        if(x == 0) {
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
        return 0;
    }
    if(d < 0) x = -x, d = -d;
    for(register int i = 0; i <= n; i++) wxw[(1ll * x * i % d + d) % d].push_back(make_pair((1ll * x * i - (1ll * x * i % d + d) % d) / d + s(i - 1), (1ll * x * i - (1ll * x * i % d + d) % d) / d + s(n - 1) - s(n - i - 1)));
    for(auto it : wxw) {
        tmp = it.second;
        sort(tmp.begin(), tmp.end());
        ll l = tmp[0].first, r = tmp[0].second;
        for(register int i = 1; i < (int)tmp.size(); i++) {
            if(tmp[i].first > r) {
                ans += r - l + 1;
                l = tmp[i].first; r = tmp[i].second;
            } else r = max(r, tmp[i].second);
        }
        ans += r - l + 1;
    }
    print(ans, '\n');
    return 0;
}


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

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

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

    int ans = INT_MAX;
    for (int i = -100; i <= 100; i++)
    {
        int sum = 0;
        for (int j = 0; j < N; j++)
        {
            sum += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)
edge = m.times.map{gets.chomp.split(" ").map(&:to_i)}
mtr = Array.new(n).map{Array.new(n,2)}
count = 0
for i in 0..m-1
  mtr[edge[i][0]-1][edge[i][1]-1] = 1
  mtr[edge[i][1]-1][edge[i][0]-1] = 1
end
for i in 0..m-1
  cpmtr = Marshal.load(Marshal.dump(mtr))
  cpmtr[edge[i][0]-1][edge[i][1]-1] = 2
  cpmtr[edge[i][1]-1][edge[i][0]-1] = 2
  list = [0]
  s = 0
  n.times do
    for j in 0..list.size-1
      s = list.size
      for k in 0..n-1
        if cpmtr[list[j]][k] == 1 && !(list.include?(k))
          list << k
        end
      end
    end
  end
  if list.size != n
    count += 1
  end
end
puts count

Measured memory_bytes: 3836
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i-j >= 0:
            dp[i] = min(abs(h[i-j] - h[i]) + dp[i-j], dp[i])
print(dp[-1])

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n,k;
  cin >> n >> k;
  double ans;
  
  for(double i = 1; i <= n; i++){
  	if(k <= i){
    	ans++;
    }
  	else{
    	double p=1;
      	double q=1;
    	while(i*p < k){
        	p *= 2;
          	q *= 0.5;
        }
    ans += q;
      
    }
  }
  cout << fixed << setprecision(10);
  cout << ans/n << endl;
}

Measured memory_bytes: 256
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const INF  = 1e9;
ll const delta = 1000000007;
int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    ll x = (H / h) * (W / w);
    ll l = 0 , r = INF, mid = (l + r) / 2;
    while(r - l > 1){
        if((H * W - x) * mid > x * INF)r = mid;
        else l = mid;
        mid = (l + r) / 2;
    }
    ll t;
    if((H * W - x) * l > x * INF)t = l;
    else if((H * W - x) * r > x * INF)t = r;
    else return cout << "No",0;
    if((h * w - 1) * t > INF)return cout << "No",0;
    cout << "Yes" << endl;
    for(ll i = 0;i < H;i++){
        for(ll j = 0;j < W;j++){
            if((i % h == h - 1) && (j % w == w - 1))cout << -INF << " ";
            else cout << t << " ";
        }
        cout << endl;
    }
    return 0;
}
//Written by M_H_H_7


Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
const int INF = 1<<31;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int LL;

ll n,a,b;
ll x[100005];

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(NULL);
    cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> n >> a >> b;
    FOR(i,0,n)
        cin >> x[i];

    ll cc=0;

    FOR(i,0,n-1){
        cc+=min((ll)(x[i+1]-x[i])*a,b);
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        h: usize, _: usize,
        c_vec: [String; h]
    }

    for c in c_vec.into_iter() {
        println!("{}\n{}", c, c)
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

long long totient(long long a) {
	ll ret = a;
	for(int i = 2;i * i <= a;i++){
		if(a % i == 0){
			ret = ret * (i - 1) / i;
			while(a % i == 0)a /= i;
		}
	}
	if(a > 1)ret = ret * (a - 1) / a;
	return ret;
}

// a / b (mod p) b と p は互いに素
// O(sqrt(p))かかるので注意
long long totient_div(long long a, long long b, long long p) {
	long long ret = a;
	long long tp = totient(p) - 1;
	long long c = b;
	for(int i = 0;i <= 60;i++){
		if(tp & (1LL << i))ret = (ret * c) % p;
		c = (c * c) % p;
	}
	return ret;
}

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}


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

	ll n, a, b, c;cin >> n >> a >> b >> c;
	ll abb = mod_div(a, a + b);
	ll bab = mod_div(b, a + b);
	ll yc = mod_div(100, 100 - c);

	ll ans = 0;
	for(ll i = n;i < 2 * n;i++){
		ll A = mod_pow(abb, n) * mod_pow(bab, i - n) % MOD;
		ll B = mod_pow(abb, i - n) * mod_pow(bab, n) % MOD;
		ll C = i * yc % MOD;
		ll tmp = ((A + B) % MOD) * C % MOD;
		ans = (ans + combination(i - 1, n - 1) * tmp % MOD) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define X 200003
#define PR 5
#define LL long long
using namespace std;
int n,a[N+5],s[X+5],Lg[X+5];LL p[X+5];
class FastIO
{
	private:
		#define FS 100000
		#define tc() (A==B&&(B=(A=FI)+fread(FI,1,FS,stdin),A==B)?EOF:*A++)
		#define D isdigit(c=tc())
		char c,*A,*B,FI[FS];
	public:
		I FastIO() {A=B=FI;}
		Tp I void read(Ty& x) {x=0;W(!D);W(x=(x<<3)+(x<<1)+(c&15),D);}
}F;
namespace Poly
{
	#define DB double
	#define Pi acos(-1)
	struct node
	{
		DB x,y;I node(Con DB& a=0,Con DB& b=0):x(a),y(b){}
		I node operator + (Con node& o) Con {return node(x+o.x,y+o.y);}
		I node operator - (Con node& o) Con {return node(x-o.x,y-o.y);}
		I node operator * (Con node& o) Con {return node(x*o.x-y*o.y,x*o.y+y*o.x);}
	}A[4*X+5];int P,L,R[4*X+5];
	I void FFT(node *s,CI op)
	{
		RI i,j,k;node x,y,U,S;for(i=0;i^P;++i) i<R[i]&&(x=s[i],s[i]=s[R[i]],s[R[i]]=x,0);
		for(i=1;i^P;i<<=1) for(U=node(cos(Pi/i),op*sin(Pi/i)),j=0;j^P;j+=i<<1)
			for(S=1,k=0;k^i;++k,S=S*U) s[j+k]=(x=s[j+k])+(y=S*s[i+j+k]),s[i+j+k]=x-y;
	}
	I void Sqr(int *a,long long *res)
	{
		RI i;for(i=0;i<=X-2;++i) A[i]=a[i];
		P=1,L=0;W(P<=2*(X-2)) P<<=1,++L;for(i=0;i^P;++i) R[i]=(R[i>>1]>>1)|((i&1)<<L-1);
		for(FFT(A,1),i=0;i^P;++i) A[i]=A[i]*A[i];
		for(FFT(A,-1),i=0;i<=2*(X-2);++i) res[i%(X-1)]+=A[i].x/P+0.1;
	}
}
I void Init() {RI i,x=1;for(i=0;i<X-1;++i) Lg[x]=i,x=1LL*x*PR%X;}
int main()
{
	RI i;for(Init(),F.read(n),i=1;i<=n;++i) F.read(a[i]),a[i]&&++s[Lg[a[i]]];
	for(Poly::Sqr(s,p),i=0;i<X-1;++i) p[(i<<1)%(X-1)]-=s[i];
	LL ans=0;for(i=1;i^X;++i) ans+=1LL*i*p[Lg[i]];return printf("%lld\n",ans>>1),0;
}

Measured memory_bytes: 22648
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int c[3][3] = {};
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }

    int a[3] = {}, b[3] = {};
    for (int i = 0; i < 3; ++i) {
        b[i] = c[0][i] - a[0];
    }
    for (int i = 0; i < 3; ++i) {
        a[i] = c[i][0] - b[0];
    }

    bool good = true;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (c[i][j] != a[i] + b[j]) good = false;
        }
    }
    cout << (good ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
fun gcd(x: Int, y: Int): Int {
  if (x < y) {
    return gcd(y, x)
  }
  val r = x % y
  if (r == 0) {
    return y
  } else {
    return gcd(y, r)
  }
}

fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  val s = readLine()!!
  val t = readLine()!!
  val r = gcd(n, m)
  for (k in 0 until r) {
    if (s[k * (n / r)] != t[k * (m / r)]) {
      println(-1)
      return
    }
  }
  println(n.toLong() * m.toLong() / r.toLong())
}


Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N,K;
    cin >> N >> K;
    ll ret = 0;
    for(int i = K + 1;i <= N;i++) {
        int A = K;
        int B = i - 1;
        while(A <= N) {
            if(A == 0) {
                ret += min(B, N);
            }
            else {
                ret += (min(B, N) - A + 1);
            }
            A += i;
            B += i;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in<ll>(),K = in<ll>();
    vector<ll> sum(N+1);
    sum[0] = 0;
    REP(i,N){
        sum[i+1] = sum[i] + in<ll>();
    }
    vector<ll> allsum;
    REP(i,N){
        for (size_t j = i+1; j < N+1; j++){
            allsum.push_back(sum[j] - sum[i]);
        }
    }
    ll answer = 0;
    for (int i = 59; i >= 0; i--){
        sort(ALL(allsum),greater<>());
        int count = 0;
        REP(l,allsum.size()){
            if(allsum[l] >> i == 1){
                count++;
            }else{
                break;
            }
        }
        bool oka = count >= K;
        if(oka){
            answer += 1LL << i;
        }
        REP(l,allsum.size()){
            if(allsum[l] >> i == 1){
                allsum[l] -= 1LL << i;
            }else if(oka){
                allsum[l] = 0;
            }else{
                break;
            }
        }
    }
    cout << answer << "\n";
}

Measured memory_bytes: 6256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    if((a+b) > (c+d)) cout << "Left" << endl;
    else if ((a+b) == (c+d)) cout << "Balanced" << endl;
    else cout << "Right" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        char a;
        // int[] A;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            String s = in.next();
            a = s.charAt(0);
            // A = new int[N];
            // for (int i = 0; i < N; i++) {
            // A[i] = in.nextInt();
            // }

            if (a >= 'a' && a <= 'z') {
                out.println("a");
            } else {
                out.println("A");
            }
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 33040
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int32_t main()
{
    string s, t;
    cin>>s>>t;
    int n=s.length(), m=t.length();
    
    vector<vector<int>>nxt(n, vector<int>(26, -1));
    nxt[n-1][s[n-1]-'a']=n-1;
    for(int i=n-2; i>=0; --i)
    {
        nxt[i]=nxt[i+1];
        nxt[i][s[i]-'a']=i;
    }
    for(int i=n-1; i>=0; --i)
    {
        nxt[i]=nxt[(i+1)%n];
        nxt[i][s[i]-'a']=i;
    }

    int cnt=0;
    int ch;
    int i=0, j=0;
    while(i<m)
    {
        ch=t[i]-'a';
        cnt+=(nxt[j][ch]-j+n)%n+1;
        j = nxt[j][ch];
        // cout << j << " "<<cnt<<"\n";
        if(j==-1)
        {
            cout<<-1;
            exit(0);
        }
        i++;
        j=(j+1)%n;
    }
    cout<<cnt;
}

Measured memory_bytes: 24704
#include<stdio.h>
int main()
{
    int a,b,c,d,i,s=0;
    scanf("%d%d",&a,&b);
    for(i=0;i<b;i++)
    {
        scanf("%d",&c);
        s=s+c;
    }
    d=a-s;
    if(d<0)
        printf("-1");
    else
        printf("%d",d);
}


Measured memory_bytes: 1736
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())
    C = [c-1 for c in map(int, input().split())]
    tree = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)

    # 1回以上 > 全体 - 1回も通らない
    # 選べる数 = n(n+1)//2
    size_subtree = [1] * N
    num_v = [0] * N
    ans = [0] * N

    def dfs(v_now, v_parent, color_parent):
        color_now = C[v_now]
        num_v_now = num_v[color_now]
        num_v_parent = num_v[color_parent]
        for v2 in tree[v_now]:
            if v2 == v_parent: continue
            dfs(v2, v_now, color_now)
            size_subtree[v_now] += size_subtree[v2]
        num_v[color_now] = num_v_now + size_subtree[v_now]
        if color_parent != -1:
            k = size_subtree[v_now] - (num_v[color_parent]-num_v_parent)
            ans[color_parent] += k*(k+1)//2

    dfs(0, -1, -1)

    for color in range(N):
        if color == C[0]: continue
        k = N - num_v[color]
        ans[color] += k*(k+1)//2

    numAll = N*(N+1)//2
    ans = [numAll-ans for ans in ans]

    print(*ans, sep='\n')

main()


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int solve(){
    cin>>n>>m;
    cout<<n*m/gcd(n,m);
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    main(input)
});

function main(input){
    var args = input.trim().split('\n');

    args.forEach(function(data){
        data = data.split(' ').map(Number);
        solve(data[0], data[1]);
    })
}

function solve(a, b){
    if(a < b){
        var tmp = b;
        b = a;
        a = tmp;
    }
    var gcd = calcGcd(a, b);
    var lcm = a * b / gcd;
    console.log(gcd + ' ' + lcm);
}

function calcGcd(a, b){
    if(b <= 0){
        return a;
    }
    return calcGcd(b, a % b);
}

Measured memory_bytes: 16016
package main

import (
    "fmt"
    "math"
)

func main() {
    var (
        N int
        T,A float64
        ans int = -1
        diffMin float64 = 10e9
    )
    fmt.Scan(&N, &T, &A)
    H := make([]float64, N)
    for i:=0; i<N; i++ {
        fmt.Scan(&H[i])
        var temp float64 = T-H[i]*0.006
        // fmt.Println(temp)
        // fmt.Println(math.Abs(A - temp))
        // fmt.Println(diffMin)
        if math.Abs(A - temp) < diffMin {
            ans = i
            diffMin = math.Abs(A - temp)
        }
    }

    fmt.Println(ans+1)
}


Measured memory_bytes: 512