akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int max = 0;
		if(a >= b && a >= c){
			max = a;
			a = 0;
		}else if(b >= c){
			max = b;
			b = 0;
		}else{
			max = c;
			c = 0;
		}
		for(int i=0; i<k; i++){
			max *= 2;
		}
		System.out.println(a + b + c + max);
	}
}


Measured memory_bytes: 35604
#include<stdio.h>

main(){
	int W, H, x, y, r;
	
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	
	if(x+r<=W&&x-r>=0){
		if(y+r<=H&&y-r>=0){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
sum = 0
sum_of_num = 0
count = 0

while line = gets
  price, num = line.chomp.split(',').map(&:to_i)
  sum += price * num
  sum_of_num += num
  count += 1
end

puts sum
puts (sum_of_num.to_f / count.to_f).round

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

using namespace std;



int main(){

    string str;

    cin >> str;
    int zero = 0;
    int one = 0;

    for(int i = 0; i < str.size(); i++){
        if(str[i] == '0'){
            zero++;
        }else one++;
    }
    
    if(zero > one){
        cout << str.size() - (zero - one) << endl;
    }else cout << str.size() - (one - zero) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
 
int main(void){
 
int n, i, j;
 
while(1){
 
scanf("%d", &n);
 
if(n==0)
break;
 
 
 
int teamnum[n];
int timedata[n][8];
int time[n];
 
for(i=0; i<n; i++){
 scanf("%d", &teamnum[i]);
  
  for(j=0; j<8; j++)
  scanf("%d", &timedata[i][j]);
 
}
 
for(i=0; i<n; i++){
time[i]=(timedata[i][0]+timedata[i][2]+timedata[i][4]+timedata[i][6])*60+(timedata[i][1]+timedata[i][3]+timedata[i][5]+timedata[i][7]);
}
 
 
for(i=0; i<n-1; i++){
for(j=0; j<n-1; j++){
 
 if(time[j]>time[j+1]){
 
 int temp=time[j];
 time[j]=time[j+1];
 time[j+1]=temp;
 
 int temp2=teamnum[j];
 teamnum[j]=teamnum[j+1];
 teamnum[j+1]=temp2;
 
  }
 
 }
}
 
printf("%d\n", teamnum[0]);
printf("%d\n", teamnum[1]);
printf("%d\n", teamnum[n-2]);
 
}
 
return 0;
 
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main(){
  ll n,ii,mid,mid1,mid2,num;
  vector<ll> d;
  cin >> n;
  d.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> d[ii];
  }

  sort(d.begin(),d.end());

  mid = n/2;
  mid1 = d[mid-1];
  mid2 = d[mid];
  num = mid2 - mid1;
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
 
namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            long start = 100;
            long goal = long.Parse(Console.ReadLine());
            int ans = 0;
            while(start < goal) {
                start += start / 100;
                ans++;
            }
            Console.Write(ans);
        }
    }
}

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

int calc_gr(int a, int k) {
  while (a % k > 0) {
    int step = (a - a / k * k) / (a / k + 1);
    if ((a - a / k * k) % (a / k + 1) > 0) step++;
    a -= (a / k + 1) * step;
  }
  return a / k;
}

int main() {
  int n;
  cin >> n;
  int gr = 0;
  for (int ni = 0; ni < n; ni++) {
    int a, k;
    cin >> a >> k;
    gr ^= calc_gr(a, k);
  }
  if (gr == 0) {
    cout << "Aoki\n";
  } else {
    cout << "Takahashi\n";
  }
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

import fractions
CD = C * D // fractions.gcd(C, D)

# C, D, C*Dで割り切れるものの個数
div_C = B//C - (A//C + (-1 if A%C==0 else 0))  # 40//6 - 10//6 -> 6 - 1 = 5
div_D = B//D - (A//D + (-1 if A%D==0 else 0))  # 40//8 - 10//8 -> 5 - 1 = 4
div_CD = B//(CD) - max(0, (A//(CD) + (-1 if A%(CD)==0 else 0)))
print(B-A+1 - div_C - div_D + div_CD)

Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       ll n,c[4];
       rep(i,0,4) cin>>c[i];
       cin>>n;
       n*=4;
       rep(i,1,4) c[i]=min(c[i], 2*c[i-1]);
       ll cost = 0;
       for(ll i=3; i>=0; i--)
       {
              ll need = n/(1LL<<i);
              cost += need*c[i];
              n -= need*(1LL<<i);
       }
       cout<<cost;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define mod 1000000007
    #define maxn 200005
    #define vi vector<int>
    #define vl vector<ll>
    #define mii map<int,int>
    #define mli map<ll,int>
    #define forit(it,v) for(auto it=v.begin();it!=v.end();++it)
    #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    using namespace std;
    void solve()
    {
        ll n,k;
        cin>>n>>k;
        vl a(n);
        for (int i = 0; i < n; ++i)
        {
            cin>>a[i];
        }
        ll beg=1,end=(ll)1e9,ans=end;
        while(beg<=end)
        {
            ll mid=beg+(end-beg)/2;
            ll c=0,c1=0;
            for (int i = 0; i < n; ++i)
            {
                c1=a[i]/mid;
                if (a[i]%mid==0)
                {
                    c1--;
                }
                // if (round((a[i]) / (c1 + 1)) > mid)
                // {
                //     c1++;
                // }
                c+=c1;               
            }
            if (c<=k)
            {
                ans=mid;
                end=mid-1;
            }
            else
            {
                beg=mid+1;
            }
        }
        cout<<ans;
        // ll n,k;
        // cin>>n>>k;
        // priority_queue<float> q;
        // for (int i = 0; i < n; ++i)
        // {
        //     float x;
        //     cin>>x;
        //     q.push(x*1.0);
        // }
        // int i=0;
        // while(i<k)
        // {
        //     i++;
        //     float x=q.top();
        //     cout<<x<<" ";
        //     q.pop();
        //     q.push(x/2.0f);
        //     q.push(x-x/2.0f);
        // }
        // ll v=q.top();
        // cout<<v;
    }
    int main()
    {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        fastIO;
        // sieve();
        int t=1;
        // int t;
        // cin>>t;
        while(t--)
        {
            solve();
        }
        return 0;
    }

Measured memory_bytes: 4760
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;





int main(int argc, char *args[]) {
	int a[5];
	int r[5];
	vector <pair<int, int>> v(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		r[i] = (10 - a[i] % 10) % 10;
		v[i] = make_pair(r[i], a[i]);
	}
	
	sort(v.begin(), v.end());

	int time = 0;
	
	for (int i = 0; i < 5; i++) {
		//cout << v[i].first << " " << v[i].second << endl;
		time += v[i].first + v[i].second;
		//cout << time << endl;
	}
	cout << time - v[4].first << endl;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
                                          //By the name of ALLAH
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<iterator>
#include<numeric>
#define pi acos(-1.0)
using namespace std;
void solve()
{
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k<=n)
    cout<<(k*x)+((n-k)*y)<<endl;
    else
        cout<<n*x<<endl;

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



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,k;cin >> a >> b >> k;
    int cnt=0;
    vector<int> v;
    for(int i=1;i<=100;i++){
        if(a%i==0&&b%i==0){
            v.push_back(i);
        }
    }
    cout << v[v.size()-k] << endl;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    for(int i=0;i<5;i++) {
        ll a;
        cin >> a;
        if(a==0) ans = i+1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  (s == "AAA" || s == "BBB") ? cout << "No\n" : cout << "Yes\n";
return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int a[100100];

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

  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  ll ans1=0, ans2=0;
  ll sum = 0LL;
  //plus, minus
  REP(i, n){
    sum += a[i];
    if(i%2 == 0){
      if(sum >= 0){
	ans1 += sum+1;
	sum = -1;
      }
    }
    else{
      if(sum <= 0){
	ans1 += 1-sum;
	sum = 1;
      }
    }
  }
  sum = 0LL;
  //minus, plus
  REP(i, n){
    sum += a[i];
    if(i%2 == 1){
      if(sum >= 0){
	ans2 += sum+1;
	sum = -1;
      }
    }
    else{
      if(sum <= 0){
	ans2 += 1-sum;
	sum = 1;
      }
    }
  }  

  cout << min(ans1, ans2) << endl;
  
  return 0;
}


Measured memory_bytes: 768
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t a[100000];
static bool pushed[100000];

int main(void) {
    size_t H, W, N, a[10000];
    size_t c[100][100];

    scanf("%zu %zu\n%zu\n", &H, &W, &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(a[i]));
        if (i < N - 1) {
            scanf(" ");
        }
    }

    size_t row = 0;
    size_t col = 0;
    for (size_t aI = 0; aI < N; aI++) {
        for (size_t cC = 0; cC < a[aI]; cC++) {
            c[row][col] = aI + 1;

            if (row % 2 == 0) {
                if (col < W - 1) {
                    col++;
                }
                else {
                    row++;
                }
            }
            else {
                if (0 < col) {
                    col--;
                }
                else {
                    row++;
                }
            }
        }
    }

    for (size_t row = 0; row < H; row++) {
        for (size_t col = 0; col < W; col++) {
            printf("%zu", c[row][col]);

            if (col < W - 1) {
                putchar(' ');
            }
            else {
                if (row < H - 1) {
                    putchar('\n');
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 384
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_e
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  ll n;
  cin >> n;
  auto as = make_v<ll>(n+1);
  // auto diff = make_v<int>(n+1);
  map<ll, ll> diff2;
  for (ll i = 1; i <= n; ++i) {
    cin >> as[i];
    // if (i+1 - as[i] >= 0) {
      // diff[i+1 - as[i]]++;
      ll b = as[i] - (i);
      diff2[b]++;
      // diff2[i+1 - as[i]]++;
    // }
  }
  ll ans = 0;
  debug(diff);
  for (ll i = 1; i <= n; ++i) {
    // ans+=diff2[as[i]+i+1];
    ans+=diff2[-(as[i]+i)];
    // if (as[i] + i+1 <= n) ans += diff[as[i] + i+1];
    // if (as[i] + i+1 <= n) ans += diff[as[i] + i+1];
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

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

	cout << (a+b)*h/2 << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N,M=map(int,input().split())
G=[[] for i in range(N+1)]

for i in range(M):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)

flg=False

near=[False for i in range(N+1)]

for i in range(len(G[1])):
    near[G[1][i]]=True

for i in range(len(G[N])):
    if near[G[N][i]]:
        flg=True

if flg:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 40064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    bool ans=false;
    int four=0;
    int two=0;
    rep(i,n){
        if(a[i]%4==0){
            four++;
        }
        else if(a[i]%2==0){
            two++;
        }
    }
    if(four>=n/2){
        ans = true;
    }
    else if(four*2+two>=n){
        ans = true;
    }
    if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

#define ALL(a) (a).begin(), (a).end()

typedef long long ll;

using namespace std;

string str;

int getend(int idx){
	int depth = 1;idx++;
	while(depth > 0 && idx < str.size()){
		switch(str[idx]){
			case '[':
				depth++;
				break;
			case ']':
				depth--;
				break;
		}
		idx++;
	}
	return idx;
}

int toint(int idx){
	int size = 0;
	for(int i = idx;str[i] >= '0' && str[i] <= '9'; i++)size++;
	return (stoi(str.substr(idx, size))+1)/2;
}

int calc(int idx){
	int end = getend(idx);
	//cerr << str.substr(idx, end - idx) << endl;
	vector<int> arr;
	idx++;
	while(idx < end-1){
		//cerr << str[idx];
		switch(str[idx]){
			case '[':
				arr.push_back(calc(idx));
				idx = getend(idx);
				//cerr << "for:" << idx << " ";
				break;
			case ']':
				assert(false);
			default:
				return toint(idx);
		}
		//cerr << "e";
	}
	sort(ALL(arr));
	int ret = 0;
	for(int i = 0; i < (arr.size()+1)/2;i++){
		ret += arr[i];
	}
	return ret;
}

int main(){
	int nn; cin >> nn;
	for(int z = 0; z < nn; z++){
		cin >> str;
		cout << calc(0) << endl;
	}
	return 0;
}



Measured memory_bytes: 3220
n=int(input())
s=input()
left=[0]*(n+1)
right=[0]*(n+1)
for i in range(n):
    if s[i]=="W":
        left[i+1]=left[i]+1
    else:
        left[i+1]=left[i]

for i in range(n-1,0,-1):
    if s[i]=="E":
        right[i-1]=right[i]+1
    else:
        right[i-1]=right[i]
print(min([left[i]+right[i] for i in range(n)]))

Measured memory_bytes: 67804
n = int(input())
line = list(map(int, input().split()))

max = line[0]
min = line[0]
sum = line[0]

for i in range(1, n):
    if max < line[i]:
        max = line[i]
    elif min > line[i]:
        min = line[i]
    sum += line[i]

print(min, max, sum)


Measured memory_bytes: 6596
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<sstream>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
#include <cstdio>
using namespace std;

int main() {
	int i, j;
	int N;
	int W[200];
	int S1[101] = {};
	int S2[101] = {};
	int sum1 = 0;
	int sum2 = 0;
	int minSum = 9999999;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> W[i];
		sum1 += W[i];
	}

	for (i = 0; i < N-1; ++i) {
		sum2 += W[i];

		minSum = min(minSum, abs(sum2-(sum1-sum2)));
	}
	cout << minSum << endl;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(){
    int n,i;
    scanf("%d",&n);
    i=1;
    while(2*i<=n){
        i*=2;
    }
    printf("%d\n",i);
    return 0;
}


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

#define ll long long
#define MOD 1000000007


int main(){
    deque<string> s;
    string sv;
    cin>>sv;
    s.push_back(sv);

    int q;
    cin>>q;
    int t,f;
    string c;
    int j=0;
    int co=0;
    for(int i=0;i<q;i++){
        cin>>t;
        if(t==1){
            co++;
            if(j==1){
                j=0;
                continue;
            }
            j=1;
        }else{
            cin>>f>>c;
            if(f==1){
                if(j==1){
                    s.push_back(c);
                }else {
                    s.push_front(c);
                }

            }else{
                if(j==1){
                    s.push_front(c);
                }else{
                    s.push_back(c);
                }
            }
        }
    }

    string ans = "";
    int n=s.size();
    if(co%2==1)reverse(s.begin(),s.end());
    for(int i=0;i<n;i++){
        if(sv==s.front()&&co%2==1)reverse(s.front().begin(),s.front().end());
        ans += s.front();
        s.pop_front();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12132
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

A,B,C,D = Ints()
now = 0
while A>0 and C>0:
    if now%2==0:
        C-=B
    else:
        A -= D
    now += 1
if A<=0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61752
MOD = 10**9 + 7
n = int(input())
a = []
for _ in range(n):
	x = int(input())
	a.append([x, 1])
for _ in range(n):
	x = int(input())
	a.append([x, -1])
a.sort()
ans = 1
tmp = 0
for i in range(2*n):
	x = a[i][1]
	if x == 1 and tmp < 0:
		ans *= -tmp
	elif x == -1 and tmp > 0:
		ans *= tmp
	tmp += x
	ans %= MOD
print(ans)

Measured memory_bytes: 30740
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, a: [i64; n]
    }

    let c = a.iter().filter(|x| **x <= 0).count();
    let a = a.into_iter().map(|x| x.abs()).sorted().collect_vec();
    let ans = if c.is_even() {
        a.iter().sum::<i64>()
    } else {
        a.iter().skip(1).sum::<i64>() - a[0]
    };

    println!("{}", ans);
}



Measured memory_bytes: 4544
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

void Solution()
{
    int n, flag = 0;
    
    while(cin>>n, n)
    {
        if(flag)
        {
            cout<<endl;
        }
        
        int a, b, c, z[100], tmp;
        
        string s[100], tmp2;
        
        for(int i = 0; i < n; i++)
        {
            cin>>s[i]>>a>>b>>c;
            
            z[i] = a * 3 + c;
        }
        
        for(int i = 0; i < n - 1; i++)
        {
            for(int j = n - 1; j > i; j--)
            {
                if(z[j] > z[j - 1])
                {
                    tmp = z[j];
                    z[j] = z[j - 1];
                    z[j - 1] = tmp;
                    
                    /*swap the team name and score*/
 
                    tmp2 = s[j];
                    s[j] = s[j - 1];
                    s[j - 1] = tmp2;
                }
            }
        }
        
        for(int i = 0; i < n; i++)
        {
            cout<<s[i]<<","<<z[i]<<endl;
        }
        
        flag = 1;
    }
}

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

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

int n,sum,arr[101];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i = 1;i <= n;i++){
		cin>>arr[i];
	}
	for(int i = 0;i < n;i++){
		for(int j = 1;j < n;j++){
			if(arr[j] > arr[j + 1]){
				swap(arr[j],arr[j + 1]);
				sum++;
			}
		}
	}
	for(int i = 1;i <= n;i++){
		if(i != n)cout<<arr[i]<<" ";
		else cout<<arr[i];
	}
	cout<<endl;
	cout<<sum<<endl;
}



Measured memory_bytes: 3176
from collections import deque

h,w=map(int,input().split())
INF=float('inf')
G=[]
for _ in range(h):
  s=input()
  S=[]
  for i in range(w):
    S.append(s[i])
  G.append(S)
  
dist=[[INF for i in range(w)] for j in range(h)]
Q=deque()
for i in range(h):
  for j in range(w):
    if G[i][j]=='#':
      dist[i][j]=0
      Q.append((i,j))
while Q:
  pi,pj=Q.popleft()
  for di,dj in [[-1,0],[1,0],[0,-1],[0,1]]:
    ni,nj=pi+di,pj+dj
    if 0>ni or ni>h-1:
      continue
    if 0>nj or nj>w-1:
      continue
    if G[ni][nj]=='#':
      continue
    if dist[ni][nj]>dist[pi][pj]+1:
      dist[ni][nj]=dist[pi][pj]+1
      Q.append((ni,nj))
ans=-INF
for i in range(h):
  for j in range(w):
    ans=max(ans,dist[i][j])
print(ans)

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

const int MAX=100005;
int N;
vector<int> S[MAX];
vector<int> state(MAX),par(MAX),dis(MAX);
queue<int> Q;

void BFS1(){
    for(int i=0;i<N;i++){
        state[i]=0;
        par[i]=i;
        dis[i]=0;
    }
    Q.push(0);
    state[0]=1;
    while(Q.size()){
        int a=Q.front();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(state[b]==0){
                state[b]=1;
                par[b]=a;
                dis[b]=dis[a]+1;
                Q.push(b);
            }
        }
        Q.pop();
    }
    
}

int BFS2(int u){
    for(int i=0;i<N;i++){
        state[i]=0;
    }
    int cnt=1;
    Q.push(0);
    state[0]=1;
    state[u]=1;
    while(Q.size()){
        int a=Q.front();
        for(int i=0;i<S[a].size();i++){
            int b=S[a][i];
            if(state[b]==0){
                state[b]=1;
                cnt++;
                Q.push(b);
            }
        }
        Q.pop();
    }
    return cnt;
}

int main(){

  cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        S[b].push_back(a);
    }
    BFS1();
    int D=dis[N-1];
    int a=N-1,b=N-1;
    for(int i=1;i<=(D-1)/2;i++){
        b=par[a];
        a=b;
    }
    if(BFS2(b)>N/2) cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}



Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
int main() {
	int N, Q; cin >> N;
	vector<ll>S(N);
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
	}
	cin >> Q;
	vector<ll>T(Q);
	for (int i = 0; i < Q; i++) {
		cin >> T.at(i);
	}
	int ans = 0;
	for (int i = 0; i < Q; i++) {
		const int t = T.at(i);
		for (int j = 0; j < N; j++) {
			if (S.at(j) == t) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define test(t) ll t;cin>>t;while(t--)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Vi vector
#define pr pair
#define mpr make_pair
#define fi first
#define se second
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

set <ld> s[100005];
ld d[100005];

vector<char> prime (100000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
	{
		if (prime[i])
		{
			s[i].insert(i);			
			for (ld j=2*i; j<=n; j+=i)
			{
				prime[j] = false;
				s[j].insert(i);
			}
		}
	}
}
#define forn(i,e) for(int i = 0; i < e; i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)

#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
ld gcd(ld a, ld b) { if(b == 0) return a; return gcd(b, a % b); }
ld fastpowMOD(ld a, ld p,ld MOD){ if(p==0) return 1; ld z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
ld fastpow(ld a, ld p){ if(p==0) return 1; ld z = fastpow(a,p/2); z = (z*z); if(p%2) z = (z*a); return z; }
ld a,b;

ld search1(ld a[], ld f,ld n)
{
	ld left=1;
	ld right=n+1;
	while(right-left>1)
	{
		ld mid = left + (right-left)/2;
		if(a[mid]<f)
		{
			left=mid;
		}
		else right=mid;
	}
	return a[left];
}
ld MOD = 1e9+7;
int main(){
	string k;
	cin >> k;
	ld n = k.length();
	ld d,i,j,t;
	cin >> d;
	ld dp[n][d];
	ld dp2[n][d];
	memset(dp,0,sizeof(dp));
	memset(dp2,0,sizeof(dp2));
	ld num = k[n-1]-'0';
	for(i=0;i<10;i++)
	{
		dp2[n-1][i%d]+=1;
	}
	for(i=0;i<=num;i++)
	{
		dp[n-1][i%d]+=1;
	}
	for(i=n-2;i>=0;i--)
	{
		for(j=0;j<10;j++)
		{
			for(t=0;t<d;t++)
			{
				dp2[i][t]+=dp2[i+1][((t-j)%d+d)%d]%MOD;
			}
		}
		num = k[i]-'0';
		for(j=0;j<num;j++)
		{
			for(t=0;t<d;t++)
			{
				dp[i][t]+=dp2[i+1][((t-j)%d+d)%d]%MOD;
			}
		}
		for(t=0;t<d;t++)
		{
			dp[i][t]+=dp[i+1][((t-num)%d+d)%d]%MOD;
		}
	}
	cout << (dp[0][0]-1+MOD)%MOD << endl;
	return 0;
}

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


int main(){

    int N, D, X, A[100];
    cin >> N;
    cin >> D >> X;
    for( int i = 0; i < N; i++ ) cin >> A[i];

    
    int ans = X;

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j <= D; j++ ){
            if( j*A[i] + 1 <= D ) ans++;
        }
    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  
  ll a,b;
  cin >> a >> b;

  if(a<b) rep(i,0,b) cout << a;
  else rep(i,0,a) cout << b;
  
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

a=input()
b=input()
if len(a)>len(b):
    print("GREATER")
elif len(a)<len(b):
    print("LESS")
else:
    for i in range(len(a)):
        if a[i]>b[i]:
            print("GREATER")
            break
        elif a[i]<b[i]:
            print("LESS")
            break
    else:
        print("EQUAL")



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%2==1){
		a++;
	}
	if(a/2>=b){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int N, A, B, i, x = 0, y = 0;

    cin >> N >> A >> B;

    for(i = 0; ; ++i) {

        A++;
        x++;

        if(B - A == 1)
            break;

        else if(B - A == 0) {

            cout << "Borys" << endl;

            return 0;
        }

        B--;
        y++;

    }

    if(x > y)
        cout << "Alice" << endl;

    else
        cout << "Borys" << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
  int N,M;
  map <string, int> counter;
  cin >> N;
  for( int i=0;i<N;i++ )
    {
      string in;
      cin >> in;
      counter[in] = counter[in]+1;
    }
  cin >> M;
  for( int i=0;i<M;i++ )
    {
      string in;
      cin >> in;
      counter[in] = counter[in]-1;
    }

  int x = 0;
  for( auto &e:counter )
    {
      x = max(x, e.second);
    }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int h,w,d;
    cin >> h >> w >> d;
    VP p(h*w);
    int in;
    REP(i,0,h) REP(j,0,w) {
        cin >> in;
        p[in-1] = make_pair(i,j);
    }
    VI ru(h*w+1);
    REP(i,0,h*w-d) {
        ru[i+d] = abs(p[i].first - p[i+d].first) + abs(p[i].second - p[i+d].second);
    }
    REP(i,0,h*w-d+1) ru[i+d] += ru[i];
    //REP(i,0,h*w+1) dump(ru[i]);
    int q;
    cin >> q;
    int l,r;
    REP(i,0,q) {
        cin >> l >> r;
        cout << ru[r-1] - ru[l-1] << endl;
    }
}

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

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = in.nextInt();
		}
		int l = 0;
		long sum = 0;
		long xor = 0;
		for(int r=0;r<N;r++) {
			while((xor ^ A[r]) != (xor + A[r])) {
				xor ^= A[l];
				l++;
			}
			xor ^= A[r];
			sum += r - l + 1;
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];

    ll s = 0;
    rep(i, N) s += A[i];
    ll ans = 0;
    rep(i, N){
        s -= A[i];
        s = (s+1000000007) % 1000000007;
        ans = (ans + A[i]*s) % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4776
local n = io.read("n")
local c = io.read("n")
local b = io.read("n")
local a = io.read("n")
function pay(x,y,z)
    return math.abs(x-a)+math.abs(y-b)+math.abs(z-c)
end
local mem = {}
function dfs(arr)
    local arrstr = table.concat(arr,":")
    if mem[arrstr] then
        return mem[arrstr]
    end
    mem[arrstr] = math.huge
    for i=1,#arr do
        for j=i+1, #arr do
            for k=j+1, #arr do
                cnt = pay(arr[i],arr[j],arr[k])
                if cnt < mem[arrstr] then
                    mem[arrstr] = cnt
                end
            end
        end
    end

    if #arr > 3 then
        for i=1,#arr do
            for j=i+1,#arr do
                local newarr = {}
                for k=1,#arr do
                    if k ~= i and k ~= j then
                        newarr[#newarr+1] = arr[k]
                    end
                end
                newarr[#newarr+1] = arr[i]+arr[j]
                table.sort(newarr)
                local newv = 10 + dfs(newarr)
                if newv < mem[arrstr] then
                    mem[arrstr] = newv
                end
            end
        end
    end

    return mem[arrstr]
end

local bamboos = {}


for i=1,n do
    bamboos[i] = io.read("n")
end
table.sort(bamboos)
print(dfs(bamboos))

Measured memory_bytes: 1528
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);

  int prime[1000] = {};
  int not_prime_flag[1001] = {}; not_prime_flag[1] = 1;
  int j = 0;
  for(int i = 1; i <= n; i++){
    if(not_prime_flag[i] == 0){
      prime[j++] = i;
      int k = 2;
      while(i * k <= n){
	not_prime_flag[i * (k++)] = 1;
      }
    }
  }

  int k = 2; long long ans = 1; int cnt = 0; int temp;

  for(int i = 0; i < j; i++){
    cnt = 0; k = 2;
    while(k <= n){
      temp = k;
      while(temp % prime[i] == 0){
	cnt++;
	temp /= prime[i];
      }
      k++;
    }
    ans = ans * ((long long)cnt + 1) % 1000000007;
  }

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

  return 0;
  
    
}
    
    

  


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int a[20000], b[20000], count=0,number[20000],i;
  char op = 'c';
  for ( i=0; i<=20000; i++) {
    scanf("%d %c %d", &a[i+1] ,&op ,&b[i+1]);
    if (op == '?') {break;
    }
    count++;
    if ( op == '+' ){
      number[i+1]=a[i+1]+b[i+1];
    }
    else if ( op == '-' ){
      number[i+1]=a[i+1]-b[i+1];
    }
    else if ( op == '*' ){
      number[i+1]=a[i+1]*b[i+1];
    }
    else if ( op == '/' ){
      number[i+1]=a[i+1]/b[i+1];
    }
    else if ( op == '/' ){
      number[i+1]=a[i+1]/b[i+1];
    }
    else {

    }
  }

   for ( i=1; i<=count; i++) {
    printf("%d\n" ,number[i]);
   }
  return 0;
}

Measured memory_bytes: 616
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
    s: chars
    }
    let mut l = vec![0; 100];
    for i in s {
        let u = i as u8 - 97;
        l[u as usize] += 1;
    }
    for i in l {
        if i >= 2 {
            println!("No");
            return
        }
    }
    println!("Yes")
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        long N = sc.nextLong();

        System.out.println(solve(N));
    }

    private static int solve(long N) {
        int count = 0;

        List<Pair> list = primeFactorize(N);
        for (int i=0; i<list.size(); i++) {
            Pair p = list.get(i);

            for (int j=1; j<=p.second; j++) {
                count++;
                p.second -= j;
            }
        }

        return count;
    }

    /**
     * Nを素因数分解する
     * @param N
     * @return
     */
    private static List<Pair> primeFactorize(Long N) {
        List<Pair> list = new ArrayList();


        for (long p=2; p*p <= N; p++) {
            if (N%p != 0) continue;
            int num = 0;
            while (N%p == 0) {
                num++;
                N /= p;
            }

            list.add(new Pair(p, num));
        }
        if (N != 1) {
            list.add(new Pair(N, 1));
        }

        return list;
    }

    public static class Pair {
        long first;
        long second;

        public Pair(long a, long b) {
            this.first = a;
            this.second = b;
        }
    }
}

Measured memory_bytes: 35840
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  vi prime = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
  vi factor(prime.size());
  int n;
  cin >> n;
  FOR(i,1,n+1){
    int tmp = i;
    REP(j,prime.size()){
      while(tmp%prime[j]==0){
        tmp /= prime[j];
        factor[j]++;
      }
    }
  }
  ll ans = 0;
  ll sz = prime.size();
  REP(i,sz) FOR(j,i+1,sz) REP(k,sz){
    if(i==k||j==k) continue;
    if(factor[i]>=4&&factor[j]>=4&&factor[k]>=2) ans++;
  }
  REP(i,sz) REP(j,sz){
    if(i==j) continue;
    if(factor[i]>=14&&factor[j]>=4) ans++;
    if(factor[i]>=24&&factor[j]>=2) ans++;
  }
  REP(i,sz) if(factor[i]>=74) ans++;
  cout << ans << endl;
}




Measured memory_bytes: 256
// 解答不能.
// betrue12氏.
// https://atcoder.jp/contests/abc152/submissions/9635180
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL n[10][10];

int main(){
    int N;
    scanf("%d", &N);
    repx(i, 1, N + 1){
        string s = to_string(i);
        n[s[0] - '0'][s.back() - '0']++;
    }
    LL ans = 0;
    repx(a, 1, 10) repx(b, 1, 10) ans += n[a][b] * n[b][a];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
// AOJ GRL_6_A: Network Flow - Maximum Flow
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;
// Edmonds Karp algorithm: max flow
// TBE
struct edge
{
  int to, capacity, flow, rev;
  edge(){}
  edge(int to, int capacity, int flow, int rev):to(to), capacity(capacity), flow(flow), rev(rev){}
};

struct EdmondsKarp
{
  vector< vector<edge> > graph;
  vector<int> prevv, preve;
  EdmondsKarp(int sz):graph(sz), prevv(sz, -1), preve(sz, -1){}
  void add_edge(int from, int to, int capacity)
  {
    graph[from].push_back(edge(to, capacity, 0, (int)graph[to].size()));
    graph[to].push_back(edge(from, capacity, capacity, (int)graph[from].size()-1));
  }
  int max_flow(int source, int sink)
  {
    int flow = 0;
    while(1) {
      queue<int> que;
      que.push(source);
      fill(prevv.begin(), prevv.end(), -1);
      fill(preve.begin(), preve.end(), -1);      
      while(!que.empty()) {
	int u = que.front(); que.pop();
	for(int i = 0; i < (int)graph[u].size(); i++) {
	  edge& e = graph[u][i];
	  if(prevv[e.to] == -1 && e.to != source && e.capacity > e.flow) {
	    prevv[e.to] = u; preve[e.to] = i;
	    que.push(e.to);
	  }
	}
      }
      if(prevv[sink] == -1) break;

      int df = inf;
      for(int v = sink; v != source; v = prevv[v]) {
	edge e = graph[prevv[v]][preve[v]];
	df = min(df, e.capacity - e.flow);
      }
      for(int v = sink; v != source; v = prevv[v]) {
	edge& e = graph[prevv[v]][preve[v]];
	e.flow += df;
	graph[v][e.rev].flow -= df;
      }
      flow += df;
    }
    return flow;
  }
};



int main()
{
  int V, E; cin >> V >> E;
  EdmondsKarp mxf(V);
  while(E--) {
    int u, v, c;
    cin >> u >> v >> c;
    mxf.add_edge(u, v, c);
  }
  cout << mxf.max_flow(0, V-1) << endl;
  return 0;
}

Measured memory_bytes: 3116