akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265

// read statement carefully.

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


void solve()
{
       cin>>n;
       rep(i,1,2*n+1) cin>>a[i];
       sort(a+1, a+1+2*n);
       ll ans=0;
       for(ll i=1; i<=2*n+1; i+=2) ans+=a[i];
       cout<<ans;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 256
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)  for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    read2(k,n);
    if(k*500>=n) cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int i, N;
    
    cin >> N;

    int B[N-1];
    
    for(i = 0; i < N-1; i++){
        cin >> B[i];
    }
    
    int max = B[0];
    
    for(i = 1; i < N-1; i++){
        if(B[i] > B[i-1]){
            max += B[i-1];
        }else{
            max += B[i];
        }
    }

    max += B[N-2];
    
    cout << max;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(N):
        w, v = map(int, input().split())
        for j in range(W + 1):
            if j >= w:
                dp[i + 1][j] = max(
                    dp[i][j],
                    dp[i][j - w] + v
                )
            else:
                dp[i + 1][j] = dp[i][j]
    print(dp[-1][-1])


main()


Measured memory_bytes: 118512
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for i in range(N):
    ans[0] += A[-1 - i] * (-1) ** i
for i in range(N - 1):
    ans[i + 1] = A[i] * 2 - ans[i]
print(*ans)


Measured memory_bytes: 14028
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int tree[500005*4][30];
int a[500005];
char s[500005];
int n,q;
int _n;
void update(int num,int k,int ind){
    k+=_n-1;
    tree[k][ind]+=num;
    while(k>=2){
        k/=2;
        tree[k][ind]=tree[k*2][ind]+tree[k*2+1][ind];
    }
}
int query(int l,int r,int nl,int nr,int ind,int ooo){
    if(nl>r || nr<l) return 0;
    if(l<=nl && nr<=r) return tree[ind][ooo];
    int mid=(nl+nr)/2;
    return query(l,r,nl,mid,ind*2,ooo)+query(l,r,mid+1,nr,ind*2+1,ooo);
}
int main(){
    _n=1;
    scanf("%d",&n);
    while(_n<n) _n*=2;
    scanf("%s",s);
    for(int i=0;i<n;i++) a[i]=s[i]-'a';
    for(int i=0;i<n;i++)
        update(1,i+1,a[i]);
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int x,y,z;char w;
        scanf("%d %d",&x,&y);
        if(x==1){
            scanf(" %c",&w);
            update(1,y,w-'a');
            update(-1,y,a[y-1]);
            a[y-1]=w-'a';
        }
        else{
            scanf("%d",&z);
            int ans=0;
            for(int j=0;j<26;j++)
                if(query(y,z,1,_n,1,j)) 
                    ans++;
            printf("%d\n",ans);
        }
    }
    return 0;
}

Measured memory_bytes: 123136
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Function
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO()
main = do
  getLine
  ns <- getIntList
  print . maximum . map ((subtract  1). length) . unfoldr slice $ ns
  where
    slice [] = Nothing
    slice (n:ns) = Just $ cut n ns
    cut n [] = ([n], [])
    cut n mss@(m:ms)
      | n >= m = (\(ns, ms) -> ((n:ns), ms)) $ cut m ms
      | otherwise = ([n], mss)

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
//int 2×10の9乗
 
int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  int X=0;
  long double ans = w*h/2;
  if(x==w/2 && y==h/2) X=1;
  cout << fixed << setprecision(16);
  cout << ans << " " << X << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

#print(g)
for i in range(n):
    if len(g[i])%2 == 1:
        print('NO')
        exit()
else:
    print('YES')


Measured memory_bytes: 55328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

vector<vector<int>> G;
vector<int> used;
vector<int> ans;

int main(){
    int n,m; cin >> n >> m;
    G.resize(n);
    used.resize(n,false);
    ans.resize(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << "Yes" << endl;
    used[0] = true;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int v : G[u]){
            if(used[v]) continue;
            used[v] = true;
            ans[v] = u+1;
            q.push(v);
        }
    }
    repr(i,1,n){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 10640
N = int(input())
A = list(map(int,input().split()))
flag = 0
ans = 1
for i in range(N):
    if flag == 0:
        ans *= A[i]
    if ans > 10**18 and flag != 2:
        flag = 1
    if A[i] == 0:
        flag = 2
if flag == 0:
    print(ans)
elif flag == 1:
    print(-1)
else:
    print(0)


Measured memory_bytes: 21788
N,K,Q = map(int,input().split())
a_list = [int(input()) for _ in range(Q)]

from collections import Counter

counter = Counter(a_list)

if K>Q:
    # これで終えても良い
    base = 1
else:
    base = 0
winners = [base for _ in range(N+1)]
for i,cnt in counter.items():
    if K-Q+cnt > 0:
        winners[i] = 1

for win in winners[1:]:
    if win==1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 61272
# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 265748
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var csf = new CSF[n];
			for (int i = 0; i < n - 1; i++) {
				var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				csf[i] = new CSF { C = temp[0], S = temp[1], F = temp[2] };
			}

			var sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				int time = 0;
				for (int j = i; j < n - 1; j++) {
					if (time <= csf[j].S) {
						time = csf[j].S + csf[j].C;
					} else {
						if (time % csf[j].F == 0) {
							time += csf[j].C;
						} else {
							time += (csf[j].F - (time % csf[j].F)) + csf[j].C;
						}
					}
				}

				sb.AppendLine(time.ToString());
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public struct CSF
	{
		public int C { get; set; }
		public int S { get; set; }
		public int F { get; set; }
	}
}

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

void printChess(int H,int W){
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if((j+i)%2==0){ //??¶??°??????
				cout<<"#";
			}else{
				cout<<".";
			}
		}
		cout<<endl;
	}
}

int main()
{
	int H,W;
	cin>>H>>W;
	while( H!= 0 && W != 0 ){
		printChess(H,W);
		cout<<endl;
		cin>>H>>W;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int cw[200020], cb[200020], ct[200020];

int main(void)
{
    int n;     cin >> n;
    string s;  cin >> s;
    cw[n] = cb[0] = 0;
    REP(i, n+1) {
        cb[i+1] += (cb[i] + (s[i]=='#'?1:0));
        cw[n-i-1] += (cw[n-i] + (s[n-i-1]=='.'?1:0));
    }
    int  m = 3*10e5;
    REP(i, n+1) {
//        cout << i << " " << cb[i] << " " << cw[i] << endl;
        m = min(m, cb[i]+cw[i]);
    }
    cout << m << endl;
}


Measured memory_bytes: 2180
import sys
table = [0]*26

alphabet = "abcdefghijklmnopqrstuvwxyz"
#big_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
while True:
    try:
        line=input().lower()
        for s in line:
            for  i in range(len(alphabet)):
                #print(alphabet[i],s)
                if s == alphabet[i]:
                    table[i] +=1
                    #rint(table[i])
    except:
        break

for i in range(len(alphabet)):
    print(f'{alphabet[i]} : {table[i]}')




Measured memory_bytes: 5580
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val av = Vector.fill(n)(sc.nextInt)

  val resl = {
    val (odds, evens) = av.zipWithIndex.partition(_._2 % 2 == 0)

    if(n % 2 == 0) evens.reverse ++ odds
    else odds.reverse ++ evens
  }

  val res = resl.map(_._1).mkString(" ")
  println(res)
}



Measured memory_bytes: 82960
n = input().split()
m = input().split()

a = len(m)
sum = 0
for i in range(a):
  sum += int(m[i])

item2 = []
for i in range(a):
  item2.append(int(m[i]) / sum)

ans = 1 / (4 * int(n[1]))

item3 = []
for i in range(a):
  if item2[i] >= ans:
    item3.append(item2[i])

if int(n[1]) <= int(len(item3)):
  print('Yes')
else:
  print('No')
    



Measured memory_bytes: 3064
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    std::bitset<26> C;

    for (size_t i = 0; i < S.size(); ++i) {
        C.set(S[i] - 'a');
    }

    if (C.all()) {
        for (int i = 25; i > 0; --i) {
            if (S[i - 1] < S[i]) {

                char cn = 'z';
                for (int j = i; j < 26; ++j) {
                    if (S[j] >= S[i-1] && S[j] < cn) {
                        cn = S[j];
                    }
                }
                std::cout << S.substr(0, i - 1) << cn << endl;
                return 0;
            }
        }
        std::cout << "-1" << std::endl;
        return 0;
    }
    else {
        for (size_t i = 0; i < 26; ++i) {
            if (!C[i]) {
                std::cout << S << (char)(i + 'a') << std::endl;
                break;
            }
        }
    }

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	ll ret=0;
	for(int a=1;a<=K;a++) {
		for(int b=1;b<=K;b++) {
			int g=__gcd(a,b);
			for(int c=1;c<=K;c++) ret+=__gcd(g,c);
			
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

template<typename T> inline constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

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

	VI V(N);
	rbf(v, V) {
		cin >> v;
	}

	sort(All(V));
	
	double value = static_cast<double>(V[0] + V[1]) / 2.0;

	rng(i, 2, N) {
		value = (static_cast<double>(V[i]) + value) / 2.0;
	}

	COL(value);

	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	double R;
	cin >> R;

	cout << 2.0 * 3.14159265368979 * R << "\n";

	return 0;
}



Measured memory_bytes: 3724
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

# ソートした後グルーピングする
# 最大距離を避けるように配置する？
if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    if N >= M:
        print(0)
        exit()

    X = list(map(int, sys.stdin.readline().split()))
    X = sorted(X)
    length = max(X) - min(X)
    distance = []
    for i in range(len(X) - 1):
        distance.append(abs(X[i] - X[i + 1]))
    distance = sorted(distance, reverse=True)

    for i in range(N - 1):
        length -= distance[i]

    print(length)

Measured memory_bytes: 16144
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fir first
#define sec second
using namespace std;
const int N=310,mod=998244353;
int a[N];
int f[N*N];
int read()
{
	int x=0,flag=1;char c=getchar();
	while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*flag;
}
ll qpow(int a,int b)
{
	ll ans=1,base=a;
	while(b)
	{
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	int n=read(),sigma=0;
	for(int i=1;i<=n;i++) a[i]=read(),sigma+=a[i];
	f[0]=1;
	for(int i=1;i<=n;i++) 
	{
		for(int j=300*i;j>=0;j--)
		{
			if(j>=a[i]) f[j]=(f[j]+f[j-a[i]]*2ll)%mod;
		}
	}
	ll ans=qpow(3,n);
	for(int i=0;i+i<=sigma;i++) ans=(ans-1ll*f[i]*3)%mod;
	memset(f,0,sizeof(f));
	f[0]=1;
	for(int i=1;i<=n;i++) 
	{
		for(int j=300*i;j>=0;j--)
		{
			if(j>=a[i]) f[j]=(f[j]+f[j-a[i]])%mod;
		}
	}
	if(sigma%2==0)
	{
		ans=(ans+1ll*f[sigma/2]*3)%mod;
	}
	cout<<(ans%mod+mod)%mod;
	return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 998244353
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back

using namespace std;

void solve()
{
    ll n;
    cin>>n;
    cout<<pow(n,3);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	//cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++){
        s[i] = (s[i]-'A' + n) % 26 + 'A';
        cout << s[i];
    }
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

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

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

	int num = 0;
	int ans = 1e6;
	for (int i = 0; i < 3-1; i++) {
		for (int j = i+1; j < 3; j++) {
			num = p[i] + p[j];
			if (num < ans) {
				ans = num;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

signed main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	cout << 15 - a - b - c - d - e << endl;
}

Measured memory_bytes: 3632
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/lexical_cast.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  string S;
  cin >> S;
  vec<int> ABCD;
  transform(ALL(S), back_inserter(ABCD),
            [](char c) { return boost::lexical_cast<int>(c); });
  const int A = ABCD[0];
  const int B = ABCD[1];
  const int C = ABCD[2];
  const int D = ABCD[3];

  if (A + B + C + D == 7) {
    cout << S[0] << "+" << S[1] << "+" << S[2] << "+" << S[3] << "=7" << endl;
  } else if (A + B + C - D == 7) {
    cout << S[0] << "+" << S[1] << "+" << S[2] << "-" << S[3] << "=7" << endl;
  } else if (A + B - C + D == 7) {
    cout << S[0] << "+" << S[1] << "-" << S[2] << "+" << S[3] << "=7" << endl;
  } else if (A + B - C - D == 7) {
    cout << S[0] << "+" << S[1] << "-" << S[2] << "-" << S[3] << "=7" << endl;
  } else if (A - B + C + D == 7) {
    cout << S[0] << "-" << S[1] << "+" << S[2] << "+" << S[3] << "=7" << endl;
  } else if (A - B + C - D == 7) {
    cout << S[0] << "-" << S[1] << "+" << S[2] << "-" << S[3] << "=7" << endl;
  } else if (A - B - C + D == 7) {
    cout << S[0] << "-" << S[1] << "-" << S[2] << "+" << S[3] << "=7" << endl;
  } else if (A - B - C - D == 7) {
    cout << S[0] << "-" << S[1] << "-" << S[2] << "-" << S[3] << "=7" << endl;
  }
  return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;

const int maxn = 100010;

int n;
int a[maxn + 5], b[maxn + 5];

int must[maxn + 5];

int ans = 1;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d", a + i);
	REP(i, 0, n) scanf("%d", b + i);
	memset(must, -1, sizeof must);
	REP(i, 0, n) if (!i || a[i] != a[i - 1]) must[i] = a[i];
	REP(i, 0, n) if (i == n - 1 || b[i] != b[i + 1]) 
	{
		if (~must[i] && must[i] != b[i]) { printf("0\n"); return 0; }
		must[i] = b[i];
	}
	int Max = 0;
	REP(i, 0, n) 
	{
		chkmax(Max, must[i]);
		if (Max > a[i]) { printf("0\n"); return 0; }
	}
	Max = 0;
	for (int i = n - 1; i >= 0; --i)
	{
		chkmax(Max, must[i]);
		if (Max > b[i]) { printf("0\n"); return 0; }
	}
	ans = 1;
	REP(i, 0, n) if (!~must[i]) ans = (LL)ans * min(a[i], b[i]) % Mod;
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1408
n = {}
for b in range(1,5):
    for f in range(1,4):
        for r in range(1,11):
            n[(b,f,r)] = 0

for i in range(int(input())):
    b, f, r, v = map(int, input().split())
    n[(b,f,r)] += v

for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            print (" " + str(n[(b,f,r)]), end ="")
        print("")
    if b <= 3:
        print("#"*20)



Measured memory_bytes: 5620
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	static int N;
	static int K;
	static boolean[] ng;
	static int[] ok;
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		String s = "";
		for(int i = 0; i < K; i++)
			s += sc.next();
		while(!isOk(N, s)) N++;
		System.out.println(N);
	}
	
	static boolean isOk(int num, String s){
		String n = "" + num;
		for(int j = 0; j < s.length(); j++)
			if(n.indexOf(s.charAt(j)) != -1) return false;
		return true;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 27476
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if (abs(a - b) % 2 == 0)
  {
    cout << abs(a - b) / 2 + min(a, b) << endl;
  }
  else
  {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a[21];
int n;

int solve(int p, int s, int t)
{
  if(p == n) return abs(s-t);
  return min(solve(p+1, s+a[p], t), solve(p+1, s, t+a[p]));
}

int main()
{
  while(scanf("%d", &n)!=EOF && n != 0){
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    printf("%d\n", solve(0, 0, 0));
  }

  return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  vi vec;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  m = l = 0;
  sort(all(vec),greater<int>());
  rep(i,0,vec.sz){
    if(i % 2 == 0)m += vec[i];
    else l += vec[i];
  }
  print(abs(m-l));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmin(T& a,T b){
    if( a > b) {a = b; return 1; } return 0;
}
ll dp[110][100100];
int main()
{
    ll n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    for(ll i = 0; i < 110; i++){
        for(ll j = 0; j < 100100; j++){
            dp[i][j] = 1LL << 60;
        }
    }

    dp[0][0] = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < 100100;j++){
            if(j - value[i] >= 0)
            chmin(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
            chmin(dp[i + 1][j],dp[i][j]);
        }
    }
    ll res = 0;
    for(ll j = 0; j < 100100; j++){
        if(dp[n][j] <= w)
        res = j;
    }
    cout << res << endl;
}

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

int main() {
	int n, m, k; cin >> n >> m >> k;
	map<int, int> num_to_ind, ind_to_num;
	vector<bool> dark(n, false);
	for (int i = 0; i < m; ++i) {
		int z; cin >> z; z--;
		num_to_ind[z] = i;
		ind_to_num[i] = z;
		dark[z] = true;
	}
	vector<vector<int> > v(n, vector<int>(k));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < k; ++j) {
			cin >> v[i][j]; v[i][j]--;
		}
	}
	vector<int> dist(1<<m, 10000);
	dist[(1<<m)-1] = 0;
	deque<int> q;
	q.push_back((1<<m)-1);
	while (dist[0] == 10000) {
		int x = q.front();
		q.pop_front();
		for (int i = 0; i < k; ++i) {
			int res = 0;
			for (int j = 0; j < m; ++j) {
				if ((x>>j)&1 && dark[v[ind_to_num[j]][i]]) {
					res |= 1<<(num_to_ind[v[ind_to_num[j]][i]]);
				}
			}
			if (dist[res] > dist[x] + 1) {
				dist[res] = dist[x]+ 1;
				if (res == 0) break;
				q.push_back(res);
			}
		}
	}
	cout << dist[0] << endl;

	return 0;
}


Measured memory_bytes: 3460
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	string s;
	cin >> s;

	string ans = "";

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'B' && ans.length() != 0) {
			ans = ans.substr(0, ans.length() - 1);
		}
		else if (s[i] != 'B') {
			ans += s.substr(i, 1);
		}
		else {
			continue;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<vector<pair<int,int>>> graph(21);
    
    vector<int> pct(21);
    
    for(int i=0; i<=3; i++){
        graph[1].push_back({2,i});
    }
    
    pct[2]=4;
    
    for(int i=2; i<=18; i++){
        graph[i].push_back({i+1,0});
        graph[i].push_back({i+1,pct[i]});
        pct[i+1]=2*pct[i];
    }
    //pct[20]=2*pct[19];
    /*
    cout<<pct[19]<<endl;
    
    for(int i=1; i<=10; i++){
        for(auto p:graph[i]){
            cout<<i<<" "<<p.first<<" "<<p.second<<endl;
        }
    }
    
    cout<<pct[19]<<endl;
    */
    int pos=19;
    int rem=n, add=0;
    
    while(pos>=2 && rem){
        if(pct[pos]<=rem){
            graph[pos].push_back({20, add});
            rem-=(pct[pos]);
            add+=pct[pos];
        }
        pos--;
    }
    
    
    
    for(int i=0; i<rem; i++){
        graph[1].push_back({20,add+i});
    }
    
    int ect=0;
    
    for(int i=1; i<=20; i++){
        ect+=graph[i].size();
    }
    cout<<"20 "<< ect<<endl;
    
    for(int i=1; i<=20; i++){
        for(auto p:graph[i]){
            cout<<i<<" "<<p.first<<" "<<p.second<<endl;
        }
    }
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
plst = list(map(int, input().split()))
qlst = list(map(int, input().split()))
rlst = list(map(int, input().split()))
plst.sort()
qlst.sort()
rlst.sort(reverse = True)
inf = 10 ** 20
plst = plst[-x:] + [inf]
qlst = qlst[-y:] + [inf]
r_pos = 0
p_pos = 0
q_pos = 0
while 1:
    if rlst[r_pos] <= plst[p_pos] and rlst[r_pos] <= qlst[q_pos]:
        break
    elif plst[p_pos] < qlst[q_pos]:
        plst[p_pos] = rlst[r_pos]
        p_pos += 1
        r_pos += 1
    else:
        qlst[q_pos] = rlst[r_pos]
        q_pos += 1
        r_pos += 1
    if r_pos == c:
        break
print(sum(plst) + sum(qlst) - inf * 2)


Measured memory_bytes: 28156
from collections import deque
N,M=map(int,input().split())
tree=[[] for _ in range(N+M)]   #tree[0]~tree[N]は人の番号、tree[N+1]~tree[M]は言語に対応させる

#ここの操作は高々10^5回
for i in range(N):                      #各人について
    l=list(map(int,input().split()))
    K=l[0]
    n=len(l)
    for j in range(1,n):                #言語と人を繋ぐbidirectional treeを構成する
        tree[i].append(l[j]+N-1)
        tree[l[j]+N-1].append(i)
#print(tree)

#探査は普通のbfsで10^5回以下で終了することを利用する
d=deque()
seen=[0]*(N+M)              #木ではないので、一度見たかどうか管理。0~N番目は「人」N+1~N+M番目は「言語」
d.append(0)                 #グラフ探査の始点を入れる(何でも良い、ここでは0)
while len(d)>0:             #0(1人目)と連結な成分を探せば良い、これは1人目<=>言語x<=>...<=>i人目<=>言語m<=>j人目<=>言語n<=>...の関係を持つ、全ての言語と人の集合に相当し
                            #これに含まれる人同士が、互いにコミュニケーションを取れることになる
    v=d.popleft()
    seen[v]=1               #連結な成分に1を代入していく
    for i in tree[v]:
        if seen[i]==0:
            d.append(i)
#print(seen)
#print(seen[:N])
if sum(seen[:N])==N:        #0~N番目に全て1があれば、N人全ては互いにコミュニケーションをとれることになる
    print("YES")
else:
    print("NO")

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

using namespace std;

using int64 = long long;

int main() {
  int N, M;
  bool p[1001] = {};
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int x;
    cin >> x;
    p[--x] = true;
  }
  int ret = 0;
  for(int i = N - 1; i >= 0; i--) {
    if(p[i]) {
      for(int j = 0; j <= i; j++) {
        if(!p[j]) {
          ++ret;
          p[j] = true;
          p[i] = false;
          break;
        }
      }
    }
  }

  cout << ret << endl;
}




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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    set<P> st;
    for(int i=0;i<n;i++){
        cin>>a[i];
        st.insert(P(a[i],i));
    }
    for(int i=0;i<n;i++){
        P p=P(a[i],i);
        st.erase(p);
        P pp=*rbegin(st);
        cout<<pp.first<<'\n';
        st.insert(p);
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

ll euclid(ll a, ll b)
{
	int temp;

	if (a < b) { temp = a; a = b; b = temp; }
	if (b < 1) return -1;

	if (a % b == 0) return b;
	return euclid(b, a % b);
}
int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll>T(N);
	rep(i, N)cin >> T[i];
	rep(i, N - 1) {
		ll x = euclid(T[i], T[i + 1]);
		T[i + 1] = x*(T[i] / x)*(T[i + 1] / x);
	}
	cout << T[N-1] << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		long N = nextLong();

		long ed =(long)Math.sqrt(N);
		long ans = N;
		for(long i=1;i<=ed;i++) {
			if(N%i==0) {
				ans = Math.min(ans,Math.max(String.valueOf(i).length(),String.valueOf(N/i).length()));
			}
		}
		pw.println(ans);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;
template<typename T,typename E>
struct LazySegmentTree{
    using F=function<T(T,T)>;
    using G=function<T(T,E)>;
    using H=function<E(E,E)>;
    
    int n;
    vector<T> dat;
    vector<E> lazy;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    
    LazySegmentTree(int n_,F f,G g,H h,T ti,E ei) :f(f),g(g),h(h),ti(ti),ei(ei){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
        
        lazy.assign(2*n-1,ei);
    }
    
    LazySegmentTree(int n_,vector<T> &v,F f,G g,H h,T ti,E ei) :f(f),g(g),h(h),ti(ti),ei(ei){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
        
        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];
        
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
        
        lazy.assign(2*n-1,ei);
    }
    
    inline void eval(int k,int l,int r){
        
        if(lazy[k]==ei) return;
        
        dat[k]=g(dat[k],lazy[k]);
        
        if(r-l>1){
            lazy[k*2+1]=h(lazy[k*2+1],lazy[k]);
            lazy[k*2+2]=h(lazy[k*2+2],lazy[k]);
        }
        
        lazy[k]=ei;
    }
    
    void update_(int a,int b,E x,int k,int l,int r){
        
        eval(k,l,r);
        
        if(r<=a||b<=l) return;
        
        if(a<=l&&r<=b){
            lazy[k]=h(lazy[k],x);
            eval(k,l,r);
        }
        
        else{
            update_(a,b,x,2*k+1,l,(l+r)/2);
            update_(a,b,x,2*k+2,(l+r)/2,r);
            dat[k]=f(dat[2*k+1],dat[2*k+2]);
        }
        
    }
    
    void update(int a,int b,E x){
        return update_(a,b,x,0,0,n);
    }
    
    T query_(int a,int b,int k,int l,int r){
        
        eval(k,l,r);
        
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        
        T vl=query_(a,b,2*k+1,l,(l+r)/2);
        T vr=query_(a,b,2*k+2,(l+r)/2,r);
        return f(vl,vr);
    }
    
    T query(int a,int b){
        return query_(a,b,0,0,n);
    }
    
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,Q;cin>>N>>Q;
    
    LazySegmentTree<pair<ll,int>,ll> seg(N,
                                         [](pair<ll,int> a,pair<ll,int> b){return make_pair(a.first+b.first,a.second+b.second);},
                                         [](pair<ll,int> a,ll b){return make_pair(a.first+b*a.second,a.second);},
                                         [](ll a,ll b){return a+b;},
                                         make_pair(0,1),
                                         0);
    
    while(Q--){
        int k;cin>>k;
        if(k==0){
            int a,b,c;cin>>a>>b>>c;
            a--;
            seg.update(a,b,c);
        }else{
            int a,b;cin>>a>>b;
            a--;
            cout<<seg.query(a,b).first<<"\n";
        }
    }
}





Measured memory_bytes: 8884
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char x,y;
    cin >> x >> y;
    if(x == y)
    {
        cout << "=";
    }
    else if(x > y)
    {
        cout << ">";
    }
    else
    {
        cout << "<";
    }

    return 0;
}

Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[200005];
    //bool flag=false,d[100005];
    //int n,ans=0;
    char s[105],t[105],u;
   
   cin >> s >> t;
    
    //for(int i=0;i<n;i++) cin >> s[i];
    //for(int i=0;i<n;i++) cin >> t[i];

   
    
    //cout << (!flag ? "Yes" : "No");
    cout << t << s;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    string s;
    cin >> s;

    map<char, ll> mp;
    rep(i, n) {
        mp[s[i]]++;
    }

    ll t = 0;
    rep(i, n) {
        REP(j, 1, (n - 1 - i) / 2 + 1) {

            if (s[i] != s[i + j] && s[i] != s[i + j * 2] && s[i + j] != s[i + j * 2]) t++;
        }
    }

    ll res = max((ll)0, mp['R'] * mp['G'] * mp['B'] - t);
    cout << res << endl;

    return 0;
}

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

from itertools import accumulate
ac = accumulate(A)
from collections import Counter
c = Counter(ac)

ans = 0
for k,v in c.items():
    if k == 0:
        ans += v * (v + 1) // 2
        continue
    ans += v * (v - 1) // 2

print(ans)


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

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int n,k;

int main()
{
	n=read();k=read();
	printf("%d",(int)ceil(n/(k+0.0)));
	return 0;
}

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

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b, h; scanf("%d %d %d", &a, &b, &h);
	printf("%d", (a+b)*h/2);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) return(gcd(b, a%b));
  return b;
}

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

int main(){

  string s; cin >> s;
  for (int i = 0; i < s.length() - 1; i++)
  {
    if(s[i] == s[i + 1]){
        pr("Bad");
        return 0;
    }
  }
  
  pr("Good");

  return 0;
}


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

using namespace std;

int main(void)
{
    string input_str;
    string rev_str;
    cin >> input_str;

    rev_str = input_str;
    reverse(rev_str.begin(), rev_str.end());

    //回文判定
    if(input_str == rev_str)
    {   
        int str_size = input_str.size();

        rev_str = input_str.substr(0, (str_size-1)/2);
        reverse(rev_str.begin(), rev_str.end());

        if(input_str.substr(0, (str_size-1)/2) == rev_str)
        {
            rev_str = input_str.substr( (str_size+3)/2 - 1);
            reverse(rev_str.begin(), rev_str.end());

            if(input_str.substr( (str_size+3)/2 - 1) == rev_str)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]
dest = [int(x) for x in input().split()]
route = [1]
flag = [1] + [0] * (N-1)
t = 1
while True:
  if flag[dest[t-1]-1] == 0:
    t = dest[t-1]
    route.append(t)
    flag[t-1] = 1
  else:
    loop = route.index(dest[t-1])
    L_loop = len(route) - loop
    break
  #print(route)
  #print(flag)
ans = 0
if K < len(route):
  ans = route[K]
else:
  K = K - len(route)
  ans = route[loop + (K % L_loop)]
print(ans)

Measured memory_bytes: 32252
use proconio::input;

fn main() {
    input! {
        n: i32,
        m: usize,
        a: [i32; m]
    }

    solve(n, &a);
}

fn solve(n: i32, a: &[i32]) {
    let s = n - a.iter().sum::<i32>();

    match s.cmp(&0) {
        std::cmp::Ordering::Less => println!("-1"),
        _ => println!("{}", s),
    }
}


Measured memory_bytes: 2132