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

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine(); // String sを受け取る
		sc.close(); // 標準入力を終了

		String s2 = s.replace("0", ""); // 0を空白に置き換え

		// 残った1の個数を出力
		System.out.println(s2.length());
	}

}

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

idx = A.index(1)

ans = N
for k in range(K + 1):
    L = idx - (K - k - 1)
    R = (N - 1 - idx) - k
    cntL = 0
    cntR = 0
    while L > 0:
        cntL += 1
        L -= K - 1
    while R > 0:
        cntR += 1
        R -= K - 1
    ans = min(ans, cntL + cntR + 1)

print(ans)


Measured memory_bytes: 52732
while (n = gets.to_i) != 0 do
  ss = gets.split.map(&:to_i)
  m = ss.reduce(:+).to_f / ss.size
  alpha_2 = ss.map{|s| (s - m) ** 2}.reduce(:+)  / ss.size
  puts Math.sqrt(alpha_2)
end

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

int ok1[2010], ok2[2010], ok3[2010];

bool check(string &a, int p1, string &b, int p2) {
	while (p1 < a.size() && p2 < b.size()) {
		if (a[p1] != b[p2] && a[p1] != '?' && b[p2] != '?') return 0;
		p1++, p2++;
	}
	return 1;
}

int solve(string a, string b, string c) {
	for (int i = 0; i <= a.size(); i++) {
		ok1[i] = check(a, i, b, 0);
	}
	for (int i = 0; i <= b.size(); i++) {
		ok2[i] = check(b, i, c, 0);
	}
	for (int i = 0; i <= a.size(); i++) {
		ok3[i] = check(a, i, c, 0);
	}
	int ans = 0x3f3f3f3f;
	for (int i = 0; i <= a.size(); i++) {
		for (int j = 0; j <= b.size() || i + j <= a.size(); j++) {
			if (ok1[i] && (j > b.size() || ok2[j]) && (i + j > a.size() || ok3[i + j])) {
				ans = min(ans, (int)max(a.size(), max(i + b.size(), i + j + c.size())));
			}
		}
	}
	return ans;
}

int main () {
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	sort(s, s + 3);
	int ans = 0x3f3f3f3f;
	do {
		ans = min(ans, solve(s[0], s[1], s[2]));
	} while (next_permutation(s, s + 3));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  vi a(3);
  rep(i,3){
    cin>>a[i];
  }
  sort(all(a));
  cout<<a[2]*10+a[0]+a[1]<<endl;


}

Measured memory_bytes: 256
from collections import defaultdict

def main():
    left, right = map(int, input().split())
    mod = 2019

    aaa = defaultdict(int)
    for i in range(left, min(right + 1, left + 5000)):
        aaa[i % mod] += 1

    score_sorted = list(sorted(aaa.items(), key=lambda x: x[0]))

    # print(score_sorted)

    ans = 2019
    for i in range(len(score_sorted)):
        if score_sorted[i][1] >= 2:
            ans = min(ans, (score_sorted[i][0] * score_sorted[i][0]) % mod)
        for j in range(i + 1, len(score_sorted)):
            ans = min(ans, (score_sorted[i][0] * score_sorted[j][0]) % mod)

    print(ans)







if __name__ == '__main__':
    main()


Measured memory_bytes: 41968
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> W(N);
  for(int i=0;i<N;i++)cin>>W[i];

  int ans=INF;
  for(int i=0;i<N;i++){
    int tmp=0;
    for(int j=0;j<N;j++){
      if(j<=i){
        tmp+=W[j];
      }else{
        tmp-=W[j];
      }
    }
    ans=min(ans,abs(tmp));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
    fast_cin();
    int N,M,K;
    cin>>N>>M>>K;
    cout<<min(N*M,K);
    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("No"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 10000000, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int h,w,r,c;
  scanf("%d%d%d%d",&h,&w,&r,&c);
  bool sw = false;
  if (h%r == 0) {
    swap(h,w);
    swap(r,c);
    sw = true;
  }
  if (h%r == 0) dame;
  int x = MX-1, y = -MX;
  vvi a(h,vi(w));
  rep(i,h)rep(j,w) {
    if (i%r == 0 && j%c == 0) a[i][j] = x;
    if (i%r == r-1 && j%c == c-1) a[i][j] = y;
  }

  puts("Yes");
  if (sw) {
    swap(h,w);
    vvi b(h,vi(w));
    swap(a,b);
    rep(i,h)rep(j,w) a[i][j] = b[j][i];
  }
  rep(i,h) cout<<a[i]<<endl;
  return 0;
}






















Measured memory_bytes: 4480
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	cin >> k;
	ll n = 50;
	vector<ll> a(n, k/n + n - 1);
	k %= n;
	rep(i,n){
		if(i < k) ++a[i];
		else a[i] -= k;
	}
	cout << n << endl;
	rep(i,n) cout << a[i] << " ";
	cout << endl;
	return 0;
}

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

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

	s.at(k-1) += 32;

	cout << s << endl;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
	int A,B;
	ll X, tmp;
	cin >>X;
	A = 0;
	int flug = 0;
	rep(i, 100) {
		rep(j, i) {
			if ((i*i*i*i*i+j*j*j*j*j) == X) {
				flug = 1;
				A = i;
				B = j * (-1);
				break;
			}
		}
	}
	while (flug == 0) {
		A++;
		B = A-1;
		tmp = 0;
		while (flug == 0) {
			tmp = (A + B) * (A*A*A + B*B*B) + A * A * B * B;
			if ((X % tmp == 0) && ((X / tmp) == (A - B))) {
				flug = 1;
				break;
			}
			if (B<=1)break;
			else B--;
		}
	}
		
		
	cout << A << " " << B;

	
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    n%=10;
    if(n==3) cout<<"bon";
    else if(n==0 || n==1 || n==6 || n==8) cout<<"pon";
    else cout<<"hon";

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define e(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,q,p;long long x[110],y[110],z[110],a[110][2],b[110][2],c[110][2],s;
int main(){
	cin>>n>>q;
	e(i,2*n){cin>>x[i]>>y[i]>>z[i];
		a[i/2][i%2]=x[i],b[i/2][i%2]=y[i],c[i/2][i%2]=z[i];
	}sort(x,x+n*2);sort(y,y+n*2);sort(z,z+n*2);s=0;
	e(i,n*2-1)e(j,n*2-1)e(k,n*2-1){p=0;
	e(t,n){bool o=1;e(r,2){
		if(a[t][0]>x[i+r]||x[i+r]>a[t][1])o=0;
		if(b[t][0]>y[j+r]||y[j+r]>b[t][1])o=0;
		if(c[t][0]>z[k+r]||z[k+r]>c[t][1])o=0;
	}if(o)p++;
	}if(p>=q)s+=(x[i+1]-x[i])*(y[j+1]-y[j])*(z[k+1]-z[k]);
}cout<<s<<endl;
return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <stdio.h>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;
// ??????: a.x*b.x
double dot_product(xy_t a, xy_t b) { 
  return (conj(a)*b).real(); 
}
// ??????: a.x*b.y - b.x*a.y
// ????§???¢????¬????????????¢????????????
double cross_product(xy_t a, xy_t b) { 
  return (conj(a)*b).imag(); 
}
// ?????±: ????????¨ p ??????????????´?????? b ????????±
xy_t projection(xy_t p, xy_t b) { 
  return b*dot_product(p,b)/norm(b); 
}
xy_t P[110];
int main() {
  int N=0;
  double x, y;
  while (scanf("%lf,%lf", &x, &y) != EOF) {
    P[N++] = xy_t(x,y);
  }
  // ??¢????¨????
  double sum = 0.0;
  for (int i=0; i+2<N; ++i) {
    xy_t a=P[0], b=P[i+1], c=P[i+2];
    // ????§???¢ abc ?????¢??????????¨?
    sum += fabs(cross_product(c-a,c-b))/2;
  }
  printf("%.6f\n", abs(sum));
}

Measured memory_bytes: 1244
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n, k; cin >> n >> k;
	vector<ll> v; v.resize(n+1);
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		for (int j = 0; j < d; j++) {
			int tt; cin >> tt;
			v[tt]++;
		}
	}
	int res = 0;
	for (int i = 1; i <=n; i++) {
		if (v[i] == 0)res++;
	}
	cout << res;
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[,] dp = new int[5, 4001];
            dp[0, 0] = 1;

            for (int i = 1; i <= 4; i++)
            {
                for (int j = 0; j <= 4000; j++)
                {
                    if (dp[i - 1, j] <= 0) continue;

                    for (int k = 0; k <= 1000 && j + k <= 4000; k++)
                    {
                        dp[i, j + k] += dp[i - 1, j];
                    }
                }
            }

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int n = int.Parse(input);

                sb.AppendLine(dp[4, n].ToString());
            }
            Console.Write(sb);
        }
    }
}

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

using namespace std;

long long best(long long a, long long b){
	long long answer = 1LL << 60;
	for (int i = 0; i <= a; ++i){
		long long c = a - i;
		long long t = b * i;

		if (c % 2 == 0 || b % 2 == 0){
			answer = min(answer, abs(c * b / 2 - t));
		}
		else{
			long long x = c / 2 * b, y = (c + 1) / 2 * b;
			answer = min({answer, max({t, x, y}) - min({t, x, y})});
			x = b / 2 * c, y = (b + 1) / 2 * c;
			answer = min({answer, max({t, x, y}) - min({t, x, y})});	
		}
	}
	return answer;
}

int main(){
	long long w, h;
	cin >> w >> h;

	long long answer = min( best(w, h), best(h, w) );
	cout << answer << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n;
  cin >> n;

  string s = "ACGT";
  string t[64];
  rep(i, 4) rep(j, 4) rep(k, 4) {
    t[16*i + 4*j + k].push_back(s[i]);
    t[16*i + 4*j + k].push_back(s[j]);
    t[16*i + 4*j + k].push_back(s[k]);
  }

  map<string, ll> num;
  string x[64];
  int cnt = 0;
  rep(i, 64) {
    if (t[i] != "AGC" && t[i] != "GAC" && t[i] != "ACG") {
      num.insert(make_pair(t[i], cnt));
      x[cnt] = t[i];
      cnt++;
    }
  }
  

  ll a[64][110] = {};
  rep(i, 64) a[i][3] = 1;
  rep(i, n - 3) {
    rep(j, cnt) {
      bool use[4] = {true, true, true, true};
      if (x[j][0] == 'A' && x[j][1] == 'G') use[1] = false;
      if (x[j][0] == 'A' && x[j][2] == 'G') use[1] = false;
      if (x[j][1] == 'A' && x[j][2] == 'G') use[1] = false;
      if (x[j][1] == 'A' && x[j][2] == 'C') use[2] = false;
      if (x[j][1] == 'G' && x[j][2] == 'A') use[1] = false;
      rep(k, 4) {
	if (use[k]) {
	  string w;
	  w.push_back(x[j][1]);
	  w.push_back(x[j][2]);
	  w.push_back(s[k]);
	  a[num.at(w)][4 + i] += a[num.at(x[j])][3 + i];
	  a[num.at(w)][4 + i] %= MOD;
	}
      }
    }
  }
  ll ans = 0;
  rep(i, cnt) {
    ans += a[i][n];
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// abc130b.cpp : Bounding
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define ote(x) cout<<(x)<<endl

int main(){
	int l, n, x; cin>>n>>x;
	vi d(n+1);
	rp(i,n){ cin>>l; d[i+1] = d[i] + l; }
	int c = 0; rp(i,n+1) if(d[i]<=x) c++;
	ote(c);
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> subordinates(N+1, 0);

    for(int I = 2; I <= N; I++){
        int boss;
        cin >> boss;
        subordinates[boss]++;
    }

    for(int I = 1; I <= N; I++)
        cout << subordinates[I] << "\n";

    return 0;

}



Measured memory_bytes: 4048
/* Filename: ABC073B.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int total = 0;
			int N = input.nextInt();
			
			while(N > 0){
				int l = input.nextInt();
				int r = input.nextInt();
				
				total += r - l + 1;
				
				--N;
			}
			
			System.out.println(total);
		}
	}

}


Measured memory_bytes: 25576
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  int n, a, b;
  cin >> n >> a >> b;
  string ans[2] = {"Alice", "Borys"};
  cout << ans[abs(a - b) % 2] << endl;
  return 0;
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


int main()
{
  li n;
  cin>>n;
  li a[10000];

  li mi = 10000000000L, ma = -10000000000L, ave = 0;

  for (li i=0;i<n;i++) {
    cin>>a[i];
    ave+=a[i];
    mi=min(mi,a[i]);
    ma=max(ma,a[i]);
  }

  cout << mi << " " << ma << " " << ave << endl;

  return 0;
}



Measured memory_bytes: 3192
import heapq

N = int(input())

a = []
for n in range(N):
    sp = input().split()
    s = sp[0]
    p = int(sp[1])
    heapq.heappush(a, (s, -p, n))

while len(a)>0:
    _, _, i = heapq.heappop(a)
    print(i+1)


Measured memory_bytes: 3060
#!/usr/bin/env python3

def main():
    A, B, C, X, Y = map(int, open(0).read().split())
    
    S = []
    for i in range(0, 2*max(X, Y)+1):
        S.append(A*max(0, X - i//2) + B*max(0, Y - i//2) + C*i)
    print(min(S))

main()

Measured memory_bytes: 11032
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  
  int a, b, c, d;  
  cin >> a >> b >> c;

  c = (a + b) * (a + b - 1) / 2;
  
  d = c - a * b;
  cout << d << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    cout<<(x*(x+1))/2<<endl;
    return 0;
}


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

vector<int> getvec(vector<int> v, int m){
    vector<int> buf;
    int n = v.size();
    for(int i=0;i<n;i++){
        if(i != m)buf.push_back(v[i]);
    }
    return buf;
}

bool isok(vector<int> v){
    int d = v[1] - v[0];
    int s = v.size();
    for(int i=1;i<s-1;i++){
        if(v[i+1]-v[i] != d)
            return false;
    }
    return true;
}

int solve(int n,vector<int> v){
    for(int i=0;i<n;i++){
        if(isok(getvec(v,i))){
            return v[i];
        }
    }
}



int main(){
    while(true){
        vector<int> v;
        int n;
        cin >> n;
        if(n == 0)break;
        n++;
        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            v.push_back(tmp);
        }
        cout << solve(n,v) << endl;
    }
    return 0;
}

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

#define int long long
#define double long double

const int INF = 2147483647;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-18;

using namespace std;

int n;
int a[200001], b[200001];
int ca[200001], cb[200001];
int l, r;

signed main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	for (int i = 1; i <= n; i++) {
		if (ca[i] + cb[i] > n) {
			cout << "No" << endl;
			return 0;
		}
	}

	reverse(b, b + n);

	l = INF;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			l = min(l, i);
			r = i;
		}
	}

	cout << "Yes" << endl;

	for (int i = l; i <= r; i++) {
		int tmp = b[i];
		b[i] = b[ (i + (n / 2)) % n ];//(r - l + 1) <= n/2,otherwise answer does not exits
		b[ (i + (n / 2)) % n ] = tmp;
	}

	for (int i = 0; i < n; i++) {
		cout << b[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 9804
import bisect
import sys

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

index = bisect.bisect_left(x,0)

if x[0] >= 0 :
  print(x[k-1])
  sys.exit()
  
if x[-1] <= 0 :
  print(x[n-k]*(-1))
  sys.exit()

ans = 10**9
if min(index+k,n) == index+k :
  ans = x[index+k-1]

if max(0,index-k) == index - k :
  ans = min(ans,x[index-k]*(-1))
  
c = 0
for i in range(index,min(index+k,n)) :
  c += 1
  if i <= n-1 and i-(k-1) <= n-1 and i-(k-1) >= 0 :
    ans = min(ans,x[i]*2+x[i-(k-1)]*(-1))

c = 0
for i in range(max(0,index-k),index) :
  c += 1
  if i <= n-1 and i+(k-1) <= n-1 :
    ans = min(ans,x[i]*(-1)*2+x[i+(k-1)])
  
print(ans)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<20;
bool ok;
map<string,ll> MA;
ll molecule(string S,int &i);
ll atom(string S,int &i);
ll number(string S,int &i);

ll molecule(string S,int &i){
    ll res=0;
    while(i<S.size()){
        if(S[i]=='('){
            i++;
            ll plus=molecule(S,i);
            ll kake=number(S,i);
            res+=plus*kake;
        }else if(S[i]==')'){
            i++;
            break;
        }else{
            ll plus=atom(S,i);
            if(i<S.size()&&'0'<=S[i]&&S[i]<='9'){
                res+=plus*number(S,i);
            }else{
                res+=plus;
            }
        }
    }
    
    return res;
}

ll atom(string S,int &i){
    string T;
    T+=S[i];
    i++;
    
    if('a'<=S[i]&&S[i]<='z'){
        T+=S[i];
        i++;
    }
    if(MA.count(T)) return MA[T];
    else{
        ok=false;
        return 0;
    }
}

ll number(string S,int &i){
    ll res=0;
    while('0'<=S[i]&&S[i]<='9'){
        res*=10;
        res+=S[i]-'0';
        i++;
    }
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;cin>>S;
        if(S=="END_OF_FIRST_PART") break;
        ll a;cin>>a;
        MA[S]=a;
    }
    
    while(1){
        string S;cin>>S;
        if(S=="0") break;
        int i=0;
        ok=true;
        ll res=molecule(S,i);
        if(!ok) cout<<"UNKNOWN"<<endl;
        else cout<<res<<endl;
    }
}





Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define INT long long
using namespace std;
INT n, a[200020], ans, b[1<<19], c[200020], base;
string s;
INT getXor(int s, int e)
{
    s+=base, e+=base;
    INT ret = 0;
    while( s <= e )
    {
        if( s%2 == 1 ) ret ^= b[s], s++;
        if( e%2 == 0 ) ret ^= b[e], e--;
        s>>=1, e>>=1;
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for( base = 1 ; base < n ; base<<=1 );
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    c[0] = a[0];
    for(int i = 0 ; i < n ; i++ ) c[i] = c[i-1]+a[i];
    for(int i = 0 ; i < n ; i++ ) b[base+i] = a[i];
    for(int i = base-1 ; i > 0 ; i-- ) b[i] = b[2*i]^b[2*i+1];
    for(int i = 0 ; i < n ; i++ )
    {
        int lb = i, ub = n-1, md;
        while( lb < ub )
        {
            md = (lb+ub+1)/2;
            if( getXor(i, md) == (c[md]-c[i-1]) ) lb = md;
            else ub = md-1;
        }
        INT cnt = ub-i+1;
        ans += cnt;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <map>
#define pb push_back
#define ll long long
using namespace std;
int n,W,a,b;
typedef struct
{
    ll w,v,q;
 }triplet;
vector<triplet> v;
ll knapSack(ll W,ll n)
{
   int i,j;
   ll dp[n+1][W+1];
   for (i=0;i<=n;i++)
   {
       for(j=0;j<=W;j++)
       {
           if (i==0 || j==0)
               dp[i][j]=0;
           else if(v[i-1].w<=j)
                 dp[i][j]=max(v[i-1].v+dp[i-1][j-v[i-1].w],dp[i-1][j]);
           else
                 dp[i][j]=dp[i-1][j];
       }
   }
   return dp[n][W];
}
int main()
{
    int i;
    cin>>n>>W;
    for(i=1;i<=n;i++)
    {
          triplet t;
          cin>>t.w>>t.v;
          t.q=t.v/t.w;
          v.push_back(t);
    }
    cout<<knapSack(W,n);
    return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> >g(1e5 + 5);
vector<int>vis(1e5 + 5, 0);
vector<int>dp(1e5 + 5, 0);
void dfs(int u){
    if(g[u].size() == 0){
        dp[u] = 0;
    }
    else{
        for(int i = 0; i < g[u].size(); i++){
            int v = g[u][i];
            if(vis[v] == 0){
                vis[v] = 1;
                dfs(v);
            }
            dp[u] = max(dp[u], dp[v] + 1);
        }
    }
}
int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0){
            vis[i] = 1;
            dfs(i);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

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

int mincoin(int a) {
  int i, j, k, l, n;
  l = a/500;
  k = (a%500)/100;
  j = (a%100)/50;
  i = (a%50)/10;
  n = i+k+j+l;
  return n;
}
  


int main() {
  int price, a, b, c, d, i, j, k, l, p, q, r, s, change, num, tempnum;
  cin >> price;
  if (price == 0) return 0;
  while(1){
    cin >> a >> b >> c >> d;
    num = 60;
    for(i=0; i<=a; i++)
      for(j=0; j<=b; j++)
	for(k=0; k<=c; k++)
	  for(l=0; l<=d; l++)
	    {
	      if ((change = i*10+j*50+k*100+l*500 - price) >= 0) {
		tempnum = mincoin(change) - i - j - k - l;
		if (tempnum < num)
		  {
		    num = tempnum;
		    p = i;
		    q = j;
		    r = k;
		    s = l;
		  }
	      }
	    }
    if (p > 0) cout << "10 " << p << endl;
    if (q > 0) cout << "50 " << q << endl;
    if (r > 0) cout << "100 " << r << endl;
    if (s > 0) cout << "500 " << s << endl;
    cin >> price;
    if (price == 0) return 0;
    cout << endl;
  }
}

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


#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    ll           long long
const ll N = 10e5+1;



void fio()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}



int main()
{
    boost;
    fio();
    ll t = 1;
    // cin >> t;
    while (t--) {
     	int n;
     	cin>>n;
        int a[n], b[n], c[n];

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


        
        int dp[3]= { a[0], b[0], c[0]};
        
        // cout<<dp[0]<<' '<<dp[1]<<' '<<dp[2]<<'\n';

        for(int i=1;i<n;i++){
            int temp[3]={0,0,0};
            temp[0] =max(a[i]+dp[1], a[i]+dp[2]);
            temp[1] =max(b[i]+dp[2], b[i]+dp[0]);
            temp[2] =max(c[i]+dp[0], c[i]+dp[1]);
            
        	dp[0]=temp[0];
        	dp[1]=temp[1];
        	dp[2]=temp[2];
        	
        // 	cout<<dp[0]<<' '<<dp[1]<<' '<<dp[2]<<'\n';
        }

        int ans= max(dp[0], dp[1]);
        ans= max(dp[2],ans);
        cout<<ans;



     	


      }

    return 0;
}


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

#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    int mx = 26000;
    int h,w; cin>>h>>w;
    int a[h][w];
    int b[h][w];
    int c[h][w];
    REP(i,h) REP(j,w) cin>>a[i][j];
    REP(i,h) REP(j,w) cin>>b[i][j];
    // cout<<b[0][0]<<endl;
    REP(i,h) REP(j,w) c[i][j] = abs( a[i][j] - b[i][j] );
    // cout<<c[4][4]<<endl;
    bool dp[h][w][mx];
    // cout<<c[0][0]<<endl;
    dp[0][0][c[0][0]]=true;
    REP(i,h){
        REP(j,w){
            if(i==0 && j==0) continue;
            REP(k,mx){
                if(j!=0 && dp[i][j-1][k]) {
                    dp[i][j][k+c[i][j]] = true;
                    dp[i][j][abs(k-c[i][j])] = true;
                }
                if(i!=0 && dp[i-1][j][k]){
                    dp[i][j][k+c[i][j]] = true;
                    dp[i][j][abs(k-c[i][j])] = true;
                }
            }

        }
    }
    REP(i,mx){
        if(dp[h-1][w-1][i]){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 162560
n = int(input())
l = []
l.append(list(map(int, input().split())))
l.append(list(map(int, input().split())))
ans = 0
for i in range(n):
  if sum(l[0][:i+1]) + sum(l[1][i:n]) > ans:
    ans = sum(l[0][:i+1]) + sum(l[1][i:n])
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int x[5];

int main(void){
	int pos=0;
	for(int i=0;i<5;i++){
		scanf("%d",&x[i]);
		if(x[i]==0){
			pos=i+1;
		}
	}
	printf("%d\n",pos);
	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int N=S.size();
    int ok=1;
    for (int i=0;i<N;++i){
        if (S[i]!=S[N-1-i]) ok=0;
    }
    for (int i=0;i<(N-1)/2;++i){
        if (S[i]!=S[(N-1)/2-1-i]) ok=0;
    }
    for (int i=0;i<(N-1)/2;++i){
        if (S[i+(N+3)/2-1]!=S[N-1-i]) ok=0;
    }
    cout << (ok?"Yes":"No") << '\n';
}

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

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

  vector<int> a(n);
  int cnt[3];
  fill_n(cnt, 3, 0);  
  for ( int i = 0; i < n; i++ ) cin >> a[i], cnt[a[i]%3]++;
  
  int tmp[3];
  for ( int i = 0; i < 3; i++ ) tmp[i] = cnt[i];

  int ans = 1;
  if ( cnt[1] ) {
    int sum = 1;
    int cnt1 = 1+cnt[0];
    cnt[1]--;
    cnt[0] = 0;
    while ( 1 ) {     
      if ( sum == 1 ) {
	if ( cnt[1] <= 0 ) break;
	cnt1++;
	sum++;
	sum %= 3;
	cnt[1]--;
      } else if ( sum == 2 ) {
	if ( cnt[2] <= 0 ) break;
	cnt1++;	
	sum += 2;
	sum %= 3;
	cnt[2]--;	
      }
    }
    if ( sum == 1 && cnt[2] ) cnt1++;
    else if ( sum == 2 && cnt[1] ) cnt1++;

    ans = max(ans, cnt1);    
  }

  for ( int i = 0; i < 3; i++ ) cnt[i] = tmp[i];
  if ( cnt[2] ) {
    int sum = 2;
    int cnt1 = 1+cnt[0];    
    cnt[2]--;
    cnt[0] = 0;
    while ( 1 ) {
      if ( sum == 1 ) {
	if ( cnt[1] <= 0 ) break;
	cnt1++;
	sum++;
	sum %= 3;
	cnt[1]--;
      } else if ( sum == 2 ) {
	if ( cnt[2] <= 0 ) break;
	cnt1++;
	sum += 2;
	sum %= 3;
	cnt[2]--;	
      }
    }
    if ( sum == 1 && cnt[2] ) cnt1++;
    else if ( sum == 2 && cnt[1] ) cnt1++;
    ans = max(ans, cnt1);    
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4680
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
n,a,b = map(int,input().split())
A = [1 for _ in range(2*10**5+1)]
for i in range(2,2*10**5+1):
    A[i] = (A[i-1]*i)%p
B = [1 for _ in range(2*10**5+1)]
B[2*10**5] = pow(A[2*10**5],p-2)
for i in range(2*10**5-1,1,-1):
    B[i] = (B[i+1]*(i+1))%p
cnt = pow(2,n)-1
cnt1 = 1
for i in range(a):
    cnt1 = (cnt1*(n-i))%p
cnt1 = (cnt1*B[a])%p
cnt2 = 1
for i in range(b):
    cnt2 = (cnt2*(n-i))%p
cnt2 = (cnt2*B[b])%p
cnt = (cnt-cnt1-cnt2)%p
print(cnt)

Measured memory_bytes: 105304
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

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


Measured memory_bytes: 3600
import java.util.Scanner;

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

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

    // ========================================================================= //
    char[][] f;
    int h, w;

    public void init() {
        h = sc.nextInt();
        w = sc.nextInt();
        f = new char[h][];
        for (int i = 0; i < h; i++) {
            f[i] = sc.next().toCharArray();
        }
    }

    public void solve() {
        char[][] res = new char[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (f[i][j] == '#') {
                    res[i][j] = '#';
                    continue;
                }

                int n = 0;
                for (int y = i - 1; y <= i + 1; y++) {
                    for (int x = j - 1; x <= j + 1; x++) {
                        if (y >= 0 && y < h && x >= 0 && x < w) {
                            if (f[y][x] == '#') {
                                n++;
                            }
                        }
                    }
                }
                res[i][j] = (char)(n + '0');
            }
        }

        for (int i = 0; i < h; i++) {
            System.out.println(String.valueOf(res[i]));
        }
    }
}


Measured memory_bytes: 22996
fn main() {
    let input = read_line_as_vector::<i32>();
    let mut input_iter = input.iter();
    let a = input_iter.next().unwrap();
    let b = input_iter.next().unwrap();

    println!("{}", std::cmp::max(0, a-2*b));
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()

int di[5];
int vis[5];
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;

    while (m--)
    {
        int s,c;
        cin>>s>>c;
        if (s==1&&c==0) 
            if (n==1) {vis[s]=1;} 
            else {cout<<-1<<'\n'; return 0;}
        if (vis[s]) 
            if (c==di[s]) continue;
            else {cout<<-1<<'\n'; return 0;}
        else {di[s]=c; vis[s]=1;}
    }
    
    /*
    if (n==2&&di[1]==0) {cout<<-1<<'\n'; return 0;}
    if (n==2&&di[1]==0&&di[2]==0) {cout<<-1<<'\n'; return 0;}
    if (n==2&&di[1]==0) {cout<<-1<<'\n'; return 0;}
    if (n==2&&di[1]==0&&di[2]==0) {cout<<-1<<'\n'; return 0;}
    if (n==2&&di[1]==0&&di[2]==0) {cout<<-1<<'\n'; return 0;}
    if (n==2&&di[1]==0&&di[2]==0&&di[3]==0) {cout<<-1<<'\n'; return 0;}
    */
    if (n!=1&&!vis[1]) di[1]=1; 
    for (int i=1;i<=n;i++)
        cout<<di[i];
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    map<char, int> cnt;
    for (int i = 0; i < s.length(); ++i) {
        cnt[s[i]]++;
    }
    int mini = min(cnt['0'], cnt['1']);
    cout << 2 * mini << "\n";
    return 0;
}

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

const ll mod = 2019;

int main() {
    ll l, r;
    cin >> l >> r;
    
    if(l/mod != r/mod) {
        cout << 0 << endl;
    }
    else {
        ll ans = mod - 1;
        for(ll i = l; i < r; i++) {
            for(ll j = i+1; j <= r; j++) {
                ans = min(ans, i * j % mod);
            }
        }
        cout << ans << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
int add(int a,int b){return (a%mod + b%mod)%mod;}
int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a,int b){return (a%mod * b%mod)%mod;}
int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
signed main()
{
    GODSPEED;
    int n,l;
    cin>>n>>l;
    vector<string>v(n);
    FOR(i,0,n-1)
      cin>>v[i];
    sort(all(v));
    FOR(i,0,n-1)
     cout<<v[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }

 
 
 
 
 
int N, M, X[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) cin >> X[i];
    sort(X, X + M);
 
    vector<int> d;
    rep(i, 0, M - 1) d.push_back(X[i + 1] - X[i]);
    sort(all(d));
 
    ll ans = 0;
    int cnt = max(0, M - N);
    rep(i, 0, cnt) ans += d[i];
    cout << ans << endl;
}

Measured memory_bytes: 1276
n = int(input())
arr = []
tmp = 0
flg = 0
for i in range(n):
  a,b = map(int, input().split())
  arr.append([b,a])
arr.sort()
for i in range(n):
  tmp += arr[i][1]
  if tmp > arr[i][0]:
    flg = 1
if flg == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 35608
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,m;cin>>n>>m;
	vi a(n);
	ll sum=0;
	rep(i,0,n) cin>>a[i],sum+=a[i];
	sort(a.begin(), a.end(),greater<ll> ());
	cout<<(a[m-1]*4*m>=sum?"Yes":"No");
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,K;
    while(cin >> N >> K,N|K){
        vector<int> a(N);
        rep(i,N)cin >> a[i];
        int left=0,right=0;
        ll sum= 0,res=0;
        for(left=0;;left++){
            while(right<N&&right-left<K){
                sum+=a[right];
                right++;
            }
            res = max(res,sum);
            sum-=a[left];
            if(right==N&&left==N-K)break;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        
        System.out.println("" + a.charAt(0) + "" + b.charAt(1) +  "" + c.charAt(2));
    }
}

Measured memory_bytes: 20436
N = int(input())

nums = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N + 1):
    top = int(str(i)[0])
    bottom = int(str(i)[-1])
    nums[top][bottom] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += nums[i][j] * nums[j][i]


print(ans)


Measured memory_bytes: 3064
program Switches
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,i,j,j2,c,ans,k
    integer(int32), allocatable::p(:)
    logical,allocatable:: s(:,:)
    logical:: all_tuiteru


    read*, n,m
    allocate(s(n,m),source=.false.)
    allocate(p(m))

    block;integer(int32):: inpt(n)
        do i=1,m
            read*, k,inpt(1:k)
            do j=1,k
                s(inpt(j),i) = .true.
            end do
        end do
    end block
    read*, p(:)
    ans=0
    block;logical:: switch(n)
        do i=0,2**n-1
            do j=1,n
                switch(j) = btest(i,j-1)
            end do
            all_tuiteru = .true.
            do j=1,m
                c=0
                do j2=1,n
                    if (s(j2,j) .and. switch(j2)) c=c+1
                end do
                if (mod(c,2) /= p(j)) all_tuiteru = .false.
            end do
            if (all_tuiteru) ans=ans+1
        end do
    end block

    print'(i0)', ans
end program Switches

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

int main(void) {
	string s; cin >> s;
	int i; bool a[4] = { false };

	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'N') { a[0] = true; }
		if (s[i] == 'W') { a[1] = true; }
		if (s[i] == 'S') { a[2] = true; }
		if (s[i] == 'E') { a[3] = true; }
	}

	if (a[0]&&a[2]&&a[1]==false&&a[3]==false) {
		cout << "Yes" << endl;
	}
	else if (a[1] && a[3]&&a[2]==false&&a[0]==false) { cout << "Yes" << endl; }
	else if (a[0] && a[1] && a[2] && a[3]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  long long l = 0, r = 0;
  while (q--) {
    int p, n;
    char c;
    cin >> p >> c >> n;
    if (c == '(') {
      l += n;
    } else {
      r += n;
    }
    if (l == r) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
}



Measured memory_bytes: 3220
L,R = map(int,input().split())
if R - L >= 2019:
     print (0)
else:
     a = 2020
     l = L % 2019
     r = R % 2019
     for i in range (l, r):
          for j in range(l+1, r+1):
               a = min (i*j % 2019, a) 
     print(a)

Measured memory_bytes: 40428
import java.util.*;

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

        char[] c = sc.next().toCharArray();
        boolean res = c[2]==c[3] && c[4]==c[5];
        System.out.println(res ? "Yes" : "No");
    }
}

Measured memory_bytes: 22864
import java.util.*;
public class Main {
	public static void main(String[] args) {
		B();
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		sc.close();
		String num = n.toString();
		if(num.charAt(1) != num.charAt(2)) {
			System.out.println("No");
			return;
		}
		char mid = num.charAt(1);
		if(mid == num.charAt(0) || mid == num.charAt(3)) {
			System.out.println("Yes");
		}
		else System.out.println("No");
	}
	
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N==1) {
			System.out.println(1);
			return;
		}
		sc.close();
		long Li = 2;
		long Lj = 1;
		long temp;
		for(int i=2;i<N+1;i++) {
			temp = Lj;
			Lj = Li+Lj;
			Li = temp;
		}
		System.out.println(Lj);
	}
	
}


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

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int kaisu;
    if(n % x == 0){
        kaisu = n / x;
    }else{
        kaisu = n / x + 1;
    }
    cout << t * kaisu << endl;
}

Measured memory_bytes: 3632