akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P2;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 998244353;

int const TREE_SIZE = (1 << 20);

class SegTree{
	public:
	// コンストラクタ
	SegTree(std::function<long long int(long long int, long long int)> monoidFunc_, long long int invalidValue_){
		monoidFunc = monoidFunc_;
		invalidValue = invalidValue_;
	}
	// 値の初期化
	void init(long long int initValue){
		for(int i = 0; i < TREE_SIZE; i++){
			segTree[i] = initValue;
		}
	}
	// a番目(0-indexed)をwに変更する O(log N)
	void change(int a, long long int w){
		change_(a + 1, w);
	}
	// 区間 [a, b] (0-indexed)の値を求める O(log N)
	long long int query(int a, int b){
		return query_(a + 1, b + 2, 1, 0, TREE_SIZE / 2);
	}
	private:
	function<long long int(long long int, long long int)> monoidFunc;
	long long int invalidValue;
	long long int segTree[TREE_SIZE]; // 1-indexed

	// a番目をwに変更する O(log N)
	void change_(int a, long long int w){
		a += TREE_SIZE / 2;
		segTree[a] = w;
		for(int x = a / 2; x > 0; x /= 2){
			segTree[x] = monoidFunc(segTree[2 * x], segTree[2 * x + 1]);
		}
	}
	// 区間 [a, b) の値を求める O(log N)
	// query(a, b, 1, 0, TREE_SIZE / 2) のように呼ぶ
	long long int query_(int a, int b, int index, int l, int r){
		if(r <= a || b <= l){
			return invalidValue;
		}
		if(a <= l && r <= b){
			return segTree[index];
		}
		return monoidFunc(query_(a, b, index * 2, l, (l + r) / 2), query_(a, b, index * 2 + 1, (l + r) / 2, r));
	}
};

long long int func(long long int a, long long int b){
	return a + b;
}

SegTree segTree(func, 0);

int main(){
	segTree.init(0);
	int n, q;
	cin >> n >> q;
	for(int i = 0; i < q; i++){
		long long int tp, a, b;
		cin >> tp >> a >> b;
		if(tp == 0){
			long long int res = segTree.query(a, a) + b;
			segTree.change(a, res);
		}else{
			cout << segTree.query(a, b) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 11332
#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie   
    int n ;
    cin >> n ;
    int a[n+1] ;
    int ans = 0 ;
    rep(i, 1, n+1) {
        cin >> a[i] ;
        if(a[i]%2 == 1 && i%2 == 1) ans++ ;
    }
    cout << ans << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



signed main() {
	int n;cin>>n;int ans = 0;
	int a[20], c[20];
	rep(i,n)cin>>a[i];
	rep(i,n){
		int b;cin>>b;ans += b;
	}
	rep(i,n-1)cin>>c[i];
	rep(i,n-1){
		if(a[i]+1 == a[i+1])ans += c[a[i]-1];
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
    std::string txt;
    int m;
    cin >> txt;
    do{
        cin >> m;
        int *h = new int[m];
        for(int i=0;i<m;i++){
            cin >> h[i];
            std::string place = txt;
            place.replace(h[i],place.size()-h[i],"");
            txt.replace(0,h[i],"");
            txt = txt + place;
        }
        std:cout << txt << std::endl;
        cin >> txt;
    }while(txt!="-");
    return 0;
}



Measured memory_bytes: 3148
import numpy as np

W, H, N = map(int, input().split())

c = np.zeros((W, H), int)

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        c[:x, :] = 1
    elif a == 2:
        c[x:, :] = 1
    elif a == 3:
        c[:, :y] = 1
    else:
        c[:, y:] = 1

ans = W * H - np.sum(c)
print(ans)


Measured memory_bytes: 12512
a = [int(input()) for i in range(5)]
b = [g%10 for g in a]
kkk = 9
h = 0
for i in range(len(a)):
    g = a[i] % 10
    if g > 0 and g < kkk:
        kkk = g
        h = i
l = a[h]
a.pop(h)
a.append(l)
total = 0
for i in a:
    if total % 10 != 0:
        total += 10 - (total % 10)
    total += i

print(total)


Measured memory_bytes: 3064
x = int(input())

count = 0
for i in range(0, x):
    a =  int(input())
    for j in range ( 2,  a ):
        c = int(a)
        if a % j == 0:
            count += 1
            break;
        if j * j  > c:
            break;
        
print(x-count)
        



Measured memory_bytes: 5604
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, cnt;
ll mem;
priority_queue<ll, vector<ll>, greater<ll>>a;
int main() {
	cin >> n;
	lp(n) {
		cin >> mem;
		a.push(mem);
	}
	cnt = 1;
	lp(n - 1) {
		mem = a.top();
		a.pop();
		if (mem * 2 >= a.top())
			cnt++;
		else
			cnt = 1;
		a.push(a.top() + mem);
		a.pop();
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int dp[1001][10001];
int n,t;
int a[100001];
int b[100001];
int recurse(int idx, int have)
{
    if(have<=0)
    {
        return 0;
    }
    if(idx>=n)
    {
       // return 0;
      return 1e8+7;
    }
    if(dp[idx][have]!=-1)
    {
        return dp[idx][have];
    }
    int x=1e8+7;
    x=recurse(idx+1,have);
    x=min(x,recurse(idx,have-a[idx])+b[idx]);
    return dp[idx][have]=x;
    
}








int main()
{
    cin>>t>>n;
  
   for(int i=0;i<n;i++)
   {
       cin>>a[i]>>b[i];
   }
   memset(dp,-1,sizeof(dp));
   cout<<recurse(0,t);
}


Measured memory_bytes: 39936
"use strict"

function main(input) {

    input = input.split('\n')
    const n = ~~input[0]
    const nums = input[1].split(' ').map(v => ~~v)

    const step = 400
    const over = 3200
    const color = over / step
    let sets = new Set();
    let ovr3200 = 0
    for (let num of nums) {
        for (let i = 1; i <= color; i++)
            if (num < step * i) {
                sets.add(step * i)
                break
            }
        if (num >= over) {
            ovr3200++
        }
    }
    let min = sets.size <= 0 ? 1 : sets.size
    let max = Number(sets.size + ovr3200)// <= color ? Number(sets.size + ovr3200) : color
    const ans = min + ' ' + max
    console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int l=sc.nextInt();
		int[][] mat1=new int[n][m];
		int[][] mat2=new int[m][l];
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++) mat1[i][j]=sc.nextInt();
		for(int i=0;i<m;i++)
			for(int j=0;j<l;j++) mat2[i][j]=sc.nextInt();
		
		long sum=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				sum=0;
				for(int k=0;k<m;k++){
					sum+=mat1[i][k]*mat2[k][j];
				}
				System.out.print(sum);
				if(j!=l-1)System.out.print(" ");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 44832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,ans=0;cin>>k;
  for(ll a=1;a<=k;++a) {
    for(ll b=1;b<=k;++b) {
      for(ll c=1;c<=k;++c) {
        ans+=__gcd(__gcd(a,b),c);
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  vector<int> a(n);
    double ans;
  for(int i=0;i<n;i++){
  cin>>a[i];
    ans+=((double)1/a[i]);
  }
  ans=((double)1/ans);
  cout<<setprecision(6)<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
n-=1
i=26
c=1
while n-i>=0:
    n-=i
    i*=26
    c+=1
al=list('abcdefghijklmnopqrstuvwxyz')
ans=[]
for i in range(c):
    ans.append(al[n%26])
    n=n//26
ans.reverse()
print(''.join(ans))

Measured memory_bytes: 9192
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  ll x,a,b;
  cin >> x >> a >> b;
  if(-a+b<=0){
    cout << "delicious" << endl;
  }else if(-a+b>x){
    cout << "dangerous" << endl;
  }else{
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

  int ans;
  ans = x/500 * 1000;
  ans += (x%500)/5 * 5;

  cout << ans << endl;
}

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

void program(); 
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    program();
}

#define INF 0x7fffffffffffffff
#define UINF 0xffffffffffffffff
#define MOD 1000000007

#define int long long
#define unsigned unsigned long long
#define double long double

#define endl "\n"

int pow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

class UF{
public:
    int n;
    vector<int> par, sz;
    UF(int size) : n(size), par(size), sz(size){
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }
    void join(int x, int y){
        if ((x = find(x)) == (y = find(y))) return;
        if (sz[y] < sz[x]) std::swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        sz[x] = 0;
    }
    int find(int x){ return par[x] = (x == par[x] ? x : find(par[x])); }
    bool connected(int x, int y){ return find(x) == find(y); }
};

template<class Iter> void _print_range(ostream& o, Iter s, Iter e){
    for(;s != e;s++) o << *s << " ";
} 
template<class T> std::ostream& operator<<(ostream& o, const std::vector<T> &ds)
{
    _print_range(o,ds.begin(),ds.end()); 
    return o;
}
template<class T> std::ostream& operator<<(ostream& o, const std::set<T> &ds)
{
    _print_range(o,ds.begin(),ds.end()); 
    return o;
}
template<class T, class U> std::ostream& operator<<(ostream& o, const std::pair<T,U> &ds)
{
    o << "<" << ds.first << "," << ds.second << ">" << endl;
    return o;
}
template<typename ...Args>
void print(Args&&... args) {
    for(auto&& x: {args...})
        cout << x << " ";
    cout << endl;
}

#define debug(x) cout << "DEBUG    " <<  #x << ": " << x << endl;

#define fr(i, a, b) for(int i = a; i != (b); i += (a<b ? 1 : -1))
#define rep(i, a) for(decltype(a) i = 0; i < (a); i++)

#define trav(x, a) for(auto& x : a)
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define vi vector<int>
#define si set<int>
#define pii pair<int,int>

#define N 1005
char a[N][N];
int dp[N][N];
void program(){
    int h,w;
    cin>>h>>w;
    rep(i,h) rep(j,w) cin>>a[i][j];
    dp[0][0]=1;
    rep(i,h) rep(j,w){
        if(a[i][j]=='#') continue;
        if(i>0) dp[i][j] += dp[i-1][j];
        if(j>0) dp[i][j] += dp[i][j-1];
        dp[i][j] = dp[i][j]%MOD;
    }
    cout<<dp[h-1][w-1]<<endl;
}


/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-bruteforce?
-reduce dimensionality with problem contraints?
*/


Measured memory_bytes: 9088
#include<stdio.h>
int main(void)
{
    long long int n,l[100],i=0;
    scanf("%lld",&n);
    l[0]=2; l[1]=1;
    for(i=2;i<=n;i++){
        l[i]=l[i-1]+l[i-2];
    }
    printf("%lld\n",l[n]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

vector<ll> A(51);
vector<ll> B(51);
// dfs
// Lv.N 残りX枚食べる
ll dfs(ll N, ll X){
  if(X==0) return 0;
  if(N==0) return 1;
  if(B[N] == X) return A[N];
  ll ret = 0;
  X--;
  ret += dfs(N-1, min(X, B[N-1]));
  X -= B[N-1];
  if(X>0){
    ret++; X--;
  }
  if(X>0) ret += dfs(N-1, min(X, B[N-1]));
  return ret;
}

int main(){
  ll N, X; cin >> N >> X;
  A[0] = 1;
  B[0] = 1;
  rep(i,50){
    A[i+1] = A[i]*2+1;
    B[i+1] = B[i]*2+3;
  }
  ll ans = dfs(N, X);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int t = sc.NextInt();

        int answer = t / a * b;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=1e5+5,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);
int n;
int dp[mxN];
int go(ll cur){
    if(cur<=0)
        return cur==0?0:1e9;
    int &ret=dp[cur];
    if(~ret)
        return ret;
    ret=go(cur-1)+1;
    ll x=6,y=9;
    loop(8,i,0){
        ret=min({ret,go(cur-x)+1,go(cur-y)+1});
        x*=6;
        y*=9;
    }
    return ret;
}
void solve(){
    cin>>n;
    mem(dp,-1);
    cout<<go(n)<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	if (W==x*2&&H==y*2) {
		doublece(W*H/2,1)
	}
	else {
		doublece(W*H / 2, 0)
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
   	
int main() {
	int n,x;
	int sum = 0;
	int counter = 1;

	cin >> n >> x;

	int l[n];

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

	for (int i = 0; i < n; i++)
	{
		sum = sum + l[i];
		if (sum <= x)
		{
			counter++;
		}
		else
		{
			break;
		}
	}
	cout << counter  ;

	return 0;
}



Measured memory_bytes: 256
using System;

namespace code
{
    class Program
    {
        static void Main(string[] args)
        {
            string read = Console.ReadLine();
            bool kekka = Hantei(read);
            Console.WriteLine(kekka ? "Yes" : "No");
        }

        private static bool Hantei(string s)
        {
            bool kisuFlg = true;
            foreach (char c in s)
            {
                if (kisuFlg)
                {
                    if (c == 'L') return false;
                }
                else
                {
                    if (c == 'R') return false;
                }
                kisuFlg = kisuFlg ? false : true;
            }
            return true;
        }
    }
}

Measured memory_bytes: 11092
#ABC111C
import collections
def main():
    n=int(input())
    v=list(map(int,input().split()))
    ve=[]
    vo=[]
    for i in range(n//2):
        ve.append(v[2*i])
        vo.append(v[2*i+1])
    ce=collections.Counter(ve)
    co=collections.Counter(vo)
    ans=n
    if ce.most_common()[0][0]!=co.most_common()[0][0]:
        ans=n-ce.most_common()[0][1]-co.most_common()[0][1]
    elif len(ce)==1 and len(co)==1:
        ans=n-ce.most_common()[0][1]
    elif len(ce)==1:
        ans=n-ce.most_common()[0][1]-co.most_common()[1][1]
    elif len(co)==1:
        ans=n-ce.most_common()[1][1]-co.most_common()[0][1]
    else:
        ans=min(n-ce.most_common()[0][1]-co.most_common()[1][1],n-ce.most_common()[1][1]-co.most_common()[0][1])
    print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 24988
n = int(input())

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


K1 = sum(a)//n
K2 = K1+1

ans1 = 0
ans2 = 0


for i in a:
    ans1+=(K1-i)*(K1-i)
    ans2+=(K2-i)*(K2-i)
    
if ans1<ans2:
    print(ans1)
else:
    print(ans2)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <set>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<set<int>> index(26, set<int>({n + 10}));

    for (int i = 0; i < n; i++)
    {
        index[s[i] - 'a'].insert(i);
    }

    for (int i = 0; i < q; i++)
    {
        int type;
        cin >> type;
        if (type == 1)
        {
            int j;
            char c;
            cin >> j >> c;
            j--;
            char pc = s[j];
            s[j] = c;
            index[pc - 'a'].erase(j);
            index[c - 'a'].insert(j);
        }
        else if (type == 2)
        {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int result = 0;
            for (auto &&cix : index)
            {
                if (cix.empty())
                    continue;
                auto litr = cix.lower_bound(l);
                auto ritr = cix.lower_bound(r + 1);
                if (*litr < *ritr)
                    result++;
            }
            cout << result << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 24324
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int m =  sc.nextInt();
		
		int p[] = new int[n];
		
		for(int i = 0 ; i < n ; i++){
			p[i] = sc.nextInt()-1;
		}
		int x[] = new int[m];
		int y[] = new int[m];
		
		for(int i = 0; i < m ; i++){
			x[i] = sc.nextInt()-1;
			y[i] = sc.nextInt()-1;
		}
		
		init(n);
		for(int i = 0; i < m ; i++){
			union(x[i],y[i]);
		}
		
		int res = 0;
		for(int i = 0; i < n ; i++){
			if(find(p[i]) == find(i)){
				res++;
			}
		}
		System.out.println(res);
		
	}
	int[] uf;
	
	void init(int n){
		uf = new int[n];
		for(int i=0;i<n;i++){
			uf[i]= i;
		}
	}
	
	int find(int k){
		if(uf[k] == k){
			return k;
		}else{
			uf[k] = find(uf[k]);
			return uf[k];
		}
	}
	
	void union(int x,int y){
		if(find(x) != find(y)){
			uf[find(x)] = find(y);
		}
	}
	
}


Measured memory_bytes: 87960
#include<stdio.h>
int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b) {
		if (b < c) {
			printf("Yes\n");
		}
else{
printf("No\n");
}
	}
	else {
		printf("No\n");
	}
	return 0;
}

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

int main()
{
    long long x;
    cin >> x;
    for (long long a = -1000; a < 1000; a++)
    {
        for (long long b = -1000; b < 1000; b++)
        {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

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

#define st first
#define nd second

const int MAXN = 1e7 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int sieve[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

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

    int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        for (int j = i; j <= n; j += i) {
            sieve[j]++;
        }
    }

    ll res = 0;
    for (int i = 1; i <= n; ++i) {
        res += 1LL * (sieve[i] + 1) * i;
    }
    cout << res << "\n";
}


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

const int mod=int(1e9)+7;

int main(){
  string l;
  cin >> l;
  reverse(l.begin(), l.end());
  int pow3[100010]={1};
  int pow2[100010]={1};
  for(int i=1; i<100010; i++){
    pow3[i]=(3L*pow3[i-1])%mod;
    pow2[i]=(2L*pow2[i-1])%mod;
  }
  int cnt1=0;
  int ret=0;
  for(int i=l.length()-1; i>=0; i--){
    if(l[i]=='1'){
      ret+=((long)pow2[cnt1]*(long)pow3[i])%mod;
      ret%=mod;
      cnt1++;
    }
  }
  ret+=pow2[cnt1];
  ret%=mod;
  cout << ret;
  return 0;
}
  

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
using namespace std;

int main() {
    fio;
    ll x, y, m, x1, y1;
    cin >> x >> y >> m;
    ll hori[x + 1] = {0}, vert[y + 1] = {0};
    unordered_map<ll, set<ll>> s;
    set<ll> a;
    while(m--) {
        cin >> x1 >> y1;
        s[y1].insert(x1);
        hori[x1]++;
        vert[y1]++;
    }
    ll ans1 = 0, ans2 = 0;
    For(i, 1, x + 1) {
        ans1 = max(ans1, hori[i]);
    }
    For(i, 1, y + 1) {
        ans2 = max(ans2, vert[i]);
    }
    ll found = -1;
    For(i, 1, x + 1) {
        if(hori[i] == ans1)
            a.insert(i);
    }
    For(i, 1, y + 1) {
        if(vert[i] == ans2) {
            for(auto j : a) {
                if(s[i].find(j) == s[i].end()) {
                    cout << ans1 + ans2;
                    return 0;
                }
            }
        }
    }
    if(ans1 == 0 || ans2 == 0) {
        cout << ans1 + ans2 << "\n";
        return 0;
    }
    cout << ans1 + ans2 - 1;
}

Measured memory_bytes: 63344
n = gets.to_i

m = 0
ans = []
s = n/2*n

(n-1).times{|i|
  n.times{|j|
    if i+j+2!=n+((n+1)%2) && i<j
      ans << [i+1, j+1]
      m += 1
    end
  }
}

puts ans.size
ans.each{|x|
  puts x*" "
}



Measured memory_bytes: 2300
import random


class Cube:
    def __init__(self, u, s, e, w, n, d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d

    def rotate(self, dic):
        if dic == "N":
            tmp = self.u
            self.u = self.s
            self.s = self.d
            self.d = self.n
            self.n = tmp
        elif dic == "E":
            tmp = self.u
            self.u = self.w
            self.w = self.d
            self.d = self.e
            self.e = tmp
        elif dic == "W":
            tmp = self.u
            self.u = self.e
            self.e = self.d
            self.d = self.w
            self.w = tmp
        else:
            tmp = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = tmp


def main():
    u1, s1, e1, w1, n1, d1 = map(int, input().split())
    u2, s2, e2, w2, n2, d2 = map(int, input().split())
    cube1 = Cube(u1, s1, e1, w1, n1, d1)
    cube2 = Cube(u2, s2, e2, w2, n2, d2)

    ret = "No"
    for i in range(10000):
        cube2.rotate(random.choice("NWES"))
        if cube1.u == cube2.u and cube1.n == cube2.n and cube1.w == cube2.w and cube1.e == cube2.e and cube1.s == cube2.s and cube1.d == cube2.d:
            ret = "Yes"
            break
    print(ret)


if __name__ == '__main__':
    main()



Measured memory_bytes: 8188
fn main() {
	let text = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = text.split_whitespace();
	let _ = iter.next();
	let mut sum = 0i32;
	let mut prev = 0i32;
	for height in iter.map(|word| word.parse::<i32>().unwrap()) {
		if prev < height {
			sum += height - prev;
		}
		prev = height;
	}
	println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>

void traceALDS12B(int arr[], int max) {
	for (int i = 0; i < max; ++i) {
		if (i)
			std::cout << " ";
		std::cout << arr[i];
	}
	std::cout << std::endl;
}
int main() {

	int N;
	std::cin >> N;

	int arr[N];
	for (int i = 0; i < N; ++i) {
		std::cin >> arr[i];
	}

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		int minIdx = i;
		for (int j = i; j < N; ++j) {
			if (arr[j] < arr[minIdx]) {
				minIdx = j;
			}
		}
		if (minIdx != i) {
			std::swap(arr[i], arr[minIdx]);
			++cnt;
		}
	}

	traceALDS12B(arr, N);
	std::cout << cnt << std::endl;

	return 0;
}

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

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for (int i = 0;i <= N / R;++i) {
		for (int j = 0;j <= N / G;++j) {
			if ((N - R * i - G * j) % B == 0 && (N - R * i - G * j) / B >= 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
m,d = map(int,input().split())
cnt = 0
for i in range(1,m+1):
  for j in range(1,d+1):
    j1 = j%10
    j2 = int((j%100-j%10)/10)
    if j1>1 and j2>1 and j1*j2==i:
      cnt += 1
print(cnt)

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

using namespace std;


typedef long long LL;

int main(){
    LL N,A,B;
    scanf("%lld%lld%lld",&N,&A,&B);
    LL sum = (B-A)*(N-2)+1;
    if(A>B){
        printf("0");
        return 0;
    }
    if(N == 1 && A != B){
        printf("0");
        return 0;
    }
    if(N == 1 && A == B){
        printf("1");
        return 0;
    }
    printf("%lld", sum);

}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  
  Scanner sc = new Scanner(System.in);
  double N = sc.nextInt();
  double D = sc.nextInt();
  double n;
  
  n = N / (2*D+1);
  System.out.println((int)Math.ceil(n));
  }
}


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

int main(){
  int N , X;
  cin >> N >> X;
  int L[N];
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  int total = 0;
  int res = 1;
  for(int i = 0; i < N; i++){
    total += L[i];
    if(total <= X) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,K = map(int,input().split(' '))
l = list(map(int,input().split(' ')))

u = 10**9 + 7
in_cnt = 0
out_cnt = 0
for i in range(N):
    k = l[i]
    for j in l[i:]:
        if k > j:
            in_cnt += 1
for i in range(N):
    k = l[i]
    for j in range(N):
        kk = l[j]
        if i==j:
            continue
        if k > kk:
            out_cnt += 1
cnt = out_cnt*(K*(K-1)//2)
cnt += in_cnt*K
print(cnt%u)

Measured memory_bytes: 3188
N = int(input())
A = list(map(int,input().split()))

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)

Measured memory_bytes: 122936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N, M;
    cin >> N >> M;

    bool isng = false;
    vector<int> num(N, -1);
    for (int i = 0; i < M; ++i) {
        int s, c;
        cin >> s >> c;
        s--;
        if (num[s] != -1 && num[s] != c) {
            isng = true;
            continue;
        }
        num[s] = c;
    }

    if (N > 1 && num[0] == 0)
        isng = true;

    if (isng)
        cout << -1 << endl;
    else {
        if ((num[0] == 0 || num[0] == -1) && N > 1)
            num[0] = 1;
        for (int i = 0; i < N; ++i)
            cout << max(num[i], 0);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#define LL long long
#define MAXN 100010
#define debug(x) cerr << #x << " = " << x << endl
using namespace std;

inline LL read() { LL x = 0, f = 1; char ch = getchar();
    for(; !isdigit(ch); ch = getchar()) f = ch == '-' ? -1 : 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; return x * f;
}

const int MOD = 1e9 + 7;int n;
LL k;
LL sum[MAXN];

LL mi(LL a, int b) {
    LL ans = 1;
    while(b) {
        if(b % 2) ans *= (LL)a;
        a *= a;
        b /= 2;
    }
    return ans;
}

LL sol(int n, LL k) {
    //debug(k);

    if(n == 0) return k > 0;
    LL x = mi(2, n + 2) - 3ll;
    //debug((x));
    if(k > (x >> 1) + 1ll) {
        return sol(n - 1, k - (x >> 1) - 1ll) + sum[n - 1] + 1ll;
    }
    if(k > (x >> 1)) return sol(n - 1, k - 1) + 1ll;
    return sol(n - 1, k - 1);
}

LL tot[MAXN];

int main() {
    //debug(mi(2, 52));
    n = (int)read();
    k = read();
    sum[0] = 1; tot[0] = 1;
    for(int i = 1; i <= n; ++i) {
        sum[i] = (sum[i - 1] << 1) + 1ll;
        tot[i] = (tot[i - 1] << 1) + 3ll;
//        debug(tot[i]);
//        debug(sum[i]);
    }
    //debug(k - tot[n] / 2 - 1);
    printf("%lld\n", sol(n, k));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 200005;
const int mod = 1e9 + 7;

int n, m;
int f[MAXN];
char s[MAXN];
int sum[MAXN];

int main(){
	scanf("%d %d %s",&n,&m,s);
	for(int i=0; i<m; i++) if(s[i] == 'R') s[i] = 'A';
	if(s[0] == 'B'){
		for(int i=0; i<m; i++) s[i] = 'A' + 'B' - s[i];
	}
	if(count(s, s + m, 'B') == 0){
		f[0] = 1; f[1] = 2;
		for(int i=2; i<=n; i++){
			f[i] = f[i-1] + f[i-2];
			f[i] %= mod;
		}
		lint ret = f[n];
		if(n == 3) ret += mod - 1;
		else if(n >= 4) ret += mod - f[n - 4];
		ret %= mod;
		cout << ret << endl;
		return 0;
	}
	int alt = 1e9;
	int pref = 0;
	while(s[pref] == 'A') pref++;
	for(int i=0; i<m; i++){
		if(s[i] == 'B'){
			int e = i + 1;
			while(s[e] == 'A') e++;
			if(e == m) break;
			if(e > i + 1 && e % 2 == i % 2){
				alt = min(alt, e - i - 1);
			}
			i = e - 1;
		}
	}
	if(n % 2 == 1){
		puts("0");
		return 0;
	}
	int x = min(alt, pref + 1);
	f[0] = 1;
	sum[0] = 1;
	for(int i=1; i<=n/2; i++){
		f[i] = sum[i - 1];
		if(i >= (x + 3) / 2) f[i] += mod - sum[i - (x + 3) / 2];
		f[i] %= mod;
		sum[i] = (sum[i-1] + f[i]) % mod;
	}
	lint ret = 0;
	for(int i=0; i<n;i++){
		int len = n - 1 - x;
		if(n - 1 - x > n - 1 - i) continue;
		ret += sum[(n - 1 - i) / 2];
		if(len >= 1){
			ret += mod - sum[(len - 1) / 2];
		}
	}

	cout << ret % mod << endl;
}


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

int main() {

	int N,i,j;
	cin >> N;

	// 2つの整数の組(座標)の配列
	vector< pair<int,int> > r(N),b(N);

	// 入力
	for(i=0;i<N;i++) cin >> r[i].second >> r[i].first;
	for(i=0;i<N;i++) cin >> b[i].first  >> b[i].second;
	
    // それぞれ昇順にソート
	sort(r.begin(),r.end());
	sort(b.begin(),b.end());
	
	// ペア用バケット
	vector<int> pair(N);
	
	int point, ans = 0;
	for(i = 0 ; i < N ; i++) {
	  
		bool f = false;
		for(j = 0 ; j < N ; j++) {
		  
			if( r[j].second < b[i].first && r[j].first < b[i].second) {
			// いま注目している青点より左下にある赤点に注目
			
				if(pair[j] == 0) {
				// r[j]がまだペアでないならj番目をペアに予約
					f = true;
					point = j;
				}
			}
		}
		if(f)
		{ans++; pair[point]=1;} //予約したjをバケットに追加
	}
	cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $total, $choice);
$nums = explode(' ', trim(fgets(STDIN)));
$cumsums = [0];
for ($i=1; $i <= $total; $i++) { 
    $cumsums[$i] = $nums[$i-1] + $cumsums[$i-1];
}
$list = [];
for ($i=0; $i <= $total - $choice; $i++) { 
    $list[] = $cumsums[$i+$choice] - $cumsums[$i];
}
echo (max($list) + $choice) / 2;

Measured memory_bytes: 37356
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, k, r, s, p;
string t;
char choice[3] = {'r', 's', 'p'};
map<char, int> m;
map<char, char> beats;
vector<string> vs;

signed main(void){
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    m.insert(P('r', r));
    m.insert(P('s', s));
    m.insert(P('p', p));

    beats.insert(P('r', 'p'));
    beats.insert(P('s', 'r'));
    beats.insert(P('p', 's'));

    int ret = 0;
    for(int i=0; i<k; i++){
        char prev = 'a';
        for(int j=i; j<n; j+=k){
            if(j < k || beats[t[j]] != prev){
                ret += m[beats[t[j]]];
                prev = beats[t[j]];
            }else{
                prev = 'a';
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char s[101];
    char t[101];
    char tmp;
    int i, j;
    scanf("%s",s);
    scanf("%s",t);
    for(i=0;i<(int)strlen(s)-1;i++)
    {
          for(j=i+1;j<(int)strlen(s);j++)
          {
                if(s[i] > s[j])
                {
                      tmp = s[i];
                      s[i] = s[j];
                      s[j] = tmp;
                }
          } 
    }
    for(i=0;i<(int)strlen(t)-1;i++)
   {
          for(j=i+1;j<(int)strlen(t);j++)
          {
                if(t[i] < t[j])
                {
                     tmp = t[i];
                     t[i] = t[j];
                     t[j] = tmp;
                }
         }
    }
    if(strcmp(s,t)<0)
          printf("Yes\n");
    else
          printf("No\n");
    return 0;
    }


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

//K進法での桁数
int digsumK(int K, int n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= K;
    }
    return res;
}

int main() {
  int N, K;
  cin >> N >> K;
  int ans = digsumK(K, N);
  cout << ans << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
def 解():
    iN = int(input())
    aA = [int(_) for _ in input().split()]
    #itertools をつかわず 累積和でやってみると？
    aAc = [0]*iN
    aAc[0] = aA[0]
    for i in range(1,iN):
        aAc[i] = aAc[i-1] + aA[i]
    iD = aAc[-1]
    minDiff = 10**9 *2
    for i in range(iN-1):
        minDiff = min(minDiff,abs(iD-2*aAc[i]))
    print(minDiff)
解()


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<vector<int>> left(n+2, vector<int>(k+1)), right(n+2, vector<int>(k+1));
    left[0][0] = right[n+1][0] = 1;
    for (int i = 0; i+1 <= n; i++) {
        for (int j = 0; j <= k; j++) {
            left[i+1][j] |= left[i][j];
            if (j+a[i+1] <= k) left[i+1][j+a[i+1]] |= left[i][j];
        }
    }
    for (int i = n+1; i-1 >= 1; i--) {
        for (int j = 0; j <= k; j++) {
            right[i-1][j] |= right[i][j];
            if (j+a[i-1] <= k) right[i-1][j+a[i-1]] |= right[i][j];
        }
    }
    for (int i = 0; i <= n+1; i++) {
        partial_sum(begin(right[i]), end(right[i]), begin(right[i]));
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            if (j + a[i] < k && left[i-1][j] && right[i+1][k-j-1] - right[i+1][k-j-a[i]-1]) {
                ans++;
                break;
            } else if (j >= k - a[i] && left[i-1][j]) {
                ans++;
                break;
            }
        }
    }
    cout << n - ans << endl;
}


Measured memory_bytes: 196096
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

cnt = B[A[0]-1]
for i in range(1, N):
    cnt += B[A[i]-1]
    if A[i-1]+1 == A[i]:
        cnt += C[A[i-1]-1]
print(cnt)



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            // Drop
            Console.ReadLine();

            var inputArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x));

            Console.WriteLine(1.0 / inputArray.Select(x => 1.0 / x).Sum());
        }
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  map<ll,int> c;
  rep(i,n){
    cin >> a[i];
    b[i] = a[i]-i;
    c[b[i]]++;
  }

  ll ans = 0;
  rep(i,n){
    ll fi = -1*b[i]-2*i;
    ans += c[fi];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    map<char, int> mps;
    for(int i = 0; i < 4; i++){
        if(mps[S[i]] == 0) mps[S[i]] = 1;
        else mps[S[i]]++;
    }
    if(mps.size() == 2){
        for(auto i: mps){
            if(i.second != 2){
                cout << "No" << endl;
                return 0;
            }
        }
    }else{
        cout << "No\n";
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};
mod mod_pow(ll n, ll r) {return mod_pow(mod(n), r);}

#define FACT_MAX 1000000
mod t_fact[FACT_MAX], t_fact_inv[FACT_MAX];
mod fact(int n)
{
    if (n == 0 || n == 1) return t_fact[n] = 1;
    if (t_fact[n] != 0) return t_fact[n];
    else return t_fact[n] = n * fact(n-1);
}
mod fact_inv(int n)
{
    if (t_fact_inv[n] != 0) return t_fact_inv[n];
    else return t_fact_inv[n] = mod_pow(fact(n), -1);
}
mod comb(int n, int k) {if (n < 0 || k < 0 || k > n) return 0; else return fact(n) * fact_inv(n - k) * fact_inv(k);}
mod multi_choose(int n, int k) {return comb(n + k - 1, k);}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    ll A, B, C;
    cin >> N >> A >> B >> C;
    
    mod Ret = 0;
    for (int m = N; m <= 2*N-1; ++m) {
        mod Tmp = comb(m-1, N-1);
        Tmp *= mod_pow(A, N) * mod_pow(B, m-N) + mod_pow(A, m-N) * mod_pow(B, N);
        Tmp /= mod_pow(100-C, m);
        Tmp *= mod(m) * 100 / (100-C);
        Ret += Tmp;
    }
    cout << Ret << endl;
    
    return 0;
}


Measured memory_bytes: 17408
#include <iostream>
bool isPrime(int x) {for(int i=2;i*i<=x;i++)if(x%i==0)return false;return true;}
int main() {
  int n;
  while(std::cin>>n,n) {
    int ans=0;
    for(int s=-1;s<2;s+=2)for(int i=0;!isPrime(n+i*s);i++,ans++);
    std::cout<<ans<<'\n';
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main(){
  char s[6]={};
  int a,k=0;
  scanf("%s",s);
  for(a=0;a<3;a++){
    if(s[a]=='1'){
      k++;
    }
  }
  printf("%d",k);
  return 0;
}

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

using namespace std;

const int N = 200005;
int a[N], b[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	set <pair <int, long long> > s;
	s.insert({0, 0});
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		auto it = s.lower_bound({a[i], 0});
		--it;
		long long temp = it->second + x;
		++it;
		while (it != s.end()) {
			if (it->second > temp) {
				break;
			}
			s.erase(it++);
		}
		s.insert({a[i], temp});
	}
	printf("%lld\n", (*(--s.end())).second);
	return 0;
}


Measured memory_bytes: 13568