akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e+7;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
struct Segtree{
    int n,hi;
    vector<ll> node,lazy;
    Segtree(int n_){
        n=1;hi=1;
        while(n<n_)n<<=1,++hi;
        node.assign(2*n,-LINF);
        lazy.assign(2*n,0);
    }
    ll eval(int k){
        node[k]=(node[k]==-LINF?lazy[k]:node[k]+lazy[k]);
        if(lazy[k]==0)return node[k];
        if(k<n){
            lazy[k<<1]+=lazy[k];
            lazy[k<<1|1]+=lazy[k];
        }
        lazy[k]=0;
        return node[k];
    }
    void update(int a,int b,ll x){
        int l=a+n,r=b+n;
        for(int i=hi;i>0;i--)eval(l>>i),eval(r>>i);
        for(++r;l<r;l>>=1,r>>=1){
            if(l&1)lazy[l++]+=x;
            if(r&1)lazy[--r]+=x;
        }
        l=a+n,r=b+n;
        while(l>>=1)node[l]=max(eval(l<<1),eval(l<<1|1));
        while(r>>=1)node[r]=max(eval(r<<1),eval(r<<1|1));
    }
    ll query(int a,int b){
        int l=a+n,r=b+n;
        for(int i=hi;i>0;i--)eval(l>>i),eval(r>>i);
        ll vl=-LINF,vr=-LINF;
        for(++r;l<r;l>>=1,r>>=1){
            if(l&1)vl=max(vl,eval(l++));
            if(r&1)vr=max(eval(--r),vr);
        }
        return max(vl,vr);
    }
};
int main(){
    int n,m;cin>>n>>m;
    vector<vector<ll>> l(n+10);
    vector<vector<P>> r(n+10);
    for(int i=0;i<m;i++){
        int l1,r1,a;cin>>l1>>r1>>a;
        l[l1].push_back(a);
        r[r1].push_back(P(a,l1));
    }
    ll ans=0;
    Segtree tree(n+10);
    for(int i=1;i<=n;i++){
        for(auto a:l[i]){
            tree.update(0,i-1,a);
        }
        ll dp=tree.query(0,i-1);
        ans=max(ans,dp);
        tree.update(i,i,dp);
        for(auto a:r[i]){
            tree.update(0,a.second-1,-a.first);
        }
    }
    cout<<ans<<endl;
}   


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

public class Main {
	
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		if(A == 1) A = 14;
		int B = sc.nextInt();
		if(B == 1) B = 14;
		System.out.println(A == B ? "Draw" : (A > B) ? "Alice" : "Bob");
	}
}

Measured memory_bytes: 22740
import sys
from collections import deque

n = int(sys.stdin.readline())
linked_list = deque([])

for i in range(n):
    line = sys.stdin.readline().split()
    cmd = line[0]

    if len(line) == 2:
        value = line[1]

    if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop()

print(*linked_list)

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

int main() {
  int N; cin >> N;
  int S[110];
  int total_score = 0, mn_score = 100;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    total_score += S[i];
    if (S[i] % 10 >= 1)
      mn_score = min(mn_score, S[i]);
  }
  
  if (total_score % 10 >= 1)
    cout << total_score << endl;
  else if (mn_score != 100)
    cout << total_score - mn_score << endl;
  else // tototal_score % 10 == 0 && mn_score == 100
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * Task_A.cpp
 * 
 * Copyright 2020 Dell <Dell@HP>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */


#include <bits/stdc++.h>
int main(int argc, char **argv)
{
	int s, w;
	scanf("%d%d", &s, &w);
	if(s < w || s == w){
		printf("unsafe");
	}
	else if(s > w){
		printf("safe");
	}
	
	return 0;
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
    return 0;
}


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

using namespace std;

const int inf = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    for (int &x : a) cin >> x;
    vector <int> dp(n);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for (int j = 2; j <= k; j++) {
            if (i - j < 0) continue;
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }
    cout << dp[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 1152
n, d = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(n)]

from math import sqrt

res = 0
for i in range(n-1):
    for j in range(i+1, n):
        r2 = sum([(points[i][k]-points[j][k])**2 for k in range(d)])
        if r2 == int(sqrt(r2))**2:
            res += 1
print(res)



Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int a;
	scanf("%d", &a);
	a = a % 10;
	if (a == 3)
	{
		printf("bon");
	}
	else if (a == 0 || a == 1 || a == 6 || a == 8)
	{
		printf("pon");
	}
	else
	{
		printf("hon");
	}
    return 0;
}

Measured memory_bytes: 1732
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var w = new int[n];
        var b = new int[n];
        b[0] = s[0] == '#' ? 1 : 0;
        w[n - 1] = s[n - 1] == '.' ? 1 : 0;
        for (int i = 1; i < n; i++)
        {
            if (s[i] == '#') b[i] = b[i - 1] + 1;
            else b[i] = b[i - 1];
            var t = n - 1 - i;
            if (s[t] == '.') w[t] = w[t + 1] + 1;
            else w[t] = w[t + 1];
        }
        Console.WriteLine(getAns(b, w, s, n));
    }
    static int getAns(int[] b, int[] w, string s, int n)
    {
        var ans = int.MaxValue;
        for (int i = 0; i < n; i++)
            ans = Min(ans, w[i] + b[i] - 1);
        return ans;
    }
}

Measured memory_bytes: 13280
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] != t[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  int ans=0;
  vector<vector<int>> A(10,vector<int>(10));
  for(int i=0;i<=N;i++){
    string S=to_string(i);
    A[S[0]-'0'][S[S.size()-1]-'0']++;
  }
  for(int i=1;i<10;i++)
    for(int j=1;j<10;j++)
      ans+=A[i][j]*A[j][i];
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits.h>
#include<set>
#include<map>
#include<string.h>
#include<queue>
#include<math.h>
using namespace std;

int main(){
    int h,w;
    char m[9][9];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>m[i][j];
        }
    }
    bool v[9][9];
    memset(v, 0, sizeof(v));
    int x=0,y=0;
    while(1){
        v[y][x]=1;
        if(x<w-1&&m[y][x+1]=='#'){
            x++;
            continue;
        }
        if(y<h-1&&m[y+1][x]=='#'){
            y++;
            continue;
        }
        break;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(m[i][j]=='#'&&v[i][j]==0){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    cout<<"Possible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


int main() {
    string s,t;
    cin >> s >> t;

    print(t + s);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin(n);
    incin2(a,b);

    int ans = 0;
    for(int i=1;i<=n;i++){
        int d = Digit(i);
        if(a <= d && d <= b){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  string s,t;
  int count=0;
  cin >> s;
  cin >> t;
  rep(i,3){
    if(s[i] == t[i]) count++;
  }
  cout << count << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}



Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, K;
	cin >> N >> K;
	VI A(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	for (int i = K; i < N; i++) {
		if (A[i] > A[i - K])cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <queue>
#include <map>
using namespace std;
 
class Point2{
public:
    int tx;
    int ty;
    int kx;
    int ky;
};
 
int mk(Point2 p)        
{
    return (((p.tx-1)*50+(p.ty-1))*50+(p.kx-1))*50+(p.ky-1);
}
 
int main()
{
    while(true){
        int W, H;
        cin >> W >> H;
 
        if(W==0 && H==0)
            break;
 
        Point2 p;
        cin >> p.tx >> p.ty;
        cin >> p.kx >> p.ky;
 
        int d[52][52];
        for(int y=0; y<=H+1; y++){
            for(int x=0; x<=W+1; x++){
                d[y][x] = 1;           
            }
        }
 
        for(int y=1; y<=H; y++){
            for(int x=1; x<=W; x++){
                cin >> d[y][x];
            }
        }
 
        queue<Point2> que;        
        que.push(p);
 
        map<int, int> n;        
        n[mk(p)] = 0;
 
        while(true){
            if(que.empty()){           
                cout << "NA" << endl;
                break;
            }
 
            p = que.front();
            que.pop();
 
            if(n[mk(p)]>=100){      
                cout << "NA" << endl;
                break;
            }
 
            if(p.tx==p.kx && p.ty==p.ky){       
                cout << n[mk(p)] << endl;
                break;
            }
 
            Point2 q;
 
            q = p;
            if(d[q.ty][q.tx+1]==0){
                q.tx = q.tx+1;
            }
            if(d[q.ky][q.kx-1]==0){
                q.kx = q.kx-1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty][q.tx-1]==0){
                q.tx = q.tx-1;
            }
            if(d[q.ky][q.kx+1]==0){
                q.kx = q.kx+1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty+1][q.tx]==0){
                q.ty = q.ty+1;
            }
            if(d[q.ky-1][q.kx]==0){
                q.ky = q.ky-1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty-1][q.tx]==0){
                q.ty = q.ty-1;
            }
            if(d[q.ky+1][q.kx]==0){
                q.ky = q.ky+1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
        }
    }
 
    return 0;
}


Measured memory_bytes: 11472
from itertools import zip_longest

abcd = input()

n = 3
op_li = [0] * 2**n

for i in range(2**n):
  op = ["-"] * n
  for j in range(n):
    if (i >> j) & 1 == 1:
      op[j] = "+"
  op_li[i] = op

for i in op_li:
  siki = ""
  for j, k in zip_longest(i, abcd, fillvalue=""):
    siki += k+j
  if eval(siki) == 7:
    print(siki + "=7")
    exit()

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

int main() {
  int n;
  cin >> n;
  vector<int>x(n);
  rep(i,n) cin >> x[i];
  int sum = 0;
  rep(i,n) sum +=x[i];
  int mean = (sum+n)/n;
  int mean_2 = sum/n;
  int ans = 0;
  int res = 0;
  rep(i,n) {
    ans += (x[i]-mean)*(x[i]-mean);
    res += (x[i]-mean_2)*(x[i]-mean_2);
  }
  cout << min(ans, res) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n, x;
    cin >> n >> x;;
    vector<ll> L(n);
    for (auto& l : L) {
        cin >> l;
    }
    ll d = 0;
    ll i = 1;
    for (; i <= n; ++i) {
        d += L[i-1];
        if (d > x) break;
    }
    cout << i << endl;
}


Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007//10^9+7
#define PI acos(-1)

using namespace std;


static int come[100010];
int solonum=0;
int cnt=0;
static vector<int> graph[100010];
int solo[100010];
static vector<int> subtree[100010];


int search(int x){
	int i;

	if(come[x]==1) return 0;

	come[x]=1;

	subtree[cnt].push_back(x);

	for(i=0;i<graph[x].size();i++){
		search(graph[x][i]);
	}

	return 0;
}


struct cost_t {
	int idnum;
	int cost;
} ;

int compare_cost(const void *a, const void *b) {
	struct cost_t *A = (struct cost_t *)a;
	struct cost_t *B = (struct cost_t *)b;
	return A->cost - B->cost;
}

struct subtree_min_t {
	int idnum;
	int cost;
} ;

int compare_min(const void *a, const void *b) {
	struct subtree_min_t *A = (struct subtree_min_t *)a;
	struct subtree_min_t *B = (struct subtree_min_t *)b;
	return A->cost - B->cost;
}

int main(void)
{
	//変数の宣言
	int n,m;
	int x,y;
	//	vector<int> graph[100010];
	//	int solo[100010];
	multiset<int> maintree;
	static int use[100010];
	static struct cost_t ct[100010];
	static int inv[100010];
	//	vector<int> subtree[100010];
	//	static int come[100010];
	static struct cost_t memo[100010]; 
	int mt;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	//	int cnt=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;



	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	for(i=0;i<n;i++){
		scanf("%d",&ct[i].cost);
//		scanf_s("%d",&ct[i].cost);
		ct[i].idnum=i;
	}

	qsort(ct, n, sizeof(struct cost_t), compare_cost);

	for(i=0;i<n;i++){
		inv[ct[i].idnum]=i;
	}

	for(i=0;i<m;i++){
		scanf("%d %d",&x,&y);
//		scanf_s("%d %d",&x,&y);
		graph[inv[x]].push_back(inv[y]);
		graph[inv[y]].push_back(inv[x]);
	}

	for(i=0;i<n+1;i++){
		come[i]=0;
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	i=0;
	while(i<n){
		search(i);
		cnt++;

		while(1==come[i]){
			i++;
		}
	}

	for(i=0;i<cnt;i++){
		for(j=0;j<subtree[i].size();j++){
			memo[j].idnum=subtree[i][j];
			memo[j].cost=ct[subtree[i][j]].cost;
		}

		qsort(memo, subtree[i].size(), sizeof(struct cost_t), compare_cost);
		ans=ans+memo[0].cost;
		for(j=1;j<subtree[i].size();j++){
			maintree.insert(subtree[i][j]);
		}
	}

	if(cnt==1){
		printf("0");
		return 0;
	}else if(cnt>2&&maintree.size()<cnt-2){
		printf("Impossible");
		return 0;
	}else{
		auto itr=maintree.begin();
		for(i=0;i<cnt-2;i++){
			mt=*itr;
			ans=ans+ct[mt].cost;
			++itr;
		}
	}



	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	long long res=0;
  int ans=0;
	for(int i=0;i<s.length();i++)
	{
	   // cout<<s[i]<<'\n';
	    if(s[i]=='B')
	    {
	        ans++;
	    }
	    else{
	        res+=ans;
	       // ans=0;
	    }
	}
    cout<<res;
	return 0;
}


Measured memory_bytes: 720
using System;

    public class Problem_A
    {
        public static void Main()
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int m = inputs[0], d = inputs[1];
            var ans = m - 1;
            if (d >= m) ans++;
            Console.WriteLine($"{ans}");
        }
    }


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	long long x,y;
	cin>>x>>y;
	if(x%y==0)cout<<-1<<endl;
	else for(int i=1;;i++){
		if(x*i%y!=0)cout<<x*i<<endl;break;
	}
	return 0;
}


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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<typename T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<typename T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<typename T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<typename T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<typename T> T &onth(T &a, const T &b){ return a = ont(a, b); }

template<typename T> T make_v(T val){ return val; }
template<typename... Ts> auto make_v(size_t n, Ts... ts){ return std::vector<decltype(make_v(ts...))>(n, make_v(ts...)); }

int a, b, c, d, e, f;

int main(){
	int left = 0, right, top, bottom = 0, n;
	scanf("%d%d%d", &right, &top, &n);

	RC(i, n){
		int x, y, a;
		scanf("%d%d%d", &x, &y, &a);
		switch(a){
			case 1:
				anth(left, x);
				break;
			case 2:
				onth(right, x);
				break;
			case 3:
				anth(bottom, y);
				break;
			case 4:
				onth(top, y);
				break;
		}
	}

	printf("%d\n", ant(right - left, 0) * ant(top - bottom, 0));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	int a;
	int i;
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=0;i<9;i++){
			cin>>a;
			n-=a;
		}
		cout<<n<<endl;
	}
	return 0;
}

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

struct NODE { int key; NODE *pa, *ri, *le; };
NODE *NIL, *root;

void insert(int k)
{
	NODE *z, *x = root, *y = NIL;

	z = new NODE;
	z->key = k;
	z->le = NIL;
	z->ri = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
			x = x->le;
		else
			x = x->ri;
	}

	z->pa = y;

	if (y == NIL)
		root = z;
	else
	{
		if (z->key < y->key)
			y->le = z;
		else
			y->ri = z;
	}
}

void preorder(NODE *u)
{
	if (u == NIL)return;
	cout << " " << u->key;
	preorder(u->le);
	preorder(u->ri);
}

void inorder(NODE *u)
{
	if (u == NIL)return;
	inorder(u->le);
	cout << " " << u->key;
	inorder(u->ri);
}

void find(int k)
{
	NODE *s = root;
	while (s != NIL)
	{
		if (s->key == k)
		{
			cout << "yes" << endl; return;
		}
		else if (s->key > k)
			s = s->le;
		else
			s = s->ri;
	}
	cout << "no" << endl;
}

int main()
{
	string str;
	int i, n, k;
	cin >> n;
	
	for (i = 0; i < n; i++)
	{
		cin >> str;
		if (str[0] == 'i')
		{
			cin >> k;
			insert(k);
		}
		else if (str[0] == 'f')
		{
			cin >> k;
			find(k);
		}
		else  if (str[0] == 'p')
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		
	}
	return 0;
}


Measured memory_bytes: 21872
//a.c A-Still TBD
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>

int main(void){
    char buf[11];
    char *ptr;
    scanf("%s",buf);
    bool flag = true;

    ptr = strtok(buf,"/");
    int year = atoi(ptr);
    if(year>2019){
        flag = false;
    }
    ptr = strtok(NULL,"/");
    int month = atoi(ptr);
    if(month>4){
        flag = false;
    }
    ptr = strtok(NULL,"/");
    int day = atoi(ptr);
    if(month==4&&day>30){
        flag = false;
    }
    if(flag){
        printf("Heisei\n");
    }else{
        printf("TBD\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;


typedef unsigned long long ULL;

const int N = 2345;

vector<int> t[N];
int k;

int dfs(int v, int prev_v, int depth, int depth_limit) {
//	cout << "dfs" << endl;
//	cout << v << " " << prev_v << " " << depth << " " << depth_limit << endl;
	int r = 1;
	if (depth < depth_limit)
		for (size_t i = 0; i < t[v].size(); i++)
			if (t[v][i] != prev_v)
				r += dfs(t[v][i], v, depth + 1, depth_limit);
//	cout << "returning " << r << endl;
	return r;
}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		t[a].push_back(b);
		t[b].push_back(a);
	}

//	cout << k << endl;

	int res = 0;
	if (k % 2 == 0) // single root
		for (int i = 1; i <= n; i++)
			res = max(res, dfs(i, 0, 0, k / 2));
	else
		for (int i = 1; i <= n; i++)
			for (auto j : t[i])
				res = max(res, dfs(i, j, 0, k / 2) + dfs(j, i, 0, k / 2));
	cout << n - res << endl;
}


Measured memory_bytes: 512
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict

stacks = defaultdict(list)   # Key String, Value List

n,q = map(int, sys.stdin.readline().split())
for i in range(q):
    query = sys.stdin.readline().split()  # use in string
    ope = query[0]
    stack_id = query[1]

    if ope == '0':      # Push
        stacks[stack_id].append(query[2])
    elif ope == '1':    # Top
        if stacks[stack_id]:
            print(stacks[stack_id][-1])
    elif ope == '2':    # Pop
        if stacks[stack_id]:
            stacks[stack_id].pop()




Measured memory_bytes: 20100
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String u, nl = System.getProperty("line.separator");
		StringBuilder 
			p = new StringBuilder(1000),
		  	d = (new StringBuilder(100)).append("."),
		  	s = (new StringBuilder(100)).append("#"),
		  	k = new StringBuilder(100);
		Scanner r = new Scanner(System.in);
		int h, w, ww = 0x10;
		while (0 != (ww >>= 1)) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while (0 != ((h = r.nextInt()) | (w = r.nextInt()))) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww = d.length();
			}
			p.append(u = s.substring(0, w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			while (2 != h--) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18388
from itertools import combinations, product,cycle
from fractions import gcd
from collections import defaultdict

left = 0
right = 0
for i,value in enumerate(input().split(" ")):
    if i == 0 or i == 1:
        left += int(value)
    else:
        right += int(value)
if left > right:
    print("Left")
elif  left < right:
    print("Right")
else:
    print("Balanced")

Measured memory_bytes: 5692
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int x,y,a,b;
    cin>>a>>b;
   if(a == 1 or a == 3 or a == 5 or a == 7 or a == 8 or a == 10 or a == 12) x = 1;
      if(b == 1 or b == 3 or b == 5 or b == 7 or b == 8 or b == 10 or b == 12) y =1;
      if(a == 4 or a == 6 or a == 9 or a == 11) x =2;
      if(b == 4 or b == 6 or b == 9 or b == 11) y=2;
      if(a == 2) x = 3;
        if(b == 2) y = 3;
      if(x == y)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, x, y, a;
  cin >> n >> x >> y;
  vector<int> cnt(n); 
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      
      a = min(j - i, abs(x - (i + 1)) + 1 + abs((j + 1) - y));
      cnt[a]++;
    }
  }
  
  for(int i = 1; i < n; i++){
    cout << cnt[i] <<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(15) << w*h/2 << endl;
	
	if(x+x == w && y+y == h){
		cout << "1" << endl;
	}else{
		cout << "0" << endl;
	}
	return 0;
}

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int N,b;
  vector<int> h;

  cin >> N;

  vector<int> costs(N+1);

  REPI(N)
  {
    cin >> b;
    h.push_back (b);
    costs[i] = INT_MAX;
  }
  
  costs[0] = 0;
  costs[1] = abs(h[0]-h[1]);


  for (int i=2;i<N;i++)
  {
    costs[i] = min (costs[i-1] + abs(h[i]-h[i-1]), costs[i-2] + abs(h[i]-h[i-2]));
  }

  cout << costs[N-1] << endl;

  return 0;
}

Measured memory_bytes: 4248
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n;
		scanf("%d",&n);
		if (n>=30) printf("Yes");
		else printf("No");
		puts(" ");
 
return 0;
}  

/*
               
 

*/


Measured memory_bytes: 3836
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

x = inp()

a = x // 500
b = (x - a*500) // 5

print(a*1000 + b*5)

Measured memory_bytes: 31232
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    vector<pair<ll,ll> >v;
    ll n; cin>>n;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb({i,n/i});
        }
    }
    ll x=v[v.size()-1].first;
    ll y=v[v.size()-1].second;
    cout<<(x-1)+(y-1);
}


Measured memory_bytes: 3652
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,M = LMIIS()
    print(N*(N-1)//2+M*(M-1)//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool hoge(pll a, pll b) {
	if(a.fi > b.fi) return true;
	else return false;
}
bool fuga(ll a, ll b) {
	if (a>b) return true;
	else return false;
}

int main() {
	int N,M;
	cin >> N >> M;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	sort(a.begin(),a.end());
	vector<pll> b(M);
	ll bt,ct;
	//cout << "test";
	rep(i,M) {
		cin >> bt >> ct;
		b[i] = pll(ct,bt);
	}
	//cout << "test2" << endl;
	sort(b.begin(), b.end(), greater<pll>());
	int count = 0;
	vector<ll> c;
	rep(i,M) {
		rep(j, b[i].se) {
			c.pb(b[i].fi);
			count++;
		}
		if(count >= N) break;
	}
	sort(c.begin(), c.end(), greater<ll>()); 
	rep(i,min(N,count)) {
	//rep(i,N) {
		if(a[i] >= c[i]) break;
		a[i] = c[i];
	}
	ll ans = 0;
	rep(i,N) ans += a[i];
	cout << ans << endl;
	
  return 0;
}

Measured memory_bytes: 4340
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

const int N = 100'009;

int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  reverse(a, a + n);
  vector<pair<int, int>> res;
  int ans = a[n - 1];
  for (int i = 1; i < n - 1; ++i) {
    if (a[i] > 0) {
      res.emplace_back(ans, a[i]);
      ans -= a[i];
    }
  }
  res.emplace_back(a[0], ans);
  ans = a[0] - ans;
  for (int i = 1; i < n - 1; ++i) {
    if (a[i] <= 0) {
      res.emplace_back(ans, a[i]);
      ans -= a[i];
    }
  }
  printf("%d\n", ans);
  assert((int)res.size() == n - 1);
  for (auto &e : res) {
    printf("%d %d\n", e.first, e.second);
  }
}


Measured memory_bytes: 3188
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

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

class DCake123 {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int X, Y, Z, K;
        in>>X>>Y>>Z>>K;
        vc<lint> A(X), B(Y), C(Z), D, E;
        for(auto& a : A) in>>a;
        for(auto& b : B) in>>b;
        for(auto& c : C) in>>c;
        REP(i, X) REP(j, Y) D.pb(A[i]+B[j]);
        sort(RALL(D));
        if(LEN(D)>K) D.erase(D.begin()+K, D.end());
        for(auto& d : D) REP(k, Z) E.pb(d+C[k]);
        sort(RALL(E));
        REP(i, K) out<<E[i]<<'\n';
    }
};


int main() {
	DCake123 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 44084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int a = cin.Int();
			string s = cin.Next();
			if (a >= 3200) {
				Console.WriteLine(s);
			} else {
				Console.WriteLine("red");
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MAX = 4000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,k;
	cin>>n>>k;
	COMinit();
	
	for(int i=1;i<=k;i++){
		cout<<COM(k-1,i-1)*COM(n-k+1,i)%MOD<<endl;
	}
	
	
}
	


Measured memory_bytes: 384
using System;
using System.Linq;

class Program {
  static void Main() {
    var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
    if (a[0] + a[1] == a[2]) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 13396
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    
    int n = sc.nextInt();

    int cnt = 0;
    
    for(int i = 1; i <= n; i++){
      cnt += i;
    }
    
    System.out.print(cnt);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int ans = 0, num = 0;
	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		ans += l;
		num = max(num, l);
	}
	if (num < ans - num) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main()
{
    ll n,t,a,b,c,d,e,p,q,cnt=0;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;

    cin>>t;

    ll ac=0,tle=0,wa=0,re=0;
    while(t--){
        cin>>s;
        if(s=="AC"){
            ac++;
        }
        else if(s=="TLE"){
            tle++;
        }
        else if(s=="WA"){
            wa++;
        }
        else if(s=="RE"){
            re++;
        }



    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;


}


Measured memory_bytes: 3640
fun main(args: Array<String>) {

    val (H, N) = readLine()!!.split(" ").map(String::toDouble)

    var i : Int = 0
    readLine()!!.split(" ").map(String::toInt).forEach {
        i+=it
    }

    println(if(i>=H){"Yes"}else{"No"})
}

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

int main(){
  int a;
  cin >> a;
  vector<string> srtr(a);
  rep(i, a) cin >> srtr.at(i);
  string ans = "Yes";
  bool flag = true;
  while (flag){
    rep(i, a){
      rep(j, i - 1){
        if (srtr.at(i) == srtr.at(j)){
          ans = "No";
          flag = false;
        }
      }
    }
    rep(i, a - 1){
      if (srtr.at(i).at(srtr.at(i).size() - 1) != srtr.at(i + 1).at(0)){
        ans = "No";
        flag = false;
      }
    }
    flag = false;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
char s[200001];
long long a[200000];
long long rui[200000];
long long b[200001];
long long ans, n, p, x;
int main() {
	scanf("%lld%lld", &n, &p);
	scanf(" %s", s );
	for (long long i = 0; i < n; i++) {
		a[i] = s[i] - '0';
	}
	rui[0] = 1;
	for (long long i = 1; i < 200000; i++) {
		rui[i] = rui[i - 1] * 10 % p;
	}
	if (p == 2) {
		for (long long i = 0; i < n; i++) {
			if (a[i] % 2 == 0)ans += i + 1;
		}
		printf("%lld\n", ans);
		return 0;
	}
	if (p == 5) {
		for (long long i = 0; i < n; i++) {
			if (a[i] % 5 == 0)ans += i + 1;
		}
		printf("%lld\n", ans);
		return 0;
	}
	for (int i = 0; i < n; i++) {
		b[i + 1] = b[i] + rui[n - 1 - i] * a[i];
		b[i + 1] %= p;
	}
	std::sort(b, b + n + 1);
	x = 1;
	for (int i = 1; i <= n; i++) {
		if (b[i] == b[i - 1])x++;
		else {
			ans += x * (x - 1) / 2;
			x = 1;
		}
	}
	ans += x * (x - 1) / 2;
	printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector<ll>
ll n,m;
void deb(string s, ll vl){
  cout<<s<<" : "<<vl<<"\n";
}
void prv(vct v){
  for(ll i=0;i<v.size();i++)cout<<v[i]<<" ";
  cout<<"\n";
}

void solve(){
  cin>>n;
  n==0?cout<<"1\n":cout<<"0\n";
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll t;
  t=1;
  // cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=1e5+10;
int k;
vector<ll>s;
void bfs()
{
	queue<ll>q;
	for(ll i=1;i<10;i++)
	{
		q.push(i);
	}
	while(!q.empty()&&SZ(s)<N)
	{
		ll x=q.front();
		s.pb(x);
		q.pop();
		ll d=x%10;
		if(d==0){
			q.push(10*x);
			q.push(10*x+1);
		}
		else if(d==9){
			q.push(10*x+8);
			q.push(10*x+9);
		}
		else{
			q.push(10*x+d-1);
			q.push(10*x+d);
			q.push(10*x+d+1);
		}
	}
	sort(all(s));
}
int main(){
	scanf("%d",&k);
	bfs();
	printf("%lld",s[k-1]);
    return 0;
}


Measured memory_bytes: 2548
/***********************************************
 *                                             *
 *   author: raghav_0901 (Raghav Dalmia)       *
 *   updated on: 27-06-2020,  5:53:37 pm IST   *
 *                                             *
\***********************************************/

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define endl '\n'
#define f(i, begin, end) \
    for (__typeof(end) i = (begin); i != (end) - (begin > end); i += 1 - 2 * ((begin) > (end)))
#define ff(i, begin, end, fl) \
    for (__typeof(end) i = (begin); i != (end)(begin > end) && fl; i += 1 - 2 * ((begin) > (end)))
#define int long long int

const int mod = INT_MAX;
const int N = (1e7) + 1;
// const int N = 10;

int arr[N];

void precompute( )
{
    for (int i = 2; i <= N; i++) arr[i] = 2;
    for (int i = 2; i < N; i++)
    {
        for (int j = i << 1; j <= N; j += i) { arr[j]++; }
        arr[i] *= i;
    }
}

signed main( )
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    precompute( );

    int n;
    cin >> n;
    int ans = 1;
    for (int i = 2; i <= n; i++) { ans += arr[i]; }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81772
// 1_abc132_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<char> s(4);
    rep(i, 4){
        cin >> s[i];
    }
    sort(s.begin(), s.end());

    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
int main(){
    ll a,b,c,d;
    ll ans[5];
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    ans[0] = a*c;
    ans[1] = a*d;
    ans[2] = b*c;
    ans[3] = b*d;
    int i,j;
    ll swap;
    for(i=0;i<4;i++){
        for(j=i+1;j<4;j++){
            if(ans[i] > ans[j]){
                swap = ans[i];
                ans[i] = ans[j];
                ans[j] = swap;
            }
        }
    }
    printf("%lld\n",ans[3]);
    return 0;
}

Measured memory_bytes: 1728