akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

int dp[410][410], nxt[410][410];
int a[41], b[41], c[41];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ma, mb;
    cin >> n >> ma >> mb;
    rep(i, 0, n){
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i, 0, 410) rep(j, 0, 410) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, 0, n){
        rep(j, 0, 410) rep(k, 0, 410) nxt[j][k] = dp[j][k];
        rep(j, 0, 410){
            rep(k, 0, 410){
                if(dp[j][k] == INF) continue;
                chmin(nxt[j + a[i]][k + b[i]], dp[j][k] + c[i]);
            }
        }
        swap(dp, nxt);
    }
    int ans = INF;
    rep(i, 1, 410){
        rep(j, 1, 410){
            if(ma * j == mb * i){
                chmin(ans, dp[i][j]);
            }
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 2944
n=int(input())
sums=[0]*(n+1)
node=[0]*(n+1)
p=list(map(int,input().split()))
flag=False

sums[n]=p[n]
for i in reversed(range(n)):
    sums[i]=p[i]+sums[i+1]

sums[0]=1
for i in range(1,n):
    c=(sums[i-1]-p[i-1])*2
    if c<=0:
        flag=True
        break
    if c<sums[i]:
        sums[i]=c
    else:
        break

if n==0:
    if p[0]==1:
        print(1)
    else:
        print(-1)
elif flag or (sums[n-1]-p[n-1])*2<sums[n]:
    print(-1)
else:
    print(sum(sums))

Measured memory_bytes: 87132
N = int(input())
li = list(map(int,input().split()))

S = max(li)
L = [0] * (S+1)

import math
from functools import reduce

if reduce(math.gcd,li) != 1:
    print('not coprime')
    exit()

for i in li:
    L[i] = 1

for k in range(2,S+1):
    t = 0
    for j in range(0,S+1,k):
        t += L[j]
    if t > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')
    

Measured memory_bytes: 189340
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream fin("input.txt")
//#define of1 ofstream fout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,p;
	cin>>a>>p;
	ll total=3*a+p;
	cout<<(total/2);
    return 0;
}

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

int a[15];
int b[15];
int n;
int ans = 0;

void dfs(int i){
	if(i == n+1){
		int res = 1;
		for(int i=1;i<=n;i++) res*=b[i];
		if(res%2 == 0) ans++;
	}
	else{
		for(int j=a[i]-1;j<=a[i]+1;j++){
			int k = j%2;
			b[i] = j;
			dfs(i+1);
		}
	}
}

int main(){
	scanf("%d", &n);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
	}
	dfs(1);
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int lo;
    string str;
     
    int main(){
        cin >> str;
        if(str.size() <= 2){
            cout << "Yes";
            return 0;
        }
        string  str1 = "";
        for(lo i = str.size()-1;i >= 0;i--) str1 += str[i];
        //cout << str << " " << str1 << endl;
        if(str != str1){
            cout << "No";
            return 0;
        } 
        string str2 = "";
        for(lo i = 0;i < (str.size()-1)/2;i++){
            str2 += str[i];
        }
        
        string  str3 = "";
        for(lo i = str2.size()-1;i >= 0;i--) str3 += str2[i];
        //cout << str2 << " " << str3 << endl;
        if(str2 != str3){
            cout << "No";
            return 0;
        } 
        
        string str4 = "";
        for(lo i = (str.size()+3)/2-1;i < str.size();i++) str4 += str[i];
     
        string  str5 = "";
        for(lo i = str4.size()-1;i >= 0;i--) str5 += str4[i];
        //cout << str4 << " " << str5 << endl;
        if(str4 != str5){
            cout << "No";
            return 0;
        } 
        cout << "Yes";
    }

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        int kazu = int.Parse(ReadLine());
        string[] reader = ReadLine().Split(' ');
        int hp = int.Parse(reader[0]);
        int wazasu = int.Parse(reader[1]);
        string[] readerwaza = ReadLine().Split(' ');
        int total = 0;
        
        for(int i=0;i<wazasu;i++){
            total += int.Parse(readerwaza[i]);
        }
        
        if(total >= hp){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
        
/*        string[] hyokol = ReadLine().Split(' ');
        double minsa = 99999999;
        int titen = 0;
        for(int i=0;i<kazu;i++){
            int hyoko = int.Parse(hyokol[i]);
            double hiku = (double)(hyoko*6)/1000;
            double kionh = (double)kion - hiku;
            double sa = Abs(kionh - (double)moku);
//            WriteLine(kionh);
//            WriteLine(sa);
            if(minsa > sa){
                minsa = sa;
                titen = i+1;
            }
        }
        WriteLine(titen);*/
    }
}

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

typedef long long ll;
ll a, b, n;

int main(){
    cin >> a >> b >> n;
    if(n >= b){
        ll ans = (a * (b - 1)) / b;
        printf("%lld\n", ans);
    }else{
        ll ans = (a * (n)) / b;
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll bestsat = -1;

    rep(i,d){
        ll mx=0,x;
        rep(j,26){
            if(s.at(i).at(j)>mx){
	            mx = s.at(i).at(j);
    	        x = j; 
            }
        }
        cout << x+1 << endl;
    }

    /*
    srand(time(NULL));
    vector<ll> randbest(d,0);
    ll times = 10000;
    while(times--){
        ll sat = 0;
        vector<ll> ans(d,0);
        rep(i,d){
            ans.at(i) = (rand() % 26) + 1;
        }
        for(int i=1;i<=d;i++){
            ll t = ans.at(i-1);
            t--;
            last.at(t) = i;
            sat += s.at(i-1).at(t);
            for(int j=0;j<26;j++){
                sat -= c.at(j) * (i - last.at(j));
            }
            //cout << sat << endl;
        }
        if(sat>bestsat){
            bestsat = sat;
            randbest = ans;
        }
    }
    */

    /*
    rep(i,d){
        cout << randbest.at(i) << endl;
    }
    */
  
    //cout << bestsat << endl;

    /*
    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 3700
from collections import deque
QUE=deque()


while True:
    w,h=map(int,input().split())
    
    if w==h==0:
        break
    
    MAP=[list(map(int,input().split())) for i in range(h)]
    ANSLIST=[[0 for i in range(w)] for j in range(h)]

    NOW=1

    for i in range(h):
        for j in range(w):
            if MAP[i][j]==0:
                continue
            if ANSLIST[i][j]!=0:
                continue
            
            QUE.append((i,j))
            while QUE:
                i,j=QUE.pop()
                for x,y in [(i-1,j-1),(i-1,j),(i-1,j+1),(i,j-1),(i,j),(i,j+1),(i+1,j-1),(i+1,j),(i+1,j+1)]:
                    if 0<=x<h and 0<=y<w and MAP[x][y]==1 and ANSLIST[x][y]==0:
                        ANSLIST[x][y]=NOW
                        QUE.append((x,y))

            NOW+=1

    #for an in ANSLIST:
    #    print(an)

    print(NOW-1)
                     


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace boost::multiprecision;

using namespace std;
using uif = uint_fast64_t;
using ll = int256_t;
//using ll = long long int;

int main(void)
{
  long long int n;
  cin >> n;
  vector<long long int> T(n);
  vector<long long int> A(n);
  rep(i, n) cin >> T[i] >> A[i];

  ll t = (ll)T[0];
  ll a = (ll)A[0];

  for (long long int i = 1; i < n; i++)
  {
    ll l = 0;
    ll r = LLONG_MAX;

    while (r - l > (ll)1)
    {
      ll piv = l + (r - l) / (ll)2;

      if (piv * (ll)(T[i]) >= t && piv * (ll)(A[i]) >= a)
      {
        r = piv;
      }
      else
      {
        l = piv;
      }
    }
    ll k;
    if (l == r)
      k = l;
    else
    {
      if (l * (ll)(T[i]) >= t && l * (ll)(A[i]) >= a)
        k = l;
      else
        k = r;
    }
    t = k * (ll)T[i];
    a = k * (ll)A[i];
  }

  cout << t + a << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N,K; cin >> N >> K;
    vector<int> a = {0,1,2,3,4,5,6,7,8,9};
    for (int i = 0; i < K; i++){
        int d; cin >> d;
        for (int j = 0; j < a.size(); j++){
            if (a[j] == d){
                a.erase(a.begin()+j);
                break;
            }
        }
    }
    /*
    for (int i = 0; i < a.size(); i++){
        cout << a[i] << " ";
    }
    cout << endl;
    */


    
    for (int i = N; i <= 1000000; i++){
        int num = i;
        bool flg = true;
        while (num > 0){
            int yo = num % 10;
            num /= 10;
            bool check = false;
            for (int j = 0; j < a.size(); j++){
                if (a[j] == yo){
                    check = true;
                }
            }
            if (!check){
                flg = false;
                break;
            }
        }
        if (flg){
            cout << i << endl;
            return 0;
        }
    }
    

} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 5005;
int dp[N][N], n, k, a[N], tmp, x, z[N];
int sol(int i, int cur)
{
	if(i == n || cur >= k-x) return cur;
	int &ret = dp[i][cur];
	if(ret != -1) return ret;
	ret = sol(i+1, cur);
	if(ret >= k-x) return ret;
	if(cur + a[i] < k && tmp != i) return max(ret, sol(i+1, cur+a[i]));
	return ret;
}
bool check(int i)
{
	x = a[i];
	if(z[x] != -1) return z[x];
	if(x >= k) return z[x] = 1;
	tmp = i;
	memset(dp, -1, sizeof dp);	
	if(sol(0, 0) >= k-x) return z[x] = 1;
	return z[x] = 0;
}
int main()
{
	memset(z, -1, sizeof z);
	cin >> n >> k;
	for(int i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	while(a[n-1] >= k) n--;
	int s = 0, e = n-1;
	while(s <= e)
	{
		int mid = (s+e)>>1;
		if(check(mid)) e = mid-1;
		else s = mid+1;
	}
	cout << s << endl;
}

Measured memory_bytes: 98304
def main():
	# n = int(input())
	# b = int(input())
	a,b = list(map(int,input().split()))
	# A = [list(map(int, input().split())) for _ in range(H)]
	
	import fractions
	# import math
	def lcm(x, y):
		return (x * y) // fractions.gcd(x, y)
	# print(fractions.gcd(a,b))
	
	print(lcm(a,b))

	




if __name__ == '__main__':
	main()

Measured memory_bytes: 64364
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=10000010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.length();i++){
		if('a'<=s[i]&&s[i]<='z'){
			int a=s[i]-'a';
			s[i]='A'+a;
		}
	}
	cout<<s<<endl;
	return 0;
}



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

using namespace std;

#define sq(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define what_is(x) cerr << fixed << setprecision(2) << #x << " = " << x << endl
#define setbitj(n, j) (n |= (1 << (j)))
#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)
#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/

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

const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAX = 100005;
const int MOD = 1000000007;

inline bool isEq(double a, double b){return abs(a - b) < EPS;}
inline double toRad(double deg){return deg*PI/180;}
inline double toDeg(double rad){return rad*180/PI;}

inline int geti(int &_int){return scanf("%d", &_int);}
inline int getii(int &_int, int &_int2){return scanf("%d %d", &_int, &_int2);}
inline int getiii(int &_int, int &_int2, int &_int3){return scanf("%d %d %d", &_int, &_int2, &_int3);}

inline int getl(ll &_ll){return scanf("%lld", &_ll);}
inline int getll(ll &_ll, ll &_ll2){return scanf("%lld %lld", &_ll, &_ll2);}
inline int getlll(ll &_ll, ll &_ll2, ll &_ll3){return scanf("%lld %lld %lld", &_ll, &_ll2, &_ll3);}

inline int getd(double &_double){return scanf("%lf", &_double);}
inline int getdd(double &_double, double &_double2){return scanf("%lf %lf", &_double, &_double2);}

inline int getstr(char *str){return scanf("%s", str);}

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};
bool status[MAX];
vector<int>primes;

void sieve()
{
    status[1] = 1;
    primes.pb(2);
    for(int i = 3; i*i < MAX; i++){
        if(!status[i]){
            primes.pb(i);
            //what_is(i*i);
            for(ll j = (ll)i*i; j < MAX; j+=i+i)
                status[j] = 1;
        }
    }
}

int cnt[MAX];

int main(int argc, char* argv[])
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    sieve();
    cnt[3]=1;
    for(int i = 4; i < MAX; i++){
        cnt[i] = cnt[i-1];
        if((i%2 ==1 && ((i+1)/2)%2==1 && !status[i] && !status[(i+1)/2]) || i == 2017)
           cnt[i]++;
    }
    int q, l, r;
    cin >> q;
    while(q--){
        cin >> l >> r;
        cout << cnt[r] - cnt[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
while True:
    n,k=map(int,(input().split()))
    if n==0 and k==0:
        break
    a,b,s=[],[],0
    for i in range(n):
        a.append(int(input()))
        if i==k-1:
            s=sum(a[0:k])
        elif i>=k:
            s=s+a[i]-a[i-k]
        b.append(s)
    print(max(b))


Measured memory_bytes: 11864
#include <stdio.h>

int main(){


 
  int i,j,key,num,array[100],k;
  
  
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&array[i]);
  }

  
  for(i=0;i<num-1;i++){
    printf("%d ",array[i]);
  }
  printf("%d\n",array[num-1]);
  
  
  for(i =1;i<num;i++){

    key = array[i];

    j = i -1;

    while(j >=0 && array[j] >key){

      array[j+1] = array[j];

      j = j -1;

      array[j+1] = key;
    }
    
    for(k=0;k<num-1;k++){
      printf("%d ",array[k]);

  }
    printf("%d\n",array[num-1]);
    
}
  return 0;
}

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

int main(){
    int h, m, s;
    int S;
    cin >> S;
    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = S - 3600 * h - 60 * m;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


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

int main() {
  vector<int> a(5);
  for (int i = 0;i < 5;i++){
    cin >> a.at(i);
  }
  
  for (int i = 0;i < 5;i++){
  if (a.at(i) == 0){
    cout << i + 1 << endl;
  }
  }
}



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

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end(), greater<long long>());
  if (N % 2 == 0) {
    long long ans = 0;
    for (int i = 0; i < N/2 - 1; i++) ans += 2 * A.at(i);
    ans += A.at(N/2 - 1);
    ans -= A.at(N/2);
    for (int i = N/2 + 1; i < N; i++) ans -= 2 * A.at(i);
    cout << ans << endl;
  }
  else {
    long long ans1 = 0;
    for (int i = 0; i < N/2 - 1; i++) ans1 += 2 * A.at(i);
    ans1 += A.at(N/2 - 1) + A.at(N/2);
    for (int i = N/2 + 1; i < N; i++) ans1 -= 2 * A.at(i);
    long long ans2 = 0;
    for (int i = 0; i < N/2; i++) ans2 += 2 * A.at(i);
    ans2 -= A.at(N/2) + A.at(N/2 + 1);
    for (int i = N/2 + 2; i < N; i++) ans2 -= 2 * A.at(i);
    cout << max(ans1, ans2) << endl;
  }
}

Measured memory_bytes: 1024
/*---------------------------------
 *File name: asd.cpp
 *Team: 这题太简单啦
 *Author: Snpilola
 *Creation date: 2019-11-09 16:48
 *-------------------------------*/
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define mkp make_pair
#define PLL pair<LL, LL>
#define lowbit(x) x & (-x)
#define PII pair<int, int>
#define Pque priority_queue 
using namespace std;
const int maxn = 1e3 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int EPS = 1e-6;

char a[maxn][maxn];
LL dp[maxn][maxn];
bool vis[maxn][maxn];

LL dfs(int x, int y){
	if(vis[x][y]) return dp[x][y] % mod;
	if(x == 1 && y == 1) return 1LL;
	vis[x][y] = 1;
	if(a[x - 1][y] == '.') dp[x][y] = (dfs(x - 1, y) + dp[x][y]) % mod;
	if(a[x][y - 1] == '.') dp[x][y] = (dfs(x, y - 1) + dp[x][y]) % mod;
	return dp[x][y] % mod;
}

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	for(int i = 1; i <= h; ++i)	scanf(" %s", a[i] + 1);
	LL ans = dfs(h, w);
	ans %= mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 10112
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void bubbleSortWithCount(ref int[] arr, out int cnt)
{
  for (auto i = 0; i < arr.length; i++) {
    for (auto j = arr.length-1; j >= i+1; j--) {
      if (arr[j] < arr[j-1]) {
        swap(arr[j], arr[j-1]);
        cnt++;
      }
    }
  }
}


void main(string[] args)
{
  int n = to!int(strip(readln()));
  int[] arr = to!(int[])(split(readln()));
  int cnt;
  bubbleSortWithCount(arr, cnt);
  writeln(join(arr.map!(text), " "));
  writeln(cnt);
}

Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    string s; cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
    return 0;
}

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

Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))

A.sort()

maxnum = A[-1]
checklist = [True]*(maxnum+1)
before = 0

for a in A:
    if before == a:
        checklist[a] = False
        continue
    num = 2
    while num * a <= maxnum:
        checklist[a * num] = False
        num += 1
    before = a

ans = 0
for i in A:
    ans += checklist[i]
print(ans)

Measured memory_bytes: 121940
def check(s)
    s.chars do |c|
        if "AGCT".include?(c).!
            return false
        end
    end
    return true
end

s = gets.chomp
n = s.size
ans = ""
n.times do |i|
    (i + 1).upto(n) do |j|
        t = s[i...j]
        if check(t) && ans.size < t.size
            ans = t
        end
    end
end
puts ans.size

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include <math.h>

#include <iostream>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

const int INF = 1e+8;

typedef struct edge_def {
	int from;
	int to;
	int cost;
} edge;

int V, E;
edge es[90];
int d[10];

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)

void min_time(int s) {
	int i;
	FOR(i,0,V+1) d[i] = INF;
	d[s] = 0;
	while (1) {
		bool update = false;
		FOR(i,0,2*E) {
			edge e = es[i];
			if (e.from != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) break;
	}
}

int main() {
	int i, j;
	int total;
	int minT;

	while (1) {
		scanf("%d ", &E);
		if (!E) break;

		V = 0;
		FOR(i,0,E) {
			scanf("%d%d%d ", &(es[i].from), &(es[i].to), &(es[i].cost));
			es[E+i].from = es[i].to;
			es[E+i].to = es[i].from;
			es[E+i].cost = es[i].cost;
			V = max(V, es[i].to);	
		}

		total = INF;
		minT = INF;
		FOR(i,0,V+1) {
			min_time(i);

			int sum = 0;
			FOR(j,0,V+1)
				sum += d[j];

			if (sum < total) {
				total = sum;
				minT = i;
			} else if (sum == total && i < minT)
				minT = i;
		}

		printf("%d %d\n", minT, total);
	}	

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
int n_max=100100;
int memo[100100];
vector<vector<int>> g(n_max);
int rec(int i){
    if(memo[i]!=-1) return memo[i];
    int res=0;
    for(auto nv:g[i]) {chmax(res, rec(nv) + 1);
                      /*cout<<"res="<<res<<"|"<<i<<"→"<<nv<<endl;*/}
    return memo[i]=res;
}
int main(){
    int n,m;
    cin>>n>>m;
  int x,y;
    REP(i,m) {
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
    }
  /*REP(i,n){
    cout<<"x:"<<i<<"|";
    for(auto y:g[i]) cout<<y<<",";
  cout<<endl;*/
  //}
   REP(i,n)memo[i]={-1};
    int res=0;
  	
    REP(i,n) chmax(res,rec(i));
    cout<<res<<endl;
}

Measured memory_bytes: 8192
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2-y1)
y3 = y2 - (x1-x2)
x4 = x1 - (x2-x3)
y4 = y1 - (y2-y3)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
# ABC107C - Candles (ARC101C)
def main():
    n, k = tuple(map(int, input().rstrip().split()))
    x = tuple(map(int, input().rstrip().split()))
    ans = float("inf")
    for i in range(n - k + 1):
        a, b = x[i], x[i + k - 1]
        if a < b < 0 or 0 < a < b:
            ans = min(ans, max(abs(a), abs(b)))
        else:
            ans = min(ans, max(abs(a), abs(b)) + min(abs(a), abs(b)) * 2)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14352
n=gets.strip.to_i
problems = n.times.map { [gets.strip.split(''), gets.strip.split('')] }

def solve(l_s, r_s)
  dp=Array.new(l_s.length+1) { [0]*(r_s.length+1) }

  l_s.each_with_index do |lc, i|
    r_s.each_with_index do |rc, j|
      if lc==rc
        dp[i+1][j+1] = dp[i][j]+1
      else
        dp[i+1][j+1] = [dp[i+1][j], dp[i][j+1]].max
      end
    end
  end

  dp[l_s.length][r_s.length]
end

problems.each do |lstr, rstr|
  p solve(lstr, rstr)
end



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

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		 // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {

	ll n, p; cin >> n >> p;
	vector<pair<long long, long long>> a_prime;  // a^x ならば { a, x }

	a_prime = prime_factorize(p);
	ll tmp = 1;
	for (ll i = 0; i < a_prime.size(); i++) {
		ll quo = a_prime[i].second / n;
		for (int j = 0; j < quo; j++) {
			tmp *= a_prime[i].first;
		}	
	}
	cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(b-a==1) cout<<"Borys";
	else
	{
		while(b-a!=1)
		{
			a++;
			if(b-a==1)
			{
				cout<<"Alice";
				break;
			}
			b--;
			if(b-a==1)
			{
				cout<<"Borys";
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
p=1
while p==1:
    a,b,c=input().split()
    if b=="?":
        break
    elif b=="+":
        print(int(a)+int(c))
    elif b=="-":
        print(int(a)-int(c))
    elif b=="*":
        print(int(a)*int(c))
    else:
        print(int(a)//int(c))


Measured memory_bytes: 5592
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

def readInts():
  return list(map(int,input().split()))

def main():
  """
  例えば x = 100で、k=7みたいなとき
  最初はずっと x >= kの場合になる
  x = 2のときに、 2 - 7より、7 - 2となる
  最終値になり得るものは、最終的に
  2 - 5 - 2 - 5 - 2のどっちかの数になる
  
  2 というのは　N % K
  そうすると、 N % K = a と置くと、
  a, k - aをminすればよい
  
  """
  n,k = readInts()
  a = n % k
  ans = min(a, k - a)
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	answer := minN(n, k)
	fmt.Println(answer)
}

func minN(n, k int) int {
	n = n % k
	minDiff := abs(n - k)
	for diff := minDiff; diff <= minDiff; diff = abs(n - k) {
		minDiff = diff
		n = diff
	}
	return minDiff
}

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


Measured memory_bytes: 512
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a%(MOD-7);
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n,nu;
ll s,k;
int h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	srand((long long)new char);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>n>>k;
	for (int i=0;i<n;++i) cin>>h[i];
	sort(h,h+n);
	for (int i=0;i<n;++i)
	{
		s+=h[i];
		if (k>=s) ++nu;
	}
	if (k>s) --nu;
	cout<<nu;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int answer[4][2];

	for( int i = 0;i < 4;i++ ){
		for( int j = 0;j < 2;j++ ){
			answer[i][j] = 0;
		}
	}

	double left,right;

	while( cin >> left >> right ){
		if( left >= 1.1 ) answer[0][0]++;
		else if( left >= 0.6 ) answer[1][0]++;
		else if( left >= 0.2 ) answer[2][0]++;
		else answer[3][0]++;

		if( right >= 1.1 ) answer[0][1]++;
		else if( right >= 0.6 ) answer[1][1]++;
		else if( right >= 0.2 ) answer[2][1]++;
		else answer[3][1]++;

	}

	for( int i = 0;i < 4;i++ ){
		cout << answer[i][0] << " " << answer[i][1] << endl;
	}
	return 0;
}

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

		int d = sc.nextInt();

		int[] c = new int[27];
		for ( int i=1; i<27; i++ ) {
			c[i] = sc.nextInt();
		}

		int[][] s = new int[d][27];
		for ( int i=0; i<d; i++ ) {
		for ( int j=1; j<27; j++ ) {
			s[i][j] = sc.nextInt();
		}
		}

		int[] last = new int[27];
		for ( int i=0; i<d; i++ ) {
			int t = 0;
			int man = -999999999;

			for ( int j=1; j<27; j++ ) {
				int manj = 0;
				for ( int k=1; k<27; k++ ) {
					if ( j==k ) {
						manj += s[i][j];
					} else {
						manj -= (c[k]*((i+1)-last[k]));
					}
				}

				if ( manj>man || ( manj==man && c[j]>c[t] ) ) {
					man = manj;
					t = j;
				}
			}

			last[t] = i+1;
			System.out.println(t);
		}

	}
}

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

int main(){
  double a,b,h,m,l;
  double r1,theta1,r2,theta2;
  
  cin >> a >> b >> h >> m;
  
  r1 = a;
  theta1 = (2*M_PI)*(h+m/60.0)/12.0;
  
  r2 = b;
  theta2 = (2*M_PI)*(m/60.0);

  l = r1*r1 + r2*r2 - 2*r1*r2*cos(theta1-theta2);
  printf("%.16f\n",pow(l,0.5));
  return 0;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
string a[8];
int ax[]={-1,-1,-1,0,0,1,1,1};
int ay[]={-1,0,1,-1,1,-1,0,1};
int i,j,turn=1,x=7,y=7,cou,k=0,c1=0,c2=0;
char mi[]={'x','o'};
int dfs(int dx,int dy){
  int aa=dx+1,bb=dy+1;
  if(y+ay[k]*aa==8||x+ax[k]*bb==8||y+ay[k]*aa<0||x+ax[k]*bb<0)return 0;
  if(a[y+ay[k]*aa][x+ax[k]*bb]==mi[(turn+1)%2])cou=dfs(aa,bb);
  else if(a[y+ay[k]*aa][x+ax[k]*bb]==mi[turn%2])return aa-1;
  else return 0;
  return cou;
}
int ds(){
  int c=0;
  for(k=0;k<8;k++){
    if(ax[k]+x==8||ay[k]+y==8||ax[k]+x<0||ay[k]+y<0)continue;
    if(a[y+ay[k]][x+ax[k]]==mi[(turn+1)%2]){c+=dfs(0,0);}
    cou=0;
  }
  return c;//
}
int re1(int dx,int dy){
  int c=0,aa=dx+1,bb=dy+1;
    if(y+ay[k]*aa==8||x+ax[k]*bb==8||y+ay[k]*aa<0||x+ax[k]*bb<0)return 0;
    if(a[y+ay[k]*aa][x+ax[k]*bb]==mi[(turn+1)%2])c=re1(aa,bb);
  else if(a[y+ay[k]*aa][x+ax[k]*bb]==mi[turn%2])return 1;
  else return 0;
  if(c){a[y+ay[k]*aa][x+ax[k]*bb]=mi[turn%2];
  return 1;
    }
    return 0;
}
void reverse(){
  a[y][x]=mi[turn%2];
  for(k=0;k<8;k++){
    if(ax[k]+x==8||ay[k]+y==8||(ax[k]+x)<0||(ay[k]+y)<0)continue;
    if(a[y+ay[k]][x+ax[k]]==mi[(turn+1)%2]){re1(0,0);}
  }
}
void tiro(){
  int m=0,max1=0,xy[8][8];
  for(y=7;y>=0;y--){
    for(x=7;x>=0;x--){
      if(a[y][x]=='.')m=ds();
      xy[y][x]=m;
      max1=max(m,max1);
      m=0;
    } 
  }
  if((turn+1)%2){
  for(y=7;y>=0;y--){
    if(max1==0)break;
    for(x=7;x>=0;x--){
      if(xy[y][x]==max1){
        reverse();
        max1=0;
        break;
      }
    }   
  }
 }
 else{
  for(y=0;y<8;y++){
    if(max1==0)break;
    for(x=0;x<8;x++){
      if(xy[y][x]==max1){
        reverse();
        max1=0;
        break;
      }
    }   
  }
 }
} 
int check(){
  int aa=0,bb=0;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(a[i][j]=='x')aa++;
      if(a[i][j]=='o')bb++;
    }
  }
  c1++;
  if((!aa||!bb)||aa+bb==64||c1>64)return 1;
  else return 0;
}
int main(){
  for(i=0;i<8;i++)cin>>a[i];
  while(1){
    tiro();
    if(check())break;
    turn++;
  }
  for(i=0;i<8;i++)cout<<a[i]<<endl;
  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

LL change_div_mul_mod(LL divisor, LL mod_minus_2, LL mod){
    if(mod_minus_2 == 0) return 1;
    else if(mod_minus_2 % 2 == 0){
        LL d = change_div_mul_mod(divisor, mod_minus_2/2, mod);
        return (d * d) % mod;
    }else{
        return (divisor * change_div_mul_mod(divisor, mod_minus_2-1, mod)) % mod;
    }
}

//#define int long long

/*************** using variables ***************/
vector<int> a;
/**********************************************/

signed main(){
    a.resize(3);
    cin >> a[0] >> a[1] >> a[2];
    VSORT(a);
    cout << a[0]+a[1] << endl;

}


Measured memory_bytes: 764
w,h,n=map(int,input().split())
g=[list(map(int,input().split())) for i in range(n)]
t1,t2,t3,t4=0,w,0,h
for i in range(n):
  if g[i][2]==1:
    t1=max(t1,g[i][0])
  elif g[i][2]==2:
    t2=min(t2,g[i][0])
  elif g[i][2]==3:
    t3=max(t3,g[i][1])
  else:
    t4=min(t4,g[i][1])
if t2<=t1 or t4<=t3:
  print(0)
else:
  print((t2-t1)*(t4-t3))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int k;
    string s;
    cin >> k >> s;
    
    if (s.size() <= k)
        cout << s << endl;
    else {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "..." << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
program main
    implicit none
    integer(8)::h, at_num, at_all
    read*,h
    at_num = 1
    at_all = 0
    do while(h > 1)
        at_all = at_all + at_num
        h = h / 2
        at_num = at_num * 2
    end do
    at_all = at_all + at_num

    print*, at_all

end program main

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$arr=array("AC"=>0,"WA"=>0,"TLE"=>0,"RE"=>0);
while($n>0){
  $s=trim(fgets(STDIN));
  ++$arr[$s];
  --$n;
}
foreach($arr as $k => $v){
  echo "$k x $v\n";
}

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

int main() {
	
	int n,num,contador=0,position;
	vector <int> v={};
	bool sort=true, swap=true;
	cin>>n;
	
	for (int i=0;i<n;i++)
	{
		cin>>num;
		v.push_back(num);
	}
	
	for (int i=1;i<=n;i++){
		if(v[i-1]!=i)
		{
			contador++;
			if (contador==1)
			position=i-1;
			
			
		if(contador>1)
		{
			if (contador>2)
			{cout<<"owo";sort=false; break;}
			else
			{
				
				if (v[i-1]==position+1 && v[position]==i)
				{
					swap=false;
				}
				else
				{sort=false; break;}
			}
		}
			
		}


	}
	
	if (sort)
	cout<<"YES";
	else
	cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a; cin >> a;
	cout << pow(a, 3) << endl;
}

Measured memory_bytes: 4216
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  int N, K;
  cin >> N >> K;

  i64 high = 0, sum = 0;

  vector<int> ps(N);
  F0R(i, N) {
    cin >> ps[i];

    sum += ps[i];
    if (i >= K - 1) {
      chmax(high, sum);
      sum -= ps[i - K + 1];
    }
  }
  high += K;
  long double r = 0.5 * high;
  cout << r;
}
#endif


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

const mod = 1000000007

func main() {
	var N int64
	fmt.Scan(&N)
	var D int64
	fmt.Scan(&D)
	sc.Split(bufio.ScanWords)
	count := 0
	dd := D * D
	for i := int64(0); i < N; i++ {
		a := nextInt()
		b := nextInt()
		if int64(a*a+b*b) <= dd {
			count++
		}
	}
	fmt.Print(count)
}
func helper(a []int64, b []int64, t int64, dp [][]int, dpt [][]bool) int {
	ca := 0
	cb := 0
	la := len(a)
	lb := len(b)
	tb := &dpt[la][lb]
	tc := &dp[la][lb]
	if *tb == true {
		return *tc
	}
	if la >= 1 && t-a[0] >= 0 {
		ca = 1 + helper(a[1:], b, t-a[0], dp, dpt)
	}
	if len(b) >= 1 && t-b[0] >= 0 {
		cb = 1 + helper(a, b[1:], t-b[0], dp, dpt)
	}
	ans := Max(ca, cb)
	*tb = true
	*tc = ans
	return ans
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int64) {
	var num int64
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 4964
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define maxn 1000005
#define mod 924844033
using namespace std;
const int G=5;
int omega[maxn],N=1,n;
inline int add(int a,int b){a+=b; return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b; return a<0?a+mod:a;}
int ksm(int a,int b){int s=1;for(;b;a=1ll*a*a%mod,b>>=1) if(b&1) s=1ll*s*a%mod; return s;}
int fac[maxn],facinv[maxn],cnt[maxn];
void NTT(int *A,int n,int type)
{
    int t0,t1;
    for(int i=0,j=0;i<n;i++)
    {
        if(i<j) swap(A[i],A[j]);
        for(int k=(n>>1);(j^=k)<k;k>>=1);
    }
    omega[0]=1;
    for(int m=1;m<n;m<<=1)
    {
        t0=ksm(G,(mod-1+type*(mod-1)/(m<<1))%(mod-1));
        for(int i=1;i<m;i++) omega[i]=1ll*omega[i-1]*t0%mod;
        for(int k=0;k<n;k+=(m<<1))
        {
            for(int i=k;i<k+m;i++)
            {
                t0=A[i];
                t1=1ll*A[i+m]*omega[i-k]%mod;
                A[i]=add(t0,t1),A[i+m]=sub(t0,t1);
            }
        }
    }
    if(type==1) return;
    t0=ksm(n,mod-2);
    for(int i=0;i<n;i++) A[i]=1ll*A[i]*t0%mod;
}
int t0[maxn],t1[maxn];
void Mul(int *A,int *B,int *C)
{
    for(int i=0;i<N;i++) t0[i]=A[i],t1[i]=B[i];
    NTT(t0,N,1),NTT(t1,N,1);
    for(int i=0;i<N;i++) t0[i]=1ll*t0[i]*t1[i]%mod;
    NTT(t0,N,-1);
    for(int i=0;i<N;i++) C[i]=t0[i];
}
int pre[maxn],las[maxn],to[maxn],sz[maxn],inc;
void ins(int a,int b){pre[++inc]=las[a],las[a]=inc,to[inc]=b;}
void dfs(int x,int f)
{
    sz[x]=1;
    for(int i=las[x];i;i=pre[i])
    {
        if(to[i]==f) continue;
        dfs(to[i],x),sz[x]+=sz[to[i]];
    }
    if(x!=1) cnt[sz[x]]++,cnt[n-sz[x]]++;
}
int cc[maxn];
int main()
{
    scanf("%d",&n);
    fac[0]=facinv[0]=1;
    for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod,facinv[i]=ksm(fac[i],mod-2);
    for(int i=1;i<=n;i++) cc[i]=1ll*fac[n]*facinv[i]%mod*facinv[n-i]%mod*n%mod;
    for(int i=1,u,v;i<n;i++) scanf("%d%d",&u,&v),ins(u,v),ins(v,u);
    dfs(1,0);
    for(int i=0;i<=n;i++) fac[i]=1ll*fac[i]*cnt[i]%mod;
    reverse(facinv,facinv+n+1);
    while(N<=2*n) N<<=1;
    Mul(fac,facinv,fac);
    reverse(facinv,facinv+n+1);
    for(int i=1;i<=n;i++)
        printf("%d\n",sub(cc[i],1ll*facinv[i]*fac[i+n]%mod));
    return 0;
}

Measured memory_bytes: 45696