akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
////////////////////////////////////////////////
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
const ll MOD = 1000000007;  // 1e9+7
////////////////////////////////////////////////
ll n;
ll k;
vecll v;
vecll bitk;
ll dfs(int i, bool stricted) {
  if (i < 0) return 0;
  ll n1 = v[i];
  ll n0 = (n - v[i]);
  if (!stricted) {
    return (1LL << (ll)i) * max(n1, n0) + dfs(i - 1, false);
  } else {
    if (bitk[i] == 1) {
      if (n1 >= n0) {
        return (1LL << (ll)i) * n1 + dfs(i - 1, false);
      }
      ll res1 = (1LL << (ll)i) * n0 + dfs(i - 1, true);
      ll res2 = (1LL << (ll)i) * n1 + dfs(i - 1, false);
      return max(res1, res2);
    } else {
      //////cannot choose 1
      return (1LL << (ll)i) * n1 + dfs(i - 1, true);
    }
  }
}
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  cin >> n >> k;
  vecll a(n);
  ll amax = 0;
  REPe(e, a) {
    cin >> e;
    amax = max(e, amax);
  }
  ll ans = 0;
  ////////////////////////////////////////////////
  if (k == 0) {
    REPe(e, a) ans += e;
    cout << ans << endl;
    return 0;
  }
  ////////////////////////////////////////////////
  int m = log2(max(amax, k));
  m++;
  // cout << m << endl;
  bitk = vecll(m, 0);
  REP(i, m) {
    if ((k >> i) & 1LL) {
      bitk[i] = 1;
    }
  }
  v = vecll(m, 0);
  REPe(e, a) {
    REP(i, m) {
      if ((e >> i) & 1LL) {
        v[i]++;
      }
    }
  }
//  cout << "check" << endl;
  // REPe(e, bitk) { cout << e << " "; }
  // cout << endl;
  // REPe(e, v) { cout << e << " "; }
  // cout << endl;
  cout << dfs(m - 1, true) << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

std::vector<int> sorter(std::vector<int> list);

int main(){
	int N;
	int Alice=0,Bob=0;
	std::vector<int> cards;
	
	std::cin>>N;
	for(int i=0;i<N;i++){
		int num;
		std::cin>>num;
		cards.push_back(num);
	}
	cards = sorter(cards);

	bool turn = true;
	for(auto itr = cards.begin();itr != cards.end();++itr){
		if(turn){
			Alice += *itr;
		}else{
			Bob += *itr;
		}
		turn = !turn;
//		std::cout<<*itr<<" ";
	}
	std::cout<<int(Alice - Bob);
	return 0;
}

std::vector<int> sorter(std::vector<int> list){
	bool sorted = false;
	while(!sorted){	
		sorted = true;
		for(int i=0;i<list.size()-1;i++){
			if(list.at(i)<list.at(i+1)){
				int temp = list.at(i);
				list.at(i) = list.at(i+1);
				list.at(i+1) = temp; 
				sorted = false;
			}
		}
	}
	return list;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count =0;
  for (int i=0;i<=a;i++){
    for (int j=0;j<=b;j++){
      for (int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

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

int main() {
    double N, K;
    cin >> N >> K;

    double ans = 0;
    for (double i = 1; i <= N; ++i) {
        if (i >= K) {
            ans += 1.0;
        } else {
            ans += pow(0.5, ceil(log2(K / i)));
        }
    }
    ans = ans / N;
    cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 4184
n,m = map(int,input().split())
ab= [[0 for i in range(n)] for j in range(n)]
eda = []
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1][b-1] = 1
    ab[b-1][a-1] = 1
    eda.append([a-1,b-1])

def dfs(x):
    global v
    v.append(x)
    for k in range(n):
        global i
        if ab[x][k] == 1 and not k in v:
            dfs(k)
count = 0
for i in range(m):
    ab[eda[i][0]][eda[i][1]] = 0
    ab[eda[i][1]][eda[i][0]] = 0
    v = []
    dfs(0)
    if len(v) != n:
        count += 1
    ab[eda[i][0]][eda[i][1]] = 1
    ab[eda[i][1]][eda[i][0]] = 1
print(count)    

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

vector<pair<vector<int>,int>>point;
vector<int> pp;
int count = 0;

int main() {
    int n,z;
    int x =0;
    cin >> n >> z;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < z; ++j) {
            int bb = 0;
            cin >> bb;
            pp.push_back(bb);
            x++;
        }
        pair<vector<int>,int> b = make_pair(pp,x);
        point.push_back(b);
        pp.clear();
    }

    for (int k = 0; k < n; ++k) {
        int distance = 0;
        for (int j = k+1; j < n; ++j) {
            for (int i = 0; i < z; ++i) {
                int a = point[k].first[i];
                int b = point[j].first[i];
                distance += abs(a-b)*abs(a-b);
            }
            double tt = sqrt(double(distance));
            int t = int(tt);
            if(tt - t == 0){
                count++;
            }
            distance = 0;
        }

    }


    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

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

int k,x;
signed main(){
cin>>k>>x;
if(500*k >= x)cout << "Yes" << endl;
else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ok = 1e9 + 5, ng = 0;

    auto check = [&](int x) {
        ll cnt = 0;
        rep(i, n) {
            int now = a[i] / x;
            if (a[i] % x == 0) now--;
            cnt += now;
        }
        return cnt <= k;
    };
    
    while (ok - ng > 1) {
        int mid = (ok + ng) >> 1;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    
    cout << ok << endl;
}


Measured memory_bytes: 3988
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
int a[105];
int ans;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 1; i < n; i++){
		if(a[i] == a[i-1]){
			if(i < n-1 && a[i] + 1 == a[i+1]){
				a[i] += 2;
			}else{
				a[i]++;
			}
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
// made by egor <https://pypi.org/project/egor/>
// @author MaxHeap

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;
const int N = 10010;

int A[N], B[N];
int n;
int dp[1010][N];

int go(int index, int health) {
  if(index >= n) {
    return health <= 0 ? 0: 2e9;
  }
  if(health <= 0) return 0;
  if(dp[index][health] != -1) return dp[index][health];
  int ans = 2e9;
  ans = min(ans, go(index + 1, health));
  ans = min(ans, go(index, health - A[index]) + B[index]);
  ans = min(ans, go(index + 1, health - A[index]) + B[index]);
  return dp[index][health] = ans;
}

int main(){
  for(int i = 0; i < 1010; ++i) {
    for(int j = 0; j < N; ++j) dp[i][j] = -1;
  }

  int h; cin >> h >> n;
  for(int i = 0; i < n; ++i) cin >> A[i] >> B[i];
  cout << go(0, h) << endl;
}


Measured memory_bytes: 40448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if(n%10==9){
        cout<<"Yes"<<endl;
        return 0;
    }
    n/=10;
    if(n==9){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int a[10000];
	long long int sum = 0;
	
	scanf("%d",&n);
	
	int i;
	int max = -1000000;
	int min = 1000000;
	for(i = 0; i < n; i++){
		int b;
		scanf("%d",&b);
	
		sum += b;
		
		if(min >= b){
		min = b;
		}
	
		if(max <= b){
		max = b;
		}
	}
	printf("%d %d %lld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 2672
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
 
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("./input.txt","r",stdin);
  //  freopen("./output.txt","w",stdout);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<(a[n/2]-a[n/2 - 1]);
}

Measured memory_bytes: 640
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 100 + 10 , maxA = 1000 + 10 ;

int n , a [ N ] ;

int chk ( int x ) {
	int ret = 0 ;
	for ( int i = 1 ; i <= n ; i++ )
		ret += ( a [ i ] - x ) * ( a [ i ] - x ) ;
	return ret ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	for ( int i = 1 ; i <= n ; i++ )
		cin >> a [ i ] ;
	int ans = 1e18 ; 
	for ( int i = -maxA ; i <= maxA ; i++ )
		smin ( ans , chk ( i ) ) ;
	cout << ans << '\n' ; 
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int i;
    int a = 100000;

    n = sc.nextInt();

    for(i = 0;i < n;i++){
      a *= 1.05;
      if(a % 1000 != 0){
        a /= 1000;
        a *= 1000;
        a += 1000;
      }
    }

    System.out.println(a);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17164
n,m = map(int,input().split())
prb = [[0] for _ in range(n+1)]

for _ in range(m):
    sub = input().split()
    p, s = int(sub[0]), sub[1]
    lst = prb[p]
    if lst[-1] == 1:
        pass
    elif s == "WA":
        lst.append(0)
    elif s == "AC":
        lst.append(1)
    prb[p] = lst

ac_prb = [lst for lst in prb if lst[-1] == 1]
ac_num = len(ac_prb)
pe_num = -2*ac_num

for prb in ac_prb:
    pe_num += len(prb)

print(ac_num, pe_num)

Measured memory_bytes: 22904
#include <iostream>

using namespace std;

int main(void){
    
    int a, b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if (op == '+') cout << a+b << endl;
        else if (op == '-') cout << a-b << endl;
        else if (op == '*') cout << a*b << endl;
        else if (op == '/') cout << a/b << endl;
        else if (op == '?') break;
    }
    return 0;
}



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

int main() {
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i = 0; i<n; i++){
	    cin>>arr[i];
	}
	
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(arr[1]-arr[0]);
	for(int i = 2; i < n; i++){
	    dp[i] = min(abs(arr[i]-arr[i-1]) + dp[i-1], abs(arr[i] - arr[i-2]) + dp[i-2]);
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long R, long long G, long long B, long long N){
    lli cnt=0;
    for(lli r=0;r*R<=N ;r++){
    for(lli g=0;r*R + g*G <= N;g++){
        lli bB = (N-(r*R+g*G));
        if(bB<0)continue;
        if(bB%B!=0)continue;
        cnt++;
        
    }
    }
    cout<<cnt<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long R;
    scanf("%lld",&R);
    long long G;
    scanf("%lld",&G);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    func(R, G, B, N);
    return 0;
}


Measured memory_bytes: 256
K=int(input())
S=input()
N=len(S)
mod=10**9+7

fact=[0]*(K+N)
fact[0]=fact[1]=1
for i in range(2,K+N):
    fact[i]=fact[i-1]*i%mod

def comb(n,r):
    ret=fact[n]*pow(fact[r],mod-2,mod)*pow(fact[n-r],mod-2,mod)%mod
    return ret

ans=0
for i in range(K+1):
    ans+=pow(26,i,mod)*pow(25,K-i,mod)*comb(K+N-1-i,N-1)
    ans%=mod

print(ans)

Measured memory_bytes: 107572
#include <stdio.h>
int main() {
	int n, a[100], same, min, sum = 0, cost = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	same = sum / n;
	for (int i = 0; i < n; i++) {
		cost += (a[i] - same) * (a[i] - same);
	}
	min = cost;
	same = (sum + n - 1) / n;
	cost = 0;
	for (int i = 0; i < n; i++) {
		cost += (a[i] - same) * (a[i] - same);
	}
	if (min > cost) {
		min = cost;
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	long long s=a*b;
	if(a==1 || b==1){
		cout<<1;
		return 0;
	}
	if(s%2==0)cout<<s/2;
	if(s%2 !=0)cout<<(s+1)/2;
	return 0;
} 

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	deque<int>dq;
	int n,cnt=1,b=0;
	cin >> n;
	vector<int>arr(n);
	rep(i, n)cin >> arr[i];
	if (n % 2 == 0)b = 1;
	rep(i, n) {
		if (i % 2 == b)dq.push_front(arr[i]);
		else dq.push_back(arr[i]);
	}
	for (auto d : dq) {
		if (cnt == n)cout << d << endl;
		else cout << d << " ";
		cnt++;
	}

	return 0;
}



Measured memory_bytes: 4820
N, T = map(int, input().split())
c = [0]*N
t = [0]*N
for i in range(N):
    c[i], t[i] = map(int, input().split())
min_cost = 1001
for i in range(N):
    if t[i]<=T:
        min_cost = min(c[i],min_cost)
if min_cost == 1001:
    print("TLE")
else:
    print(min_cost)

Measured memory_bytes: 3060
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
ld h, m,n, sum,d; string s, t;
const ll MOD= 1000000007;
const ld PI = acos(-1);
int main() {
    cin >> n >> m >> d;
    if (d == 0) cout << fixed << setprecision(10) << (n-d) * (m-1) / (n*n) << endl;
    else cout << fixed << setprecision(10) << 2 * (n - d) *(m - 1)/ (n * n) << endl;
    
}

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

int main(){
  vector<int> times(5);
  for(int i = 0;i < 5;i++) cin >> times.at(i);
  
  vector<int> p = {0, 1, 2, 3, 4};
  int ans = 1000;
  do{
    int sum = 0;
    for(int i = 0;i < 5;i++){
      while(sum % 10 != 0) sum++;
      sum += times.at(p.at(i));
    }
    
    ans = min(ans, sum);
  }while(next_permutation(p.begin(), p.end()));
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
/*author : Yashvardhan
Thursday, April 30, 2020
10:15 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

map<int,int> mapi;
void getpf(int n){
	vi pf;
	for(int i = 2; i * i <= n; i++){
		int cnt = 0;
		if(n % i == 0){
			pf.pb(i);
			while(n % i == 0){
				cnt++;
				n /= i;
			}
			mapi[i] = max(mapi[i], cnt); 
		}
	}
	if(n > 1) mapi[n] = max(mapi[n], 1ll);
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	vi arr(n);
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}

	vi pf[n];
	for(int i = 0; i < n; i++){
		getpf(arr[i]);
	}

	int l = 1;
	for(auto i : mapi){
		for(int j = 0;  j < i.ss; j++){
			l = (l * i.ff) % mod;
		}
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		int toadd = (l * modinv(arr[i])) % mod;
		ans = (ans + toadd) % mod;
	}

	cout << ans << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n;
	cin>>n;
	lli a[n],i;
	fr(i,n)
	{
		cin>>a[i];
	}
	lli money=1000,stocks=0,flag=0;
	fr(i,n)
	{
		if(a[i]<a[i+1]&&flag==0)
		{
			stocks=money/a[i];
			money-=(stocks*a[i]);
			flag=1;
		}
		if(a[i]>a[i+1]&&flag==1)
		{
			money+=stocks*a[i];
			stocks=0;
			flag=0;
		}
	}
	money+=stocks*a[n-1];
	cout<<money;
	
	return 0;
}

Measured memory_bytes: 3612
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())
ss = collections.Counter(s)
s_most = ss.most_common()

ans = []
#
for i in range(len(s_most)):
    if s_most[i][1] == s_most[0][1]:
        ans.append(s_most[i][0])
    else:
        break
for i in sorted(ans):
    print(i)


Measured memory_bytes: 49280
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
    print("Yes")
elif sum(a) >= sum(b):
    print("No")
else:
    aa = 0
    bb = 0
    for i in range(N):
        if a[i]-b[i] > 0:
            bb += a[i]-b[i]
        elif b[i]-a[i] > 0:
            aa += (b[i]-a[i])//2
    if aa >= bb:
        print("Yes")
    else: 
        print("No")

Measured memory_bytes: 4596
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

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

  int n3 = 0, n2 = 0, n1 = 0;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (num == 3)
      n3++;
    else if (num == 2)
      n2++;
    else if (num == 1)
      n1++;
  }

  double dp[n + 1][n + 1][n + 1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) { dp[i][j][k] = -1; }
    }
  }

  std::function<double(int, int, int)> func = [&dp, &n, &func](const int n3, const int n2,
                                                               const int n1) -> double {
    if (dp[n3][n2][n1] >= 0) return dp[n3][n2][n1];
    if (n3 + n2 + n1 == 0) return 0;

    double res = 0;
    if (n3 > 0) res += func(n3 - 1, n2 + 1, n1) * n3;
    if (n2 > 0) res += func(n3, n2 - 1, n1 + 1) * n2;
    if (n1 > 0) res += func(n3, n2, n1 - 1) * n1;
    res += n;
    res /= n1 + n2 + n3;

    dp[n3][n2][n1] = res;
    return res;
  };

  printf("%.10f\n", func(n3, n2, n1));
}



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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  string s;
  string t;
  cin >> s >> t;
  if (s == t.substr(0, t.size() - 1)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,k;
int main(){
	cin>>n>>k;
	if(k==1){
		cout<<0<<endl;
	}else{
		int p=n-k;
		cout<<p<<endl;
	}
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> q(N);
    vector<int> p(N);
    rep(i, N){
        cin >> p[i];
    }
    rep(i, N){
        cin >> q[i];
    }

    map<vector<int>, int> mp;
    vector<int> a(N);
    rep(i, N){
        a[i] = i+1;
    }

    do{
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 5248
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;


int main(){

  int n;
  int G[105][105];

  cin >> n;

  for( int i = 0; i < n; ++i){
    for( int j = 0; j < n; ++j){
      G[i][j] = 0;
    }
  }

  for( int i = 0; i < n; ++i){
    int u,k,v;
    cin >> u >> k;
    for( int j = 0; j < k; ++j){
      cin >> v;
      G[u-1][v-1] = 1;
    }
  }

  for( int i = 0; i < n; ++i){
    for( int j = 0; j < n; ++j){
      if(j) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }

}

Measured memory_bytes: 3068
#include<stdio.h>
#include<stdlib.h>


int main(void){

	int n;
	int data;
	int sum;
	int *sum_last;
	int i,j;

	while(1){

		scanf("%d",&n);
		if(n == 0)
			break;

		sum_last = (int*)malloc(sizeof(int)*n);
		for(i=0;i<n;i++)
			sum_last[i] = 0;


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

			sum = 0;

			for(j=0;j<n;j++){
				scanf("%d",&data);
				printf("%5d",data);
				sum += data;
				sum_last[j] += data;
			}
			printf("%5d\n",sum);
		}

		sum = 0;
		
		for(i=0;i<n;i++){
			printf("%5d",sum_last[i]);
			sum+=sum_last[i];
		}

		printf("%5d\n",sum);


	}

	return 0;
}

Measured memory_bytes: 612
/* You can't hack me! */
#pragma warning(disable : 4996)
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vch;
typedef set<ll> sll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define sc scanf
#define pr printf
#define in(x) sc("%lld", &(x))
#define id(x) sc("%Lf", &(x))
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=998244353;
const ll MaxN=2000010;
const long double pi=3.14159265358979323846264338327950288419716939937510;

ll gcd(ll a, ll b)
{
    ll m=min(a, b), M=max(a, b);
    if(m==0) return M;
    return gcd(m, M%m);
}

ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t=1;
    //cin>>(t);
    //in(t);
    fo(q, t)
    {
        ll a, b, h, m;
        cin>>a>>b>>h>>m;
        long double c=0, o;
        o=abs(pi*(h+m/60.0)/6.0-pi*m/30.0);
        c=sqrt(a*a+b*b-2*a*b*cos(o));
        on(fixed << setprecision(25) << c);
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 4184
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int a = getInt(sc);
		int b = getInt(sc);
		int c = getInt(sc);
		int d = getInt(sc);

		System.out.println(Math.max(a * b, c * d));
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	long x;
	long tmpCoins;

	public Status(long x, long tmpCoins) {
		this.x = x;
		this.tmpCoins = tmpCoins;
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
static const int INF = 1000000000;

vector<int> bfs(int root, const vector<vector<int>>& conn){
	const int n = conn.size();
	vector<int> d(n, INF);
	queue<int> q;
	d[root] = 0;
	q.push(root);
	while(!q.empty()){
		const int u = q.front();
		q.pop();
		for(const int v : conn[u]){
			if(d[v] < INF){ continue; }
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	return d;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> conn(n);
	for(int i = 1; i < n; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		conn[a].push_back(b);
		conn[b].push_back(a);
	}
	const auto a = bfs(0, conn);
	const auto b = bfs(n - 1, conn);
	int x = 0, y = 0;
	for(int i = 0; i < n; ++i){
		if(a[i] <= b[i]){
			++x;
		}else{
			++y;
		}
	}
	cout << (x > y ? "Fennec" : "Snuke") << endl;
	return 0;
}



Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 200000
char s[MAXN+5],t[MAXN+5];
int n;
int Ts[27],Ts2[27];
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
    {
        int A=s[i]-'a'+1,B=t[i]-'a'+1;
        if(Ts[B]==0)Ts[B]=A;
        else if(Ts[B]!=A){printf("No\n");return 0;}
        if(Ts2[A]==0)Ts2[A]=B;
        else if(Ts2[A]!=B){printf("No\n");return 0;}
    }
    printf("Yes");
}


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

int main(){

    int n;
    cin>>n;
    int a;
    bool flag=false;
    while(n){
        a=n%10;
        if(a==7){
            flag=true;
            break;
        }
        n=n/10;
    }
    if(flag){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
	return 0;
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
      cin >> a.at(i);
  }
  int count = 0;
  while(true){
      bool flag = true;
    // 配列の中身を2で割る
    for(int i=0;i<n;i++){
      	if(a[i] % 2 != 0) {
          flag = false;
          break;
        }
    }
    if(flag==false) break;
    for(int i=0;i<n;i++){
    	int tmp;
      	tmp = a[i]/2;
      	a[i] = tmp;
    }
    count+=1;
  }
  cout << count ;
}

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

S = ''.join(list(reversed(input())))

candidate = ["remaerd", "resare", "esare", "maerd"]

while True:
    flag = 0
    if S[:7] == "remaerd":
        S = S[7:]
        flag = 1
        #print(S)
    if S[:6] == "resare":
        S = S[6:]
        flag = 1
        #print(S)
    if S[:5] == "esare" or S[:5] ==  "maerd":
        S = S[5:]
        flag = 1
        #print(S)
    if flag == 0:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")


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

int main( void ) {
    
    string a, b, c;
    cin >> a >> b >> c;
    
    if( a.back() == b.front() && b.back() == c.front() )
        cout << "YES\n";
    else
        cout << "NO\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio   ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll        long long
#define yes       printf("YES\n")
#define no        printf("NO\n")
#define pb        push_back
#define srtd(x)   sort(x.begin(),x.end())
#define rvsd(x)   reverse(x.begin(),x.end())
#define scn(n)    scanf("%lld",&n)
#define scab(a,b) scanf("%lld %lld",&a,&b)
#define pn(n)     printf("%lld\n",n)
#define pab(a,b)  printf("%lld %lld",a,b)
#define nl        cout<<endl
#define MAX       1000011
#define PI        acos(-1.0)
#define mmst(a,b) memset(a,b,sizeof(a));
#define FOR(i,n)  for(ll i=1;i<=n;i++)
#define LOP(i,n)  for(ll i=0;i<n;i++)
//Emama_ Nahid//
using namespace std;
int main()
{
    fastio;
    string s,t,a;
    cin>>s>>t;
    a=t+s;
    cout<<a<<endl;

    return 0;

}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
cin >> a >> b;
  int x = 0;
  for(int i = 0;i < a + 1;i++){
    for(int j = 0;j < a + 1;j++){
      if(b - i - j >= 0 && b - i - j < a + 1){
        x++;}
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main() {
  ll x;
  cin >> x;
  ll y = x / 11;
  x -= y*11;
  if(x == 0) cout << 2*y << endl;
  else if(x < 7) cout << 2*y+1 << endl;
  else cout << 2*y+2 << endl;
}

  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100009
using namespace std;
long long L[maxn],R[maxn],sum[maxn];
long long a[maxn];
int n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>=0)
			L[i]=L[i-1]+a[i];
		else
			L[i]=L[i-1];
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=n;i>=1;i--){
		R[i]=R[i+1]+max(a[i],0LL);
	}
	long long ans=0;
	for(int i=1;i+k-1<=n;i++){
		ans = max(ans,L[i-1]+R[i+k]);
		ans = max(ans,L[i-1]+R[i+k]+sum[i+k-1]-sum[i-1]);
	}
	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3456
let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

(* ストリームの先頭n要素をマージソートし，ソート前の転倒数を計算する
   ストリームの要素数がnに満たない場合は適当な例外を投げる *)
let sort_count :
  (* 要素の比較関数（compareみたいなの） *)
  ('a -> 'a -> int) ->
  (* 先頭から何個までの要素をソートするか *)
  int ->
  (* ソートする要素の入ったストリーム *)
  'a Seq.t ->
  (* 継続渡しスタイル *)
  ('a Seq.t -> (* 先頭からn要素を取り除いたストリーム *)
   int -> (* 転倒数 *)
   'a list -> (* ソート結果 *)
   'b) -> 'b
= fun cmp ->
  (* 標準ライブラリのList.sortをCPS変換して，転倒数を計算する処理を追加したような実装 *)
  let rec rev_merge_count xs lxs ys invs acc k =
    match xs, ys with
    | _, [] -> k invs (List.rev_append xs acc)
    | [], _ -> k invs (List.rev_append ys acc)
    | x :: xs', y :: ys' ->
        if cmp x y <= 0
        then rev_merge_count xs' (lxs - 1) ys invs (x :: acc) k
        else rev_merge_count xs lxs ys' (lxs + invs) (y :: acc) k in
  let rec rev_merge_count_rev xs ys lys invs acc k =
    match xs, ys with
    | _, [] -> k invs (List.rev_append xs acc)
    | [], _ -> k invs (List.rev_append ys acc)
    | x :: xs', y :: ys' ->
        if cmp x y > 0
        then rev_merge_count_rev xs' ys lys (lys + invs) (x :: acc) k
        else rev_merge_count_rev xs ys' (lys - 1) invs (y :: acc) k in
  let rec sort_count invs n xs k =
    match n with
    | 0 -> k xs invs []
    | 1 ->
        let Seq.Cons (x, xs) = xs () in
        k xs invs [x]
    | _ ->
        sort_count_rev invs ((n + 1) lsr 1) xs @@ fun xs invs ys ->
          sort_count_rev invs (n lsr 1) xs @@ fun xs invs zs ->
            rev_merge_count_rev ys zs (n lsr 1) invs [] @@ k xs
  and sort_count_rev invs n xs k =
    match n with
    | 0 -> k xs invs []
    | 1 ->
        let Seq.Cons (x, xs) = xs () in
        k xs invs [x]
    | _ ->
        sort_count invs (n lsr 1) xs @@ fun xs invs ys ->
          sort_count invs ((n + 1) lsr 1) xs @@ fun xs invs zs ->
            rev_merge_count ys (n lsr 1) zs invs [] @@ k xs in
  sort_count 0;;

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " Fun.id in
  sort_count compare n (Array.to_seq as_) @@ fun _ invs _ ->
  Printf.printf "%d\n" @@
  ( +^ ) (k *^ invs) @@
  ( *^ ) (k * (k - 1) / 2 mod m) @@
  fst @@
  IntMap.fold (fun _ n (acc, sum) -> (acc + n * sum, sum + n))
    (Array.fold_left (fun m a ->
      IntMap.add a (1 +
        try IntMap.find a m
        with Not_found -> 0) m) IntMap.empty as_) (0, 0)


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t="No";
  cin >>s;
  rep(i,s.size()){
    if(s[i]=='7')t="Yes";
  }
  cout <<t;
}

Measured memory_bytes: 3652
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(str(type(var)) + name +":" + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    W = list(map(int,input().split()))
    ress = []
    for i in range(N):
        ress.append(abs(sum(W[:i+1]) - sum(W[i+1:])))
    print(min(ress))



if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int l;
  cin >> l;
  long double ans;
  l=l*l*l;
  ans=l/27.0;
  printf("%.20Lf",ans);
}

Measured memory_bytes: 256
N, D = map(int, input().split())
x = [list(map(int, input().split())) for i in range(N)]
y = []
for i in range(N):
    for j in range(i + 1, N):
        calc_x = 0
        for k in range(D):
            calc_x += pow(x[i][k] - x[j][k], 2)
        y.append(pow(calc_x, 1/2))

print(sum([1 if y[i] % 1 == 0 else 0 for i in range(len(y))]))


Measured memory_bytes: 3064
import bisect
N = int(input())
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
check = [0] * N
ans = 0
for i in range(N):
    check[i] = N - bisect.bisect_right(C,B[i])
for i in range(1,N):
    check[N-1-i] += check[N-i]
for i in range(N):
    b = bisect.bisect_right(B,A[i])
    if b == N:
        continue
    ans += check[b]
print(ans)

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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (u == s) {
    a--;
  }
  else {
    b--;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	bool val = s[0] == 'A';
	int upper = 0;
	rep(i,0,s.length())if(s[i] <= 'Z' && s[i] >= 'A')upper++;
	val &= upper == 2;
	int cnt = 0;
	rep(i,2,(int)s.length() - 1)cnt += s[i] == 'C';
	val &= cnt == 1;
	cout << (val?"AC":"WA") << '\n';
}


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


int main() {
  string s, t;
  cin >> s >> t;
  int S, T;
  S = s.size();
  T = t.size();
  bool ans = true;
  
  string u;
  u = t.substr(0,S);
  
  
  
  if(u != s){
    ans = false;
  }
  
 if(ans){
   cout << "Yes";
 }
  else{
    cout << "No";
  }
   
  
  
  return 0;
}

Measured memory_bytes: 3632
day = input()
if day == "SUN":
  print(7)
elif day == "MON":
  print(6)
elif day == "TUE":
  print(5)
elif day == "WED":
  print(4)
elif day == "THU":
  print(3)
elif day == "FRI":
  print(2)
elif day == "SAT":
  print(1)
else:
  print(-1)

Measured memory_bytes: 3060
N, M = gets.split.map(&:to_i)
lmax, rmin = 1, N
M.times do
  l, r = gets.split.map(&:to_i)
  lmax = [l, lmax].max
  rmin = [r, rmin].min
end
puts [0, rmin - (lmax - 1)].max


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

using namespace std;
int n,k,a,sn,arr[1000],ans=0;
int main(){
 
  cin>>n>>k;
  
  for(int i=0;i<k;i++)
  {
    cin>>sn;
    for(int j=0;j<sn;j++)
    {
      cin>>a;
      arr[a]++;
    }
  }
  for(int i=1;i<=n;i++)
  {
    if(arr[i]==0)
      ans++;
  }
  cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3604
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n;
     map<ll,ll> mp;
     vector<ll> v(n);
     for(i=0;i<n;i++) {cin>>v[i];mp[v[i]]++;}
      ll sum=0;
     for(auto it=mp.begin();it!=mp.end();++it)
     {
      sum+=(it->S)*(it->S-1)/2;
     }
     for(i=0;i<n;i++)
     {
       ll rem=(mp[v[i]])*(mp[v[i]]-1)/2;
       ll f=mp[v[i]];
       f--;
       ll add=(f*(f-1))/2;
       ll ans=sum-rem+add;
       cout<<ans<<endl;
     }
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 11136
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

fn main() {
    let a: i32 = read();
    let b: i32 = read();

    println!("{}", max(max(a+b, a-b), a*b));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

typedef long long LL;

int main(void){
    int x, y, a, b, c;
    int p[100000], q[100000], r[100000];
    cin >> x >> y >> a >> b >> c;
    rep(i, a)cin >> p[i];
    rep(i, b)cin >> q[i];
    rep(i, c)cin >> r[i];
    sort(p, p+a, greater< int >());
    sort(q, q+b, greater< int >());
    sort(r, r+c, greater< int >());
    vector<int> tot;
    rep(i, x){
        tot.push_back(p[i]);
    }
    rep(i, y){
        tot.push_back(q[i]);
    }
    rep(i, c){
        tot.push_back(r[i]);
    }
    sort(tot.begin(), tot.end(), greater<int>());
    LL ans = 0;
    rep(i, x+y)ans += tot[i];
    cout << ans << endl;

}

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

struct Card{char suit, value;};

bool isStable(struct Card in[], struct Card out[], int n){
    for(int i = 0; i < n; i++)
        for(int j = i + 1; j < n; j++)
            for(int k = 0; k < n; k++)
                for(int h = k + 1; h < n; h++)
                    if(in[i].value == in[j].value && in[i].value == out[h].value && in[i].suit == out[h].suit && in[j].value == out[k].value && in[j].suit == out[k].suit)
                        return false;
    return true;
}

void bubblesort(struct Card in[], int n){
    for(int i = 0; i < n; i++)
        for(int j = n - 1; j > i; j--)
            if(in[j].value < in[j - 1].value)
                swap(in[j], in[j - 1]);
}

void selectionsort(struct Card in[], int n){
    int min;
    for(int i = 0; i < n; i++){
        min = i;
        for(int j = i; j < n; j++)
            if(in[min].value > in[j].value)
                min = j;
        swap(in[i], in[min]);
    }
}

int main(){
    int n; cin >> n;
    Card in[n], out[n];
    
    for(int i = 0; i < n; i++)
        cin >> in[i].suit >> in[i].value;
    for(int i = 0; i < n; i++)
        out[i] = in[i];
    
    bubblesort(out, n);
    for(int i = 0; i < n - 1; i++)
        cout << out[i].suit << out[i].value << " ";
    cout << out[n - 1].suit << out[n - 1].value;
    cout << endl;
    if(isStable(in, out, n))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;

    for(int i = 0; i < n; i++)
        out[i] = in[i];
    
    selectionsort(out, n);
    for(int i = 0; i < n - 1; i++)
        cout << out[i].suit << out[i].value << " ";
    cout << out[n - 1].suit << out[n - 1].value;
    cout << endl;
    if(isStable(in, out, n))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
}


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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '7') {
    ++counter;
  }
  if (s[1] == '7') {
    ++counter;
  }
  if (s[2] == '7') {
    ++counter;
  }
  if (counter == 0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */


/* add your algorithm here */

int main() {
  ll n,m;
  cin >> n >> m;
  ll ans = 0;

  if (abs(m-n) >= 2) {
    cout << ans << endl;
  } else if (m == n) {
    ll tmp1 = 1, tmp2 = 1;
    for (int i = m; i > 0; --i) {
      tmp1 *= i;
      tmp1 %= MOD;
    }

    tmp2 = tmp1;
    tmp1 *= 2;
    tmp1 %= MOD;
    tmp2 %= MOD;
    tmp1 *= tmp2;
    tmp1 %= MOD;
    cout << tmp1 << endl;
  } else if (abs(m-n) == 1) {
    ll tmp1 = 1, tmp2 = 1;
    for (int i = m; i > 0; --i) {
      tmp1 *= i;
      tmp1 %= MOD;
    }
    for (int i = n; i > 0; --i) {
      tmp2 *= i;
      tmp2 %= MOD;
    }
    ans = (tmp1 * tmp2) % MOD;
    cout << ans << endl;
  }
}


Measured memory_bytes: 256