akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
long long M = 1e9+7;
long long power(long long a, long long p)
{
    if(p==0) return 1;
    long long ans= power(a,p/2);
    ans =(ans * ans) % M;
    if(p%2) ans = (ans*a) % M;
    return ans;
}

bool isPrime(long long n)
{
    if (n <= 1)
        return false;
    for (long long i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
long long SieveOfEratosthenes(long long n, long long a)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (long long p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (long long i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (long long p=2; p<=n; p++)
       if (prime[p])
       {
           if(a%p==0)
           {
               return (a-p);
           }
       }
}
long long nCr(int n, int r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}
//int vis[51][51];
//int x[]={1,0,0,-1};
//int y[]={0,1,-1,0};
/* void dfs_visit(long long n,long long a, long long b)
{
    vis[a][b]=1;
    for(int i=0; i<4; i++)
    {

        int p=a+x[i];
        int q=b+y[i];
        if(p>=0 && p<n && q>=0 && q<n && vis[p][q]==0)
        {
           // cout<<p<<" "<<q<<endl;
            vis[p][q]=1;
            dfs_visit(n,p,q);
        }
    }
}
*/
long long fun(long long a)
{
    long long co=1,res=0;
    while(a>0)
    {
        if(a%2==0)
        {
            res=co;
        }
        a/=2;
        co++;
    }
    return res;
}

int main()
{
    IOS;
    long long a,b,c,d,e,h,l,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
   // vector<string>vs;
   // vector<string>vs1;
    //map<long long,long long>mp;
    //set<long long>s;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
   // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    //int x[]={1,1,1,0,0,-1,-1,-1};
    //int y[]={0,1,-1,1,-1,1,-1,0};
    //int x[]={1,0,0,-1};
    //int y[]={0,1,-1,0};
    cin>>a>>b>>c;
    d=min((b-1),c);
    cout<<(a*d)/b<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
#define ll long long

void solve()
{
	int n,k;cin>>n>>k;
	vector < double > v(n);
	int arr[n];
	int dp[n]={0};
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		if(!i)
		dp[i]=arr[i];
		else
		dp[i]=dp[i-1]+arr[i];
	}
	ll mx=dp[k-1];
	int l=0,r=k-1;
	for(int i=0,j=k;j<n;++i,++j)
	{	//cout<<dp[j]<<" "<<dp[i]<<" "<<mx<<endl;
		if((dp[j]-dp[i])>mx)
		{
			mx=dp[j]-dp[i];
			l=i+1,r=j;
		}
	}
	//cout<<l<<" "<<r<<endl;
	double sum=0;
	for(int i=l;i<=r;i++)
	{
	sum+=double(arr[i]+1)/2;
	}
	printf("%.10f",sum);
	
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



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

        char ans;
        if (a + b == 15) {
                ans = '+';
        } else if (a * b == 15) {
                ans = '*';
        } else {
                ans = 'x';
        }

        cout << ans << endl;
}


Measured memory_bytes: 3584
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
    int x,i,j,t;
    x = A[r]; //比較対象の数字
    i = p-1;
    for(j = p;j<r;j++){
        if(A[j] <= x){
            i++;
            t = A[i];A[i]=A[j];A[j]=t;
        }
    }
    t = A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}

int main(){
    int i,q;

    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);

    q = partition(0,n-1);

    for(i=0;i<n;i++){
        if(i)printf(" ");
        if(i == q)printf("[");
        printf("%d",A[i]);
        if(i == q)printf("]");
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2228
S = []
for _ in range(5):
    S.append(int(input()))

q=[] #quotient
r=[] #reminder
count0=0 #余りが0の時を検出
for i in S:
  j, k= divmod(i, 10)
  q.append(j)
  if k==0:
    count0+=1
  else:
    r.append(k)

# sum(q)*10→商をベースに基本値を算出
# 10*(4-count0)→余り分の待ち時間を算出。ただし、余り0の場合には待ち時間なし
# min(r)→最も余りが短い料理を最後に注文する
# 最初、すべてが0になる場合を想定できていなかったので、REになった
if count0==5:
  print(sum(S))
else:
  print(sum(q)*10+10*(4-count0)+min(r))
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll a;
    long  double b;
    cin >> a >> b;
    cout << (ll)floor(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
    #include<string.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define Max(x,y,z) max(x,max(y,z))
    #define Min(x,y,z) min(x,min(y,z))
    #define fr(i,s,e) for(i=s;i<e;i++)
    #define rf(i,s,e) for(i=s-1;i>=e;i--)
    #define pb push_back
    #define eb emblace_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define ll long long
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define vl vector<long long>
     
    #define vi vector<int> 
    #define vii vector< vector<int> >
    #define vll vector< vector<long long> >
    #define vpi vector< pair<int,int> >   
    #define vpl vector< pair<ll,ll> >   
    typedef pair<pair<int, int>,int> P;
     #define mod %1000000007
     
    bool less_vectors(const vector<int>& a,const vector<int>& b) 
    {
       return a.size() > b.size();
    }
     
    int gcd(int a,int b)
    {
    	if(a%b==0)
    		return b;
    		else
    			return gcd(b,a%b);
    }
     
    bool cmp(pair<int,pair<int,int> >  p1,pair<int,pair<int,int> > p2)
    {
    		return p1.ff>p2.ff;
    }
    
    int main()
    {
    	IOS;
    	ll a,b;
		cin>>a>>b;
		bool ch=0;
		if(a%3==0)
			ch=1;
			else
				if(b%3==0)
					ch=1;
					else
						if((a+b)%3==0)
							ch=1;
		if(ch)
			cout<<"Possible";
			else
				cout<<"Impossible";
    	return 0;
    		
    } 

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

string num[9] = {
"########.....##...|.##.....##...|.##..-..########",
"########..-..##...|.##..-..##.|...##..-..########",
"########..-..##...|.##..-..##...|.##..-..########",
"########.....##.|.|.##..-..##...|.##.....########",
"########..-..##.|...##..-..##...|.##..-..########",
"########..-..##.|...##..-..##.|.|.##..-..########",
"########..-..##...|.##.....##...|.##.....########",
"########..-..##.|.|.##..-..##.|.|.##..-..########",
"########..-..##.|.|.##..-..##...|.##..-..########"
};

int conv(int i,int k) {
    int x = i%7;
    int y = i/7;
        
    if(k == 0) return 7*y+(7-x-1);
    if(k == 1) {
        int rx = 7-x-1,ry = y;
        return (7-rx-1)*7+ry;
    }
    if(k == 2) {
        return (7-y-1)*7+(7-x-1);
    }
    if(k == 3) {
        int rx = 7-x-1,ry = y;
        return rx*7+(7-ry-1);
    }
}

string input[21];

int calc(int y,int x,int i) {

    string ss(49,'.');
    for(int k=0; k<49; ++k) {
        int lk = conv(k,i);
        ss[lk] = input[y+k/7][x+k%7];
        if(i%2 && ss[lk] == '|') ss[lk] = '-';
        else if(i%2 && ss[lk] == '-') ss[lk] = '|';
    }

    // cout<<i<<endl;
    // for(int j=0; j<7; ++j) {
    //     for(int l=0; l<7; ++l) {
    //         cout<<ss[j*7+l];
    //     }
    //     cout<<endl;
    // }

    for(int numk=0; numk<9; ++numk) {
        if(num[numk] == ss) return numk+1;
    }

    assert(false);
    return -1;
}

int v1[6],v2[6];

int main() {
    while(true) {
        cin>>input[0];
        if(input[0] == "0") break;
        for(int i=1; i<21; ++i) cin>>input[i];

        int sum1 = 0;
        // cout<<calc(0,7,0)<<" "<<calc(7,0,1)<<" "<<calc(7,7,0)<<" "<<calc(7,14,3)<<" ";
        // cout<<calc(7,21,0)<<" "<<calc(14,7,2)<<endl;
        v1[0]=calc(0,7,0),v1[1]=calc(7,0,1),v1[2]=calc(7,7,0),v1[3]=calc(7,14,3);
        v1[4]=calc(7,21,0),v1[5]=calc(14,7,2);

        int sum2 = 0;
        // cout<<calc(0,36,0)<<" "<<calc(7,29,1)<<" "<<calc(7,36,0)<<" "<<calc(7,43,3)<<" ";
        // cout<<calc(7,50,0)<<" "<<calc(14,36,2)<<endl;
        v2[0]=calc(0,36,0),v2[1]=calc(7,29,1),v2[2]=calc(7,36,0),v2[3]=calc(7,43,3);
        v2[4]=calc(7,50,0),v2[5]=calc(14,36,2);

        int high=0,low=0,cc = 0;
        for(int i=0; i<6; ++i) {
            for(int j=0; j<6; ++j) {
                if(v1[i] > v2[j]) high++;
                else if(v1[i] < v2[j]) low++;
                if(v1[i] != v2[j]) cc++;
            }
        }
//        cout<<sum1<<" "<<sum2<<endl;

        if(high >= low) cout<<"HIGH"<<endl;
        else cout<<"LOW"<<endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int n, m, c, sum, ans = 0;
	cin >> n >> m >> c;
	vector<int> a(m), b(m);
	REP(i, m) cin >> b[i];

	REP(i, n){
		sum = c;
		REP(j, m){
			cin >> a[j];
			sum += a[j]*b[j];
		}
		if(sum > 0) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	ll res = h2 * 60 + m2 - (h1 * 60 + m1) - k;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <memory.h>
#include <iomanip>
using namespace std;

#define maxn 302
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
const ll MOD = 1000000007;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int n, m;
ll f[maxn][maxn][maxn];
vector<ii> R[maxn];

bool check(int i, int x, int y, int z) {
    REP(j, R[i].sz()) {
        int l = R[i][j].fi, T = R[i][j].se, cnt = 0;
        if (x>=l) ++cnt;
        if (y>=l) ++cnt;
        if (z>=l) ++cnt;
        if (cnt!=T) return false;
    }
    return true;
}

ll dp(int x, int y, int z) {
    if (f[x][y][z]>-1) return f[x][y][z];
    int i = max(max(x, y), z);
    if (i==n) return check(i, x, y, z);
    if (!check(i, x, y, z)) return f[x][y][z] = 0;
    return f[x][y][z] = (dp(i+1, y, z) + dp(x, i+1, z) + dp(x, y, i+1))%MOD;
}

int main() {
    //freopen("rbg.inp", "r", stdin);
    //freopen("", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d%d", &n, &m);
    memset(f, -1, sizeof(f));
    while (m--) {
        int l, r, x; scanf("%d%d%d", &l, &r, &x);
        R[r].push_back(ii(l, x));
    }
    //Debug(dp(0, 0, 1));
    //cout << (dp(0, 0, 1) + dp(0, 1, 0) + dp(1, 0, 0))%MOD;
    cout << dp(0, 0, 1)*3%MOD;
}



Measured memory_bytes: 215552
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
int a[MAXN],n,L,go[19][MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	scanf("%d",&L);
	memset(go,0x3f,sizeof(go));
	for(int i=1;i<=n;++i){
		int p=upper_bound(a+1,a+n+1,a[i]+L)-a;
		if(p!=n+1)go[0][i]=p-1;
	}
	for(int i=1;i<=18;++i)
		for(int j=1;j<=n;++j)
			if(go[i-1][j]!=0x3f3f3f3f)go[i][j]=go[i-1][go[i-1][j]];
	int q;
	scanf("%d",&q);
	while(q--){
		int x,y,ans=0;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		for(int i=18;i>=0;--i)
			if(go[i][x]!=0x3f3f3f3f && a[go[i][x]]<=a[y])
				x=go[i][x],ans+=(1<<i);
		if(x==y)printf("%d\n",ans);
		else printf("%d\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<int> C(N);
    cin >> C;
    sort(C.begin(), C.end());
    int ans = 0, add = 1;
    if (N == 1) {
        (ans += C[0]) %= mod;
        (ans += C[0]) %= mod;
        cout << ans << endl;
        return 0;
    }
    for (int i = 2; i < N; i++) {
        add *= 2;
        add %= mod;
    }
    int temp = (add * 2) % mod;
    for (int i = N - 1; i >= 0; i--) {
        ans += (((C[i]) * temp) % mod);
        ans %= mod;
        temp += add;
        temp %= mod;
    }
    for (int i = 0; i < N; i++) {
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
s = input()
s1, s2 = s[:2],s[2:]
if s1>'12' and s2>'12':
    print('NA')
elif s1<='12' and s2<='12':
    if s1 == '00' and s2!='00':
        print('YYMM')
    elif s2 == '00' and s1!='00':
        print('MMYY')
    elif s1 =='00' and s2 =='00':
        print('NA')
    else :
        print('AMBIGUOUS')
elif s1<='12' and s2>'12':
    print('NA' if s1 == '00' else 'MMYY')   
elif s2<='12' and s1>'12':
    print('NA' if s2 == '00' else 'YYMM')
else:
    print('NA')

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define endl "\n"
#define INF (ll) (3e18)
double dp[3005];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    for(ll i=0;i<=n;i++)
        dp[i]=1;
    double p;
    cin>>dp[1];
    dp[0]=1.-dp[1];
    for(ll i=2;i<=n;i++){
        cin>>p;dp[i]=dp[i-1]*p;
        for(ll j=i-2;j>=0;j--)
            dp[j+1]=dp[j]*p+dp[j+1]*(1.-p);
        dp[0]*=(1.-p);
    }
    double ans=0;
    if(n&1)
        for(ll i=n;i>=n/2+1;i--)
            ans+=dp[i];
    else
        for(ll i=n;i>n/2;i--)
            ans+=dp[i];
    cout<<setprecision(15)<<ans<<endl;
    return 0;
}





Measured memory_bytes: 256
import math
from collections import deque
def main():
    a,b,m = tuple([int(t)for t in input().split()])

    a_i = [int(t)for t in input().split()]
    b_i = [int(t)for t in input().split()]

    pairs = []
    for _ in range(m):
        pairs.append(tuple([int(t)for t in input().split()]))

    candidates = [min(a_i)+min(b_i)]

    for x,y,c in pairs:
        candidates.append(a_i[x-1]+b_i[y-1]-c)

    print(min(candidates))

if __name__ == "__main__":
    main()

Measured memory_bytes: 33200
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void integerFactorization(long long n, vector<pair<long long, int> >& factor)
{
    factor.clear();
    long long a = 2;
    while(a * a <= n){
        int b = 0;
        while(n % a == 0){
            ++ b;
            n /= a;
        }
        if(b > 0)
            factor.push_back(make_pair(a, b));
        ++ a;
    }
    if(n > 1)
        factor.push_back(make_pair(n, 1));
}

void mod_inverse(int n, vector<long long>& inv, int mod)
{
    inv.assign(n+1, -1);
    inv[1] = 1;
    for(int i=2; i<=n; ++i)
        inv[i] = inv[mod % i] * (mod - mod / i) % mod;
}

class FactorialCalculation
{
private:
    const int mod;
    vector<long long> factorial;
    vector<long long> invFactorial;
public:
    FactorialCalculation(int n, int mod) : mod(mod)
    {
        factorial.resize(n+1, 1);
        invFactorial.resize(n+1, 1);
        vector<long long> inv;
        mod_inverse(n, inv, mod);
        for(int i=1; i<=n; ++i){
            factorial[i] = factorial[i-1] * i % mod;
            invFactorial[i] = invFactorial[i-1] * inv[i] % mod;
        }
    }
    long long getFactorial(int n){
        return factorial[n];
    }
    long long getInvFactorial(int n){
        return invFactorial[n];
    }
    long long getPermutation(int n, int r){
        if(n < r)
            return 0;
        return factorial[n] * invFactorial[n-r] % mod;
    }
    long long getCombination(int n, int r){
        if(n < r)
            return 0;
        return getPermutation(n, r) * invFactorial[r] % mod;
    }
    long long getHomogeneous(int n, int r){
        return getCombination(n+r-1, r);
    }
};

const int MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    FactorialCalculation fc(n+100, MOD);

    vector<pair<long long, int> > factor;
    integerFactorization(m, factor);
    long long ans = 1;
    for(const auto& p : factor){
        ans *= fc.getHomogeneous(n, p.second);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255
#define ll long long

using namespace std;
const ll dividend = 1000000007;
const ll limit = pow(10, 18);
const ll bigNum = pow(10, 9);

ll funcComb(int n, int k) 
{
	ll output = 1;
	int sum = n + k;
	vector<int> dividends;
	for (int i = 0; i < k; i++)
	{
		dividends.push_back(k - i);
	}
	for (int i = 0; i < k; i++)
	{
		output *= sum - i;
		for (auto it = dividends.begin(); it != dividends.end(); it++)
		{
			if (*it == 0)
				continue;
			if (output % *it == 0)
			{
				output /= *it;
				*it = 0;
			}
		}
		if (output > dividend)
		{
			output %= dividend;
		}
	}

	return output;
}

vector<bool> outputs;

int main()
{
	int x, y;
	cin >> x >> y;

	bool ret = false;
	if (y % 2 != 0)
	{
		cout << "No" << endl;
		return 0;
	}
	if (y < 2 * x || y > 4 * x)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3596
import collections
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = input()

set_s = set(s)
cnt_s = collections.Counter(s)

m=0
for i in set_s:
    m = max(m,cnt_s[i])
ans=[]
for i in set_s:
    if cnt_s[i]==m:
        ans.append(i)
ans = sorted(ans)

for a in ans:
    print(a)



Measured memory_bytes: 49764
fun main() {
    val (n, k) = readInts()
    val logs = readInts()

    var a = 0
    var b = logs.max()!!

    while (b - a > 1) {
        val c = (b + a) / 2
        val cuts = logs.sumBy { log -> ((log + c - 1) / c - 1) }

        if (cuts <= k) b = c
        else a = c
    }
    println(b)
}

private fun readInt() = readLine()!!.toInt()
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 64984
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

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

using namespace std;

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

  string S;
  cin >> S;

  int l = 0;
  int r = S.size() - 1;

  int ans = 0;
  while (l < r) {
    if (S[l] == S[r]) {
      l++;
      r--;
    } else {
      if (S[l] == 'x') {
        ans++;
        l++;
      } else if (S[r] == 'x') {
        ans++;
        r--;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#define N 250
int A[N];

int parent(int i){
  return i/2;
}
int left(int i){
  return i*2;
}
int right(int i){
  return i*2+1;
}

int main(){
  int H;
  int i;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1){
      printf("parent key = %d, ",A[parent(i)]);
    }if(left(i) <=H){
      printf("left key = %d, ",A[left(i)]);
    }if(right(i) <= H){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#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; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  char s[30][30];
  REP(i, h) {
    string t;
    cin >> t;
    REP(j, w) { s[i][j] = t[j]; }
  }

  ll ans = 0;
  REP(i, h) REP(j, w) {
    if (s[i][j] == '#') continue;
    ll d[30][30];
    REP(x, h) REP(y, w) { d[x][y] = INF; }
    d[i][j] = 0;

    queue<P> que;
    que.push(P(i, j));
    while (!que.empty()) {
      P v = que.front();
      que.pop();
      REP(k, 4) {
        ll nx = v.first + dx[k], ny = v.second + dy[k];
        if (!(0 <= nx && nx < h && 0 <= ny && ny < w)) continue;
        if (s[nx][ny] == '#' || d[nx][ny] != INF) continue;
        d[nx][ny] = d[v.first][v.second] + 1;
        que.push(P(nx, ny));
      }
    }
    REP(x, h) REP(y, w) {
      if (d[x][y] == INF) continue;
      ans = max(ans, d[x][y]);
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    set <string> pins;
    set <string> pairs;
    set <string> chars;
    for(int i = 0; i < N; i++){
        for(auto it = pairs.begin(); it != pairs.end(); it++){
            string tmp = *it;
            tmp.push_back(S[i]);
            if(pins.find(tmp) == pins.end()){
                pins.insert(tmp);
            }
        }
        for(auto it = chars.begin(); it != chars.end(); it++){
            string tmp = *it;
            tmp.push_back(S[i]);
            if(pairs.find(tmp) == pairs.end()){
                pairs.insert(tmp);
            }
        }
        
        string tmp = "";
        tmp.push_back(S[i]);
        if(chars.find(tmp) == chars.end()){
            chars.insert(tmp);
        }
    }
    cout << pins.size() << endl;
    return 0;
}



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

#define int long long int
int32_t main()
{
    
   int p,k;
   cin>>p>>k;
   int a[k];
   for(int i=0;i<k;i++)
    cin>>a[i];
    int max1=INT_MIN;
    int sum1=0;
    for(int i=1;i<k;i++)
    {
        max1=max(a[i]-a[i-1],max1);
        sum1+=a[i]-a[i-1];
    }


    cout<<p-max(p-sum1,max1)<<endl;


    return 0;

}

Measured memory_bytes: 1792
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();

  		String[] s=new String[n+1];
		for(int c=0;c<n;c++){
    		s[c]=sc.next();
    	}
  	s[n]="zzzzzzzzzzzzzzzzzzz";
  	  Arrays.sort(s);
  		
  		ArrayList<String> ans=new ArrayList<String>(n);
  		int count=0;
  		int max=0;
  		int k=0;
  		if(s[0].equals(s[1])){
  		ans.add(s[0]);
        }
  		for(int d=0;d<n;d++){
          if(s[d].equals(s[d+1])){
          	count++;
           
          }else{
            
            if(max<count){
             ans.clear();
            ans.add(s[d]);
        
          	max=count;
            
            }else if(max==count){
             ans.add(s[d]);
             max=count;
            
            }
            count=0;
            
          }
        
        }
    
 	for(String a:ans){

    	System.out.println(a);
    }
    }
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
int a[N];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i];
    int maxx = a[1];
    ll sum = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] < maxx)sum += 1ll * abs(a[i] - maxx);
        maxx = max(maxx, a[i]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4392
import bisect
a,b,q=map(int,input().split())
ff=float("inf")
s=[-ff]
t=[-ff]
for i in range(a):
    v=int(input())
    s.append(v)
for i in range(b):
    w=int(input())
    t.append(w)
s.append(ff)
t.append(ff)
s.sort()
t.sort()
for i in range(q):
    x=int(input())
    a=bisect.bisect_right(s,x)
    b=bisect.bisect_right(t,x)
    res=ff
    for y in [s[a],s[a-1]]:
        for w in [t[b],t[b-1]]:
            d1,d2=abs(y-x)+abs(w-y),abs(w-x)+abs(w-y)
            res=min(res,d1,d2)
    print(res)

Measured memory_bytes: 12088
l = [int(input()) for _ in range(6)]
f = True
if abs(l[0] - l[1]) > l[5] or abs(l[0] - l[2]) > l[5] or abs(l[0] - l[3]) > l[5] or abs(l[0] - l[4]) > l[5]:
    f = False
elif abs(l[1] - l[2]) > l[5] or abs(l[1] - l[3]) > l[5] or abs(l[1] - l[4]) > l[5]:
    f = False
elif abs(l[2] - l[3]) > l[5] or abs(l[2] - l[4]) > l[5]:
    f = False
elif abs(l[3] - l[4]) > l[5]:
    f = False
print('Yay!' if f else ':(')


Measured memory_bytes: 3064
from collections import deque

def getDiameter(adjList):
    def bfs(vSt):
        dists = [-1] * numV
        dists[vSt] = 0
        Q = deque([vSt])
        while Q:
            vNow = Q.popleft()
            distNow = dists[vNow]
            for v2 in adjList[vNow]:
                if dists[v2] == -1:
                    dists[v2] = distNow + 1
                    Q.append(v2)

        maxD = max(dists)
        vMaxD = dists.index(maxD)
        return (vMaxD, maxD)

    numV = len(adjList)
    v, d = bfs(0)
    v2, d2 = bfs(v)
    return d2


N = int(input())
adjL = [[] for v in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adjL[a-1].append(b-1)
    adjL[b-1].append(a-1)

if getDiameter(adjL) % 3 == 1:
    print('Second')
else:
    print('First')


Measured memory_bytes: 47504
n,m = map(int, raw_input().split())
arr = []
for i in xrange(n):
	a,b = map(int, raw_input().split())
	arr.append((a,b))
arr.sort()
ans = 0
ptr = 0
while m > 0:
	ans += min(m,arr[ptr][1])*arr[ptr][0]
	m -= min(m, arr[ptr][1])
	ptr += 1
print ans


Measured memory_bytes: 42272
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        vector<vector<char> > v(n);
        rep(i,n) {
            rep(j,5) {
                char c;
                cin >> c;
                v[i].push_back(c);
            }
        }

        int ans = 0;
        while(true) {
            bool flag = true;

            rep(i,n) {
                rep(j,3) {
                    if(v[i][j] == '0') continue;

                    int len = 1;
                    REP(k,j+1,5) {
                        if(v[i][j] == v[i][k]) {
                            len++;
                        }
                        else break;
                    }

                    if(len >= 3) {
                        flag = false;
                        REP(k,j,j+len) {
                            ans += v[i][k] - '0';
                            v[i][k] = '0';
                        }
                    }
                }
            }

            if(flag) break;

            for(int i=n-1;i>0;i--) {
                rep(j,5) {
                    if(v[i][j] != '0') continue;

                    int y = i-1;
                    while(0 < y && v[y][j] == '0') y--;
                    swap(v[i][j],v[y][j]);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LP lower_bound
#define UP upper_bound
#define MP make_pair
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define UMP unordered_map
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    /*
    **  author : mahiman12
    **  created : 2020-05-03 17:39 
    */
    cin>>n>>m;
    ll arr[n+1];
    rep(i,1,n+1)
    {
        cin>>arr[i];
    }
    bool res[n+1];
    memset(res, true, sizeof(res));
    rep(i,0,m)
    {
        cin>>a>>b;
        if(arr[a]<arr[b])
        {
            res[a]&=false;
        }
        else if(arr[a]>arr[b])
        {
            res[b]&=false;
        }
        else
        {
            res[a]&=false;
            res[b]&=false;
        }
    }
    ll ans=0;
    rep(i,1,n+1)
    {
        // cout<<res[i]<<endl;
        if(res[i])
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 4528
#include "iostream"
using namespace std;
int main() {
	int a, b, c, ans;
	cin >> a >> b >> c;
	if (a == b && b == c)ans = 1;
	else if (a == b || a == c || b == c)ans = 2;
	else ans = 3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/24.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int N;
    char S[110];

    cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>S[i];
    }

    bool flags[] = {0,0,0,0};

    for (int i = 0; i < N; ++i) {
        switch(S[i]){
            case 'P':
                flags[0] =1;
                break;
            case 'W':
                flags[1] = 1;
                break;
            case 'G':
                flags[2] = 1;
                break;
            case 'Y':
                flags[3] = 1;
        }
    }

    int count = 0;
    for (int i = 0; i < 4; ++i) {
        if(flags[i])count++;
    }

    if(count>3){
        cout<<"Four"<<endl;
    }else{
        cout<<"Three"<<endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin >> c;
    if (c == 'A')
        cout << 'T' << endl;
    else if (c == 'T')
        cout << 'A' << endl;
    else if (c == 'C')
        cout << 'G' << endl;
    else if (c == 'G')
        cout << 'C' << endl;
    
    return 0;
}


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

N_d = []
N1_d = []
answer = set()
for i in range(1,math.ceil(N**0.5)+1):
    if N%i == 0:
        N_d.append(i)
        N_d.append(N//i)

for i in range(len(N_d)):
    temp = N
    while temp % N_d[i] == 0:
        temp = temp//N_d[i]
        if N_d[i] == 1:
            break
        
    if temp % N_d[i] == 1:
        answer.add(N_d[i])


for i in range(1,math.ceil((N-1)**0.5)+1):
    if (N-1) %i == 0:
        answer.add(i)
        answer.add((N-1)//i)

answer.remove(1)
print(len(answer))

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int ans;
    ans = H * W - h *W - H * w + h * w;
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

ll D;
ll c[26+1];
ll s[365+1][26+1];

ll last[365+1];

int main(){
    cin>>D;
    repn(i,26) cin>>c[i];
    repn(i,D) repn(j,26) cin>>s[i][j];

    //ll v=0;
    repn(d,D){
        ll maxi=0;
        ll k=0;
        repn(i,26){
            if(maxi<=s[d][i]){
                maxi=s[d][i];
                k=i;
            }
        }
        //cout<<idx<<':'<<maxi<<endl;
        //v+=maxi;
        //last[k]=d;
        //repn(i,26) v-=c[i]*(d-last[i]);
        cout<<k<<endl;
    }
}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b)
{
	ll x = a * b;
	if (a < b) {
		swap(a, b);
	}
	ll r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}

	return x / b;
}

int dev2cnt(ll a)
{
	int cnt = 0;
	while (a % 2 == 0) {
		a /= 2;
		cnt++;
	}
	return cnt;
}

int main(int argc, char *argv[])
{
	ll N, M, a[100005];

	cin >> N >> M;

	for (ll i = 0; i < N; i++) {
		cin >> a[i];
		a[i] /= 2;
	}

	int dc = dev2cnt(a[0]);
	for (ll i = 1; i < N; i++) {
		if (dc != dev2cnt(a[i])) {
			cout << 0 << endl;
			return 0;
		}
	}

	ll g = a[0];
	for (ll i = 1; i < N; i++) {
		g = gcd(g, a[i]);
	}

	ll c = 0;
	for (ll i = 1; 0 <= g * i && g * i <= M; i += 2) {
		c++;
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int n,m;
int x[100005],y[100005];
int sum_x,sum_y;

signed main(){
    cin>>n>>m;
    for(int i=0;i<n;++i)cin>>x[i];
    for(int i=0;i<m;++i)cin>>y[i];
    for(int i=0;i<n;++i){
        sum_x+=i*x[i]-(n-i-1)*x[i];
        sum_x%=mod;
    }
    for(int i=0;i<m;++i){
        sum_y+=i*y[i]-(m-i-1)*y[i];
        sum_y%=mod;
    }
    cout<<(sum_x*sum_y)%mod<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {1, 0}, dx[] = {0, 1};
int h, w, n;
bool ok(vector<string> v){
	while(1){
		for(int i = h - 2; i >= 0; i--) rep(j, w) if(v[i][j] != '.'){
			int k = i + 1;
			while(k < h && v[k][j] == '.'){
				swap(v[k][j], v[k - 1][j]);
				k++;
			}
		}
		bool er[30][30] = {}, update = 0;
		rep(i, h) rep(j, w) if(v[i][j] != '.') rep(d, 2){
			int k = 0, y = i, x = j;
			while(y < h && x < w && v[y][x] == v[i][j]){
				k++;
				y += dy[d]; x += dx[d];
			}
			if(k < n) continue;
			y = i; x = j;
			while(y < h && x < w && v[y][x] == v[i][j]){
				er[y][x] = 1;
				y += dy[d]; x += dx[d];
			}
		}
		rep(i, h) rep(j, w) if(er[i][j]){
			update = 1;
			v[i][j] = '.';
		}
		if(!update) break;
	}
	rep(i, h) rep(j, w) if(v[i][j] != '.') return 0;
	return 1;
}

int main(){
	cin >> h >> w >> n;
	vector<string> in(h);
	
	rep(i, h) cin >> in[i];
	rep(i, h) rep(j, w) for(int k = 1; k < 2; k++){
		int y = i + dy[k], x = j + dx[k];
		if(y >= h || x >= w) continue;
		swap(in[i][j], in[y][x]);
		
		if(ok(in)){
			cout << "YES" << endl;
			return 0;
		}
		swap(in[i][j], in[y][x]);
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
using namespace std;
int main()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    int x = 0;
    int max1 = 0;
    for (int i=0; i<a; i++)
    {
        if (s[i] == 'I')
        {
            x++;
        }
        else
        {
            x--;
        }
        max1 = max (x,max1);
    }
    cout << max1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
long long GCD(long long a,long long b)
{
	if(a<b) swap(a,b);
	long long r=a%b;
	while(r)
	{
		r=a%b;
		a=b;b=r;
	}
	return a;
}
int main()
{
	//freopen("out.txt","w",stdout);
	int T;scanf("%d",&T);
	while(T--)
	{
		long long A,B,C,D;
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		long long x=A%B,y=GCD(D,B);
		if(A<B || D<B || A%B>C) {printf("No\n");continue;}
		if(C>B || D%B==0) {printf("Yes\n");continue;}
		if(((C+1-x)%y+B-C-2)>=y || (B-C>1 && (C+1-x)%y==0))
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

struct abc{
    int id;
    int last = 0;
    int c;
    vi s;

public:
    abc(int n, int id){
        s = vi(n+1);
        this -> id = id;
    }
};


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

  int d;
  cin >> d;
  vector<abc> abcs;
  rep(i,26) abcs.push_back(abc(d, i+1));

  rep(i,26){
      cin >> abcs[i].c;
  }

  rep(i,d){
      rep(j,26) cin >> abcs[j].s[i+1];
  }

  vi ret(d);

  for(int day = 1; day <= d; day++){
    sort(all(abcs),[=](auto const& lhs, auto const& rhs) {
        return lhs.c * (day - lhs.last) + lhs.s[day] > rhs.c * (day - rhs.last) + rhs.s[day];
    });
    
    ret[day - 1] = abcs[0].id;
    abcs[0].last = day;
  }

  rep(i,d){
      cout << ret[i] << endl;
  }
}

Measured memory_bytes: 3712
#include<cstdio>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=10){
		a=10-a;
		a=100*a;
		printf("%d\n",a+b);
	}
	else printf ("%d\n",b);
	return 0;
}


Measured memory_bytes: 128
require 'prime'

N, M = gets.chomp.split.map(&:to_i)

MOD = 10 ** 9 + 7

class Integer
  def combination(k)
    (self - k + 1..self).inject(&:*) / k.factorial
  end

  def factorial
    return 1 if self == 0
    (1..self).inject(&:*)
  end
end

ans = 1

M.prime_division.each do |base, k|
  ans = (ans * (k + N - 1).combination(k)) % MOD
end

puts ans


Measured memory_bytes: 2044
#include <algorithm>
#include<iostream>
using namespace std;
const long long mod = 998244353;
int main(void) {
	long long A, B, C, D;
	cin >> A >> B >> C >> D;
	long long DP[3001][3001];
	DP[A][B] = 1;
	long long ans = 0;
	long long N;

	long long i, j, t, k;
	for (i = A + 1; i < C + 1; i++) {
		DP[i][B] = DP[i - 1][B] * B % mod;
	}
	for (i = B + 1; i < D + 1; i++) {
		DP[A][i] = DP[A][i - 1] * A % mod;
	}
	N = (C - A) + (D - B) + 1;
	for (i = 2; i < N; i++) {
		long long s = max((long long)0, i - (D - B));
		long long g = min(i, C - A + 1);
		for (j = s; j < g; j++) {
			int x = A + j;
			int y = B + i - j;
			DP[x][y] = (DP[x - 1][y] * y + DP[x][y - 1] * x) % mod;
			DP[x][y] -= DP[x - 1][y - 1] * (x - 1) * (y - 1) % mod;
			while (DP[x][y] < 0) {
				DP[x][y] += mod;
			}
		}
	}
	cout << DP[C][D] << endl;
}


Measured memory_bytes: 73780
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int kisu = N/2;
		int gusu = N/2;
		if(N % 2 == 1) {
			kisu += 1;
		}
			
		System.out.println(kisu * gusu);
		sc.close();
	}

}


Measured memory_bytes: 21204