akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000


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


int main(){
    int  n,i;

    scanf("%d", &n);
    int r=n-1;
    
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    int q = partition(0,r);
    
    for(i=0;i<n;i++){
        if(i)
            printf(" ");
         if(i==q)  printf("[");
            printf("%d",A[i]);
         if(i==q)   printf("]");
        
      
    }
      printf("\n");
      return 0;
}


Measured memory_bytes: 2140
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, a, b;

	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector <int> G[MAX];
int color[MAX];

void dfs(int r, int c){
    stack <int> S;
    S.push(r);
    color[r] = c;
    while (!S.empty()){
        int u = S.top();
        S.pop();
        for (int i=0;i< G[u].size();i++){
            int v = G[u][i];
            if(color[v] == NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id = 1;
    for (int i=0;i<n;i++){
        color[i] = NIL;
    }
    for (int u=0;u<n;u++){
        if (color[u] == NIL){
            dfs(u,id++);
        }
    }
}

int main(){
    

    int s,t,m,q;
    cin >> n >> m;
    for (int i=0;i<m;i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;
    for (int i=0;i<q;i++){
        cin >> s >> t;
        if(color[s] == color[t]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }

    }

}


Measured memory_bytes: 9008
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	int n,m;
	string s[101],t[101];

	cin>>n;
	rep(i,n)cin>>s[i];
	cin>>m;
	rep(j,m)cin>>t[j];
	sort(s,s+n,greater<string>());

	int ma=0,x=0;
	rep(i,n){
		if(s[i]==s[i+1])x++;
		else{
			x++;
			rep(j,m){
				if(t[j]==s[i])x--;
			}
			ma=max(ma,x);
			x=0;
		}
	}
	cout<<ma<<endl;

	return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c, x, y;
	cin >> a >> b >>c >> x >> y;
	ll ans;
	if (a + b > 2*c) {
		if (x < y)ans = x * 2*c + (y - x)*b;
		else ans = y * 2*c + (x - y)*a;
		ans = min(ans, max(x, y) * 2 * c);
	}
	else {
		ans = a * x + y * b;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, T = map(int, input().split())
    ans = 10**9
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(ans, c)
    if ans == 10**9:
        print("TLE")
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin >> a >> b;
    if(a*b%2==0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)
int main() {
	string s;
	int n,x;

	cin >> n>>x ;
	vector<int>a(n);
	long long sum=0;
	rep(i,n){
		cin >> a[i];
		sum+=a[i];
	}
	sort(a.begin(),a.end());
	int ans=0;
	int i=0;
	if (sum==x){
		ans=n;
		cout <<ans<<endl;
		return 0;
	}
	if (sum<x){
		ans=n-1;
		cout <<ans<<endl;
		return 0;
	}
	while(1){
//		cout << "a=" << a[i] << " x=" << x<<endl;
		if(x>=a[i]){
			x-=a[i++];
			ans++;
		}
		else{
			break;
		}
		if (x==0){
			break;
		}
	}
	cout <<ans<<endl;
	return 0;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int ok=1;
    int n,x;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>x;
        if (x%2==0)
        {
            if (x%3==0||x%5==0) ;
            else ok=0;
        }
    }
    if (ok) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  int S;
  if (op == '+'){
    S = A + B;
  }
  else if(op == '-'){
    S = A - B;
  }
  cout << S << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int lover[M] = {};
  int K, temp;
  for (int i = 0; i < N; i++) {
    cin >> K;
    for (int j = 0; j < K; j++) {
      cin >> temp;
      lover[temp - 1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (lover[i] == N) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
AB=[]
for _ in range(n):
  AB.append(list(map(int,input().split())))
AB.sort(key=lambda x:x[1])
if AB[0][0] >AB[0][1]:
    print("No")
    exit() 
for i in range(1,len(AB)):
  AB[i][0]=AB[i-1][0]+AB[i][0]
  if AB[i][0] >AB[i][1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 53720
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner s = new Scanner(System.in);
    int n[]=new int[5];
    for(int i=0;i<5;i++){
    	n[i]=s.nextInt();
    }
    s.close();
    int minA=n[0];
    if(minA>n[1])minA=n[1];
    if(minA>n[2])minA=n[2];
    int minB=n[3];
    if(minB>n[4])minB=n[4];
    System.out.println(minA+minB-50);
  }
}


Measured memory_bytes: 26312
sx, sy, tx, ty = map(int, input().split())
x = tx-sx
y = ty-sy
ans = ""
ans += "U"*y + "R"*x # s -> t
ans += "D"*y + "L"*x # t -> s
# 2週目
ans += "L"+"U"*(y+1) + "R"*(x+1)+"D" # s -> t
ans += "R"+"D"*(y+1) + "L"*(x+1)+"U" # t -> s
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
*/

ll MOD = 998244353;

vector<vector<int>> A, B, C;
vector<ll> X,Y,Z;

int N, M;

ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b % 2) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        b /= 2;
    }
    return res;
}

ll cal(const unordered_set<int>& s) {
    ll v = 0;
    for (const int t : s) {
        v += power(10, t * 18);
        v %= MOD;
    }
    return v;
}

vector<ll> process(const vector<vector<int>>& x) {
    unordered_set<int> u;
    vector<ll> res;
    set<int> rem;
    for (int i = 1;i <= N;i++) rem.insert(-i);
    for (int i = N;i > 0;i--) {
        if (u.find(i) != u.end()) continue;
        unordered_set<int> s;
        s.insert(i);
        u.insert(i);
        unordered_set<int> r;
        r.insert(i);
        rem.erase(-i);
        for (auto m : x[i]) r.insert(m);
        for (int jj : rem) {
            int j = -jj;
            if (r.find(j) != r.end() || u.find(j) != u.end()) continue;
            s.insert(j);
            u.insert(j);
            r.insert(j);
            for (auto m : x[j]) r.insert(m);
        }
        for (int j : s) {
            rem.erase(-j);
        }
        res.push_back(cal(s));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    A.resize(N+1);
    B.resize(N+1);
    C.resize(N+1);
    int a, b;
    cin >> M;
    for (int i = 0;i < M;i++) {
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    cin >> M;
    for (int i = 0;i < M;i++) {
        cin >> a >> b;
        B[a].push_back(b);
        B[b].push_back(a);
    }
    cin >> M;
    for (int i = 0;i < M;i++) {
        cin >> a >> b;
        C[a].push_back(b);
        C[b].push_back(a);
    }
    X = process(A);
    Y = process(B);
    Z = process(C);
    ll ans = 0;
    vector<set<int>> yx(Y.size());
    for (int i = 0;i < Y.size();i++) {
        for (int j = 0;j < X.size();j++) yx[i].insert(j);
    }
    for (int i = 0;i < Z.size();i++) {
        ll z = Z[i];
        unordered_set<int> use;
        for (int j = 0;j < Y.size();j++) {
            ll y = z * Y[j];
            y %= MOD;
            for (int k : yx[j]) {
                if (use.find(k) == use.end()) {
                    use.insert(k);
                    yx[j].erase(k);
                    ans += (y * X[k]) % MOD;
                    ans %= MOD;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 29896
N, Ma, Mb = map(int, input().split())
items = []
ap = items.append
a_sum =0
b_sum = 0
for i in range(N):
    a, b, c = map(int, input().split())
    ap((a, b, c))
    a_sum += a
    b_sum += b

inf = float("inf")
dp = [[[inf for _ in range(b_sum + 10)] for _ in range(a_sum + 10)] for i in range(N + 1)]
dp[0][0][0] = 0
for i in range(N):
    for a in range(a_sum):
        for b in range(b_sum):
            if dp[i + 1][a][b] > dp[i][a][b]:
                dp[i + 1][a][b] = dp[i][a][b]
            if dp[i + 1][a + items[i][0]][b + items[i][1]] > dp[i][a][b] + items[i][2]:
                dp[i + 1][a + items[i][0]][b + items[i][1]] = dp[i][a][b] + items[i][2]

ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 96604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int count = 0;
		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");

			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);

			if (a == b) {
				count++;
			} else {
				count = 0;
			}
			if (count >= 3) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 32656
n = int(input())
p = list(map(int, input().split()))
result = 0
for i in range(1, n - 1):
    mini = min(p[i-1], p[i], p[i+1])
    maxi = max(p[i-1], p[i], p[i+1])
    if p[i] != mini and p[i] != maxi:
        result += 1
print(result)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
    int n,a,center;
    vector<int> v;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> a;
        v.push_back(a-i-1);
    }
    sort(v.begin(),v.end());
    if(v.size()%2==0)center = (v[v.size()/2-1]+v[v.size()/2-1])/2;
    else center = v[v.size()/2];
    long long ans = 0;
    for(int i=0;i<v.size();i++){
        ans += abs(v[i]-center);
    }
    cout << ans << endl;
    return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
    ll minute = (60-b) + 60 * (c - (a+1)) + d;
    cout << max(0LL,minute-e) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'


VS s;


signed main()
{
    REP(i, 3){
        string p;
        cin >> p;
        s.push_back(p);
    }

    string t;
    REP(i, 3){
        t += s[i][i];
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;

int a, b, n;

string s;

int main()
{
    long double res = 0;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        long double tmp;
        string tmp2;

        cin >> tmp >> tmp2;
        if (tmp2 == "BTC")
        {
            res += tmp * 380000;
        }
        else
        {
            res += tmp;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){

  int n,i,j;
  int a[51];
  int sum = 0;

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

  for(i = 0;i < n - 1;i++){
    for(j = i + 1;j < n;j++){
      sum += a[i]*a[j];
    }
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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(){
   int k;
   cin >> k;
   string s;
   cin >> s;
   if(s.length()<=k){
      cout << s << endl;
      return 0;
   }
   string ans="";
   rep(i,k){
      ans+=s[i];
   }
   ans+="...";
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3632
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	int k, x;
	cin >> k >> x;
	k = k - 1;
	for (int i = x - k; i <= x + k; i++) {
		cout << i;
		cout << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 2e5 + 1;
const int MOD = 1e9 + 7;

long long fenwick[N];

void Set(int i, long long val) {
	for (; i < N; i |= (i + 1)) {
		fenwick[i] = max(fenwick[i], val);
	}
}

long long Get(int i) {
	long long keep = 0;
	for (; i >= 0; i = (i & (i + 1)) - 1) {
		keep = max(keep, fenwick[i]);
	}
	return keep;
}

int h[N];
int a[N];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		long long Best = Get(h[i]);
		Set(h[i], a[i] + Best);
	}
	cout << Get(n) << "\n";
	return 0;
}

Measured memory_bytes: 3456
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    
    int h[] = new int[n];
    
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    /* logic */
    
    int visible = 0;
    
    int highest = 0;
    
    for (int i = 0; i < n; i++) {
      if (h[i] >= highest) {
        highest = h[i];
        visible++;
      }
    }

    os.println(visible);
  }
}

Measured memory_bytes: 24020
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math


N = int(input())
A = [int(i) for i in input().split()]

A.sort()
len_dic = {}
for a in A:
    if a in len_dic.keys():
        len_dic[a] += 1

    else:
        len_dic[a] = 1

ans = [0,0]
for k, v in sorted(len_dic.items(),key=lambda x:-x[0]):
    if v >= 4 and ans[0] == 0:
        ans = [k,k]
    elif v >= 2:
        if ans[0]==0:
            ans[0] = k
        elif ans[1] == 0:
            ans[1] = k

print(ans[0]*ans[1])


Measured memory_bytes: 25868
////////////////////////////////////
//          ,.                    //
//         (_|,.                  //
//        ,' /, )_______   _      //
//     __j o``-'        `.'-)'    //
//    (")                 \'      //
//     `-j                |       //
//        `-._(           /       //
//           |_\  |--^.  /        //
//          /_]'|_| /_)_/         //
//             /_]'  /_]'         //
//                                //
//           PIGMEISTER™          //
//                                //
////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define mod (ll)1000000007
#define sidha(i, x, n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i, x, n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mii map<ll, ll>
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define modInv(x) powah(x, mod-2)
#define test ll t;cin>>t;while(t--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
ll powah(ll, ll);

int main()
{
    jaldi;
    
    ll h, a;
    cin >> h >> a;
    if (h%a == 0) cout << h/a;
    else cout << h/a + 1;
    
    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1;
    x = x % mod;
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1;
        x = (x*x) % mod; 
    } 
    return res; 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			String str = br.readLine();
			for (int i = n; i > 0; i--) {
				str = generate(str);
			}
			sb.append(str + "\n");
		}
		System.out.print(sb.toString());
	}

	static String generate(String str) {

		StringBuilder sb = new StringBuilder();
		char prev = str.charAt(0);
		int cnt = 1;
		for (int i = 1; i < str.length(); i++) {
			char next = str.charAt(i);
			if (next == prev) {
				cnt++;
			} else {
				sb.append(cnt).append(prev);
				prev = next;
				cnt = 1;
			}
		}
		sb.append(cnt).append(prev);
		return sb.toString();
	}
}

Measured memory_bytes: 27896
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    d = int(ipt())
    c = [int(i) for i in ipt().split()]
    s = [[int(i) for i in ipt().split()] for _ in range(d)]
    ld = [-1]*26
    edval = [0]*26

    for i in range(d):
        edval = s[i]*1
        for j in range(26):
            dl = i-ld[j]
            edval[j] += 0.5*c[j]*dl**(1.5)
        v = edval.index(max(edval))
        ld[v] = i
        print(v+1)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 76456
import java.lang.Math;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int W = sn.nextInt();
        int H = sn.nextInt();
        int x = sn.nextInt();
        int y = sn.nextInt();
        int r = sn.nextInt();
        
        System.out.println((0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) ? "Yes" : "No");
    }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL N;
    cin >> N;
    LL res = 1;
    for(int i = 2; i <= N; ++i) {
        res *= i;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


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

bool is_product_overflow(ll a, ll b) {
        if ( a< (LLONG_MAX/b)){
                return false;
        }else{
                return true;
        }
}

int main()
{
        ll a;
        long double b;
        std::cin >> a ;
        std::cin >> b ;

        //printf("%lld\n", a);
        //printf("%llf\n", b);
        //printf("%lld\n", std::floor(static_cast<long double>(a)*b));
        std::cout.precision(0);
        std::cout << std::fixed<< std::floor(a*b)<<'\n';

        return 0;
}

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

int dig_sum(int n){
  if(n<10) return n;
  return dig_sum(n/10)+n%10;
}

int main() {
  int n; cin >> n;
  if(n%dig_sum(n)==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

long long ara[3001][3001],dp[3002][3002][3],n,m;

long long solve(long long row,long long col,long long sta)
{
    if(row>n)return 0;
    else if(dp[row][col][sta]!=-1)return dp[row][col][sta];
    else
    {

        long long p=0,fr,sc,x,y,z;

        if(col+1<=m)
        {
            p=max(p,solve(row,col+1,sta));

            if(sta+1<=2){ p=max(p,ara[row][col]+solve(row,col+1,sta+1));  }
        }

        if(sta+1<=3){  p=max(p,ara[row][col]+solve(row+1,col,0));  }

        dp[row][col][sta]=p; return dp[row][col][sta];


    }


}

int main()
{

    long long k,a,b,c,i,j,ans;

    scanf("%lld %lld %lld",&n,&m,&k);

    for(i=1;i<=k;i++)
    {
        scanf("%lld %lld %lld",&a,&b,&c);
        ara[a][b]=c;
    }

    memset(dp,-1,sizeof dp);
    ans=solve(1,1,0);

    printf("%lld\n",ans);



    return 0;
}


Measured memory_bytes: 285852
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, P[21][21], M, I[30];
char D[30];
int dd[5] = { 0, 1, 0, -1, 0 };
bool v[20];

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, 21) REP(j, 0, 21) P[i][j] = -1;
    REP(i, 0, N) {
      int X, Y;
      cin >> X >> Y;
      P[X][Y] = i;
    }
    cin >> M;
    REP(i, 0, M) cin >> D[i] >> I[i];

    REP(i, 0, 20) v[i] = false;

    int x = 10, y = 10;
    REP(i, 0, M) {
      int dir;
      switch(D[i]) {
        case 'N': dir = 0; break;
        case 'E': dir = 1; break;
        case 'S': dir = 2; break;
        case 'W': dir = 3; break;
      }
      REP(j, 0, I[i]) {
        x += dd[dir];
        y += dd[dir + 1];
        // cout << x << ", " << y << endl;
        if(P[x][y] >= 0) v[P[x][y]] = true;
      }
    }

    int ans = 0;
    REP(i, 0, N) if(v[i]) ans++;
    cout << (ans == N ? "Yes" : "No") << endl;
  }

  return 0;
}

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

int main() {
  char a;
  cin >> a;
  if(a - 'Z' > 0) cout << "a" << endl;
  else cout << "A" << endl;
}


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

int main() {
  int n, S = 0;
  cin >> n;
  vector<int> v(n);
  for(int i = 0;i < n;i++) {
    cin >> v[i];
  }
  for(int i = 0;i < n;i++) {
    for(int j = i + 1;j < n;j++) {
      S += v[i] * v[j];
    }
  }
  cout << S << endl;
}

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

int main()
{
	string s,t;
	int ans = 0;
	cin >> s >> t;
	int n = s.size();

	for(int i = 0;i<n;i++)ans += (s[i]!=t[i]);
	cout << ans<<endl;
}


Measured memory_bytes: 3824
N = gets.to_i
red = (1..N).map { gets.split.map &:to_i }
blue = (1..N).map { gets.split.map &:to_i }

s = 0
while blue.size>0
  min_x_blue = blue.min
  pair_red = red.select {|x, y| x<min_x_blue[0] and y<min_x_blue[1] }
    .sort {|r1, r2| r1[1]<=>r2[1] }.last
  if pair_red
    s+=1
  end
  blue.delete(min_x_blue)
  red.delete(pair_red)
end
puts s


Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
    int n1,n2,GCD,LCM,a,b,x,y;
    while(scanf("%d %d",&n1,&n2)!=EOF){
            x=n1;
            y=n2;
       while(n1 != n2)
 {
  if(n1 > n2)
   n1 = n1 - n2 ;
  if(n2 > n1)
   n2 = n2 - n1 ;
 }
 GCD = n1 ;
 a=x/GCD;
 b=y/GCD;
 LCM=a*b*GCD;
 
 printf("%d %d\n",GCD,LCM);

    }
    return 0;
}

Measured memory_bytes: 596
n=int(input())
l=sorted([int(i) for i in input().split()])

a=0
b=[0]*3
for i in range(n-2):
  b[0]=l[i]
  for j in range(i+1,n-1):
    b[1]=l[j]
    for k in range(j+1,n):
      b[2]=l[k]
      if b[0]<b[1]<b[2] and b[0]+b[1]>b[2]:
        a+=1
print(a)        

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

kisuu = 0
four_baisuu = 0

for a in A:
    if a % 2 != 0:
        kisuu += 1
    elif a % 4 == 0:
        four_baisuu += 1
if kisuu <= four_baisuu:
    print("Yes")
elif kisuu + four_baisuu == len(A) and kisuu == four_baisuu + 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62576
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
static int desc(const void *a, const void *b);
static int asc(const void *a, const void *b);
 
int main (void){
    int i,j;
    int x,y,z;
    int a,b,m;
    int min = 2000000000;
    int mina = 2000000000;
    int minb = 2000000000;
    a = b = m = 0;
    int count = 0;
    double dx;
    int box_a[200001]={};
    int box_b[200001]={};
    char text[200001]={};
    char s[200001]={};
    char t[200001]={};
    char alf[256] = {"abcdefghijklmnopqrstuvwxyz"};
    char alfb[256] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    char sample_text[256];
 
    // Input Area //
    scanf("%d",&x);
    y = x / 500;
    if (y > 0){
        a = 1000 * y;
        x = x - y * 500;
    }
    y = 0;
    y = x / 5;
    if (y > 0){
        b = 5 * y;
        x = x - y * 5;
    }
    printf("%d",a+b);
    //scanf("%s %s",s,t);
    //scanf("%d %d",&x,&y);
    //scanf("%s",text);
 
    /*
    if(strcmp(text,s)==0){
        x--;
    }else if(strcmp(text,t)==0){
        y--;
    }
    */
    //printf("%d %d",x,y);
    //scanf("%s",&sample_text);
    //scanf("%s",&text);
 
    /*
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&box[i]);
    }
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    printf("\n");
    qsort(box,n,sizeof(int),desc);
    
    */
    // Output Area //
    
    /*
    for(i = 0; i < n; i++){
        printf("%d",box[i]);
    }
    */
 
}
 
static int desc(const void *a, const void *b){
    return *(int *) b - *(int *) a;
}
 
static int asc(const void *a, const void *b){
    return *(int *) a - *(int *) b;
}
 
 
/* KonoLvBANK
 
配列降順ソート
qsort(box,n,sizeof(int),desc);
配列昇順ソート
qsort(box,n,sizeof(int),asc);
 
アルファベットを次の単語に変えるやつ
    while(1){
        if (text[i] == '\0'){
            break;
        }
        for(j = 0; j < 26; j++){
            if (text[i] == alf[j]){
                if (j != 25){
                    text[i] = alf[j + 1];
                }else{
                    text[i] = alf[0];
                }
                break;
            }
        }
        i++;
    }
    */

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

s = input()
t = input()

lens = len(s)
lent = len(t)

dp = [[0 for _ in range(lent+1)] for _ in range(lens+1)]

ans_index = []

for i in range(1, lens+1):
    for j in range(1, lent+1):
        if s[i-1] == t[j-1]:
            candidate = max(dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1])
            if candidate == dp[i-1][j-1]+1:
                dp[i][j] = dp[i-1][j-1]+1
                continue
            elif candidate == dp[i-1][j]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = dp[i][j-1]
        else:
            candidate = max(dp[i-1][j], dp[i][j-1])
            if candidate == dp[i-1][j]:
                dp[i][j] = dp[i-1][j]
                continue
            else:
                dp[i][j] = dp[i][j-1]

i, j = lens, lent
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
        continue
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
        continue
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
print(ans)


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	for(int i = -1000; i <= 1000; i++){
		for(int j = -1000; j <= 1000; j++){
			if(pow(i, 5) - pow(j, 5) == x){
				cout << i << " " << j;
				return 0;
			}
		}
	}

	return 0;
}

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

#define int long long

using namespace std;



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

    string A, B;
    cin >> A >> B;

    int cont = 0;

    for(int i = 0 ; i < A.size() ; i++)
    {
    	if(A[i] != B[i])cont++;
    }

    cout << cont << '\n';

    return 0;
}

Measured memory_bytes: 3880
#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int P[N];
    double D[N] = {0};
    for(int i=0; i<N; i++){
        cin >> P[i];
        D[i] = (1 + P[i]) / 2.0;
    }

    double Total = 0, Ans;
    for(int i=0; i<K; i++){
        Total += D[i];
    }
    Ans = Total;
    for(int i=0; i<N-K; i++){
        Total += D[K+i] - D[i];
        if(Ans < Total){
            Ans = Total;
        }
    }
    
    cout << fixed << setprecision(6) << Ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}
ll dp[1005][1005];
void solve()
{
  //code begins from here//
  ll h,w;
  char x;
  cin>>h>>w;
  dp[0][0]=1;
  lop(i,h)
  {
      lop(j,w)
      {
        cin>>x;
        if(i+j!=0 && x=='.')
        {
            if(i-1>=0) (dp[i][j]+=dp[i-1][j])%=M1;
            if(j-1>=0) (dp[i][j]+=dp[i][j-1])%=M1;
        }
      }
  }
  cout<<dp[h-1][w-1]<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
    //cin>>testcase;
    while(testcase--) solve();
    return 0;
}


Measured memory_bytes: 11456
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=305;
int n;
int a[4];
double dp[3*N][2*N][N],nd;
bool vis[3*N][2*N][N];
double f(int a,int b, int c){
	if(a+b+c==0)return 0;
	double &r=dp[a][b][c];
	bool &vi=vis[a][b][c];
	if(vi)return r;
	vi=1;
	if(a)r=(1+f(a-1,b,c))*a/nd;
	if(b)r+=(1+f(a+1,b-1,c))*b/nd;
	if(c)r+=(1+f(a,b+1,c-1))*c/nd;
	r+=1-(a+b+c)/nd;
	double D=(a+b+c)/nd;
	r/=D;
	return r;
}
int main(){FIN;
	cin>>n;
	nd=n;
	fore(i,0,n){
		int x;cin>>x;
		a[x]++;
	}
	cout<<fixed<<setprecision(15)<<f(a[1],a[2],a[3])<<"\n";
}

Measured memory_bytes: 492928
readlines.each do |l|
  puts case l.to_f.ceil
  when 0..48; "light fly"
  when 48..51; "fly"
  when 51..54; "bantam"
  when 54..57; "feather"
  when 57..60; "light"
  when 60..64; "light welter"
  when 64..69; "welter"
  when 69..75; "light middle"
  when 75..81; "middle"
  when 81..91; "light heavy"
  else "heavy"
  end
end

Measured memory_bytes: 6108
#入力取得
N = int(input())
a = [int(i) for i in input().split()]

#aを降順にソートする。
a.sort(reverse=True)

a_sum = 0
b_sum = 0

for i in range(len(a)):
    if i % 2 == 0:
        a_sum = a_sum + a[i]

    elif i % 2 == 1:
        b_sum = b_sum + a[i]


print(a_sum - b_sum )

Measured memory_bytes: 3060
s = gets.chomp.split('')
n = s.length
temp = s.clone

0.upto (n - 1) do |i|
  0.upto (n - 1) do |j|
    s.slice!(i, j)
    if s.join('') == 'keyence'
      puts 'YES'
      exit
    end
    s = temp.clone
  end
end

puts 'NO'


Measured memory_bytes: 3836
#include<stdio.h>
int isprime(int n) {
	for(int i=2;i*i<=n;i++) {
		if(n%i==0) return 0;
	}
	return 1;
}

int main() {
	int n,p1,q1,i;
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		for(i=n;i>=5;i--) {
			if(isprime(i)==1) {
				if(isprime(i-2)==1) {
					q1=i; p1=i-2;
					break;
				}
			}
		}
		printf("%d %d\n",p1,q1);
	}
	return 0;
}

Measured memory_bytes: 1792
#include <functional>
#include <iostream>
#include <vector>
#ifndef SEGMENT_TREE
#define SEGMENT_TREE

template <class T> class SegmentTree {
public:
  SegmentTree(const int n, const T id, std::function<T(T, T)> op, std::function<T(T, T)> updateOp)
      : id(id), op(op), updateOp(updateOp) {
    leafNum = 1;
    while (leafNum < n)
      leafNum *= 2;
    data = std::vector<T>(2 * leafNum - 1, id);
  }

  void update(const int index, const T value) {
    int i = leaf(index);
    data[i] = updateOp(data[i], value);
    while (i > 0) {
      i = parent(i);
      data[i] = op(data[rightChildIndex(i)], data[leftChildIndex(i)]);
    }
  }

  T find(const int l, const int r) { return query(l, r, 0, 0, leafNum); }

private:
  int leftChildIndex(const int parent) { return parent * 2 + 1; }

  int rightChildIndex(const int parent) { return parent * 2 + 2; }

  int parent(const int child) { return (child - 1) / 2; }

  int leaf(const int index) { return index + leafNum - 1; }

  T query(const int l, const int r, const int node, const int al, const int ar) {
    if (r <= al || ar <= l)
      return id;
    if (l <= al && ar <= r)
      return data[node];
    int mid = (al + ar) / 2;
    T leftValue = query(l, r, leftChildIndex(node), al, mid);
    T rightValue = query(l, r, rightChildIndex(node), mid, ar);
    return op(leftValue, rightValue);
  }

private:
  std::vector<T> data;
  int leafNum;
  T id;
  std::function<T(T, T)> op;
  std::function<T(T, T)> updateOp;
};
#endif

int main() {
  int n, q;
  std::cin >> n >> q;
  SegmentTree<long long int> seg(
      n, (1LL << 31) - 1, [](long long int a, long long int b) -> long long int { return std::min(a, b); },
      [](long long int _, long long int b) -> long long int { return b; });
  for (int i = 0; i < q; i++) {
    int com, x, y;
    std::cin >> com >> x >> y;
    if (com == 0) {
      seg.update(x, y);
    } else {
      std::cout << seg.find(std::min(x, y), std::max(x, y) + 1) << std::endl;
    }
  }
}



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

int main()
{
	long long a,b,c,k;
	cin >> a >> b >> c >> k;
	long long maxm = max(a,max(b,c));
	long long sum = a+b+c;
	sum -= maxm;
	for(int i = 1 ; i <= k ; i++)
		maxm *= 2;
	sum += maxm;
	cout << sum << '\n';
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int D;

int main()
{
  cin >> D;

  switch (D)
  {
  case 25:
    cout << "Christmas" << endl;
    break;
  case 24:
    cout << "Christmas Eve" << endl;
    break;
  case 23:
    cout << "Christmas Eve Eve" << endl;
    break;
  case 22:
    cout << "Christmas Eve Eve Eve" << endl;
    break;
  default:
    break;
  }

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long H, N;
	cin >> H >> N;
	vector<int>A(N);
	long long sum = 0;
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
		sum += A.at(i);
	}
	if (sum >= H) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

int main()
{
    int d, n;
    cin>>d>>n;
    if(n%100 != 0)
    {
        cout <<int(n * pow(100, d))<< endl;
    }
    else
    {
        cout <<int((n + 1) * pow(100, d))<< endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,M;cin >> N >> M;
  ll ans = 0;
  if(2*N<=M){
    ans += N;
    M-=2*N;
  }else{
    ans += M/2;
    M %= 2;
    N=0;
  }
  ans += M/4;
  cout << ans << endl;
  return 0;
}


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

int n;
ll m;
vector<int> a;

bool chk(int x)
{
  ll cnt = 0;
  rep(i, n)
  {
    int pos = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
    cnt += n - pos;
  }
  return cnt < m;
}

int main()
{
  cin >> n >> m;
  a.resize(n);
  rep(i, n)
    cin >> a[i];
  sort(a.begin(), a.end());
  int ng = 0, ok = 2 * 100000 + 1;
  while (ok - ng > 1)
  {
    int mid = (ok + ng) / 2;
    if (chk(mid))
      ok = mid;
    else
      ng = mid;
  }
  vector<ll> csum(n + 1, 0);
  rep(i, n)
    csum[i+1] = csum[i] + a[i];
  ll ans = 0;
  rep(i, n)
  {
    int pos = lower_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
    int cnt = n - pos;
    ans += csum[n] - csum[pos] + (ll)cnt * a[i];
    m -= cnt;
  }
  ans += (ll)m * ng;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double DET = 0.00000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	ll A, B;
	cin >> A >> B;
	if (A % 2 == 0) {

		if (B % 2 == 1) {
			cout << (int)(((B - A + 1) / 2) % 2 == 1);
		}
		else {
			ll ans = ((int)(((B - A + 1 - 1) / 2) % 2 == 1)) ^ B;
			cout << ans;
		}
	}
	else {

		if (B % 2 == 1) {
			ll ans = ((int)(((B - (A + 1) +1) / 2) % 2 == 1)) ^ A;
			cout << ans;
		}
		else {

			ll ans = ((int)(((B - (A + 1) + 1 -1) / 2) % 2 == 1)) ^ A ^ B;
			cout << ans;


		}

	}





}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<assert.h>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const ll p=1000000007;
const int N=310;
void add(ll &a,ll b)
{
	a=(a+b)%p;
}
int n;
int a[2*N];
ll f[2*N][N][N];
int b[2*N];
int c[2*N];
int t;
int main()
{
	open2("f");
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		scanf("%d",&a[i]);
	int cnt=0;
	for(int i=1;i<=2*n;i+=2)
		if(a[i]!=-1&&a[i+1]!=-1)
			b[a[i]]=b[a[i+1]]=2;
		else if(a[i]!=-1)
			b[a[i]]=1;
		else if(a[i+1]!=-1)
			b[a[i+1]]=1;
		else
			cnt++;
	for(int i=1;i<=2*n;i++)
		if(b[i]==1)
			c[++t]=1;
		else if(b[i]==0)
			c[++t]=2;
	f[t][0][0]=1;
	for(int i=t;i>=1;i--)
		for(int j=0;j<=t&&j<=n;j++)
			for(int k=0;k<=t&&k<=n;k++)
				if(c[i]==1)
				{
					 add(f[i-1][j+1][k],f[i][j][k]);
					 if(k)
					 	add(f[i-1][j][k-1],f[i][j][k]);
				}
				else
				{
					add(f[i-1][j][k+1],f[i][j][k]);
					if(k)
						add(f[i-1][j][k-1],f[i][j][k]);
					if(j)
						add(f[i-1][j-1][k],f[i][j][k]*j);
				}
	ll ans=f[0][0][0];
	for(int i=1;i<=cnt;i++)
		ans=ans*i%p;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 450688
import sys
import fractions
N, M = map(int, input().split())
S = input()
T = input()

g = fractions.gcd(N, M)
L = N * M // g

def check(U1, U2):
  s1 = L // len(U1)
  s2 = L // len(U2)
  for i in range(len(U1)):
    if (i * s1) % s2 == 0:
      j = (i * s1) // s2
      if U1[i] != U2[j]:
        return False
  return True

if check(S, T) and check(T, S):
  print(L)
else:
  print(-1)

Measured memory_bytes: 5344
#include<stdio.h>
int main()
{
  int a[1000]={0};
  int alice=0,bob=0;
  int i=0,tmp=0,j=0,n=0;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }  
  for(i=0;i<n;i++){
  	for(j=0;j<n;j++){
    	if(a[i]>a[j]){
          tmp=a[i];
          a[i]=a[j];
    	  a[j]=tmp;    
        }
    }
  }
 
  for(i=0;i<n;i+=2){
    alice+=a[i];
  }
  for(i=1;i<n;i+=2){
    bob+=a[i];
  }
  printf("%d",alice-bob);
    return 0;
  }

Measured memory_bytes: 1696