akhauriyash/Code-Regression huggingface dataset:
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    ll a,b,k;
    cin >> a >> b >> k;
    cout << a - min(a,k) << " ";
    k -= min(a,k);
    cout << b - min(b,k) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    double a, b, x;
    cin >> a >> b >> x;

    if (x >= a * a * b / 2)
    {
        double h = (a * a * b - x) / (a * a) * 2;
        cout << fixed << setprecision(10) << 180 * atan2(h, a) / M_PI << endl;
    }
    else
    {
        double c = 2 * x / (a * b);
        cout << fixed << setprecision(10) << 180 * atan2(b, c) / M_PI << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>

int main(int argc, char const* argv[])
{
    uint64_t n, m;
    std::cin >> n >> m;

    auto as = std::vector<std::tuple<uint64_t, uint64_t>>(n);

    uint64_t current_num = 0;
    uint64_t result = 0;
    for(auto &a: as)
    {
        uint64_t val, num;
        std::cin >> val >> num;
        a = std::make_tuple(val, num);
    }

    std::sort(as.begin(), as.end(), [](std::tuple<uint64_t, uint64_t> a, std::tuple<uint64_t, uint64_t> b) -> uint64_t {
            return std::get<0>(a) < std::get<0>(b);
            });

    for(auto a: as)
    {
        auto val = std::get<0>(a);
        auto num = std::get<1>(a);

        if(m <= num)
        {
            result += val * m;
            break;
        }
        else
        {
            m -= num;
            result += val * num;
        }
    }

    std::cout << result << std::endl;

    return 0;
}

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


void f(int n,int m){
  vector<P> big(n),small(n);

  for(int i=0;i<n;i++){
    big[i]=P(0,i);
    small[i]=P(0,i);
  }

  for(int i=0;i<m;i++){
    int s,k;
    cin>>s>>k;
    for(int j=0;j<k;j++){
      int x;
      cin>>x;
      x--;
      big[x].first+=s;
      if(k==1) small[x].first+=s;
    }
  }

  sort(big.begin(),big.end());
  reverse(big.begin(),big.end());
  sort(small.begin(),small.end());

  if(big[0].second!=small[0].second){
    cout<<big[0].first-small[0].first+1<<endl;
  }else{
    int ans=big[0].first-small[1].first;
    ans = max(ans,big[1].first-small[0].first);
    cout<<ans+1<<endl;
  }
}

main(){
  int n,m;
  while(true){
    cin>>n>>m;
    if(n==0) break;
    f(n,m);
  }

}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a*100+b*10+c*1) % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1000000000;

int main(){
	int ans,n;
	int a,b,t[102],c;
	double dans,dn,da,db,dt[102],dc;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	for(int i=0;i<n;i++)scanf("%d",&t[i]);
	for(int i=n;i<102;i++)t[i]=0;
	sort(t,t+102);
	for(int i=101;i>-1;i--){
		dc=c; dt[i]=t[i]; da=a; db=b;
		if((dc+dt[i])/(da+db)>dc/da){c+=t[i]; a+=b;}
		else break;
	}
	dc=c; da=a;
	ans=(int)dc/da;
	printf("%d\n",ans);
}

Measured memory_bytes: 1188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d));
int ans[100][100];
  int dx[] = {1,0};
  int dy[] = {0,1};
int solve(){ 
  int h,w;
  cin >> h >> w;
  vector<string>s(h + 1);
  rep(i,h){
    string tmp;
    cin >> tmp;
    tmp.push_back('.');
    s[i] = tmp;
  }
  string tmp('.',w);
  s[h] = tmp;
  rep(i,h)rep(j,w){
    rep(k,2){
      if(s[i + dy[k]][j + dx[k]] == '#' && s[i][j] == '#'){
        ans[i][j]++;
        ans[i + dy[k]][j + dx[k]]++;
      }
    }
  }
  bool can = true;
  rep(i,h)rep(j,w){
    if(s[i][j] == '#'){
      if(ans[i][j] == 0)can = false;
    }
  }
  
  if(can)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String c[] = new String[n];
    int answer =1;
    for(int i=0;i<n;i++){
      c[i]=s.substring(i,i+1);
    }
    
    for(int i=0;i<n-1;i++){
      if(!c[i].equals(c[i+1])){
        answer = answer +1;
      }
    }
    System.out.println(answer);
    
  }
  

  
}

Measured memory_bytes: 30732
/*input
6
AC
TLE
AC
AC
WA
TLE
*/

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int t; cin >> t; while(t--)
#define MP make_pair
#define PI acos(-1)
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
	godspeed;
	int a[4];
	memset(a, 0, sizeof(a));
	string s;
	tests {
		cin >> s;
		if (s[0] == 'A') {
			a[0]++;
		} else if (s[0] == 'W') {
			a[1]++;
		} else if (s[0] == 'T') {
			a[2]++;
		} else {
			a[3]++;
		}
	}
	cout << "AC x " << a[0] << endl;
	cout << "WA x " << a[1] << endl;
	cout << "TLE x " << a[2] << endl;
	cout << "RE x " << a[3] << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
typedef long long ll;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	rep(i,m) cin >> v[i];
	sort(v.begin(), v.end());
	priority_queue<int> q;
	ll sum = 0;
	rep(i,m-1) {
		q.push(v[i+1] - v[i]);
		sum += v[i+1] - v[i];
	}
	ll sub = 0;
	rep(i,n-1) {
		if (q.empty()) break;
		sub += q.top();
		q.pop();
	}
	cout << sum - sub << endl;
}

Measured memory_bytes: 4300
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
  int n, m;
  while(cin >> n >> m, n + m){
    vector<int> v(n + m);
    vector<int> d(n + m);

    REP(i,n + m) cin >> v[i];
    sort(v.begin(), v.end());
    adjacent_difference(v.begin(), v.end(), d.begin());
    cout << *max_element(d.begin(), d.end()) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
num = 0

for i in range(n):
  num += b[a[i]-1]
  if i >= 1 and a[i]-a[i-1] == 1:
    num += c[a[i]-2]
    
print(num)

Measured memory_bytes: 3064
#include <algorithm>
#include <cstring>
#include <cstdio>
const int N=1005,inf=1000000000;
int f[N],g[5005],fst[N],nxt[N],a[N];
void addedge(int x,int y){
	nxt[y]=fst[x];fst[x]=y;
}
int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=2;i<=n;i++){
		int p;
		scanf("%d",&p);
		addedge(p,i);
	}
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int x=n;x>=1;x--){
		memset(g,0,sizeof g);
		for (int y=fst[x];y;y=nxt[y])
			for (int i=a[x];i>=0;i--){
				int z=inf;
				if (i>=a[y]) z=g[i-a[y]]+f[y];
				if (i>=f[y]) z=std::min(z,g[i-f[y]]+a[y]);
				g[i]=z;
			}
		if ((f[x]=g[a[x]])>=inf){
			printf("IMPOSSIBLE\n");
			return 0;
		}
	}
	printf("POSSIBLE\n");
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] arr = new int[5];
    arr[0] = sc.nextInt();
    arr[1] = sc.nextInt();
    arr[2] = sc.nextInt();
    arr[3] = sc.nextInt();
    arr[4] = sc.nextInt();
    Arrays.sort(arr);
    System.out.print(arr[4]); 
    System.out.print(" ");
    System.out.print(arr[3]); 
    System.out.print(" ");
    System.out.print(arr[2]); 
    System.out.print(" ");
    System.out.print(arr[1]); 
    System.out.print(" ");
    System.out.println(arr[0]); 
  }
}

Measured memory_bytes: 26276
#include<iostream>
using namespace std;
#define x e-(y*y+z*z*z)
int main()
{
  int a,e;
  for(;cin>>e,e;cout<<a<<endl)
    {
      a=e;
      for(int y=0;y*y<=e;y++)
	for(int z=0;y*y+z*z*z<=e;z++)
	  if(x>=0&&x+y+z<a)
	    a=x+y+z;
    }
}

Measured memory_bytes: 1160
def make_ST(n,first): #firstで初期化された、葉がn要素を超えるように2のべき乗個用意されたリストを返す

    i = 0
    ret = []
    while 2 ** (i-1) < n:

        for j in range(2 ** i):
            ret.append(first)

        i += 1

    return ret

def RMQ_update_point(num,point,tree): #葉のindex(0-origin)がpointの要素をnumにする/treeはセグ木

    i = (len(tree) - 1) // 2 + point
    tree[i] = num
    while i > 0:
        i = (i - 1) // 2
        tree[i] = min(tree[i * 2 + 2] , tree[i * 2 + 1])

    return

def RMQ_query(a,b,k,l,r,tree): #query区間左,右,注目ノード番号,担当範囲左,担当範囲右,木

    if r <= a or b <= l: #区間が完全にかぶらない場合inf
        return float("inf")
    
    if a <= l and r <= b: #区間が完全に含まれる場合自分
        return tree[k]

    c1 = RMQ_query(a,b,2*k+1,l,(l+r)//2,tree)
    c2 = RMQ_query(a,b,2*k+2,(l+r)//2,r,tree)   

    return min(c1,c2)
        

n,q = map(int,input().split())

ABLE_MAX = 2 ** 31 - 1
segt = make_ST(n,ABLE_MAX)

for i in range(q):

    com,x,y = map(int,input().split())

    if com == 0:
        RMQ_update_point(y,x,segt)
    else:
        print (RMQ_query(min(x,y+1),max(x,y+1),0,0,(len(segt)+1)//2,segt))



Measured memory_bytes: 9040
s = input()
k = int(input())


def dfs(sub, i):
  if sub in s:
    i += 1
    if i == k:
      print(sub)
      exit()
    for c in range(ord('a'), ord('z') + 1):
      c = chr(c)
      i = dfs(sub + c, i)
  return i
  
dfs('', -1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    cout<<n*n<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
  string s;
  cin >> s;
  
  int i = 0;
 if(s == "SUN"){
   i = 7;
 } else if(s == "MON"){
    i = 6;
 } else if(s == "TUE"){
   i = 5;
 } else if (s == "WED"){
   i = 4;
 } else if (s == "THU"){
   i = 3;
 } else if (s == "FRI"){
   i = 2;
 } else if (s == "SAT"){
   i = 1;
 }
  cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>
#include <unordered_set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}
/*
*/
int main()
{
	ll i,j,k,a,b;
	ll N,M,K;
	ll mn[5200] = {0};
	cin>>N>>M;
	for(i=0;i<5000;++i)
	{
		mn[i] = 200000000;
	}
	mn[0] = 0;
	K=1<<N;
	for(i=0;i<M;++i)
	{
		ll line = 0;
		cin>>a>>b;
		for(j=0;j<b;++j)
		{
			cin>>k;
			line |= 1<<(k-1);
		}
		for(j=0;j<K;++j)
		{
			k=j|line;
			if(k>=5000)
				k=5000;
			if(mn[k]>mn[j]+a)
				mn[k]=mn[j]+a;
		}
	}
	if(mn[K-1] == 200000000)
		cout << -1 << endl;
	else
		cout << mn[K-1] << endl;
	return 0;
}




















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

int main() {
	ios_base::sync_with_stdio(false);
	int n, a[50];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int max=-1000000, min=1000000, i1=0,i2=0;
	for(int i=0;i<n;i++){
		if(max<a[i]){
			max=a[i];
			i1=i;
		}
		if(min>a[i]){
			min=a[i];
			i2=i;
		}
	}
	if(max>min*-1){
		cout<<2*n-2<<endl;
		for(int i=0;i<n;i++){
			if(i!=i1){
				cout<<i1+1<<" "<<i+1<<endl;			}
		}
		for(int i=0;i<n-1;i++){
			cout<<i+1<<" "<<i+2<<endl;
		}
	}
	else{
		cout<<2*n-2<<endl;
		for(int i=0;i<n;i++){
			if(i!=i2){
				cout<<i2+1<<" "<<i+1<<endl;			}
		}
		for(int i=n-1;i>0;i--){
			cout<<i+1<<" "<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			if (n %2 == 0)
			{
				Console.WriteLine(0.5);
			}
			else
			{
				Console.WriteLine((n / 2 + 1.0) / n);
			}
		}
	}
}


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

namespace AtCoder.AtCoder_Begginer_Contest_161
{
    class A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            int y = int.Parse(input[1]);
            int z = int.Parse(input[2]);

            Console.WriteLine(z + " " + x + " " + y);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n,e,t;
long long s[N],dp[N];
struct g{
	long long v;
	int pos;
}q[N];
int l,r;
long long tmp;
int main(){
	scanf("%d",&n);
	scanf("%lld%d",&s[n+1],&t);
	for (int i=1;i<=n;i++)
		scanf("%lld",&s[i]);
	
	l=1;r=0;tmp=(1LL<<50);
	q[++r].pos=1;
	q[r].v=t;
	for (int i=1;i<=n;i++){
		while ((s[i]-s[q[l].pos])*2>t) 
		{	
			tmp=min(tmp,q[l].v-t-2*s[q[l].pos]);
			l++;
		}
		dp[i]=(1LL<<50);
		dp[i]=min(dp[i],q[l].v+s[i]);
		dp[i]=min(dp[i],tmp+3*s[i]);
		while ((l<=r)&&(dp[i]-s[i]+t<=q[r].v)) r--;
		q[++r].pos=i+1;
		q[r].v=dp[i]-s[i]+t;
	}
	printf("%lld\n",dp[n]+s[n+1]-s[n]);
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}

int main(){
    int n,m,x; cin >> n >> m >>x;
    
    bool ans = 0;
    if(n <= x and m+n >= x) ans = 1;
    
    cout << yn(ans) << endl;
}







Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

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

using namespace std;

int N;
double A[201];

int main()
{
    cin >> N;
    REP(i, N) cin >> A[i];
    double sum = 0;
    REP(i, N) sum += 1.0 / A[i];
    cout << 1.0 / sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int v[200200],w[200200];
int main() {
	int n;
	scanf("%d ",&n);
	v[0] = 0;
	for(int i=0;i<n;i++) {
		char c;
		scanf("%c ",&c);
		w[i] = c=='#';
		v[i+1] = v[i]+w[i];
	}
	int ma = 999999;
	for(int i=0;i<=n;i++) {
		ma = min(ma,v[i]+n-i-(v[n]-v[i]));
		//printf("%d ",v[i]+n-i-(v[n]-v[i]));
	}
	//printf("\n");
	printf("%d\n",ma);
}


Measured memory_bytes: 1792
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
Q=int(input())
F=A-B
G=A-C
H=A-D
I=A-E
J=B-C
K=B-D
L=B-E
M=C-D
N=C-E
O=D-E

P=max(abs(F),abs(G),abs(H),abs(I),abs(J),abs(K),abs(L),abs(M),abs(N),abs(O))
if P<=Q:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 9216
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int x , a ;
    cin >> x >> a; 
    cout << max(max(a+x , x*a) , x-a) ; 























return 0 ;
}


Measured memory_bytes: 3648
import sys
t='X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e)or(e[-1]==t and '=X'in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5616
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
void solve()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
ll a,ans;
int main() {
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	{
		cin>>a;
		if(a>=k)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, A: int, B: int, C: int, L: "List[int]"):

    def dfs(cur,a,b,c):
        if cur == N:
            return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a,b,c) > 0 else 100000

        cur_l = L[cur]
        nex = cur + 1

        ret0 = dfs(nex,a,b,c)
        ret1 = dfs(nex,a+cur_l,b,c)+10
        ret2 = dfs(nex,a,b+cur_l,c)+10
        ret3 = dfs(nex,a,b,c+cur_l)+10

        return min(ret0,ret1,ret2,ret3)

    print(dfs(0,0,0,0))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B, C, l)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int partition(int*,int,int);
int main(){
  int n,i,x;
  int A[100000];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  
  x = partition(A,0,n-1);

  for(i = 0; i < n; i++){
    if(i == x)printf("[%d]",A[i]);
    else printf("%d",A[i]);
    if(i != n-1) printf(" ");
    else printf("\n");
  }

  return 0;
}

int partition(int *A,int p,int r){
  int i,j,x,temp;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  
  return i+1;
}



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

static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n;i++){
    d[i] = INFTY;
  }
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int v = 0; v < n; v++){
      if(M[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i = 0;i < n;i++){
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main(){
  int u,k,v;

  cin >> n;
  for(int i = 0; i < n;i++){
    for(int j = 0;j < n;j++)M[i][j] = 0;
  }

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);

  return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, s.size()) cout << s[i++];
    cout << endl;
    return 0;
}

Measured memory_bytes: 592
n,p = map(int,input().split())
a = list(map(int,input().split()))
even=True
for i in range(n):
    if a[i]%2!=0:
        even=False
        break
if even:
    if p==0:
        ans = 2**n
    else:
        ans = 0
else:
    ans = 2**(n-1)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k,a[110] ,b[110] ;
ll mem[110][110000];

ll dp(int i, int sum){
if(i == n) return 0;
if(mem[i][sum] != -1) return mem[i][sum];
long long ret = 0 ,ret1 = 0;
if(a[i] + sum <= k){
    ret = b[i] + dp(i+1,sum+a[i]);
}
ret1 = dp(i+1,sum);

return mem[i][sum] = max(ret, ret1);
}
int main()
{
  cin>>n>>k;
  for(int i=0; i<n; i++)
  for(int j=0; j< 2 ; j++){
    if(j == 0) cin>>a[i];
    if(j==1) cin>>b[i];

  }
  memset(mem,-1,sizeof(mem));
  cout<<dp(0,0);

}


Measured memory_bytes: 94720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

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;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s;
bool bl[200010];
int cnt1, cnt2;
int cnt;
int ans = 1;

signed main() {
	cin >> n >> s;
	bl[0] = 0;
	cnt2++;
	for (int i = 1; i < 2 * n; i++) {
		if (s[i - 1] == s[i]) {
			if (bl[i - 1])bl[i] = false;
			else bl[i] = true;
		}
		else bl[i] = bl[i - 1];
		if (bl[i])cnt1++;
		else cnt2++;
	}
	if (s[0] == 'W' || s[2 * n - 1] == 'W' || cnt1 != cnt2) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < 2 * n; i++) {
		if (!bl[i])cnt++;
		else {
			ans *= cnt;
			ans %= mod;
			cnt--;
		}
	}
	ans *= kai(n, n);
	ans %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 772
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <stack>
#include <queue>
#define waru 1000000000+7

using namespace std;

int main(){
  int n;
  cin >> n;
  unsigned long long int res = 0;
  rep(i,n){
      res += i;
  }
  cout << res;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2019/11/05.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

mti e;
vi flag;
vi ans;

bool dfs(int x, int r){
    int tmp = flag[x];
    flag[x] = -IINF;
    int count = 0;
    for(auto &nx: e[x]){
        if(flag[nx] < 0) count++;
    }
    if(count > 1){
        flag[x] = tmp;
        return false;
    }else if(count==1){
        for(auto &nx: e[x]){
            if(flag[nx] > 0) continue;
            if(nx == r){
                ans.push_back(x);
                return true;
            }
        }
        return false;
    }
    for(auto &nx: e[x]){
        flag[nx]++;
    }
    for(auto &nx: e[x]){
        flag[nx]--;
        if(flag[nx] == 0){
            if(dfs(nx, r)){
                ans.push_back(x);
                return true;
            }
        }
        flag[nx]++;
    }
    for(auto &nx: e[x]){
        flag[nx]--;
    }
    flag[x] = tmp;
    return false;
}

int main(){
    int n, m;
    cin >> n >> m;
    e = mti(n);
    int u, v;
    rep(i, m){
        cin >> u >> v;
        e[u - 1].push_back(v - 1);
    }
    rep(i, n){
        flag = vi(n, 0);
        if(dfs(i, i)){
            cout << ans.size() << endl;
            for(auto &nx: ans){
                cout << nx + 1 << endl;
            }
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int ara[100002];
bool mark[100002];

int main()
{
    int n,m,a,b,i;
    cin>>n>>m;
    for(i=1; i<=n; i++)scanf("%d",&ara[i]);
    while(m--)
    {
        scanf("%d %d",&a,&b);
        if(ara[a]>ara[b])mark[b]=true;
        else if(ara[a]<ara[b])mark[a]=true;
        else mark[a]=mark[b]=true;
    }
    b=0;
    for(a=1; a<=n; a++)
        if(!mark[a])b++;
    cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 4148
#include<stdio.h>
int main()
{
int a,b,w;
char op;
w=0;
while(1){
scanf("%d",&a);scanf("%s",&op);scanf("%d",&b);
if(op=='+')w=a+b;
else if(op=='-')w=a-b;
else if(op=='*')w=a*b;
else if(op=='/')w=a/b;
else if(op=='?')break;
printf("%d\n",w);
}
 return 0;
}

Measured memory_bytes: 1028
package main

import (
	"fmt"
)

func main() {
	x := make([]int, 5)
	for i := 0; i < len(x); i++ {
		fmt.Scanf("%d", &x[i])
	}

	for i := 0; i < len(x); i++ {
		if x[i] == 0 {
			fmt.Println(i + 1)
			break;
		}
	}
}


Measured memory_bytes: 1836
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import Data.List (group)

main :: IO ()
main = do
  let
    f :: Int -> Int -> Int
    f k m = (2 * k) `min` (m - 1)
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ds <- map ('R' ==) <$> getLine :: IO [Bool]
  let
    (m, s) = ((,) <$> length <*> sum . map (pred . length)) . group $ ds :: (Int, Int)
  print $ s + f k m

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  
  int s=1,bit=0;
  string ans = "NG";
  while(true){
    bit = k*s;
    if(a<=bit && bit <= b){
      ans = "OK";
      break;
    }
    if(bit>b)
      break;
    s++;
  }
  
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

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

  vector<int> D(N);
  for (int &d : D) {
    cin >> d;
  }

  sort(D.begin(), D.end());

  int piv = D.size() / 2;
  int ans = D[piv] - D[piv - 1];
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = readLine()?.split(" ")?.map(String::toInt) ?: return
    var alice = 0
    var bob = 0
    a.sortedDescending().forEachIndexed { i, v ->
        if (i % 2 == 0) {
            alice += v
        } else {
            bob += v
        }
    }
    println((alice-bob).toString())
}


Measured memory_bytes: 39060
d,n=map(int,input().split())
if d==0:
    if n==100:
        print(101)
    else:
        print(n)
elif d==1:
    if n==100:
        print(10100)
    else:
        print(n*100)
else:
    if n==100:
        print(1010000)
    else:
        print(n*10000)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

const int kMaxN = 100;

int main() {
    int n, m;
    int T[kMaxN];
    int sum = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> T[i];
        sum += T[i];
    }

    cin >> m;
    int p, x;

    for (int i = 0; i < m; i++) {
        int ans = sum;
        cin >> p >> x;
        
        ans -= T[p - 1];
        ans += x;

        cout << ans << endl;
    }

}


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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    if(d[0]) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> cnt(n);
    rep(i,n) cnt[d[i]]++;
    if(cnt[0]>1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,n-1){
        if(!cnt[i] && cnt[i+1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i = 1; i < n; ++i) {
        if(!cnt[i]) break;
        rep(j,cnt[i]){
            ans*=cnt[i-1];
            ans%=mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC151A - Next Alphabet

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        
        char[] c = s.toCharArray();
        
        c[0] += 1;

        System.out.println(String.valueOf(c[0]));
    }
}

Measured memory_bytes: 23892
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	q := make([]int, n)
	for i := range q {
		fmt.Scan(&q[i])
	}

	r := make([]int, n-1)
	fac := 1
	for i := 1; i < n; i++ {
		fac *= i
		r[n-i-1] = fac
	}

	a := 1
	b := 1
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if p[i] > p[j] {
				a += r[i]
			}
			if q[i] > q[j] {
				b += r[i]
			}
		}
	}
	fmt.Println(abs(a - b))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,K,X,Y,ans=0;
	cin >> N >> K >> X >> Y;
	if(K>=N){
		ans = N*X;
	}else{
		ans = X*K + (N-K)*Y;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
const int mod = 1e9+7;

int main(){
    int N, M, X, sum_before=0, sum_after=0;
    cin >> N >> M >> X;
    vector <int> a(M);

    for(int i=0; i<M; i++){
        cin >> a[i];
    }
    for(int i=0;i < M; i++){
        if(a[i] < X){
            sum_before++;
        }
    }
    sum_after = a.size() - sum_before;

    if(sum_before > sum_after){
        cout << sum_after;
    }else{
        cout << sum_before;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> h(100000);
    for (int i = 0; i < N; i++) cin >> h[i];
    vector<ll> dp(100000);
    for (int i = 0; i < 100000; i++) dp[i] = INF;
    dp[0] = 0;

    for (int i = 0; i < N; i++){
      for (int j = 1; j <= K; j++){
        chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	ll a, b;
  	cin >> a >> b;
  	ll ans = a * b;
  	if (ans % 2 == 0) cout << "Even" << endl;
  	else cout << "Odd" << endl;
    return 0;
}


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

int main() {

	int h, w;
	cin >> h >> w;

	vector<vector<char>> data(h, vector<char>(w));
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> data.at(i).at(j);
		}
	}

	vector<int> row(h);
	vector<int> column(w);

	//row
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(data.at(i).at(j) == '#') break;
			if(j == w-1) row.at(i) = 1;
		}
	}
	//column
	for(int j=0; j<w; j++){
		for(int i=0; i<h; i++){
			if(data.at(i).at(j) == '#') break;
			if(i == h-1) column.at(j) = 1;
		}
	}

	//print
	for(int i=0; i<h; i++){
		if(row.at(i) == 1) continue;
		for(int j=0; j<w; j++){
			if(column.at(j) == 1) continue;
			cout << data.at(i).at(j);
		}
		cout << endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

struct Dice {
    int face[6];
    const int dir[5][6]={
        {1, 5, 2, 3, 0, 4},
        {3, 1, 0, 5, 4, 2},
        {4, 0, 2, 3, 5, 1},
        {2, 1, 5, 0, 4, 3},
        {0, 2, 4, 1, 3, 5}
    };
    const char dchars[6]="NESWY";
    int encode[256]={};
    Dice(int f[6]) {
        for (size_t i=0; i<6; ++i)
            face[i] = f[i];

        for (size_t i=0; i<5; ++i)
            encode[dchars[i]+0] = i;
    }
    void roll(char d) {
        int tmp[6]={};
        for (size_t i=0; i<6; ++i)
            tmp[i] = face[i];

        for (size_t i=0; i<6; ++i)
            face[i] = tmp[dir[encode[d+0]][i]];
    }
    void yaw() {
        roll('Y');
    }
    void flip() {
        roll('N'), roll('N');
    }
    int top() {
        return face[0];
    }
    int front() {
        return face[1];
    }
    int right() {
        return face[2];
    }
    int back() {
        return face[3];
    }
    int left() {
        return face[4];
    }
    int bottom() {
        return face[5];
    }
    bool operator==(const Dice d2) {
        for (size_t i=0; i<6; ++i)
            if (face[i] != d2.face[i])
                return false;

        return true;
    }
    bool equals(Dice d2) {
        for (int i=0; i<4; ++i) {
            for (int j=0; j<4; ++j) {
                d2.yaw();
                if (*this == d2) return true;
            }
            d2.roll('N');
        }
        d2.roll('E');
        for (int j=0; j<4; ++j) {
            d2.yaw();
            if (*this == d2) return true;
        }
        d2.flip();
        for (int j=0; j<4; ++j) {
            d2.yaw();
            if (*this == d2) return true;
        }

        return false;
    }
};

int main() {
    int f[6];
    for (size_t i=0; i<6; ++i)
        scanf("%d", &f[i]);

    Dice d1(f);

    for (size_t i=0; i<6; ++i)
        scanf("%d", &f[i]);

    Dice d2(f);

    printf("%s\n", d1.equals(d2)? "Yes":"No");
    return 0;
}

Measured memory_bytes: 2672
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p,r):
        if (A[j] <= x):
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1
# r = (len(A)-1)
n = int(input())
A = list(map(int, input().split()))
i = partition(A, 0, n-1)
for k in range(n):
    if (k == (n-1)):
        if (k == i):
            print('[{}]'.format(A[i]), end = '')
        else:
            print('{0}'.format(A[k]), end = '')
        
    elif(k == i):
        print('[{}]'.format(A[i]), end = ' ')
    else:
        print('{}'.format(A[k]), end =' ')
print()


Measured memory_bytes: 16396
n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}

for i in range(n):
    s=input()
    dic[s]=dic.get(s,0)+1

mx=max(dic.values())
ansl=[]
for k, v in dic.items():
    if v==mx:
        ansl.append(k)

ansl.sort()

for st in ansl:
    print(st)

Measured memory_bytes: 32096
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string s = "";
    rep(i,w+2) s += "#";
    vector<string> p(h);
    rep(i,h) cin >> p[i];
    PRINT(s);
    rep(i,h) PRINT("#"+p[i]+"#");
    PRINT(s);
}    


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }



int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		int N;

		cin >> N;
		if (cin.fail()) break;

		ll result = 0;
		int R = 0, A;
		for (int i = 0; i < N; i++) {
			cin >> A;
			int r = min(R, A);
			result += r;
			R = A - r;
			result += R / 2;
			R &= 1;
		}

		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 256