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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

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

  vector<int> cs(n + 1);
  for (int x : xs) cs[x]++;

  vector<int> indexes;
  for (int i = 0; i < n + 1; i++) {
    if(cs[xs[i]] == 2) {
      indexes.push_back(i);
    }
  }
  int i1 = indexes[0];
  int i2 = indexes[1];
  int m = n + 1 - (i2 - i1) - 1;
  // cout << "m: " << m << endl;

  vector<FiniteField> factorials(n + 1);
  vector<FiniteField> inverse_factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  inverse_factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    inverse_factorials[i] = inverse_factorials[i - 1] / i;
  }
  // inverse_factorials[n] = FiniteField(1) / factorials[n];
  // for (int i = n; i >= 1; i--) {
  //   inverse_factorials[i - 1] = inverse_factorials[i] * i;
  // }

  auto c_fn = [&](int a, int b) -> FiniteField {
    if (a < b) return 0;
    auto v = factorials[a] * inverse_factorials[b] * inverse_factorials[a - b];
    // cout << "a: " << a << " b: " << b << " v: " << v.Value() << endl;
    return v;
  };

  for (int k = 1; k <= n + 1; k++) {
    if (k == 1) {
      cout << FiniteField(n).Value() << endl;
    } else {
      FiniteField ans = 0;
      if (k <= n - 1) ans += c_fn(n - 1, k);
      if (k <= n) ans += c_fn(n - 1, k - 1) * 2 - c_fn(m, k - 1);
      ans += c_fn(n - 1, k - 2);
      cout << ans.Value() << "\n";
    }
  }
}

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

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  vll a(7);
  repeat(i,7) cin >> a[i];
  ll K = a[1];
  if(1&a[0]&a[3]&a[4]||!(1&(a[0]|a[3]|a[4]))){
    K += a[0]+a[3]+a[4];
  }else if(1&(a[0]^a[3]^a[4])){
    K += a[0]+a[3]+a[4]-1;
  }else if(!(a[0]*a[3]*a[4])){
    K += a[0]+a[3]+a[4]-2;
  }else{
    K += a[0]+a[3]+a[4]-1;
  }
  cout << K << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
int main()
{
    string s;
    cin>>s;
    ll l=s.length();
    cout<<s;
    if(s[l-1]=='s')
        cout<<"es"<<endl;
    else
        cout<<"s"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, m;
    cin >> n >> m;
    map<int, int> um;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        um[x]++;
    }
    vector<int> modm(m);
    vector<int> mul(m);
    auto itr = um.begin();
    while(itr != um.end())
    {
        int v = itr->first;
        int count = itr->second;
        modm[v % m] += count;
        mul[v % m] += count / 2;
        itr++;
    }

    int ans = modm[0] / 2;
    for(int i = 1; i <= m/2; i++)
    {
        if(i == m/2 && m%2 == 0)
        {
            ans += modm[i] / 2;
            continue;
        }
        int pos;
        if(modm[i] > modm[m-i]) pos = i;
        else pos = m-i;
        int h = max(modm[i], modm[m-i]);
        int l = min(modm[i], modm[m-i]);
        ans += l;
        int more = h - l;
        ans += min(more / 2, mul[pos]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {

  int n, x;
  cin >> n >> x;
  vector<int> a(2*n, -1);
  if( x == 1 || x == 2*n-1 ){
    cout << "No" << endl;
    return 0;
  }
  if( n == 2 ){
    cout << "Yes" << endl;
    cout << "1 2 3" << endl;
    return 0;
  }
  vector<bool> b(2*n, false);
  if( x == 2 ){
    a[n] = x;
    a[n-1] = x+1;
    a[n+1] = x-1;
    a[n+2] = x+2;
    b[x] = true;
    b[x+1] = true;
    b[x-1] = true;
    b[x+2] = true;
  }else {
    a[n] = x;
    a[n-1] = x-1;
    a[n+1] = x+1;
    a[n+2] = x-2;
    b[x] = true;
    b[x+1] = true;
    b[x-1] = true;
    b[x-2] = true;
  }

  int p = 1;
  for(int i=1; i<2*n; i++){
    while(b[p]) p++;

    if( a[i] == -1 ){
      b[p] = true;
      a[i] = p;
    }
  }

  cout << "Yes" << endl;
  for(int i=1; i<2*n; i++){
    cout << a[i] << " ";
  }
  cout << endl;

  return 0;
}

//


Measured memory_bytes: 2304
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
    #define ll long long int
    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #define all(a) (a).begin(), (a).end()
    #define sz size
    #define f first
    #define s second
    #define pb push_back
    #define er erase
    #define in insert
    #define mp make_pair
    #define pi pair
    #define rc(s) return cout<<s,0
    #define mod 1000000007
    #define PI 3.14159265359
    #define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
    using namespace std;
    ll n;
    string s;
    int32_t main(){
    CODE_START;
  cin>>s;
  if(s=="Sunny"){
      cout<<"Cloudy";
  }else if(s=="Cloudy"){
      cout<<"Rainy";
  }else if(s=="Rainy"){
      cout<<"Sunny";
  }
    }
   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;



int main()
{
    idfc;

    ll n,d;
    cin>>n>>d;

    ll ans=0;
    ll a,b;
    d*=d;
    ll p;
    while(n--)
    {
        cin>>a>>b;
        p=(a*a)+(b*b);
        if(d>=p)ans++;
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 3652
N,K=map(int,input().split())
point=[list(map(int,input().split())) for _ in range(N)]
ans=10**30
#print(ans)
#print(Decimal(1999999999)*Decimal(1999999999))
#print(1999999999*1999999999)
for i in range(N):
    for j in range(i,N):
        x1,_=point[i]
        x2,_=point[j]
        minx=min(x1,x2)
        maxx=max(x1,x2)
        for k in range(N):
            for l in range(k,N):
                _,y1= point[k]
                _,y2= point[l]
                miny = min(y1,y2)
                maxy = max(y1,y2)
                cnt=0
                menseki=(maxx-minx)*(maxy-miny)
                for m in range(N):
                    x,y=point[m]
                    if (minx<=x<=maxx)and(miny<=y<=maxy):
                        cnt=cnt+1
                if cnt>=K:
                    ans=min(ans,menseki)
print(ans)

"""
for i in range(N):
    for j in range(i+1,N):
        #print(i,j)
        menseki=Decimal(1)
        x1,y1=point[i]
        x2,y2=point[j]
        if x1<x2:
            abx=Decimal(x2)-Decimal(x1)
        else:
            abx=Decimal(x1)-Decimal(x2)
        if y1<y2:
            aby=Decimal(y2)-Decimal(y1)
        else:
            aby=Decimal(y1)-Decimal(y2)
        print("")
        print(abx,aby)
        menseki=abx*aby
        print(menseki)
        minx=min(x1,x2)
        maxx=max(x1,x2)
        miny=min(y1,y2)
        maxy=max(y1,y2)
        pnum=0
        print(minx,maxx,miny,maxy)
        for x,y in point:
            #print(x,y)
            if (minx<=x<=maxx)and(miny<=y<=maxy):
                pnum=pnum+1
        print(pnum)
        if pnum>=K:
            ans=ans.min(menseki)
            print(ans)
print(ans)
"""

Measured memory_bytes: 75840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d)cout<<"Yes"<<endl;
  else if(abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
    long long int n, a=100, count=0;
    scanf("%lld", &n);
    while(a<n){
    	a=a+(a/100);
    	count++;
	}
	printf("%lld\n", count);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        ll res=0ll;
        for(int i=1;i<=n;++i){
            int x;
            cin>>x;

            while(x%2==0){
                ++res;
                x/=2;
            }
        }

        printf("%lld\n", res);




        //printf("Case %d: ",++te);
    }
    return 0;
}

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

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

  sort(a.begin(),a.end());
  vector<int> div0, div1;
  for(int i=1; i<=sqrt(a[0]); ++i)if(a[0]%i==0){div0.push_back(i); div0.push_back(a[0]/i);}
  for(int i=1; i<=sqrt(a[1]); ++i)if(a[1]%i==0){div1.push_back(i); div1.push_back(a[1]/i);}
  
  sort(div0.begin(), div0.end());
  sort(div1.begin(), div1.end());

  int ans0,ans1;
  
  for(int i=div0.size()-1; i>=0; --i){
    int dum=0;
    for(int j=0; j<n; ++j)if(a[j]%div0[i]!=0)++dum;
    if(dum<=1){ans0=div0[i]; break;}
  }
  
  for(int i=div1.size()-1; i>=0; --i){
    int dum=0;
    for(int j=0; j<n; ++j)if(a[j]%div1[i]!=0)++dum;
    if(dum<=1){ans1=div1[i]; break;}
  }
  cout<<max(ans0,ans1)<<endl;
}


Measured memory_bytes: 640
<?php

    $N = intval(trim(fgets(STDIN)));
    $s = trim(fgets(STDIN));
    $S = str_split($s);
    
    for($i=0;$i<strlen($s);$i++){
        $num = ord($S[$i])+$N;
        if($num>ord("Z")){
            $num = $num - 26;
        }
        
        echo chr($num);
    }
    
    
?>

Measured memory_bytes: 16720
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
int n;cin>>n;int t[n+1];int m,a,b;long long s=0,p;
for(int i=1;i<=n;i++)
{cin>>t[i];s+=t[i];}
cin>>m;
for(int i=0;i<m;i++)
{p=s;
	cin>>a>>b;
	cout<<p-t[a]+b<<"\n";
	
}

return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  int count;
  int max = 0;
  int ans = 1;
  rep(i, n){
    count = 0;
    int num = i;
    while(1){
      if (num % 2 == 1) break;
      if (num == 0) break;
      num /= 2;
      ++count;
    }
    if (max < count){
      max = count;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<cstdio>
const static int MAX_A = 100000;
unsigned Bucket[MAX_A];

int main(){
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i){
		unsigned tmp;
		scanf("%u", &tmp);
		Bucket[tmp-1]++;
	}
	unsigned answer = 0;
	bool even = false;
	for (int i = 0; i < MAX_A; ++i){
		if(Bucket[i]){
			answer++;
			if(!(Bucket[i] & 1)) even ^= true;
		}
	}
	if(even) answer--;
	printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
struct Cube{
    /**
    *   0
    * 3 1 2 4
    *   5
    * <:y ^:x <>:z
    **/
    Cube(){}
    int d[6];
    void roll(int i,int j,int k,int l){
        int t=d[i];d[i]=d[j];d[j]=d[k];d[k]=d[l];d[l]=t;
    }
    
    void z(){roll(1,2,4,3);}
    void y(){roll(0,2,5,3);}
    void x(){roll(0,1,5,4);}
    
    void n(){x();}
    void s(){x(),x(),x();}
    void e(){y(),y(),y();}
    void w(){y();}
    
    int getRight(int top,int front){
        int right;
        for(int i=0;i<6;++i){
            for(int j=0;j<4;++j){
                if(d[0]==top&&d[1]==front)right=d[2];
                z();
            }
            if(i&1)x();
            else y();
        }
        return right;
    }
};
int getRight(Cube c,int top,int front){
    int right;
    for(int i=0;i<6;++i){
        for(int j=0;j<4;++j){
            if(c.d[0]==top&&c.d[1]==front)return c.d[2];
            c.z();
        }
        if(i&1)c.x();
        else c.y();
    }
    return right;
}
int main(){
  Cube c;
  int n;
  for(int i=0;i<6;++i)cin>>c.d[i];
  cin>>n;
  for(int i=0;i<n;++i){
    int x,y;
    cin>>x>>y;
    cout<<getRight(c,x,y)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,a[3],maxi=0,pos,tt=0;
    cin >> a[0] >> a[1] >>a[2];
    for(i=0;i<3;i++){
        if(a[i]>maxi){
            maxi = a[i];
            pos = i;
        }
    }
    for(i=0;i<3;i++){
        if(i!=pos){
            tt+=a[i];
        }
    }
    cout << tt;
}

Measured memory_bytes: 256
// agc041_a
#include <iostream>
#include <math.h>
#include <cstring>
#include <iomanip>
#include <algorithm>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

int main(int argc, char const *argv[])
{
    UL n, a, b, out;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0)
        out = (b - a) / 2;
    else if ((b - a) == 1)
        out = min(n - a, b - 1);
    else
        out = min((n - b + 1) + ((b -a - 1) / 2), a + ((b - a - 1) / 2));
    cout << out << endl;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    char s[101], t[101];
    scanf("%s", s);
    scanf("%s", t);
    int n = 0;
    for(int i = 0; s[i] != 0; i++){
        n++;
    }
    
    for(int i = 0; i < n; i++){
        bool flag = true;
        for(int j = 0; j < n; j++){
            int index;
            if (j + i < n){
                index = j + i;
            }else{
                index = j + i - n;
            }
            if (s[j] != t[index]){
                flag = false;
                break;
            }
        }
        if (flag){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    
}

Measured memory_bytes: 128
n,k = map(int,input().split())

dic = {}

for i in range(n):
    a,b = map(int,input().split())
    if a in dic.keys():
        dic[a] += b 
    else:
        dic[a] = b 
        
keys = list(dic.keys())
keys.sort()
for i in keys:
    k -= dic[i]
    if k <= 0:
        ans = i
        break

print(ans)

Measured memory_bytes: 10592
from sys import stdin
x, y = map(int, stdin.readline().rstrip().split())

res = 'No'

if y%2 == 1: #偶数だけ
    print(res)
elif x*4 == y or x*2 == y:
    print('Yes')

else:
    for i in range(1, x):
        if i*4 + (x-i)*2 == y:
            res = 'Yes'

    print(res)




Measured memory_bytes: 9184
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

void prints(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << "\n";
}

void selectionSort(int a[], int n) {
	int j, minJ, c = 0;
	for (int i = 0; i < n; i++) {
		minJ = i;
		for (j = i; j < n; j++) {
			if (a[j] < a[minJ]) {
				minJ = j;
			}
		}
		if (i != minJ) {
			swap(a[i], a[minJ]);
			c++;
		}
	}

	prints(a, n);
	cout << c << "\n";
}

int main()
{
	int n, a[100];
	cin >> n;

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

	selectionSort(a, n);
}


Measured memory_bytes: 3104
import math

def main():

    k = int(input())
    
    r = range(1,k+1)

    #because gcd can only appear in this range
    count = [0]*201
    
    for i in r:
        for j in r:
            count[math.gcd(i,j)] += 1
    
    final = 0
    
    for i in range(1,201):
        if count[i] > 0:
            for j in r:
                final += count[i]*math.gcd(i,j)
    
    print(final)


main()


Measured memory_bytes: 9188
s = gets.chomp.chars
t = gets.chomp.chars


ans = "z" * s.size
restorable = false

(0..(s.size-t.size)).each do |i|
  chars = s[i,t.size]
  valid = true

  chars.each_with_index do |c, j|
    if c == t[j] || c == "?"
      next
    else
      valid = false
    end
  end

  if valid
    restorable = true
    tmp = s[0...i] + t + s[i+t.size..-1]
    ans = [tmp.join.gsub("?", "a"), ans].min
  end
end

if !restorable
  ans = "UNRESTORABLE"
end

puts ans

Measured memory_bytes: 2044
#include <vector>
#include <iostream>
using namespace std;
#define int long long

long long INF = 1LL << 60;

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  vector<vector<int>> dp(N, vector<int>(2, -INF));
  dp[1][0] = A[0];
  dp[1][1] = -A[0];
  
  for (int i = 1; i < N - 1; i++) {
    dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
    dp[i+1][1] = max(dp[i][1] + A[i], dp[i][0] - A[i]);
  }
  
  cout << max(dp[N-1][0] + A[N-1], dp[N-1][1] - A[N-1]) << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int h,a;cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll n;
  cin>>n;
  op((n-2)*180);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string b;
  cin >> b;
  if(b=="A"){
    cout << "T" << endl;
  }
  if(b=="T"){
    cout << "A" << endl;
  }
  if(b=="C"){
    cout << "G" << endl;
  }
  if(b=="G"){
    cout << "C" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.util.*

fun main() = abc114d()

@OptIn(ExperimentalStdlibApi::class)
fun abc114d() = SimpleFastIOWithToken_abc114d().exec {
    val n = readLong()

    val pf = mutableMapOf<Long, Long>()
    for (it in 1..n) for ((k, v) in primeFactorization(it)) {
        pf.merge(k, v, Long::plus)
    }

    fun count(x: Long) = pf.count { it.value >= x - 1 }

    val answer = count(75) +
            count(25) * (count(3) - 1) +
            count(15) * (count(5) - 1) +
            count(5) * (count(5) - 1) * (count(3) - 2) / 2

    println(answer)
}

private fun primeFactorization(n: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    var temp = n
    var i = 2L
    while (i * i <= temp) {
        while (temp % i == 0L) {
            factors[i] = (factors[i] ?: 0) + 1
            temp /= i
        }
        i++
    }
    if (temp > 1) factors[temp] = 1
    return factors
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc114d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc114d.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 34936
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();
        int a = scan.nextInt();
        long b = scan.nextLong();
        int[] h = new int[N];
        for(int i = 0; i < N; i++) {
            h[i] = scan.nextInt();
        }

        int l = 0;
        int r = 1000000001;
        while(l<r-1) {
            long count = 0;
            long[] k = new long[N];
            for(int i = 0; i < N; i++) {
                k[i] = h[i];
            }
            int m = (l+r)/2;
            for(int  i = 0; i < N; i++) {
                k[i] -= b*m;
                if(k[i] > 0) {
                    if(k[i]%(a-b)==0) {
                        count += k[i]/(a-b);
                    }
                    else {
                        count = count + (k[i]/(a-b)) + 1;
                    }
                }
            }
            if(count > m) {
                l = m;
            }
            else if(count <= m) {
                r = m;
            }
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 62468
#include<iostream>
using namespace std;
int main(){
int n;
  cin>>n;
  int p[n];
  for (int i=0; i<n; i++) cin>>p[i];
  int counter=0;
  for (int i=1; i<n-1; i++) {
 if ((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1])) counter++;
  }
  cout<<counter<<endl;}
                               

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

using namespace std;

int main()
{
  int n;

  cin >> n;

  while(n--){
    int sum = 0;
    
    for(int i = 0; i < 2; i++){
      string s;
      cin >> s;

      int num = 0;
      for(int k = 0; k < s.size(); k++){
	if(s[k] >= '1' && s[k] <= '9'){
	  int a = s[k] - '0';
	  k++;
	  
	  if(s[k] == 'm'){
	    num += 1000*a;
	  }
	  else if(s[k] == 'c'){
	    num += 100*a;
	  }
	  else if(s[k] == 'x'){
	    num += 10*a;
	  }
	  else if(s[k] == 'i'){
	    num += 1*a;
	  }
	}
	else {
	  if(s[k] == 'm'){
	    num += 1000;
	  }
	  else if(s[k] == 'c'){
	    num += 100;
	  }
	  else if(s[k] == 'x'){
	    num += 10;
	  }
	  else if(s[k] == 'i'){
	    num += 1;
	  }
	}
      }
      sum += num;
    }
    //cout << "sum = " << sum << endl;

    if(sum/1000 > 0){
      if(sum/1000 != 1) cout << sum/1000;
      cout << "m";
      sum %= 1000;
    }
    if(sum/100 > 0){
      if(sum/100 != 1) cout << sum/100;
      cout << "c";
      sum %= 100;
    }
    if(sum/10 > 0){
      if(sum/10 != 1) cout << sum/10;
      cout << "x";
      sum %= 10;
    }
    if(sum > 0){
      if(sum != 1) cout << sum;
      cout << "i";
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3004
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut d = 0;
    for _ in 0..n {
        let mut a = read::<usize>();
        while a % 2 == 0 {
            a /= 2;
            d += 1
        }
    }
    println!("{}", d)
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll h,w;
    cin>>h>>w;
    ll k;
    cin>>k;
    vector<string> ar(h);
    for(ll x=0;x<h;x++){
        cin>>ar[x];
    }
    ll ru=1ll<<h,cu=1ll<<w;
    ll ans=0;
    for(ll x=0;x<ru;x++){
        for(ll y=0;y<cu;y++){
            vector<string> temp=ar;
            for(ll r=0;r<h;r++){
                for(ll c=0;c<w;c++){
                    if((x & (1ll<<r)) || (y & (1ll<<c))){
                        temp[r][c]='R';
                    }
                }
            }
            ll count=0;
            for(ll r=0;r<h;r++){
                for(ll c=0;c<w;c++){
                    if(temp[r][c]=='#')count++;
                }
            }
            if(count==k)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
public:
    input()
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var) { return std::cin >> var, *this; }
    template <class T>
    inline input& operator,(T& var) { return *this >> var; }

    template <class T>
    inline T read()
    {
        T var;
        std::cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            std::cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    int a, b, c, d, e, k;
    in >> a, b, c, d, e, k;
    if (e - a > k) {
        out(":(");
    } else {
        out("Yay!");
    }
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

f=max([a,b,c,d,e])
g=min([a,b,c,d,e])
if (f-g)>k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
tbl = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
line = "#" * 20

n = int(input())
for i in range (n):
    b, f, r, v = list(map(int, input().split()))
    tbl[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f" {tbl[i][j][k]}", end = "")
        print()
    if int(i) < 3:
        print(line)


Measured memory_bytes: 5636
#include <iostream>

int main(void){
  int num[10010],i = 0;
  while(1){
    std::cin >> num[i];
    if(num[i] == 0)break;
    std::cout << "Case " << i + 1 << ": " << num[i] << '\n';
    i++;
  }
  return 0;
}


Measured memory_bytes: 3136
import fractions
 
a, b = map(int, input().split())
gcd = fractions.gcd(a, b)
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr

if gcd == 1:
  print(1)
else:
  print(len(factorization(gcd))+1)

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

const ll INF = 1LL << 60;

string S, T;
int main() {
    cin >> S >> T;
    if (T.find(S) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

int main(void){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

count = 0

(0..n-1).each do |i|
  mon = a[i] + a[i+1]
  if mon <= b[i]
    count += mon
    a[i+1] = 0
  else
    if a[i] > b[i]
      count += b[i]
    else
      a[i+1] = mon - b[i]
	  count += b[i]
    end
  end
end

puts count

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

ll gcm(int a,int b) {return b ? gcm(b,a%b) : a;}
ll lcm(int a,int b) {return b / gcm(a,b) * a;}

int main()
{
    int a,b;
    cin >> a >> b;
    ll ans = 0;
    ans = lcm(a,b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = input()

def dfs(i, f, s):
    if i == 3:
        if s==7:
            return f+"=7"
        else:
            return ''
    return dfs(i+1, f+"+"+n[i+1], s+int(n[i+1])) or dfs(i+1, f+"-"+n[i+1], s-int(n[i+1]))

print(dfs(0, n[0], int(n[0])))


Measured memory_bytes: 3060
// Problem : G - Longest Path
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_g
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
vector<vector<int>>adj;
vector<bool>vis;
vector<int>dp;
int dfs(int node)
{
	int ans=0;
	vis[node]=true;
	dp[node]=0;
	for(auto child:adj[node])
	{
		if(!vis[child])
		{
			dfs(child);
		}
		dp[node]=max(dp[node],1+dp[child]);
	}
	return dp[node];
}
void solve(){
	int n,e;
	cin>>n>>e;
	adj.resize(n+1,vector<int>());
	vis.resize(n+1);
	dp.resize(n+1);
	FOR(i,e)
	{
		int u,v;
		cin>>u>>v;
		adj[u].pb(v);
	}
	int ans=0;
	rep(i,1,n+1)
	{
		if(!vis[i])
		{
			ans=max(ans,dfs(i));
		}
	}
	cout<<ans;
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}

Measured memory_bytes: 12144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var list = IntList();
            var ordered = list.OrderBy(x => x).ToList();

            for (int i = 0; i < N; i++) {
                Console.WriteLine(ordered[N / 2] > list[i] ? ordered[N / 2] : ordered[N / 2 - 1]);
            }
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 37448
// UF + MST
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

vector<int> p(100000), r(100000, 1);
int n;

void init(){
    for(int i = 0; i < n; i++)  p[i] = i;
}

int isParent(int x){
    if(x != p[x]){
        p[x] = isParent(p[x]);
    }
    return p[x];
}

void unite(int i, int j){
    int pi = isParent(i), pj = isParent(j);
    if(pi == pj)    return;

    if(r[pi] < r[pj]){
        p[pi] = pj;
        r[pj] += r[pi];
    }else{
        p[pj] = pi;
        r[pi] += r[pj];
    }
}

bool isSame(int i, int j){
    return isParent(i) == isParent(j);
}

struct data{
    int x, y, index;
};

bool compx(data a, data b){
    return a.x < b.x;
}

bool compy(data a, data b){
    return a.y < b.y;
}

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

    vector<data> xa, ya;

    int x, y;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        data d{x, y, i};
        xa.push_back(d);
        ya.push_back(d);
    }

    sort(xa.begin(), xa.end(), compx);
    sort(ya.begin(), ya.end(), compy);

    priority_queue<pair<int,pair<int,int>>> pq;
    
    for(int i = 0; i < n; i++){
        if(i != 0){
            pq.push({-(xa[i].x-xa[i-1].x),{xa[i-1].index, xa[i].index}});
            pq.push({-(ya[i].y-ya[i-1].y),{ya[i-1].index, ya[i].index}});
        }
        if(i != n-1){
            pq.push({-(xa[i+1].x-xa[i].x),{xa[i].index, xa[i+1].index}});
            pq.push({-(ya[i+1].y-ya[i].y),{ya[i].index, ya[i+1].index}});
        }
        
    }

    ll ans = 0;
    while(!pq.empty()){
        auto p = pq.top();  pq.pop();
        int cost = -p.first;
        int i = p.second.first, j = p.second.second;
        if(isSame(i,j)) continue;
        ans += cost;
        unite(i,j);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int h,w;
    cin>>h>>w;
    REP(i,w+2)cout<<'#';cout<<endl;

    REP(i,h){
        string s;
        cin>>s;
        cout<<'#'<<s<<'#'<<endl;
    }
    REP(i,w+2)cout<<'#';cout<<endl;
    
    return 0;
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010
#define MAX_V 		102
#define MAX_E 		10101

const ll LINF = (ll)1e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int prime[MAX];			// 素数を列挙した配列
bool is_prime[MAX+1];	// is_prime[i] = 素数 : true / false

int sieve(int n){
	int p=0;
	//	REP(i,n+1)is_prime[i]=true;
	fill(is_prime,is_prime+MAX+1,true);
	is_prime[0] = is_prime[1] = false;
	REPS(i,2,n+1){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j=2*i;j<=n+1;j+=i)is_prime[j] = false;
		}
	}
}

vector<pair<ll, ll> > prime_factorize(ll n) {
	vector<pair<ll,ll> > res;
	for (ll 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;
}

//
int main(){
	ll A,B;cin >> A >> B;

	ll c = gcd(A,B);

	auto d = prime_factorize(c);
	
	cout << d.size()+1 << endl;

	return 0;
}




Measured memory_bytes: 256
N = int(input())

primes = set(range(2, N+1))
for i in range(2, int(N**0.5+1)):
    primes.difference_update(range(i*2, N+1, i))
primes = list(primes)
primes.sort()

div = [0]*len(primes)

for i in range(2, N+1):
    num = i
    for j, prime in enumerate(primes):
        cnt = 0
        if num < prime: break
        while num%prime == 0:
            cnt += 1
            num //= prime
        div[j] += cnt
        
c74, c24, c14, c4, c2 = 0, 0, 0, 0, 0
for i in div:
    if i>= 74: c74 += 1
    if i >= 24: c24 += 1
    if i >= 14: c14 += 1
    if i >= 4: c4 += 1
    if i >= 2: c2 += 1
ans = 0
ans += c74
ans += (c24) * (c2 - 1)
ans += c14 * (c4 - 1)
ans += (c4) * (c4 - 1) // 2 * (c2 - 2)
print(ans)

Measured memory_bytes: 9288
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;


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

    vector < pair<long long, long long> > BA(N);
    for (int i = 0; i < N; i++){
        long long A, B; cin >> A >> B;
        BA[i].first = B;
        BA[i].second = A;
    }
    sort(BA.begin(), BA.end());

    long long sum = 0;
    bool flag = true;
    for (int i = 0; i < N; i++){
        sum += BA[i].second;
        if (sum > BA[i].first){
            flag = false;
            break;
        }
    }
    
    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3328
/*
                  ,     \    /      ,
                 / \    )\__/(     / \
                /   \  (_\  /_)   /   \
           ____/_____\__\@  @/___/_____\____
          |             |\../|              |
          |              \VV/               |
          |        ------___-------         |
          |__________Chuta Dragon___________|
           |    /\ /      \\       \ /\    |
           |  /   V        ))       V   \  |
           |/     `       //        '     \|
           `              V                '
        */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cin>>ara[i];
}

#define eb emplace_back

int main()
{


    fastread();



    ll a,b,c,d;


    cin>>a>>b>>c>>d;

   ll g=__gcd(c,d);

   ll l=(c/g)*d;

   //cout<<g<<" "<<l<<endl;

   ll sum=(b/c)+(b/d)-(b/l);
 // cout<<sum<<endl;
   sum=b-sum;
   a--;

   ll ans=(a/c)+(a/d)-(a/l);
  ans=a-ans;
   cout<<sum-ans<<endl;






}


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


int main() {
  int a[110];
  int N;
  cin >> N;
  for(int i=0;i<N;++i)cin>>a[i];
  
  int alice=0;
  int bob=0;
  
  sort(a,a+N, greater<int>());
  
  for(int i=0;i<N;++i){
    if(i%2==0) alice+=a[i];
    else bob+=a[i];
  }
  
  cout << alice-bob << endl;

}


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

using namespace std;
const long long INF = 1LL << 60;

ll dp[50][1010];
ll N,sum_C = 0,m = 0;
ll C[100],V[100];

int main(){
  cin >> N;
  rep(i,N) cin >> V[i];
  rep(i,N){
    cin >> C[i];
    sum_C += C[i];
  }
  rep(i,1010) dp[0][i] = 0;
  //DP
  rep(i,N){
    for(int c = 0; c <= sum_C; ++c){
      if(c >= C[i]) dp[i+1][c] = max(dp[i][c-C[i]] + V[i],dp[i][c]);
      else dp[i+1][c] = dp[i][c];
    }
  }
  for(int i = 1; i <= sum_C; ++i){
    if(dp[N][i-1] == dp[N][i]) continue;
    if(m < dp[N][i] - i) m = dp[N][i] - i;
  }
  cout << m << endl;
  return 0;
}


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

int main(void){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256