akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
typedef pair<int,int>P;

int _;

//========================================================================
int a[maxn];
//========================================================================
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                if(i==j&&j==k) continue;
                if(a[i]==a[j]) continue;
                if(a[j]==a[k]) continue;
                if(a[i]+a[j]>a[k]&&a[k]-a[j]<a[i]) ans++;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3824
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,A,B = MI()

if (B-A) % 2 == 0:
    print((B-A)//2)
else:
    if B-1 <= N-A:
        print((A+B-1)//2)
    else:
        print(N-(A+B-1)//2)



Measured memory_bytes: 61584
a,b=map(int,input().split())
ans=[]
i=0
while i<1000 and a+i<=b:
    ans.append((a+i)%2019)
    i+=1
ans.sort()
minn=10**6
for i in range(len(ans)):
    for j in range(i+1,len(ans)):
        minn=min(minn,(ans[i]*ans[j])%2019)
print(minn)



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

using namespace std;

int main()
{
    int m,k;
    scanf("%d%d",&m,&k);
    if(k==0)
    {
        for(int i=0;i<(1<<m);i++) printf("%d %d ",i,i);
        printf("\n");
    }
    else if(k<(1<<m))
    {
        int res=0;
        for(int i=0;i<(1<<m);i++) res=res^i;
        res=res^k;
        if(res==k)
        {
            for(int i=0;i<(1<<m);i++) if(i!=k) printf("%d ",i);
            printf("%d ",k);
            for(int i=(1<<m)-1;i>=0;i--) if(i!=k) printf("%d ",i);
            printf("%d\n",k);
        }
        else printf("-1\n");
    }
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;


int main(void){
 char s[3];
 cin>>s;

 for(int i=0; i<3; i++){
  if(s[i]=='1')std::cout<<"9";
  else std::cout<<"1";
 }
 std::cout<<std::endl;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  string S;
  ll counts[2019];

  void init() {
    cin >> S;
    // N = S.size();
  }

  void solve() {
    counts[0] = 1;
    reverse(S.begin(), S.end());
    ll d = 1, sum = 0, n = S.size();
    rep(i, n) {
      sum += (S[i] - '0') * d;
      sum %= 2019;
      d *= 10;
      d %= 2019;
      counts[sum]++;
    }
    ll ans = 0;
    rep(i, 2019) ans += (counts[i]*(counts[i]-1))/2;
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;

int main () {
    int H, W, h, w;
    read(H), read(W), read(h), read(w);
    write((H - h) * (W - w)), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;


string str(ll i) {
    return i < 0 ? "" : str((i / 26) - 1) + (char)(97 + i % 26);
}
int main(){
        _
        ll n; cin >> n;
        cout<<str(n-1)<<endl;


return 0;
}




Measured memory_bytes: 3672
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

// 素因数分解
map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

signed main(){
  int N,P;cin>>N>>P;
  map<int, int> pf=prime_factor(P);
  int ans=1;
  each(m,pf){
    // print(m.fi,m.se);
    if(m.se>=N){
      ans*=powl(m.fi,(m.se/N));
    }
  }
  print(ans);

}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a*b == 15)cout << "*" << endl;
	else cout << "x" << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n , a[1000000] , frog , memo[1000000] , k;
int f(int n){
	if(n == 1)return 0;
	if(n == 0)return 1e9;
	if(memo[n] != -1)return memo[n];
	memo[n] = 1e9;
	for(int i = 1 ; i <= k ; i++){
		if(n < i)break;
		memo[n] = min(f(n-i) + abs(a[n] - a[n-i]) , memo[n]);
	}
	return memo[n];
}
int main(){
	memset(memo , -1 , sizeof(memo));
	scanf("%d %d" , &n , &k);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d" , &a[i]);
	}
	printf("%d" , f(n));
}

Measured memory_bytes: 11008
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll W,H;
P cost[200010];
int main(){
    cin>>W>>H;
    for(ll i=0;i<W;i++){
        ll p;cin>>p;
        cost[i]=P(p,i);
    }
    for(ll i=0;i<H;i++){
        ll q;cin>>q;
        cost[i+W]=P(q,i+W);
    }
    sort(cost,cost+H+W);
    ll wConnectCnt=0;
    ll hConnectCnt=0;
    ll ans=0;
    for(ll i=0;i<H+W;i++){
        ll num=cost[i].second;
        ll c=cost[i].first;
        if(num<W){//取り出したのがp(横方向の道)なら
            wConnectCnt++;
            ans+=c*(H+1-hConnectCnt);
        }else{
            hConnectCnt++;
            ans+=c*(W+1-wConnectCnt);
        }
    }
    cout<<ans;
}

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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second
#define ff fflush(stdout)

using namespace std;

const int N = 6e6 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main ()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.size() <= k)
	{
		cout << s;
	}
	else {
		for (int i = 0; i < s.size(); i++)
		{
			if (i + 1 <= k)
			{
				cout << s[i];
				continue;
			}
			break;
		}
		cout << "...";
	}
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const ll MAX = 200005;
ll fac[MAX], finv[MAX], inv[MAX];
void cominit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for(ll 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;
    }
}

ll com(ll n, ll k){
    if (n<k) return 0;
    if (n<0 or k<0) return 0;
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 1;
    ll tt = n;
    ll aa = 2;
    while(tt>0){
        if (tt & 1) ans = ans * aa % mod;
        aa = aa * aa % mod;
        tt >>= 1;
    }
    ans--;
    cominit();
    ll tmp = 1;
    ll invv = 1;
    rep(i, a){
        tmp = tmp*(n-i)%mod;
    }
    tmp = tmp*finv[a]%mod;
    ans = ans + mod - tmp;
    ans %= mod;
    tmp = 1;
    invv = 1;
    rep(i, b){
        tmp = tmp*(n-i)%mod;
    }
    tmp = tmp*finv[b]%mod;
    ans = ans + mod-tmp;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
N, M, Q = map(int, input().split())
a,b,c,d = [],[],[],[]
for _ in range(Q):
    ta, tb, tc, td = map(int, input().split())
    a.append(ta)
    b.append(tb)
    c.append(tc)
    d.append(td)

def solve(S):
    out = 0
    for i in range(Q):
        if (S[b[i]-1] - S[a[i]-1]) == c[i]:
            out += d[i]

    return out

def bfs(S,cnt):
    ans = 0
    if cnt == N:
        return solve(S)
    
    for i in range(S[-1], M+1):
        ans = max(ans, bfs(S + [i], cnt + 1))

    return ans

answer = 0
for i in range(1,M+1):
    answer = max(answer, bfs([i], 1))

print(answer)

Measured memory_bytes: 9256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


int main()
{
	double w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans =(double) w * h/2.00;
	int count = 0;
	if (x+x==w&&y+y==h) {
		count+=2;
	}
	cout << setprecision(9) << ans << " ";
	if (count < 2) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> t, x, y;
  t.resize(n);
  x.resize(n);
  y.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }
  int time = 0, posx = 0, posy = 0;
  for (int i = 0; i < n; ++i) {
    int tdiff = t[i] - time;
    int xdiff = abs(x[i] - posx);
    int ydiff = abs(y[i] - posy);
    int posdiff = xdiff + ydiff;
    if (tdiff < posdiff || (posdiff % 2) != (tdiff % 2)) {
      cout << "No\n";
      return 0;
    }
    time = t[i];
    posx = x[i];
    posy = y[i];
  }
  cout << "Yes\n";
}


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

int main(void){
  char str[10];
  int k,x;
  int i;
  
  fgets(str,sizeof(str),stdin);
  k=atoi(strtok(str," "));
  x=atoi(strtok(NULL," "));
  
  for(i=-1000000;i<=1000000;i++){
    if(i>x-k&&i<x+k){
      printf("%d ",i);
    }
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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;}

int main(){
	//input
	ll N; cin>>N;

	if(N%2==0) cout<<(N-1)*(N/2);
	else cout<<((N-1)/2)*N;
}

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

int main(){
  string ADUNYAN = "AIDUNYAN";
  sort(ADUNYAN.begin(), ADUNYAN.end());  
  
  string s;
  cin >> s;
  
  for(int i = 0 ; i < (int)s.size() - 7 ; i++){
    string t = s.substr(i, 8);
    sort(t.begin(), t.end());
    if(t == ADUNYAN){
      s.replace(i, 8, "AIZUNYAN");
      i += 7;
    }
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 1212
#include <cstdio>

int main(){
    int m,f,r;
    for(int i = 0;;i++){
        scanf("%d%d%d",&m,&f,&r);
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        if(m == -1 || f == -1){
            printf("F\n");
            continue;
        }
        if(m + f >= 80){
            printf("A\n");
            continue;
        }
        if(65 <= m + f && m + f< 80){
            printf("B\n");
            continue;
        }
        if(50 <= m + f && m + f < 65){
            printf("C\n");
            continue;
        }
        if(30 <= m + f && m + f < 50){
            if(r >= 50){
                printf("C\n");
                continue;
            }
            printf("D\n");
            continue;
        }
        printf("F\n");
    }
    return 0;
}


Measured memory_bytes: 2584
#include<stdio.h>
int gcd(int p, int q){
  if(p%q==0)return q;
  return gcd(q, p%q);
}
int main(void){
  int k,s=0;
  scanf("%d",&k);
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        s+=gcd(gcd(a, b), c);
      }
    }
  }
  printf("%d",s);
  return 0;
}
  


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
#define pld pair<pll,ll>
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
bool isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a*b)/__gcd(a,b);
}
void solve()
{	
	ll n,m;
	cin>>n>>m;
	ll a[n];
	rep(i,0,n)
	{
		cin>>a[i];
		a[i]=a[i]/2;
	}
	ll l=1;
	for(ll i=0;i<n;i++)
	{
		l=lcm(l,a[i]);
		if(l>m)
		{
			cout<<"0";
			return;
		}
	}
	for(ll i=0;i<n;i++)
	{
		if((l/a[i])%2==0)
		{
			cout<<"0";
			return;
		}
	}
	ll x=(m/l);	
	cout<<(x+1)/2;	//Considering only odd multiples of the LCM(a1,a2,....,an) that are less than m
}	
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
S = input()
OK = True
if 'N' in S:
    if not 'S' in S:
        OK = False
if 'S' in S:
    if not 'N' in S:
        OK = False
if 'E' in S:
    if not 'W' in S:
        OK = False
if 'W' in S:
    if not 'E' in S:
        OK = False
print('Yes' if OK else 'No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;
constexpr ll MOD = 1000000007;

ll fact[200000];
ll factinv[200000];
// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

ll comb(ll n, ll k) {
  return fact[n] * factinv[k] % MOD * factinv[n-k] % MOD;
}

ll calc(const vecll& a, ll k) {
  ll n=a.size();
  ll ans = 0;
  for(auto&& i:irange(k,n+1)) {
    ll tmp = a[i-1] * comb(i-1, k-1) % MOD;
    ans += tmp;
    ans %= MOD;
  }
  return ans;
}

int main()
{
  fact[0] = 1;
  for(auto&& i:irange(0,199999)) {
    fact[i+1] = fact[i] * (i+1) % MOD;
  }
  factinv[199999] = inv(fact[199999], MOD);
  for(auto&& i:irange(0,199999)) {
    int j=199999-i;
    factinv[j-1] = factinv[j] * j % MOD;
  }
  ll n,k;
  cin>>n>>k;
  vecll a(n);
  for(auto&& e:a)cin>>e;
  boost::sort(a);
  ll g = calc(a, k);
  boost::reverse(a);
  ll h = calc(a, k);
  ll ans = (g + (MOD - h)) % MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4096
n, m = map(int, input().split())
c = list(map(int, input().split()))
c.sort() # sortしなくてもこのアルゴリズムは有効

dp = [50001 for i in range(n + 1)]
dp[0] = 0

for i in c:
  for j in range(i, n + 1):
    dp[j] = min(dp[j], dp[j - i] + 1)
    
print(dp[n])


Measured memory_bytes: 7636
<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$m = (int)$input[1];
$end = floor($m/$n);

for($i = $end; $i>0; $i--){
if($m%$i === 0){echo $i; exit();}
}
echo '1';

Measured memory_bytes: 4604
from math import modf


A, B, C = [int(elem) for elem in input().split(' ')]
remainder_set = set()

current_num = A
multiplier = 2
while True:
    remainder = current_num % B
    already_included = remainder in remainder_set
    if already_included:
        break
    else:
        remainder_set.add(remainder)
        current_num = A * multiplier
        multiplier += 1

if C in remainder_set:
    print("YES")
else:
    print("NO")


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

using namespace std;

#define reps(i,f,n) for(int i=f; i<n; ++i)
#define rep(i,n) reps(i,0,n)

pair<int, int> calc(vector<pair<char, int>>& exp, int h, int lv)
{
    char c = exp[h].first;
    vector<int> v;
    
    if(isdigit(c)){
        return {h+1, c-'0'};
    }
    
    for(h++; h<exp.size() && exp[h].second > lv; ){
        auto ret = calc(exp, h, lv+1);
        v.push_back(ret.second);
        h = ret.first;
    }
    
    int ans;
    
    if(c == '+'){
        ans = 0;
        for(int x : v) ans += x;
    }
    else{
        ans = 1;
        for(int x : v) ans *= x;
    }
    
    return {h, ans};
}

void solve(int n)
{
    vector<pair<char, int>> exp(n);
    
    rep(i, n){
        string s;
        cin >> s;
        exp[i].first  = s[s.size()-1];
        exp[i].second = s.size() - 1;
    }
    
    cout << calc(exp, 0, 0).second << endl;
}

int main()
{
    int n;
    
    while(cin >> n, n){
        solve(n);
    }
}

Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n, r; cin >> n >> r;
    int k = 0;
    if(n < 10) k = r + (10 - n) * 100 ;
    else k = r;
    cout << k << endl;
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[])
{
  for(;;) {
    string str;
    getline(cin, str);
    int l = str.length();
    if(l == 1) break;
    auto check = [l, &str]() {
      vector<char> st;
      for(int i = 0; i < l; i++) {
        char c = str[i];
        if(c == '(' || c == '[') {
          st.push_back(c);
        } else if(c == ')') {
          if(st.size() == 0) return false;
          if(st.back() == '(') {
            st.pop_back();
          } else {
            return false;
          }
        } else if(c == ']') {
          if(st.size() == 0) return false;
          if(st.back() == '[') {
            st.pop_back();
          } else {
            return false;
          }
        }
      }
      return st.size() == 0;
    };
    cout << (check() ? "yes" : "no") << endl;
  }
  return 0;
}

Measured memory_bytes: 3164
n = gets.to_s.to_i
s = gets.to_s.chomp.split('')

cnt = 0
n.times do |i|
  j = i + 1
  k = i + 2
  while k < n
    cnt += 1 if s[i] != s[j] && s[j] != s[k] && s[i] != s[k]
    j += 1
    k += 2
  end
end

puts s.count('R') * s.count('G') * s.count('B') - cnt

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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
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; }


void solve(long long N, long long K, vector<long long> p){
    // 累積和を前計算
    vector<int> s(N+1, 0);
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + p[i];

    // 答えを求める
    ll INF = 1LL << 60;
    long long res = -INF; // 最初は無限小の値に初期化しておく
    ll max_index = 0;
    for (int i = 0; i <= N-K; ++i) {
        long long val = s[K+i] - s[i];
        if (res < val) {
            res = val;
            max_index = i;
        }
    }

    /* double max = -100.0; */
    double pp;
    ll i = max_index;
    double sum_e = 0;
    rep(k, K) {
        pp = double(p[i+k]);
        sum_e += (pp * (pp+1) / 2.0) / pp;
    }
    printf("%lf\n", sum_e);
    /* rep(i, N-K+1) { */
    /*     double sum_e = 0; */
    /*     rep(k, K) { */
    /*         pp = double(p[i+k]); */
    /*         sum_e += (pp * (pp+1) / 2.0) / pp; */
    /*     } */
    /*     if (max <= sum_e) { */
    /*         max = sum_e; */
    /*     } */
    /* } */
    /* printf("%lf\n", max); */

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    long long K;
    cin >> K;
    vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> p[i];
    }
    solve(N, K, move(p));
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int n, mn=1e9;
int f(int p, int q) {return p ? f(p/q, q) + p%q : 0;}
int main() {
	cin>>n;
	for(int i=0; i<=n; i++) mn = min(mn, f(i,6) + f(n-i,9));
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    n = int(input())
    h = list(map(int, input().split()))

    dp = [0, abs(h[0]-h[1])]
    for i in range(2, n):
        from_2 = dp[i-2] + abs(h[i-2] - h[i])
        from_1 = dp[i-1] + abs(h[i-1] - h[i])
        dp.append(min(from_2, from_1))
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 20412
N, M, K = [int(v) for v in input().strip().split(" ")]
A = [int(v) for v in input().strip().split(" ")]
B = [int(v) for v in input().strip().split(" ")]

a, b = [0], [0]
max_sum = 0

for i in range(len(A)):
    a.append(a[i] + A[i])

for j in range(len(B)):
    b.append(b[j] + B[j])

j = len(B)
for i in range(len(A)+1):
    if a[i] > K:
        continue
    else:
        while b[j] > K - a[i]:
            j -= 1
        max_sum = max(max_sum, i + j)

print(max_sum)


Measured memory_bytes: 48392
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
N = int(input())
# N=3
# M=1
# A=[5,4,2,1]
 
cnt = 0
cnt1 = 0
 
# for i in range(N):
#     cnt = cnt + A[i]
#
# for i in range(N):
#     if A[i] / cnt > 1 / 4 / M:
#         cnt1 = cnt1 + 1
 
sum=0
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N + 1):
            sum =sum + gcd(i,j,k)
            # print(i,j,k)
 
# a1 = N % 10
# a2 = ((N-a1*10) % 100)/10
# a3 = ((N-a1*100-a2*10))/100
 
print(sum)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b;
	ll k;
	//string s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> x;

	if (x < 1200) s_ans = "ABC";
	else s_ans = "ARC";

	cout << s_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 256
s = input()
if 'N' in s:
    if 'S' not in s:
        print('No')
        exit()
if 'S' in s:
    if 'N' not in s:
        print('No')
        exit()
if 'E' in s:
    if 'W' not in s:
        print('No')
        exit()
if 'W' in s:
    if 'E' not in s:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 2940
// Problem: A - Calc
// Contest: AtCoder - AtCoder Beginner Contest 172
// URL: https://atcoder.jp/contests/abc172/tasks/abc172_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int n;
           cin >> n;
           
           cout << n + (n * n) + (n * n * n) << endl;
        }
    }



Measured memory_bytes: 3556
import Control.Monad (replicateM,when,forM_)
import Control.Monad.ST (ST)
import Data.Array.Unboxed (UArray,elems)
import qualified Data.Array.ST as STArr

type Test = ((Int,Int,Int),Bool)
type Checks = UArray Int Int

main = do
    [a,b,c] <- getLine >>= (return . map read . words)
    if all (==0) [a,b,c] then return () else do
        n <- readLn
        ts <- replicateM n (getLine >>= return . test . map read . words)
        forM_ (elems $ checks (a+b+c) ts) print

        main

    where
    test [a,b,c,1] = ((a,b,c),True)
    test [a,b,c,0] = ((a,b,c),False)

checks :: Int -> [Test] -> Checks
checks m ts = STArr.runSTUArray $ do
    chks <- init m
    forM_ (map fst $ filter snd ts) (applyCollect chks)
    forM_ (map fst $ filter (not . snd) ts) (applyWrong chks)
    return chks

    where
    init m = STArr.newArray (1,m) 2

    applyCollect chks (a,b,c) = do
        STArr.writeArray chks a 1
        STArr.writeArray chks b 1
        STArr.writeArray chks c 1

    applyWrong chks (a,b,c) = do
        ca <- STArr.readArray chks a
        cb <- STArr.readArray chks b
        cc <- STArr.readArray chks c
        when ((ca,cb,cc) == (2,1,1)) (STArr.writeArray chks a 0)
        when ((ca,cb,cc) == (1,2,1)) (STArr.writeArray chks b 0)
        when ((ca,cb,cc) == (1,1,2)) (STArr.writeArray chks c 0)

Measured memory_bytes: 5696
#!/usr/bin/env python3
import sys


def solve(N: int, R: int):
    if N>=10:
        print(R)
    else:
        ans=100*(10-N)+R
        print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(N, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

long smax=0;
long smin=0;
long res_min=1e13;

void divide2(int H,int W){
  if(H%2==0 || W%2==0){
    smin=(long)H*(long)W/2;
    smax=(long)H*(long)W/2;
  }else{
    if(H>W){
      int half=H/2;
      smin=(long)half*(long)W;
      smax=smin+W;
    }else{
      int half=W/2;
      smin=(long)half*(long)H;
      smax=smin+H;
    }
  }
}

void divide3(int H,int W){
  if(H%3==0||W%3==0){
    smin=0;
    smax=0;
    res_min=0;
  }else{
    for(int i=H/3;i<=H/3+1;i++){
      divide2(H-i,W);
      long tmp=(long)i*(long)W;
      smax=smax>tmp?smax:tmp;
      smin=tmp>smin?smin:tmp;
      if(res_min>(smax-smin))
	res_min=smax-smin;
    }
    for(int i=W/3;i<=W/3+1;i++){
      divide2(H,W-i);
      long tmp=(long)i*(long)H;
      smax=smax>tmp?smax:tmp;
      smin=tmp>smin?smin:tmp;
      if(res_min>(smax-smin))
	res_min=smax-smin;
    }
  }
}

int main(){
  int H=0,W=0;
  cin>>H>>W;
  divide3(H,W);
  cout<<res_min<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100,mod=1e9+7;
int n,h[N+1];
int f[N+1][N+1];
int pow(int x,int times)
{
	int ret=1;
	while(times) {
		if(times&1) {
			ret=1ll*ret*x%mod;
		}
		times>>=1,x=1ll*x*x%mod;
	}
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",&h[i]);
	}
	h[0]=1,f[0][0]=1;
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=n;++j) {
			if(h[j]>h[i]) {
				continue;
			}
			if(h[j]<h[i-1]) {
				if(h[i]<h[i-1]) {
					f[i][j]=(f[i-1][j]+f[i-1][i])%mod;
				} else {
					f[i][j]=1ll*(f[i-1][j]+f[i-1][i-1])*pow(2,h[i]-h[i-1])%mod;
				}
			} else {
				f[i][j]=2ll*f[i-1][i-1]*pow(2,h[i]-h[j])%mod;
			}
		}
	}
	printf("%d\n",f[n][0]);
	return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

int main()
{
	fastIO;
	int r, c, k; cin >> r >> c >> k;
	vector<vll> v(r + 1,vll(c + 1));
	vector<vector<vll>> dp(r + 1,vector<vll>(c + 1,vll(4,0)));
	vector<set<ll>> s(r);

	for(int i = 0; i < k; i++)
	{
		int x, y;
		cin >> x >> y;
		cin >> v[x][y];
	}

	for(int i = 1; i <= r; i++)
		for(int j = 1; j <= c; j++)
		{
			for(int k = 1; k < 4; k++)
				dp[i][j][k] = max(dp[i][j - 1][k],max(dp[i][j - 1][k - 1] + v[i][j],dp[i - 1][j][3] + v[i][j]));

			// for(int i = r - 1; i >= 0; i--)
			// {
			// 	for(int j = 0; j < c; j++)
			// 	{
			// 		for(int k = 0; k < 4; k++)
			// 			printf("%3d ", dp[i][j][k]);
			// 		printf("   ");
			// 	}
			// 	printf("\n");
			// }
			// printf("\n");
		}

	cout << dp[r][c][3] << endl;

	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    ll cur = 1;
    while (cur <= N) {
        cur <<= 1;
    }
    cur >>= 1;
    cout << cur << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, T; cin >> n >> T;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    ll ans = 0;
    rep(i,n-1){
        if(t[i+1] - t[i] > T) ans += T;
        else ans += t[i+1] - t[i];
    }
    ans += T;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int r; cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }else if(r<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a=input().split()
min=1001
for i in range(int(a[0])):
    aa=input().split()
    if int(aa[1])<=int(a[1]) and int(aa[0])<min:
        min=int(aa[0])
if min==1001:
    print("TLE")
else:
    print(min)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main (){
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
 
void mincount();
int n,m[100][100],r[100];
 
main(){
  int c[100],i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&r[i],&c[i]);
    if(i == n-1) r[i+1]=c[i];
  }
  mincount();
  printf("%d\n",m[1][n]);
  return 0;
}
 
void mincount(){
  int q,i,j,k,l;
  for(i = 0 ;  i < n+1 ; i++) m[i][i]=0;
  for(l = 2 ; l < n+1 ;l++){
    for(i= 1 ; i < n-l+2 ; i++){
      j = i + l - 1;
      m[i][j]=1000000;
      for(k = i ; k < j ; k++){
    q = m[i][k] + m[k+1][j] + r[i-1] * r[k] * r[j];
    if(m[i][j] > q) m[i][j] = q;
      }
    }
  } 
}

Measured memory_bytes: 636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace A {
	class main {
		public main() { }
		public static int Main() {
			new main().run();
            return 0;
        }
		void run() {
			Scanner cin = new Scanner();
			while(true) {
				int n = cin.nextInt();
				if(n==0) break;
				for(int i=0; i<n; i++) {
					int m = cin.nextInt();
					int e = cin.nextInt();
					int j = cin.nextInt();
					string s;
					if(m==100 || e==100 || j==100) s="A";
					else if((m+e)/2>=90) s="A";
					else if((m+e+j)/3>=80) s="A";
					else if((m+e+j)/3>=70) s="B";
					else if((m+e+j)/3>=50 && (m>=80 || e>=80)) s="B";
					else s="C";
					Console.WriteLine(s);
				}
			}
		}
	}

	class Scanner {
		string[] s;
		int i;
		
		char[] cs = new char[] { ' ' };
		
		public Scanner() {
			s = new string[0];
			i = 0;
		}
		public string next() {
			if (i < s.Length) return s[i++];
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 0;
			return s[i++];
		}
		public int nextInt() {
			return int.Parse(next());
		}
		public long nextLong() {
			return long.Parse(next());
		}
		public double nextDouble() {
			return double.Parse(next());
		}
	}
}


Measured memory_bytes: 5380
s = input()
s_li = list(s)
k = int(input())

alp = list('abcdefghijklmnopqrstuvwxyz')
moji_li = []
count_li = []
for ss in s_li:
    ind = alp.index(ss)
    moji_li.append(alp.index(ss))
    count_li.append(26 - alp.index(ss))
for i,c in enumerate(count_li):
    #print(i,len(count_li)-1)
    if i == len(count_li)-1:
        moji_li[i]+= k
        break
    else:
        if c == 26:
            continue
        if c<=k:
            k-=c
            moji_li[i]=0
ans = ''
#print('count_li',count_li)
#print(moji_li)
for m in moji_li:
    ans += alp[m%26]
print(ans)

Measured memory_bytes: 11600
S = input()
a = int(S[:2])
b = int(S[2:])
if 1 <= a <= 12:
    yy = True
else:
    yy = False
if 1 <= b <= 12:
    mm = True
else:
    mm = False
if yy and mm:
    print("AMBIGUOUS")
elif yy:
    print("MMYY")
elif mm:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> a(n),b(n);
  for(auto &x:a) cin >> x;
  for(auto &x:b) cin >> x;
  LL answer = 0;
  REP(i,30) {
    LL d = (1<<i);
    LL mask = d*2-1;
    vector<LL> xa(n),xb(n);
    REP(i,n) {
      xa[i] = (a[i] & mask);
      xb[i] = (b[i] & mask);
    }
    sort(xa.begin(),xa.end());
    LL tmp = 0;
    for(auto x:xb) {
      tmp += lower_bound(xa.begin(),xa.end(),d*4-x) -
        lower_bound(xa.begin(),xa.end(),d*3-x);
      tmp += lower_bound(xa.begin(),xa.end(),d*2-x) -
        lower_bound(xa.begin(),xa.end(),d-x);
    }
    if(tmp%2) answer += d;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 6552
#include <bits/stdc++.h>
#define pii pair<int,int>
#define eb emplace_back
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, mx=1e9+1;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    sort(v.begin(),v.end(),greater<int>());
    int ans = v[0];
    int t = 2, i=1;
    bool x = false;
    while( t<n )
    {
        ans += v[i];
        i += x;
        x = !x;
        t++;
    }
    cout << ans;
}

Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, d;
int x[10][10];
bool heiho[1000001];

signed main() {
	int i, j, k;
	
	cin >> n >> d;
	rep(i, n) {
		rep(j, d) cin >> x[i][j];
	}
	
	rep(i, 1000) {
		heiho[i * i] = true;
	}
	
	int ans = 0;
	rep(i, n) {
		for (j = i + 1; j < n; j++) {
			int ssum = 0;
			rep(k, d) {
				int p = x[i][k] - x[j][k];
				ssum += p * p;
			}
			if (heiho[ssum]) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  int F = 0;
  int T = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0) {
      F++;
    }
    else if (a % 2 == 0) {
      T++;
    }
  }
  if (T == 0) {
    T = 1;
  }
  if ((F * 2 + T) >= N) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b) {
            if (c < a) {
                System.out.printf("%d %d %d\n", c, a, b);
            } else if (c < b) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", a, b, c);
            }
        }else {
            if (c < b) {
                System.out.printf("%d %d %d\n", c, b, a);
            }else if(c < a){
                System.out.printf("%d %d %d\n", b, c, a);
            }else{
                System.out.printf("%d %d %d\n", b, a, c);
            }
        }
    }
}



Measured memory_bytes: 26308
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  vector<int>copy=a;
  sort(a.begin(),a.end());
  int ma=a[n-1];
  for(int i=0;i<n;i++){
    if(copy[i]!=ma){
      cout<<a[n-1]<<endl;
    }
    else{
      cout<<a[n-2]<<endl;
    }
  }
}

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

#define int long long
#define F first
#define S second

const int MAXM = 6 * 100 * 1000;
const int MOD = 1000 * 1000 * 1000 + 7;
int tav[MAXM], a[MAXM];

int32_t main() {
	ios::sync_with_stdio(false);
	tav[0] = 1;
	for (int i = 1; i < MAXM; i++) {
		tav[i] = tav[i - 1] * 2 % MOD;
	}
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		ans = (ans + a[i] * tav[2 * n - 2] % MOD * (n - i + 1) % MOD) % MOD;
//		cerr << ans << endl;
	cout << ans;
}



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

#define PI 3.1415926535

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i <s.size();i++){
        if(s.at(i)+n<='Z') s.at(i) += n;
        else {
             'Z' - s.at(i);
             s.at(i) = s.at(i)-(26-n);
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef unsigned long long ll;
    typedef long long ull;

    int main(){

        int a;
        cin >> a;

        int b = a%10;
        if(b==2||b==4||b==5||b==7||b==9)
            cout << "hon";
        else if(b==0||b==1||b==6||b==8){
            cout << "pon";
        }
        else
            cout <<    "bon";

        return 0;
    }









Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, k, h[100100], dp[100100];

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 100100; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint A, B;
	cin >> A >> B;
	cout << A * B << enld;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = N - K + 1;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972