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

#define ll unsigned long long
#define dbl double
#define endl "\n"
#define fo(i,n) for(int i=0; i<n; i++)
#define FOR(i,n,k) for(int i=0; i<n; i+=k)
#define sFOR(i,s,n) for(int i=s; i<n; i++)
#define vi vector<int>
#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
#define eb(x) emplace_back(x)
#define UM unordered_map<int,int>
#define INF INT_MAX
#define NEG_INF INT_MIN
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int r,c;
  cin>>r>>c;
  vector<vector<char>> mat(r+1,vector<char>(c+1));
  vector<vector<ll>> dp(r+1,vector<ll>(c+1,0));
  for(int i=1; i<=r; i++){
    for(int j=1; j<=c; j++){
      cin>>mat[i][j];
    }
  }
  dp[1][1] = 1;
  for(int i=2; i<=r; i++){
    if(mat[i][1] != '#')
      dp[i][1] = dp[i-1][1];
  }
  for(int j=2; j<=c; j++){
    if(mat[1][j] != '#')
      dp[1][j] = dp[1][j-1];
  }
  for(int i=2; i<=r; i++){
    for(int j=2; j<=c; j++){
      if(mat[i][j] != '#'){
          dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;

      }
    }
  }

  cout<<dp[r][c]%MOD;
  return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int k;
	char s[105];
	cin>>k;
	cin>>s;
	int len=strlen(s);
	if(len<=k)
		cout<<s<<endl;
	else
	{
		for(int i=0;i<k;i++)
		    cout<<s[i];
		cout<<"..."<<endl;
	}
	return 0;
}

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt")  
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 998244353

ll gcd(ll x, ll y){ 
	if(x<y) 
		swap(x,y); 
	if(x%y==0)
		return y;
	return gcd(y, x%y);
}

// ll pwm(ll a, ll n){
// 	ll ans = 1;
// 	while(n>0){
// 		if(n%2==1){
// 			ans = (ans * a)%mod;
// 		}
// 		a = (a*a)%mod;
// 		n /= 2;
// 	}
// 	return ans%mod;
// }

// const int pwn = 100010;
// ll pw[pwn];
// void pwtwo(){
// 	pw[0] = 1;
// 	for(int i=1; i<pwn; i++){
// 		pw[i] = (pw[i-1]*2)%mod;
// 	}
// }


ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
ll modInverse(ll a, ll m) 
{ 	
	if(a==1)
		return 1;
	//cout<<"mi "<<a<<" "<<m<<" ";
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1){
        //cout << "Inverse doesn't exist"<<endl; 
        return -1;
    }
    else
    { 
        // m is added to handle negative x 
        ll res = (x%m + m) % m; 
        //cout<<res<<endl;
        return res;
        // cout << "modular multiplicative inverse is " << res; 
    } 
} 
  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

ll fact[300005];
ll init(){
	fact[0] = 1ll;
	for(int i=1; i<300005; i++)
		fact[i] = (fact[i-1]*i)%mod;
}

ll ncr(ll n, ll r){
	// cout<<" "<<n<<" "<<r<<endl;
	if(r>n)
		return 0;
	
	ll ans = fact[n];

	//if(r!=0)
	ans = (ans*modInverse(fact[r], mod))%mod;
	// if(n-r!=0)
	ans = (ans*modInverse(fact[n-r], mod))%mod;

	return ans;
}

int main(){
	// finput;
	// foutput;
	fast;

	ll n, k, i, j, x, m,a,b, sum;
	ll ans = 0ll;
	// string s;
	cin>>n>>a>>b>>k;
	init();
	for(i=0; i<=n; i++){
		// i;
		sum = k - a*i;
		if(sum<0 || sum%b!=0){
			continue;
		}

		j = sum/b;

		ans += (ncr(n, j)*ncr(n, i))%mod;
		ans %= mod;
	}

	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 2560
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product # 全探索
from bisect import bisect_left, bisect_right

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

N, K = s_inpl()

if K%2 == 1:
    ans = int(N/K)**3
else:
    ans = int(N/K)**3 + int(N/int(K/2)-int(N/K))**3

print(ans)

Measured memory_bytes: 20532
SIZE=100001; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0


# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,k = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]

a.sort()


ans = 0
for i in range(n):
    ans += a[i]*choose(i,k-1)
    ans -= a[i]*choose(n-i-1,k-1)
    ans %= MOD

print(ans)




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

vector<int> edge[100005];
bool vis[100005], A[100005], B[100005];

void dfs(int x, int p) {
	vis[x] = 1;
	for (auto i : edge[x]) {
		if (vis[i]) {
			if (i != p && x < i) A[x] ^= 1;
			continue;
		}
		A[x] ^= 1;
		dfs(i, x);
	}
}

bool f(int x, int p) {
	bool ret = B[x];
	vis[x] = 1;
	for (auto i : edge[x]) {
		if (vis[i]) {
			if(i != p && x < i) printf("%d %d\n",x, i);
			continue;
		}
		bool t = f(i, x);
		if (t) printf("%d %d\n",i, x);
		else printf("%d %d\n", x, i);
		ret ^= t;
	}
	return ret;
}

int main() {
 	ios_base::sync_with_stdio(0), cin.tie(0);
 	int N, M; cin >> N >> M;
 	for (int i = 0; i < M; ++i) {
 		int x, y; cin >> x >> y;
 		edge[x].push_back(y);
 		edge[y].push_back(x);
 	}
 	if (M & 1) return !printf("-1");
 	dfs(1, 1);
 	vector<int> vec;
 	for (int i = 1; i <= N; ++i) if(A[i]) vec.push_back(i);
 	for (int i = 0; i < vec.size(); i += 2) {
 		B[vec[i]] ^= 1;
 		B[vec[i + 1]] ^= 1;
 	}
 	memset(vis, 0, sizeof(vis));
 	f(1, 1);
	return 0;
}

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

int main()
{
	int a,b,c;
	cin>>a>>b;
	if(a*b*1%2==1)
	{ 
	cout<<"Yes";
	return 0;
    }
    if(a*b*2%2==1)
    {
    	cout<<"Yes";
    	return 0;
	}
	if(a*b*3%2==1)
	{
		cout<<"Yes";
		return 0;
	}
	if(a*b*1%2==0)
	{
		cout<<"No";
		return 0;
	}
	if(a*b*2%2==0)
	{
		cout<<"No";
		return 0;
	}
	if(a*b*3%2==0)
	{
		cout<<"No";
		return 0;
	}
 } 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	String[] stack = new String[1000000];
	int top = 0;
	
	void run() throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] stringArray = br.readLine().split(" ");
		int result = 0;
		for (int i = 0; i < stringArray.length; i++) {
			
			if (stringArray[i].equals("+") ||
				stringArray[i].equals("-") ||	
				stringArray[i].equals("*") ||
				stringArray[i].equals("/")) {
				
				int x = Integer.parseInt(pop());
				int y = Integer.parseInt(pop());
				result = calc(stringArray[i], y ,x);
				push(String.valueOf(result));
			} else {
				push(stringArray[i]);
			}
		}
		System.out.println(result);
	}
	
	void push(String x) {
		top++;
		stack[top] = x;
	}
	
	String pop() {
		String x = stack[top];
		top--;
		return x;
	}
	
	int calc(String optor, int x , int y) {

		int result = 0;
		switch (optor) {
			case "+" :
				result = x + y;
				break;
			case "-":
				result = x - y;
				break;
			case "*":
				result = x * y;
				break;
			case "/":
				result = x / y;
				break;
		}
		return result;
	}

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

Measured memory_bytes: 28172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int alpha[26];
const int INF = 10000000;

int main(){
    int n; 
    cin >> n;
    vector<string> S(n);
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    for(int i = 0; i < 26; i++){
        alpha[i] = INF;
    }
    
    for(char c = 'a'; c <= 'z'; c++){
        if(alpha[c - 'a'] == 0)     continue;
        
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 0; j < S[i].length(); j++){
                if(S[i][j] == c){
                    cnt++;
                }
            }
            alpha[c - 'a'] = min(alpha[c - 'a'], cnt);
        }
    }
    
    string ans = "";
    for(char c = 'a'; c <= 'z'; c++){
        int temp = alpha[c - 'a'];
        while(temp > 0){
            ans += c;
            temp--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 100007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n;
int a[Maxn];
bool check(int x)
{
	int sum=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]!=x&&a[i]!=x-1) return false;
		if (a[i]==x) ++sum;
	}
	int t=x-n+sum;
	if (t<0||(t<1&&sum>0)||t>sum/2) return false;
	return true;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	if (check(a[1])||check(a[1]+1)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (((n / (a + b)) * a) + min(n % (a + b), a)) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  vector<int> ai(n);
  int maxabs = 0;
  for(int i=0; i<n; ++i){
    cin >> ai[i];
    if(abs(ai[maxabs]) < abs(ai[i])) maxabs = i;
  }
  vector<P> ans(0);
  int ansnum = 0;
  if(ai[maxabs] > 0){
    for(int i=0; i<n; ++i){
      if(ai[i] <0){
        ans.push_back(make_pair(maxabs, i));
        ai[i] += ai[maxabs];
        ++ansnum;
      }
    }
    for(int i=1; i<n; ++i){
      if(ai[i-1] > ai[i]){
        ans.push_back(make_pair(i-1, i));
        ai[i] += ai[i-1];
        ++ansnum;
      }
    }
  }else{
    for(int i=0; i<n; ++i){
      if(ai[i] >0){
        ans.push_back(make_pair(maxabs, i));
        ai[i] += ai[maxabs];
        ++ansnum;
      }
    }
    for(int i=n-2; i>=0; --i){
      if(ai[i] > ai[i+1]){
        ans.push_back(make_pair(i+1, i));
        ai[i] += ai[i+1];
        ++ansnum;
      }
    }
  }
  cout << ansnum << endl;
  for(auto pi: ans){
    cout << pi.first+1 << " " << pi.second+1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
ll n,W,w[100],v[100],dp[101][100001];
ll rec(ll i,ll j){
  if(dp[i][j]>=0) return dp[i][j];
  ll res;
  if(i==n) res=0;
  else if(j<w[i]) res=rec(i+1,j);
  else res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);
  return dp[i][j]=res;
}
int main(){
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  memset(dp,-1,sizeof(dp));
  cout<<rec(0,W);
}

Measured memory_bytes: 79104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin>>n,n) {
    int t[n][n+1];
    REP(i,n) {
      REP(j,n+1) {
        cin >> t[i][j];
      }
    }
    int dp[1<<n];
    REP(i,1<<n)dp[i] = INF;
    dp[0] = 0;

    REP(S,1<<n) {
      //    cout << bitset<3>(S) << endl;
      REP(i,n) {
        if (!(S>>i&1)) continue; 
        int tmp = t[i][0];
        REP(j,n) {
          if (i==j) continue;
          if (S>>j&1) {
            tmp = min(tmp, t[i][j+1]);
          }
        }
        dp[S] = min(dp[S], dp[S&~(1<<i)] + tmp);
//        printf("%d,%d\n",i,tmp);
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
}

Measured memory_bytes: 1120
/******************************************
* AUTHOR : AMAN SAXENA *
* Nick : blue-meth *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

ll amanpower(ll a, ll b) {
    ll r = 1;
    while (b > 0) 
    {
        if (b & 1) r = r * a;
        a = a * a;
        b >>= 1;
    }
    return r;
}


ll amanlcm(ll a, ll b)
{
     return a*(b/__gcd(a,b));
}


//********* CODE START *********

void solve()
{
  ll mod;
  cin >> mod;
  ll val = 7%mod;
  FOR(i,1,1e7)
  {
    if(val == 0)
    {
      cout << i;
      return;
    }
    val = (val*10 + 7)%mod;
  }
  cout << -1;
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

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

    
    return 0;
}

Measured memory_bytes: 3652
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-10;
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003


int dp[353][353]={0};
int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n;
P ps[101];

int main(){
	
	int n;
	
	cin>>n;
	
	ll sum=0;
	vector<int> a(n);
	
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	
	sort(a.begin(),a.end());
	
	cout<<a[0]<<" "<<a[n-1]<<" "<<sum<<endl;
	
	
	
	
	
	
	

	
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int main() { 
    int n;
    ll k;
    cin >> n >> k;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll start = 1;
    ll end = 1000000000;
    while (end - start > 1) {
        ll medium = (start + end) / 2;
        ll count = 0;
        for (int i = 0; i < n; i++) {
            count += (a[i] - 1) / medium;
        }
        if (count <= k) end = medium;
        else start = medium;
    }
    ll countlast = 0;
    for (int i = 0; i < n; i++) {
        countlast += (a[i] - 1) / start;
    }
    if (countlast <= k) {
        cout << start << endl;
    }
    else cout << end << endl;
    return 0;
}

Measured memory_bytes: 5160
n = int(input())
out = ''
for i in range(3,n+1):
    if i % 3 == 0:
        out += ' {0}'.format(i)
        continue
    elif i % 10 == 3:
        out += ' {0}'.format(i)
        continue
    n = i
    while n // 10:
        n = n // 10
        if n % 10 == 3:
            out += ' {0}'.format(i)
            n = 0
print(out)

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

int main()
{
    int a, b, c, d, e, n = 5;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;

    vector<int> time = {a, b, c, d, e};
    vector<int> next_time(n);
    rep(i, n)
    {
        // if (time[i] % 10 == 0)
        //     next_time[i] = time[i];
        // else
        //     next_time[i] = time[i] - time[i] % 10 + 10;

        next_time[i] = (time[i] + 9) / 10 * 10;
    }

    int best_time = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        int sum_time = 0;
        for (int j = 0; j < n; j++)
        {
            if (i == j)
            {
                sum_time += time[j];
            }
            else
            {
                sum_time += next_time[j];
            }
        }
        best_time = min(best_time, sum_time);
    }

    cout << best_time << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  set<int> st;
  int N;
  cin >> N;
  REP(i,N){
    int d;
    cin >> d;
    st.insert(d);
  }
  cout << st.size() << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>//懒人专用头文件
#define inr int
#define rpt(n) for(register inr ttxyc=0;ttxyc<n;++ttxyc)//宏定义
using namespace std;
inline int read()//快读
{
	register int x=0,t=0;register char c=getchar();
	for(;c<'0'||c>'9';t|=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar());
	return t?-x:x;
}
int n,t,x,y,nowt,nowx,nowy,ft,f;
main()
{
	n=read();
	rpt(n)
	{
		t=read();x=read();y=read();
		ft=t-nowt;f=abs(x-nowx)+abs(y-nowy);
		if(ft<f||(ft-f)%2){puts("No");return 0;}
		nowt=t;nowx=x;nowy=y;
	}
	puts("Yes");
}/**/

Measured memory_bytes: 256
S = gets.chomp
N = S.length

if S != S.reverse
    puts "No"
elsif S.slice(0...((N - 1) / 2)) != S.slice(0...((N - 1) / 2)).reverse
    puts "No"
elsif S.slice(((N + 1) / 2)...N) != S.slice(((N + 1) / 2)...N).reverse
    puts "No"
else
    puts "Yes"
end



Measured memory_bytes: 1788
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	map<int, int> mp;
    rep(i, 3) {
        int a; cin >> a;
        mp[a] ++;
    }
    for(P p: mp) {
        if(p.sc == 1) {
            cout << p.fr << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
    int N, M, ans, res;
    cin >> N;
    M = N;

    for(int i=0; i<=9; i++) {
        res = N%10;
	N = (N-res)/10;
	ans += res;
    }

    if(M%ans == 0) {
	cout << "Yes" << endl;
    } else {
	cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  REP(i, pow(3, N)){
    int bit = i;
    int ret = 1;
    REP(j, N){
      ret *= A[j]-1+bit%3;
      bit /= 3;
    }
    if(ret%2 == 0) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int main()
{
  int N, M; cin >> N >> M;
  vector<int> aba(M);
  rep(i, 0, M) cin >> aba[i];
  vector<int> value(10);
  value[1] = 2;
  value[2] = 5;
  value[3] = 5;
  value[4] = 4;
  value[5] = 5;
  value[6] = 6;
  value[7] = 3;
  value[8] = 7;
  value[9] = 6;
  vector<string> dp(N + 1, "0");
  dp[0] = "";

  repe(num, 0, N){
    if(dp[num] == "0") continue;
    rep(i, 0, M){
      int next = num + value[aba[i]];
      if(num + value[aba[i]] <= N){
        string tmp = dp[num];
        tmp.push_back('0' + aba[i]);
        if(dp[next].size() < tmp.size()){
          dp[next] = tmp;
        } else if(dp[next].size() == tmp.size()){
          if(dp[next] < tmp) dp[next] = tmp;
        }
      }
    }
  }
  string ans = dp[N];
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

}


Measured memory_bytes: 54540
//Created by: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 1005, mod = 1e9 + 7;

char ar[N][N];
int n, m, dp[N][N];

int solve(int i, int j)
{
    if (i == n || j == m || ar[i][j] == '#')
        return 0;
    if (i == n - 1 && j == m - 1)
        return 1;
    if (dp[i][j] != -1)
        return dp[i][j];
    int x = solve(i + 1, j);
    int y = solve(i, j + 1);
    return dp[i][j] = (x + y) % mod;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, ans = 0, cnt = 0, sum = 0;
        cin >> n >> m;
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < m; j++)
            {
                cin >> ar[i][j];
                dp[i][j] = -1;
            }
        }
        cout << solve(0, 0);
    }
    return 0;
}

Measured memory_bytes: 12504
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    deque<int> d;
    int q;
    cin >> q;
    int n, a, b;
    vector<int> v;
    rep(i, q) {
        cin >> n;
        if (n == 0) {
            cin >> a >> b;
            if (a == 0)
                d.push_front(b);
            else
                d.push_back(b);
        }
        else if (n == 1) {
            cin >> a;
            v.push_back(d[a]);
        }
        else {
            cin >> a;
            if (a == 0)
                d.pop_front();
            else
                d.pop_back();
        }
    }
    for (auto i : v)
        cout << i << endl;
}


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

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

    for (int i=0;i<a.size();i++) {
        cout<<a[i];
        if(i<b.size()){
            cout<<b[i];
        }
    }


    cout<<endl;

}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,i,j,ans=999999;
	cin>>n;
	vector<tuple<int,int,int>> x(n);//?§??????????v,Si
	for(i=0;i<n;i++){
		int m,d,s,v;cin>>m>>d>>v>>s;
		x[i]=mt(m*30+d,v,s);
	}
	for(i=0;i<360;i++){
		int gen=0;
		for(j=0;j<n;j++){
			int p=(3600+i-get<0>(x[j]))%360;//??£????????????????????\??????
			int v=get<1>(x[j]);
			int s=get<2>(x[j]);
			if(p<v){maxeq(gen,s);}
			else{
				maxeq(gen,s+v-p-1);
				maxeq(gen,s+p-360);
			}
		}
		mineq(ans,gen);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3112
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a = I()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return

#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return

#C
def C():
    n = I()
    v = LI()
    q = []
    for i in v:
        heappush(q,i)
    while q:
        x = heappop(q)
        if not q:
            print(x)
            return
        y = heappop(q)
        heappush(q,(x+y)/2)
    return

#D
def D():
    def dfs(x,d,s):
        for y in v[x]:
            if d[y]:
                s += f[y]
                ans[y] = s
                d[y] = 0
                dfs(y,d,s)
                s -= f[y]
    n,q = LI()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for i in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    ans = [0]*n
    d = [1]*n
    d[0] = 0
    ans[0] = f[0]
    s = f[0]
    dfs(0,d,s)
    print(*ans)
    return

#E
def E():
    s = input()
    t = input()

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 291188
while True:
    b,r,g,c,s,t=map(int,raw_input().split())
    if b==r==g==c==s==0:break
    nb=b*5+r*3
    no=t-nb
    print 100+15*(b+r+nb)+7*g+2*c-3*(no-s)-2*nb

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N - 1);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  for (ll i = 0; i < N; i++)
  {
    cin >> B.at(i);
  }
  for (ll i = 0; i < N - 1; i++)
  {
    cin >> C.at(i);
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    ans += B.at(A.at(i) - 1);
    if (i != 0 && A.at(i - 1) + 1 == A.at(i))
      ans += C.at(A.at(i - 1) - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  string s;
  cin>>s;
  for(auto &I:s){I-='0';}
  vector<vector<int>> idx(10);
  for(int i=0;i<N;i++){
    idx[s[i]].push_back(i);
  }
  for(auto &I:idx){I.push_back(N);}
  
  auto search=
    [&](int num,int lf)->int{
      lf=min<int>(lf,N);
      return *lower_bound(idx[num].begin(),idx[num].end(),lf);
    };
  ll ans=0;
  for(int i=0;i<1000;i++){
    int a=i%10;
    int b=i/10%10;
    int c=i/100%10;
    int x=0;
    x=search(a,x);
    x=search(b,x+1);
    x=search(c,x+1);
    if(x<N){ans++;}
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
    using namespace std;
     
    int main(){
      int count = 0;
      char s[3];
      cin >> s;
      for(int i = 0;i < 3;i++){
       	if(s[i] == 'o') ++count; 
      }
    	cout << count*100 + 700 << endl;
     return 0; 
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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


int main() {

	string S;
	cin >> S;
	int max = 0;
	int now = 0;

	rep(i, S.size()) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			now++;
		}
		else {
			if (now > max)max = now;
			now = 0;
		}
	}
	if (now > max)max = now;
	
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
// combi.cpp

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

const int MAX_N = 100010;
const int ABC = 26;

void wrong()
{
    cout << "NO" << endl;
    exit(0);
}

struct DSU
{
    int a[MAX_N + 1], n;
    DSU(int _n)
    {
		n = _n;
		for (int i = 0; i <= n; ++i) a[i] = i;
    }
    int root(int x) { return (x == a[x] ? x : a[x] = root(a[x])); }
    void merge(int x, int y)
    {
    	if (root(x) == root(y)) return;
        x = root(x); y = root(y);
        if (x > y) swap(x, y);
        a[y] = x;
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

int mod(int x, int m)
{
    while (x < 0) x += m;
    while (x >= m) x -= m;
    return x;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string S; cin >> S;
    int sz = S.size();
    int N; cin >> N;

    // dsu
    int maxn = sz / 2;
    DSU dsu(maxn);

    for (int i = 0; i < N; ++i) {
        int l, r; cin >> l >> r; --l;
        l = min(l, sz-l);
        r = min(r, sz-r);
        dsu.merge(l, r);
//        cerr << 's' << l << ' ' << r << endl;
	}

	vector<int> vec[maxn+1];
    for (int i = 0; i <= maxn; ++i) {
//        cerr << dsu.root(i) << ' ';
    	vec[dsu.root(i)].push_back(i);
    }
//    cerr << endl;

    int nxt[maxn+1];
    for (int i = 0; i <= maxn; ++i) {
		if (vec[i].empty()) continue;
        sort(vec[i].begin(), vec[i].end());
        for (int j = 1; j < vec[i].size(); ++j) {
            nxt[ vec[i][j-1] ] = vec[i][j];
        }
        nxt[ vec[i][vec[i].size() - 1] ] = -1;
    }

//    for (int i = 0; i <= maxn; ++i) {
//        cerr << nxt[i] << ' ';
//    }
//    cerr << endl;


    // new string
    int ch[maxn];
    for (int i = 0; i < maxn; ++i) {
        ch[i] = mod(S[i] - S[sz-1-i], ABC);
//        cerr << ch[i] << ' ';
    }
//    cerr << endl;

    // process
    int add[maxn+1], cur = 0;
    memset(add, 0, sizeof add);
    for (int i = 0; i < maxn; ++i) {
        cur += add[i];
        cur = mod(cur, ABC);

        ch[i] = mod(ch[i] + cur, ABC);
        if (ch[i] == 0) continue;
        if (nxt[i] < 0) wrong();

        cur += mod(-ch[i], ABC);
        cur = mod(cur, ABC);

        add[ nxt[i] ] += mod(ch[i], ABC);
        add[ nxt[i] ] = mod(add[ nxt[i] ], ABC);
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 3920
#!/usr/bin/env python3

import itertools
try:
    from math import gcd
except ImportError:
    from fractions import gcd


class Cumulative(object):

    def __init__(self, seq, op):
        self.cumul_array = [0]
        self.cumul_array.extend(itertools.accumulate(seq, op))


def solve(n, xs):
    left_cumul = Cumulative(xs, gcd)
    right_cumul = Cumulative(reversed(xs), gcd)
    res = 1
    for i in range(n):
        left_gcd = left_cumul.cumul_array[i]
        right_gcd = right_cumul.cumul_array[n - i - 1]
        cand = gcd(left_gcd, right_gcd)
        if cand > res:
            res = cand
    return res


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    res = solve(n, xs)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16164
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int main(){

    int N;
    int tmp;
    cin >> N;

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

    sort(d.begin(), d.end(), greater<int>());

    tmp = *max_element(d.begin(), d.end());

    int ans = 1;
    for(int i = 0; i < N; ++i){
        if(d[i]<tmp){
            ans++;
            tmp = d[i]; 
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0

for i in range(n):
    if A[i] >= B[i]:
        count += B[i]
        A[i] -= B[i]
    else:
        if A[i+1] >= B[i]-A[i]:
            count += B[i]
            A[i+1] -= B[i]-A[i]
        else:
            count += A[i] + A[i+1]
            A[i+1] = 0
print(count)

Measured memory_bytes: 18476
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 100000+10;
int N;
vector<double> X(max_n);
vector<double> Y(max_n);
vector<char> d(max_n);

double calc(double time) {
    double xmin = TEN(10),xmax=-TEN(10),ymin=TEN(10),ymax=-TEN(10);
    
    for(int i = 0;i < N;i++) {
        double dx = 0;
        double dy = 0;
        if(d[i] == 'R') {
            dx += time;
        } else if(d[i] == 'L') {
            dx -= time;
        } else if(d[i] == 'U') {
            dy += time;
        } else {
            dy -= time;
        }

        xmin = min(xmin,X[i]+dx);
        xmax = max(xmax,X[i]+dx);
        ymin = min(ymin,Y[i]+dy);
        ymax = max(ymax,Y[i]+dy);
    }

    return (xmax-xmin)*(ymax-ymin);
}

double trisection(double s, double t) {
    int num = 300;
    double ans = TEN(18);
    double f1;
    double f2;
    
    while(num--) {
        double mid1 = (2*s+t) / 3.0;
        double mid2 = (s+2*t) / 3.0;
        
        f1 = calc(mid1);
        f2 = calc(mid2);
        if(f1 <= f2) {
            t = mid2;
        } else if(f1 >= f2) {
            s = mid1;
        } else {
            t = mid2;
        }

        ans = min(ans,min(f1,f2));
    }

    return ans;
}

double solve(void) {
    double ans = trisection(0, TEN(9));

    return ans;
}

int main(void) {
    cin>>N;
    for(int i = 0;i < N;i++) {
        cin>>X[i]>>Y[i]>>d[i];
    }

    cout<<fixed<<setprecision(10);
    cout<<solve()<<endl;


    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <vector>

int main(){
	int n;
	scanf("%d",&n);
	std::vector<int> v;
	v.clear();
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	for(int i=0;i<n;i++){
		printf("%d%c",v[n-1-i],i!=n-1?' ':'\n');
	}
	return 0;
}

Measured memory_bytes: 1048
s=list(input())
ans=0
if s[0]=="R" :
    ans=1
    if s[1]=="R" :
        ans=2
        if s[2]=="R" :
            ans=3

elif s[0]=="S" :
    ans=0
    if s[1]=="R" :
        ans=1
        if s[2]=="R" :
            ans=2
    elif s[1]=="S" :
        ans=0
        if s[2]=="R" :
            ans=1
print(ans)
        

Measured memory_bytes: 8996
#include <stdio.h>
int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2148
#include <iostream>
using namespace std;
int main(){
	int a,b,c,x,y,tmpx,tmpy;
	long total=0,subtotal=0;
	cin>>a>>b>>c>>x>>y;
	tmpx=x;
	tmpx=y;
	if ((a+b)/2>=c){
		if (tmpx%2==1)	tmpx-=1;
		if (tmpy%2==1)	tmpy-=1;
		int min=(x>y)?y:x;
		total+=min*2*c;
		if (x>min)	total+=(x-min)*a;
		if (y>min)	total+=(y-min)*b;
		
		int max=(x>y)?x:y;
		subtotal=max*c*2;
	}
	else{
		total+=x*a+y*b;
	}
	if (subtotal>total || subtotal==0)	cout<<total;
	else	cout<<subtotal;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {	
	string s;
	cin >> s;
	if (s == "SUN") {
		cout << "7" << endl;
	}
	else if (s == "MON") {
		cout << "6" << endl;
	}
	else if (s == "TUE") {
		cout << "5" << endl;
	}
	else if (s == "WED") {
		cout << "4" << endl;
	}
	else if (s == "THU") {
		cout << "3" << endl;
	}
	else if (s == "FRI") {
		cout << "2" << endl;
	}
	else if (s == "SAT") {
		cout << "1" << endl;
	}
	return 0;
}

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

bool solve(int i, std::vector<int> &A, int m)
{
    // exhaustive research
    int n = A.size();
    if (m == 0) return true;
    else if (i >= n) return false;
    else return solve(i+1, A, m) || solve(i+1, A, m - A[i]);
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int q;
    std::cin >> q;
    int m;
    for (int i = 0; i < q; i++) {
        std::cin >> m;
        if (solve(0, A, m))
            std::cout << "yes" << std::endl;
        else
            std::cout << "no" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define MAX 200010
#define inf 2147483647
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n,n_,q;
ll st[MAX*2];

void init(){
  n_ = 1;
  while(n_<n)n_*=2;
  FOR(i,0,2*n_-1)st[i]=0;
}

void add(int a,int b){
  a+=n_-1;
  st[a] += b;
  while(a>0){
    a = (a-1)/2;
    st[a] = st[a*2+1]+st[a*2+2];
  }
}

int find(int a,int b,int c,int l,int r){
  if(r<=a || b<=l)return 0;
  if(a<=l && r<=b)return st[c];
  
  int L = find(a,b,c*2+1,l,(l+r)/2);
  int R = find(a,b,c*2+2,(l+r)/2,r);
  return L+R;
}

int main()
{
  cin>>n>>q;
  init();
  FOR(i,0,q){
    int a,b,c;
    cin>>a>>b>>c;
    if(a)cout<<find(b-1,c,0,0,n_)<<endl;
    else add(b-1,c);
  }
  return 0;
}



Measured memory_bytes: 5132
#include <iostream>

using namespace std;

int main()
{
    int N;
    int flag=0;
    cin>>N;
    for(int i=1;i<=9&&flag==0;i++)
        for(int j=1;j<=9&&flag==0;j++)
            if(N==i*j)
            {
                flag=1;
                break;
            }
    if(flag)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


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

int N;

int main() {
    cin >> N;
    map<int, int> mp;
    int first = 0, second = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ++mp[a];
        if (mp[a] >= 2) {
            if (a > first) {
                second = first;
                first = a;
                mp[a] -= 2;
            } else if (a > second) {
                second = a;
                mp[a] -= 2;
            }
        }
    }
    cout << 1ll * first * second << endl;
}




Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>

int main(){
	int h,w;
	char s[205][104];
	scanf("%d%d", &h, &w);
	for(int i = 1; i <= h; i++){
		scanf("%s", s[i] + 1);
	}
	for(int i = 1; i <= h; i ++)
	{
		for(int j = 1; j <= w; j++){
			printf("%c", s[i][j]);
		}
		printf("\n");
		for(int j = 1; j <= w; j++){
			printf("%c", s[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
  long int a, b, c, x;
  scanf("%ld %ld %ld",&a, &b, &c);
  
  x = c-a-b;
  if(x<0)
    printf("No");
  else if(4*a*b < x*x)
    printf("Yes");
  else
    printf("No");
 
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

int n, a, b, c, d;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read() - 1, a = Read(), b = Read(), c = Read(), d = Read();
	b -= a;

	for (int i = 0; i <= n; i ++)
	{
		LL l = 1LL * c * (n - i) - 1LL * d * i, r = 1LL * d * (n - i) - 1LL * c * i;
		if (b >= l && b <= r)
			return puts("YES"), 0;
	}
	puts("NO");
}


Measured memory_bytes: 256