akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {

    ll N, K; cin >> N >> K;
    vector <pair<ll, ll>> p(N);
    rep(i,N) cin >> p[i].first >> p[i].second;
    Sort(p);
    ll ans;
    ll cnt = K;
    ll num = 0;
    while (cnt > 0) {
        ans = p[num].first;
        cnt -= p[num].second;
        ++num;
    }
    out(ans);

    
    return 0;
}











Measured memory_bytes: 1792
n = int(input())
p = [int(input()) for _ in range(n)]
pi = [(x-1, i) for i, x in enumerate(p)]
pi.sort()
pi.append((n, -1))

l, mxl = 0, 0
for i, x in pi:
    if x < pi[i-1][1]:
        mxl = max(l, mxl)
        l = 0
    l += 1

print(n - mxl)


Measured memory_bytes: 38852
a = input()
array = []

for i in range(2**3):
    a2 = a[0]
    for j in range(3):
        if (i >> j) & 1 == 1:
            a2 += '+'
        else:
            a2 += '-'
        a2 += a[j+1]
    if eval(a2) == 7:
        c = 1
        break

print(a2+'=7')

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

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);(i)++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

#define INF INT_MAX/3

struct RangeMinQuery{
  int dat[(1<<19)-1];
  int size;

  void init(int n_){
    size=1;
    while(size<n_)size*=2;
    for(int i=0;i<2*size-1;i++)dat[i]=INF;
  }

  void update(int k,int a){
    k+=size-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }

  int subquery(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    else{
      return min(subquery(a,b,k*2+1,l,(l+r)/2),subquery(a,b,k*2+2,(l+r)/2,r));
    }
  }

  int query(int a,int b){
    return subquery(a,b,0,0,size);
  }
};

struct BIT{
  int n;
  vector<int> bit;
  BIT(int size):n(size),bit(size+1,0){}

  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,int v){
    if(i==0)return ;
    while(i<=n){
      bit[i]+=v;
      i+=i&-i;
    }
  }

  int lower_bound(int w){
    if(w<=0)return 0;
    int x=0,r=1;
    while(r<n)r<<=1;
    for(int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }
};

int N,Q;
char input[1000010];
vector<string> S;
vector<int> ord;
int ridx[100010],lcp[100010];
RangeMinQuery rmq;

int main(){
  scanf("%d",&N);
  S.resize(N);
  rep(i,N){
    scanf("%s",input);
    S[i]=string(input);
    ord.push_back(i);
  }
  sort(ord.begin(),ord.end(),[=](const int& a,const int& b){
    return S[a] < S[b];
  });
  rep(i,N){
    ridx[ord[i]]=i;
  }
  rmq.init(N-1);
  rep(i,N-1){
    lcp[i]=0;
    rep(j,min(S[ord[i]].size(),S[ord[i+1]].size())){
      if(S[ord[i]][j]==S[ord[i+1]][j])lcp[i]++;
      else break;
    }
    // dbg(lcp[i]);
    rmq.update(i,lcp[i]);
  }

  BIT bit(N);

  scanf("%d",&Q);
  rep(i,Q){
    int a,b;
    scanf("%d%d",&a,&b);
    a--; b--;
    if(a==0){
      bit.add(ridx[b]+1,+1);
    }else if(a==1){
      bit.add(ridx[b]+1,-1);
    }else{
      int sum=bit.sum(ridx[b]);
      int idx=bit.lower_bound(sum+1);
      if(idx==N+1){
        cout<<-1<<endl;
        continue;
      }
      int len=rmq.query(ridx[b],idx-1);
      if(len>=(int)S[b].size())cout<<ord[idx-1]+1<<endl;
      else cout<<-1<<endl;
    }
  }

  return 0;
}



Measured memory_bytes: 11112
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}



int main(){
const double PI=3.14159265358979323846;
double A,B,H,M; cin >> A >> B >> H >> M;
double x,y,z;
x = H * 30 + M / 2;
y = 6 * M;
z = abs(x-y);
double ans;
ans = sqrt(A*A + B*B - (2*A*B*cos(PI/180*z)));
printf("%.12f\n",ans);
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

char a[10][10];
int main(){
    int h,w,k,cnt,ans=0;
    scanf("%d%d%d",&h,&w,&k);
    rep(i,0,h){
        rep(j,0,w){
            cin>>a[i][j];
        }
    }
    rep(i,0,(1<<h)){
        rep(j,0,(1<<w)){
            cnt=0;
            rep(hang,0,h){
                rep(lie,0,w){
                    if(((i>>hang)&1)==0&&((j>>lie)&1)==0&&a[hang][lie]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long sum=0;
    for(long long i=1;i<=n;i++)
    {
        if((i%5!=0)&&(i%3!=0))
            sum+=i;
    }
    cout<<sum<<endl;
return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll s;
  cin >> s;
  ll x1 = 0, y1 = 0, x2 = 1e+9, y2 = 1, x3, y3;

  if (s % x2) {
    y3 = s / x2 + 1;
    x3 = x2 - s % x2;
  } else {
    y3 = s / x2;
    x3 = 0;
  }
  cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3
       << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, K;
	double ans = 0;
	cin >> N >> K;

	//N面サイコロ
	for (int i = 1; i <= N; i++) {
		//サイコロの目->i
		int tmp = i;
		int cnt = 0;
		while(1){
			if(tmp>=K){
				break;
			}
			tmp *= 2;
			cnt++;
		}
		ans += ((double)1/N)*pow(0.5, cnt);
	}

	printf("%.12f\n",ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N % 2 == 0)System.out.println(N);
		else System.out.println(2 * N);
		}

}


Measured memory_bytes: 23764
# -*- coding: utf-8 -*-

K = int(input())
A, B = (int(x) for x in input().split())

a = A // K
b = B // K

if b-a >= 1 or K == 1:
    print("OK")
elif B%K==0 or A%K==0:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9180
def main():
    n, m, *l = map(int, open(0).read().split())
    ab = list(zip(l[::2], l[1::2]))
    c = sorted(ab, key=lambda x: x[0])

    sum = 0
    ans = 0
    for i, j in c:
        if sum + j < m:
            sum += j
            ans += i * j
        else:
            ans += (m - sum) * i
            break
    print(ans)


if __name__ == '__main__':
    main()


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

#define ll long long

char maze[30][30];
int H, W;
int INF = 1000;

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

void chmax(int& a, int b) {
  if (a < b) a = b;
}




int BFS(int i, int j) {
  int dist[30][30];
  for (int x = 0; x < H; x++) {
    for (int y = 0; y < W; y++) {
      dist[x][y] = INF;
    }
  }
  
  dist[i][j] = 0;
  
  int maxdist = 0;
  queue<pair<int, int>> que;
  pair<int, int> P = make_pair(i, j);
  
  que.push(P);
  
  while (que.size()) {    
    pair<int, int> p = que.front();
    que.pop();
    
    int i = p.first, j = p.second;
    // (dx, dy)の4点について調べる
    for (int k = 0; k < 4; k++) {
      
      int nx = i + dx[k], ny = j + dy[k];
      // 範囲を超えていたら次へ進む
      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      
      // 壁でも次へ進む
      if (maze[nx][ny] == '#' || dist[nx][ny] != INF) continue;
      
      
      P = make_pair(nx, ny);
      dist[nx][ny] = dist[i][j] + 1;
      
      chmax(maxdist, dist[nx][ny]);
      que.push(P);
    }
  }
  
  return maxdist;    
}
  
  
int main() {
  
  cin >> H >> W;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }
  
  
  int ans = 0;
  
  // (i, j) をスタートと思った時の BFS で最大値を求める．
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j ++) {
      
      // (i, j)が壁なら次へ飛ぶ
      if (maze[i][j] == '#') continue;
      
      // (i, j) スタートでBFSして最大距離を出力
      int maxdist = BFS(i, j);
      
      chmax(ans, maxdist);
    }
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3612
#include <iostream>
using std::cin ;
using std::cout;

long long int attack(long long int hp);

int main(){
    long long int h;
    cin>>h;
    cout <<attack(h)<<'\n';
    return 0;
}

long long int attack(long long int hp){
    if(hp==1){
        return 1;
    }else{
        return (2 * (attack(hp/2)) + 1);
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  if(A<0 || A>100){
     printf("1~100の範囲で入力してください\n");
   }
   if(B<0 || B>100){
     printf("1~100の範囲で入力してください\n");
   }
   if(C<0 || C>100){
     printf("1~100の範囲で入力してください\n");
   }
   if(D<0 || D>100){
     printf("1~100の範囲で入力してください\n");
   }

  for(;;){
    C-=B;
    if(C<=0){
       printf("Yes\n");
       break; 
    }
    A-=D;
    if(A<=0){
       printf("No\n"); 
       break;
    }
  } 
    return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}

















int n,k;
int mc[N*N],inv[N*N];
void input()
{
	n=read<int>(),k=read<int>();
}
const int mo=1e9+7;
ll power(ll x,int y)
{
	ll res=1;
	for(;y;x=x*x%mo,y>>=1)if(y&1)res=res*x%mo;
	return res;
}
int Max;
void init()
{
	Max=n*k;
	mc[0]=inv[0]=1;
	For(i,1,Max)mc[i]=1ll*mc[i-1]*i%mo;
	inv[Max]=power(mc[Max],mo-2);
	Fordown(i,Max-1,1)inv[i]=1ll*inv[i+1]*(i+1)%mo;
}
ll C(int x,int y){return 1ll*mc[x]*inv[y]%mo*inv[x-y]%mo;}
int dp[N][N];
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
void work()
{
	if(k==1){puts("1");return;}
	dp[0][0]=1;
	For(i,0,n)For(j,0,i)
	{
		add(dp[i+1][j],dp[i][j]);
		add(dp[i][j+1],1ll*dp[i][j]*(n-j)%mo*C(n*k-j*(k-1)-i-1,k-2)%mo);
	}
	write(dp[n][n],'\n');
}
int main()
{
	//file();
	input();
	init();
	work();
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string,int>data;
    rep(i,n){
        string s;
        cin >> s;
        data[s]++;
    }
    int mx = 0;
    for(auto e:data)mx = max(mx,e.second);
    for(auto e:data)if(e.second == mx)cout << e.first << endl;
    return 0;
}

Measured memory_bytes: 25216
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
typedef pair<ll,ll> p; 
 

int main() {
    char c;
    cin>>c;
    char b=int(c)+1;
    cout<<b<<endl;
    
}

Measured memory_bytes: 256
n,q = map(int, input().split())
way = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
add = [0]*n
for i in range(q):
    a,b = map(int, input().split())
    add[a-1] += b
ans = [-1]*n
ans[0] = add[0]
    
stack = [(0,add[0])]
while stack:
    a,b = stack.pop()
    for i in range(len(way[a])):
        if (ans[way[a][i]]==-1):
            stack.append((way[a][i],b+add[way[a][i]]))
            ans[way[a][i]] = b+add[way[a][i]]
print(*ans)

Measured memory_bytes: 74756
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
string res;

ll pow(ll x, ll y){
    if (y == 0) return 1;
    
    if (y % 2) {
        return pow(x, y - 1) * x;
    } else {
        ll z = pow(x, y / 2);
        return z * z;
    }
}

int main(void){
    // Your code here!
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll i = 1;
    while(n != 0){
        if (n % pow(2, i) == 0){
            res = '0' + res;
        } else {
            res = '1' + res;
            n -= pow(-2, i - 1);
        }
        i++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <array>
#include <map>

#define ll long long

#define TEST

using namespace std;
const int INF = 1e9;
int dp[65][65][4000];
void chmin(int& a, int b) {
	a = min(a, b);
}

int main() {
	for (int i = 0; i < 65; i++)
		for (int j = 0; j < 65; j++)
			for (int k = 0; k < 4000; k++)
				dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	int N, K; cin >> N >> K;
	vector<int> a(N), r(K), b(K);
	for (int i = 0; i < N; i++)cin >> a[i];
	for (int i = 0; i < K; i++)cin >> r[i];
	for (int i = 0; i < K; i++)cin >> b[i];
	sort(a.rbegin(), a.rend());
	sort(r.rbegin(), r.rend());
	sort(b.rbegin(), b.rend());
	int sumred = 0, sumblack = 0, sumQ = 0;
	for (int i = 0; i < N; i++)sumQ += a[i];
	for (int i = 0; i < K; i++)sumred += r[i];
	for (int i = 0; i < K; i++)sumblack += b[i];
	for (int Q = 0; Q < N; Q++) {
		for (int i = 0; i <= Q; i++) {
			int j = Q - i;
			for (int k = 0; k < 3005; k++) {
				if (i + 1 <= K)chmin(dp[i + 1][j][k + a[Q]], dp[i][j][k] + max(a[Q] - r[i], 0));
				if (j + 1 <= K)chmin(dp[i][j + 1][k], dp[i][j][k] + max(a[Q] - b[j], 0));
			}
		}
	}
	/*
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 16; k++) {
				cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
			}
		}
	}
	*/
	int ans = INF;
	for (int i = 0; i < 65; i++) {
		for (int j = 0; j < 65; j++) {
			for (int k = 0; k < 4000; k++) {
				if (i + j != N)continue;
				if (k > sumred)continue;
				if (sumQ - k > sumblack)continue;
				chmin(ans, dp[i][j][k]);
			}
		}
	}
	if (ans >= INF)ans = -1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 69116
from fractions import gcd
A,B,C,D=map(int,input().split())
#CとDのどちらかで割り切れる
#=(Cで割り切れる)+(Dで割り切れる)-(lcm(C,D)で割り切れる)
L=(C*D)//gcd(C,D)
#(i-1)<A/C<=i
#i*C<=B<(i+1)C
i=(B//C)-((A+C-1)//C)+1
j=(B//D)-((A+D-1)//D)+1
k=(B//L)-((A+L-1)//L)+1
print(B-A+1-(i+j-k))


Measured memory_bytes: 5048
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n, k;
	while(scanf("%d%d", &n, &k)==2)
	{
		int ans;
		for(ans=1;n>=k;ans++)
			n/=k;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
n = int(input())
A = list(map(int,input().split()))

c=[0]*8
maxc=0
for a in A:
    if a>=3200:
        maxc+=1
    else:
        c[a//400]=1
minc = c.count(1)
ans = minc+maxc
print(max(minc,1),ans)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define fr(i,n) for(i = 0 ; i < n ; i++)
int dp[100000];
int h[100000];
int solve(int k,int m)
{
    int mn = INT_MAX;
    if(dp[k-1]!=-1)
        return dp[k-1];
    for(int i = m+1;i<k;i++)
    {mn = INT_MAX;
    for(int j = 1;j<=m;j++)
    {
        mn = min(mn,abs(h[i]-h[i-j])+dp[i-j]);
    }
    dp[i] = mn;
    }
    return dp[k-1];

}
int main()
{
    fio
    int n,i,j,k;
    cin>>n>>k;
    fr(i,n)
    cin>>h[i];
    dp[0]=0;
    for(i = 1; i <= k ; i++)
    {
        dp[i]=abs(h[i]-h[0]);
    }
    for(i=k+1;i<n;i++)
        dp[i] = -1;
    cout<<solve(n,k);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>

using namespace std;

int a,b,c,n,ans=0;
int main()
{
    cin>>a>>b>>c>>n;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++)
                if(i*500+j*100+k*50==n)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

ll gcd(ll a, ll b) {return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  ll a,b; cin >> a >> b;
  cout << lcm(a,b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>
#include <queue>
#include <cstring>

using namespace std;

const double EPS = 1e-8;

typedef complex<double> P;
struct L { P p, q; L(P p, P q) : p(p), q(q) {} };

class Node{
public:
	int b, p, q, num; double len;
	Node(int b, int p, int q, int num, double len) : b(b), p(p), q(q), num(num), len(len) {}
	bool operator < (const Node &nd) const {
		return make_pair(num, len) > make_pair(nd.num, nd.len);
	}
};

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

bool spIntersect(L l, P p){
	return abs(abs(l.p-p)+abs(l.q-p)-abs(l.p-l.q)) < EPS;
}

bool ssIntersect(L a, L b){
	if(abs(imag((a.q-a.p)/(b.q-b.p)))<EPS) return false;
	return true;
}

P ssCrosspoint(L a, L b){
	double A = cross(a.q-a.p, b.q-b.p);
	double B = cross(a.q-a.p, a.q-b.p);
	return b.p + B/A * (b.q-b.p);
}

int main(){
	int n;
	int num[1024][10][10];
	double len[1024][10][10];
	while(cin >> n, n){
		memset(num, -1, sizeof(num));
		priority_queue<Node> qu;
		vector<P> vp(n);
		for(int i=0;i<n;i++){
			double x, y; cin >> x >> y;
			vp[i] = P(x, y);
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				int b = (1<<i)|(1<<j);
				for(int k=0;k<n;k++){
					if(spIntersect(L(vp[i], vp[j]), vp[k])) b |= (1<<k);
				}
				qu.push(Node(b, i, j, 0, abs(vp[i]-vp[j])));
				qu.push(Node(b, j, i, 0, abs(vp[i]-vp[j])));
			}
		}
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			if(num[nd.b][nd.p][nd.q]!=-1) continue;
			num[nd.b][nd.p][nd.q] = nd.num;
			len[nd.b][nd.p][nd.q] = nd.len;
			L l = L(vp[nd.p], vp[nd.q]);
			for(int i=0;i<n;i++){
				if(nd.b&(1<<i)) continue;
				for(int j=0;j<n;j++){
					if(i==j) continue;
					if(abs(imag((l.q-l.p)/(vp[i]-vp[j]))) < EPS) continue;
					P p = ssCrosspoint(l, L(vp[i], vp[j]));
					if(dot(l.q-p, l.p-p) < -EPS || dot(vp[i]-p, vp[j]-p) < -EPS) continue;
					if(abs(p-l.q)>abs(p-l.p)||abs(p-vp[j])>abs(p-vp[i])) continue;
					int nb = nd.b|(1<<i)|(1<<j);
					for(int k=0;k<n;k++)
						if(spIntersect(L(p, vp[j]), vp[k])) nb |= (1<<k);
					qu.push(Node(nb, j, i, nd.num+1, nd.len+abs(p-l.q)+abs(p-vp[i])));
				}
			}
		}
		pair<int, double> res; res.first = n;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(num[(1<<n)-1][i][j]!=-1)
					res = min(res, make_pair(num[(1<<n)-1][i][j], len[(1<<n)-1][i][j]));
		printf("%d %.8lf\n", res.first, res.second);
	}
}

Measured memory_bytes: 4696
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0579 : Hot days **/
int D, N;
vector<int> T, A, B, C;
int dp[201][101];

int solve(int d, int old)
{
	if (d >= D) return 0;
	
	if (dp[d][old]>=0)
		return dp[d][old];
	
	int res=0;
	rep(i, N) {
		if (A[i] <= T[d] && T[d] <= B[i]) {
			int t = abs(C[i] - old) + solve(d+1, C[i]);
			res = max(res, t);
		}
	}
	
	return dp[d][old] = res;
}

int main()
{
	cin>>D>>N;
	T.resize(D);
	rep(i, D) cin>>T[i];
	A.resize(N); B.resize(N); C.resize(N);
	rep(i, N) {
		cin>>A[i]>>B[i]>>C[i];
	}
	memset(dp, -1, sizeof(dp));
	
	int ans=0;
	rep(i, N) {
		if (A[i] <= T[0] && T[0] <= B[i])
			ans = max(ans, solve(1, C[i]));
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	int A = 0, B = 0;
	const int MOD = 998244353;
	std::vector<std::vector<std::vector<int>>> dp(2 * s.size() + 1, std::vector<std::vector<int>>(2 * s.size() + 1, std::vector<int>(2, 0)));
	dp[0][0][0] = 1;
	for(int i = 0; i < 2 * s.size(); i++) {
		if(i < s.size()) {
			if(s[i] == '0') {
				A += 2;
			} else if(s[i] == '1') {
				A++;
				B++;
			} else {
				B += 2;
			}
		}
		
		for(int j = 0; j <= A; j++) {
			int X = A - j, Y = B - (i - j);
			if(X > 0) (dp[i + 1][j + 1][0] += dp[i][j][0] + dp[i][j][1]) %= MOD;
			if(Y > 0) (dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]) %= MOD;
		}
	}
	int ans = 0;
	for(auto v: dp[2 * s.size()]) for(auto w: v) (ans += w) %= MOD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 876032
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> snukes(N, 0);
  int i;
  int d;
  for (i=0;i < K;i++) {
    cin >> d;
    int j;
    while(d > 0) {
      cin >> j;
      snukes[j-1]++;
      d--;
    }
  }
  int total = 0;
  for (i=0;i < N;i++) {
    if(snukes[i] == 0) total++;
  }
    cout << total << "\n";
  return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#define N 100000

int part(int A[],int p,int r){
  int x,i,j,tmp;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;

  return i+1;
}

int main(){

  int i,j,A[N],n,q;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  q=part(A,0,n-1);

  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    if(q==i)printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
    cin >> n;
    ll a[n];
    ll cnt = 0;
    for (ll i = 0; i < n;i++){
        cin >> a[i];
        if (((i+1) & 1) and (a[i] & 1)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3584
def fourroll(s):
    count = 0
    for i in range(len(s)):
        if s[i][0]==s[i][1]:
           count +=1
           #print(count)
           if count is 3:
               print("Yes")
               return
        else:
           count = 0
    print("No")

s = []
n = int(input())
for i in range(n):
    a,b = input().split()
    s.append((a,b))
fourroll(s)

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int& h : H) cin >> h;
  vector<int> dp(N+1, 0);
  dp[2] = abs(H[0] - H[1]);
  for (int i = 3; i <= N; i++) {
    dp[i] = min(abs(H[i-1]-H[i-2])+dp[i-1], abs(H[i-1]-H[i-3])+dp[i-2]);
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
	int n, m, ans = 0;
	cin >> n >> m;
	vector<int> e[n], v;
	rep (i, n) v.push_back(i);
	rep (i, m) {
		int a, b;
		cin >> a >> b;
		e[b - 1].push_back(a - 1);
		e[a - 1].push_back(b - 1);
	}
	while (true) {
		bool ok = true;
		if (v[0] != 0) break;
		rep (i, n - 1) {
			int s = v[i], g = v[i + 1];
			if (!any_of(e[s].begin(), e[s].end(), [&](int x) {return x == g; })) ok = false;
		}
		if (ok) {
			// rep (i, n) cout << v[i] + 1 << " "; cout << endl;
			ans++;
		}
		if (!next_permutation(v.begin(), v.end())) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<time.h> 
#define loop(i,c,n) for(long long i=c;i<n;i++) 
#define iter(v) for(auto x : v)  // to iterate over entire vector/sets/map
using namespace std; 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii; 
typedef set<int> si; 
int max(int a,int b){if(a>b)return a;
return b;} 
//optimised school method
bool isPrime(ll a){ 
if(a<=1)return false ;
if(a<=3)return true ;
if(a%2==0 || a%3==0)return false;
for(ll i=5;i*i<=a;i=i+6){//Instead of checking till n, we can check till √n because a larger factor of n 
//must be a multiple of smaller factor that has been already checked.
if(a%i==0 || a%(i+2)==0)return false;}return true;}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);  
	cout.tie(0);
	//  to read input from local files  
	 #ifndef ONLINE_JUDGE 
	clock_t clocktime; 
	clocktime= clock(); 
	 freopen("input.txt", "r",stdin);
	 freopen("output.txt", "w",stdout);
	#endif
	// to read entire line with spaces 
	// string s;
	// getline(cin,s);
	
	// when amount of data is unknown
	// while(cin>>x){}    
	
 
int n ,k;
cin>>n>>k ; 
vi v(n); 
loop(i,0,n)cin>>v[i]; 
 sort(v.begin(),v.end()); 
 int  sum=0; 
 loop(j,0,k)sum+=v[j]; 
 cout<<sum;
	
	#ifndef ONLINE_JUDGE
	clocktime = clock()-clocktime; 
	double runtime  = (((double)clocktime)/CLOCKS_PER_SEC); 
	cout<<"\n--------\nTimeUsed -- "<<runtime<<"s"; 
	#endif
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE 
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int L,R,d;
    cin>>L>>R>>d;
    int c=0;
    for(int i=L;i<=R;i++)
    {
        if(i%d==0)
            c++;
    }
    cout<<c<<"\n";
    return 0;
}





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

int  main(){
  int n,m,ans=0;cin>>n>>m;
  m/=1000;
  int x=-1,y=-1,z=-1;
  for(x=0;9*x<=m-n; x++){
    if((m-n-9*x)%4==0){
      y=(m-n-9*x)/4;
      if(x+y<=n){
        z=n-x-y;
        
        break;}
    }
  }
  if(z==-1){x=-1;y=-1;}
  cout<<x<<" "<<y<<" "<<z;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int pt = 1e9 + 7;
LL n, m;

int main(){
	while(~scanf("%lld %lld", &n, &m)){
		if(abs(n - m) > 1){
			printf("0\n");
			continue;
		}
		LL num = 1;
		for(LL i = 1LL; i <= n; i++) num = (num * i) % pt;
		for(LL i = 1LL; i <= m; i++) num = (num * i) % pt;
		if(n == m) num = (num * 2LL) % pt;
		printf("%lld\n", num);
	}
	return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int c;
    vector<int> a(26,0);
    while((c=getchar())!=10 && c!=-1){
        a[c-'a']++;
    }
    for(int i=0 ;i<26;i++){
        if(a[i]==0){
            cout<<(char)(i+'a');
            return 0;
        }
    }
    cout<<"None";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////


int main() {

    ll n,m;
    L2(n, m);

    ll res = 0;
    for(ll i = 1;i * i <= m; i++){

        if(m % i == 0){
            ll x= m/i;
            if(x >=n)res = max(res, i);

            if(i >= n)res =  max(res, x);
        }
    }

    cout<< res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector<ll>
#define vpp vector<pair<ll,ll> >
#define ump unordered_map<ll,ll>
#define smp map<ll,ll>
#define st set<ll>
int main()
{
    ll n,k,q;cin>>n>>k>>q;
    ll ar[n+1];
    ll t;
    memset(ar,0,sizeof(ar));
    for(ll i=0;i<q;i++)
    {
        cin>>t;
        ar[t]++;
    }
    
    for(ll i=1;i<=n;i++)
    {
        ll cor=ar[i];
        ll neg=q-cor;
        if((k-neg)<=0)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
    }
    
}

Measured memory_bytes: 1408
# A = [list(map(int, input().split())) for _ in range(3)]
L = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
# a, b = map(int, input().split())
# S = input()
half = L/3
print(half**3)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int d, n, m = 0;
	int t[200];

	cin >> d >> n;

	for (int i = 0; i < d; i++)
		cin >> t[i];

	vector<vector<int> > cx(d);

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

		for (int j = 0; j < d; j++) {
			if (t[j] >= a && t[j] <= b)
				cx[j].push_back(c);
		}
	}

	for (int i = 0; i < d; i++)
		sort(cx[i].begin(), cx[i].end());

	int mx = abs(cx[0].back() - cx[1].front()),
		mn = abs(cx[0].front() - cx[1].back());

	for (int i = 2; i < d; i++) {
		int a = mx, b = mn;
		mx = max(a + abs(cx[i - 1].front() - cx[i].front()), b + abs(cx[i - 1].back() - cx[i].front()));
		mn = max(a + abs(cx[i - 1].front() - cx[i].back()), b + abs(cx[i - 1].back() - cx[i].back()));
	}

	cout << max(mx, mn) << endl;

	return 0;
}



Measured memory_bytes: 3264
#include <cstdio>
#include <cmath>
#include <vector> 
#include <limits>
using namespace std;
int N;
int int_inf = numeric_limits<int>::max();

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

int jump(int history, int h_destination, int h_departure){
  return history + abs(h_destination-h_departure);
}

int main(){
  scanf("%d", &N);
  vector<int> footing(N);
  vector<int> dp(N,int_inf);
  for(int i=0; i<N; i++) scanf("%d", &footing[i]);
  
  for(int i=0; i<N; i++){
    if(i==0){chmin(dp[i], 0); continue;}
    if(i==1){chmin(dp[i], jump(dp[i-1], footing[i], footing[i-1])); continue;}
    chmin(dp[i], jump(dp[i-1], footing[i], footing[i-1]));
    chmin(dp[i], jump(dp[i-2], footing[i], footing[i-2]));
  }
  printf("%d\n", dp[N-1]);
}

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

using namespace std;

int main(){
    
    int k;
    vector<int> v;

    for(int i = 0; i < 3; i++){
        int tmp;
        cin >> tmp;
        v.emplace_back(tmp);
    }

    cin >> k;

    auto max = max_element(v.begin(), v.end());

    *max = *max * pow(2, k);

    cout << accumulate(v.begin(), v.end(), 0) << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, ans = 0; cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    for(lli i=0; i<n-1; i++){
        lli k = i;
        for(lli j=i+1; j<n; j++){
            while(k<n && l[k] < l[i]+l[j]) k++;
            ans += k - (j+1ll);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
 
using lint = long long;
 
void solve() {
    int n;
    std::string s;
    std::cin >> n >> s;
 
    std::vector<lint> cnt(3, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (s[i] == "RGB"[j]) ++cnt[j];
        }
    }
 
    lint ans = cnt[0] * cnt[1] * cnt[2];
    for (int i = 0; i < n; ++i) {
        for (int l = 1; i + l * 2 < n; ++l) {
            int j = i + l * 1,
                k = i + l * 2;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                --ans;
            }
        }
    }
 
    std::cout << ans << std::endl;
}
 
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
 
    solve();
 
    return 0;
}

Measured memory_bytes: 3672
X, Y, A, B, C =map(int,input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p_ind = X-1
q_ind = Y-1
r_ind = 0

while 1:

    if p_ind == -1 and q_ind == -1:
        break

    if q_ind == -1 or p[p_ind] < q[q_ind]:
        worst = p[p_ind]
        apple = "p"
    else:
        worst = q[q_ind]
        apple = "q"
    
    if worst <= r[r_ind]:
        r_ind += 1
        if apple == "p":
            p_ind -= 1
        else:
            q_ind -= 1
            
        if r_ind == C:
            break
    else:
        break

eat_p = p[:p_ind+1]
eat_q = q[:q_ind+1]
eat_r = r[:r_ind]

if p_ind == -1:
    eat_p = []
if q_ind == -1:
    eat_q = []


print(sum(eat_p) + sum(eat_q) + sum(eat_r))

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getbit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int n; cin >> n;
  map<int, map<int, int>> m;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    ans += m[s.back()][s.front()] * 2;
    m[s.front()][s.back()]++;
    if (s.front() == s.back()) ans++;
  }
  cout << ans << '\n';
}

signed main() {
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 3712
#include <iostream>
int main() {
    std::string s, p;
    std::cin >> s >> p;
    int len_s = s.size();
    s = s + s;
    int len_p = p.size();
    std::string result = "No";
    for (int i = 0; i < len_s; i++) {
        if (s.substr(i, len_p) == p) {
            result = "Yes";
        }
    }
    std::cout << result << std::endl;
}


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

int main() {
  int n;
  cin >> n;
  int ary[n] = {0};

  for (int i = 0; i < (n - 1); i++) {
    int x; cin >> x;
    ++ary[x - 1];
  }

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

  return 0;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N, 0), S(N, 0);
    queue<int> q;
    for(int i = 0; i < M; i++) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "WA" && !S[p]) P[p]++;
        if(s == "AC") S[p] = 1;
    }
    for(int i = 0; i < N; i++) {
        if(!S[i]) P[i] = 0;
    }
    cout << accumulate(WHOLE(S), 0) << " " << accumulate(WHOLE(P), 0) << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,k,ans,num=0;
    cin >> a >> b >> c;
    cin >>k;
    
    /*for(int i=0;i<k;i++){
        num += 2*max(a, max(b,c));
    }*/
    int max_num = max(a, max(b,c));
    int sisu = pow(2, k);
    ans = a + b +c +max_num*(sisu-1);
    
    cout << ans << endl;
    return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var set = new HashSet<int>();
            for (int i = 0; i < N; i++){
                set.Add(cin.ReadInt);
            }
            WriteLine(set.Count());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13396
votos = dict()

quantidade = int(input())

for i in range(0, quantidade):
    nome = input()

    if(len(votos) == 0):
        votos[nome] = 1
    elif nome in votos:
            votos[nome] += 1
    else:
        votos[nome] = 1

maior = 0

for i in votos:
    if(votos[i] > maior):
        maior = votos[i]

nome = list()
for i in votos:
    if(votos[i] == maior):
        nome.append(i)

nome.sort()
for i in nome:
    print(i)

Measured memory_bytes: 35336
/****************************************************************************************
	test004.c: #004 ITP1_1_D
	  function: Watch

 ****************************************************************************************/
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int S;
	scanf("%d", &S);

	int h = S / 3600; S %= 3600;
	int m = S / 60;
	int s = S % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;



int main() {
    int n, k;
    cin >> n >> k;
    cout << k * (int) pow(k - 1, n - 1);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=2e5+9,inf=1e18;
int a[N],n,ans[N];
vector <int> g[N];
int dp[N];
void dfs(int v,int p){
	int pos=lower_bound(dp,dp+N,a[v])-dp;
	int tmp=dp[pos];
	dp[pos]=a[v];
	ans[v]=max(ans[p],pos);
	for(auto u:g[v]){
		if(u==p)continue;
		dfs(u,v);
	}
	dp[pos]=tmp;
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++)
    	cin >> a[i];
    for(int i=1;i<n;i++){
    	int u,v;
    	cin >> u >> v;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }
    fill(dp,dp+N,inf);
    dp[0]=0;
    dfs(1,0);
    for(int i=1;i<=n;i++)
    	cout << ans[i] << "\n";
}

Measured memory_bytes: 33552