akhauriyash/Code-Regression huggingface dataset:
//D
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
	return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
	stringstream ss;
	ss << x;
	return ss.str();
}
//string to ll
ll toNumber(string S) {
	ll ret; 
	sscanf(S.c_str(),"%lld",&ret); 
	return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
	int n;
	ll dat[305][305], data[305][305];
	bool mark[305][305];
	scanf("%d",&n);
	FOR(i,n) FOR(j,n)scanf("%lld",&dat[i][j]), data[i][j]=dat[i][j], mark[i][j]=true;
	//floyd warshall
	FOR(k,n) FOR(i,n) FOR(j,n){
		if(i==j)continue;
		if(i!=k&&k!=j&&dat[i][j]>=dat[i][k]+dat[k][j])mark[i][j]=false;
		dat[i][j]=min(dat[i][j],dat[i][k]+dat[k][j]);
	}
	ll res=0; bool flag=true;
	FOR(i,n) FOR(j,n){
		if(mark[i][j])res+=data[i][j];
		if(data[i][j]>dat[i][j])flag=false;
	}
	if(!flag)res=-1;
	printf("%lld\n",res>>1);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

read=sys.stdin.read
    
def main():
    class Unionfind():
        def __init__(self,n):
            self.parents=[-1]*n
            self.dist=[0]*n 
        
        def find(self,x):
            if self.parents[x]<0:
                return self.dist[x],x
            else:
                tmp=self.find(self.parents[x])
                self.dist[x]+=tmp[0]
                self.parents[x]=tmp[1]
            return self.dist[x], self.parents[x]
        
        def union(self,x,y,d):
            rx=self.find(x)[1]
            ry=self.find(y)[1]
            diff=self.dist[y]-self.dist[x]-d
            if rx==ry:
                if diff!=0:
                    return True
                return False
            if diff<0:
                rx,ry=ry,rx
                diff=-diff
            self.parents[ry]=min(self.parents[ry],self.parents[rx]-diff)
            self.parents[rx]=ry
            self.dist[rx]=diff
            return False
    n,m,*lrd=map(int,read().split())
    edg=[]
    v=Unionfind(n)
    for l,r,d in zip(*[iter(lrd)]*3):
        if v.union(l-1,r-1,d):
            print('No')
            break
    else:
        if max(-d-1 for d in v.parents if d<0) >10**9:
            print('No')
        else:
            print('Yes')
if __name__=='__main__':
    main()


Measured memory_bytes: 73296
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
    int N;
    int A[200] = { 0 };
    
    cin >> N;
    for (auto i = 0; i < N; ++i) cin >> A[i];

    int tmp[200], result[200];
    memcpy(tmp, A, sizeof(A));

    bool isFinish = false;
    int count = 0;
    while (!isFinish) {
        memcpy(result, tmp, sizeof(tmp));
        for (int i = 0; i < N; ++i) {
            if (result[i] % 2 == 1) {
                isFinish = true;
                break;
            }
            tmp[i] = result[i] / 2;
        }
        ++count;
    }
    // 最後に余分に回った分を減らしておく
    --count;

    cout << count << endl;

    return 0;
}

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

string toLowerString(std::string s) {
     for (int i = 0; i < s.size(); i++) {
         s[i] = tolower(s[i]);
     }

     return s;
}

int main() {
     string w, word;
     int count;

     cin >> w;
     w = toLowerString(w);

     while(true) {
         cin >> word;
         if (word == "END_OF_TEXT") {
             break;
         }
         if (toLowerString(word) == w) {
             count++;
         }
     }

     cout << count << endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int x,y,a,b,c;
		cin>>x>>y>>a>>b>>c;
		int red[a],green[b];
		vector<int>col;
		for (int i = 0; i < a; i++)
		{
			cin>>red[i];
		}
		for (int i = 0; i < b; i++)
		{
			cin>>green[i];
		}
		for (int i = 0; i < c; i++)
		{	
			int v;
			cin>>v;
			col.pb(v);
		}
		sort(red,red+a);
		reverse(red,red+a);
		sort(green,green+b);
		reverse(green,green+b);
		for (int i = 0; i < x; i++)
		{
			col.pb(red[i]);
		}
		for (int i = 0; i < y; i++)
		{
			col.pb(green[i]);
		}
		sort(all(col));
		ll ans=0;
		reverse(all(col));
		for(int i=0;i<x+y;i++)	
			ans+=(ll)col[i];
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 6076
S = list(input())[::-1]
L = len(S)
from collections import defaultdict

mod = 2019
t = 0
dic = defaultdict(int)
ans = 0
for l in range(L):
    t += pow(10, l, mod)*int(S[l])%mod
    t %= mod
    ans += dic[t]
    dic[t] += 1
    if t==0:
        ans += 1

print(ans)

Measured memory_bytes: 79952
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int digit(int n, int j){
    int N[10];
    int i=1;
    while(n>0){
        N[i]= n%10;
        n /= 10;
        i++;
    }
    return N[j];
}
int keta(int n){
    int c=1;
    while(n>0){
        n /= 10;
        c++;
    }
    return c-1;
}

int main(){
    int N, A, B, sum=0, summin=9999999;
    cin >> N;
    for(int A=1; A<=N/2; A++){
        B=N-A;
        sum=0;
        for(int i=1; i<=keta(A); i++){
            sum += digit(A, i);
        }
        for(int i=1; i<=keta(B); i++){
            sum += digit(B, i);
        }
        if(summin>sum){
            summin = sum;
        }
        //cout << "A=" << A << " sum=" << sum << " summin=" << summin << endl;
    }
    cout << summin << endl;
    
    return 0;
}


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

int main()
{
  unsigned int N;
  unsigned long long a[300001];
  unsigned long long res=0;
  scanf("%d", &N);

  rep(i,N) {
    scanf("%lld", &a[i]);
  }

  unsigned long long  digit = 1LL;
  for(int j=0; j<60; j++) {
    unsigned long long x = 0;
    rep(i,N){
      if(a[i] >> j & 1) x++;
    }
    res = (res + ((x*((unsigned long long)N-x) % MOD) * digit % MOD)) % MOD;
    digit = 2*digit % MOD;
  }
  
  cout << res << endl;
}


Measured memory_bytes: 2560
n, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
count = 0
for i in range(n - 1):
	if A[i] <= x:
		x -= A[i]
		count += 1
	else:
		print(count)
		exit()
print(count if x != A[n - 1] else count + 1)

Measured memory_bytes: 38704
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EMaxGCD solver = new EMaxGCD();
        solver.solve(1, in, out);
        out.close();
    }

    static class EMaxGCD {
        public boolean check(int a[], int k, int x) {
            ArrayList<Integer> rems = new ArrayList<>();
            for (int i = 0; i < a.length; i++) rems.add(a[i] % x);
            Collections.sort(rems);
            int l = 0;
            int r = rems.size() - 1;
            int rem = 0;
            int reqd = 0;
            while (l <= r) {
                if (rem <= 0) {
                    rem += rems.get(l);
                    reqd += rems.get(l);
                    l++;
                } else {
                    rem -= (x - rems.get(r));
                    reqd += (x - rems.get(r));
                    r--;
                }
            }
            if (reqd > 2 * k) return false;
            if (rem != 0) return false;
            return true;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }
            int ans = 1;
            for (int i = 1; i * i <= sum; i++) {
                if (sum % i == 0) {

                    if (check(a, k, i)) {
                        ans = Math.max(ans, i);
                    }
                    if (check(a, k, sum / i)) {
                        ans = Math.max(ans, sum / i);
                    }
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 39960
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	if (b%a == 0)
	{
		cout << a + b << endl;
	}
	else
	{
		cout << b - a << endl;
	}


}


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

namespace Matrix_Vector_Multiplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int n = int.Parse(strs[0]);
            int m = int.Parse(strs[1]);

            Vector vectorA = new Vector(n, m);
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine();
                strs = line.Split(' ');
                for (int j = 0; j < m; j++)
                {
                    int value = int.Parse(strs[j]);
                    vectorA.SetValue(i, j, value);
                }
            }

            Vector vectorB = new Vector(m, 1);
            for (int i = 0; i < m; i++)
            {
                int value = int.Parse(Console.ReadLine());
                vectorB.SetValue(i, 0, value);
            }

            Vector answer = vectorA.Mul(vectorB);

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(answer.GetValue(i,0));  
            }

        }
    }

    public class Vector
    {
        private List<List<int>> vector;

        private int row;

        private int col;

        /// <summary>
        /// n行m列の行列を構築する
        /// 全要素は0となる
        /// </summary>
        /// <param name="row">行数</param>
        /// <param name="col">列数</param>
        public Vector(int row, int col)
        {
            vector = new List<List<int>>();

            this.row = row;
            this.col = col;

            for (int i = 0; i < row; i++)
            {
                vector.Add(new List<int>());
                for (int j = 0; j < col; j++)
                {
                    vector[i].Add(0);
                }
            }
        }

        public int GetRow()
        {
            return row;
        }

        public int GetCol()
        {
            return col;
        }

        public int GetValue(int row, int col)
        {
            return vector[row][col];
        }

        public void SetValue(int row, int col, int value)
        {
            vector[row][col] = value;
        }

        public Vector Mul(Vector rValue)
        {
            Vector answer = new Vector(row, rValue.GetCol());

            for (int i = 0; i < row; i++)
            {
                int sum = 0;
                for (int j = 0; j < rValue.GetRow(); j++)
                {
                    sum += GetValue(i, j) * rValue.GetValue(j, 0); 
                }
                answer.SetValue(i, 0, sum);
            }

            return answer;
        }

        public string Show()
        {
            string str = "";
            for (int i = 0; i < GetRow(); i++)
            {
                for (int j = 0; j < GetCol(); j++)
                {
                    str += GetValue(i, j) + " ";
                }
                str += "\n";
            }
            return str;
        }
    }
}

Measured memory_bytes: 5984
a,b,c,x,y = map(int,input().split())


l = [x,y]
p = 10**5 * 15000
for i in range(max(l)+1):

    x_ = x-i
    y_ = y-i
    
    if x-i < 0:
        x_= 0
        
    if y-i < 0:
        y_ = 0
    
    if p > (i * 2*c + (x_) * a + (y_) * b):
        p = (i * 2*c + (x_) * a + (y_) * b)
print(p)


Measured memory_bytes: 3060
#include <cstdio>

int main()
{
  char s[200001];
  scanf("%s", s);
  long long a = 0;
  long long ans = 0;
  for (char *p = s; *p; ++p)
  {
    if (*p == 'A')
    {
      a += 1;
    }
    else if (*p == 'B')
    {
      if (*(p + 1) == 'C')
      {
        ans += a;
        p += 1;
      }
      else
      {
        a = 0;
      }
    }
    else
    {
      a = 0;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100010];

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

    dp[0] = 1;
    for(int i = 0; i < S.size(); ++i){
        if(!dp[i])continue;
        for(string s : divide){
            if(S.substr(i, s.size()) == s){
                dp[i + s.size()] = 1;
            }
        }
    }
    cout << (dp[S.size()] ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3820
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF

xy.sort()
for l in range(N-K+1):  #長方形の最も左の点
	for r in range(l+K, N+1):  #長方形の最も右の点
		y = sorted(xy[l:r], key = lambda x: x[1]) #lからrの中でyのとりうる値をソート
		for i in range(r-l-K+1):
			sq = (xy[r-1][0] - xy[l][0])*(y[i+K-1][1] - y[i][1])
			ans = min(ans, sq)
print(ans)

Measured memory_bytes: 10056
#include <stdio.h>

int min(int a, int b){
	return a < b ? a : b;
}

int main(void){
	char in;
	int count = 0, next = '0', diff = 0;
	while((in = getchar()) != '\n'){
		if(in != next)diff++;
		if(next == '0')next = '1';
		else next = '0';
		count++;
	}
	printf("%d\n", min(diff, count - diff));
	return 0;
}


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

int main(){
	long long n,k;
	cin>>n>>k;
	long long ans=0;
	for(int i=k;i<=n+1;i++){
		ans=ans+i*(n-i+1)+1;
	}
	cout<<ans%1000000007;
	return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	map<int, int>m;
	rep(i, 0, N) {
		m[v[i]]++;
		m[v[i] + 1]++;
		m[v[i] - 1]++;
	}
	int ans(-INF);
	for (auto &a : m) {
		chmax(ans, a.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
using namespace std;
int a,b;
int ans = 0;
int main() {
	cin >> a >> b;
	int n;
	if (b / 100 != 0) {
		n = a * 1000 + b;
	}
	else if (b / 10 != 0) {
		n = a * 100 + b;
	}
	else {
		n = a * 10 + b;
	}
	FOR(i, 500) {
		if (n == i*i) {
			cout << "Yes" << endl;
			break;
		}
		if (i == 499)cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import numpy as np

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353

dp = np.zeros(s + 1, np.int64)
dp[0] = 1

for e in a:
    pre = dp.copy()

    dp = 2 * pre
    dp[e:] += pre[:-e]
    dp %= mod

ans = dp[s]
print(ans)


Measured memory_bytes: 27504
#pragma GCC optimize(3)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;

int T;
LL a, b, c, d, t, del, _del;

inline bool solve() {
  cin >> a >> b >> c >> d;
  if (a < b || d < b) return 0;
  if (c > a) {
    a = (c - a) / (d - b) * (d - b);
    if (a < c) a += d - b;
  }
  else a -= (a - c - 1) / b * b;
  d = d % b + b;
  if (b == d) return a >= b;
  bool ans = 1;
  for (int i = 1; i <= 300000; i ++) {
    a += (c - (a - b)) / (d - b) * (d - b);
    if (a - b <= c) a += d - b;
    a -= b;
    ans &= (a >= b);
  }
  return ans;
}

int main() {
  cin >> T;
  while (T --) puts(solve() ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    p=list(map(int,input().split()))
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=S[i]+p[i]
    ans=float(0)
    for i in range(N-K+1):
        tmp=(S[i+K]-S[i]+K)/2
        ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a >= k) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
x, y = list(map(int, input().split()))
xy = [x, y]
result = 0
for n in [x, y]:
    if n == 3:
        result += 100000
    if n == 2:
        result += 200000
    if n == 1:
        result += 300000
if x == 1 and y == 1:
    result += 400000

print(result)

Measured memory_bytes: 3060
#include <stdio.h>

int main( void )
{
	int H;
	int W;
	int loop1;
	int loop2;

	while( 1 ){

		scanf( "%d %d", &H, &W );
		if( ( 0 == H ) && ( 0 == W ) ) {
			break;
		}

		for ( loop1 = 0; loop1 < H; loop1++ ) {
			for ( loop2 = 0; loop2 < W; loop2++ ) {
				printf( "#" );
			}
			printf( "\n" );
		}
		printf( "\n" );
	}

	return ( 0 );
}

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

using namespace std;

string str[50000];

string data;

int main(){

	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		int ansNum=0;

		for(int j=0;j<50000;j++){
			str[j]="-1";
		}

		cin>>data;

		for(int i=1;i<data.size();i++){
			
			//前半文字列
			char beforeStr[80];
			char beforeRev[80];
			for(int j=0;j<i;j++){
				beforeStr[j]=data.at(j);
			}
			for(int j=0;j<i;j++){
				beforeRev[j] = beforeStr[i-j-1];
			}
			beforeStr[i] = '\0';
			beforeRev[i] = '\0';
			//後半文字列
			char afterStr[80];
			char afterRev[80];
			for(int j=i;j<data.size();j++){
				afterStr[j-i]=data.at(j);
			}
			for(int j=0;j<data.size()-i;j++){
				afterRev[j] = afterStr[data.size()-i-j-1];
			}

			afterStr[data.size()-i]='\0';
			afterRev[data.size()-i]='\0';

			string bTmp[2];
			string aTmp[2];

			bTmp[0] = beforeStr;
			bTmp[1] = beforeRev;
			aTmp[0] = afterStr;
			aTmp[1] = afterRev;

			/*
			cout<<beforeStr<<afterStr<<endl;
			cout<<beforeStr<<afterRev<<endl;
			cout<<beforeRev<<afterStr<<endl;
			cout<<beforeRev<<afterRev<<endl;
			cout<<afterStr<<beforeStr<<endl;
			cout<<afterStr<<beforeRev<<endl;
			cout<<afterRev<<beforeStr<<endl;
			cout<<afterRev<<beforeRev<<endl;
			*/

			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					string ans[2];
				       	ans[0]	= bTmp[j]+aTmp[k];
					ans[1]  = aTmp[k]+bTmp[j];

					for(int l=0;l<2;l++){
						int flag=0;
						for(int search=0;search<ansNum;search++){
							if(str[search]==ans[l]){
								flag=1;
								break;
							}
						}
						if(flag==0){
							str[ansNum]=ans[l];
							ansNum++;
						}
					}


				}
			}

		}
		cout<<ansNum<<endl;
	}
	return 0;
}

Measured memory_bytes: 4000
#include<iostream>

using namespace std;

int w[110],v[110];
long long int dp[110000];
int INF = 1e9+9;

int N,W;
int main () {
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    for(int j=0; j<=100000; j++) dp[j] = INF;
    dp[0] = 0;

    for(int i=0; i<N; i++) {
        for(int va=100000; va>=v[i]; va--) {
            if( dp[va-v[i]] != INF && dp[va-v[i]]+w[i] <= W) {
                dp[va] = min(dp[va-v[i]]+w[i],dp[va]);
            }
        }
    }
    for(int i=100000; i>=0; i--) {
        if(dp[i] != INF) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

/*thief??????*/

int main(void){
    
    int array[5] = {0};
    int size = sizeof(array) /sizeof(int);
    cin >> array[0] >> array[1] >> array[2] >> array[3] >> array[4];
    sort(array, array+size);
    RFOR(i, 4, -1) { cout << array[i]; if(i != 0) cout << " "; else cout << endl;}
    return 0;

}

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

#define SZ(v) ((int)(v).size())
using ll = long long;

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

	int nb_chaines;
	cin >> nb_chaines;
	vector<string> mots(nb_chaines);
	for (auto &s : mots)
		cin >> s;
	vector<pair<int, int> > carac(nb_chaines);
	for (int i(0); i < nb_chaines; ++i)
	{
		int cur_sum(0);
		int smallest(0);
		for (auto c : mots[i])
		{
			if (c == '(')
				cur_sum++;
			else
				cur_sum--;
			smallest = min(smallest, cur_sum);
		}
		carac[i] = make_pair(max(0, -smallest), cur_sum);
	}
	int tot_sum(0);
	for (auto [s, m] : carac)
		tot_sum += m;
	if (tot_sum)
	{
		cout << "No" << endl;
		return 0;
	}
	int cur_ind(0);
	vector<pair<int, int>> negatifs;
	vector<pair<int, int> > positifs;
	for (auto [m, s] : carac)
	{
		if (s >= 0)
			positifs.emplace_back(m, s);
		else
			negatifs.emplace_back(m, s);
	}

	int cur_sum(0);
	sort(positifs.begin(), positifs.end());
	for (auto [m, s] : positifs)
	{
		if (cur_sum < m)
		{
			cout << "No" << endl;
			return 0;
		}
		cur_sum += s;
	}
	cur_sum=0;
	vector<pair<int, int>> a_prendre;
	for (int i(0); i < SZ(negatifs); ++i)
		a_prendre.emplace_back(negatifs[i].first + negatifs[i].second, i);
	sort(a_prendre.begin(), a_prendre.end());
	for (auto [a, i] : a_prendre)
	{
		if (a > cur_sum)
		{
			cout << "No" << endl;
			return 0;
		}
		cur_sum -= negatifs[i].second;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 56060
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

        final int N = sc.nextInt();
        final Set S = new HashSet<String>();
        for (int i = 0; i < N; i++) {
            S.add(sc.next());
        }

        System.out.println(S.size());
    }
}


Measured memory_bytes: 76984
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, r;
  cin >> n >> r;
  if(n < 10) print(r+100*(10-n));
  else print(r);
}


Measured memory_bytes: 256
//Bismillahir Rahmanir Raheem
#include<bits/stdc++.h>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define pb push_back
#define inf 1e9
#define all(x) (x).begin(), (x).end()
vector<int> h;
int dp[100002];
int n;

int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        h.pb(x);
    }
    h.pb(1e9);
    dp[n - 1] = 0, dp[n] = 1e9;
    for(int i = n - 2; ~i; i--)
        dp[i] = min(dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i] - h[i + 2]));
    cout << dp[0] << endl;

}






Measured memory_bytes: 1276
#ID
from collections import deque
n,m=map(int,input().split())
s=[]
for i in range(m):
    p,y=map(int,input().split())
    s.append([y,p,i+1])
s=sorted(s)
s=deque(s)
s.appendleft(0)
t=[1]*(n+1)
ID=[0]*(m+1)
for i in range(1,m+1):
    ID[s[i][2]]=str(s[i][1]*(10**6)+t[s[i][1]]).zfill(12)
    t[s[i][1]]+=1
for i in range(1,m+1):
    print(ID[i])

Measured memory_bytes: 78936
def calc_median(X):
    #中央値計算
    Xl = len(X)
    if Xl % 2:
        ret = X[(Xl + 1) // 2 - 1]
    else:
        ret = (X[Xl // 2 - 1] + X[Xl // 2]) / 2

    return ret


N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

A = [AB[i][0] for i in range(N)]
B = [AB[i][1] for i in range(N)]

A.sort()
B.sort()

AM = calc_median(A)
BM = calc_median(B)

if N % 2:
    ans = BM - AM + 1
else:
    ans = int((BM - AM) * 2 + 1)

print(ans)


Measured memory_bytes: 49184
K = int(input())
A, B = map(int, input().split(" "))

N = A // K

flag = False
for i in range(N, N+1000):
    v = K * i
    if (A <= v) and (v <= B):
        print("OK")
        flag = True
        break
        
if not flag:
    print("NG")

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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int
main()
{
    IO;
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        // cout<<"Case #"<<c<<": ";
        int d, s, t;
        cin >> d >> t >> s;
        if(d <= t*s){
            cout << "Yes" << nl;
        }
        else {
            cout << "No" << nl;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
k, x = input().split()

k = int(k)
x = int(x)

upper = 0
lower = 0

if x - k < -1000000:
    lower = -1000000
    upper = x + k
elif x + k > 1000000:
    upper = 1000000
    lower = x - k
else:
    upper = x + k
    lower = x - k

ans = ""
for num in range(lower + 1, upper):
    ans = ans + " " + str(num)

print(ans)


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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define pii pair<int,int>
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;
void solve()    {
        queue<ll> q;
        int k;          cin>>k;
        fl(i,1,10)       q.push(i*1LL);
        ll ans;
        while(k--)      {
                ans=q.front();
                q.pop();
                if(ans%10!=0)   q.push(10*ans+(ans%10)-1);
                q.push(10*ans+(ans%10));
                if(ans%10!=9)   q.push(10*ans+(ans%10)+1);
        }
        cout<<ans;
}
/*  Integer Overflow  */
int main()  {
    fast;
    //test()
        solve();
}

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

i=1
max_i=0
now_N=0
while(True):
    now_N+=i
    if N<=now_N:
        max_i = i
        break
    i+=1
    
output=[]
    
for i in range(1,max_i+1)[::-1]:
    if N-i>=0:
        N -= i
        output.append(str(i))
    if N==0:
        break
        
print("\n".join(output[::-1]))

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

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;
    int d = 'a' - 'A';
    cout << (char)(a.at(0) - d) << (char)(b.at(0) - d) << (char)(c.at(0) - d);
}

Measured memory_bytes: 256
N = int(input())
pt, px, py = [0, 0, 0]
ans = 'Yes'
for i in range(N):
    t, x, y = [int(n) for n in input().split()]
    dt = t-pt
    dxy = sum([abs(x-px), abs(y-py)])
    if dt < dxy or dt%2 != dxy%2:
        ans = 'No'
        break
    else:
        pt, px, py = t, x, y
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    string s;cin>>s;
    int count=0;
    vector<int> c(s.size());
    for(int i=0;i+1<s.size();i++){
        if(s[i]=='R'){
            count++;
            if(s[i+1]=='L'){
                if(count%2==1){
                    c[i]+=(count/2+1);
                    c[i+1]+=count/2;
                }
                else{
                    c[i]+=count/2;
                    c[i+1]+=count/2;
                }
            }
        }
        if(s[i]=='L')count=0;
    }
    count=0;
    for(int i=s.size()-1;i>0;i--){
        if(s[i]=='L'){
            count++;
            if(s[i-1]=='R'){
                if(count%2==1){
                    c[i]+=(count/2+1);
                    c[i-1]+=count/2;
                }
                else{
                    c[i]+=count/2;
                    c[i-1]+=count/2;
                }
            }
        }
        if(s[i]=='R')count=0;
    }
    for(int i=0;i<s.size()-1;i++){
        cout<<c[i]<<' ';
    }
    cout<<c[s.size()-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  string s, t;
  cin >> s >> t;

  sort(all(s));
  sort(all(t));
  reverse(all(t));

  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  long long N,K,Q;
  cin>>N>>K>>Q;
  int A[100000];
  int judge[100001];
  for(int i=1;i<=N;i++){
    judge[i]=K-Q;
  }
  for(int i=0;i<Q;i++){
    cin>>A[i];
    judge[A[i]]+=1;
  }
  for(int i=1;i<=N;i++){
    if(judge[i]<=0){
      cout<<"No"<<endl;
    }
    else{
      cout<<"Yes"<<endl;
    }
  }
  
  return 0;
}

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

int N;
int a[100100], b[100100], c[100100];

int dp[100100][3];

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> a[i] >> b[i] >> c[i];

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 3; j++) dp[i][j] = 0;
    }

    for (int i = 1; i <= N; i++) {
        dp[i][0] = max(dp[i][0], dp[i-1][1] + a[i]);
        dp[i][0] = max(dp[i][0], dp[i-1][2] + a[i]);
        dp[i][1] = max(dp[i][1], dp[i-1][2] + b[i]);
        dp[i][1] = max(dp[i][1], dp[i-1][0] + b[i]);
        dp[i][2] = max(dp[i][2], dp[i-1][0] + c[i]);
        dp[i][2] = max(dp[i][2], dp[i-1][1] + c[i]);
    }

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(ans, dp[N][i]);
    }

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

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


using namespace std;


const int N = 1e5 + 10;
struct node{
    int t, x, y;
}A[N];

int main(){
    int n;
    cin.tie(0);
    cin >> n;

    A[0].t = A[0].x =  A[0].y = 0;

    for(int i = 1; i <= n; i ++)
        cin >> A[i].t >> A[i].x >> A[i].y;
    bool is = true;
    for(int i = 1; i <= n; i++){
        int sum = abs(A[i].x - A[i-1].x) + abs(A[i].y - A[i-1].y);
        if(sum + A[i-1].t > A[i].t) is = false;

        if(((A[i].x + A[i].y)%2) != (A[i].t % 2)) is = false;
    }

    cout << (is ? "Yes":"No") << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int X = N, fX = 0;
  while (X > 0) {
    fX += X % 10;
    X /= 10;
  }
  
  if (N % fX == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


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


def main():
    N = ii()
    A = list(mi())
    cnt = 0
    for i in range(N):
        if A[i]%2==1:
            cnt += 1
    if cnt%2 == 1:
        print('NO')
    else:
        print('YES')

if __name__ == '__main__':
    main()


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

int main() {
  int N,K;
  cin >> N >> K;
  int ans=0;
  int x = N;
  while(x>=K) {
    ans++;
    x /= K;
  }
  cout << ans+1 << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i = 0; i < a.size(); i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int Alice = 0;
  int Bob = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      Alice += a.at(i);
    }else{
      Bob += a.at(i);
    }
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static String[] a = new String[] {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
	static String[] b = new String[] {"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C"};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] w = new int[10];
		int[] k = new int[10];
		for(int i = 0; i < 10; i++) {
			w[i] = stdIn.nextInt();
		}
		for(int i = 0; i < 10; i++) {
			k[i] = stdIn.nextInt();
		}
		
		Arrays.sort(w);
		Arrays.sort(k);
		
		System.out.println((w[9] + w[8] + w[7]) + " " + (k[9] + k[8] + k[7]));
	}
	
}

Measured memory_bytes: 17176
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int W = sc.nextInt();
    int[] w = new int[N];
    int[] v = new int[N];

    for (int i = 0; i < N; i++) {
      w[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }

    sc.close();

    long[][] dp = new long[N+1][100000+1];

    long INF = 1000000001;
    
    for (int j = 0; j <= 100000; j++) {
      dp[0][j] = INF;
    }

    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= 100000; j++) {
        if (j < v[i]) {
          dp[i + 1][j] = dp[i][j];
        } else {
          dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v[i]] + w[i]);
        }
      }
    }

    long result = INF;

    for (int i = 0; i <= 100000; i++) {
      if (dp[N][i] <= W) {
        result = i;
      }
    }

    System.out.println(result);

  }

}

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

void put(int x){
    cout << x << endl;
}
void put(string x){
    cout << x << endl;
}
void put(vector<int> x){
    cout << x.front();
    for(int i=1;i<x.size();++i){
        cout  << "," << x[i];
    }
    cout << endl;
}
void put(vector<int> x ,string s){
    cout << x.front();
    for(int i=1;i<x.size();++i){
        cout << s << x[i];
    }
    cout << endl;
}
void put(vector<vector<int>> x){
    cout << "{" <<endl;;
    for(int i=0;i<x.size();++i){
        cout << x[i].front();
        for(int j=1;j<x[i].size();++j){
            cout << "," << x[i][j];
        }
        cout << endl;
    }
    cout << "}" << endl;
}
void vsort(vector<int> v){
    sort(v.begin(),v.end());
}
void vsort(vector<string> v){
    sort(v.begin(),v.end());
}


int main(void) {
    int n;
    int x[200001];
    int _x[200001];
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> x[i];
        _x[i] = x[i];
    }
    
    //削除してからソートするとO（NlogN）（N回ソートするから）でアウト
    //ソートしてから削除するとO（logN）で済む気がする。中央値の前か後ろかだけでいいから削除はO（１）で済むよね
    
    sort(x,x+n);
    for(int i=0;i<n;++i){
        if(_x[i]<=x[n/2-1]){
            put(x[n/2]);
        }else{
            put(x[n/2-1]);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
import sys,collections
input = sys.stdin.readline

N=input().rstrip()
A=list(map(int,input().split()))
Ac = collections.Counter(A)
Q = int(input())
for i in range(Q):
    B,C = list(map(int,input().split()))
    nb = Ac[B]
    Ac[C] += Ac[B]
    Ac[B] = 0

    if i==0:
        ans = 0
        for key,val in Ac.items():
            ans += key*val
    else:
        ans +=nb*C - nb*B
    
    print(ans)


Measured memory_bytes: 24128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K, Q = MAP()
A = [INT() for _ in range(Q)]
cnt = [0]*N

for n in A:
  cnt[n-1] += 1
  
for i in range(N):
  print("Yes" if K + cnt[i] -Q > 0 else "No")

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x) {
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

int n, k;

int inp[N];

ll f(int p, int q){
  ll ret = 1ll * k * q % mod;
  ll sum = (1ll * (k - 1) * k) / 2ll;
  sum %= mod;
  sum = 1ll * sum * p % mod;
  ret += sum;
  return ret % mod;
}

int main(){
  fastScan(n);
  fastScan(k);
  for(int i = 1; i <= n; i++){
    fastScan(inp[i]);
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    int p = 0, q = 0;
    for(int j = 1; j <= n; j++){
      if(inp[i] < inp[j]){
        p++;
      }
      if(i > j){
        if(inp[i] < inp[j]){
          q++;
        }
      }
    }
    ans += f(p, q);
    ans %= mod;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
/* ex4_2
   moka223711 */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358

int main(void){
    // 時針の長さがlenh[cm]、分針の長さがlenm[cm]である時計のhour時minute分における
    // 時針の先端と分針の先端の距離を求める
    
    double lenh, lenm, hour, minute, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &lenh, &lenm, &hour, &minute);
    
    // 針が12時を指しているときを0[rad]とする
    // 時針は12時間(12*60分)で一周するので、hour時minute分のとき
    // 時針の角度radhは、2*PIに(hour/12+minute/60/12)をかけたものになる
    radh = 2 * PI * (hour + minute / 60) / 12;
    
    // 分針は60分で一周するので、分針の角度radmは2*PIにminute/60をかけたものになる
    radm = 2 * PI * minute / 60;
    
    // なす角を知りたいのでPI(180°)より小さい方を選ぶ
    rad = (radh-radm < PI) ? radh-radm : radm-radh;
    
    
    // 余弦定理を用いて時針の先端と分針の先端の距離を求める
    ans = sqrt(pow(lenh, 2) + pow(lenm, 2) - 2*lenh*lenm*cos(rad));
    // 誤差は10^{-9}まで許されるので10^{-10}まで表示する
    printf("%.10lf", ans);
    
    return 0;
}


Measured memory_bytes: 2600
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

string str;

int main() {
	cin >> str;
	ll howG = 0, howP = 0;
	for(int i = 0;i < str.size();i++){
		if(str[i] == 'g') howG++;
		else howP++;
	}

	ll ret = howG - howP;

	cout << ret / 2 << endl;
	return 0;
}

Measured memory_bytes: 512