akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int n; ll m; scanf("%d%lld",&n,&m);
    vector<ll> a(n);
    rep(i,0,n)scanf("%lld",&a[i]);
    sort(ALL(a));
    ll lb=0,rb=INF;
    while(rb-lb>1){
        ll mid=(lb+rb)/2,cnt=0;
        rep(i,0,n){
            cnt+=n-(lower_bound(ALL(a),mid-a[i])-a.begin());
        }
        if(cnt>=m)lb=mid; else rb=mid;
    }
    vector<ll> b=a;
    rep(i,0,n-1)b[i+1]+=b[i];
    ll res=0,cnt=0;
    rep(i,0,n){
        int idx=(lower_bound(ALL(a),lb-a[i])-a.begin());
        if(idx==n)continue;
        res+=b[n-1]-(idx?b[idx-1]:0)+(n-idx)*a[i]; cnt+=n-idx;
    }
    res-=(cnt-m)*lb; printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 1792
n,m=input().split()
n,m=int(n),int(m)
ab,cd=[],[]
for i in range(n):
    ab1=input().split()
    ab.append((int(ab1[0]),int(ab1[1])))

for i in range(m):
    cd1=input().split()
    cd.append((int(cd1[0]),int(cd1[1])))

for i in range(n):
    c=1
    d=abs(ab[i][0]-cd[0][0])+abs(ab[i][1]-cd[0][1])+1
    for j in range(m):
        if abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])<d:
            c=j+1
            d=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
    print(c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, r; cin >> n >> r;
    if (!n) break;
    V<> a(n);
    iota(begin(a), end(a), 0);
    while (r--) {
      int p, c; cin >> p >> c, --p;
      rotate(begin(a), begin(a) + p, begin(a) + p + c);
    }
    cout << n - a[0] << '\n';
  }
}


Measured memory_bytes: 3036
n=int(input())
table={}
for i in range(n):
    tmp=list(input())
    if tmp[0]=="M" or tmp[0]=="A" or tmp[0]=="R" or tmp[0]=="C" or tmp[0]=="H":
        if tmp[0] in table:
            table[tmp[0]]+=1
        else:
            table[tmp[0]]=1
    else:
        continue
ans=0
for i in table:
    for j in table:
        for k in table:
            if i==j or j==k or k==i:
                continue
            ans+=table[i]*table[j]*table[k]
print(ans//6)

Measured memory_bytes: 45016
n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
ans = 0
ls = [0 for i in range(n+1)]
rs = [0 for i in range(n+1)]
for i in range(n):
  ls[i+1] = ls[i]+v[i]
  rs[i+1] = rs[i]+v[n-i-1]

from heapq import heappush, heappop
for i in range(1, k+1):
  for j in range(1, i+1):
    for k in range(0, j+1):
      menus = []
      l = min(n, k)
      r = min(n-l, j-l)
      for ll in range(l):
        if v[ll]<0:
          heappush(menus, v[ll])
      for rr in range(r):
        if v[n-rr-1]<0:
          heappush(menus, v[n-rr-1])
      cur = ls[l] + rs[r]
      rm = i-l-r
      while rm>0 and len(menus)>=rm:
        rm -= 1
        t = heappop(menus)
        cur -= t
      ans = max(ans, cur)
print(ans)

Measured memory_bytes: 64860
while True:
    n = int(raw_input())
    if n == 0: break
    y = int(raw_input())
    res = []
    for i in range(n):
        b, r, t = map(int, raw_input().split())
        if t == 1:
            p = 1+y*(float(r)/100)
        else:
            p = (1+(float(r)/100))**y
        res.append((p, b))
    else:
        print sorted(res, reverse=True)[0][1]

Measured memory_bytes: 4316
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 X          PIC 9(19).
01 cur        PIC 9(19).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT X.
  MOVE 100 TO cur.
  PERFORM UNTIL X <= cur
    ADD 1 TO ans
    MULTIPLY cur BY 1.01 GIVING cur
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3904
#include<stdio.h>
#include<string.h>
int main(){
  char str[21],tmp[21];
  int a,i,j,x=0;
  scanf("%s",str);
  x = strlen(str);
  for(i=0;i<=x;i++){
    if(i==x){
      tmp[i] = str[i];
    }
    else{
      tmp[x-1-i] = str[i];
    }
  }	
  printf("%s\n",tmp);
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vi a,dp;

int main(){
	cin>>n>>m;
	a=dp=vi(n+1);
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	dp[0]++;
	for(int i=1;i<=n;i++) if(!a[i]) dp[i]=(dp[i-1]+(i>1?dp[i-2]:0))%mod;
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int table[][][] = new int[4][3][10];

    public static void main(String[] args) {
        for (int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for (int k = 0; k < 10; k++){
                    table[i][j][k] = 0;
                }
            }
        }
        for (int i = 0; i < n; i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            table[b - 1][f - 1][r - 1] += v;
        }
        for (int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for (int k = 0; k < 10; k++){
                    System.out.print(" ");
                    System.out.print(table[i][j][k]);
                }
                System.out.println();
            }
            if (i != 3)
            System.out.println("####################");
        }
    }
}



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

using namespace std;

int main() {
  long N, K, Q;
  cin >> N >> K >> Q;
  long A[Q];
  long point[N];
  for (int i = 0; i < Q; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    point[i] = 0;
  }

  for (int i = 0; i < Q; i++) {
    point[A[i] - 1]++;
    // for (int j = 0; j < N; j++) {
    //   if (j != A[i] - 1) {
    //     point[j]--;
    //   }
    // }
  }

  for (int i = 0; i < N; i++) {
    if (K - Q + point[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2176
import sys, os

def f():
    args = list(map(int,input().split()))
    if len(args) > 1:
        return args
    return args[0]

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c,k = f()
    ans = 0
    ac = min(a, k)
    k -= ac
    ans += ac

    bc = min(b, k)
    k -= bc

    cc = min(c, k)
    ans -= cc
    print(ans)
solve()

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

namespace B_015_46
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //new Logic_A().Start();
            new Logic_B().Start();
            Console.ReadLine();
        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var N = Convert.ToInt32(str[0]);
                var K = Convert.ToInt32(str[1]);

                long count = 1;

                for (int i = 1; i <= N; i++)
                {
                    if (i == 1)
                    {
                        count = K;
                    }
                    else if (i > 1)
                    {
                        count = count * (K - 1);
                    }
                }
                Console.WriteLine(count);
            }
        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var a = Convert.ToInt32(str[0]);
                var b = Convert.ToInt32(str[1]);
                var c = Convert.ToInt32(str[2]);

                Console.WriteLine((a == b && a != c || b == c && a != b || c == a && a != b) ?
                    2 : a == b && b == c ? 1 : 3);
            }
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin >> n;
    int a[n],b[n];
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    int ans = 0;
    rep(i,n){
        int res = 0;
        for(int j = 0;j <= i;j++)res += a[j];
        for(int j = i;j < n;j++)res += b[j];
        ans = max(ans,res);

    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,ma,pr;
	cin>>n;
	ma=0;
	pr=0;
	int p[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
		ma=max(ma,p[i]);
		pr+=p[i];
	}
	cout<<pr-ma/2<<endl;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int x;
    cin >> x;

    if (x >= 30)cout << "Yes";
    else cout << "No";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[11], t[11], u[11];
	int n, m;
	scanf("%s %s", s, t);
	scanf("%d %d", &n, &m);
	scanf("%s", u);
	if (strcmp(s, u))
	{
		printf("%d %d", n, m - 1);
	}
	else
	{
		printf("%d %d", n - 1, m);
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int n = 10;
int h[n];

int main()
{
  rep(i, n) cin >> h[i];
  sort(h, h+n, greater<int>());

  cout << h[0] << endl << h[1] << endl << h[2] << endl;

  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	string c[a];
	for (int j=0;j<a;j++) {
		cin >> c[j];
	}
	for (int i=0;i<a;i++) {
		cout << c[i] << endl << c[i] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <climits>
#include <numeric>
#include <algorithm>

using namespace std;

bool all_0(int a, int b, int c){
    return a == b && b == c && c == 0;
}

int main()
{
    int a[3][3] = {};
    map<int, int*> m;
    for(int y = 0; y < 3; ++y){
        for(int x = 0; x < 3; ++x){
            cin >> a[y][x];
            m[a[y][x]] = &a[y][x];
        }
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int b;
        cin >> b;
        if(m.find(b) != m.end()){
            *m[b] = 0;
        }
    }

    for(int x = 0; x < 3; ++x){
        if(all_0(a[0][x], a[1][x], a[2][x])){
            cout << "Yes\n";
            return 0;
        }
    }
    for(int y = 0; y < 3; ++y){
        if(all_0(a[y][0], a[y][1], a[y][2])){
            cout << "Yes\n";
            return 0;
        }
    }
    if(all_0(a[0][0], a[1][1], a[2][2])){
        cout << "Yes\n";
        return 0;
    }
    if(all_0(a[0][2], a[1][1], a[2][0])){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sumAll(n int) int {
	sum := 0
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

func plus(a, b, n int) bool {
	if a <= n && n <= b {
		//		fmt.Println(n)
		return true
	}
	return false
}

func main() {
	var (
		n, a, b, sum int
	)

	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		if plus(a, b, sumAll(i)) {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
signed main(){
    fast_io();
    int X; cin >> X;
    int a = lcm(X,360LL);
    cout << a / X << endl;
    
}




Measured memory_bytes: 3628
#include <stdio.h>

#define SIZE_F 1300000

int furui[SIZE_F];
int prime[100100];

int main() {
	int i, j, k;
	int n;

	for(i = 2, k = 0; i < SIZE_F; i++) {
		if(!furui[i]) {
			for(j = i * 2; j < SIZE_F; j += i) {
				furui[j] = 1;
			}
			prime[k] = i;
			k++;
		}
	}

	while(1) {
		scanf("%d", &n);
		if(!n)
			break;
		int middle;
		int top = k - 1, bottom = 0;

		while(top - bottom > 1) {
			middle = (top + bottom) / 2;
			
			if(prime[middle] == n)
				break;
			else if(prime[middle] > n)
				top = middle;
			else
				bottom = middle;
		}

		if(!furui[n])
			printf("0\n");
		else
			printf("%d\n", prime[top] - prime[bottom]);
	}

	return 0;
}

Measured memory_bytes: 6076
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(" ").map { it.toInt() }
    val map1: Map<Int, Int> = toCountMap(xs.filterIndexed { index, x -> index % 2 == 0 })
    val map2: Map<Int, Int> = toCountMap(xs.filterIndexed { index, x -> index % 2 == 1 })
    val pairs1 = map1.toList().sortedByDescending { it.second }
    val pairs2 = map2.toList().sortedByDescending { it.second }
    var ans = n
    for (p1 in pairs1) {
        val p2 = pairs2[0]
        if (p1.first != p2.first) {
            ans = Math.min(n - p1.second - p2.second, ans)
        } else {
            ans = Math.min(n - p1.second, ans)
            ans = Math.min(n - p2.second, ans)
        }
    }
    for (p2 in pairs2) {
        val p1 = pairs1[0]
        if (p1.first != p2.first) {
            ans = Math.min(n - p1.second - p2.second, ans)
        } else {
            ans = Math.min(n - p1.second, ans)
            ans = Math.min(n - p2.second, ans)
        }
    }
    println(ans)
}

fun toCountMap(xs: List<Int>): Map<Int, Int> {
    val count = mutableMapOf<Int, Int>()
    for (x in xs) {
        if (!count.containsKey(x)) {
            count[x] = 1
        } else {
            count[x] = count[x]!! + 1
        }
    }
    return count
}

Measured memory_bytes: 62136
#include <bits/stdc++.h>
#define ll long long
#define mod (ll)(1e9+7)
#define inf (ll)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue
using namespace std;
typedef pair<ll,ll> P;
signed main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='L'){puts("No");return 0;}
	}
	for(int i=1;i<s.size();i+=2){
		if(s[i]=='R'){puts("No");return 0;}
	}
	puts("Yes");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m,d;cin>>n>>m>>d;
    if(d==0)cout<<fixed<<setprecision(18)<<(m-1.0)/(n*1.0);
    else cout<<fixed<<setprecision(18)<<(2.0*(n-d)*(m-1))/(n*n*1.0);
}

Measured memory_bytes: 256
N = int(input())
rn = [[True]+list(map(int,input().split())) for _ in range(N)]
bn = sorted([list(map(int,input().split())) for _ in range(N)])
rn.sort(key=lambda x: -x[2])
for bp in bn:
  bx,by = bp
  for rp in rn:
    f,rx,ry = rp
    if f and rx<bx and ry<by:
      rp[0] = False
      break
print(sum([0 if rp[0] else 1 for rp in rn]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long X;
    scanf("%lld",&X);
    judge(X>=30)
    return 0;
}


Measured memory_bytes: 3764
object methods {
  def solver(): Unit = {

    val tempList: Seq[Seq[String]] = {
      for (line <- io.Source.stdin.getLines()) yield {
        line.split(' ').toSeq
      }
    }.toSeq
    val N: Int = tempList(0)(0).toInt //電球の個数
    val K: Int = tempList(0)(1).toInt //操作回数
    val initBrightness: Seq[Int] = tempList(1).map(_.toInt)

    //K回更新：いもす法ならこの関数でO((N+N)*K)：ナイーブな解法ならO(N*N*K)
    val kUpBrightness: Seq[Int] = loop(1, K, N, initBrightness)

    //val kUpBrightness: Seq[Int] = UpdateBrightness(N, initBrightness)：いもす法では累積和が答え
    println(kUpBrightness.mkString(" "))
  }

  //K回この操作をする: 照らしている個数のシーケンスを返す
  def UpdateBrightness(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {
    val illuminateNum: Array[Int] = Seq.fill(N)(0).toArray[Int]

    //Mapとかでもできそう。時間制限にひっかかるなら改良
    var i = 0
    while (i < N) {
      //照らす範囲下部分
      val illuminateBottom: Int = {
        if (i - BrightSeq(i) < 0) 0
        else i - BrightSeq(i)
      }
      val illuminateTop: Int = {
        if(i + BrightSeq(i) > BrightSeq.length) BrightSeq.length
        else i + BrightSeq(i)
      }

      //この操作でO(N*N)を作り出している
      illuminateNum.zipWithIndex.foreach{
        case (v, i) => if(illuminateBottom <= i && i <= illuminateTop) illuminateNum(i) = v + 1
      }
      i += 1
    }//while締め
    illuminateNum
  }

  //累積和を使った計算（いもす法）：ランプの左始点に+1ランプの右切れ端に-1
  def UpdateByCumulativeSum(N: Int, BrightSeq: Seq[Int]): Seq[Int] = {
    //記録
    val illuminateNumCount: Array[Int] = Seq.fill(N)(0).toArray[Int]
    var i = 0
    var count: Boolean = true
    while (i < N) {
      val illuminateStart: Int = {
        if (i - BrightSeq(i) < 0) 0
        else i - BrightSeq(i)
      }
      val illuminateOut: Int = {
        if (i + BrightSeq(i) + 1 > BrightSeq.length -1) { //インデックス最大値よりも.lengthは1多い
          count = false
          BrightSeq.length
        } else {
          count = true
          i + BrightSeq(i) + 1
        }
      }
      illuminateNumCount(illuminateStart) += 1
      if (count) illuminateNumCount(illuminateOut) -= 1
      i += 1
    }
    //計測：ここで計算量はO(N+N)
    val cumulativeIlluminateNum: Seq[Int] = illuminateNumCount.scanLeft(0)((x, y) => x+y)
    cumulativeIlluminateNum.drop(1) //累積和の一番最初はいらないのでそれを覗いたSeqを返す
  }

  def loop(k: Int, K: Int, N: Int, Brightness: Seq[Int]): Seq[Int] = {
    val CurrentBrightness = UpdateByCumulativeSum(N, Brightness)

    // 計算時間エラー起こった：O(logN)回の操作で収束するらしい。なにそれってかんじだが41回を上限とする
    if(k < K && k < 42) loop(k+1, K, N, CurrentBrightness)
    else CurrentBrightness
  }

}

object Main extends App {
  methods.solver
}

Measured memory_bytes: 107456
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f+"=7")
            exit()
    else :
        dfs(i+1, f + '-' + s[i+1], sum - int(s[i+1]))
        dfs(i+1, f + '+' + s[i+1], sum + int(s[i+1]))
        
s = input()
dfs(0, s[0], int(s[0]))



Measured memory_bytes: 9100
using System;
using System.Linq;
using static System.Console;

class Program{
	static void Main(){
    	var haa = ReadLine().Split(' ').Select(int.Parse).ToArray();
      	long[] enemies = ReadLine().Split(' ').Select(long.Parse).OrderByDescending(a => a).ToArray();
		long count = 0;
      
      	for(var i = 0;i <haa[0];i++){
        	if(haa[1]>0){
              haa[1]--;
              continue;
            }
          	count = count + enemies[i];
        }
		Write(count);

    }
}

Measured memory_bytes: 43904
program sum_of_large_numbers
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, k, i
  integer(8) :: x = 0, l = -1, r
  read(*,*) n, k
  r = n
  do i = 1, n+1
    if (i >= k) x = modulo(x+r-l,md)
    l = mod(l+i,md)
    r = mod(r+(n-i),md)
  end do
  write(*,'(i0)') x
end program sum_of_large_numbers

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

int main() {
    int n,m,x,res=0;
    cin>>n>>m>>x;
    vector<int> c(n);
    int a[n][m];
    vector<int> d(m);
    rep(i,n) {
        cin>>c[i];
        rep(j,m) cin>>a[i][j];
    }
    int sum;
    rep(i,m) {
        sum=0;
        rep(j,n) {
            sum+=a[j][i];
        }
        if (sum<x) {
            cout<<-1<<endl;
            return 0;
        }
    }
    int ans=100000000;
    bool exist=true;
    for (int bit=0; bit<(1<<n); bit++) {
        int sum=0;
        int res=0;
        rep(j,m) d[j]=0;
        for (int i=0; i<n; i++) {
            if (bit&(1<<i)) {
                sum+=c[i];
                for (int j=0; j<m; j++) {
                    d[j]+=a[i][j];      
                }
            }
        }
        rep(j,m) if (d[j]>=x) res++;
        if (res==m) {
            ans=min(sum,ans);
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<double > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, K;
    cin >> N >> K;

    ll sum = 0;
    vector<double> in;
    vector<double> in2;
    for(ll i = 0; i < N; i++){
        double t; cin >> t;
        in.push_back(t*(t+1)/2 / t);
        in2.push_back(t);
        //cout << in[i] << endl;
    }

    vector<double> r(N+19, 0);
    vector<double> r2(N+19, 0);
    for(ll i = 1; i <= N; i++){
        r[i] = r[i-1] + in[i-1];
        r2[i] = r2[i-1] + in2[i-1];
        //cout << r[i] << endl;
    }

    double ans = -1;
    ll idx = 1;
    for(ll i = K; i <= N; i++){
        //cout << (r[i] - r[idx-1]) << endl; 
        ans = max(r[i] - r[idx-1], ans);
        idx++;
    }

    cout << fixed << std::setprecision(15) << ans << endl;

}

Measured memory_bytes: 6756
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, X, Y = [int(x) for x in input().split()]

    ans = [0] * N
    for i in range(1, N + 1):
        s = collections.deque()
        s.append([i, 0])
        v = set()
        v.add(i)
        while s:
            c = s.popleft()
            ans[c[1]] += 1

            if c[0] == X:
                if Y not in v:
                    s.append([Y, c[1] + 1])
                    v.add(Y)
            if c[0] == Y:
                if X not in v:
                    s.append([X, c[1] + 1])
                    v.add(X)

            if c[0] != 1:
                if c[0] - 1 not in v:
                    s.append([c[0] - 1, c[1] + 1])
                    v.add(c[0] - 1)

            if c[0] != N:
                if c[0] + 1 not in v:
                    s.append([c[0] + 1, c[1] + 1])
                    v.add(c[0] + 1)

    for a in ans[1:]:
        print(a // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64092
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, p[200100], i, ruimin=300000, ans=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> p[i];
    }
    for(i=0;i<n;i++){
        if(p[i]<=ruimin){
            ans++;
            ruimin=p[i];
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    ll K, total = 0;
    cin >> N >> K;
    vector<pair<int, int>> A(N);
    for (int i = 0; i < N; i++)
    {
        pair<int, int> a;
        cin >> a.first >> a.second;
        A[i] = a;
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++)
    {
        total += A[i].second;
        if (K <= total)
        {
            cout << A[i].first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define int ll

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair

#define DEBUG

using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll R, C, N, K;

bool v[15][10005];

ll a[20];

signed main() {

    cin >> N;

    vector<P> pos(N,make_pair(0,0));
    vector<ll> dist(N-1,0);

    rep(i,N){
        cin >> pos[i].first;
        cin >> pos[i].second;
    }

    sort(pos.begin(),pos.end());
    
    double sum = 0;
    int count = 0;
    do{
        count ++;
        rep(i, N-1){
            double x = pos[i].first - pos[i+1].first;
            double y = pos[i].second - pos[i+1].second;
            sum += sqrt(x*x + y*y);
        }
    }while(next_permutation(pos.begin(),pos.end()));

    cout << fixed << setprecision(10) << sum/count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
void dfs(vector< string > &ans, string &now, int m, int x) {
	if (x == N) {
		ans.push_back(now);
		return;
	}
	rep(c, m) {
		now.push_back(c + 'a');
		int nm = 0;
		rep(i, now.size()) chmax(nm, now[i] - 'a' + 1);
		nm++;
		dfs(ans, now, nm, x + 1);
		now.pop_back();
	}
}
signed main() {
	cin >> N;
	vector< string > ans;
	string now = "";
	dfs(ans, now, 1, 0);
	sort(ans.begin(), ans.end());
	rep(i, ans.size()) cout << ans[i] << endl;
	return 0;
}

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

int main(){
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char *argv[])
{
    char s[101],t[101];
    int n;
    scanf("%d",&n);
    scanf("%s %s",s,t);
    for(int i=0;i<n;i++)
        printf("%c%c",s[i],t[i]);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
yen = 1000
kabu = 0
for i in range(n-1):
    yen += kabu * a[i]
    kabu = 0
    if a[i] <= a[i+1]:
        kabu = yen // a[i]
        yen = yen % a[i]
yen += kabu * a[n-1]
print(yen)


Measured memory_bytes: 9176
import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){

        int n = sc.nextInt();
        int t = sc.nextInt();
        int[][] ab = new int[n][2];
        for (int i=0; i<n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            ab[i][0] = a;
            ab[i][1] = b;
        }

        Arrays.sort(ab, (c1, c2)->c1[0]-c2[0]);

//        System.out.println(ab[0][1]);


        PriorityQueue<int[][]> pq = new PriorityQueue<>();
        
        int[] dp = new int[t];
        
        int max = 0;
        
        for (int i=0; i<n; i++){
            int a = ab[i][0];
            int b = ab[i][1];
            max = Math.max(max, dp[t-1]+b);
            
            for (int j=t-1; j>=0; j--){
                if (j>=a){
                    dp[j] = Math.max(dp[j], dp[j-a]+b);
                }
            }
        }
        System.out.println(max);


    }
}

Measured memory_bytes: 32260
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n,min_s=100000,cnt=0;
    long long v;
    cin >> n;
    vector<int> V(n);
    for(int i=0;i<n;i++) cin >> V[i];
    
    for(int i=0;i<n;i++){
        v = V[i];
        cnt = 0;
        while(1){
            if(v % 2 != 0) break;
            v /= 2;
            cnt++;
        }
        if(min_s>cnt) min_s = cnt;
    }
    cout << min_s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
ll a[100000];
int main()
{
	IO;
	ll n;
	ll tmp=100;
	int cnt=1;
	a[0]=tmp;
	while(tmp<=2e18){
		tmp=tmp+tmp/100;
		a[cnt++]=tmp;
	}
	cin>>n;
	int ans=lower_bound(a,a+cnt,n)-a;
	cout<<ans<<endl;
 	return 0;
}







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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int a,b;
    cin>>a>>b;
    if(a+b<10){
        cout<<a+b<<endl;
    }else{
        cout<<"error"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = in.nextInt();
		int b = in.nextInt();

		if (a == 1)
			a += 13;
		if (b == 1)
			b += 13;
		if (a > b) {
			System.out.println("Alice");
		} else if (b > a) {
			System.out.println("Bob");
		} else {
			System.out.println("Draw");
		}

	}
}

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

n = int(readline())
s = readline().decode().rstrip()

cost = [0]*n
cost[0] = s[1::].count('E')
if s[0] == 'W':
    cost[1] += 1

for i in range(1, n):
    if s[i] == 'E':
        cost[i] += cost[i - 1] - 1
    else:
        cost[i] += cost[i - 1]
        if i < n - 1:
            cost[i + 1] += 1

print(min(cost))

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

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

    int n;cin >> n;
    vector<int> a(n), b(n);
    vector<bool> exist(n+1, false);
    string ans = "Yes";
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++){
        cin >> b[i];
        if(exist[b[i]]) ans = "No";
        exist[b[i]] = true;
    }

    cout << ans << endl;
    if(ans == "No"){
        for(int i=0;i<n;i++){
            cout << a[0];
            if(i != n-1){
                cout << " ";
            }
        }
        cout << endl;

        for(int i=0;i<n;i++){
            if(exist[a[i]]){
                cout << a[0];
            }else{
                cout << a[1];
            }
            if(i != n-1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = 0;
        for(int j = 1; j <= (int)sqrt(i); j++){
            for(int k = j; k <=(int)sqrt(i); k++){
                for(int l = k; l <= (int)sqrt(i); l++){
                    if(((j+k) * (j+k) + (k+l) * (k+l) + (j+l) * (j+l))/2.0 == i){
                        int x,y,z;
                        int temp = j+k+l;
                        x = temp/2 - (k+l); 
                        y = temp/2 - (j+l);
                        z = temp/2 - (k+j);
                        if(x == y && y == z) ans++;
                        else if(x == y && y != z) ans += 3;
                        else if(x == z && y != z) ans += 3;
                        else if(y == z && x != z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 3616
import sys
readline = sys.stdin.readline

def main():
    W, H, N = map(int, readline().rstrip().split())
    p = [[1] * W for _ in range(H)]
    for _ in range(N):
        x, y, a = map(int, readline().rstrip().split())
        if a == 1:
            for yi in range(H):
                for xi in range(x):
                    p[yi][xi] = 0
        elif a == 2:
            for yi in range(H):
                for xi in range(x, W):
                    p[yi][xi] = 0
        elif a == 3:
            for xi in range(W):
                for yi in range(y):
                    p[yi][xi] = 0
        else:
            for xi in range(W):
                for yi in range(y, H):
                    p[yi][xi] = 0
    
    print(sum([sum(l) for l in p]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for ai in a:
    cnt = sum(aij * bi for aij, bi in zip(ai, b))
    ans += (cnt > -c)
print(ans)


Measured memory_bytes: 62228
#include<iostream>
int main()
{
	int n;
	std::cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		std::cin >> a;
		int cnt = 0;
		while (a % 2 == 0)
		{
			cnt++;
			a >>= 1;
		}
		ans += cnt;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A<=C && C<=B) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for(int i=0; i<H; i++) cin >> S.at(i);
  int ans = 10001;
  for(int i=0; i<pow(2,H-1); i++){
    int temp = i;
    int bordercount = 0;
    vector<bool> line(H);
    for(int j=0; j<H-1; j++){
      if(temp%2!=0){
        line.at(j)=1;
        bordercount++;
      }
      temp/=2;
    }
    vector<int> dp(H);
    int linecount = 0;
    for(int j=0; j<W; j++){
      int cnt = 0;
      for(int k=0; k<H; k++){
        if(S.at(k).at(j)=='1') dp.at(cnt)++;
        if(dp.at(cnt)>K){
          linecount++;
          for(int l=0; l<H; l++) dp.at(l)=0;
          cnt =0;
          for(int l=0; l<H; l++){
            if(S.at(l).at(j)=='1') dp.at(cnt)++;
            if(line.at(l)) cnt++;
          }
          for(int l=0; l<H; l++){
            if(dp.at(l)>K) linecount=10001;
          }
          cnt=0;
          break;
        }
        if(line.at(k)) cnt++;
      }
    }
    ans = min(ans, linecount+bordercount);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a+b+c;
  int x = max({a,b,c}) ;
  int y = sum - x;
  if(x == y) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3608
from collections import namedtuple

Edge = namedtuple('Edge', ('fr', 'to', 'cost'))
inf = 1e9


def bf(n, s, es):
    d = [inf for _ in range(n)]
    d[s] = 0
    while True:
        updated = False
        for e in es:
            if d[e.fr] != inf and d[e.fr] + e.cost < d[e.to]:
                updated = True
                d[e.to] = d[e.fr] + e.cost

        if not updated:
            break

    return d


n = int(input())

m = [[-1 for _ in range(n)] for _ in range(n)]
es = []
for i in range(n):
    fs = list(map(int, input().split()))
    ne = fs[1]
    for j in range(ne):
        v = fs[2+2*j]
        c = fs[2+2*j+1]
        m[i][v] = c
        es.append(Edge(i, v, c))


d = bf(n, 0, es)
for (i, di) in enumerate(d):
    print(i, di)


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

string s;
int a[500001], b, c;

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

	cin >> s;
	for(int i=0; i<s.size(); ++i) {
		a[i]+=(s[s.size()-1-i]-'0')*9;
		a[i+1]=a[i]/10;
		a[i]%=10;
		b+=a[i];
	}
	b+=a[s.size()];
	for(; b>c; ++c) {
		for(int i=0; ; ++i) {
			if(a[i]>8) {
				a[i]=0;
				b-=9;
			} else {
				++a[i];
				++b;
				break;
			}
		}
	}
	cout << (c+8)/9;
}

Measured memory_bytes: 2844
#include <iostream>

using namespace std;

long A[300][300];
long d[300][300];

void WarshallFloyd(int size){
    //init
    for(int i = 0; i < size ; i++){
        for(int j = 0; j < size; j++){
            d[i][j] = A[i][j];
        }
    }
    for(int k = 0; k < size; k++){
        for(int i = 0; i < size ; i++){
            for(int j = 0; j < size; j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int N;
    cin >> N;
    bool same = true;
    for(int i = 0; i < N; i++){
        for(int j = 0; j< N;j++){
            cin >> A[i][j];
        }
    }
    WarshallFloyd(N);
    for(int i = 0; i < N ; i++){
        for(int j = 0; j < N; j++){
            if(d[i][j] != A[i][j]){
                same = false;
            }
        }
    }
    if(same){
        long ans = 0;
        bool deleted[300][300];
        for(int i = 0; i < N ; i++){
            for(int j = 0; j < N; j++){
                ans += A[i][j];
                deleted[i][j] = false;
            }
        }
        
        for(int k = 0; k < N ; k++){
            for(int i = 0; i < N ; i++){
                for(int j = 0; j < N; j++){
                    if(A[i][j] == A[i][k]+ A[k][j] && deleted[i][j] == false && i!= k && j!=k){
                        ans -= A[i][j];
                        deleted[i][j] = true;
                    }
                }
            }
        }
        cout << ans/2 << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1792
program main

  implicit none
  integer :: N, i, j, k
  character(50) :: S 

  read(*,*) N
  read(*,*) S
  
  j = 0
  do i = 0, N
    if ( S(i:i+2) == "ABC" ) then
      j = j + 1
    end if
  end do
  print*, j

    
end program main


Measured memory_bytes: 640
// Last Change: 04/07/2019 13:23:46.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  int ans = 0;
  for (int k = 1; k <= N; k += 2) {
    int cnt = 0;
    for (int i = 1; i <= k; ++i) {
      if (k % i == 0) {
        ++cnt;
      }
    }
    if (cnt == 8) {
      ++ans;
    }
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

int main(){
  ios_base::sync_with_stdio(false);
  string s,ans="";
  cin >> s;
  for(int i=0;i<s.size();i+=2){
    ans += s[i];
  }

  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define pqueue priority_queue
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    int K; cin>>K;
    int N; cin>>N;
    vin A(N);
    fin(N,A);
    vin dist(N);
    rep(0,N-1){
        dist.at(i)=A.at(i+1)-A.at(i);
    }
    dist.at(N-1)=K-A.at(N-1)+A.at(0);
    sort(dist.begin(),dist.end());
    int sum=0;
    rep(0,N-1){
        sum+=dist.at(i);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int read();
int n, L, res;
int x[300005], t[300005], del[300005];
int l[300005], r[300005];
int main() {
    n = read(), L = read(), res = n + 1;
    for (int i = 1; i <= n; ++i) x[i] = read();
    for (int i = 1; i <= n; ++i)
        res += (t[i] = read()) / (L << 1), t[i] %= L << 1;
    for (int i = 1; i <= n; ++i) {
        if (!t[i]) {
            --res, del[i] = 1;
            continue;
        }
        del[i] = !((l[i] = 2 * (L - x[i]) >= t[i]) | (r[i] = 2 * x[i] >= t[i]));
    }

    res -= l[n];
    int sum = 0, top = 0, pos = n;
    for (int i = 1; i < n; ++i) {
        if (del[i]) continue;
        if (!l[i]) {
            pos = i;
            break;
        }
        r[i] ? ++top : (top ? --top, --res : 0);
    }

    sum += top, top = 0;
    for (int i = n - 1; i >= pos; --i) {
        if (del[i]) continue;
        l[i] ? ++top : (top ? --top, --res : 0);
    }
    printf("%lld\n", 2ll * L * (res -= sum + top >> 1));
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,y=0;
  int a[109];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  for(int i=0;i<n;i++){
    if(i%2==0)x+=a[i];
    else y+=a[i];
  }
  cout<<x-y<<endl;
  return(0);
}

Measured memory_bytes: 256