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

int main() {
  int N;
  cin >> N;
  int d[51];
  for (int i = 0; i < N; ++i) {
    cin >> d[i];
  }
  
  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

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

//-----------------------------------------------------------------------------------
typedef long long int ll;
typedef long double ld;
#define endl "\n"
#define int long long
#define float long double
#define u_s unordered_set
#define mm multimap
#define pb push_back
#define ff first
#define ss second
#define go_flash ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
const int mod = 1000000007;
//-----------------------------------------------------------------------------------
void primeFactors(int n){while(!(n%2)){n/=2;}for(int i=3;i<=sqrt(n);i+=2){
while(!(n%i)){n/=i;}}if(n>2){;}}
int cd(int n){return floor(log10(n) + 1);} 
unsigned int cb(int number) {unsigned int l=log2(number)+1;return l;}
bool at_position(int num,int pos){unsigned int go=(1ULL<<pos);bool bit = num & go;return bit;} 
//-----------------------------------------------------------------------------------
template<typename...T>void input(T &...args) {((cin >> args), ...);}
template<typename...T>void print(T &&...args) {((cout << args <<" "),...);}
template<typename...T>void deb(T &&...args) {((cerr<<args<<" "),...);cerr<<endl;}
//#define debug(x) cerr<<#x<<" => "<<x<<" ";
//-----------------------------------------------------------------------------------
void forv(vector<int> &v, int n) {int x;for(int i=0;i<n;i++){cin>>x;v.pb(x);}}
void printv(vector<int> v) {for(auto i: v){cout<<i<<" ";}}
void fora(int a[], int n) {for(int i=0;i<n;i++)cin>>a[i];}
void printa(int a[], int n) {for(int i=0;i<n;i++)cout<<a[i]<<" ";}
void dmap(map<int,int> mp){for(auto i: mp)cout<<i.ff<<" "<<i.ss<<endl;}
void dmmap(mm<int,int> mp){for(auto i: mp)cout<<i.ff<<" "<<i.ss<<endl;}
//-----------------------------------------------------------------------------------

signed main(){
    go_flash;

        int t=1;
        while(t--){
            //Your Code Blows HERE
            int n;cin>>n;
            string s;cin>>s;
            if(s.length()<=n)cout<<s;
            else{
                for(int i=0;i<s.length();i++){
                    if(i<=n-1){
                        cout<<s[i];
                    }
                }
                cout<<"...";
            }
            cout<<endl;
        }
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	ll a,b;
	cin>>a>>b;
	double e1=0.08,e2=0.1;
	for(double i=0;i<1e5;i++)
	{
		ll a1=e1*i;
		ll b1=e2*i;
		if(a1==a && b1==b)
		{
			cout<<i;
			exit(0);
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin >> s;
    if (s[1] == 'R') {
        cout << "ABC" << endl;
    }
    else {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int N,C,A[400],B[400];
long mod=1e9+7,S[401][401],dp[401][401];
main()
{
	cin>>N>>C;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	for(int j=1;j<=400;j++)S[0][j]=1;
	for(int k=1;k<=400;k++)
	{
		for(int j=1;j<=400;j++)S[k][j]=S[k-1][j]*j%mod;
	}
	for(int k=0;k<=400;k++)for(int j=1;j<=400;j++)S[k][j]=(S[k][j]+S[k][j-1])%mod;
	dp[0][C]=1;
	for(int i=0;i<N;i++)for(int j=0;j<=C;j++)
	{
		for(int k=0;k<=j;k++)
		{
			dp[i+1][j-k]=(dp[i+1][j-k]+(S[k][B[i]]-S[k][A[i]-1]+mod)%mod*dp[i][j])%mod;
		}
	}
	cout<<dp[N][0]<<endl;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll r = 0, g = 0, b = 0;
    rep(i, n){
        if(s[i]=='R') r++; 
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
    ll ans = r*g*b;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(j+j-i >= n) continue;
            if(s[i] != s[j] && s[i] != s[j+j-i] && s[j] != s[j+j-i]){
                ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};


using namespace std;

int main() {
    int ma=0;
    int v[3][3];
    rep(i,0,3)rep(j,0,3){
        cin>>v[i][j];
        ma=max(ma,v[i][j]);
    }
    int a,b,c;
    vector<int> v1,v2,v3;
    bool f=true;
    rep(i,0,ma+1){
        rep(j,0,ma+1){
            rep(k,0,ma+1){
                /*if((v[0][0]-i==v[1][0]-j&&v[1][0]-j==v[2][0]-k)&&(v[0][1]-i==v[1][1]-j&&v[1][1]-j==v[2][1]-k)&&(v[0][2]-i==v[1][2]-j&&v[1][2]-j==v[2][2]-k)){
                    cout<<"Yes"<<endl;
                    return 0;
                }else cout<<"No"<<endl;*/
                if((v[0][0]-i==v[0][1]-j&&v[0][1]-j==v[0][2]-k)&&(v[1][0]-i==v[1][1]-j&&v[1][1]-j==v[1][2]-k)&&(v[2][0]-i==v[2][1]-j&&v[2][1]-j==v[2][2]-k)){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        s:chars,
    }
    let mut map = HashMap::new();
    for &c in &s {
        *map.entry(c).or_insert(0) += 1;
    }
    if map.iter().all(|(k,v)| v== &2) {
        println!("Yes");
    } else {
        println!("No");
    }
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

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

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a == b) {
		cout << c << endl;
	} else if (b == c) {
		cout << a << endl;
	} else {
		cout << b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ok = 0;
  bool pal = true;
  int n = s.length();
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - i - 1])
      pal = false;
  }
  if (pal) ok |= 1;
  pal = true;
  int low = 0, high = n / 2 - 1;
  while (low < high) {
    if (s[low++] != s[high--])
      pal = false;
  }
  if (pal) ok |= 2;
  pal = true;
  low = n / 2 + 1, high = n - 1;
  while (low < high) {
    if (s[low++] != s[high--])
      pal = false;
  }
  if (pal) ok |= 4;
  if (ok == 7)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


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

using namespace std;

struct edge{
	int u,v,w;
};

long long ans=0;
int par[200005],ed[200005]={},sz[200005];

int root(int u){
	if(par[u]!=u){
		return par[u]=root(par[u]);
	}
	return u;
}

void merge(int u, int v, int w){
	int ru=root(u),rv=root(v);
	if(ru==rv){
		if(sz[ru]>ed[ru]){
			ed[ru]++;
			ans+=w;
		}
	}
	else{
		if(sz[ru]+sz[rv]>ed[ru]+ed[rv]){
			if(sz[ru]>sz[rv]){
				par[rv]=ru;
				sz[ru]+=sz[rv];
				ed[ru]+=ed[rv]+1;
			}
			else{
				par[ru]=rv;
				sz[rv]+=sz[ru];
				ed[rv]+=ed[ru]+1;
			}
			ans+=w;
		}
	}
}

int main(){
	int p,h,w; cin >> p >> h >> w;
	for(int i=0;i<h+w;i++){
		par[i]=i;
		sz[i]=1;
	}
	vector <edge> e(p);
	for(int i=0;i<p;i++){
		cin >> e[i].u >> e[i].v >> e[i].w;
		e[i].u--;e[i].v--;
	}
	sort(e.begin(),e.end(),[](edge &a, edge &b){
		return a.w>b.w;
	});
	for(int i=0;i<p;i++){
		merge(e[i].u,h+e[i].v,e[i].w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
  string s,t;
  cin>>s>>t;
  if(s==t)
  {
  	cout<<"0";
  }
  else
  {  int count=0;
  	for(int i=0;i<s.size();i++)
  	{
  		if(s[i]!=t[i])
  		 count++;
	  }
	  cout<<count;
  }
}


Measured memory_bytes: 3848
//Twitter@KonoLv1 2020年春卒で現在就職活動中！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count1,count2,count;   //  カウント用に使用
    int box[256] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    int a,b,c;
    a = b = c = i = 0;
    int mode = 0;
    count = count1 = count2 = 0;
 
    //  入力処理
    
    scanf("%s",s);
 
    //  計算処理
    
    if (s[0] == 'S'){
        printf("Cloudy");
    }else if (s[0] == 'C'){
        printf("Rainy");
    }else{
        printf("Sunny");
    }
    

 
    //  出力処理
 

 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={-1,1,0,0};
int dc[]={0,0,-1,1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    ll dp[n+2]={0};
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[1]-a[0]);
    for(ll i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i-2]),dp[i-2]+abs(a[i-1]-a[i-3]));
    }
    cout<<dp[n];

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll, ll> pii;
ll mod=998244353;
int main() {
    int n;
    cin>>n;
    int x,y;
    cin>>x>>y;
    int cnt[n];
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int d=min(abs(j-x)+abs(i-x)+1, abs(i-x)+abs(j-y)+1);
            d=min(d,abs(i-j));

            cnt[d]++;
        }
    }
    for(int i=1; i<n;i++){
        cout<<cnt[i]<<endl;
    }
	return 0;
}

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

F = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    v = 0
    for i in range(5 * 2):
        v += tmp[i] << i
    F.append(v)

P = []
for _ in range(N):
    p = list(map(int, input().split()))
    P.append(p)

ans = -1 * (10**12)
for bit in range(1, 1 << (5 * 2)):
    v = 0
    for i in range(len(F)):
        f = F[i]
        product = bit & f
        cnt = 0
        for j in range(5 * 2):
            if product & (1 << j):
                cnt += 1
        v += P[i][cnt]
    ans = max(ans, v)
print(ans)


Measured memory_bytes: 41836
function main(){
  var debt = 100000;
  var wk = input.trim() - 0;
  for(;wk > 0; wk--){
    debt = Math.ceil((debt * 1.05)/1000) * 1000;
  }

  console.log(debt);
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  main();
});

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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] + N > 90) {
      S[i] = S[i] + N - 26;
    } else {
      S[i] = S[i] + N;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3640
def main():
    a = [-1, -1, -1]
    b = [-1, -1, -1]
    for i in range(3):
        a[i], b[i] = map(int, input().split())

    visited = [False, False, False, False]
    degrees = [0, 0, 0, 0]
    for i in range(3):
        visited[a[i] - 1] = True
        visited[b[i] - 1] = True
        degrees[a[i] - 1] += 1
        degrees[b[i] - 1] += 1
    for i in range(4):
        if visited[i] == False:
            print('NO')
            return
    for i in range(4):
        if 3 <= degrees[i]:
            print('NO')
            return
    print('YES')

main()

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();
        int ans = 0;
        
        for(int i=1; i<N; i++){
            if(str.charAt(i-1) != str.charAt(i)){
                ans++;
            }
            //System.out.println(i);
        }
        System.out.println(ans+1);
    }
}


Measured memory_bytes: 39524
import bisect

N = int(input())

*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort()
B.sort()
C.sort()

A_B = [0]*N
B_C = [0]*N

for i in range(N):
    index = bisect.bisect_left(A,B[i])
    A_B[i] = index 

for i in range(N):
    index = bisect.bisect_right(C,B[i])
    B_C[i] = len(C)-index

sum = 0
for i in range(N):
    sum = sum + B_C[i]*A_B[i]

print(sum)


Measured memory_bytes: 23764
import java.util.Scanner;

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

		String ans = "";

		if (a<=b) {
			for (int i = 0; i < b; i++) {
				ans += a;
			}
		} else {
			for (int i = 0; i < a; i++) {
				ans += b;
			}
		}
		System.out.println(ans);

	}
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

// a^b^c = 0 かつ b^c^d = 0 なので、v[i] == v[(i+3)%N]
// N%3!=0のとき
// すべて0でないとダメ
//
// N%3==0のとき
// mp.size() = 1 すべての値は0
// mp.size() = 2 それぞれ2N/3個とN/3個
// mp.size() = 3 それぞれN/3個ずつ
signed main() {
  bool ans = false;
  ll N;
  cin>>N;
  map<ll ,ll> mp;
  rep(i,0,N) {
    ll x;
    cin>>x;
    mp[x]++;
  }
  if (N%3 != 0) {
    if (mp.size()==1 && mp[0] == N)
      ans=true;
  } else {
    if (mp.size()==1 && mp[0] == N) {
      ans=true;
    } else if (mp.size()==2) {
      auto it = mp.begin();
      ll x = it->second, xv=it->first; it++;
      ll y = it->second, yv=it->first;
      if (x > y) {
        swap(x,y);
        swap(xv,yv);
      }
      ll t=0;
      t ^= xv;
      t ^= yv;
      t ^= yv;
      if (x == N/3 && y == 2*N/3 && t==0)
        ans=true;
    } else if (mp.size()==3) {
      ll t = 0;
      auto it = mp.begin();
      ll x = it->second; t^=it->first; it++;
      ll y = it->second; t^=it->first; it++;
      ll z = it->second; t^=it->first;
      if (x==N/3 && y==N/3 && z==N/3 && t==0)
        ans=true;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 5120
# https://atcoder.jp/contests/abc160/submissions/15902850
# を配列アクセスが減るように

def rerooting(n, edges, identity, merge, add_node):
    # 全方位木 dp
    # 参考: https://qiita.com/keymoon/items/2a52f1b0fb7ef67fb89e
    G = [[] for _ in range(n)]
    G_idxs = [[] for _ in range(n)]  # 自分を指すノードのインデックス
    for a, b in edges:
        G_idxs[a].append(len(G[b]))
        G_idxs[b].append(len(G[a]))
        G[a].append(b)
        G[b].append(a)
    # step 1
    parents = [0] * n
    order = []  # 行きがけ順
    stack = [0]
    parents[0] = -1
    while stack:
        v = stack.pop()
        p = parents[v]
        order.append(v)
        for u in G[v]:
            if p != u:
                stack.append(u)
                parents[u] = v
    subtree_res = [[0]*len(Gv) for Gv in G]
    # 下から登る
    for v in order[:0:-1]:
        p = parents[v]
        result = identity
        for idx_Gv, (u, subtree_res_v_i) in enumerate(zip(G[v], subtree_res[v])):
            if p == u:
                parent_idx = idx_Gv
            else:
                result = merge(result, subtree_res_v_i)
        idx_p2v = G_idxs[v][parent_idx]
        subtree_res[p][idx_p2v] = add_node(result, v)
    # step 2
    # 上から降りる
    results = [0] * n
    for v in order:
        subtree_res_v = subtree_res[v]
        cum = identity
        cum_from_tail = [identity]
        for r in subtree_res_v[:0:-1]:
            cum = merge(r, cum)
            cum_from_tail.append(cum)
        cum_from_tail.reverse()
        cum = identity
        for r, cum_t, u, idx_u2v in zip(subtree_res_v, cum_from_tail, G[v], G_idxs[v]):
            result = add_node(merge(cum, cum_t), v)
            subtree_res[u][idx_u2v] = result
            cum = merge(cum, r)
        results[v] = add_node(cum, v)
    return results


class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

def main():
    N = int(input())
    AB = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N-1)]
    mod = 10**9 + 7
    comb = Combination(202020)
    identity = (1, 0)
    fac, facinv = comb.fac, comb.facinv
    def merge(a, b):
        a0, a1 = a
        b0, b1 = b
        return a0*b0*fac[a1+b1]*facinv[a1]*facinv[b1]%mod, a1+b1
    def add_node(a, idx):
        a0, a1 = a
        return a0, a1+1
    Ans = rerooting(N, AB, identity, merge, add_node)
    print("\n".join(str(ans) for ans, _ in Ans))

main()


Measured memory_bytes: 202908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N; cin >> N;
    bool ans = false;
    rep(i,N) if ((N - 7 * i) >= 0 and (N - 7 * i) % 4 == 0) ans = true; 
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define endl "\n" 
int main(){
    int n ; cin>>n ; 
    int arr[n] ; for(int i = 0; i<n ; i++) cin>>arr[i] ; 
     
    int ans = 0; 
    for(int i = 0 ; i<n ; i++) {
        ans = ans^arr[i] ; 
    }
    for(int  i= 0 ; i<n ; i++){
        int x = ans^arr[i] ; 
        cout<<x<<" " ; 
    }
    cout<<"\n" ; 

}

Measured memory_bytes: 4352
# 132 B

n = int(input())
p = list(map(int, input().split()))
num = 0

def sec(a, k, b):
    if (a <= k <= b) or (a >= k >= b):
        global num
        num += 1

for i in range(1, n-1):
    sec(p[i-1], p[i], p[i+1])

print(num)

Measured memory_bytes: 9192
#include <iostream>
#include <float.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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




int main() {
	string str;
	cin >> str;
	bool ok = false;
	rep(i, str.size()-1) {
		if (str[i] == 'A' && str[i + 1] == 'C')
			ok = true;
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



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

using namespace std;

long m, a, r, c, h;
int main()
{
	int n;
	cin >> n;
	char s[12];
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		switch (s[0])
		{
		case 'M': m++; break;
		case 'A': a++; break;
		case 'R': r++; break;
		case 'C': c++; break;
		case 'H': h++;
		}
	}
	cout << m * (a*(r + c + h) + r * (c + h) + c * h) + a * (r*(c + h) + c * h) + r * c*h << endl;
	return 0;
}


Measured memory_bytes: 256
a = input()

if  a == 'RRR':
    print(3)
elif a == 'RRS' or a == 'SRR':
    print(2)
elif a == 'RSR' or a == 'SSR' or a == 'SRS' or a == 'RSS':
    print(1)
else:
    print(0)

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

int main(){
    string s;
    cin >> s;
    bool ok = true;
    int l = 0,r = 0;
    rep(i,s.length()-1){
        if(s[i] == s[i+1]){
            l = i+1;
            r = i+2;
            ok = false;
            break;
        }
        if(i < s.length()-2 && s[i] == s[i+2]){
            l = i+1;
            r = i+3;
            ok = false;
            break;
        }
    }
    if(ok){
        printf("-1 -1\n");
    }else{
        cout << l << " " << r << endl;
    }
    return 0;
}

Measured memory_bytes: 512
h,w,ppp=map(int,input().split())
lis=[]
for i in range(h):
  lis.append(str(input()))
ans=0
for i in range(0,2**h):
  h_list=[]
  for k in range(0,h):
    t=h-k-1
    amari=i//2**t
    i-=amari*2**t
    h_list.append(amari)
  for j in range(0,2**w):
    count=0
    w_list=[]
    for l in range(0,w):
      t=w-l-1
      amari=j//2**t
      j-=amari*2**t
      w_list.append(amari)
    for x in range(0,h):
      for y in range(0,w):
        if w_list[y]==0 and h_list[x]==0:
          if lis[x][y]=="#":
            count+=1
    if count==ppp:
      ans+=1
print(ans)

Measured memory_bytes: 9240
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var axis = CRL().ArrayLongs();
        var any = axis.Count(x => 3200 <= x);
        var colors = axis.Where(x => x < 3200).Select(x => x / 400).Distinct().Count();
        CWL($"{Math.Max(1, colors)} {colors + any}");
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    //テンプレここまで
}


Measured memory_bytes: 13524
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String X = sc.next();
        String Y = sc.next();
        
        if(henkan(X)<henkan(Y)){
            System.out.println("<");
        }else if(henkan(X)>henkan(Y)){
            System.out.println(">");
        }else{
            System.out.println("=");
        }
    }
    
    public static int henkan(String str){
            if(str.equals("A")) return 10;
            if(str.equals("B")) return 11;
            if(str.equals("C")) return 12;
            if(str.equals("D")) return 13; 
            if(str.equals("E")) return 14;
            else return 15;
        }
}

Measured memory_bytes: 35512
import math
a, b, x = map(int,input().split())
if x >= a ** 2 * b / 2:
    tan = 2 * (a ** 2 * b - x) / a ** 3

else:
    tan = a * b ** 2 / x / 2
print(180 * math.atan(tan) / math.pi)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile(" ");
      int[] arrayS = delim
        .splitAsStream(line)
        .parallel()
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 198908
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}
ll dp1[101][4];
ll dp2[101][4];
string N;
int main() {
    int K;
    cin >> N >> K;
    // cout << "wo" << endl;
    int keta = N.length();
    // cout << keta << endl;
    // vector<vector<ll>> dp1(keta, vector<ll>(K + 1, 0LL));
    // vector<vector<ll>> dp2(keta, vector<ll>(K + 1, 0LL));
    // cout << "memory allocated" << endl;
    // dp1 inactive
    // dp2 active
    dp1[0][0] = 1LL;
    // cout << "e" << endl;
    dp1[0][1] = N[0] - '0' - 1;
    // cout << dp1[0][1] << endl;
    dp2[0][1] = 1;
    dp2[0][0] = 0;
    for(int i = 1; i < keta; i++) {
        for(int j = 0; j <= K; j++) {
            // jは0出ない数
            if(j == 0) {
                dp1[i][j] = dp1[i - 1][j];
            } else {
                dp1[i][j] = 9 * dp1[i - 1][j - 1] + dp1[i - 1][j];
                if(N[i] != '0') {
                    dp1[i][j] +=
                        (N[i] - '0' - 1) * dp2[i - 1][j - 1] + dp2[i - 1][j];
                }
                if(j != 0) {
                    if(N[i] == '0') {
                        dp2[i][j] = dp2[i - 1][j];
                    } else {
                        dp2[i][j] = dp2[i - 1][j - 1];
                    }
                }
            }
        }
    }
    // cout << dp2[keta - 1][K] << " : " << dp1[keta - 1][K] << endl;
    cout << dp2[keta - 1][K] + dp1[keta - 1][K] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 n;
  std::cin >> n;

  std::vector<i64> a(n);

  rep(i, 0, n) {
    std::string s;
    std::cin >> s;

    bool de = false;
    i64 cnt = 0;
    for (const auto& e : s) {
      if (de) cnt++;
      if (e == '.') de = true;
    }
    size_t c;
    while ((c = s.find_first_of(".")) != std::string::npos) {
      s.erase(c, 1);
    }
    a[i] = std::stol(s) * mypow(10l, 9 - cnt);
  }

  using P=std::pair<i64,i64>;

  std::vector<P> factor(n,{0,0});

  rep(i,0,n){
    while(a[i]%2==0){
      factor[i].first++;
      a[i]/=2;
    }
    while(a[i]%5==0){
      factor[i].second++;
      a[i]/=5;
    }
  }

  rep(i,0,n)debug(factor[i]);

  std::vector<std::vector<i64>> sum(200,std::vector<i64>(200,0));

  rep(i,0,n)sum[factor[i].first][factor[i].second]++;

  for(i64 i=198;i>=0;i--){
    for(i64 j=198;j>=0;j--){
      sum[i][j]+=sum[i+1][j]+sum[i][j+1]-sum[i+1][j+1];
    }
  }

  i64 ans=0;

  rep(i,0,n){
    if(factor[i].first*2 >= 18&&factor[i].second*2>=18)ans--;
    ans+=sum[std::max(0l,18-factor[i].first)][std::max(0l,18-factor[i].second)];
  }

  std::cout<<ans/2<<"\n";

  return 0;
}

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

int main(void){
    int n;
    cin>>n;
    vector<string> s(n);
    map<string, int> mp;
    bool ng = false;
    rep(i,n){
        cin>>s[i];
        mp[s[i]]++;
        if (mp[s[i]] == 2) {
            ng = true;
        }
    }
    for (int i = 1; i < n; i++){
        if (s[i-1][(int)s[i-1].size()-1] != s[i][0]){
            ng = true;
        }
    }
    cout<<((!ng) ? "Yes" : "No")<<endl;
    return 0;
}


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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

map<int,int> t;
int main(){
    int n,m,ai,bi;
    cin>>n>>m;
    rep(i,m){
        cin>>ai>>bi;
        ++t[ai],++t[bi];
    }
    for(auto it:t){
        if(it.second%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

const int MAX_N = 1e5;
ll a[MAX_N+5];

int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];

    sort(a, a+n);

    ll ans1 = 0, ans2 = 0;
    for(int i=0;i<n/2-1;i++){
        ans1 += 2 * a[n-i-1] - 2 * a[i];
        ans2 += 2 * a[n-i-1] - 2 * a[i];
    }

    if(n%2){
        ans1 += a[n/2] + a[n/2+1] - 2 * a[n/2-1];
        ans2 += 2 * a[n-n/2] - a[n/2-1] - a[n/2];
    }else{
        ans1 += a[n/2] - a[n/2-1];
        ans2 += a[n/2] - a[n/2-1];
    }

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

Measured memory_bytes: 1024
N, L = map(int, input().split())

curr_min = float('inf')
curr_sum = 0
for i in range(1, N + 1):
    curr_flavour = L + i - 1
    curr_sum += curr_flavour
    if curr_min >= 0:
        curr_min = min(curr_min, curr_flavour)
    else:
        curr_min = max(curr_min, curr_flavour)
print(curr_sum - curr_min)

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<ll> H(N);
  for(int i=0;i<N;i++) std::cin >> H[i];
  int ans = 0, count=0;
  for(int i=N-2;i>=0;i--){
    if(H[i]>=H[i+1]) count++;
    else count = 0;
    ans = max(ans, count);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d,e=0,f=0,j,i;
cin>>a;
vector<ll>v;
for(i=1;i<=a;i++)
{
cin>>b;v.push_back(b);
}
sort(v.begin(),v.end());
for(i=a-1,j=1;i>=0;i--,j++)
{
if(j%2==1)e+=v[i];
else f+=v[i];
}
    cout<<e-f<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
	int n;
    int a[50],max, min, mpoint;
    int count=0;
    bool flag = true;
    unsigned int ans=0;

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

    for(int i=0;i<n-1;i++){
       	max = 0;
        min = 1000000;
        for(int j=i+1;j<n;j++){
            if(min>a[j]){
                min = a[j];
                mpoint = j;
            }
        }

         if(a[i]>min){
            if(flag){
                a[i] = a[i] + a[mpoint];
                a[mpoint] = a[i] - a[mpoint];
                a[i] = a[i] - a[mpoint];
              	i -= 1;
                flag = false;
            }else{
                cout << "NO" << endl;                   
                return 0;
            }    
        }
    }
    
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N];
		int max = 0;
		int index = 0;
		
		for(int i = 0; i < N; i++) {
			A[i] = stdIn.nextInt();
			if(A[i] > max) {
				max = A[i];
				index = i;
			}
		}
		
		Arrays.sort(A);
		int max2 = A[N-2];
		
		for(int i = 0; i < N; i++) {
			if(i == index) {
				System.out.println(max2);
			}
			else {
				System.out.println(max);
			}
		}

	}

}

Measured memory_bytes: 93996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    int x = 0;
    rep(i,n){
        if(s[i]=='I') x++;
        else x--;
        ans = max(x,ans);
    }
    cout << ans << endl;
    
    
}



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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> L){
    sort(L.begin(), L.end(), std::greater<long long>());

    long long s = 0;
    for (int i = 1; i < L.size(); i++) {
        s += L[i];
    }

    if (s > L[0]) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
import kotlin.math.pow

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var result: Long = 1
    val max = 10.0.pow(18).toLong()

    readLine()!!.split(" ").map(String::toLong).let { numbers ->
        numbers.forEach { number ->
            if (number == 0L) {
                println(0)
                return
            }
        }
        numbers.forEach { number ->
            val tmp = result
            result *= number
            if (number > max || result > max || result / number != tmp) {
                println(-1)
                return
            }
        }
    }
    println(result)
}

Measured memory_bytes: 63232
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

ll n, m;
ll x[101010], y[101010];

int main() {
  cin >> n >> m;
  repe(i, 1, n) { cin >> x[i]; }
  repe(i, 1, m) { cin >> y[i]; }

  ll xsum = 0;
  repe(i, 1, n) {
    ll xx = x[i + 1] - x[i];
    xsum += xx * i * (n - i) % MOD;
    xsum %= MOD;
  }

  ll ysum = 0;
  repe(i, 1, m) {
    ll yy = y[i + 1] - y[i];
    ysum += yy * i * (m - i) % MOD;
    ysum %= MOD;
  }

  cout << xsum * ysum % MOD;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

#define INF INT32_MAX

int main() {
    int H, W; cin >> H >> W;
    int Ch, Cw; cin >> Ch >> Cw;
    Ch--, Cw--;
    int Dh, Dw; cin >> Dh >> Dw;
    Dh--, Dw--;
    vector<string> G(H);
    rep(i,H) {
        cin >> G.at(i);
    }
    G[Ch][Cw] = '.'; G[Dh][Dw] = '.';
    vector<vector<int>> V(H, vector<int>(W,INF));

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

    int mi = INF;
    using triple = tuple<int, int ,int>;
    deque<triple> Q;
    Q.emplace_front(make_tuple(Cw,Ch,0));
    while (!Q.empty()) {
        auto [x, y, cnt] = Q.front(); Q.pop_front();
        if (x == Dw && y == Dh) {
            if (mi > cnt) mi = cnt;
            continue;
        }

        rep(i,4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= W) continue;
            if (ny < 0 || ny >= H) continue;
            char c = G[ny][nx];
            if (c == '.' && cnt < V[ny][nx]) {
                Q.push_front(make_tuple(nx, ny, cnt));
                V[ny][nx] = cnt;
            }
        }

        for (int dx = -2; dx <= 2; dx++) {
            for (int dy = -2; dy <= 2; dy++) {
                if (dx == 0 && dy == 0) continue;
                int nx = x + dx;
                int ny = y + dy;
                if (nx < 0 || nx >= W) continue;
                if (ny < 0 || ny >= H) continue;
                char c = G[ny][nx];
                if (c == '.' && V[ny][nx] > cnt + 1) {
                    Q.push_back(make_tuple(nx, ny, cnt+1));
                    V[ny][nx] = cnt + 1;
                }
            }
        }
    }
    if (mi == INF) {
        cout << -1 << endl;
    } else {
        cout << mi << endl;
    }
}


Measured memory_bytes: 9544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
		// 文字列の入力
		String s = sc.next();
      byte[] asciiCodes;
        asciiCodes = s.getBytes();
      int b = 'Z';
      for (int i = 0; i < asciiCodes.length; i++) {
      	asciiCodes[i] += a;
        if (asciiCodes[i] > b) {
          asciiCodes[i] -= 26;
        }
      }
      String resultString = new String(asciiCodes);
      // 出力
		System.out.println(resultString);
      
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+5;
const int M = 5e+5+10;
const int INF = 1e+9;

int f[N][2];
int n;
int lef[N],rig[N],a[N];
bool ans;
int g0[M],g1[M],G0[M],G1[M];

void add(int v0,int v1){
	fo(i,v0,5000)G0[i]=min(G0[i],g0[i-v0]+v1);
	fo(i,v1,5000)G1[i]=min(G1[i],g1[i-v1]+v0);
}

void dfs(int x){
	for(int y=lef[x];y;y=rig[y])dfs(y);
	fo(i,0,5000)g0[i]=g1[i]=0;
	for(int y=lef[x];y;y=rig[y]){
		fo(i,0,5000)G0[i]=G1[i]=INF;
		if(f[y][0]<INF)add(a[y],f[y][0]);
		if(f[y][1]<INF)add(f[y][1],a[y]);
		fo(i,1,5000)G0[i]=min(G0[i],G0[i-1]),G1[i]=min(G1[i],G1[i-1]);
		fo(i,0,5000)g0[i]=G0[i],g1[i]=G1[i];
	}
	f[x][0]=g0[a[x]];
	f[x][1]=g1[a[x]];
	if(f[x][0]==INF&&f[x][1]==INF)ans=0;
}

int main(){
	n=get();
	fo(i,2,n){
		int x=get();
		rig[i]=lef[x];
		lef[x]=i;
	}
	fo(i,1,n)a[i]=get();
	ans=1;
	dfs(1);
	if (ans)printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 6528
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let h:usize = read();
    let w:usize = read();
    let grid:Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect::<Vec<char>>()).collect();
    let mut row = vec![false; h];
    let mut column = vec![false; w];
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '#' {
                row[i] = true;
                column[j] = true;
            }
        }
    }
    for i in 0..h {
        if row[i] {
            for j in 0..w {
                if column[j] {
                    print!("{}", grid[i][j]);
                }
            }
            println!("");
        }
    }
}


Measured memory_bytes: 2216