akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static long gcd(long p,long q){
        if(q==0)
            return p;
        long r=p%q;
        return gcd(q,r);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int m=sc.nextInt();
        long n=sc.nextLong();
        int a[]=new int[m+1];
        long all=1;
        for(int i=0;i<m;i++) {
            a[i] = sc.nextInt();
            all = all*a[i]/Main.gcd(all, a[i]);
        }
        all=all*a[m-1]/Main.gcd(all, a[m-1]);
        int flag=0;
        for(int i=0;i<m;i++){
            if(all/a[i]%2==0) {
                System.out.print("0");
                break;
            }else
                flag++;
        }
        if(flag==m)
            System.out.print((2*n/all+1)/2);
    }
}


Measured memory_bytes: 51528
# -*- encoding: utf-8 -*-
import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

# st = Counter(raw_input())


ct = list(Counter(raw_input().rstrip()).values())
if ct == [2,2]:
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 21236
#![allow(unused_imports)]
use num::Integer;
use proconio::*;
use std::collections::VecDeque;
use std::ops::*;

fn main() {
   input! {
      n: usize
   }
   let ans = (1..=n).map(|x| x as i64).fold(0, |sum, a| {
      if a % 3 == 0 || a % 5 == 0 {
         sum
      } else {
         a + sum
      }
   });
   println!("{}", ans);
}


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

using namespace std;

char alfa(int a);

int main(void){
  long long in = 0;
  cin >> in;
  char b[100];
  int i=0;
  while(in != 0){
    in--;
    b[i] = char('a'+ in%26);
    i++;
    in /= 26;
  }
  i--;
  do{
    cout << b[i];
    i--;
  }while(i >= 0);
  cout << endl;
  return 0;
}


Measured memory_bytes: 3632
import numpy as np


a, b, x = [int(str) for str in input().strip().split()]

if x < a * a * b / 2:
    print(np.rad2deg(np.arctan(a * b * b / x / 2)))
else:
    print(np.rad2deg(np.arctan(2 * (a * a * b - x) / (a ** 3))))

Measured memory_bytes: 20548
#include <iostream>
using namespace std;
 
int main(){
    int c = 0, h = 0;
    int s1, s2, t;
    char a, b;
    while(cin >> s1 >> a >> s2 >> b >> t)
   {
        if(((s1 * s1) + (s2 * s2)) == t * t) c++;
        if(s1 == s2) h++;
    }
    cout << c << endl;
    cout << h << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k, q;
  cin >> n >> k >> q;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  int ans = 2e9;
  for (int i = 0; i < n; i++) {
    int now = a.at(i), it = 0;
    vector<vector<int>> G(n);
    for (int j = 0; j < n; j++) {
      if (a.at(j) >= now) G[it].emplace_back(a.at(j));
      else if (G[it].size() != 0) it++;
    }
    vector<int> keep;
    for (int j = 0; j <= it; j++) {
      sort(G[j].begin(), G[j].end());
      for (int ii = 0; ii + k <= G[j].size(); ii++) {
        keep.emplace_back(G[j][ii]);
      }
    }
    sort(keep.begin(), keep.end());
    if (keep.size() >= q) ans = min(ans, keep[q - 1] - keep[0]);
  }
  
  cout << ans << '\n';
}

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

long long int N, M, ans = 0;
int pos[] = {-1, 0, 1};

main()
{
    cin >> N >> M;
    if (N > 1 && M > 1) {
        ans = N * M - (2 * N + 2 * M -4);
    } else if (N == 1 && M == 1) {
        ans = 1;
    } else {
        ans = N * M -2;
    }
    cout << ans << endl;
}

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

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

ll powmod(long long a, long long n, long long p) {
    if (n == 0) return 1; // 0乗にも対応する場合
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * powmod(a, n - 1, p)) % p;
    long long t = powmod(a, n / 2, p);
    return (t * t) % p;
}

map< ll, int > prime_factor(ll n) {
    map< ll, int > ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

ll comb(ll k, ll n) {
    ll ans = 1;
    if (k - n < n)return comb(k, k - n);
    ll ansMul = 1, ansDiv = 1;
    rep(i, n) {
        ansMul *= (k - i);
        ansDiv *= (i + 1);
        ansMul %= mod;
        ansDiv %= mod;
    }
    ans = ansMul * powmod(ansDiv, mod - 2LL,mod);
    ans %= mod;
    return ans;
}

int main() {
	ll n, m,ans=1;
	cin >> n >> m;
    map<ll, int>mp = prime_factor(m);
    for (auto p : mp) {
        ans *= comb(n + p.second - 1, p.second);
        ans %= mod;
    }
    cout << ans % mod << endl;
	return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int total=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    total+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(vec.at(n-1)<total-vec.at(n-1)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3596
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

ll int w[200],v[200];

ll int dp[N][200];

ll int solve(ll int weight,ll int idx)
{
	if(dp[weight][idx]!=-1) return dp[weight][idx];
	if(idx==1)
	{
		ll int ret;
		if(w[idx]<=weight) ret=v[idx];
		else ret=0;
		return dp[weight][idx]=ret;
	}
	ll int ret;
	if(w[idx]>=weight)
	{
		ret=0;
		return dp[weight][idx]=ret;
	} 
	ll int maxi=0;
	for(ll int i=idx-1;i>=1;i--)
	{
		maxi=max(maxi,solve(weight-w[idx],i));
	}
	maxi+=v[idx];
	return dp[weight][idx]=maxi;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,W;
		cin>>n>>W;
		for(ll int i=1;i<=n;i++)
		{
			cin>>w[i]>>v[i];
		}
		memset(dp,-1,sizeof(dp));
		ll int maxi=0;
		for(ll int i=1;i<=n;i++)
		{
			maxi=max(maxi,solve(W,i));
		}
		cout<<maxi;
	}
	return 0;
}

Measured memory_bytes: 156544
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int A,B,C,K; cin>>A>>B>>C>>K;
	while(A>=B) K--, B*=2;
	while(B>=C) K--, C*=2;
	cout<<(K>=0 ? "Yes" : "No")<<"\n";
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

struct Node {
	char str[4];
	double mon;
};

int main(void) {
	struct Node Nk[10];
	int n;
	double sam = 0;

	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%lf %s", &Nk[i].mon, &Nk[i].str);
	}

	for (int i = 0; i < n; i++) {
		if (Nk[i].str[0] == 'J') {
			sam += Nk[i].mon;
		}
		else {
			sam += 380000.0 * Nk[i].mon;
		}
	}

	printf("%lf\n", sam);


	return 0;
}

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

int main() {
    int k;
    cin >> k;
    string s, ans;
    cin >> s;

    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout <<  s.substr(0, k) + "..." << endl;
    }

    return 0;
}

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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 n = read::<usize>();
    let mut candidate = vec![1];
    {
        let mut v9 = 1;
        for i in 0..20 {
            v9 *= 9;
            if v9 > n {
                break;
            }
            candidate.push(v9);
        }
        let mut v6 = 1;
        for j in 0..20 {
            v6 *= 6;
            if v6 > n {
                break;
            }
            candidate.push(v6);
        }
    }
    let mut ans = n;
    let mut dp = vec![1 << 20; n + 1];
    dp[0] = 0;
    for i in 0..n + 1 {
        for &v in candidate.iter() {
            let nv = v + i;
            if nv > n {
                continue;
            }
            dp[nv] = std::cmp::min(dp[nv], dp[i] + 1);
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 4352
N = int(input())
a = [int(x) for x in input().split()]

color_dict = [0 for x in range(9)] # d[8]

for c in a :
    if c in range(1, 400) : color_dict[0] = 1
    elif c in range(400, 800) : color_dict[1] = 1
    elif c in range(800, 1200) : color_dict[2] = 1
    elif c in range(1200, 1600) : color_dict[3] = 1
    elif c in range(1600, 2000) : color_dict[4] = 1
    elif c in range(2000, 2400) : color_dict[5] = 1
    elif c in range(2400, 2800) : color_dict[6] = 1
    elif c in range(2800, 3200) : color_dict[7] = 1
    elif c >= 3200 : color_dict[8] += 1
        
tot = sum(color_dict)
rainbow = color_dict[8]

if tot > rainbow :
    print(tot - rainbow, tot)
elif tot - rainbow <= rainbow :
    print(tot - rainbow + 1, tot)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    int ab = 0, a = 0, b = 0, ba = 0;
    for (int i = 0; i < n; i++)
    {
        int sz = s[i].size();
        for (int c = 0; c < sz - 1; c++)
        {
            if (s[i][c] == 'A' && s[i][c + 1] == 'B')
            {
                ab++;
            }
        }
        if (s[i][0] == 'B')
        {
            if (s[i][sz - 1] == 'A')
            {
                ba++;
            }
            b++;
        }
        if (s[i][sz - 1] == 'A')
        {
            a++;
        }
    }
    int tmp = min(a, b);
    if (ba == a && ba == b && (ba > 0 || b > 0 || a > 0))
    {
        tmp--;
    }
    cout << ab + tmp << endl;
}

Measured memory_bytes: 768
data = input().split()

a,b,c = int(data[0]), int(data[1]), int(data[2])

for i in range (a, min(b+1,a + c)):
    if (i < a + c or i > b - c):
        print(i)

for j in range (max(i + 1, b - c + 1), b + 1):
    if (j < a + c or j > b - c):
        print(j)


Measured memory_bytes: 3060
n,m=map(int,input().split())
keys=[None]*m
dp=[-1]*(2**n)
dp[0]=0
for i in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  cond=0
  for j in c:
    cond+=2**(j-1)
  keys[i]=[a,cond]
for key in keys:
  for sta in range(2**n):
    if dp[sta]==-1:continue
    if dp[sta|key[1]]==-1:
      dp[sta|key[1]]=key[0]+dp[sta]
    else:
      dp[sta|key[1]]=min(dp[sta|key[1]],dp[sta]+key[0])
print(dp[-1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
       long long n,m;
       cin>>n>>m;
       int a[m];
       for(long long i=0;i<m;i++) {
           cin>>a[i];
       }
       long long sum = 0;
       for(long long i = 0;i<m;i++) {
           sum +=a[i];
       }
       if(sum > n) {
           cout<<-1;
       }
       else {
           cout<<n-sum;
       }
    return 0;
}


Measured memory_bytes: 3668
/*	ex6_2
	suzuto	*/

#include <stdio.h>
#include <string.h>
#define  LIMIT 100


int main(void) {
  char str_array[LIMIT]; /*変数の宣言*/
  int count, length;

  scanf("%s", &str_array); /*文字列を入力*/
  length = strlen(str_array); /*文字列の長さを算出*/
  count = length - 2; /*文字列全体 - (最初 + 最後) = 中の文字*/
  printf("%c%d%c\n", str_array[0], count, str_array[length - 1]);/*答えの出力*/
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
b = a[0]
m = abs(s - 2 * b)
for i in range(1, n - 1):
    b += a[i]
    m = min(m, abs(s - 2 * b))
print(m)


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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;

  int counter = 0;
  while (1) {
    int w_pos = (int)s.find_first_of('W');
    int r_pos = (int)s.find_last_of('R');

    if (w_pos == (int)string::npos || r_pos == (int)string::npos) {
      break;
    }

    if (w_pos < r_pos) {
      swap(s.at(w_pos), s.at(r_pos));
      counter++;
    } else {
      break;
    }
  }

  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 3748
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),
  fast;
	ll n ;
	cin>> n ;
	ll ans = n*n*n;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int k = sc.nextInt();
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < k; i++) {
                set.add(Math.min(b, a + i));
                set.add(Math.max(a, b - i));
            }
            List<Integer> list = new ArrayList<>(set);
            Collections.sort(list);
            for (int i : list) {
                System.out.println(i);
            }
        }
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(){
  int a,b=0,c=0;
  scanf("%d",&a);
  int d[a];
  for(int i=0; i<a; i++){scanf("%d",&d[i]);}
  for(int i=a-1; 0<i; i--){
    for(int j=0; j<i; j++){
      if(d[j]<d[j+1]){
        int e=d[j];
        d[j]=d[j+1];
        d[j+1]=e;
      }
    }
  }
  for(int i=0; i<a; i++){
    if(i%2){c+=d[i];}else{b+=d[i];}
  }
  printf("%d",b-c);
  return 0;}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

typedef pair<int,int> pii;
const int INF =  1000000000;

int par[10000],rnk[10000];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rnk[i] = 1;
  }
}
int find(int x){
  if(par[x]==x) return x;
  else return par[x] = find(par[x]);
}
bool same(int x,int y){
  return find(x)==find(y);
}
void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(rnk[x]>rnk[y]) par[y] = x;
  else{
    par[x] = y;
    if(rnk[x]==rnk[y]) rnk[y]++;
  }
  return;
}

int main(){
  int V,E;
  vector<pair<int,pii> > es;
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int s,t,w;
    scanf("%d %d %d",&s,&t,&w);
    es.push_back(make_pair(w,pii(s,t)));
  }
  int ans = 0;
  int cost[10000];
  fill(cost,cost+V,INF);
  sort(es.begin(),es.end());
  cost[0] = 0;
  init(V);
  for(int i=0;i<es.size();i++){
    if(!same(es[i].second.first,es[i].second.second)){
      ans += es[i].first;
      unite(es[i].second.first,es[i].second.second);
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 4032
def main():
    a, b = [int(x) for x in input().split()]
    a = 14 if a == 1 else a
    b = 14 if b == 1 else b
    if a > b:
        print("Alice")
    elif b > a:
        print("Bob")
    else:
        print("Draw")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,Ma,Mb,K=0,C[45];
ll A,B[1005]={};
ll T,a,b,c,d;
ll ans=1;
bool h,o;
//bool D[100005];
string str,str2[55][55];
map<string,int> m;
vector<int> v[10];
ll dp[45][405][405];
int main(){
	cin>>N;
	for(int i=2;i<=N;++i){
		int s=i;
		for(int j=2;j<=i;++j){
			if(s==1)break;
			while(1){
				if(s%j==0){
					s/=j;
					B[j]++;
				}else break;
			}
		}
	}
	for(int i=0;i<1005;++i){
		ans=(ans*(B[i]+1))%1000000007;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct arry{
  int a;
  int b;
};
bool cmp(const arry &a, const arry &b){
    return a.a < b.a;
}
int main(){
  long N,K,j;
  cin >> N >> K;
  struct arry arr[N];
  for(int i=0; i<N; i++) cin >> arr[i].a >> arr[i].b;
  sort(arr, arr+N, cmp);
  for(j=0; j<N; j++){
    K -= arr[j].b;
    if(K<1) break;
  }
  cout << arr[j].a << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int a[100010] = {};
	for (int n, k; cin >> n >> k&&n;) {
		rep(i, 0, n) {
			cin >> a[i];
		}
		int ans, sum;
		ans = sum = accumulate(a, a + k, 0);
		rep(i, k, n) {
			sum = sum + a[i] - a[i - k];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3404
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 00:21:28 2020

@author: shinba
"""

n,x = map(int,input().split())

L = list(map(int,input().split()))

i = 0
ans = 1

for j in range(n):
    i += L[j]
    if i <= x:
        ans += 1
        continue
    else:
        break

print(ans)


 


Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();

    char[][] arr = new char[h][w];

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

    int ans = Integer.MAX_VALUE;

    int[][] visit = new int[h][w];

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

    void run() {
        for (int i=0; i<h; i++) {
            arr[i] = sc.next().toCharArray();
        }

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                visit[i][j] = Integer.MAX_VALUE;
            }
        }

        dfs(0, 0, 0);

        PrintWriter out = new PrintWriter(System.out);
        if (arr[0][0]=='#') {
            out.print(ans+1);
        } else {
            out.print(ans);
        }
        out.flush();

    }

    int dfs(int y, int x, int cnt) {
        if (y==h-1 && x==w-1) {
            ans = Math.min(ans, cnt);
        }

        visit[y][x] = cnt;
        char c = arr[y][x];

        if (c=='.') {
            for (int i=0; i<2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 <= nx && nx < w && 0 <= ny && ny < h) {
                    if (arr[ny][nx] == '.') {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    } else {
                        if (cnt+1<visit[ny][nx]) dfs(ny, nx, cnt + 1);
                    }
                }
            }
        } else {
            for (int i=0; i<2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];


                if (0 <= nx && nx < w && 0 <= ny && ny < h) {
                    if (arr[ny][nx] == '.') {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    } else {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    }
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 25556
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
map<ll,int>ma;
vvi in;
int main(){
	int n;
	cin>>n;
	in=vvi(n);
	rep(i,n){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		in[i]=vi{a,b,c};
		ma[a*1000000001ll+b]=c;
	}
	ll a=0,b=1,sum,sx,sy,gx,gy,area,gc_d=1;
	rep(q,n){
		loop(x,-4,5)loop(y,-4,5)if(x!=0&&y!=0){
			sum=0;
			sx=min(in[q][0],in[q][0]+x);
			gx=max(in[q][0],in[q][0]+x);
			sy=min(in[q][1],in[q][1]+y);
			gy=max(in[q][1],in[q][1]+y);
			loop(i,sx,gx+1)loop(j,sy,gy+1)if(ma.count(i*1000000001ll+j))sum+=ma[i*1000000001ll+j];
			area=abs(x*y);
			gc_d=gcd(sum,area);
			sum/=gc_d;
			area/=gc_d;
			if(a*area<b*sum){
				a=sum;
				b=area;
			}
		}
	}
	cout<<a<<" / "<<b<<endl;
}

Measured memory_bytes: 14500
tmp = readline()
#println("Input: ",split(tmp))
#println("Input: ",length(split(tmp)))
A=split(tmp)[1]
B=split(tmp)[2]

#println("Input: $A, $B")
#println("typeof each args... ",typeof(A))

c=parse(BigInt,A)*parse(BigFloat,B)
#c=parse(Int128,A)*parse(Float64,B)
#println("C: $c")
ans=(trunc(BigInt,c))
#println("Answer: $ans [min]")
println(ans)

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a-c)*(a-c) <= d*d || (max((a-b)*(a-b),(b-c)*(b-c)) <= d*d)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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


int main()
{
   ll n,m,k,i,j,x,l,a,b,c,d;
  
   cin>>a>>b>>c>>d;

    x=__gcd(c,d);
   ll tmp=c*d/x;
   cout<<((b-a+1)-((b/c)-(a-1)/c)-((b/d)-(a-1)/d)+((b/tmp)-(a-1)/tmp));
}  


Measured memory_bytes: 384
#include <iostream>
#define Nmax 100005
#define ll long long
using namespace std;

int main()
{
    ll n, k, dp[Nmax], h[Nmax];

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
        dp[i] = 1000000009;
    }


    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        for (int j = i - 1; j > 0 && i - j <= k; --j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1792
#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 MOD 1000000007

typedef long long int ll;

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


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

  vector<double> p(N+1);
  REP(i,N)cin >> p[i+1];

  vector<vector<double>> dp(N+1, vector<double>(N+1,0));
  dp[0][0]=1.0;
  FOR(i,1,N+1){
    REP(j,i){
      dp[i][j] += dp[i-1][j] * (1-p[i]);
      dp[i][j+1] += dp[i-1][j] * p[i];
    }
  }

  double ans=0;
  FOR(i,N/2+1, N+1){
    ans += dp[N][i];
  }

  printf("%.10f\n", ans);
}



Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;

int main()
{
  vector<int> a(3);
  for (auto &e : a)
    cin >> e;
  sort(a.begin(), a.end());
  cout << a[1] - a[0] + a[2] - a[1] << endl;

  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def solve(N):
	if N == 0:
		return 0
	if N == 1:
		return D

	if memo[N]:
		return memo[N]

	ret = N*D
	
	up = 2*(-(-N//2))
	down = 2*(N//2)
	ret = min(ret, D*(up-N)+A+solve(up//2))
	ret = min(ret, D*(N-down)+A+solve(down//2))

	up = 3*(-(-N//3))
	down = 3*(N//3)
	
	ret = min(ret, D*(up-N)+B+solve(up//3))
	ret = min(ret, D*(N-down)+B+solve(down//3))

	up = 5*(-(-N//5))
	down = 5*(N//5)
	ret = min(ret, D*(up-N)+C+solve(up//5))
	ret = min(ret, D*(N-down)+C+solve(down//5))

	memo[N] = ret
	return ret

T = INT()
ans = []
for _ in range(T):
	N, A, B, C, D = MAP()
	memo = defaultdict(int)
	ans.append(solve(N))
print(*ans, sep="\n")


Measured memory_bytes: 12608
#include <bits/stdc++.h>
using namespace std;
const int mod = 924844033, maxn = 4345;
int mul(long long a, long long b){
	return a * b % mod;
}
int fat[maxn], n, k, u[maxn], sz[maxn], cs[maxn];
void init(){
	iota(u, u + maxn, 0);
	memset(sz, 0, sizeof(sz));
	memset(cs, 0, sizeof(cs));
}
int find(int x){
	if(x == u[x]) return x;
	return u[x] = find(u[x]);
}
void join(int x, int y){
	u[find(x)] = find(y);
}
int ways[maxn][maxn];
int solve(int nodes, int match){
	if(match == 0) return 1;
	if(nodes <= 1) return 0;
	if(~ways[nodes][match]) return ways[nodes][match];
	int ans = 0;
	ans += solve(nodes - 2, match - 1);
	ans += solve(nodes - 1, match);
	if(ans >= mod) ans -= mod;
	return ways[nodes][match] = ans;
}
int main(){
	fat[0] = 1;
	for(int i = 1; i < maxn; i++) fat[i] = mul(fat[i - 1], i);
	cin >> n >> k;
	init();
	for(int i = 1; i <= n; i++){
		if(i - k >= 1) join(i, i - k + n);
		if(i + k <= n) join(i, i + k + n);
	}
	for(int i = 1; i <= n; i++){
		sz[find(i)]++;
		sz[find(i+n)]++;
		cs[find(i+n)]++;
	}
	memset(ways, -1, sizeof(ways));
	vector<int> roots;
	for(int i = 1; i <= n; i++){
		roots.push_back(find(i));
		roots.push_back(find(i+n));
	}
	sort(roots.begin(), roots.end());
	roots.erase(unique(roots.begin(), roots.end()), roots.end());
	vector<int> dp(n + 1), ndp(n + 1);
	dp[0] = 1;
	for(int root : roots){
		fill(ndp.begin(), ndp.end(), 0);
		int tot = sz[root] / 2;
		for(int i = 0; i <= tot; i++){
			for(int j = 0; j+i <= n; j++){
				ndp[j + i] += mul(solve(sz[root], i), dp[j]);
				if(ndp[j + i] >= mod) ndp[j + i] -= mod;	
			}	
		}
		dp = ndp;
	}
	int ans = 0;
	for(int i = 0; i <= n; i++){
		if(i&1){
			ans += mod - mul(dp[i], fat[n - i]);
		} else {
			ans += mul(dp[i], fat[n - i]);
		}
		if(ans >= mod) ans -= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 74112
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;

const int N=2e5+10,Inf=1e9+10,Mod=1e9+7;

struct Node
{
	int x,v,l,r;
	bool operator < ( const Node &A ) const { return r<A.r || (r==A.r && l<A.l); }
}P[N];
int n,f[N],sum[N];

bool cmpv(const Node &A,const Node &B) { return A.v<B.v; }
bool cmpx(const Node &A,const Node &B) { return A.x<B.x; }

void Init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d",&P[i].x,&P[i].v);
	sort(P+1,P+n+1,cmpv);
	for (int i=1;i<=n;++i) P[i].v=i;
	sort(P+1,P+n+1,cmpx);
	for (int i=1;i<=n;++i) P[i].x=i;
}

void Solve()
{
	int Mn=Inf;
	for (int i=n;i>=1;--i) 
	{
		Mn=min(Mn,P[i].v);
		P[i].l=Mn;
	}
	int Mx=-Inf;
	for (int i=1;i<=n;++i)
	{
		Mx=max(Mx,P[i].v);
		P[i].r=Mx;
	}
	sort(P+1,P+n+1);int p=1;
	f[0]=1;sum[0]=1;
	for (int i=1;i<=n;++i)
	{
		for (;P[p].r==i && p<=n;++p)
			f[i]=(0ll+f[i]+f[i]+sum[i-1]-sum[P[p].l-1]+f[P[p].l-1]+Mod)%Mod;
		sum[i]=(sum[i-1]+f[i])%Mod;
	}
	printf("%d\n",f[n]);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 4864
/*************************
author : coldbeer
2019-05-21 11:38:06 AM IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

string str;

int get_2_digit(int idx){
	int sum = 0;
	sum += (10 * (str[idx] - '0') + (str[idx + 1] - '0'));
	return sum;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> str;
	int a = get_2_digit(0),b = get_2_digit(2);
	if(a > 0 && b > 0 && a <= 12 && b <= 12)
		cout << "AMBIGUOUS" << endl;
	else if(a > 0 && a <= 12)
		cout << "MMYY" << endl;
	else if(b > 0 && b <= 12)
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int c[3][3],buf;
    bool flag = true;

    REPI(3){
        REPJ(3){
            scanf("%d",&c[i][j]);
        }
    }

    for(int i=1;i<3;i++){
        buf = c[i][0] - c[0][0];
        for(int j=1;j<3;j++){
            if((c[i][j] - c[0][j]) != buf)
                flag = false;
        }
    }
    
    for(int i=1;i<3;i++){
        buf = c[0][i] - c[0][0];
        for(int j=1;j<3;j++){
            if((c[j][i] - c[j][0]) != buf)
                flag = false;
        }
    }
    
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");


    return 0;
}


Measured memory_bytes: 256
import sys

mod = 10**9 + 7

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []
 
if M == 0:
    print(fibo(N) % mod)
    sys.exit()
 
for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1
 
for i, k in enumerate(a):
    if i == 0:
        pattern *= fibo(k-1)
    else:
        if i > 0:
            pattern *= fibo(a[i]-a[i-1]-2)
        
pattern *= fibo(N-a[-1]-1)
print(pattern % mod)

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
typedef long double ld;
#define maxn 1001

int N, A[maxn];

int32_t main()
{
	cin>>N;
	
	FOR(i,1,N) cin>>A[i];
	
	sort(A+1,A+N+1);
	
	ld cur = ld(A[1] + A[2]) / ld(2);
	
	FOR(i,3,N){
		cur = (cur + A[i]) / 2;
		
		
	}
	cout<<cur;
}


Measured memory_bytes: 3788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << setprecision(20) << fixed << 1.0 * w * h / 2 << " ";
  if (x * 2 == w && y * 2 == h) cout << 1 << endl;
  else cout << 0 << endl;  
  return 0;
}

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

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

    for(int i=0; i<n; i++){
        if(a[i]%2 == 0){
          if(a[i]%3!=0 && a[i]%5!=0){
              cout << "DENIED";
              return 0;
          }
        }
    }

    cout << "APPROVED";
    return 0;
}


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

int n, pos;
vector<int>pre, in, post;

void rec(int l, int r)
{
	if (l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve()
{
	pos = 0;
	rec(0, pre.size());
	for (int i = 0; i < n; i++)
	{
		if (i)cout << " ";
		cout << post[i];
	}
	cout << endl;
}

int main()
{
	int k;
	cin >>n;
	for (int i = 0; i < n; i++)
	{
		cin >> k;
		pre.push_back(k);
	}

	for (int i = 0; i < n; i++)
	{
		cin >> k;
		in.push_back(k);
	}

	solve();
	return 0;
}


Measured memory_bytes: 3168
using System;

namespace test1
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int ans = 0;
			for (int i = 1; i <= n; i++){
				ans += i;
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 2776
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        long[] values = new long[N];

        for (int i = 0; i < N; i++) {
            values[i] = sc.nextLong();
        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += (values[i] - 1);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25320
program main

  implicit none

  integer    :: n
  integer(8),allocatable :: a(:)
  integer :: i, j 
  
  read(*,*) n
  allocate( a(n) )
  read(*,*) a

  call quicksort1( a, 1, n ) 
  
  j = 0 
  do i = 2, n
    if( a(i) == a(i-1) ) j = j + 1
  end do
  
  if ( j > 0 ) then
    print*, "NO" 
  else
    print*, "YES" 
  end if

end program main

recursive subroutine quicksort1(a, first, last)
  implicit none
  integer(8),intent(inout)::a(*)
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  integer(8)::x,t
  integer::i,j

  x = a((first+last)/2)
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i)
     a(i) = a(j)
     a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1(a, first, i-1)
  if (j+1 < last)  call quicksort1(a, j+1, last)

  return
end subroutine quicksort1


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
const ll MOD = 1000000007;
ll num[28];
int main(){
  int N;
  string s;
  cin >> N >> s;
  for(auto c : s) num[c - 'a']++;
  ll res = 1;
  rep(i,26) {
    res *= num[i] + 1;//それぞれの文字において選択肢はnum+1回
    res %= MOD;
  }
  cout << (res + MOD - 1) % MOD << endl;//空文字ぶん引く
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, char *argv[]){
  int A_num, B_num, C_num, SUM;
  scanf("%d", &A_num);
  scanf("%d", &B_num);
  scanf("%d", &C_num);
  scanf("%d", &SUM);
  SUM /= 50;
  
  int count = 0;
  
  for(int a=0; a<=A_num; a++){
    for(int b=0; b<=B_num; b++){
      for(int c=0; c<=C_num; c++){
        if (10*a+2*b+c == SUM) count++;
      }
    }
  }
  
  printf("%d", count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
int n;
int t[100009];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans=0;
    cin>>n;
    for(int i=1; i<n; i++)
    {
        cin>>t[i];
    }
    ans+=t[1];
    ans+=t[n-1];
    for(int i=2; i<n; i++)
    {
        ans+=(min(t[i-1], t[i]));
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
from collections import deque
flag = 1
s = deque(input())
q = int(input())
for i in range(q):
         z = list(map(str,input().split()))
         if z[0] == "1":
                  flag = flag*(-1)
         else:
                  if (flag == 1 and z[1] == "1")  or (flag == (-1) and z[1] == "2"):
                           s.appendleft(z[2])
                  else:
                           s.append(z[2])
if flag == (-1):
         s.reverse()
ans = "".join(s)
print(ans)


Measured memory_bytes: 8948
#include<stdio.h>
int main()
{

    int n,count=0;
    scanf("%d",&n);
    int v[n],c[n];
    for(int i=0;i<n;i++)
        scanf("%d",&v[i]);
    for(int i=0;i<n;i++)
        scanf("%d",&c[i]);
    for(int i=0;i<n;i++)
    {
        if((v[i]-c[i])>0)
            count+=v[i]-c[i];
    }

    printf("%d",count);
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Runtime.Serialization.Formatters.Binary;

namespace atcorder2
{
    [Serializable]
    static class  Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long Gcd(long x,long y)
        {
            if (x < y) Gcd(y, x);
            while (y > 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long Lcm(long x,long y)
        {
            return x * y / Lcm(x, y);
        }

        public static bool IsLowercaseAlphabet(char target)
        {
            return new Regex("^[a-z]+$").IsMatch(target.ToString());
        }

        public static T DeepCopy<T>(this T src)
        {
            using (var memoryStream = new MemoryStream())
            {
                var binaryFormatter = new BinaryFormatter();
                binaryFormatter.Serialize(memoryStream, src);
                memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
                return (T)binaryFormatter.Deserialize(memoryStream);
            }
        }


        public static bool Prime(long n)
        {
            if (n < 2) return false;
            else if (n == 2) return true;
            else if (n % 2 == 0) return false;

            for (int i = 3; i <=Math.Sqrt(n); i++)
            {
                if (n % i == 0) return false;
            }
            return true;
        }
        


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            
            var q = ReadLine().Split();
            var a = long.Parse(q[0]);
            var b = q[1].Split('.');
            var b1 = long.Parse(b[0]);
            var b2 = long.Parse(b[1]);
           
            WriteLine((a*b1*100+b2*a)/100);
            
            
            
           

           


            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 17716
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

long long MX = 1e18;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += p.at(i);
    }
    cout << sum << endl;

return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
  char moji;
  
  while(1){
      scanf("%c",&moji);
      
      if(moji >= 'A' && moji <= 'Z'){
	moji += 'a'-'A';
	printf("%c",moji);
      }
      
      else if(moji >= 'a' && moji <= 'z'){
	moji -= 'a'-'A';
	printf("%c",moji);
      }
      
      else if(moji != '\n'){
	printf("%c",moji);
      }
      else if(moji == '\n'){
	break;
      }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n,qq;
    cin >> n >> qq;
    vector<vector<int>> e(n+1,vector<int>(0));
    vector<ll> a(n+1,0),ans(n+1);
    vector<int> c(n+1,0);
    rep(i,n-1){
        int f,g;
        cin >> f >> g;
        e.at(f).push_back(g);
        e.at(g).push_back(f);
    }
    rep(i,qq){
        ll f,g;
        cin >> f >> g;
        a.at(f)+=g;
    }
    queue<pair<int,ll>> q;
    q.push(make_pair(1,0));
    while (!q.empty()){
        int f=q.front().first;
        ll g=q.front().second;
        q.pop();
        g+=a.at(f);
        ans.at(f)=g;
        c.at(f)=1;
        rep(i,e.at(f).size()){
            if (c.at(e.at(f).at(i))==0) q.push(make_pair(e.at(f).at(i),g));
        }
    }
    rep(i,n) cout << ans.at(i+1) << endl;
}

Measured memory_bytes: 21620
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<bool> is_leaf(N);
    vector<ll> val(N), deg(N);
    
    vector<ll> A(N);
    for(int i=0; i<N; i++) scanf("%lld", &A[i]);

    vector< vector< pair<int, int> > > G(N);
    for(int i=0; i+1<N; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        G[u].emplace_back(v, i);
        G[v].emplace_back(u, i);
        deg[u]++; deg[v]++;
    }

    if(N == 2) {
        if(A[0] == A[1]) puts("YES");
        else puts("NO");
        return 0;
    }

    for(int i=0; i<N; i++) is_leaf[i] = (deg[i] == 1);

    auto dfs = [&](auto &&self, int cur, int par) -> ll {
        ll sum = 0;
        for(auto e : G[cur]) {
            int to = e.first, k = e.second;
            if(to == par) continue;
            ll v_child = self(self, to, cur);
            val[k] = v_child;
            sum += v_child;
        }
        if(is_leaf[cur]) return A[cur];
        return 2*A[cur] - sum;
    };

    dfs(dfs, 0, -1);
    bool valid = true;
    for(int i=0; i<N; i++) {
        ll sum = 0;
        for(auto e : G[i]) {
            int j = e.first, k = e.second;
            sum += val[k];
            valid &= (val[k] >= 0);
        }

        if(is_leaf[i]) valid &= (sum == A[i]);
        else {
            valid &= (sum == 2*A[i]);
            for(auto e : G[i]) {
                int j = e.first, k = e.second;
                valid &= (2 * val[k] <= sum);
            }
        }
    }
    cout << (valid ? "YES" : "NO") << endl;
    return 0;
}



Measured memory_bytes: 11904
l = list(int(x) for x in input().split())
l.sort(reverse=True)

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
gcd = gcd(l[0],l[1])

def lcm(a,b):
  return a*b//gcd
print(lcm(l[0],l[1]))

Measured memory_bytes: 3060
using System;
class Program
{
	static void Main(string[] args)
	{
			string s = Console.ReadLine();
            int[] list = new int[3];
			list[0] = int.Parse(s.Split(' ')[0]);
			list[1] = int.Parse(s.Split(' ')[1]);
			list[2] = int.Parse(s.Split(' ')[2]);
            bool[] even_list = new bool[3];
            for (int i = 0; i < 3;i++){
				if (list[i] % 2 == 0) even_list[i] = true;
				else even_list[i] = false;   
            }
            int even_num=0;
            foreach (bool b in even_list) if (b == true) even_num++;
            int result=0;
            //奇数が2つの時，2つの奇数を+1して全て偶数へ
            if(even_num==1){
                for (int i = 0; i < 3; i++) if (!even_list[i]) list[i]++;
                result++;
            }
			//奇数が1つの時，2つの偶数を+1して全て奇数へ
			if (even_num == 2){
				for (int i = 0; i < 3; i++) if (even_list[i]) list[i]++;
				result++;
            }
            //これで全て奇数or全て偶数=>最大値との差は必ず２の倍数
            //最大値の探索
            int max=0;
            foreach(int i in list){
                if (max < i) max = i;
            }
            for (int i = 0; i < 3; i++) list[i] = max-list[i];
            int sum = list[0] + list[1] + list[2];
            result += sum / 2;
            Console.WriteLine(result);
	}
}

Measured memory_bytes: 13140
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		if((in.nextInt() * in.nextInt()) % 2 != 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22612
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from numpy import *

N = int(readline())
S = frombuffer(b'-'+readline().rstrip(),'S1')
Q = int(readline())
query = map(int,read().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=int64)
cumM = isM.cumsum(dtype=int64)

for K in query:
    x = cumD.copy(); x[K:] -= cumD[:-K]
    x *= isM
    x[K+1:] -= isD[1:-K] * (cumM[K:-1] - cumM[:-K-1])
    print((x.cumsum() * isC).sum())

Measured memory_bytes: 63960