akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	int cnt = 0;

	    	int small = Math.min(A, B);
	    	for(int i=small; i>=1; i--) {

	    		if(A % i == 0 && B % i == 0){
	    			if(++cnt == K) {
	    				System.out.println(i);
	    				return;
	    			}
	    		}
	    	}
    	}
    }
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main(void) {
    int n;
    int a[2][100];
    int s[2][100];
    cin >> n;
    for(int i = 0;i < 2;i++) {
        for(int ii = 0;ii < n;ii++ )
            cin >> a[i][ii];
    }
    s[0][0] = a[0][0];
    s[1][0] = a[1][0];
    for(int i = 0;i < 2;i++ ) {
        for(int ii = 1;ii < n;ii++)
            s[i][ii] = s[i][ii-1] + a[i][ii];
    }
    int res = s[0][0] + s[1][n-1];
    for(int i = 1;i < n;i++) {
        res = max(res,s[0][i] + (s[1][n-1] - s[1][i-1]));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,w;
cin>>w>>a>>b;
if(b>(a+w))	{
	cout<<b-(a+w);
}
else if(a>(b+w)){
	cout<<a-(b+w);
}
else
{
cout<<0;	
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    cout << fixed << setprecision(7);
    int n;
    cin >> n;
    double a=n;
    if(n%2==0) cout << 0.5 << endl;
    else cout << (a+1)/2/a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>
#include<atcoder/all>

using ll=long long;
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

using namespace std;
int main()
{
	ll N, Q;
	cin >> N >> Q;
	atcoder::fenwick_tree<ll> ft(N);
	rep(i, 0, N) {
		ll a;
		cin >> a;
		ft.add(i, a);
	}
	rep(i, 0, Q) {
		ll t;
		cin >> t;
		if (t) {
			ll l, r;
			cin >> l >> r;
			cout << ft.sum(l, r) << endl;
		}
		else {
			ll p, x;
			cin >> p >> x;
			ft.add(p, x);
		}
	}

	return 0;
}



Measured memory_bytes: 8212
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> A(1 * 1e5 + 1000, 0), B(1 * 1e5 + 1000, 0);
  char c = S[0];
  int num = 0, id1 = 0;
  REP(i, N) {
    if (c != S[i]) {
      if (c == '1') {
        A[id1] = num;
        num = 0;
        id1++;
      } else {
        B[id1] = num;
        num = 0;
        id1++;
      }
      c = S[i];
    }
    num++;
  }
  if (c == '1') {
    A[id1] = num;
  } else {
    B[id1] = num;
  }
  ll ans = 0;
  num = 0;
  int one = 0, l = 0;
  for (int i = 0; i < N; i++ && one <= K) {
    if (B[i] != 0) {
      if (one >= K) break;
      one++;
    }
    num += A[i] + B[i];
    l = i;
  }
  ans = max<ll>(num, ans);
  int r = 0;
  for (int i = l + 1; i <= N; i++) {
    if (A[r] != 0) {
      num -= B[r] + A[r];
      r++;
    }
    num -= B[r] + A[r];
    r++;
    if (B[i] != 0) {
      num += B[i] + A[i];
      i++;
    }
    num += B[i] + A[i];
    ans = max<ll>(ans, num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4296
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

int main()
{
	int n,m;
	cin>>n>>m;
	vvi adj(n,vi(n,INFTY));
	rep(i,n)
		adj[i][i]=0;
	rep(i,m){
		int a,b,c,d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		adj[a-1][b-1]=c;
		adj[b-1][a-1]=d;
	}
	rep(k,n) rep(i,n) rep(j,n)
		adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
	
	int src,dst,money,price;
	scanf("%d,%d,%d,%d",&src,&dst,&money,&price);
	
	int res=money-(price+adj[src-1][dst-1]+adj[dst-1][src-1]);
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		
		int a = 1;
		
		for(int i = 2; i <= 32; i++) {
			for(int j =2; j <=10; j++) {
				double b = Math.pow(i, j);
				if(b <= X) {
					if(X - a >= X - b) {
						a = (int)b;
					}
				} else {
					break;
				}
			}
		}
		if(X < 4) {
			System.out.println(X);
		} else {
			System.out.println(a);
		}
	}
}


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


int main(){
  int N;
  cin >> N;
  int A[1100];
  
  for(int i =0; i<N ;i++){
    cin >> A[i];
  }
  
  for(int i = 0; i < N; i++){
    int v = A[i];
    int j = i-1;
    while( j >=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v; 
    }
    
    for(int j = 0; j < N; j++){
      if(j == N-1){
        cout << A[j]<< endl;
        break;
      }
      cout << A[j]<< " ";
    }

  }
}




Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define N 500005

using namespace std;

int n,m;char s[N],ss[N][2],op[N][2];

inline bool check(int x,int y){
    for (int i=1;i<=m;i++){
        if (s[x]==ss[i][1]){
            if (op[i][1]=='L') x--;
            else x++;
        }
    }
    return x==y;
}

int main(){
    scanf("%d%d",&n,&m);
    scanf("%s",s+1);
    for (int i=1;i<=m;i++){
        scanf("%s",ss[i]+1);
        scanf("%s",op[i]+1);
    }int ans=n;
    int l=1;int r=n;
    int L=1;int R=n;
    while (l+1<r){
        int mid=(l+r)>>1;
        if (check(mid,0)) l=mid;
        else r=mid;
    }
    if (check(r,0)) ans-=r;
    else if (check(l,0)) ans-=l;
    while (L+1<R){
        int mid=(L+R)>>1;
        if (check(mid,n+1)) R=mid;
        else L=mid;
    }
    if (check(L,n+1)) ans-=n-L+1;
    else if (check(R,n+1)) ans-=n-R+1;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

const bool debug = 0;

struct Fenwick {

    std::vector<int> data;
    
    Fenwick(int n) : data(n+1, 0) { }
    
    void inc(int p, int delta = 1) {
        for (int i = p; i < (int)data.size(); i = (i | (i+1))) {
            data[i] += delta;
        }
    }
    
    int get(int r) {
        int ret = 0;
        for (int i = r; i >= 0; i = (i & (i+1)) - 1) {
            ret += data[i];
        }
        return ret;
    }
};

typedef long long ll;

int median(const std::vector<int>& arr, int begin, int after) {
    std::vector<int> temp(arr.begin()+begin, arr.begin()+after);
    std::sort(temp.begin(), temp.end());
    int len = after-begin;
    if (len % 2 == 0) {
        return temp[len / 2];
    } else {
        return temp[(len-1) / 2];
    }
}

int fast (const std::vector<int>& arr) {
    const int n = (int)arr.size()+1;
    int low = -1, high = (int)1e9+1;
    while (high - low > 1) {
        if (debug) {
            printf("------------------------------------------------\n");
            printf("low = %d, high = %d\n", low, high);
        }
        int mid = (low + high) / 2;
        std::vector<int> sum{0};
        for (auto& it : arr) {
            sum.push_back(sum.back() + (it >= mid ? 1 : -1));
        }
        Fenwick fw(2 * n + 1);
        fw.inc(n);
        ll count = 0;
        for (int i = 1; i < n; ++i) {
            count += fw.get(n+sum[i]);
            fw.inc(n+sum[i]);
        }
        if (debug) {
            ll slow = 0;
            for (int begin = 0; begin < (int)arr.size(); ++begin) {
                for (int after = begin+1; after <= (int)arr.size(); ++after) {
                    slow += (median(arr,begin,after) >= mid);
                }
            }
            printf("mid = %d, fast = %lld, slow = %lld\n", mid, count, slow);
            fflush(stdout);
            assert(slow == count);
        }
        if (count >= (ll(n)*(n-1) / 2 + 1) / 2) {
            low = mid;
        } else {
            high = mid;
        }
    }
    return low;
}

int main() {
    int n; 
    while (scanf("%d", &n) == 1) {
        std::vector<int> arr(n);
        for (auto& it : arr) scanf("%d", &it);
        printf("%d\n", fast(arr));
    }
    return 0;
}

Measured memory_bytes: 2452
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>

#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));
#define ll long long int

void merge_sort(int *a, int n){
    if(n < 2) return;
    int mid = n / 2;
    int *left = malloc(sizeof(int) * mid);
    int *right = malloc(sizeof(int) * (n - mid));
    for(int i = 0; i < mid; ++i){
        left[i] = a[i];
    }
    
    for(int i = 0; i < n - mid; ++i){
        right[i] = a[i + mid];
    }
    merge_sort(left, mid);
    merge_sort(right, n - mid);
    for(int i = 0; i < n; ++i){
        printf("%d\t", a[i]);
    }
    printf("\n");
    int li = 0, ri = 0;
    for(int i = 0; i < n; ++i){
        if(li >= mid){
            for(; ri < n - mid; ++ri){
                a[i] = right[ri];
                ++i;
            }
            break;
        }
        
        if(ri >= n - mid){
            for(; li < mid; ++li){
                a[i] = left[li];
                ++i;
            }
            break;
        }
        
        if(left[li] < right[ri]){
            a[i] = left[li];
            li++;
        }else{
            a[i] = right[ri];
            ri++;
        }
    }
    free(left);
    free(right);
}

int main(){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a == b && b == c){
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll x = min(K, A);
    ll r = max(K - x, 0LL);
    ll y = min(max(r, 0LL), B);
    ll r2 = max(K - x - y, 0LL);
    ll z = min(max(r2, 0LL), C);
    cout << x + (y * 0) + z * (-1) << endl;
    return 0;
}

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

int main(){
	int n;
  	cin>>n;
  
  	vector<int> t(n);
  	int mysum=0;
  
  	for (int i=0;i<n;i++){
      cin>>t.at(i);
      mysum+=t.at(i);
    }
  
 	int m;
  	cin>>m;
  
  for (int i=0;i<m;i++){  
 		int p,x,ans;
    	cin>>p>>x;
   		ans=mysum+x-t.at(p-1);
    	cout<<ans<<endl;
  }
}    

Measured memory_bytes: 256
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=2e5+5;
int n,k;
int a[N];
int dist(int x)
{
	if(x!=n&&x!=0)
		return a[x+1]-a[x];
	else 
		return k-a[n]+a[1];
}
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	cin>>k>>n;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	
	int ans=INF;
	for(i=1;i<=n;i++)
	{
		ans=min(ans,k-dist(i-1));
		ans=min(ans,k-dist(i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt(), m = in.nextInt();
        int[][] M = new int[n][m];
        int[] V = new int[m];

        //input
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++)M[i][j]=Integer.parseInt(in.next());
        }

        for(int i = 0; i < m; i++) V[i] = Integer.parseInt(in.next());

        //solve and output
        for(int i = 0; i < n; i++){
            int sum = 0;
            for(int j = 0; j < m; j++)sum += M[i][j] * V[j];
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 38952
ns = map(int, raw_input().split(" "))
count = 0
for loop in xrange(4):
	for i in xrange(4):
		if ns[i] < ns[i+1]:
			ns[i] , ns[i+1] = ns[i+1] , ns[i]
print ns[0],ns[1],ns[2],ns[3],ns[4]

Measured memory_bytes: 4212
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    vi candy(3);
    rep(i,3)cin >> candy[i];
    SORT(candy);
    if(candy[0]+candy[1]==candy[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

const int N=1e5+20;

int n,m,p,ac,cost[N],ans;
char s[10];
bool solved[N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d %s",&p,s);
		if(solved[p]) continue;
		if(s[0]=='A') solved[p]=true,ac++;
		else cost[p]++;
	}

	for(int i=1;i<=n;i++)
		if(solved[i]) ans+=cost[i];
	printf("%d %d",ac,ans);
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
    int c,i,b,card[4][13]={0};
    char a;
    scanf("%d",&c);

    for(i=0;i<=c*2;i++){
        scanf("%c %d",&a,&b);
        switch(a){
            case 'S':
            card[0][b-1]=b;
            break;
            case 'H':
            card[1][b-1]=b;
            break;
            case 'C':
            card[2][b-1]=b;
            break;
            case 'D':
            card[3][b-1]=b;
            break;
        }
    }

    for(i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(card[i][j-1]==0){
                switch(i){
                    case 0:
                    printf("S %d\n",j);
                    break;
                    case 1:
                    printf("H %d\n",j);
                    break;
                    case 2:
                    printf("C %d\n",j);
                    break;
                    case 3:
                    printf("D %d\n",j);
                    break;
                }
            }
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 2060
n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    f = 0
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            f = 1
            break
    if(f == 0):
        print(ans)

Measured memory_bytes: 21576
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k;
	cin >> n >> k;
	if(k > (n - 1) * (n - 2) / 2){
		cout << -1 << endl;
		return 0;
	}
	bool isEdge[110][110] = {};
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++) isEdge[i][j] = true;
	}
	int cnt = 0;
	for(int i = 1;i < n;i++){
		for(int j = i + 1;j < n;j++){
			if(cnt < k){
				isEdge[i][j] = false;
				cnt++;
			}
		}
	}
	vector<P> vec;
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			if(isEdge[i][j]) vec.emplace_back(i,j);
		}
	}
	cout << vec.size() << endl;
	for(P p : vec) cout << p.first + 1 << " " << p.second + 1 << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string A, B, C;
  cin >> A >> B >> C;
  if (A.back() == B.front() && B.back() == C.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int main(void)
{

  char s[100000];
  int  n, i, a, p=0, q=0;
  scanf("%s",s);
  n=strlen(s);
  a=0;
  for(i=1;i<n;i++){
        if((s[i-1]=='0')&&(s[i]=='0')){
                s[i]='1';
                a++;
        }
        else if((s[i-1]=='1')&&(s[i]=='1')){
                s[i]='0';
                a++;
        }
  }
  printf("%d\n",a);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n, q, b, t, e;
	std::vector<long> a;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	a.resize(n, 0);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> a[i];
#else
		std::cin >> a[i];
#endif
	}


#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> b >> e >> t;
#else
		std::cin >> b >> e >> t;
#endif

		std::swap_ranges(a.begin() + b, a.begin() + e, a.begin() + t);
	}

	std::cout << a[0];
	for(int i = 1; i < a.size(); i++){
		std::cout << " " << a[i];
	}
	std::cout << std::endl;
	return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>

int main()
{
  int a,b,c;
  scanf("%d %d %d", &a,&b,&c);
  if(a+b == c || a == b+c || a+c == b)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map> 
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pb push_back
int main(int argc, char** argv) {
	string s;
	cin>>s;
	if(s.length()%2!=0){printf("No");
	return 0;
	}
	rep(i,0,s.length()-1)
	{
		if(s[i]!='h'||s[i+1]!='i')
		{
			printf("No");
			return 0;
		}
		i++;
		
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
# Problem C - Monsters Battle Royale

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
count = 0
is_finished = True

# count
while is_finished:
    min_hp = float('INF')
    min_index = 0
    for i in range(N):
        if a_nums[i]==0:
            continue
        if min_hp>a_nums[i]:
            min_hp = a_nums[i]
            min_index = i
    for i in range(N):
        if i==min_index:
            continue
        a_nums[i] = a_nums[i] - min_hp*(a_nums[i]//min_hp)
        if a_nums[i]<0:
            a_nums[i] = 0
    if len(set(a_nums))==2 and 0 in set(a_nums):
        is_finished = False

# output
ans = max(a_nums)
print(ans)


Measured memory_bytes: 14436
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<int>t(N);
	vector<int>x(N);
	vector<int>y(N);
	rep(i, N) {
		cin >> t[i] >> x[i] >> y[i];
	}
	int cnt = 0;
	rep(i, N) {
		if (i == 0) {
			if (t[i] < x[i] + y[i]) {
				cnt++;
			}
			else if ((t[i] - x[i] - y[i]) % 2 != 0) {
				cnt++;
			}
		}
		else {
			if (t[i] - t[i - 1] < (x[i] - x[i - 1]) + (y[i] - y[i - 1])) {
				cnt++;
			}
			else if ((t[i] - t[i - 1] - (x[i] - x[i - 1]) - (y[i] - y[i - 1])) % 2 != 0) {
				cnt++;
			}
		}
	}
	if (cnt != 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}




Measured memory_bytes: 1408
S = input()
head = S[:2]
tail = S[2:]

MMYY = False
YYMM = False

if 1 <= int(head) <= 12:
    MMYY = True
if 1 <= int(tail) <= 12:
    YYMM = True

if MMYY and YYMM:
    print("AMBIGUOUS")
elif MMYY:
    print("MMYY")
elif YYMM:
    print("YYMM")
else:
    print("NA")



Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <list>
using namespace std;
list<int> L;    //??????????????????????????????????????????????????????????????????
bool DAG_check = false;

void visit(int n,vector<vector<int>>& graph,vector<int>& mark) {
	if (DAG_check == true) {
		return;
	}
	if (mark[n] == 1) {
		DAG_check = true; return;
	}
	else {
		if (mark[n] == 0) {
			mark[n] = 1;
			for (int i = 0; i < graph[n].size();i++) {
				visit(graph[n][i], graph, mark);
			}
			mark[n] = 2;
			L.emplace_back(n);
		}
	}
}

int main() {
	int V, E; cin >> V >> E;
	vector<vector<int>> graph(V);
	vector<int> mark(V,0); //????????????????????°    1???????????????????????????2??\??\??\?????????
	for (int i = 0; i < E;i++) {
		int s, t; cin >> s >> t;
		graph[s].emplace_back(t);
	}
	
	for (int i = 0; i < V;i++) {
		if (mark[i] == 0) {
			visit(i,graph,mark);
		}
	}
	if (DAG_check == true) { cout << 1; }
	else { cout << 0; }
	cout << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

int main(){
  vector<ll> A(5);
  ll time = 1e15+1, ans;
  ll N;
  cin >> N;
  REP(i, 5){
    cin >> A[i];
  }
  REP(i, 5){
    time = min(time, A[i]);
  }
  ans = 4 + N / time;
  if(N% time){
    ans++;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
            #include <chrono>
          
            using namespace std;
            using namespace std::chrono; 
         
            typedef long long int ll;
         
            #define MOD (ll)(1e9+7)
            #define endl "\n"
            #define pb push_back
            #define TEST_CASES  ll t;cin>>t;while(t--)
            #define forn(i,a,n) for (int i = a; i < n; ++i)
            #define f first
            #define s second
            #define all(x) x.begin(), x.end()


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

            int main()
            {
              ios_base::sync_with_stdio(false);
              cin.tie(NULL);
              string s,t;
              cin>>s>>t;
              int n = s.size();
              int cnt = 0;
              forn(i,0,n){
                if(s[i] != t[i])
                  cnt++;
              }        
              cout<<cnt<<endl;
            }

            
          


Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N), S(N+1);
    
    S[0]=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        S[i+1] = S[i] + A[i];
    }
    
    sort(S.begin(), S.end());
    //bool same=false;
    long long num_same=1;
    long long ans=0;
    for(int i=0; i+1<N+1; i++){
        if(S[i]==S[i+1]){
            num_same++;
        }
        else{
            ans+=(num_same*(num_same-1))/2;
            num_same=1;
        }
        if(i+1==N){
            ans+=(num_same*(num_same-1))/2;
        }
    }
    
    
    
    cout << ans << endl;
    
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> p(100001);
  long long sum = 0;
  for(int i = 0; i < n; i++) {cin >> a[i]; p[a[i]-1]++; sum += a[i];}
  long long q;
  cin >> q;
  vector<pair<long long, long long>> b(q);
  for(int i = 0; i < q; i++) cin >> b[i].first >> b[i].second;
  for(int i = 0; i < q; i++){
    sum -= p[b[i].first-1] * b[i].first;
    long long q = p[b[i].first-1];
    p[b[i].first-1] = 0;
    p[b[i].second-1] += q;
    sum += b[i].second * q;
    cout << sum << endl;
  }
}

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

T = int(input())

memo = {}
def solve(n, a, b, c, d):
  global memo
  if n in memo:
    return memo[n]
  res = []
  flag = [True] * 6
  for i in range(5):
    n1 = n - i; n2 = n + i
    if n1:
      if n1 % 2 == 0 and flag[0]:
        flag[0] = False
        v = solve(n1//2, a, b, c, d) + min(a + i*d, (n1//2 + i)*d)
        res.append(v)
      if n1 % 3 == 0 and flag[2]:
        flag[2] = False
        v = solve(n1//3, a, b, c, d) + min(b + i*d, (2*n1//3 + i)*d)
        res.append(v)
      if n1 % 5 == 0 and flag[4]:
        flag[4] = False
        v = solve(n1//5, a, b, c, d) + min(c + i*d, (4*n1//5 + i)*d)
        res.append(v)
    if n2 % 2 == 0 and flag[1]:
      flag[1] = False
      v = solve(n2//2, a, b, c, d) + min(a + i*d, abs(n-n2//2)*d)
      res.append(v)
    if n2 % 3 == 0 and flag[3]:
      flag[3] = False
      v = solve(n2//3, a, b, c, d) + min(b + i*d, abs(n-n2//3)*d)
      res.append(v)
    if n2 % 5 == 0 and flag[5]:
      flag[5] = False
      v = solve(n2//5, a, b, c, d) + min(c + i*d, abs(n-n2//5)*d)
      res.append(v)
  v = min(res)
  memo[n] = v
  return v


ans = []
for t in range(T):
  N, A, B, C, D = map(int, input().split())
  memo = {1:D}
  ans.append(solve(N, A, B, C, D))

print(*ans, sep='\n')

Measured memory_bytes: 11128
using System;

public class Queue
{
  private int size, top, tail;
  private int[] array;
  public Queue(int size)
  {
    this.size = size + 1;
    array = new int[this.size];
    top = tail = 0;
  }
  public void Enqueue(int val)
  {
    if ((tail + 1) % this.size == this.top) throw new Exception("overflow error");
    this.array[tail] = val;
    if (this.tail + 1 >= this.size) this.tail = 0;
    else this.tail++;
  }
  public int Dequeue()
  {
    if (this.top == this.tail) throw new Exception("underflow error");
    int head = array[this.top];
    if (this.top + 1 >= this.size) this.top = 0;
    else this.top++;
    return head;
  }
  public bool IsEmpty()
  {
    return this.top == this.tail;
  }
}

public class Program
{
  private static int[,] graph;
  private static int[] distance;
  private static int graphSize;

  private static void BreadthFirsSearch()
  {
    Queue queue = new Queue(graphSize);
    try
    {
      queue.Enqueue(0);
      distance[0] = 0;
      while (!queue.IsEmpty())
      {
        int u = queue.Dequeue();
        for (int i = 0; i < graphSize; i++)
        {
          if (graph[u, i] == 0) continue;
          if (distance[i] != Int32.MaxValue) continue;
          distance[i] = distance[u] + 1;
          queue.Enqueue(i);
        }
      }
    }
    catch (Exception ex)
    {
      Console.WriteLine(ex.StackTrace.ToString());
    }
  }
  public static void Main()
  {
    int i, j, u, k, v;
    string[] ary;

    graphSize = int.Parse(Console.ReadLine());
    distance = new int[graphSize];
    for (i = 0; i < graphSize; i++) distance[i] = Int32.MaxValue;

    graph = new int[graphSize, graphSize];
    for (i = 0; i < graphSize; i++)
      for (j = 0; j < graphSize; j++)
        graph[i, j] = 0;

    for (i = 0; i < graphSize; i++)
    {
      ary = Console.ReadLine().Split(' ');
      u = int.Parse(ary[0]);
      k = int.Parse(ary[1]);
      for (j = 0; j < k; j++)
      {
        v = int.Parse(ary[2 + j]);
        graph[u - 1, v - 1] = 1;
      }
    }
    BreadthFirsSearch();

    for (i = 0; i < graphSize; i++)
    {
      Console.WriteLine("{0} {1}", i + 1, distance[i] == Int32.MaxValue ? -1 : distance[i]);
    }

  }
}


Measured memory_bytes: 9312
cnt = 1
while gets
	n = $_.to_i
	break if n==0
	puts "Case " + cnt.to_s + ":"
	arr = Array.new(n) { Array.new(n) }
	a = 1
	for i in 0...n
		if i % 2 == 0
			for j in 0..i
				arr[i-j][j] = a
				a += 1
			end
		else
			for j in 0..i
				arr[j][i-j] = a
				a += 1
			end
		end
	end
	a = n*n
	for i in 0...(n-1)
		if i % 2 == 0
			for j in 0..i
				arr[n-i+j-1][n-j-1] = a
				a -= 1
			end
		else
			for j in 0..i
				arr[n-j-1][n-i+j-1] = a
				a -= 1
			end
		end
	end
	n.times do |i|
		puts arr[i].map{|j| "%3d".%(j)}.join("")
	end
	cnt += 1
end

Measured memory_bytes: 8760
#include<iostream>
#include<vector>

using namespace std;

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

int N, M;
vector<vector<int>> E;
bool visited[100000];

int main() {
	cin >> N >> M;
	E.resize(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		E[A].push_back(B);
		E[B].push_back(A);
	}

	int l = 0, r = E[0][0];//-1になったらループに入ってる判定
	int befl = r, befr = l;
	visited[l] = true, visited[r] = true;
	vector<int> ansl, ansr;
	ansl.push_back(l), ansr.push_back(r);
	while (true) {
		//expends a
		bool updatel = false;
		for (int i = 0; i < E[l].size(); i++) {
			if (E[l][i] == befl)continue;
			
			if (!visited[E[l][i]]) {
				visited[E[l][i]] = true;
				ansl.push_back(E[l][i]);
				befl = l;
				l = E[l][i];
				updatel = true;
				break;
			}
		}
		if (!updatel)break;
	}
	while (true) {
		bool updater = false;
		for (int i = 0; i < E[r].size(); i++) {
			if (E[r][i] == befr)continue;

			if (!visited[E[r][i]]) {
				visited[E[r][i]] = true;
				ansr.push_back(E[r][i]);
				befr = r;
				r = E[r][i];
				updater = true;
				break;
			}
		}
		if (!updater)break;
	}
	cout << ansl.size() + ansr.size() << endl;
	for (int i = ansl.size() - 1; i >= 0; i--) {
		cout << ansl[i] + 1 << " ";
	}
	for (int i = 0; i < ansr.size(); i++) {
		cout << ansr[i] + 1 << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6904
//
// Created by yamunaku on 2019/08/28.
//

#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
    ll r = 2155;
    int n;
    cin >> n;
    vl a(n), b(n, 1), c(n, 1);
    rep(i, n) cin >> a[i];
    vector<ll> p;
    vi hurui(r, 1);
    hurui[0] = hurui[1] = 0;
    repl(i, 2, r){
        if(hurui[i]){
            p.push_back(i);
            for(int j = i + i; j < r; j += i){
                hurui[j] = 0;
            }
        }
    }
    map<ll, map<ll, pair<int, ll>>> mp;
    int ans = 0;
    rep(i, n){
        rep(j, p.size()){
            if(a[i] % p[j] == 0){
                int cc = 0;
                while(a[i] % p[j] == 0){
                    a[i] /= p[j];
                    cc++;
                }
                cc %= 3;
                if(cc == 1){
                    b[i] *= p[j];
                    c[i] *= p[j] * p[j];
                }else if(cc == 2){
                    b[i] *= p[j] * p[j];
                    c[i] *= p[j];
                }
            }
        }
        if(a[i] == 1 && b[i] == 1){
            ans = 1;
        }else{
            mp[a[i]][b[i]].first++;
            mp[a[i]][b[i]].second = c[i];
        }
    }
    for(auto &x:mp){
        for(auto &y:x.second){
            ll aa = x.first;
            if(y.second.first == 0) continue;
            if(aa <= 1e5){
                auto itr = mp[aa * aa].find(y.second.second);
                if(itr != mp[aa * aa].end()){
                    ans += max(y.second.first, itr->second.first);
                    itr->second.first = 0;
                }else{
                    ans += y.second.first;
                }
            }else{
                ans += y.second.first;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17024
#include <iostream>
using namespace std;
int main(){
  int a = 0;
  int b = 0;
  
  cin >> a >> b;
  
  int contas[3]={};
  contas[0]=a+b;
  contas[1]=a-b;
  contas[2]=a*b;
  
  int maximum = contas[0];
  int maximum_index = 0;
  
  for(int i=0;i<3;i++){
    if(maximum<contas[i]){
      maximum=contas[i];
      maximum_index=i;
    }
  }
  
  cout << contas[maximum_index];

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int64_t ans=0;
	for(int i=1;i<=n;++i){
		ans+=1L*(1+n/i)*(n/i)*i/2;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=45;
int n;
char e[N][N];
ll f[N][N][N];
ll g[N][N][N];
int main(){
	scanf("%d",&n); n*=2;
	For(i,1,n) scanf("%s",e[i]+1);
	For(i,1,n) For(j,1,n) e[i][j]-='0';
	For(i,1,n) f[i][i][i]=1;
	For(i,1,n) For(j,1,n) if (e[i][j]) g[i][i][j]=1;
	for (int l=3;l<=n;l+=2)
		for (int i=2,j=l+1;j<=n;i++,j++){
			for (int p1=i;p1<j;p1+=2)
				for (int p2=j;p2>p1;p2-=2){
					ll S=0;
					for (int p3=p2;p3<=j;p3++)
						S+=f[p2][j][p3]*g[i][p1][p3];
					for (int p3=p1+1;p3<p2;p3++)
						f[i][j][p3]+=f[p1+1][p2-1][p3]*S;
				}
			For(k,i,j) For(l,1,n) if (e[k][l])
				g[i][j][l]+=f[i][j][k];
		}
	ll ans=0;
	For(i,2,n) if (e[1][i])
		ans+=f[2][n][i];
	printf("%lld\n",ans);
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

vi sub(vector<bool> fin,ll n) {
  vi ret;
  REP(i,n) {
    if(fin.at(i))continue;
    vector<bool> cp = fin;
    cp.at(i) = true;
    vi result = sub(cp,n);
    ret.insert(ret.end(),result.begin(),result.end());
  }
  return ret;
}

ll pow_kai(ll a, ll n) {//aのn乗を計算します。
  ll x = 1;
  while(n > 0) {
    if(n&1) x = x*a;
    a = a*a;
    n >>= 1;
  }
  return x;
}

int main() {
  ll n;
  cin>>n;
  cout << (n+1)/2 << endl;
}

Measured memory_bytes: 764
(let* ((n (read))
       (a (make-array `(,(+ 2 n))))
       (b (make-array `(,(+ 1 n))))
       (ans 0))
  (loop :for i :from 1 :to (+ n 1)
        :do (setf (aref a i) (read)))
  (loop :for i :from 1 :to n
        :do (setf (aref b i) (read)))

  (loop :for i :from 1 :to n
        :do(let* ((d (min (aref a i) (aref b i)))
                  (r (- (aref b i) d))
                  (d+ (min (aref a (1+ i)) r)))
             (incf ans d)
             (incf ans d+)
             (decf (aref a (1+ i)) d+)))
  
  (format t "~A~%" ans))


Measured memory_bytes: 78584
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e5+5;
ll seg[4*M];
void update(ll i,ll s,ll e,ll l,ll r,ll x)
{
	if(s>r || l>e)
		return;
	if(s>=l && e<=r)
	{
		seg[i]+=x;
		return;
	}
	ll m=(s+e)/2;
	update(2*i,s,m,l,r,x);
	update(2*i+1,m+1,e,l,r,x);
}
ll query(ll i,ll s,ll e,ll x)
{
	ll res=seg[i];
	if(s==e)
		return res;
	ll m=(s+e)/2;
	if(x<=m)
		return res+query(2*i,s,m,x);
	return res+query(2*i+1,m+1,e,x);
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll N,D,A;
	cin>>N>>D>>A;
	std::vector<pair<ll,ll> > v;
	v.pb({-1LL,-1LL});
	for(ll i=1;i<=N;i++)
	{
		ll x,h;
		cin>>x>>h;
		v.pb({x,h});
	}
	sort(all(v));
	ll curr=1;
	ll ans=0;
	for(ll i=1;i<=N;i++)
	{
		ll c=v[i].ss-query(1,1,N,i);
		while(curr<=N && v[curr].ff-v[i].ff<=D*2)
			curr++;
		if(c<=0)
			continue;
		ans+=(c+A-1)/A;
		update(1,1,N,i,curr-1,((c+A-1)/A)*A);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 10220
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, d, x; cin >> n >> d >> x;
    vector<int> a(n); repeat (i, n) cin >> a[i];
    repeat (i, n) {
        x += (d-1) / a[i];
        ++x;
    }
    cout << x << endl;
}

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

int main() {
  int N, K; cin >> N >> K;
  ll ans = K * pow(K-1, N-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
		string s1,s2;
		cin>>s1>>s2;
		long long n=s1.length()+1;
		long long m=s2.length()+1; 
		long long arr[n][m];
		for(long i=0;i<n;i++)
		{
			for(long j=0;j<m;j++)
			{
				if(i==0||j==0)
				{
					arr[i][j]=0;
				}
				else
				{
					if(s1[i-1]==s2[j-1])
					{
						arr[i][j]=arr[i-1][j-1]+1;
					}
					else
					{
						arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
					}
				}
			}
		}
		string ans="";
		long x=n-1;
		long y=m-1;
		while(arr[x][y]!=0)
		{
			if(arr[x-1][y]==arr[x][y])
			{
				x=x-1;
			}
			else if(arr[x][y-1]==arr[x][y])
			{
				y=y-1;
			}
			else
			{
				ans+=s1[x-1];
				x=x-1;
				y=y-1;
			}
		}
		reverse(ans.begin(),ans.end());
		cout<<ans<<"\n";
}

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


def answer(H: int, N: int, A: list) -> str:
    damage = 0                          # damageに0を代入します
    for i in range(0, N):               # 0:Nの間にiがある間は
        damage += int(A[i])             # damageにリスト[i]をint(整数）に変え足します
                                        # 6でdamage=0にforの間Aの値を足していく意味
        i += 1                          # 条件を満たす間はiに1つずつ足していきます。リスト内を進めていく
    if damage < H:
        return 'No'
    else:
        return 'Yes'

print(answer(H, N, A))


Measured memory_bytes: 20560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  ll x,k,d; cin >> x >> k >> d;
  if(x < 0) x *= -1;
  if(x / d > k) {
    cout << x - k * d << "\n";
  }
  else {
    ll m = x / d;
    if( (k - m) % 2 == 0) {
      cout << x - m * d << "\n";
    }
    else {
      cout << (m + 1) * d - x << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int s;
    cin>>s;
    int a=s/100,b=s%100;
    if(1<=a&&a<=12){
        if(1<=b&&b<=12) cout<<"AMBIGUOUS";
        else cout<<"MMYY";
    }
    else{
        if(1<=b&&b<=12) cout<<"YYMM";
        else cout<<"NA";
    }
}

Measured memory_bytes: 3596
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=50005;
//Code begin....

map<int,int>vis;

int main ()
{
    int n, x;
    scanf("%d",&n);
    FOR(i,1,n) {
        scanf("%d",&x);
        if (vis[x]==0) vis[x]=1;
        else vis[x]=0;
    }
    int ans=0;
    for (auto i=vis.begin(); i!=vis.end(); ++i) if (i->second==1) ++ans;
    printf("%d\n",ans);
    return 0;
}


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

int f[MAX];
int adj[MAX][MAX];
int n;

void bfs(int r){
    rep(i,n)f[i]=-1;
    queue<int> Q;
    Q.push(r);
    f[r]=0;
    while(!Q.empty()){
        int u=Q.front();Q.pop();
        rep(i,n){
            if(adj[u][i]==1&&f[i]==-1){
                f[i]=f[u]+1;
                Q.push(i);
            }
        }
    }
    rep(i,n){
        printf("%d %d\n",i+1,f[i]);
    }
}

int main(){
    int id,k,node;
    cin>>n;
    rep(i,n)rep(j,n)adj[i][j]=0;
    rep(i,n){
        scanf("%d %d",&id,&k);
        id--;
        rep(j,k){
            scanf("%d",&node);
            node--;
            adj[id][node]=1;
        }
    }
    bfs(0);
    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
multiset<int> ms;
signed main(){
  int n,k;cin>>n>>k;
  rep(i,n){
    int x;cin>>x;
    ms.insert(x);
  }
  int m=ms.count(*ms.begin());
  cout<<(n-m+k-2)/(k-1)<<endl;
  return 0;
}

Measured memory_bytes: 8256
from itertools import permutations
lis = [int(input()) for _ in range(5)]
ans = 1e9
for li in permutations(lis):
    cnt = 0
    for i in range(5):
        if cnt % 10 != 0:
            cnt += 10 - (cnt % 10)
        cnt += li[i]
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int k;
	char s[1010];
	cin>>k;
	cin>>s;
	int n =strlen(s);
	int flag=0;
	for(int i=0;i<n;i++){
		if(i<k){
			cout<<s[i];
		}else{
			flag=1;
			break;
		}
	}
	if(flag){
		cout<<"...";
	}
	cout<<endl;
	
 	return 0;
}

Measured memory_bytes: 3596