akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<float> A(N);
    int sum = 0;
    for(int i=0; i< N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    sort(A.begin(),A.end(),greater<int>());

    bool can = true;
    for (int i=0; i<M; i++) {
        if (A.at(i) < sum * (1.0/(4.0*M))) {
            can = false;
            break;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc,const char * arg[])
{
    int a, b, c, t, count=0;
    
    scanf("%d %d %d",&a,&b,&c);
    
    for(t=a;t<b+1;t++){
        if(c<t)break;
        if(c%t==0)count++;
    }
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("h.txt", "r", stdin);
    // freopen("main.out", "w", stdout);
#else
    fastIO;
#endif
    clock_t z = clock();
    map<int, int> mp;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            mp[i * j] = 1;
        }
    }
    int n;
    cin >> n;
    if (mp[n])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

#ifdef LOCAL
    cerr << "Total Time: " << 1.0 * (clock() - z) / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def cost(min):
    if min % 10 == 0:
        return min
    else:
        return min - (min % 10) + 10

def min_extra(t, now):
    e = t % 10
    if e == 0:
        return now
    if e < now:
        return e
    else:
        return now

extra = A % 10
extra = min_extra(B, extra)
extra = min_extra(C, extra)
extra = min_extra(D, extra)
extra = min_extra(E, extra)

sum = cost(A)
sum += cost(B)
sum += cost(C)
sum += cost(D)
sum += cost(E)
if extra != 0:
    sum -= (10 - extra)

print(sum)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<int> a(n, 10);

	for (int i = 0; i < m; i++)
	{
		int s, c;
		cin >> s >> c;

		s--;

		if (a[s] == 10 || a[s] == c)
		{
			a[s] = c;
		}
		else
		{
			println(-1);
			return 0;
		}

	}

	if ((a[0] == 0 || a[0] == 10) && n == 1)
	{
		println(0);
		return 0;
	}

	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			if (a[i] == 0)
			{
				println(-1);
				return 0;
			}
			else if (a[i] == 10)
			{
				print(1);
			}
			else
			{
				print(a[i]);
			}
		}
		else
		{
			if (a[i] == 10)
			{
				print(0);
			}
			else
			{
				print(a[i]);
			}
		}
		
	}

	println("");
}



Measured memory_bytes: 256
n, m = map(int,input().split())
A = [[]*m for i in range(n)]
for i in range(n):
    A[i] = list(map(int,input().split()))
b = [[]*1 for i in range(m)]
for i in range(m):
    b[i] = int(input())
for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += A[i][j] * b[j]
    print(tmp)


Measured memory_bytes: 6020
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[2018];
int n,k,q;
bool cal(int lo,int hi){
	int ret=0,now=0,ok=0;
	rep(i,n+1){
		if(a[i]<lo){
			ret+=max(0,min(ok,now-k+1));
			now=ok=0;
		}
		else{
			now++;if(a[i]<=hi) ok++;
		}
	}
	//cout<<lo<<' '<<hi<<' '<<ret<<endl;
	if(ret>=q) return true;return false;
}
int main()
{
	int out=1001001001;cin>>n>>k>>q;
	rep(i,n) cin>>a[i];a[n]=-1;
	rep(i,n){
		int lo=0,hi=1001001001;
		while(hi>lo){
			int mi=(hi+lo)/2;
			if(cal(a[i],a[i]+mi)) hi=mi;else lo=mi+1;
			//if(i==2) cout<<hi<<' '<<lo<<endl;
		}
		out=min(out,lo);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0 ; i<N ; i++)
    cin >> vec.at(i);
  sort(vec.begin() , vec.end());
  for(int j=0 ; j<N-1 ; j++)
    ans+=vec.at(j);
  ans+=vec.at(N-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
S = []
S.append('.' * (w + 2))
for _ in range(h):
    S.append('.' + input() + '.')
S.append('.' * (w + 2))
for i in range(1, h+1):
    l = []
    for j in range(1, w+1):
        if S[i][j] == '#':
            l.append('#')
            continue
        _s = S[i-1][j-1:j+2] + S[i][j-1] + S[i][j+1] + S[i+1][j-1:j+2]
        l.append(_s.count('#'))
    print(''.join(map(str, l)))



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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a % 2 == 0 || b % 2 == 0) {
  	  cout << "Even" << endl;
  }
  else {
      cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
len = gets.to_i
nums = gets.split.map(&:to_i)
cnt = 0
0.upto(len-1) do |i|
  min = i
  (i).upto(len-1) do |j|
    if nums[j] < nums[min]
      min = j
    end
  end

  if i != min
    nums[i], nums[min] = nums[min], nums[i]
    cnt += 1
  end
end
puts nums * ' '
puts cnt

Measured memory_bytes: 6108
main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  print $ solve n k

solve :: Int -> Int -> Double
solve n k =
  (/ fromIntegral n) $
  sum $
  map (\i -> (0.5 :: Double) ^ timesToWin k i) [1..n]

timesToWin :: Int -> Int -> Int
timesToWin k i =
  max 0 $ ceiling $ logBase (2 :: Double) $ fromIntegral k / fromIntegral i


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define int long long
#define for(i,a,b) for(int i=a;i<(signed)b;i++)

using namespace std;
int dp[100005]={0};
signed main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(i,0,n) cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    for(i,2,n){
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        for(t,2,k+1){
            dp[i] = min(dp[i],(i-t>=0)?(dp[i-t] + abs(h[i]-h[i-t])):INT_MAX);
        }
    }
    // for(i,0,n){
    //     cout<<dp[i]<<" ";
    // }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a<3200)
        cout<<"red"<<endl;
        else
            cout<<s<<endl;

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64_t res = 0, cur = 1000, x = 0;
  for (int i = 0; i < N - 1; i++) {
    if (i + 1 < N && A[i] < A[i + 1]) {
      int64_t c = cur / A[i];
      cur -= c * A[i];
      x += c;
    } else if (A[i] > A[i + 1]) {
      cur += x * A[i];
      x = 0;
    }
    res = max(res, cur);
  }
  if (x > 0) {
    cur += x * A[N - 1];
    x = 0;
  }
  res = max(res, cur);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    //int t; cin>>t; while(t--){
    ll n,p=0; cin>>n;
    for(int j=2;j<=sqrt(n);j++){
        if(n%j==0){p=1; break;}
    }
    if(p==0){
        cout<<n-1;
    }
    else{
        for(int j=2;j<=sqrt(n);j++){
            if(n%j==0){p=j;}
        }
        ll k=n/p;
        cout<<k-1+p-1;
    }
}



Measured memory_bytes: 3652
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return

#B
def B():
    s = S()
    for i in range(len(s)):
        if i%2:
            if s[i] not in ["L","U","D"]:
                print("No")
                return
        else:
            if s[i] not in ["R","U","D"]:
                print("No")
                return
    print("Yes")
    return

#C
def C():
    n,k,q = LI()
    a = IR(q)
    f = [k-q]*(n)
    for i in range(q):
        ai = a[i]-1
        f[ai] += 1
    for i in f:
        if i <= 0:
            print("No")
        else:
            print("Yes")
    return

#D
def D():
    n,m = LI()
    a = LI()
    q = []
    for i in range(n):
        heappush(q,-a[i])
    for i in range(m):
        x = heappop(q)
        x *= -1
        x >>= 1
        heappush(q,-x)
    print(-sum(q))
    return

#E
def E():
    n = I()
    s = S()
    l = 0
    r = n
    M = 10**64+1
    b = 26
    alp = list("abcdefghijklmnopqrstuvwxyz")
    f = {}
    for i in alp:
        f[i] = ord(i)-ord("a")
    pb = [pow(b,i,M) for i in range(n+1)]
    while r-l > 1:
        m = (l+r)>>1
        d = defaultdict(lambda : float("inf"))
        hash = 0
        for i in s[:m]:
            hash *= b
            hash += f[i]
            hash %= M
        d[hash] = 0
        t = pb[m]
        for i in range(n-m):
            si = s[i]
            hash *= b
            hash -= t*f[si]
            hash += f[s[i+m]]
            hash %= M
            if d[hash]+m <= i+1:
                l = m
                break
            if i+1 < d[hash]:
                d[hash] = i+1
        else:
            r = m
    print(l)
    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 46556
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n, m, cnt[102];
int a[102];
int b[102][102];

int main(){

	cin >> n >> m;
	rep(i, m)cin >> a[i];
	rep(i, m) {
		rep(j, n) {
			cin >> b[i][j];
		}
	}

	rep(i, m) {
		rep(j, n) {
			if (b[i][j] == a[i])cnt[j]++;
			else cnt[a[i] - 1]++;
		}
	}

	rep(i, n)cout << cnt[i] << endl;

	return 0;
}


Measured memory_bytes: 3136
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vector<int> g[200009];

  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      { 
        ll k;
        cin>>k;
        ll z=7;
        int d=1;
        fo(i,k)
        {
          if(z%k==0)
          {
            cout<<d<<endl;
            return 0;
          }
          d++;
          z=((z*10)%k+7)%k;
        }
        cout<<-1<<endl;
      }
      return 0;
      }
  

Measured memory_bytes: 8348
n, k = map(int, input().split())
a = list(map(int, input().split()))
total_1 = 0
for i in range (n - 1):
    for j in range (i + 1, n):
        if a[i] > a[j]:
            total_1 += 1
total_2 = 0
for i in range (n):
    for j in range (n):
        if a[i] > a[j]:
            total_2 += 1
print((total_1 * k + (total_2 * k * (k - 1)) // 2) % (10 ** 9 + 7))

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

min_step = 10**12

i = 1
j = 1
l = int(n**0.5)+1

for p in range(1, l+1):
    if n % p == 0:
        if i == (n / p) and j == p:
            break
        step = (p + n / p) - 2
        if min_step > step:
            min_step = step
            i = p
            j = (n / p)

print(int(min_step))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int fr1[150];
int fr2[130];
int main()
{
   string s,t;
   cin>>s>>t;int y=1;
   map<char,int> mp;
   for(int i=0;i<s.size();i++)
   {
       fr1[s[i]]++;
       fr2[t[i]]++;
       if(fr1[s[i]]!=fr2[t[i]])
       {
           y=0;
           break;
       }
   }
   if(y==0)
    cout<<"No\n";
    else
        cout<<"Yes\n";

}



Measured memory_bytes: 776
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cassert>
using namespace std;
vector<long long> V[500000];

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

  priority_queue<long long> Q;

  for ( int i = 0; i < N; i++ ){
    long long m;
    cin >> m;
    for ( int j = 0; j < m; j++ ){
      cin >> v;
      Q.push((-1)*v);
    }
    while(Q.size() > (i+1) ) Q.pop();
  }
  assert(Q.size() == N);
  long long sum = 0;
  while( !Q.empty() ){
    sum += Q.top()*(-1);
    Q.pop();
  }

  cout << sum << endl;

}



Measured memory_bytes: 18760
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 100010
#define M 110
using namespace std;
ll n,k,a[M],dp[M][N],qdh[N];
int main(){
	ll i,j;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	memset(dp,0,sizeof(dp));
	for(i=0;i<=k;i++)
	{
		qdh[i]=1;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<=k;j++)
		{
			if(j>a[i])
			{
				dp[i][j]=(qdh[j]-qdh[j-a[i]-1]+MOD)%MOD;
			}
			else
			{
				dp[i][j]=qdh[j]%MOD;
			}
		}
		qdh[0]=dp[i][0];
		for(j=1;j<=k;j++)
		{
			qdh[j]=(qdh[j-1]+dp[i][j])%MOD;
		}
	}
	cout<<dp[n-1][k]<<endl;
	return 0;
}

Measured memory_bytes: 86912
#include<bits/stdc++.h>
     
using namespace std;
    
#define ll long long int
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 

int main()
{
    fio
    ll tt=1;
    //cin>>tt;
    while(tt--)
    {
        ll a,b,c,k;
        cin>>a>>b>>c>>k;
        ll sum=0;
        if(k<=a) sum=k;
        else if(k>a && k<=(a+b)) sum=a;
        else sum=a-(min(k-(a+b),c));
        cout<<sum<<endl;
    }
    return 0;
}

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

using namespace std;

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

  for (int i = 1; i <= 1300; ++i) {
    int aa = i * 0.08;
    int bb = i * 0.1;
    if (aa == a && bb == b) {
      cout << i << '\n';
      return 0;
    }
  }
  puts("-1");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  FOR(i, k-1, n-1) {
    if (a[i-k+1] >= a[i+1]) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 1000 == 0)
        cout << 0 << endl;
    else
        cout << ((n / 1000) + 1) * 1000 - n << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int a[n],b[m];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  sort(a,a+n);
  sort(b,b+m);
  if(a[n-1]<b[0]&&b[0]>x&&a[n-1]<y){
    cout<<"No War";
  }else{
    cout<<"War";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  string s;
  cin >> s;
  int d[4];
  fill(d,d+4,0);
  rep(i,s.size()) {
    if(s[i]=='K') d[0]++;
    if(s[i]=='U') d[1]++;
    if(s[i]=='P') d[2]++;
    if(s[i]=='C') d[3]++;
  }
  int ans=MAX;
  rep(i,4) ans=min(ans,d[i]);
  pr(ans);
  return 0;
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll n;
	cin>>n;
	for(ll i=n;;i++){
		bool ch=false;
		for(ll j=2;j<=sqrt(i);j++){
			if(i%j==0){
				ch=true;
				break;
			}
		}
		if(ch==false){
			cout << i;
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3600
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
A = i()
B = i()
a = N - A
a = a // B
print(N-A-a*B)


Measured memory_bytes: 9988
s = list(input())
al = list("abcdefghijklmnopqrstuvwxyz")
if s[0] == "A" and s[-1] in al and s[1] in al:
    del s[0]
    del s[0]
    del s[-1]
    f = 0
    for i in s:
        if i == "C":
            if f == 1:
                print("WA")
                break
            else:
                f = 1
                continue
        else:
            if i in al:
                continue
            else:
                print("WA")
                break
    else:
        if f == 1:
            print("AC")
        else:
            print("WA")
else:
    print("WA")

Measured memory_bytes: 9124
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N-1);
    rep(i, N) { 
        cin >> A[i];
    }
    rep(i, N) {
        cin >> B[i];
    }
    rep(i, N-1) {
        cin >> C[i];
    }
    ll cnt = 0;
    rep(i, N) {
        cnt += B[i];
    }
    rep(i, N-1) {
        if (A[i]+1 == A[i+1]) cnt += C[A[i]-1];
    }
    print(cnt);
    return 0;
}

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

using namespace std;

typedef long long ll;

const int Maxn = 100110;
const int INF = (int) 1e9;

int dp[Maxn][3], a[Maxn][3];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for (int i = 1; i < n; ++i) {
        dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;


    return 0;
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    if (x * 2 == W and y * 2 == H) {
        cout << H / 2 * W << " " << 1 << endl;     
    }
    else cout << H / 2 * W << " " << 0 << endl;     


    return 0;
}


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

using namespace std;

#define ll long long

int main(){
	int n, w, w1;
	cin >> n >> w;
	vector<ll> val[4];
	ll vv;
	cin >> w1 >> vv;
	val[0].push_back(vv);	
	for(int i = 0 ; i < n - 1; ++i){
		ll wR, v;
		cin >> wR >> v;
		val[wR-w1].push_back(v);
	}
	for(int i = 0; i < 4; ++i){
		sort(val[i].begin(), val[i].end(), greater<ll>());
		val[i].insert(val[i].begin(), 0);
		for(int j = 1; j < (int)val[i].size(); ++j) val[i][j] += val[i][j-1];
	}
	ll sol = 0;
	for(ll i = 0; i < (int)val[0].size(); ++i){
		for(ll j = 0; j < (int)val[1].size(); ++j){
			for(ll k = 0; k < (int)val[2].size(); ++k){
				for(ll p = 0; p < (int)val[3].size(); ++p){
					if(w < (w1*(i+j+k+p)+j+2*k+3*p)) break;
					sol = max(sol, val[0][i]+val[1][j]+val[2][k]+val[3][p]);
				}
			}
		}
	}
	cout << sol << "\n";
	return 0;
}



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

#define ll long long 
#define ull unsigned long long
#define all(c) c.begin(),c.end()
#define pb push_back
#define F first 
#define S second

using namespace std;

int main(){

	ios_base::sync_with_stdio(0);cin.tie(0);

	int n;
	int k , w;
	cin >> n >> w;
	vector<pair<int,ll> >arr(n);
	ll dp[n+1][w+1];
	for(int i = 0 ; i < n ; ++i ){
		cin >> arr[i].F >> arr[i].S;
	}
	sort(all(arr));
	for(int i = 0 ; i <= n ; ++i ){
		for(int j = 0 ; j <= w ; ++j){
			if(i==0||j==0){
				dp[i][j]=0;
			}else{
				if(arr[i-1].F<=j){
					dp[i][j]=max(arr[i-1].S + dp[i-1][j-arr[i-1].F],dp[i-1][j]);
				}else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}


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

int main() {
	int n, ans = 2147483647, sum = 0;
	bool checked[101] = {0};
	cin >> n;
	int a[101];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int j = -100; j <= 100; j++){
		for(int k = 0; k < n; k++){
			sum += (a[k] - j) * (a[k] - j);
		}
		ans = min(ans, sum);
		sum = 0;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
n1 = int(math.sqrt(n))
cnt = 10**18
for i in range(1, n1+1):
  if n % i == 0:
      j = (n/i) - 1
      ans = i-1
      cnt = min(cnt, j+ans)
      #print(cnt)
  else:
    continue
print(int(cnt))

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

int main(){
    int n, cnt;
    bool prime[1000000] = {false, false};

    for(int i = 2;i < 1000000;i++){
        prime[i] = true;
    }
    
    for(int i = 2;i <= sqrt(1000000);i++){
        if(prime[i]){
            for(int j = 2*i;j <= 1000000;j++){
                if(j%i == 0){
                    prime[j] = false;
                }
            }
        }
    }
    
    while(cin >> n){
        cnt = 0;

        for(int i = 2;i <= n;i++){
            if(prime[i]){
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 4024
def solve(q):
    x = q / 2.0
    while abs(x**3 - q)/q >= 1e-5:
        x1 = x - (x**3 - q)/3/x**2
        x = x1
    return(x)

while True:
    q = int(input().strip())
    if q==-1:
        break
    print("%.6f" % solve(q))

Measured memory_bytes: 7684
process.stdin.resume();
process.stdin.setEncoding();
process.stdin.on('data',function(chunk){


var line=chunk.split(" ").map(Number);
var a = line[0];
var b = line[1];

var d=Math.floor(a/b);
var r=a%b;
var f=(a/b).toFixed(5);

 
 console.log(d+" "+r+" "+f);


});

Measured memory_bytes: 15724
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}

const int N=5010;
const int mod=1e9+7;
int n,P[N],pw[N],tot;
vector<int> G[N];
int dfs(int u) {
	int res=1;
	for(int v : G[u]) res+=dfs(v);
	return res;
}

int fa[N];
int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }

vector<int> b;
int dp[N];

int main() {
	rd(n);
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1;i<=n;++i) {
		rd(P[i]),tot+=P[i]==-1;
		if(P[i]!=-1) G[P[i]].PB(i),fa[find(P[i])]=find(i);
	}
	pw[0]=1; for(int i=1;i<=tot;++i) pw[i]=1ll*pw[i-1]*(n-1)%mod;
	int num=0; for(int i=1;i<=n;++i) num+=find(i)==i;
	
	for(int i=1;i<=n;++i) if(P[i]==-1) b.PB(dfs(i));
	
	int res=1ll*(num-tot)*pw[tot]%mod;
	for(int s : b) res=(res+1ll*(s-1)*pw[tot-1])%mod;
	dp[0]=1;
	for(int s : b) for(int i=tot;i>=1;--i)
		dp[i]=(dp[i]+1ll*dp[i-1]*s)%mod;
	int coe=1;
	for(int i=2;i<=tot;++i) {
		coe=1ll*coe*(i-1)%mod;
		res=(res+1ll*coe*dp[i]%mod*pw[tot-i])%mod;
	}
	res=(1ll*n*pw[tot]-res)%mod;
	printf("%d",(res+mod)%mod);
	return 0;
}

Measured memory_bytes: 4032
N = int(input())
s = [int(input()) for _ in range(N)]

res = 0
other = []

for num in s:
  if num % 10 == 0:
    res += num
  else:
    other.append(num)
    
if other:
  other.sort()
  res += sum(other)
  if res % 10 == 0:
    res -= other[0]
  print(res)
  
else:
  print(0)

Measured memory_bytes: 9172
'use strict'

const main = input => {
	const args = input.split('\n').map(t => t.split(' '))
	const a = args[0].map(t => parseInt(t, 10))
	const k = parseInt(args[1][0], 10)

	for (let i = 0; i < k; i++) {
		let tmpMax = 0
		let tmpIndex = -1

		for (let j = 0; j < 3; j++) {
			if (a[j] > tmpMax) {
				tmpMax = a[j]
				tmpIndex = j
			}
		}

		a[tmpIndex] *= 2
	}

	let sum = 0

	for (let i = 0; i < 3; i++) {
		sum += a[i]
	}

	console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21192
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();

  long N,M,K;cin>>N>>M>>K;
  long ans=0;
  for(long vx=0;vx<M;vx++){
    for(long vy=0;vy<N;vy++){
      long C=(vx+vy)%MOD;
      long S=((M-vx)*(N-vy))%MOD;
      long O=COM(M*N-2,K-2)%MOD;
      if(vx!=0&&vy!=0){
        S*=2;
        //if(vx!=vy)S*=2;
      }
      ans=ans+(((C*S)%MOD)*O)%MOD;
    }
  }
  cout<<ans%MOD;
}

Measured memory_bytes: 23680
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    
    n=I()
    list_=LI2()
    dict_=defaultdict(lambda:x)
    for i in range(n):
        dict_[list_[i]]=i
    mx=0
    length=1
    ind=1
    while ind<n:
        if dict_[ind]<dict_[ind+1]:
            length+=1
            ind+=1
        else:
            mx=max(length,mx)
            length=1
            ind+=1
    mx=max(length,mx)
    print(n-mx)
    
    



if __name__=="__main__":
    main()


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

int main() {
  int N;
  int P=0,W=0,G=0,Y=0;
  cin >> N;
  
  for(int i=0; i<N; i++){
  string clr;
    cin >> clr;
    if(clr == "P") P++;
    else if(clr == "W") W++;
    else if(clr == "G") G++;
    else if(clr == "Y") Y++;
  }
  
  if(Y != 0) cout << "Four" << endl;
  else cout << "Three" << endl;

}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
typedef struct val{
  ll value;
  ll val_p_lit; // 2lあたりの値段
  double lit;
} VAL;

int main() {

  ll q,h,s,d,n;
  vector<VAL> a(4);

  cin >> q >> h >> s >> d >> n;

  a[0].lit = 0.25;
  a[1].lit = 0.5;
  a[2].lit = 1.0;
  a[3].lit = 2.0;
    
  a[0].value = q;
  a[1].value = h;
  a[2].value = s;
  a[3].value = d;

  a[0].val_p_lit = a[0].value * 8;
  a[1].val_p_lit = a[1].value * 4;
  a[2].val_p_lit = a[2].value * 2;
  a[3].val_p_lit = a[3].value;

  auto comp = [](auto a,auto b)
  {
    return a.val_p_lit < b.val_p_lit;
  };

  sort(all(a),comp);

  ll ans = 0;
  rep(i,4)
  {
 
    ll buf = n / a[i].lit;
    n = n - buf * a[i].lit;
    ans += buf * a[i].value;
	if(n == 0) break;
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
// B - Distance
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(){
	ll n, d; cin>>n>>d;
	int c = 0;
	while(n--){
		ll x, y; cin>>x>>y;
		if(x*x + y*y <= d*d) c++;
	}
	cout<< c <<endl;
}


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


int main(){
  int a,b,l,d,w;
  cin>>a>>b>>l>>d>>w;
  int x,y;
  x=w*a;
  l=w-l;
  if(l<0){l=0;}
  y=b+l*d;
  x=min(x,y);
  cout<<x<<endl;
  
  return 0;
}



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

int main()
{
	int s;
	cin >> s;
	set<int> st;
	while (!st.count(s)) {
		st.insert(s);
		s = s & 1 ? s * 3 + 1 : s / 2;
	}
	cout << st.size() + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, M = list(map(int, input().split()))
S = input()
T = input()

if S[0]!=T[0]:
    print(-1)
else:
    if N==M:
        print(int(N*M)) if S==T else print(-1)
    else:
        g = gcd(N, M)
        if g==1:
            print(int(N*M))
        else:
            flag = False
            s, t = N//g, M//g
            ss = list(map(lambda x: int(x*s), list(range(0,g))))
            tt = list(map(lambda x: int(x*t), list(range(0,g))))
            for i,j in zip(ss,tt):
                if S[i]!=T[j]:
                    flag = True
            if flag:
                print(-1)
            else:
                print(int(s*t*g))

Measured memory_bytes: 5952
from sys import stdin 

def main():
   a, b, c = map(int, input().split())
   if (a == b) and (a != c):
       print("Yes")
   elif (b == c) and (a != c):
        print("Yes")
   elif (a == c) and (a != b):
        print("Yes")
   else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9112
// 2017/12/13 Tazoe

#include <iostream>
#include <cstdlib>
using namespace std;

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

		if(n==0)
			break;

		int a[1000];
		for(int i=0; i<n; i++){
			cin >> a[i];
		}

		int dif = 1000001;

		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				int d = abs(a[i]-a[j]);

				if(d<dif){
					dif = d;
				}
			}
		}

		cout << dif << endl;
	}

	return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
int main(void){
	
	int N;scanf("%d",&N);
	int i,j,judge = 0;
	for(i = 0;i <= 25;i++){
		for(j = 0;j <= 15;j ++){
			
			if((4*i + 7*j) == N){
				judge ++; break;
			}
		}
		if(judge == 1){
			printf("Yes");
			break;
		}
		
	}
	
	if(judge == 0){
			printf("No");
	}
	
	return 0;
	
}
				

Measured memory_bytes: 128
# 6:16
l,r = gets.to_s.split.map{|t|t.to_i}

if r - l > 2025
  ans = 0
else
  
  ans = 2018
  (l+1).upto(r) do |j|
    l.upto(j-1) do |i|
      r = i * j % 2019
      ans = r if ans > r
    end
  end
end

puts ans


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

signed main() {
    long long n, l[100], x, far, ans;
    cin >> n >> x;
    for ( int i = 0; i < n; i++ ) {
        cin >> l[i];
    }
    
    far = 0;
    ans = 0;
    for ( int i = 0; i < n && far <= x; i++ ) {
        far += l[i];
        ans ++;
    }
    
    if ( far <= x ) {
        ans ++;
    }
    cout << ans << endl;
    return (0);
}

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

/*
Sの間が|S+1|個あって、最後の1個は26文字使えて残りは25文字使える
つまり？最後に使う文字数をiとした時がnCk(K-i+|S|-1,|S|-1)*pw(25,K-i)*pw(26,i)
*/
#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=(Factorial[i-1]*i)%MOD;
  Finverse[4999999]=pw(Factorial[4999999],MOD-2);
  for(int i=4999998;i>=0;i--)Finverse[i]=(i+1)*Finverse[i+1]%MOD;
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  (res*=Finverse[k])%=MOD;
  (res*=Finverse[n-k])%=MOD;
  return res;
}

signed main(){
  int k;string s;cin>>k>>s;
  int ans=0;
  for(int i=0;i<=k;i++)(ans+=nCk(k-i+s.size()-1,s.size()-1)*pw(25,k-i)%MOD*pw(26,i))%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 83444
array = []
while True:
    n =input()
    if n == "-1 -1 -1":
        break
    array.append(n.split())
suum = 0
seiseki = []
for i in range(len(array)):
    if array[i][0]!="-1" and array[i][1] != "-1":
        suum = int(array[i][0]) + int(array[i][1])
        if suum >= 80:
            seiseki.append("A")
        elif suum < 80 and suum >= 65:
            seiseki.append("B")
        elif suum < 65 and suum >= 50:
            seiseki.append("C")
        elif suum <50 and suum >= 30:
            if int(array[i][2]) >= 50:
                seiseki.append("C")
            else:
                seiseki.append("D")
        else:
            seiseki.append("F")
    else:
        seiseki.append("F")
    print(seiseki[i])

Measured memory_bytes: 7664
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    int odd = 0;
    vector<vector<int>> ans;
    vector<vector<int>> a(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    //奇数のマスを右端に寄せる
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w - 1; j++) {
            if(a[i][j] % 2 == 1) {
                a[i][j]--;
                a[i][j + 1]++;
                ans.push_back({i + 1, j + 1, i + 1, j + 2});
            }
        }
    }
    //右端の奇数のマスを下に寄せる
    for(int k = 0; k < h - 1; k++) {
        if(a[k].back() % 2 == 1) {
            a[k][w - 1]--;
            a[k + 1][w - 1]++;
            ans.push_back({k + 1, w, k + 2, w});
        }
    }
    cout << ans.size() << endl;
    for(auto e : ans) {
        cout << e[0] << " " << e[1] << " " << e[2] << " " << e[3] << endl;
    }
}


Measured memory_bytes: 10032
from collections import deque

N = int(input())
tree = [list(map(int, input().split())) for i in range(N-1)]

M = N-1
G = [deque([]) for i in range(N+1)]

for i in range(M):
    G[tree[i][0]].append([tree[i][1], tree[i][2]])
    G[tree[i][1]].append([tree[i][0], tree[i][2]])
    
distance = [-1] * (N+1)     

def dfs(v):
    stack = deque([v])
    distance[v] = 0
    
    while stack:   
        tmp = stack[0]
        if G[tmp]:
            w = G[tmp].popleft() 
            if distance[w[0]] < 0:
                distance[w[0]] = (distance[tmp] + w[1]) % 2
                stack.append(w[0])
        else:
            stack.popleft()
    return distance

distance = dfs(1)
for i in range(N):
    print(distance[i+1])

Measured memory_bytes: 110696
# input
N = int(input())
S = [input() for _ in range(N)]

inner_count = sum(s.count('AB') for s in S)

a_ends = []
b_bgns = []
for i, s in enumerate(S):
    if s[0] == 'B':
        b_bgns.append(i)
    if s[-1] == 'A':
        a_ends.append(i)

match_flag = 0
if set(a_ends) == set(b_bgns):
    match_flag = 1
join_count = max(min(len(a_ends), len(b_bgns)) - match_flag, 0)

print(inner_count + join_count)


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long int lcm(long long int a,long long int b){
    long long int g = gcd(a,b);
    return (a/g)*b;
}


int main() {
    ll Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;

    ll p1 = min(Q*4,min(H*2,S));
    ll p2 = min(p1*2,D);

    pl(N/2*p2 + (N%2==1?p1:0))

    return 0;
}


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

int main () {
  char a,b;
  cin >> a >> b;
  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
    cout << 'H' << endl;
  } else {
    cout << 'D' << endl;
  }
  return 0;
}


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

using namespace std;

int calc(string s)
{
    set<string> sset;
    int n = s.size();
    for(int i=0; i<n; i++)
    {
        string fst(s, 0, i), snd(s, i, n-i);
        string rfst(fst.rbegin(), fst.rend()), rsnd(snd.rbegin(), snd.rend());
        sset.insert(fst+snd);
        sset.insert(snd+fst);
        sset.insert(fst+rsnd);
        sset.insert(rsnd+fst);
        sset.insert(rfst+snd);
        sset.insert(snd+rfst);
        sset.insert(rfst+rsnd);
        sset.insert(rsnd+rfst);
    }
    return sset.size();
}

int main()
{
    int n;
    cin >> n;
    while(n--)
    {
        string s;
        cin >> s;
        cout << calc(s) << endl;
    }
}

Measured memory_bytes: 3220
//D
#include<bits/stdc++.h>
#define se second
#define fi first
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
bool vis[200001];
vector<int> v[200001];

int f(int nod) {
	vis[nod] = 1;
	int cnt = 1;
	for (auto i : v[nod]) {
		if (!vis[i]) cnt += f(i);
	}
	return cnt;
}

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	set<pair<int, int> > cnt;
	int ans = 0;
	while (M--) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a > b) swap(a, b);
		if (cnt.count(mp(a, b)) == 0) {
			v[a].pb(b);
			v[b].pb(a);
			cnt.insert(mp(a, b));
		}
	}
	for (int i = 1; i <= N; i++) {
		if (!vis[i]) ans = max(ans, f(i));
	}
	printf("%d\n", ans);
}

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

int main() {
    vector<int> v;
    rep(i, 3) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    swap(v[0], v[1]);
    swap(v[0], v[2]);
    cout << v[0];
    for (int i = 1; i < 3; i++) {
        cout << " " << v[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
  int m, d;
  int t[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  while(cin >> m >> d, m || d){
    int sum = 0;

    for(int i = 0; i < m - 1; i++){
      sum += t[i];
    }
    sum += d;

    cout << week[(sum + 2) % 7] << endl;
  }
}

Measured memory_bytes: 1196
package main

import (
	"fmt"
)

func main() {
	var a, b, tmp int
	fmt.Scan(&a, &b)
	x := a * b
	if a < b {
		tmp = a
		a = b
		b = tmp
	}
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}
	ans := x / b
	fmt.Println(ans)
}


Measured memory_bytes: 512