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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
constexpr ll dx[]={1,0,-1,0},dy[]={0,1,0,-1};

main(){
  
  ll h,w;
  cin>>h>>w;
  queue<tuple<ll,ll,ll>> que;
  vector<vector<ll>> cost (h,vector<ll>(w,INF));
  rep(i,h)rep(j,w){
    char c;cin>>c;
    if(c=='#')que.emplace(i,j,0);
  }

  while(!que.empty()){
    ll y,x,t;
    tie(y,x,t)=que.front();
    que.pop();
    if( chmin(cost[y][x],t) ){
      rep(i,4){
        ll nx=x+dx[i],ny=y+dy[i],nt=t+1;
        if(nx==-1||nx==w||ny==-1||ny==h)continue;
        que.emplace(ny,nx,nt);
      }
    }
  }

  ll ans=0;
  rep(i,h)rep(j,w)chmax(ans,cost[i][j]);
  cout<<(ans)<<endl;

}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;
using Graph = vector<vector<int>>;

int N, Q;
vector<int> G[200001];
int Potential[200001];
int Counters[200001];
bool Seen[200001];

void DFS(int v = 0, int ct = 0)
{
    ct += Potential[v];
    Counters[v] = ct;
    Seen[v] = true;
    for (auto &&nv : G[v])
    {
        if (Seen[nv]) continue;
        DFS(nv, ct);
    }
}

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

    rep(N - 1, i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(Q, i)
    {
        int p, x;
        cin >> p >> x;
        p--;
        Potential[p] += x;
    }

    DFS();

    for (int i = 0; i < N; i++)
    {
        cout << Counters[i] << " ";
    }
    cout << endl;
    
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++)
  {
    if ((i / 10) % 10 == 3)
    {
      printf(" %d", i);
    }
    else if(i % 10 == 3){
      printf(" %d", i);
    }
    else if ((i / 10) % 10 == 3)
    {
      printf(" %d", i);
    }
    else if ((i / 100) % 10 == 3)
    {
      printf(" %d", i);
    }
    else if ((i / 1000) % 10 == 3)
    {
      printf(" %d", i);
    }
    else if (i % 3 == 0)
    {
      printf(" %d", i);
    }
  }
  printf("\n");
}


Measured memory_bytes: 3156
H,W=map(int,input().split())

if H%3!=0 and W%3!=0:
  a=min(H,W)
else:
  print(0)
  exit()
b=H*W
for i in range(1,H):
  x=W*i
  if W%2==0:
    y=(H*W-x)//2
    z=y
  else:
    y=((H*W-x)+(H-i))//2
    z=y-(H-i)
  A=max(x,y,z)-min(x,y,z)
  b=min(A,b)

c=H*W
for i in range(1,W):
  x=H*i
  if H%2==0:
    y=(H*W-x)//2
    z=y
  else:
    y=((H*W-x)+(W-i))//2
    z=y-(W-i)
  B=max(x,y,z)-min(x,y,z)
  c=min(B,c)
print(min(a,b,c))

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

int main() {

    string s;
    cin >> s;

    int l = s.length();

    string ans(l, 'x');

    cout << ans << endl;

    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

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;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  int n;
  cin>>n;
  int memo=0;
  rep(i,10000){
    memo+=1000;
    if(n<=memo){
      cout<<memo-n<<endl;
      return;
    }
  }
  
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[1010];
ll b[1010];
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,m)scanf("%lld",b+i);
	sortdown(a,n);
	sortdown(b,m);
	int i=0,j=0;
	ll ans=1;
	for(int s=n*m;s>0;s--){
		if(a[i]==s&&b[j]==s){
			i++;
			j++;			
		}else if(a[i]==s){
			ans=ans*j%MOD;
			i++;
		}else if(b[j]==s){
			ans=ans*i%MOD;
			j++;
		}else{
			ans=ans*(i*j-(n*m-s))%MOD;
		}
//	printf("%lld\n",ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 252
#include <iostream>
using namespace std;
int main() {
    string w[3] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    for (int i=0; i<3; i++) {
        if (s == w[i]) {
            cout << w[(i+1)%3] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    if((A * B) % 2 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var hw = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = new int[hw[0]][];
        for (var i = 0; i < hw[0]; i++)
            ar[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse).Select(v=>v%2).ToArray();
        var str = new List<string>();
        var mod = 0;
        for(var i = 0; i < hw[0]; i++)
        {
            for (var j = 0; j < hw[1]; j++)
                if ((ar[i][j] + mod) % 2 == 1)
                {
                    if (i == hw[0] - 1 && j == hw[1] - 1) break;
                    mod = 1;
                    if (j == hw[1] - 1)
                        str.Add($"{i + 1} {j + 1} {i + 2} {j + 1}");
                    else str.Add($"{i + 1} {j + 1} {i + 1} {j + 2}");
                }
                else mod = 0;
            i++;
            if (i == hw[0]) break;
            for (var j = hw[1] - 1; j >= 0; j--)
                if ((ar[i][j] + mod) % 2 == 1)
                {
                    if (i == hw[0] - 1 && j == 0) break;
                    mod = 1;
                    if (j == 0)
                        str.Add($"{i + 1} {j + 1} {i + 2} {j + 1}");
                    else str.Add($"{i + 1} {j + 1} {i + 1} {j}");
                }
                else mod = 0;
        }
        if (str.Count == 0) WriteLine(0);
        else WriteLine($"{str.Count}\n{string.Join("\n", str)}");
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 44824
import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()],dtype=np.int64)

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
  # d = A-B
  cum_left = np.cumsum(S[::d])
  cum_right = np.cumsum(S[::-1][::d])
  score = cum_left + cum_right # 等差数列の長さ-1 -> 得点
  # あとは、その経路がルール内で実現できるかどうか
  for L,s in enumerate(score):
    if answer >= s:
      continue
    # 右左に進んでいることの確認
    A = N-1-L*d
    B = A-d
    if A <= 0:
      continue
    if A<=B:
      continue
    if B<=0:
      continue
    # 同じ場所を取っていないかの確認
    # kd = N-1-ldとなるとまずい
    # 約数のとき、Ld >= N-Ldだとまずい
    if (N-1)%d == 0 and 2*L*d >= N-1:
      continue
    answer = s

print(answer)


Measured memory_bytes: 23300
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            ll ar[n+1],ar2[n+1],ans=0;
            for(i=1;i<=n-1;++i)
                cin>>ar[i];
            ar[n]=ar[n-1];
            ar2[1]=ar[1];
            for(i=2;i<=n;++i)
            {
                ar2[i]=min(ar[i-1],ar[i]);
            }
            for(i=1;i<=n;++i)
            {
                //cout<<i<<" "<<ar2[i]<<endl;
                ans=ans+ar2[i];
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

H = int(input())

x = H
cnt = 0
while x != 1 :
  x //= 2
  cnt += 1
#print (cnt)

sum = 1
y = 1
for i in range(cnt) :
  sum += y*2
  y *= 2
  #print (sum)
print (sum)
    
    
  
  
  



Measured memory_bytes: 3436
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	long long n, a[100500];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	long long flag=0, c, b;
	b = c = 0;
	for(int i=n-1;i>=0;i--)
	{    
         if(flag==0)
         {
         	if(a[i]==a[i-1])
         	{
	         	c=a[i];
	         	flag++;
            }
         }
         else if(flag==1)
         {
         	if(a[i]==a[i-1]&&a[i]!=c)
         	{
	         	b=a[i];
	         	flag++;
            }
         }
         else
         break;		
	}
	for(int i=n-1;i>=0;i--)
	{
		if(a[i]==a[i-1]&&a[i-1]==a[i-2]&&a[i-2]==a[i-3])
		{   
		    if(a[i]*a[i]>b*c)
		    {
    			printf("%lld\n",a[i]*a[i]);
				return 0;
    		}
			
		} 
	}
	printf("%lld\n",b*c);
} 

Measured memory_bytes: 1024
#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, w, weight[110], value[110], dp[110][100100];

int main() {
    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i];

    for(int i = 0; i < 110; i++) for(int j = 0; j < 100100; j++) dp[i][j] = inf;

    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100100; j++){
            if(j - value[i] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j - value[i]] + weight[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    ll res = 0;
    for(int i = 0; i < 100100; i++){
        if(dp[n][i] <= w) res = i;
    }

    cout << res << endl;
}


Measured memory_bytes: 86272
#include <stdio.h>

int main() {
	/*
	 * V1 = vector{(x1,y1),(x2,y2)}
	 * V2 = vector{(x2,y2),(x3,y3)}
	 * 
	 * V2 = rotate (90) * V1
	 * 	  = | 0 -1||V1_1|
	 * 	    | 1  0||V1_2|
	 *
	 * V2_1 = -V1_2 = y1-y2
	 * V2_2 = V1_1 = x2-x1
	 */

	int x1, x2, y1, y2;
	
	scanf ("%d %d %d %d", &x1, &y1, &x2, &y2);
	int v2_1, v2_2;
	v2_1 = y1 - y2;
	v2_2 = x2 - x1;

	printf ("%d %d %d %d\n", x2+v2_1, y2+v2_2, x1+v2_1, y1+v2_2);
	return 0;
}


Measured memory_bytes: 128
def run():
    n = int(input())
    li = input().split()
    assert(len(li) == n)

    q = int(input())
    for _ in range(q):
        b, e = [int(x) for x in input().split()]
        li = li[:b] + list(reversed(li[b:e])) + li[e:]

    print(" ".join(li))


if __name__ == '__main__':
    run()



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

using namespace std;

int main()
{
    double n,d;
    int cnt=0;

    cin >> n >> d;

    vector<vector<double>> x(n , vector<double>(d));

    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x.at(i).at(j);
        }
    }

    double sum;

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

            sum = 0;
            for(int k=0; k<d; k++){
                sum += pow( x.at(i).at(k)-x.at(j).at(k) ,2);
            }

            bool flag = false;
            for(int k=1; k<= sum; k++){
                if(k * k == sum){
                    flag = true;
                    break;
                }
            }
            if(flag){
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    
    return 0;
}

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

using namespace std;

int main()
{
    int n, h;
    cin>>n>>h;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin>>x;
        ans += (x >= h);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define MAXI 150
 
int main(){

	int n, q;
	while(cin >> n >> q, n, q){
		vector<int> cnt(MAXI, 0);
		rep(i, n){
			int m;
			cin >> m;
			rep(j, m){
				int tmp;
				cin >> tmp;
				cnt[tmp]++;
			}
		}
		
		int ans = 0;
		int ans_c = 0;
		
		rep(i, MAXI){
			if(ans_c < cnt[i]){
				ans_c = cnt[i];
				ans = i;
			}
		}
		
		cout << (ans_c >= q ? ans : 0) << endl;
		
	}
	
	
	return 0;
}

Measured memory_bytes: 2960
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int A[1000001];
int n;unordered_map<int,int> mp;int vis[1000001];
int main()
{
	n=read();
	for(rint i=1;i<=n;++i) A[i]=read();
	sort(A+1,A+n+1);int ans=0;for(rint i=1;i<=n;++i) mp[A[i]]++;
	for(rint i=n;i>=1;--i)
	{
		if(!mp[A[i]]) continue;
		mp[A[i]]--;
		for(rint j=30;j>=0;--j)
		{
			int x=1<<j;
			int tmp=x-A[i];
			if(tmp<0) continue;
//			cout<<tmp<<"\n";
			if(mp[tmp]) {mp[tmp]--,ans++;break;}
		}
	}cout<<ans;
	return 0;
}


Measured memory_bytes: 32884
#include <bits/stdc++.h>
using namespace std;
     
     
int main(){
     
     
    int n, i, t;
     
    double k = 0;    
     
    vector<int> a;
     
     
    cin >> n;
     
     
    for( i = 0 ; i < n ; i = i + 1 ){
     
         cin >> t;
     
         a.push_back(t);
     
         }
     
     
    for( i = 0 ; i < n ; i = i + 1 ){
     
         k += (double) 1 / a.at(i);
     
         }
     
     
    cout << fixed << setprecision(7);
     
    cout << 1 / k << endl;
     
     
    return 0;
     
     
    }

Measured memory_bytes: 256
#include <cstdio>

void SR(char S[], int countsl);

int main(){
    char S[101],T[101];
    scanf("%s\n%s",S,T);
    int countsl = 0;
    for(int i = 0; S[i] != '\0'; i++){
        countsl++;
    }
    int n;
    for(int i = 0; i < countsl; i++){
        SR(S, countsl);
        n = 0;
        for(int j = 0; j < countsl; j++){
            if(S[j] == T[j]){
                n++;
            }else{
                break;
            }
        }
        if(n == countsl){
            printf("Yes\n");

            return 0;
        }
    }
    printf("No\n");

    return 0;
}

void SR(char S[], int countsl){
    char E,P,Q;
    E = S[countsl - 1];
    P = S[0];
    for(int i = 1; i < countsl; i++){
        Q = S[i];
        S[i] = P;
        P = Q;

    }
    S[0] = E;
    
    printf("\n");

}

Measured memory_bytes: 128
#!/bin/bash

typeset -i SUM=0
typeset -i SKIP=1
typeset -i SKIPC=1
typeset -i V1=0
typeset -i V2=0
read N
read VARS

for V1 in $(echo $VARS)
do
        #echo $V1
        SKIPC=$SKIP
        for V2 in $(echo $VARS)
        do
                #echo $V2
                if [[ $SKIPC -gt 0 ]] ; then
                        SKIPC=$SKIPC-1
                        continue
                fi
                SUM=$((SUM+V1*V2))
        done
        SKIP=$SKIP+1
done

echo $SUM


Measured memory_bytes: 664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<string>vec(N);
	rep(i, 0, N)cin >> vec[i];
	vector<int>cnt(N, 0);
	map<char, int>mp;
	rep(i, 0, N) {
		if (vec[i][0] == 'B') {
			mp[vec[i][0]]++;
		}
		if (vec[i][vec[i].size()-1] == 'A') {
			mp[vec[i][vec[i].size() - 1]]++;
		}
		rep(j, 0, vec[i].size()) {
			if (vec[i].substr(j, 2) == "AB") {
				cnt[i]++;
				j++;
			}
		}
	}
	int a = 0;
	rep(i, 0, N) {
		if (vec[i][0] == 'B' && vec[i][vec[i].size() - 1] == 'A') {
			a++;
			mp['A']--;
			mp['B']--;
		}
	}
	int ans = 0;
	if (a > 0) {
		ans += a - 1;
		if (mp['A'] > 0) {
			ans++;
			mp['A']--;
		}
		if (mp['B'] > 0) {
			ans++;
			mp['B']--;
		}
	}
	ans += min(mp['A'], mp['B']);
	rep(i, 0, N) {
		ans += cnt[i];
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 896
import collections
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ss = collections.Counter(s)
tt = collections.Counter(t)
ans = 0
for i in ss:
    sub = ss[i]
    if i in tt:
        sub -= tt[i]
    ans = max(ans, sub)
    
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll N, X; cin >> N >> X;

	ll res{0};
	for (ll i = 0; i < N; ++i)
	{
		ll a; cin >> a;
		res = gcd(abs(a-X), res);
	}
	std::cout << res << std::endl;
}


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

int main() {
	string S; long long K;
	cin >> S >> K;
	for (int i = 0; i < min((long long)S.size(), K); i++) {
		if (S[i] >= '2') { cout << S[i] << endl; return 0; }
	}
	cout << '1' << endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<endl
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e];
using namespace std;

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

	LL h[n];
	read(h, n);

	vector<vector<int> > adj(n);
	while(m--){
		int u, v;
		cin>>u>>v;
		adj[u-1].push_back(v-1); 
		adj[v-1].push_back(u-1);
	}

	int ans = 0;
	for(int i=0; i<n; i++){
		if(adj[i].empty()){
			ans++;
			continue;
		}

		bool flag = 0;
		for(int j: adj[i]){
			if(h[i]<=h[j]){
				flag = 1;
				break;
			}
		}

		if(flag==0)
			ans++;
	}

	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 9240
N=int(input())
a=list(map(int,input().split()))

C=[0,0,0,0,0,0,0,0]
R=0

for i in range(N):
    if a[i]<3200:
        C[a[i]//400]+=1
    else:
        R+=1
#print(C,R)
m=0
for i in range(8):
    if C[i]>0:
        m+=1
if m==0:
    print(1,R)
else:
    print(m,m+R)

Measured memory_bytes: 38256
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cctype>
#include <stack>
#include <list>
#include <queue>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define lli long long int
#define ulli unsigned long long int

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)(a.size())

#define loop(i,a,b) for(int i=a; i<b; i++)

int gcd(int a, int b) {return b==0?a:gcd(b,a%b);}
int lcm(int a, int b) {return a*(b/gcd(a,b));}

#define INF 1000000000  //(10^9)
#define MOD 1000000007  //(10^9+7)

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

vector<lli> T(1010), A(1010);

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

	int n;
	cin>> n;
	loop(i,0,n)
		cin>> T[i]>> A[i];
	lli a, b;
	a= T[0];
	b= A[0];
	loop(i,1,n)
	{
		lli x, y, maxi;
		if(a%T[i]==0)
			x= a/T[i];
		else
			x= (a/T[i])+1;
		if(b%A[i]==0)
			y= b/A[i];
		else
			y= (b/A[i])+1;
		maxi= max(x,y);
		a= T[i]*maxi;
		b= A[i]*maxi;
	}
	cout<< (a+b)<< "\n";


	return 0;
}


Measured memory_bytes: 256
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
result = []
for i in range (N):
    temp = V[i]-C[i]
    result.append(temp)
    
ans = 0
for j in range (len(result)):
    if result[j]>=0:
        ans += result[j]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void){
	
	int i;
	char a[4];
	
	i = 0;
	
	scanf("%s",&a);
	
	if(a[0] == 'o')i = i + 1;
	if(a[1] == 'o')i = i + 1;
	if(a[2] == 'o')i = i + 1;
	
	printf("%d\n",700 + i * 100);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)


{


 int W,H,x,y,r;

 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);


 if( x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){


  printf("Yes\n");


 }


 else{


  printf("No\n");


 }

 return 0;


}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

vector<char> ans(100100, '.');
int n;
string s;

void swcheck(vector<char> &sw) {
    for(int i = 1; i < n; ++i) {
        if(s.at(i) == 'o') {
            if(sw.at(i) == 'S') {
                if(sw.at(i-1) == 'S') sw.at(i+1) = 'S';
                else sw.at(i+1) = 'W';
            }else {
                if(sw.at(i-1) == 'S') sw.at(i+1) = 'W';
                else sw.at(i+1) = 'S';
            }
        }else {
            if(sw.at(i) == 'S') {
                if(sw.at(i-1) == 'S') sw.at(i+1) = 'W';
                else sw.at(i+1) = 'S';
            }else {
                if(sw.at(i-1) == 'S') sw.at(i+1) = 'S';
                else sw.at(i+1) = 'W';
            }
        }
    }
}

bool lacheck(vector<char> &sw) {
    if(sw.at(0) == sw.at(n)) {
        if(s.at(0) == 'o') {
            if(sw.at(0) == 'S') {
                if(sw.at(n-1) == sw.at(1)) return true;
            }else {
                if(sw.at(n-1) != sw.at(1)) return true;
            }
        }else {
            if(sw.at(0) == 'S') {
                if(sw.at(n-1) != sw.at(1)) return true;
            }else {
                if(sw.at(n-1) == sw.at(1)) return true;
            }
        }
    }
    return false;
}

void swprint(vector<char> &sw) {
    for(int i = 0; i < n; ++i) {
        if(i == n-1) cout << sw.at(i) << endl;
        else cout << sw.at(i);
    }
}

int main() {
    cin >> n >> s;
    ans.at(0) = 'S'; ans.at(1) = 'S';
    swcheck(ans);
    if(lacheck(ans)) {
        swprint(ans); return 0;
    }
    ans.at(0) = 'S'; ans.at(1) = 'W';
    swcheck(ans);
    if(lacheck(ans)) {
        swprint(ans); return 0;
    }
    ans.at(0) = 'W'; ans.at(1) = 'S';
    swcheck(ans);
    if(lacheck(ans)) {
        swprint(ans); return 0;
    }
    ans.at(0) = 'W'; ans.at(1) = 'W';
    swcheck(ans);
    if(lacheck(ans)) {
        swprint(ans); return 0;
    }
    cout << -1 << endl;
}

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


int main(){
  string a;
  cin >> a;
  if(a=="hi"||a=="hihi"||a=="hihihi"||a=="hihihihi"||a=="hihihihihi"){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int n, k, x;

int main(int argc, char **argv) {
	cin >> n >> k;
	int res = 0;
	REP(i, n) {
		cin >> x;
		res += 2 * min(x, k - x);
	}
	cout << res << endl;
	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 REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	int n, h, w;
	cin >> n >> h >> w;

	cout << (n-h+1) * (n-w+1) << endl;

    return 0;
}


Measured memory_bytes: 256
def merge(arr, l, m, r):
    n1 = m - l + 1
    n2 = r- m
 
    # create temp arrays
    L = [0,0] * (n1)
    R = [0,0] * (n2)
 
    # Copy data to temp arrays L[] and R[]
    for i in range(0 , n1):
        L[i] = arr[l + i]
 
    for j in range(0 , n2):
        R[j] = arr[m + 1 + j]
 
    # Merge the temp arrays back into arr[l..r]
    i = 0     # Initial index of first subarray
    j = 0     # Initial index of second subarray
    k = l     # Initial index of merged subarray
 
    while i < n1 and j < n2 :
        if L[i][0] <= R[j][0]:
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1
        k += 1
 
    # Copy the remaining elements of L[], if there
    # are any
    while i < n1:
        arr[k] = L[i]
        i += 1
        k += 1
 
    # Copy the remaining elements of R[], if there
    # are any
    while j < n2:
        arr[k] = R[j]
        j += 1
        k += 1
 
# l is for left index and r is right index of the
# sub-array of arr to be sorted
def mergeSort(arr,l,r):
    if l < r:
 
        # Same as (l+r)/2, but avoids overflow for
        # large l and h
        m = (l+(r-1))//2
 
        # Sort first and second halves
        mergeSort(arr, l, m)
        mergeSort(arr, m+1, r)
        merge(arr, l, m, r)
n,m=map(int,input().split())
arr=[]
for i in range(m):
    arrx=list(map(int,input().split()))
    arr.append(arrx)
mergeSort(arr,0,m-1)
ans=0
x1=arr[0][0]
y1=arr[0][1]
for i in range(m):
    if(arr[i][0]>=y1):
        ans+=1
        x1=arr[i][0]
        y1=arr[i][1]
    else:
        x1=max(x1,arr[i][0])
        y1=min(y1,arr[i][1])
ans+=1
print(ans)




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

int main() {
    int num[3];
    for (int i = 0; i < 3; i++) {
        cin >> num[i];
    }

    int len[2] = {5, 7},
        cnt[2] = {};
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 2; j++) {
            if (num[i] == len[j]) cnt[j]++;
        }
    }
    if (cnt[0] == 2 and cnt[1] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

using namespace std;

vector<vector<pair<int, int> > > E;
vector<int> col;

void dfs(int curidx, int curcol) {
    for(int i=0; i<E[curidx].size(); i++) {
        if(col[E[curidx][i].first]!=-1) continue;
        if(E[curidx][i].second) {
            col[E[curidx][i].first]=curcol ? 0 : 1;
        } else {
            col[E[curidx][i].first]=curcol ? 1 : 0;
        }
        dfs(E[curidx][i].first, col[E[curidx][i].first]);
    }
}

int main() {
    int N;
    cin >> N;
    
    E.resize(N+1);
    col.assign(N+1, -1);
    for(int n=0; n<N-1; n++) {
        int u, v;
        long long int w;
        cin >> u >> v >> w;
        w %= 2;
        E[u].push_back(make_pair(v, (int)w));
        E[v].push_back(make_pair(u, (int)w));
    }
    
    col[1]=0;
    dfs(1, 0);

    for(int n=1; n<=N; n++) {
        cout << col[n] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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

    ll x = min(b-1,n);

    ll p = a*x/b;
    ll q = x/b;
    q = a*q;
    //cout << p << " " << q << endl;;



    cout << p - q << endl;
    

}

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

int main(){
    int N, K;
    cin >> N >> K;
    int P[N] = {};
    int d[K];
    int A[K][N];
    for(int i = 0; i < K; i++){
        cin >> d[i];
        for(int j = 0; j < d[i]; j++){
            cin >> A[i][j];
            P[A[i][j]-1]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(P[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<set>
using namespace std;
int dp[21][21][21][21];
int H, W, x[20][20];
int solve(int a1, int b1, int a2, int b2) {
	if (a1 > a2 || b1 > b2)return 0;
	if (dp[a1][b1][a2][b2] >= 0)return dp[a1][b1][a2][b2];
	set<int>S;
	for (int i = a1; i <= a2; i++) {
		for (int j = b1; j <= b2; j++) {
			if (x[i][j] == 1)continue;
			int V1 = solve(a1, b1, i - 1, j - 1);
			int V2 = solve(a1, j + 1, i - 1, b2);
			int V3 = solve(i + 1, b1, a2, j - 1);
			int V4 = solve(i + 1, j + 1, a2, b2);
			int V5 = V1 ^ V2 ^ V3 ^ V4;
			S.insert(V5);
		}
	}
	for (int i = 0; i < 400; i++) {
		if (S.count(i) == 0) { dp[a1][b1][a2][b2] = i; break; }
	}
	return dp[a1][b1][a2][b2];
}
int main() {
	cin >> H >> W;
	for (int i = 0; i < 441; i++) {
		for (int j = 0; j < 441; j++)dp[i / 21][i % 21][j / 21][j % 21] = -1;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char p; cin >> p;
			if (p == 'X')x[i][j] = 1;
		}
	}
	int res = solve(0, 0, H - 1, W - 1);
	if (res == 0)cout << "Second" << endl;
	else { cout << "First" << endl; }
	return 0;
}

Measured memory_bytes: 3888
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    def sum_up_to_n(n):
        return n * (n + 1) // 2

    print(sum_up_to_n(N - 1))
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9120
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	G := make(map[int]int)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = sc.nextInt()
		pf := primeFactors(A[i])
		for k, v := range pf {
			G[k] = max(G[k], v)
		}
	}
	lcm := 1
	for k, v := range G {
		lcm *= modPow(k, v, MOD)
		lcm %= MOD
	}
	ans := 0
	for i := 0; i < N; i++ {
		ans += lcm * modInv(A[i], MOD) % MOD
		ans %= MOD
	}

	fmt.Fprintln(wtr, ans)
}

func primeFactors(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}
	if n > 2 {
		pfs[n]++
	}

	return pfs
}

func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func modInv(a, mod int) int {
	b := mod
	u := 1
	v := 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string S;
ll ans = 0;

const ll INF = 1LL << 60;
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() {
  string S;
  cin >> S;
  ll dp[S.size()][13] = {0};
  reverse(S.begin(), S.end());
  ll keta = 1;
  if(S[0] == '?') {
    for(int i = 0; i < 10; i++) {
      dp[0][i] = 1;
    }
  } else {
    int t = S[0] - '0';
    dp[0][t] = 1;
  }

  for(int i = 1; i < S.size(); i++) {
    keta *= 10;
    keta %= 13;
    if(S[i] == '?') {
      for(int j = 0; j < 10; j++) {
        for(int k = 0; k < 13; k++) {
          dp[i][(keta * j + k) % 13] += dp[i - 1][k];
          dp[i][(keta * j + k) % 13] %= 1000000007;
        }
      }
    }
    else {
      int t = S[i] - '0';
      for(int j = 0; j < 13; j++) {
      dp[i][(t * keta + j) % 13] += dp[i - 1][j]; 
      dp[i][(t * keta + j) % 13] %= 1000000007;
      }
    }
  }
    cout << dp[S.size() - 1][5];



  return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <cmath>

using namespace std;

int roundUp(int x, int index);

int main(void)
{
    int i;
    int n;
    double intrst;
    int debt;
    
    cin >> n;
    
    debt = 100000;
    intrst = 0.05;
    for (i = 0; i < n; i++) {
        debt *= 1.0 + intrst;
        debt = roundUp(debt, 4);
    }
    
    cout << debt << endl;
    
    return 0;
}

int roundUp(int x, int index)
{
    int exp10;
    
    exp10 = pow(10, index - 1);
    x += exp10 - 1;
    x /= exp10;
    x *= exp10;
    
    return x;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
inline int qpow(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (ll)x * x % mod)
		if(y & 1) res = (ll)res * x % mod;
	return res;
}
int n, a[maxn], inv[maxn], b[maxn];

int main()
{
	n = read();
	for(int i = 1; i <= n; i ++)
		a[i] = read();
	for(int i = 1; i <= n; i ++)
		inv[i] = qpow(i, mod - 2), inv[i] = (inv[i] + inv[i - 1]) % mod;
	int rev = mod - inv[1];
	for(int i = 1; i <= n; i ++)
		b[i] = ((inv[n - i + 1] + inv[i]) % mod + rev) % mod;
	int ans = 0;
	for(int i = 1; i <= n; i ++)
		ans = (ans + (ll)a[i] * b[i] % mod) % mod;
	for(int i = 1; i <= n; i ++)
		ans = (ll)ans * i % mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
double dp[305][305][305];
int a[5];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        a[x]++;
    }
    for(int k=0;k<=n;k++)
    {	
	    for(int j=0;j<=n;j++)
	    {
		    for(int i=0;i<=n;i++)
			{
			    if(i||j||k) 
			    {
			        if(i) dp[i][j][k]+=dp[i-1][j][k]*i/(i+j+k);
			        if(j) dp[i][j][k]+=dp[i+1][j-1][k]*j/(i+j+k);
			        if(k) dp[i][j][k]+=dp[i][j+1][k-1]*k/(i+j+k);
			        dp[i][j][k]+=(double)n/(i+j+k);
			    }
		    }
	    }
    }
    printf("%.15lf\n",dp[a[1]][a[2]][a[3]]);
    return 0;
} 

Measured memory_bytes: 219392
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val k = sc.nextInt()
    println(problem096b(a, b, c, k))
}

fun problem096b(a: Int, b: Int, c: Int, k: Int): Int {
    val abc = listOf(a, b, c).sorted() // 最大をソートで取得
    return abc[0] + abc[1] + (abc[2] shl k) // 2 ** k を掛ける -> 左シフト
}


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

long long m, d, ans;

int main(){
	ans=0;
	cin >> m >> d;
	for (int i=1;i<=d;i++){
		if ((i%10)<2 || (i/10)<2) continue;
		if (((i%10)*(i/10))<=m){
//			cout << i << " " << m << "\n";
			ans++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var S int
	fmt.Scan(&S)

	x := 100
	counter := 0
	for i:=0; i<3; i++ {
		res := S / x
		if res == 7 {
			counter = 1
			fmt.Println("Yes")
			break
		}
		y := res * x
		S -= y
		x /= 10
	}
	if counter == 0 {
		fmt.Println("No")
	}

}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

 
int main() {
  ll N,M;
  cin >> N >> M;
  if(abs(N-M) > 1) {
    cout << 0 << endl;
    return 0;
  }
  ll n = 1;
  int N2 = N;
  while(N2 > 0) {
    n  = (n * N2)  % ((ll)pow(10,9)+7);
    N2--;
  }
  ll m = 1;
  int M2 = M;
  while(M2 > 0) {
    m = (m * M2)% ((ll)pow(10,9)+7);;
    M2--;
  }
  if(N == M) {
    cout <<( n * m * 2) % ((ll)pow(10,9)+7) << endl;
    return 0;
  } else if (N < M ) {
    cout <<( n * m)  % ((ll)pow(10,9)+7)  << endl;
    return 0;
  } else {
    cout <<( n * m)  % ((ll)pow(10,9)+7) << endl;
    return 0;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int P[200010];
bool a[200010];
bool l[200010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) {
		a[P[i]] = true;
		if (a[P[i] - 1]) {
			l[P[i]] = true;
		}
	}
	int ans = 0, cnt = 1;
	//for (int i = 1; i <= N; i++) cout << l[i] << " ";
	for (int i = 2; i <= N; i++) {
		if (l[i]) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 1;
		}
	}
	ans = max(ans, cnt);
	cout << N - ans << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    set<char> s;
    rep(i, n) {
        string str;
        cin >> str;
        s.insert(str[0]);
    }
    if (s.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

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

int main(){
	volatile clock_t c = clock();
	string s;
	cin >> s;
	c += (s[5] - 'a' + 1) * 0.01 * CLOCKS_PER_SEC;
	while(clock() < c);
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
   ll n;
   string s = "";
   cin >> n;
   while(n){
        ll rem = n%26;
        if(rem){
            s += ('a' + (rem-1));
            n /= 26;
        }
        else{
            s += 'z';
            n = n/26 - 1;
        }
   }
   reverse(all(s));
   cout << s << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

Measured memory_bytes: 3640
N=int(input())
S=list(input())
mS=[i for i in S]

j=1
while j==1:
  j=0
  for i in reversed(range(len(S)-1)):
    if S[i]=="(" and S[i+1]==")":
      S.pop(i+1)
      S.pop(i)
      j=1
      break

print("".join(["("]*S.count(")")+mS+[")"]*S.count("(")))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <unistd.h>


#define ll long long
#define lst(x) x.size()-1
#define ld long double
#define pr pair<ll,ll>
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using os = tree<T, null_type, less_equal<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const ll N=3e5+5,M=1e1+5,MOD=1e9+7,OO=1e13;
double h,a;
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
#ifndef ONLINE_JUDGE
  //  freopen("in.txt", "rt" , stdin);
    // freopen("in.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
    cin>>h>>a;
    int ans=ceil(h/a);
    cout<<ans<<endl;
}


Measured memory_bytes: 256