akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

typedef vector<int> Vec;
typedef vector<Vec> Mat;

int N, mod;

Mat mul(Mat &A, Mat &B)
{
	Mat C(A.size(), Vec(B[0].size()));
	for (int i=0; i<A.size(); i++) {
		for (int k=0; k<B.size(); k++) {
			for (int j=0; j<B[0].size(); j++) {
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= mod;
			}
		}
	}
	return C;
}

Mat pow(Mat A, ll y)
{
	Mat B(A.size(), Vec(A.size()));
	for (int i=0; i<A.size(); i++) B[i][i]=1;
	
	for (; y>0; y>>=1, A=mul(A, A)) {
		if (y&1) B = mul(B, A);
	}
	
	return B;
}


/** Problem1327 : One-Dimensional Cellular Automaton **/
int main()
{
	int A, B, C; ll T;
	while (cin>>N>>mod>>A>>B>>C>>T, N||mod||A||B||C||T) {
		Mat m(N, Vec(N));
		Vec S(N);
		
		rep(i, N) cin>>S[i];
		
		int base=0;
		rep(i, N) {
			rep(j, N) {
				if (j==base-1) m[i][j] = A;
				else if (j==base) m[i][j] = B;
				else if (j==base+1) m[i][j] = C;
				else m[i][j] = 0;
			}
			base++;
		}
		
		m = pow(m, T);
		
		rep(i, N) {
			int t=0;
			rep(j, N) {
				t += S[j] * m[i][j];
				t %= mod;
			}
			if (i!=0) cout<<" ";
			cout << t;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1288
#include<stdio.h>
int main(){
	long long a, b, c;
	int d, e, f;
	scanf("%lld %lld %lld", &a, &b, &c);
	d = a % 2;
	e = b % 2;
	f = c % 2;
	if (d*e*f == 0)printf("%d", 0);
	else{
		if (a > b){
			if (c > a)printf("%lld", a*b);
			else printf("%lld", b*c);
		}
		else{
			if (c > b)printf("%lld", a*b);
			else printf("%lld", a*c);
		}
	}

	return 0;
}

Measured memory_bytes: 128
/*
貰いDP
*/

# include <iostream>
# include <algorithm>

using namespace std;

int N, K;
long long h[100010], dp[100010];
const long long INF = 1LL << 60;

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> h[i];
  for (int i = 0; i < N; i++) dp[i] = INF;
  
  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    int repeat = 0;
    if (i < K) repeat = i;
    else repeat = K;
    
    for (int j = 1; j <= repeat; j++) {
      dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  
  cout << dp[N - 1] << endl;
  
  return 0;
}

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

using namespace std;

template<typename T>
long long countTranspose(vector<T>& v){
	if(v.size() <= 1) return 0;
	const int n = v.size();
	vector<T> a(v.begin(), v.begin() + n/2);
	vector<T> b(v.begin() + n/2, v.end());
	long long res = countTranspose(a) + countTranspose(b);
	int idxA = 0, idxB = 0;
	for(int i=0;i<n;i++){
		if(idxB < b.size() && (idxA == a.size() || a[idxA] > b[idxB])){
			v[idxA+idxB] = b[idxB];
			++idxB;
			res += a.size() - idxA;
		} else {
			v[idxA+idxB] = a[idxA];
			++idxA;
		}
	}
	return res;
}

int main(){
	int N; long long K;
	while(cin >> N >> K){
		vector<long long> l;
		l.push_back(0);
		long long sum = 0;
		for(int i=0;i<N;i++){
			long long a; cin >> a;
			sum += a - K;
			l.push_back(sum);
		}
		cout << (N * (N+1LL) / 2 - countTranspose(l)) << endl;
	}
}


Measured memory_bytes: 4976
var reader = require('readline').createInterface({
 input: process.stdin,
 output: process.stdout
});

var lines = [];
reader.on('line',(line) => {
         lines.push(line);
});

reader.on('close', () => {
         var s = lines[0];
 var a = [s];
 for (var i = 0; i < 1000010; i++){
   if (a[i] % 2 == 0){
    a.push( a[i] / 2 );
   } else {
     a.push( a[i]*3+1 );
   }
   for (var j = 0; j < i;j++){
     if (a[i] == a[j]){
        console.log(i+1);
       return;
     }
   }
 }
});

Measured memory_bytes: 7628
import java.io.PrintWriter
object out : PrintWriter(System.out)

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    var dp0 = 0L
    var dp1 = -1L
    for (i in 1..n) {
        val a = readLine()!!.toInt()
        val ndp0 = Math.max(dp0 + a / 2, dp1 + (a + 1) / 2)
        val ndp1 = if (a == 0) -1L else Math.max(dp0 + (a - 1) / 2, dp1 + a / 2)
        dp0 = ndp0
        dp1 = ndp1
    }
    out.println(Math.max(dp0, dp1))
    out.close()
}

Measured memory_bytes: 24076
#include <iostream>
#include <vector>
#include <algorithm>

using myPair = std::pair<long, long>;

int main()
{
	long N, M;
	std::cin >> N >> M;

	std::vector<myPair> v;

	for ( int i = 0; i < M; i++ )
	{
		long tmpA, tmpB;
		std::cin >> tmpA >> tmpB;
		v.emplace_back( std::make_pair( tmpA, tmpB ) );
	}

	// vを、Biの値で昇順ソートする
	std::sort( v.begin(), v.end(), []( myPair a, myPair b ) {
			return( a.second < b.second );
		} );

	/*
	 * これで要望Mは、島Aiから行きたくない最西のBiがわかるように並んでいる（はず）
	 * この時、|Ai - Bi|が1になっている箇所の橋iは必ず切断する必要がある
	 * すると、Aiから、Ci（Ci > Bi）には絶対に辿り着けなくなるので、
	 * 西がBi未満であり、東がBi以上の島となっているMiは全て叶えられているので、除外して良い
	 * これを、全要素が除外されるまで繰り返せば、要望Mが全て叶えられる
	 *
	 * |Ai - Bi|が2以上であっても、Ai = Bi-1として、i番目の橋を切断すれば、
	 * その要望Miは叶えられたことになるので、切断した橋の番号bについて
	 * ・Mi(Ai, Bi)が叶えられていなければ、Bi-1とBiの間にあるb番目の橋を切断
	 * ・Mi(Ai, Bj)が叶えられていれば（＝i+1<=b<jのどこかの橋が切断されている）何もしない
	 * Biは昇順ソートされているので、以降、直前のbのみを覚えておき、Ai<bのみを調べれば良い
	 * bが更新される場合、それより手前の島Aiには、すでに（それ以前の要望Mによって）到達できなくなっているはずである
	 */
	long counter = 0;			//	橋を切断した本数
	long b = 0;					//	直前に切断した橋の番号

	for ( auto &&it : v )
	{
		if ( it.first > b )
		{
			// 橋がつながっている
			b = it.second - 1;		//	橋を切断して
			counter++;				//	その本数をカウントする
		}
	}

	std::cout << counter << std::endl;

	return ( 0 );
}


Measured memory_bytes: 2548
import sys

readline = sys.stdin.readline

N, A, B, C, D = map(int, readline().split())
A, B, C, D = (x - 1 for x in [A, B, C, D])

S = readline().rstrip()
S2 = [S[i:i+2] for i in range(0, N - 1)]
S3 = [S[i:i+3] for i in range(0, N - 2)]

if C < D:
    ac = S2[A:C]
    bd = S2[B:D]
    if ac.count('##') > 0:
        print('No')
    elif bd.count('##') > 0:
        print('No')
    else:
        print('Yes')
else:
    bd = S2[B:D]
    ac = S2[A:C]
    if bd.count('##') > 0:
        print('No')
    elif ac.count('##') > 0:
        print('No')
    else:
        abd = S3[B - 1: D]
        if abd.count('...') > 0:
            print('Yes')
        else:
            print('No')
        


Measured memory_bytes: 71316
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a= new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int count = 0;
        Boolean isUp = null;
        for (int i = 0; i < n-1; i++) {
            if (isUp == null) {
                if (a[i] < a[i + 1]) {
                    isUp = true;
                }
                if (a[i] > a[i + 1]) {
                    isUp = false;
                }
            } else {
                if (isUp && a[i] > a[i + 1]) {
                    isUp = null;
                    count++;
                } else if (!isUp && a[i] < a[i + 1]) {
                    isUp = null;
                    count++;
                }
            }
        }

        System.out.println(count+1);
    }
}

Measured memory_bytes: 50336
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
long long a,sum=1000000000000;
cin>>a;
for(long long i=1;(i*i)<=a;i++){
    if(a%i==0){
        if((i+(a/i))<sum){sum=i+(a/i);}
    }
}
cout<<sum-2;
}


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

int main(){
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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

#include <boost/operators.hpp>

class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}

 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 2;

// #LIB#

using namespace std;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> s(m);
  rep(i, m) {
    ll k;
    cin >> k;
    s[i].resize(k);
    rep(j, k) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  vector<ll> p(m);
  rep(i, m) cin >> p[i];
  ll ans = 0;
  rep(i, 1 << n) {
    vector<bool> on(n);
    rep(j, n) on[j] = (i >> j) & 1;
    bool allon = true;
    rep(j, m) {
      ll onc = 0;
      itr(x, s[j]) onc += on[x];
      if (onc % 2 != p[j]) allon = false;
    }
    if (allon) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
n = int(input())
string_list = [ input() for i in range(n) ]
ans = 0
ab_list = [0, 0, 0]

for i in string_list:
    for j in range(len(i)-1):
        if i[j] == "A" and i[j+1] == "B":
            ans += 1
    if i[0] == "B" and i[-1] == "A":
        ab_list[0] += 1
    elif i[0] == "B":
        ab_list[1] += 1
    elif i[-1] == "A":
        ab_list[2] += 1

if ab_list[0] == 0:
    ans += min(ab_list[1], ab_list[2])
else:
    ans += ab_list[0] - 1
    if ab_list[1] > 0:
        ans += 1
        ab_list[1] -= 1
    if ab_list[2] > 0:
        ans += 1
        ab_list[2] -= 1
    ans += min(ab_list[1], ab_list[2])
print(ans)

Measured memory_bytes: 46552
N, M = map(int, input().split())
XY_list = [[] for i in range(N)]
ans_list = [None] * M
for i in range(M):
  X, Y = map(int, input().split())
  XY_list[X - 1].append((Y, i))
for j, k in enumerate(XY_list):
  k.sort()
  for l, (y, m) in enumerate(k):
    ans_list[m] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
print(*ans_list, sep = "\n")

Measured memory_bytes: 37480
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define pb push_back
typedef long long ll; 
std::pair<ll, ll> ans[100005]; 
std::vector<std::pair<ll, ll> > adj[100005]; 
int que[100005]; 
bool vis[100005]; 
int main()
{
	// freopen("E.in", "r", stdin); 
	int n, m;
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < m; i++)
	{
		int u, v, s; 
		scanf("%d%d%d", &u, &v, &s); 
		adj[--u].pb({--v, s}); 
		adj[v].pb({u, s}); 
		// printf("%d %d %d\n", u, v, s);
	}
	int he = 0, ta = 0;
	ll val; 
	bool ha = false; 
	que[ta++] = 0; 
	vis[0] = true; 
	ans[0] = {1, 0}; 
	while (he < ta)
	{
		int u = que[he++]; 
		// printf("%d %d %d\n", u, ans[u].first, ans[u].second);
		for (auto &e : adj[u])
		{
			int v = e.first, w = e.second; 
			auto t = ans[u]; 
			t = {-ans[u].first, w - ans[u].second}; 
			// printf("%d -> %d %d\n", u, v, w);
			if (!vis[v])
			{
				ans[v] = t; 
				vis[v] = true; 
				que[ta++] = v;
				continue; 
			}
			if (ans[v].first == t.first)
			{
				// printf("=== %d %d %d\n", v, ans[v].second, t.second);
				if (ans[v].second != t.second)
				{
					puts("0");
					return 0; 
				}
			}
			else
			{
				int x = ans[v].second - t.second; 
				if (ans[v].first == 1)
					x = -x; 
				if (x & 1)
				{
					puts("0");
					return 0; 
				}
				x >>= 1; 
				if (ha && val != x)
				{
					puts("0");
					return 0; 
				}
				ha = true; 
				val = x; 
			}
		}
	}
	if (ha)
	{
		bool f = true; 
		for (int i = 0; i < n; i++)
			f &= (ans[i].first == 1 ? val + ans[i].second : -val + ans[i].second) > 0; 
		printf("%d\n", f);
		return 0; 
	}
	ll l = 1, r = 1e18; 
	for (int i = 0; i < n; i++)
	{
		// printf("%lld %lld\n", ans[i].first, ans[i].second);
		if (ans[i].first == 1)
			l = std::max(l, -ans[i].second + 1); 
		else
			r = std::min(r, ans[i].second - 1); 
	}
	printf("%lld\n", std::max(0ll, r - l + 1));
	return 0; 
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	int t[N+1],x[N+1],y[N+1];
	for(int i=1;i<=N;i++){
		cin>>t[i]>>x[i]>>y[i]; 
	} 
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=1;i<=N;i++){
		int t1=t[i]-t[i-1];
		int x1=abs(x[i]-x[i-1]);
		int y1=abs(y[i]-y[i-1]);
		if(t1>=x1+y1){
			if((t1-x1-y1)%2==0){
				continue;
			}
		}
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
char dat[3][4];
int main(){
	while(1){
		scanf("%s",dat[0]);
		if(dat[0][0]=='0')return 0;
		scanf("%s%s",dat[1],dat[2]);
		bool b=false;
		bool w=false;
		if(dat[0][0]=='w'&&dat[0][1]=='w'&&dat[0][2]=='w')w=true;
		if(dat[1][0]=='w'&&dat[1][1]=='w'&&dat[1][2]=='w')w=true;
		if(dat[2][0]=='w'&&dat[2][1]=='w'&&dat[2][2]=='w')w=true;
		if(dat[0][0]=='w'&&dat[1][0]=='w'&&dat[2][0]=='w')w=true;
		if(dat[0][1]=='w'&&dat[1][1]=='w'&&dat[2][1]=='w')w=true;
		if(dat[0][2]=='w'&&dat[1][2]=='w'&&dat[2][2]=='w')w=true;
		if(dat[0][0]=='w'&&dat[1][1]=='w'&&dat[2][2]=='w')w=true;
		if(dat[0][2]=='w'&&dat[1][1]=='w'&&dat[2][0]=='w')w=true;
		
		if(dat[0][0]=='b'&&dat[0][1]=='b'&&dat[0][2]=='b')b=true;
		if(dat[1][0]=='b'&&dat[1][1]=='b'&&dat[1][2]=='b')b=true;
		if(dat[2][0]=='b'&&dat[2][1]=='b'&&dat[2][2]=='b')b=true;
		if(dat[0][0]=='b'&&dat[1][0]=='b'&&dat[2][0]=='b')b=true;
		if(dat[0][1]=='b'&&dat[1][1]=='b'&&dat[2][1]=='b')b=true;
		if(dat[0][2]=='b'&&dat[1][2]=='b'&&dat[2][2]=='b')b=true;
		if(dat[0][0]=='b'&&dat[1][1]=='b'&&dat[2][2]=='b')b=true;
		if(dat[0][2]=='b'&&dat[1][1]=='b'&&dat[2][0]=='b')b=true;
		if(b)printf("b\n");
		else if(w)printf("w\n");
		else printf("NA\n");
	}
}

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

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

    int n;
    while(cin>>n){
        map<string, int>::iterator iter;
        map<string, int> input_data;
        vector<string> answer;
        for (int i = 0; i < n; ++i) {
            string temp;
            cin >> temp;
            ++input_data[temp];
        }
        int max = 0;
        for (iter = input_data.begin(); iter != input_data.end();++iter) {
            if(iter->second > max){
                max=iter->second;
            }
        }
        for (iter = input_data.begin(); iter != input_data.end();++iter) {
            if(iter->second== max){
                answer.push_back(iter->first);
            }
        }
        for (auto &t:answer) {
            cout << t << endl;
        }
    }
    return 0;
}

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

int main(){
    int n,m;
    long int ans=0;
    cin >> n >> m;
    priority_queue<int> PQ;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        ans +=a;
        PQ.push(a);
    }

    for(int i=0;i<m;i++){
        int a = PQ.top(); PQ.pop();
        ans += a/2 -a;
        PQ.push(a/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static int MAX = 510000;
	public static int MOD = 1000000007;

	public static long[] f = new long[MAX];
	public static long[] finv = new long[MAX];
	public static long[] inv = new long[MAX];

	public static void ComInit() {
		f[0] = f[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i < MAX; i++) {
			f[i] = f[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	public static long Com(int n, int k) {
		if(n < k)
			return 0;
		if(n < 0 || k < 0)
			return 0;
		return f[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Long> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextLong());
		}
		Collections.sort(list);
		ComInit();
		long ans = 0;
		if(k == 1) {
			System.out.println(0);
		} else {
			for(int i = 0; i < n; i++) {
				if(n - i - 1 >= k - 1) {
					ans -= list.get(i) * Com(n - i - 1, k - 1);
					ans %= MOD;
				}
				if(i >= k - 1) {
					ans += list.get(i) * Com(i, k - 1);
					ans %= MOD;
				}
			}
			System.out.println(ans);
		}

	}

}


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

using namespace std;

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

	string s;
	cin >> s;

	int cnt = 1;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[i - 1])
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}

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

map<int,char> ma;

int gcm(int a,int b)
{
    return b==0?a:gcm(b,a%b);
}

int lcm(int a,int b)
{
    return a*b/gcm(a,b);
}

signed main() {

    int n,m;cin>>n>>m;
    string s,t;cin>>s>>t;

    int l = lcm(n,m);

    for(int i = 0; i < n; i++)
    {
         ma[i*l/n + 1] = s[i];
    }

    for(int i = 0; i < m; i++)
    {
         if(ma[i*l/m + 1])
         {
             if(ma[i*l/m + 1] != t[i])
             {
                 cout << -1 << endl;
                 return 0;
             }
         }
    }

    cout << l << endl;


}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c){
		cout<<"Yes";
		return 0;
	} 
	if(a==c&&a!=b){
		cout<<"Yes";
		return 0;
	}
	if(b==c&&a!=b){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()



int main() {
	ll x, y;
	cin >> x >> y;
	int ans = 0;
	while (x <= y) {
		ans++;
		x *= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import os
import heapq
import sys,threading
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

sys.setrecursionlimit(10 ** 5)
threading.stack_size(2**27)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""


def inpt():
    return [int(k) for k in input().split()]


def main():
    d,t,s=inpt()
    t1=d/s
    if(t1<=t):
        print('Yes')
    else:
        print('No')




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threading.Thread(target=main).start()


Measured memory_bytes: 68664
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int N, M;
  cin >> N >> M;
  vector<int> X;
  for(int i=0;i<M;i++){
    int x;
    cin >> x;
    X.push_back(x);
  }
  sort(X.begin(),X.end());

  int count_old = X.size();
  int cost_old = 0;
  if(N>=count_old){
    cout << 0 << endl;
    return 0;
  }

  for(int i=1;;i++){
    int count = 1;
    int cost = 0;
    int prev = X[0];
    for(auto x:X){
      if(x-prev > i){
        count++;
      }else{
        cost += x-prev;
      }
      prev = x;
    }
    if(N>=count){
      cout << cost_old+(count_old-N)*i << endl;
      return 0;
    }
    count_old = count;
    cost_old = cost;
  }
  return 0;
}


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

int main() {
  string S; cin >> S;
  int first, last;
  first = stoi(S.substr(0, 2));
  last = stoi(S.substr(2, 2));
  if((first >= 1 && first <= 12) && (last >= 1 && last <= 12)) {
    cout << "AMBIGUOUS" << endl;
  } else if((first >= 1 && first <= 12) && (last >= 0 && last <= 99)) {
    cout << "MMYY" << endl;
  } else if((first >= 0 && first <= 99) && (last >= 1 && last <= 12)) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d",$n);
$a=array_map('intval', explode(" ", rtrim(fgets(STDIN))));
$sum=0;
for ($i=0; $i < $n; $i++)
	$sum+=$a[$i];

$x=0; $y=$sum; $result=10000000000;
for ($i=0; $i < $n-1; $i++)
{
	$x+=$a[$i];
	$y-=$a[$i];
	$result=min($result,abs($x-$y));
}
printf("%d",$result);


Measured memory_bytes: 29168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();
	static NodeSegmentTree[] V;
	static int N;

	public static void main(String[] args) {
		int n = sc.nextInt();
		int q = sc.nextInt();

		N = 1;
		while(N < n) {
			N *= 2;
		}
		N = N * 2 - 1;
		if(N == 1) {
			N = 3;
		}

		V = new NodeSegmentTree[N];
		for(int i=0; i<N; i++) {
			V[i] = new NodeSegmentTree(i);
		}

		for(int i=N/2 - 1; i>=0; i--) {
			V[i].setSegment();
		}

		StringBuilder sb = new StringBuilder();
		for(int i=0; i<q; i++) {
			int cmd = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();

			if(cmd == 0) {
				V[N/2 + x].updateValue(y);
			} else {
				int ans = V[0].getMinimum(x, y);
				sb.append(ans);
				sb.append("\n");
			}
		}

		System.out.print(sb);

	}

	static class NodeSegmentTree {
		int seg_left;
		int seg_right;
		int id;
		int value = Integer.MAX_VALUE;
		//left = 2 * id + 1
		//right = 2 * id + 2
		//parent = (id - 1) / 2
		//array[i] -> V[N/2 + i]

		NodeSegmentTree(int id) {
			this.id = id;
			this.seg_left = id - N/2;
			this.seg_right = id - N/2;
		}

		void setSegment() {
			seg_left = V[2 * id + 1].seg_left;
			seg_right = V[2 * id + 2].seg_right;
		}

		void updateValue(int value) {
			if(id >= N/2 || value < this.value) {
				this.value = value;
				V[(id - 1) / 2].updateValue(value);
			} else if(this.value != V[2 * id + 1].value && this.value != V[2 * id + 2].value) {
				this.value = Math.min(V[2 * id + 1].value, V[2 * id + 2].value);
				V[(id - 1) / 2].updateValue(value);
			}
		}

		public int getMinimum(int l, int r) {
//			System.out.println(id + " " + value);
			if(l <= seg_left && r >= seg_right) {
				return value;
			}
			if(l > seg_right || r < seg_left) {
				return Integer.MAX_VALUE;
			}

			int a = V[2 * id + 1].getMinimum(l, r);
			int b = V[2 * id + 2].getMinimum(l, r);
			return Math.min(a, b);
		}

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 83248
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	int A,B,C;	cin >> A >> B >> C;
	ans = C - min(A-B,C);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,(n))
typedef long long ll;
using namespace std;
/*
あなたは 1 回の操作でどれか 1 つの項の値を 1だけ増やすか減らすことができます。

以下の条件を満たすために必要な操作回数の最小値を求めてください。

・すべてのi(1≦i≦n)に対し、第 1 項から第 i 項までの和は 0でない
・すべてのi(1≦i≦n−1)に対し、i 項までの和と i+1 項までの和の符号が異なる
*/

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    // 偶数にplus
    int sum = 0;
    bool plus = true;
    int64_t ans1 = 0;
    rep(i, n) {
        sum += a[i];
        if (plus) {
            if (sum <= 0) {
                ans1 += abs(sum) + 1;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                ans1 += abs(sum) + 1;
                sum = -1;
            }
        }
        plus ^= true;
    }
    // 奇数
    sum = 0;
    plus = false;
    int64_t ans2 = 0;
    rep(i, n) {
        sum += a[i];
        if (plus) {
            if (sum <= 0) {
                ans2 += abs(sum) + 1;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                ans2 += abs(sum) + 1;
                sum = -1;
            }
        }
        plus ^= true;
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ii pair <int, int>
#define x first
#define y second
#define db(x) cerr << #x << " = " << x << endl;
#define _ << " _ " <<

using namespace std;

const int N = 3007;

string s, t, res;
int m, n;
int dp[N][N];
ii trace[N][N];

void Trace(int i, int j){
	if (i == 0 && j == 0) return;
	if (s[i] == t[j]){
		res.push_back(s[i]);
		Trace(i - 1, j - 1);
	}
	else
		Trace(trace[i][j].x, trace[i][j].y);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
	cin >> s >> t;
	m = s.size(); n = t.size();
	s = ' ' + s; t = ' ' + t;
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
			if (s[i] == t[j]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
				trace[i][j] = ii(i - 1, j - 1);
			}
			else{
				if (dp[i - 1][j] > dp[i][j - 1]){
					dp[i][j] = dp[i - 1][j];
					trace[i][j] = ii(i - 1, j);
				}
				else{
					dp[i][j] = dp[i][j - 1];
					trace[i][j] = ii(i, j - 1);
				}
			}
	Trace(m, n);
	reverse(res.begin(), res.end());
	cout << res;
}

Measured memory_bytes: 106112
/**
 * Boris Sokolov
 * Software Engineer at Ring Labs
 * Kiev, Ukraine | Los Angeles, CA
 */

#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
//using namespace std;

typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = static_cast<int>(1e9);
const int MOD = static_cast<int>(1e9) + 7;

int f[(int)1e5 + 9];

int main() {
    //freopen("in.txt", "rt", stdin);
    //freopen("out.txt", "wt", stdout);
    f[0] = 1;
    for (int i = 1; i <= 100000; ++i) {
        f[i] = ((ll)f[i - 1] * i) % MOD;
    }
    int n, m;
    scanf("%d %d", &n, &m);
    if (abs(n - m) > 1) {
        printf("0\n");
        return 0;
    }
    if (n == m) {
        printf("%d\n", (ll)f[n] * f[m] * 2 % MOD);
    } else {
        printf("%d\n", (ll)f[n] * f[m] % MOD);
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define N 20000
typedef struct Data{
  int area,posi;
}Data;

Data t[N];
int u[N],n,i,T,U,ans,A;
char str1[N+1];

Data X,Y;

void Dpush(Data data)
{
  t[T++]=data;
}
Data Dpop()
{
  return t[--T];
}
void push(int x)
{
  u[U++]=x;
}
int pop()
{
  return u[--U];
}
void init()
{
  ans=U=T=0;
}

Data mkData(int x,int y)
{
  Data res;
  res.area=x;
  res.posi=y;

  return res;
}

int main(){
  init();
  scanf("%s",str1);
  n=strlen(str1);

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

    if(str1[i]=='/'){
      if(U==0)
	continue;
	A=pop();
	X=mkData(i-A,A);
	ans+=i-A;
	while(T>0){
	  Y=Dpop();
	  if(Y.posi<A){
	    Dpush(Y);
	    break;
	  }
	  X.area+=Y.area;
	  if(Y.posi<X.posi)
	    X.posi=Y.posi;
	}
	Dpush(X);
    }
    else if(str1[i]=='\\'){
      push(i);
    }
  }
  printf("%d\n%d",ans,T);
  for(i=0;i<T;i++){
    printf(" ");
    printf("%d",t[i].area);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 644
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#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++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;

int const N_MAX = 1e5;

int N;
int L[N_MAX + 1];

int main() {
  scanf("%d", &N);
  int max_len = 0;
  int max_len_idx = 0;
  rep(i, N) {
    scanf("%d", &L[i]);
    if (L[i] > max_len) {
      max_len = L[i];
      max_len_idx = i;
    }
  }
  int sum = 0;
  rep(i, N) {
    if (i != max_len_idx) sum += L[i];
  }
  if (sum > max_len) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;

double f(int n, double p){
    if(n >= K){
        return p;
    }

    return f(n * 2, p * 0.5);
}

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

    std::cin >> N >> K;

    double p = 1.0 * std::max(N + 1 - K, 0) / N;

    for(int i=1;i<K&&i<=N;++i){
        p += f(i, 1) / N;
    }

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


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut sx = read::<i64>();
  let mut sy = read::<i64>();
  let mut tx = read::<i64>();
  let mut ty = read::<i64>();
  let mut ans = String::from("");

  let abs_y = ty - sy;
  let abs_x = tx - sx;
  // 1往路
  for i in 0..abs_y {
    ans.push('U')
  }
  for i in 0..abs_x {
    ans.push('R')
  }

  // 1帰り
  ans.push('R');
  for i in 0..abs_y + 1 {
    ans.push('D')
  }
  for i in 0..abs_x + 1 {
    ans.push('L')
  }
  ans.push('U');

  // 2行き
  for i in 0..abs_x {
    ans.push('R')
  }
  for i in 0..abs_y {
    ans.push('U')
  }

  // 2帰り
  ans.push('U');
  for i in 0..abs_x + 1 {
    ans.push('L')
  }
  for i in 0..abs_y + 1 {
    ans.push('D')
  }
  ans.push('R');

  println!("{}", ans);
}



Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
  int H, W;
  int c[20][20] = {};
  int A[210][210] = {};
  int mp = 0;
  int i, j, k;

  scanf("%d %d", &H, &W);
  for(i = 0; i < 10; i++){
    for(j = 0; j < 10; j++){
      scanf("%d", &c[i][j]);
    }
  }
  for(i = 1; i <= H; i++){
    for(j = 1; j <= W; j++){
      scanf("%d", &A[i][j]);
    }
  }

  for(i = 0; i < 10; i++){//経由する数値
    for(j = 0; j < 10; j++){//出発する数値
      for(k = 0; k < 10; k++){//目的の数値
        if(c[j][k] > c[j][i] + c[i][k]){
          c[j][k] = c[j][i] + c[i][k];
        }
      }
    }
  }

  for(i = 1; i <= H; i++){
    for(j = 1; j <= W; j++){
      if(A[i][j] != -1){
        mp += c[A[i][j]][1];
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 512
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
x_li = []
y_li = []
h_li = []
for i in range(n):
    x, y, h = na()
    x_li.append(x)
    y_li.append(y)
    h_li.append(h)
ans = []
flag = False
for i in range(len(h_li)):
    if h_li[i] > 0:
        idx = i
        break
for x in range(101):
    for y in range(101):
        H = h_li[idx] + abs(x_li[idx] - x) + abs(y_li[idx] - y)
        for i in range(n):
            if h_li[i] == max(H - abs(x_li[i] - x) - abs(y_li[i] - y), 0):
                if i == n - 1:
                    flag = True
                    ans.append([x, y, H])
                    break
            else:
                break
        if flag:
            break
    if flag:
        break
print(*ans[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int maxk = (n + 1) / 2;
	if (k > maxk) {
		printf("-1\n");
		return 0;
	}
	vector<pair<int, int>> ans;
	if (n % 2 == 1) {
		for (int a = 0; a < n; a += 2) {
			ans.push_back({a, 2 * n - maxk + (int)ans.size() - a});
		}
		for (int a = 1; a < n; a += 2) {
			ans.push_back({a, 2 * n - maxk + (int)ans.size() - a});
		}
	} else {
		ans.push_back({0, n});
		for (int a = 1; a < n; a += 2) {
			ans.push_back({a, 2 * n - maxk + (int)ans.size() - a});
		}
		for (int a = 2; a < n; a += 2) {
			ans.push_back({a, 2 * n - maxk + (int)ans.size() - a});
		}
	}
	assert(ans.size() == n);
	for (int i = 0; i < ans.size(); ++i) {
		printf("%d %d %d\n", ans[i].first + k, ans[i].second + k, k + 2 * n + i);
	}
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s;
int ans = 0;
int main(){
	while (cin >> s){
		bool f = 1;
		REP(i, s.size() / 2){
			if (s[i] != s[s.size() - 1 - i]){
				f = 0;
			}
		}
		if (f)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1184
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    int H,W,N;
    cin>>H>>W>>N;
    if(W<H){
        if(N%H==0){
            cout<<((N/H))<<endl;
        }
        else{
            cout<<((N/H)+1)<<endl;
        }
    }
    else{
        if(N%W==0){
            cout<<((N/W))<<endl;
        }
        else{
            cout<<((N/W)+1)<<endl;
        }
    }

}

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

int main(){
  int N;
  cin >> N;
  
  vector<pair<int,int>> A(N);
  int dum;
  for (int i=0; i<N; i++){
    cin >> dum;
    A.at(i)=make_pair(dum,i+1);
  }
  
  sort(A.begin(),A.end());
  
  for (int i=0; i<N; i++){
  	cout << A[i].second<<" ";
  }
  cout << endl;
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
X = A[0]
p = abs(2 * X - S)
for i in range(1, N-1):
  X += A[i]
  if p > abs(2 * X - S):
    p = abs(2 * X - S)
  if p == 0:
    break
print(p)

Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

pii max(pii a, pii b){
  if(a.first > b.first){
    return a;
  }else if(a.first < b.first){
    return b;
  }else{
    if(a.second > b.second){
      return b;
    }else{
      return a;
    }
  }
}
pii dp[111][50000];

int main(){
  int n;
  while(std::cin >> n, n){
    vector<int> shop(n);
    for (int i = 0; i < n; i++) std::cin >> shop[i];
    
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j < 50000; j++) {
        dp[i][j] = pii(-1e9, 0);
      }
    }

    dp[0][0] = pii(0, 0);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 50000; j++) {
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        
        int tf = dp[i][j].first;
        int tc = dp[i][j].second;
        int five_hundred;
        int diff = (5000 - shop[i])%1000;
        if(j + diff >= 500)
          dp[i + 1][j + diff - 500] = max(dp[i + 1][j + diff - 500], pii(tf + 1, tc + shop[i]));
        else
          dp[i + 1][j + diff] = max(dp[i + 1][j + diff],
                                    pii(tf, tc + shop[i]));
      }
    }
    pii ans = pii(0, 0);
    for (int i = 0; i < 50000; i++) {
      ans = max(ans, dp[n][i]);
    }
    std::cout << ans.first << " " << ans.second << std::endl;
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll cnt[9][9] = {};

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

    ll N;
    cin >> N;

    for(int i=1;i<=N;i++){
    	string s = to_string(i);
    	ll idx = s[0] - '1';
    	ll jdx = s.back() - '1';
    	if(idx<0||jdx<0) continue;
    	cnt[idx][jdx]++;
    }
    ll res = 0;
    REP(i, 9){
    	REP(j, 9){
    		res += (cnt[i][j] * cnt[j][i]);
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      sum += a[i];
    }
    int count = 0;
    int judge = sum/(4*m);
    if(sum%(4*m)!=0){
      judge+=1;
    }
    for(int i = 0; i < n; i++){
      if(a[i] >= judge){
        count++;
      }
    }
    if(count >= m){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

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

int main() {
  int W, H, N, a, b;
  cin >> W >> H >> N;
  a = 0;
  b = 0;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> n(N);
  for(int i = 0; i < N; i++){
    cin >> x.at(i) >> y.at(i) >> n.at(i);
  }
  
  for(int i = 0; i < N; i++){
    if(n.at(i) == 1 ){
      a = max(a, x.at(i));
    }
    if(n.at(i) == 2){
      W = min(W, x.at(i));
    }
    if(n.at(i) == 3){
      b = max(b, y.at(i));
    }
    if(n.at(i) == 4){
      H = min(H, y.at(i));
    }
  }
  
  int ans;
  ans = (W - a)*(H - b);
  if(W - a < 0 || H - b < 0){
    ans = 0;
  }
  
  cout << ans << endl;
}

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

int main()
{
    std::string s;
    std::cin >> s;

    auto check = [&]() {
        if (s.length() % 2) {
            return false;
        }

        for (int i = 0; i < s.length() / 2; i++) {
            if (s[i] != s[i + s.length() / 2]) {
                return false;
            }
        }
        return true;
    };
    while (1) {
        s.pop_back();

        if (check()) {
            std::cout << s.length() << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL mod=1e9+7;
const LL inf=1e18;
const double eps=1e-9;
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
LL n,s,ans;
void jg(LL a){
    LL sum=0,x=n;
    while(x){
        sum+=x%a;
        x/=a;
    }
    if(sum==s) ans=min(ans,a);
}
LL solve(LL x){
    if(x<0) return -1;
    if(x==0) return n+1;
    ans=inf;
    for(LL i=1;i*i<=x;i++){
        if(x%i) continue;
        jg(i+1);
        jg(x/i+1);
    }
    return ans==inf?-1:ans;
}
int main()
{
    cin>>n>>s;
    cout<<solve(n-s)<<endl;
    return 0;
}


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

using namespace std;
using LL = long long;



/////////////////////////////////////////////////////////////////////////////////////////////
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////


map< LL, int > primeFactors(LL N) {

	map< LL, int > ans;

	for(LL i = 2; i * i <= N; ++i) {
		while(N % i == 0LL) {
			N /= i;
			ans[i]++;
		}
	}

	if (N > 1) ans[N]++;

	return ans;

}

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);
	
	LL N; cin >> N;

	map< LL,int > factors = primeFactors(N);	

	int ans = 0;

	for(pair<LL, int> x : factors) {
		int delta = 1;

		for(int i = 1; i <= x.second; i += delta) {
			++ans;
			++delta;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
R = N-K
RR = R-1
mod = 10**9+7

def nCr(n,r):
    K = 1
    for j in range(1,r+1):
        K = K*(n+1-j)//j
    return K

    
for i in range(K):
    ans = (nCr(K-1,i)%mod)*(nCr(N-K+1,i+1)%mod)
    ans = ans%mod
    print(ans)

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

using namespace std;


int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int m_el = max(a, max(b, c));

    cout << m_el * (1 << k) + a + b + c - m_el << '\n';
}


Measured memory_bytes: 256