akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    ll a,b; cin >> a >> b;
    cout << a*b;
    
    return;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
int n, q;
int arr[200005];
int fsum[200005];
int sum = 0;	
int main() {
	int a, b;
	cin >> a >> b;
	cout << (a ^ b);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        bool ok = false;
        int ret = 1;
        for(int i=0; i<n; ++i){
            int k;
            cin >> k;
            if(k >= 1)
                ++ ret;
            if(k >= 2)
                ok = true;
        }

        if(ok)
            cout << ret << endl;
        else
            cout << "NA" << endl;
    }
}

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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int x;
    cin >> x;
    int a[1001] = {0};
    a[1] = 1;
    for (size_t i = 2; i < 32; i++)
    {
        int b = i * i;
        a[b] = 1;
        while (b * i <= 1000)
        {
            b *= i;
            a[b] = 1;
        }
        /* code */
    }
    for (int i = x; i >= 1; i--)
    {
        if (a[i] == 1)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int h, n;
    cin >> h >> n;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        h -= a;
    }

    cout << (h <= 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
ans = 0
n = gets.to_i

def true_or_false (a)
    a_heihou = a**(1/2.0)
    hh = a_heihou.floor
    if a == 2
        return true
    elsif a > 2 && a % 2 == 0
        return false
    else
        i = 3
        while i <= hh
            if a % i == 0
                return false
            end
            i += 2
        end
        return true
    end
end


n.times do
    h = gets.to_i
    ans += 1 if true_or_false(h)
end
puts ans


Measured memory_bytes: 6944
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
using namespace std;
struct Edge {
	int from, to, cost;
};
class UnionFindTree {
	vector<int> vec;
public:
	UnionFindTree(int size) : vec(size, -1) {};
	int find(int a) {
		return vec[a] < 0 ? a : vec[a] = find(vec[a]);
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	bool unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return false;
		if (vec[a] > vec[b]) swap(a, b);
		vec[a] += vec[b];
		vec[b] = a;
		return true;
	}
};
int main() {
	int test_case{ 0 };
	while (true) {
		int n, t, k; cin >> n >> t >> k;
		if (n == 0 && t == 0 && k == 0) break;
		vector<Edge> edges(n - 1);
		for (auto& e : edges)
			cin >> e.from >> e.to >> e.cost;
		UnionFindTree uft(n + 1);
		for (auto i = 0; i < t; ++i) {
			int base; cin >> base;
			uft.unite(base, 0);
		}
		sort(edges.rbegin(), edges.rend(), [](const Edge& a, const Edge& b) {return a.cost < b.cost; });
		int sum_cost{ 0 };
		for (const auto e : edges) {
			if (!uft.unite(e.from, e.to) && ++k >= t) {
				sum_cost += e.cost;
			}
		}
		cout << "Case " << ++test_case << ": " << sum_cost << '\n';
	}
}


Measured memory_bytes: 3192
#factorial(9)でもうTLE
import itertools
import math

n = int(input())
lis = [x for x in range(1,n+1)]#順列とる数列
xy = [list(map(int,input().split())) for i in range(n)]#座標をメモ
permutations_lis = itertools.permutations(lis)#順列とって
l = list(permutations_lis)#全順列のリストを作る
ans = 0

for onecase in l: 
  s = 0
  for j in range(n-1):
    s += math.sqrt((xy[onecase[j]-1][0]-xy[onecase[j+1]-1][0])**2 + (xy[onecase[j]-1][1]-xy[onecase[j+1]-1][1])**2)
  ans += s
  
print(ans/math.factorial(n))

Measured memory_bytes: 7996
#include<stdio.h>

typedef struct TREE{
	int id;
	struct TREE *parent;
	struct TREE *child[2];
	int depth;
	int height;
}Tree;

Tree tree[100];

int setDepthHeight(Tree *nt, int depth){
	if( nt == NULL ){ return -1; }
	nt->depth = depth;
	int lh = setDepthHeight(nt->child[0], depth+1);
	int rh = setDepthHeight(nt->child[1], depth+1);
	nt->height = (lh>rh?lh:rh) + 1;
	return nt->height;
}

void preOrder(Tree *tr){
	if( tr == NULL ){ return; }
	printf(" %d", tr->id);
	preOrder(tr->child[0]);
	preOrder(tr->child[1]);
	return;
}

void inOrder(Tree *tr){
	if( tr == NULL ){ return; }
	inOrder(tr->child[0]);
	printf(" %d", tr->id);
	inOrder(tr->child[1]);
	return;
}

void postOrder(Tree *tr){
	if( tr == NULL ){ return; }
	postOrder(tr->child[0]);
	postOrder(tr->child[1]);
	printf(" %d", tr->id);
	return;
}

void output(Tree *tr){
	char *nodetype[3] = {"root", "internal node", "leaf"};
	int pid, sibling = -1, degree = 0, ni;
	if( tr->child[0] != NULL ){ degree++; }
	if( tr->child[1] != NULL ){ degree++; }
	if( tr->parent != NULL ){
		if( tr->parent->child[0] != NULL && tr->parent->child[0]->id != tr->id ){
			sibling = tr->parent->child[0]->id;
		}else if( tr->parent->child[1] != NULL && tr->parent->child[1]->id != tr->id ){
			sibling = tr->parent->child[1]->id;
		}
		if( degree == 0 ){
			ni = 2;
		}else{
			ni = 1;
		}
		pid = tr->parent->id;
	}else{
		ni = 0;
		pid = -1;
	}
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", 
		tr->id, pid, sibling, degree, tr->depth, tr->height, nodetype[ni]
	);
	return;
}

int main(){
	int n, id, id2, i, j;
	Tree *root = NULL;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		tree[i].id = -1;
		tree[i].parent = NULL;
		tree[i].child[0] = NULL;
		tree[i].child[1] = NULL;
		tree[i].depth = -1;
		tree[i].height = -1;
	}
	for( i = 0; i < n; i++ ){
		scanf("%d", &id);
		tree[id].id = id;
		scanf("%d", &id2);
		if( 0 <= id2 && id2 < n ){
			tree[id].child[0] = &tree[id2];
			tree[id2].parent = &tree[id];
		}
		scanf("%d", &id2);
		if( 0 <= id2 && id2 < n ){
			tree[id].child[1] = &tree[id2];
			tree[id2].parent = &tree[id];
		}
	}
	for( i = 0; i < n; i++ ){
		if( tree[i].parent == NULL ){
			root = &tree[i];
			break;
		}
	}
	setDepthHeight(root, 0);
	printf("Preorder\n");
	preOrder(root);
	printf("\n");
	printf("Inorder\n");
	inOrder(root);
	printf("\n");
	printf("Postorder\n");
	postOrder(root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll N,W,ww,vv,w1,ans=0;
  cin >> N >> W;
  vector<vector<ll>> v(4);
  FOR(i,0,N){
    cin >> ww >> vv;
    if(!i)w1 = ww;
    v[ww-w1].push_back(vv);
  }
  FOR(i,0,4)sort(ALL(v[i]),greater<int>());
  FOR(i,0,4)v[i].insert(v[i].begin(),0);
  FOR(i,0,4)FOR(j,1,v[i].size())v[i][j] += v[i][j-1];
  FOR(i,0,v[0].size()){
    FOR(j,0,v[1].size()){
      FOR(k,0,v[2].size()){
        FOR(l,0,v[3].size()){
          if(w1*(i+j+k+l)+j+2*k+3*l <= W){
            ans = max(ans,v[0][i]+v[1][j]+v[2][k]+v[3][l]);
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
       
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a <= c && c <= b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func main() {
	var N int
	var S string
	fmt.Scanf("%d\n%s\n", &N, &S)

	if N%2 != 0 {
		fmt.Println("No")
		return
	}
	if S[:N/2] == S[N/2:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(void) {
    int K,A,B;
    cin >> K >> A >> B;
    
    if(B/K > A/K) {
        cout << "OK\n";
    } else {
        if((B%K) == 0  || (A%K) == 0) {
            cout << "OK\n";
        } else {
            cout << "NG\n";
        }
    }
    return 0;
}


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

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

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &a : A)
    cin >> a;
  vector<ll> B(N);
  for (auto &b : B)
    cin >> b;
  int ans = 0;
  ll sumA = accumulate(A.begin(), A.end(), 0LL);
  ll sumB = accumulate(B.begin(), B.end(), 0LL);
  if (sumA < sumB)
    cout << -1 << endl;
  else
  {
    ll shortageSum = 0;
    int num = 0;
    vector<ll> excess;
    cerr << "a" << endl;
    for (int i = 0; i < N; i++)
    {
      if (A[i] < B[i])
      {
        shortageSum += B[i] - A[i];
        num++;
      }
      else if (A[i] > B[i])
      {
        excess.push_back(A[i] - B[i]);
      }
    }
    sort(excess.begin(), excess.end(), greater<ll>());
    int idx = 0;
    while (shortageSum > 0)
    {
      shortageSum -= excess[idx];
      idx++;
    }
    ans = num + idx;
    cout << ans << endl;
  }
  return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------

int tap(int a,int b){
    if(b==0) return 1;
    if(b==1) return a;
    else return a+(a-1)*(b-1);
}

int main(){
    CIN(N);
    double ans=0.0;
    rep(i,N){
        int A;
        scanf("%d",&A);
        ans+=(double)1/A;
    }
    ans=(double)1/ans;
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int main(){
  int n,k; cin >>n >>k;
  vector<li> v(n); rep(i,n) cin >>v[i];
  if(k>=n*2){
    li s=0;
    for(li x:v) s+=max((li)x,(li)0);
    print(s);
    return 0;
  }
  li m=0;
  rep(d,(k+1)/2){  // dispose
    rep(l,min(k-d,n)+1){
      vector<li> take;
      rep(i,l)take.push_back(v[i]);
      if(df)print("l",take);
      rep(r,min(n-l,k-d-l)+1){
        if(r>0){
          take.push_back(v[n-r]);
        }
        sort(take.begin(),take.end());
        if(df)print(take);
        li s=0;
        rep(i,take.size()){
          if((i>=d) or (take[i]>=0)) s+=take[i];
        }
        m=max(m,s);
      }
    }
  }
  print(m);
}


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

int main(void)
{
    char S[4];
    int a = 0;
    int i;

    scanf("%s", S);

    for (i= 0; i < 3; i++) {
        if (S[i] == 'A') a++;
    }

    if ((a == 3) || (a == 0)) {
        printf("No");
    } else {
        printf("Yes");
    }

    return 0;
}

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

int main() {
  int N,A=0,S=1;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  A += vec.at(0);
  for(int i = 1;i < N;i++) {
    if(A > vec.at(i)) {
      S++;
      A = vec.at(i);
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 4032
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <fstream>
#include <sstream>
#include <assert.h>
#include <unordered_map>
#define eps 1e-7
#define SIZE 1001000
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define pi acos(-1.0)
#define mp make_pair
#define ll long long
#define eps 1e-9
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll a[SIZE], b[SIZE], n, num1 = 0, num2 = 0;
const ll mod = 1e9 + 7;
void show(int n, ll a[]) {
	cout << "当前数组中的元素为：\n";
	rep(i, 1, n) cout << a[i] << ' ';
	puts("");
}

void bubble_sort(int n, ll a[]) {
	rep(i, 1, n)
		rep(j, 2, (n - i + 1))
			if (a[j - 1] > a[j]) 
				swap(a[j - 1], a[j]), ++num1;
	show(n, a);
}

void radix_sort(int n, ll a[]) {
	queue<int> q[10];
	ll maxx = 0, base = 1;
	rep(i, 1, n) maxx = max(maxx, a[i]);
	int len = log10(maxx) + 1;
	rep(i, 0, (len - 1)) {
		rep(j, 1, n) q[(a[j] / base) % 10].push(a[j]), ++num2;
		int cnt = 0;
		rep(j, 0, 9) {
			while (!q[j].empty()) {
				a[++cnt] = q[j].front();
				q[j].pop(); ++num2;
			}
		}
		base *= 10ll;
	}
	show(n, a);
}

int main() {
	/*io(); cin >> n;
	rep(i, 1, n) a[i] = i;
	random_shuffle(a + 1, a + 1 + n);
	rep(i, 1, n) b[i] = a[i];
	bubble_sort(n, a);
	cout <<"冒泡排序操作次数："<< num1 << '\n';
	radix_sort(n, b);
	cout << "基数排序操作次数："<<num2 << '\n';*/
	io(); cin >> n;
	string s; cin >> s;
	ll ans = 1;
	rep(i, 1, n) ans = 1ll * i * ans % mod;
	int cnt = 0;
	rep(i, 0, (2 * n - 1)) {
		if (s[i] == 'W' && (cnt % 2 == 0)) ans = (ans * cnt--) % mod;
		else if (s[i] == 'B' && (cnt % 2)) ans = (ans * cnt--) % mod;
		else ++cnt;
	}
	if (cnt != 0) ans = 0;
	cout << ans;
}
/*
由于数据量过大，不在每一步都不输出，仅输出结果
截图中的数据量较小，若需要1000000的数据量可预设n的值
*/

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

const int64_t MAX = 510000;
const int64_t MOD = 1000000007;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  COMinit();
  vector<int64_t> nck(N);
  for(int i=0; i<N; i++){
    nck.at(i) = COM(i,K-2);
  }
  vector<int64_t> sum(N);
  for(int i=0; i<N; i++){
    if(i == 0){
      sum.at(i) = vec.at(i);
    }
    else{
      sum.at(i) = sum.at(i-1) + vec.at(i);
    }
  }
  
  int64_t ans = 0;
  if(K != 1){
    for(int64_t i=K-2; i<=N-2; i++){
      int64_t x = sum.at(N-1) - sum.at(i) - sum.at(N-2-i);
      x %= MOD;
      x *= nck.at(i);
      x %= MOD;
      ans += x;
      ans %= MOD;
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 14592
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt(), m = sc.nextInt();
        int[][] a = new int[m][4];

        for (int i = 0; i < m; i++) {
            a[i][0] = i;
            a[i][1] = sc.nextInt(); // city
            a[i][2] = sc.nextInt(); // year
        }

        sortYear(a);
        String[] ans = new String[m];
        int[] count = new int[n + 1];
        for (int i = 0; i < m; i++) {
            count[a[i][1]]++;
            ans[a[i][0]] = String.format("%06d", a[i][1]) + String.format("%06d", count[a[i][1]]);
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < m; i++) {
            sb.append(ans[i]).append("\n");
        }
        System.out.print(sb);
    }

    static void sortYear(int[][] array) {
         Arrays.sort(array, new Comparator<int[]>() {
        @Override
        public int compare(int[] o1, int[] o2) {
            return o1[2] - o2[2];    //[0] をキーにソート(昇順)
            //return o2[0] - o1[0];    //[0] をキーにソート(降順)
        }
    });
    }
}


Measured memory_bytes: 165808
import sys

data=input().split(' ')
k=int(data[0])
data_1sub=k+1
s=int(data[1])
d=0
e=0
for i in range(data_1sub):
    for j in range(data_1sub):
        d=s-i-j
        if (0 <= d) and (d <= k):
            e=e+1
        else:
            pass
print(e)

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N, M; cin >> N >> M;
    cout << ( 1900 * M + ( N - M ) * 100 ) * pow( 2, M ) << endl;
}


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

struct Edge {
    ll to, cost;
    Edge(ll t, ll c) : to(t), cost(c) {}
};
struct Elem {
    ll dist, speed, cur;
    Elem(ll a, ll b, ll c) : dist(a), speed(b), cur(c) {}
};
bool operator>(const Elem& a, const Elem& b) {
    return a.dist != b.dist ? a.dist > b.dist : a.speed > b.speed;
}

typedef vector< vector<Edge> > Graph;
ll const INF = 1LL << 60;

int main() {
    ll dist[510][60][2];
    ll ans = INF;
    for(int i=0; i<510; i++)
        for(int j=0; j<60; j++)
            for(int k=0; k<2; k++)
                dist[i][j][k] = INF;

    int n, m; cin >> n >> m;
    Graph G(n);
    for(int i=0; i<m; i++) {
        ll a, b, t; cin >> a >> b >> t;
        a--; b--;
        G[a].push_back(Edge(b,t));
        G[b].push_back(Edge(a,t));
    }
    ll v, a, b, c;
    cin >> v >> a >> b >> c;
    priority_queue< Elem, vector<Elem>, greater<Elem> > q;

    ll cur = 0, speed = v;
    dist[0][v][0] = 0;
    q.push(Elem(0, speed, cur));
    while(!q.empty()) {
        Elem temp = q.top(); q.pop();
        cur = temp.cur, speed = temp.speed;
        ll nsp = (a * speed + b) % c;
        for(size_t i=0; i<G[cur].size(); i++) {
            Edge e = G[cur][i];
            ll d1 = dist[cur][speed][0] + e.cost * speed;
            ll d2 = dist[cur][speed][1] + e.cost * speed;
            // home to university
            if(dist[e.to][nsp][0] > d1) {
                dist[e.to][nsp][0] = d1;
                if(e.to == n-1) dist[e.to][nsp][1] = dist[e.to][nsp][0];
                q.push(Elem(d1, nsp, e.to));
            }
            // university to home
            if(dist[e.to][nsp][1] > d2) {
                dist[e.to][nsp][1] = d2;
                q.push(Elem(d2, nsp, e.to));
            }
        }
    }

    for(int i=0; i<c; i++) ans = min(ans, dist[0][i][1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9672
x = gets.to_i

(0..10000).each do |i|
  (0..10000).each do |j|
    if i**5 - j**5 == x
      puts "#{i} #{j}"
      exit
    elsif i**5 + j**5 == x
      puts "#{i} -#{j}"
      exit
    end
  end
end

Measured memory_bytes: 14396
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int sx, sy, tx, ty;

void solve() {
    REP(i, tx - sx) putchar('R');
    REP(i, ty - sy) putchar('U');
    REP(i, tx - sx) putchar('L');
    REP(i, ty - sy)putchar('D');
    putchar('L');
    REP(i, ty - sy + 1) putchar('U');
    REP(i, tx - sx + 1) putchar('R');
    putchar('D');
    putchar('R');
    REP(i, ty - sy + 1) putchar('D');
    REP(i, tx - sx + 1) putchar('L');
    putchar('U');
}

int main() {
    cin >> sx >> sy >> tx >> ty;
    solve();
    return 0;
}

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

int main(){
  ll M,K; cin >> M >> K;
  
  ll p = pow(2,M);
  
  if( p <= K ){ cout << -1 << endl; return 0;} 
  
  if( M == 0){
    cout << 0 << " " << 0  << endl;
  }
  else if( M == 1){ 
    if( K == 0 ){ cout << 0 << " "<< 0 << " " << 1 << " " << 1 << endl;}
    else{ cout << -1 << endl;}
  }
  else{
    //具体的に構成
    
    vector<ll> b;
    
    for(ll i = 0; i < p; i++){
      if( i == K){ continue;}
      b.push_back(i);
    }
    
    vector<ll> c = b;
    
    reverse(c.begin(),c.end());
    
    for(auto ne : b){ cout << ne << " ";}
    cout << K << " ";
    for(auto ne : c){ cout << ne << " ";}
    cout << K << endl;
    

  }
  return 0;
} 

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    int x[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d",&k);
    printf("%d",x[k-1]);
}

Measured memory_bytes: 256
n,k = map(int, input().split())
p = list(map(int, input().split()))

saikoro = [0] * 1001
for i in range(1, 1001):
    saikoro[i] = (saikoro[i-1] + i)

s = [0] * (n + 1)
for u in range(1,n + 1):
    s[u] = saikoro[p[u - 1]] / p[u - 1] + s[u - 1]

ans = 0
for j in range(k - 1,n):
    ans = max(ans, s[j + 1] - s[j + 1 - k])
 
print(ans)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#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 per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5;
const ll inf=1e18+100;
vector<ll>A;
int n,q;
ll a[maxn],cnt[maxn],ans[maxn];
typedef vector<ll>::iterator It;
void calc1(ll x,ll num){
	It it=lower_bound(A.begin(),A.end(),x);
	if(it==A.begin()){
		ans[x]+=num;
		return;
	}
	it--;
	cnt[it-A.begin()]+=num*(x/(*it));
	x%=(*it);
	calc1(x,num);
}
int main(){
	read(n);read(q);
	if(!q){
		rep(i,1,n)puts("1");
		return 0;
	}
	rep(i,1,q)read(a[i]);
	ll mini=inf;
	per(i,q,1){
		if(a[i]<mini)A.pb(a[i]);
		mini=min(mini,a[i]);
	}
	if(A.back()>n)A.pb(n);
	reverse(A.begin(),A.end());
	cnt[SZ(A)-1]=1;
	per(i,SZ(A)-1,1)if(cnt[i]){
		cnt[i-1]+=cnt[i]*(A[i]/A[i-1]);
		calc1(A[i]%A[i-1],cnt[i]);
	}
	ans[A[0]]+=cnt[0];
	per(i,n,1)ans[i]+=ans[i+1];
	rep(i,1,n)printf("%lld\n",ans[i]);
	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vi a(N), b(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    for (int i = 0; i < N; i++)
        cin >> b[i];

    int res = 0;
    for (int bit = 0; bit < 29; bit++) {
        int M = 1 << (bit + 1);

        vi vals;
        for (int v : b) {
            vals.push_back(v & (M - 1));
        }
        sort(all(vals));

        // returns number of elements of vals in [l, r)
        auto ct = [&vals](int l, int r) {
            return lower_bound(all(vals), r) - lower_bound(all(vals), l);
        };

        ll app = 0;

        // want a + b >= 2^b mod 2^(b+1)
        for (int _v : a) {
            int v = _v & (M - 1);
            int l = M/2 - v, r = M - v;
            if (l >= 0) app += ct(l, r);
            else app += ct(0, r) + ct(l + M, M);
        }

        if (app&1) res ^= 1 << bit;
    }

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



Measured memory_bytes: 3700
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using Graph=vector<vector<int>>;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main(){
    int n;cin>>n;
    Graph G(n+2);
    for(int i=0;i<n;i++){
        int u,k;cin>>u>>k;
        for(int j=0;j<k;j++){
            int v;cin>>v;
            G[u].push_back(v);
        }
    }
    bool ans_check=false;
    vector<int> b(n+2,1000000);
    queue<int> q;
    b[1]=0;
    q.push(1);
    while(!q.empty()){
        int x=q.front();q.pop();
        for(int A=0;A<G[x].size();A++){
            int check_x=G[x][A];
            if(b[check_x]==1000000){
                q.push(check_x);
                b[check_x]=b[x]+1;
            }
        }
    }
    for(int i=1;i<n+1;i++){
        if(b[i]==1000000) b[i]=-1;
        cout<<i<<' '<<b[i]<<endl;
    }
}




Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
ll dp[200000];
int h[200000];
int n;
ll fun(int pos)
{
    if(pos==n-1)
        return 0;
    if(pos==n)
        return inf;
    if(dp[pos]!=-1)
        return dp[pos];
    ll ans=INT_MAX;
    ans=min(ans,abs(h[pos]-h[pos+1])+fun(pos+1));
    ans=min(ans,abs(h[pos]-h[pos+2])+fun(pos+2));
    return dp[pos]=ans;
}
int main()
{
//    READ;
    sf(n);
    for(int i=0;i<n;i++)
    {
        sf(h[i]);
    }
    mem(dp,-1);
    cout<<fun(0)<<endl;
    return 0;
}


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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int i = Math.min(a, b);
    while (true) {
      if (a % i == 0 && b % i == 0) k--;
      if (k == 0) break;
      i--;
    }
    System.out.println(i);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
using namespace std;

int sx, sy, tx, ty;
int main()
{
    int i;
    cin >> sx >> sy >> tx >> ty;
    for(i=0; i<ty-sy; i++) printf("U");
    for(i=0; i<tx-sx; i++) printf("R");
    for(i=0; i<ty-sy; i++) printf("D");
    for(i=0; i<tx-sx; i++) printf("L");
    printf("L");
    for(i=0; i<=ty-sy; i++) printf("U");
    for(i=0; i<=tx-sx; i++) printf("R");
    printf("D");
    printf("R");
    for(i=0; i<=ty-sy; i++) printf("D");
    for(i=0; i<=tx-sx; i++) printf("L");
    printf("U");
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n = 5;
    vector<int> A(n);

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    
    vector<int> ord(n, 0);
    iota(ord.begin(), ord.end(), 0);

    int res = 1 << 24;

    auto calc = [&](vector<int>& X) {
        int res = 0;
        for (auto x : X){
            res = (res + 10 - 1) / 10 * 10;
            res += A[x];
        }
        return res;
    };

    do {
        res = min(res, calc(ord));

    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << "\n";



    return 0;
}

Measured memory_bytes: 256
using System;
//using System.Collections;
//using System.Collections.Generic;
using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      int sankaku = 0;
      int chokkaku = 0;
      int eikaku = 0;
      int donkaku = 0;

      while (true)
      {
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(a);

        if (a[0] + a[1] > a[2])
        {
          sankaku++;
          if (a[2] * a[2] == a[0] * a[0] + a[1] * a[1]) chokkaku++;
          else if (a[2] * a[2] > a[0] * a[0] + a[1] * a[1]) donkaku++;
          else eikaku++;

        }
        else
        {
          Console.WriteLine("{0} {1} {2} {3}", sankaku, chokkaku, eikaku, donkaku);
          break;
        }
      }
    }
  }
}


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

#define ll long long
#define MAXN 3005

using namespace std;

ll dp[MAXN][MAXN];

ll sum(ll pre[], int l, int r) {

    return pre[r] - (l ? pre[l - 1] : 0);
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    ll a[n], pre[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        pre[i] = (i ? pre[i - 1] : 0) + a[i];
    }

    for(int len = 0; len < n; len++) {
        for(int l = 0; l < n - len; l++) {
            int r = l + len;
            
            if(l == r) {
                dp[l][r] = a[l];
                continue;
            }

            dp[l][r] = sum(pre, l, r) - min(dp[l + 1][r], dp[l][r - 1]);
        }
    }

    cout << 2 * dp[0][n - 1] - pre[n - 1] << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    w %= 2;
    G[u].emplace_back(make_pair(v, w));
    G[v].emplace_back(make_pair(u, w));
  }

  vector<int> color(N, -1);
  color[0] = 0;

  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));

  while (!que.empty()) {
    auto q = que.front();
    que.pop();

    int u = q.first, w = q.second;
    color[u] = w;
    for (auto p : G[q.first]) {
      int v = p.first;
      if (color[v] != -1) continue;
      que.push(make_pair(v, (w + p.second) % 2));
    }
  }

  for (int i = 0; i < N; i++) {
    cout << color[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x==1)
    {
        if(y==1)
            cout<<300000+300000+400000<<endl;
        else if(y==2)
            cout<<300000+200000<<endl;
        else if(y==3)
            cout<<300000+100000<<endl;
        else
            cout<<300000<<endl;
    }
    else if(x==2)
    {
        if(y==1)
            cout<<200000+300000<<endl;
        else if(y==2)
            cout<<200000+200000<<endl;
        else if(y==3)
            cout<<200000+100000<<endl;
        else
            cout<<200000<<endl;
    }
    else if(x==3)
    {
        if(y==1)
            cout<<100000+300000<<endl;
        else if(y==2)
            cout<<100000+200000<<endl;
        else if(y==3)
            cout<<100000+100000<<endl;
        else
            cout<<100000<<endl;
    }
    else
    {
        if(y==1)
            cout<<300000<<endl;
        else if(y==2)
            cout<<200000<<endl;
        else if(y==3)
            cout<<100000<<endl;
        else
            cout<<0<<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 rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  string S, T = "";
  cin >> S;
  
  rep(i, S.size()) T += "x";
  
  cout << T << endl;
}

Measured memory_bytes: 3644
N,A,B= map(int,raw_input().split())
h=[input() for _ in range(N)]

high=max(h)
low=1

def enough(T):
	cnt=0
	for i in h:
		i-=T*B
		if i>0:
			if i%(A-B)==0:
				cnt+=i/(A-B)
			else:
				cnt+=i/(A-B)+1
	if cnt<=T:
		return True
	else:
		return False

ans=0
while low<=high:
	c= (low + high) / 2
	if enough(c):
		high=c-1
		ans=c
	else:
		low=c+1


print ans



Measured memory_bytes: 8964
function Main(input) {
  var inputs = input.split(" ");
  var a = parseInt(inputs[0], 10);
  var b = parseInt(inputs[1], 10);
  var cnt = 0;
  for ( a; a <= b; a++) {
    if (Math.floor(a / 10000) === a % 10 && Math.floor(a / 1000) % 10 === Math.floor(a / 10) % 10) {
      cnt++;
    }
  }
  console.log(cnt);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main(void) {
  int X, N; cin >> X >> N;
  bool p[103];
  memset(p, true, sizeof(p));

  for (int i = 0; i < N; i++) {
    int q; cin >> q;
    p[q+1] = false;
  }

  int d = 0;
  while (0 <= X+1-d || X+1+d <= 102) {
    if (0 <= X+1-d) {
      if (p[X+1-d]) {
        cout << X-d << endl;
        return 0;
      }
    }
    if (X+1+d <= 102) {
      if (p[X+1+d]) {
        cout << X+d << endl;
        return 0;
      }
    }
    d++;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int a,b,max;
    cin >> a >> b;
    
    if(a+b>a*b && a+b>a-b)
        max=a+b;
    else if(a-b>a+b && a-b>a*b)
        max=a-b;
    else if(a*b>a+b && a*b>a-b)
        max=a*b;
    
    cout << max << endl;
    return 0;
    
}


Measured memory_bytes: 256
s=list(input())
t=list(input())
frag=""
n=min(len(s),len(t))
for i in range(n):
  if min(s)<max(t):
    frag="Yes"
    break
  elif min(s)>max(t):
    frag="No"
    break
  else:
    s.pop(s.index(min(s)))
    t.pop(t.index(max(t)))
if frag=="":
  if len(t)>0:
    frag="Yes"
  else:
    frag='No'
print(frag)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string c1, c2;
    cin >> c1 >> c2;

    bool f = 1;
    for(int i = 0; i < 3; ++i){
        if(c1.at(i) != c2.at(2-i))f = 0;
    }

    if(f)cout << "YES" << endl;
    else cout <<"NO"<< endl;


}

    





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repf(i, a, b) for(ll i = (a); i < (b) ; i++ )
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n,m;
cin >> n>>m;
ll x[n] = {};
rep(i, n){
    cin >> x[i];
}
ll y[m] = {};
rep(i, m){
    cin >> y[i];
}
ll sumx=0;
rep(i,n){
    sumx+=i*x[i]-x[i]*(n-i-1);
    sumx%=mo;
}
ll sumy=0;
rep(i,m){
    sumy+=i*y[i]-y[i]*(m-i-1);
    sumy%=mo;
}

ans=(sumx*sumy)%mo;

cout << ans << endl;
return 0;
}

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


int lcs(char *,char *);

int main(){
  int n,i,j;
  char A[150][1002],B[150][1002];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",A[i]);
    scanf("%s",B[i]);
  }
  for(i=0;i<n;i++){
    printf("%d\n",lcs(A[i],B[i]));
  }
  /*for(i=0;i<n;i++){
    printf("%s\n%s\n",A[i],B[i]);
  }
  */
  return 0;
}

int lcs(char *a,char *b){
  int max=0,R[1001][1001];
  int i,j,n,m;
  n=strlen(a);
  m=strlen(b);
  //printf("\n%s %s\n",a,b);
  /*for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      printf("%c %c   ",a[i-1],b[j-1]);
    }
    printf("\n");
  }
  */
  //a=' '+a;
  //b=' '+b;
  for(i=0;i<=n;i++)
    R[i][0]=0;
  for(j=0;j<=m;j++)
    R[0][j]=0;
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      if(a[i-1]==b[j-1]){
	//printf("444%c %c\n",a[i-1],b[j-1]);
	R[i][j]=R[i-1][j-1]+1;
      }else{
	if(R[i-1][j]>R[i][j-1])
	  R[i][j]=R[i-1][j];
	else R[i][j]=R[i][j-1];
      }
      if(max<R[i][j])
	max=R[i][j];
    }
  }
  return max;
}

  



Measured memory_bytes: 5680
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int iter=0;
  ll N,K;
  cin>>N>>K;
  int dp[110][111000];
  int sdp[111000];
  ll num[111000];
  for(int i=1; i<=N;){
    int j=N/i;
    if(i<=j) num[iter++]=1,++i;
    else num[iter++]=N/j-i+1,i=N/j+1;
  }
  
  memset(dp, 0, sizeof(dp));
  dp[0][0]=1;
  for(int k=0; k<K; ++k){
    memset(sdp, 0, sizeof(sdp));
    for(int j=0; j<=iter; ++j) sdp[j+1]=(sdp[j]+dp[k][j])%MOD;
    for(int j=0; j<iter; ++j) dp[k+1][j]=sdp[iter-j]*num[j]%MOD;
  }
  
  ll res=0;
  for(int j=0; j<=iter; ++j) res=(res+dp[K][j])%MOD;
  if(res<0) res+=MOD;
  co(res);
  return 0;
}

Measured memory_bytes: 52224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll bdp[n+10],wdp[n+10];
    wdp[0]=0;
    bdp[0]=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='#'){
            bdp[i+1]=bdp[i]+1;
            wdp[i+1]=wdp[i];
        }
        else {
            bdp[i+1]=bdp[i];
            wdp[i+1]=wdp[i]+1;
        }
    }
    ll ans=MOD;
    ll num=wdp[n];
    for(ll i=0;i<=n;i++){
        ll x=bdp[i],y=num-wdp[i];
        ans=min(ans,x+y);
    }
    cout << ans << endl;
}

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

using namespace std;
int n;
const int maxn=105;
int b[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%d",&b[i]);
    int ans=b[1]+b[n-1];
    for(int i=1;i<n;i++)
    {
        ans+=min(b[i-1],b[i]);
    }
    printf("%d",ans);
    return 0;
}


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

using namespace std;

const int mod = 1000000007;

std::map<long long, int> prime_factor(long long n) {
  std::map<long long, int> res;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) { res[n] = 1; }
  return res;
}

long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) { res = res * x % mod; }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

long long mod_inverse(long long x, long long mod) {
  return mod_pow(x, mod-2, mod);
}

long long mod_comb(long long n, long long k, long long mod) {
  long long numer = 1, denom = 1;
  for (long long i = 0; i < k; i++) {
    numer = numer * ((n-i) % mod) % mod;
    denom = denom * ((i+1) % mod) % mod;
  }
  return numer * mod_inverse(denom, mod) % mod;
}

int main() {
  long long n, m;
  cin >> n >> m;
  std::map<long long, int> mp = prime_factor(m);

  long long ans = 1;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    long long e = it->second;
    ans = (ans * mod_comb(n+e-1, e, mod)) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char argv[]){
    int A, B = 0;

    scanf("%d%d", &A, &B);

    if(A+B >= A-B && A+B >= A*B){
        printf("%d\n", A+B);
    }
    if(A-B > A+B && A-B > A*B){
        printf("%d\n", A-B);
    }
    if(A*B > A+B && A*B > A-B){
        printf("%d\n", A*B);
    }
    
    return 0;
}

Measured memory_bytes: 128