akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15


int main() {
	double a, b;
	cin >> a>> b;
	int res = (a+b)/2;
	if((a+b)/2 - res >= 0.5){
		cout << res + 1 << endl;
	}
	else{
		cout << res << endl;
	}
		
	return 0;
}






Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int week,i;
	int debt=100000;
	scanf("%d",&week);
	for(i=0;i<week;i++)
	{
		debt*=1.05;
		if(debt%1000>0)
		{
			debt/=1000;
			debt=(debt+1)*1000;
		}
	}
	printf("%d\n",debt);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
void trans(int& x, int y)
{
	x += y;
	x -= x >= MOD ? MOD : 0;
}

int n, a[605];
int *tp, suf[605];
int dp[605][305][305];

int main()
{
	scanf("%d", &n);
	rep1(i, 2 * n) scanf("%d", &a[i]);
	
	tp = new int[605];
	memset(tp, 0, sizeof(int) * 605);
	rep(i, n) {
		int tot = (a[i * 2 + 1] == -1) + (a[i * 2 + 2] == -1);
		if(tot == 0) tp[a[i * 2 + 1]] = tp[a[i * 2 + 2]] = -1;
		else if(tot == 1) tp[max(a[i * 2 + 1], a[i * 2 + 2])] = 1;
	}
	
	int *kk = new int[605], j = 0;
	memset(kk, 0, sizeof(int) * 605);
	int cn = n * 2;
	rep1(i, 2 * n) if(tp[i] != -1) kk[++ j] = tp[i];
	else cn --;
	n = cn / 2;
	tp = kk;
	
	for(int i = 2 * n; i >= 1; i --) suf[i] = suf[i + 1] + (tp[i] == 1); 
	
	dp[0][0][0] = 1;
	rep1(i, 2 * n) {
		if(tp[i] == -1) {
			//copy
			for(int j = 0; j <= n; j ++) for(int k = 0; k <= n; k ++)
			dp[i][j][k] = dp[i - 1][j][k];
		} else if(tp[i] == 0) {
			//open tpA
			for(int j = 0; j <= n; j ++) for(int k = 0; k <= n; k ++)
			trans(dp[i][j + 1][k], 1LL * dp[i - 1][j][k] * (n - (i + j + k) / 2 - suf[i] + k) % MOD);
			//open tpB
			for(int j = 0; j <= n; j ++) for(int k = 0; k <= n; k ++)
			trans(dp[i][j][k + 1], dp[i - 1][j][k]);
			//close tpA
			rep1(j, n) for(int k = 0; k <= n; k ++)
			trans(dp[i][j - 1][k], dp[i - 1][j][k]);
		} else if(tp[i] == 1) {
			//open tpA
			for(int j = 0; j <= n; j ++) for(int k = 0; k <= n; k ++)
			trans(dp[i][j + 1][k], dp[i - 1][j][k]);
			//close tpB
			for(int j = 0; j <= n; j ++) rep1(k, n)
			trans(dp[i][j][k - 1], 1LL * dp[i - 1][j][k] * k % MOD);
		}
	}
	
	printf("%d\n", dp[2 * n][0][0]);
	return 0;
}

Measured memory_bytes: 219008
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 

void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=1000000;i++)
    {
        float p=(float)i*1.08;
        if(floor(p)==n)
        {
            cout<<i;
            return;
        }
    }
    cout<<":(";
}
 
int main()
{
 
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

ll C[51][51];

void comb_table(int N){
  for(int i=0;i<=N;i++){
    for(int j=0;j<=i;j++){
      if(j==0||j==i){
        C[i][j]=1LL;
      }else{
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  }
}


int main(){
  int n,a,b;
  cin>>n>>a>>b;
  comb_table(n);
  vector<ll> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.rbegin(),v.rend());
  double ans1=0.0;
  for(int i=0;i<a;i++){
    ans1+=v[i];
  }
  ans1/=a;
  ll ans2=0;
  int num=0,pos=0;
  for(int i=0;i<n;i++){
    if(v[i]==v[a-1]){
      num++;
      if(i<a) pos++;
    }
  }
  if(pos==a){
    for(int i=a;i<=b;i++) ans2+=C[num][i];
  }else{
    ans2+=C[num][pos];
  }
  printf("%.10f\n",ans1);
  printf("%lld\n",ans2);
  return 0;
}

Measured memory_bytes: 256
// B - Theater

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

int N;
int solve();

int main() {
  // ここにプログラムを追記
  cin >> N;
  solve();
}


int solve(){
  int num = N;
  int result =0;
  int buf;
  for(; num!=0;){
    result += num %10;
    num /= 10;
  }
  if(N % result ==0){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100100;
int i,j,k,n,ch,ff,x,y,En;
int f[N],h[N];
struct edge { int s,n;} E[N<<1];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int F) {
	int n1=0;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) {
		dfs(E[k].s,x);
		if (f[E[k].s]==-1) f[x]=-1;
		if (f[E[k].s]==1) n1++;
	}
	if (f[x]==-1) return;
	if (n1>1) f[x]=-1;
	else f[x]=n1^1;
}
int main() {
	R(n);
	for (i=1;i<n;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	dfs(1,0);
	if (f[1]==0) puts("Second");
	else puts("First");
}

Measured memory_bytes: 2560
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 1e5 + 10;
vector<int> g[N], G[N];
int n, m, u[N], v[N], out[N];
bool vis[N], vv[N];
vector<pii> vc;
void dfs(int x) {
    vis[x] = true;
    for (int id : g[x]) {
        int to = x^u[id]^v[id];
        if(!vis[to]) {
            G[x].pb(to);
            vv[id] = true;
            dfs(to);
        }
    }
}
void DFS(int u) {
    for (int v : G[u]) {
        DFS(v);
        if(out[v]%2) vc.pb(v, u), out[v]++;
        else vc.pb(u, v), out[u]++;
    }
}
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        scanf("%d %d", &u[i], &v[i]);
        g[u[i]].pb(i);
        g[v[i]].pb(i);
    }
    if(m%2) return 0*puts("-1");
    dfs(1);
    for (int i = 1; i <= m; ++i) if(!vv[i]) vc.pb(u[i], v[i]), out[u[i]]++;
    DFS(1);
    for (auto p : vc) printf("%d %d\n", get<0>(p), get<1>(p));
    return 0;
}


Measured memory_bytes: 20856
N = gets.chomp.to_i
As = gets.chomp.split.map(&:to_i)

cnt = 0
loop{
    As.each_with_index{ |x, i|
        if x % 2 == 0 then
            As[i] = As[i] / 2
        else
            puts cnt
            exit
        end
    }
    cnt += 1
}


Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d", &a,&b);
  if(a<b){
    printf("a < b\n");
      }else if(a>b){
    printf("a > b\n");
      }else {
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,q;
    cin>>n>>q;
    vector<pair<int,pair<int,int>>> v;
    for(int i=0;i<n;i++){
        int s,t,x;
        cin>>s>>t>>x;
        v.push_back({s-x,{1,x}});
        v.push_back({t-x,{-1,x}});
    }
    sort(v.begin(),v.end());
    int d[q];
    for(int i=0;i<q;i++){
        cin>>d[i];
    }
    int ans[q];
    memset(ans,-1,sizeof(ans));
    multiset<int> eve;
    int t=0;
    for(int i=0;i<q;i++){
        while(t<2*n&&v[t].first<=d[i]){
            if(v[t].second.first==1){
                eve.insert(v[t].second.second);
            }
            else{
                auto it=eve.lower_bound(v[t].second.second);
                eve.erase(it);
            }
            ++t;
        }
        if(eve.size()){
            ans[i]=*eve.begin();
        }
    }
    for(int i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 16876
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>V(N), C(N);
    for (int i = 0; i < N; i++)cin >> V[i];
    for (int i = 0; i < N; i++)cin >> C[i];

    int ans = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        int X = 0, Y = 0;
        for (int i = 0; i < N; i++) {
            if ((bit >> i) & 1) {
                X += V[i];
                Y += C[i];
            }
        }
        ans = max(ans, X - Y);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int N, u, v;
	cin >> N >> u >> v;
	u--; v--;
	Graph G(N);
	REP(i, N-1) {
		int a, b;
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	

	//BFS;
	vector<int> u_dist(N, -1); //頂点u(高橋君)からの距離;
	vector<int> v_dist(N, -1); //頂点v(青木君)からの距離;
	queue<int> bfs_queue; //BFS用キュー
	
	//高橋君からの距離BFS;
	bfs_queue.push(u);
	u_dist[u] = 0;
	
	while (!bfs_queue.empty()) {
		int this_v = bfs_queue.front();
		//cout << "this v is:" << this_v << endl;
		bfs_queue.pop();
		for (auto x : G[this_v]) {
			if (!(u_dist[x] == -1)) continue;
			else {
				u_dist[x] = u_dist[this_v]+1;
				bfs_queue.push(x);
			}
		}
	}
	
	//青木君からの距離BFS;
	bfs_queue.push(v);
	v_dist[v] = 0;

	while (!bfs_queue.empty()) {
		int this_v = bfs_queue.front();
		//cout << "this v is:" << this_v << endl;
		bfs_queue.pop();
		for (auto x : G[this_v]) {
			if (!(v_dist[x] == -1)) continue;
			else {
				v_dist[x] = v_dist[this_v] + 1;
				bfs_queue.push(x);
			}
		}
	}

	int max_dist_from_v=-1;
	//高橋君からの方が距離が近く、青木君からの距離が最も遠い頂点を求める
	REP(i, N) {
		if (u_dist[i]<v_dist[i] && v_dist[i]>max_dist_from_v) max_dist_from_v = v_dist[i];
	}
	cout << max_dist_from_v - 1 << endl;



	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 6656
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 500 + 7;

char mp[MAX_N][MAX_N];
char a[MAX_N][MAX_N] , b[MAX_N][MAX_N];

int main() {
  int n, m;
  RI(n, m);
  REP(i , n) {
    RI(mp[i]);
    REP(j , m) a[i][j] = b[i][j] = mp[i][j];
    a[i][0] = '#' , b[i][m - 1] = '#';
  }
  REP(i , n) {
    if(~i&1) REP1(j , 1 , m - 2) a[i][j] = '#';
    else REP1(j , 1 , m - 2) b[i][j] = '#';
  }
  REP(i , n) {
    REP(j , m) putchar(a[i][j]);
    PL();
  }
  PL();
  REP(i , n) {
    REP(j , m) putchar(b[i][j]);
    PL();
  }
  return 0;
}


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

namespace ABC063A___Restricted
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int sum = 0;

            foreach (var value in input)
            {
                sum += int.Parse(value);
            }

            string result = sum.ToString();

            if (sum >= 10)
            {
                result = "error";
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 11092
#include <iomanip>
#include <string>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	long long int a, b, c, d;
	if (s[0] == '0')a = 0;
	if (s[0] == '1')a = 1;
	if (s[0] == '2')a = 2;
	if (s[0] == '3')a = 3;
	if (s[0] == '4')a = 4;
	if (s[0] == '5')a = 5;
	if (s[0] == '6')a = 6;
	if (s[0] == '7')a = 7;
	if (s[0] == '8')a = 8;
	if (s[0] == '9')a = 9;
	if (s[1] == '0')b = 0;
	if (s[1] == '1')b = 1;
	if (s[1] == '2')b = 2;
	if (s[1] == '3')b = 3;
	if (s[1] == '4')b = 4;
	if (s[1] == '5')b = 5;
	if (s[1] == '6')b = 6;
	if (s[1] == '7')b = 7;
	if (s[1] == '8')b = 8;
	if (s[1] == '9')b = 9;
	if (s[2] == '0')c = 0;
	if (s[2] == '1')c = 1;
	if (s[2] == '2')c = 2;
	if (s[2] == '3')c = 3;
	if (s[2] == '4')c = 4;
	if (s[2] == '5')c = 5;
	if (s[2] == '6')c = 6;
	if (s[2] == '7')c = 7;
	if (s[2] == '8')c = 8;
	if (s[2] == '9')c = 9;
	if (s[3] == '0')d = 0;
	if (s[3] == '1')d = 1;
	if (s[3] == '2')d = 2;
	if (s[3] == '3')d = 3;
	if (s[3] == '4')d = 4;
	if (s[3] == '5')d = 5;
	if (s[3] == '6')d = 6;
	if (s[3] == '7')d = 7;
	if (s[3] == '8')d = 8;
	if (s[3] == '9')d = 9;
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
		return 0;
	}
	if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
		return 0;
	}
	if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
		return 0;
	}

	return 0;
}	

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

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

    vector<ll> a,b, c;
    for(int i = 1; i <= 9; i++) {
        a.push_back(i);
        c.push_back(i);
    }


    while(1) {
        swap(b, c);
        c.clear();

        for (ll x : b) {
            for (int i = -1; i <= 1; i++) {
                int d = x % 10 + i;
                if (d < 0 || 9 < d) continue;
                ll e = x * 10 + d;
                a.push_back(e);
                c.push_back(e);
            } 
        }

        if (k <= a.size()) {
            cout << a[k - 1] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            string s;
            cin>>s;
            if(s=="SUN")
                cout<<7<<endl;
            else if(s=="MON")
                cout<<"6"<<endl;
            else if(s=="TUE")
                cout<<"5"<<endl;
            else if(s=="WED")
                cout<<4<<endl;
            else if(s=="THU")
                cout<<3<<endl;
            else if(s=="FRI")
                cout<<2<<endl;
            else
                cout<<1<<endl;
        }
        return 0;
    }


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

constexpr int MAXA   = 350;
constexpr int MAXB   = 700;
constexpr int OFFSET = 350;

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

int main()
{
    int n, x, y;
    std::cin >> n >> x >> y;
    
    std::vector<int> a(n), b(n), c(n), d(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    
    std::vector<std::vector<int>> dp(MAXA, std::vector<int>(MAXB, -1));
    dp[x][y + OFFSET] = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < MAXA; j++) {
            for (int k = 0; k < MAXB; k++) {
                if (dp[j][k] == -1) { continue; }

                if (j - a[i] >= 0 && k + b[i] < MAXB) {
                    chmax(dp[j - a[i]][k + b[i]], dp[j][k]);
                }

                if (k - c[i] >= 0) {
                    chmax(dp[j][k - c[i]], dp[j][k] + d[i]);
                }
            }
        }
    }

    int ret = 0;
    for (int i = 0; i < MAXA; i++) {
        for (int j = OFFSET; j < MAXB; j++) {
            chmax(ret, dp[i][j]);
        }
    }
    
    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 3948
#include<stdio.h>
#include<string.h>
int main(){
    int k;
    char s[110];
    scanf("%d\n",&k);
    scanf("%s",s);
  // for(int i=0;s[i]!='\0';i++)
   //scanf("%c",s[i]);
    if(strlen(s)<=k){
        printf("%s",s);
        return 0;
    }
  else if(strlen(s)>k){
    scanf("%d",&k);
    scanf("%s",s);
    s[k]='\0';
    printf("%s...",s);
    return 0;
  }
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;

int main() {
	int n, m;
	string message = "IMPOSSIBLE";
	cin >> n >> m;
	if ((n + m) % 2 == 0) {
		cout << (n + m) / 2 << endl;
	} else {
		cout << message << endl;
	}
}

Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

const int mod = 1e9+7;

il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if( b&1 ){
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }

il ll comp(ll n,ll m){
	ll up=1, down=1;
	rep(i,1,m){
		up = (up*(n-i+1))%mod;
		down = (down*i)%mod;
	}
	return up*inv(down)%mod;
}

int main(){
	int n=ci();
	int a=ci(), b=ci();
	ll ans=(qpow(2,n)-comp(n,a)-comp(n,b)-1)%mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int take[8];
int group_bits[3][1<<8];
int groups[3];
int n;

int saiki(int ans, int group, int all_bit, int now_bit) {
	//cout << ans << "," << group << "," << all_bit << "," << now_bit << endl;
	if(group>=3) return 0;
	for(int i = 0; i < n; i++) {
		int new_bit = 1<<i;
		if((all_bit&new_bit)==0) {
			/*
			{
				int ret = saiki(ans,group,all_bit|new_bit,now_bit|new_bit);
				ans = min(ans,ret);
			}
			{
				int ret = saiki(ans,group+1,all_bit|new_bit,0);
				ans = min(ans,ret+group_bits[group][now_bit]);
			}
			*/
			ans = min(ans,saiki(ans,group,all_bit|new_bit,now_bit|new_bit));
			ans = min(ans,saiki(ans,group+1,all_bit|new_bit,0)+group_bits[group][now_bit|new_bit]);
		}
	}
	return ans;
}

int calc(int bits, int mokuhyou) {
	int bit_count = 0;
	int sum_len = 0;
	for(int i = 0; i < 8; i++) {
		if((bits&(1<<i))!=0) {
			bit_count++;
			sum_len += take[i];
		}
	}
	int cost = 0;
	cost += (bit_count-1)*10;
	cost += abs(mokuhyou-sum_len);
	return cost;
}

int main() {
	cin >> n;
	for(int j = 0; j < 3; j++) {
		cin >> groups[j];
	}
	for(int i = 0; i < n; i++) {
		cin >> take[i];
	}
	for(int j = 0; j < 3; j++) {
		group_bits[j][0] = 1<<25;
	}
	for(int i = 1; i < (1<<n); i++) {
		for(int j = 0; j < 3; j++) {
			group_bits[j][i] = calc(i,groups[j]);
		}
	}

	int ans = saiki(1<<25,0,0,0);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int p=arr[n/2];
	int q=arr[n/2-1];
	if(p==q)
		cout<<0<<endl;
	else cout<<p-q<<endl;}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, K;cin >> n >> K;
    vector<int> x(n), y(n);
    vector<int> xs, ys;
    map<int, int> mxm, mym;
    map<int, int> mx, my;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    xs = x;ys = y;
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    int xx = 0;
    int yy = 0;
    mx[xs[0]] = 0;
    my[ys[0]] = 0;
    for(int i=1;i<n;i++){
        if(xs[i] != xs[i-1]) xx++;
        mx[xs[i]] = xx;
        if(ys[i] != ys[i-1]) yy++;
        my[ys[i]] = yy;
    }
    bool c[50][50];
    memset(c, false, sizeof(c));
    for(int i=0;i<n;i++){
        c[my[y[i]]][mx[x[i]]] = 1;
    }
    int h = yy + 1;
    int w = xx + 1;
    int sum[51][51];
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            sum[i][j] = 0;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            sum[i+1][j+1] = c[i][j] + sum[i][j+1] + sum[i+1][j] - sum[i][j];
        }
    }
    vector<LL> ans;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<=i;k++){
                for(int l=0;l<=j;l++){
                    if(sum[i+1][j+1] - sum[i+1][l] - sum[k][j+1] + sum[k][l] >= K){
                        int yi = ys[i];
                        int xj = xs[j];
                        int yk = ys[k];
                        int xl = xs[l];
                        //cout << xi << " " << yj << " " << xk << " " << yl << endl;
                        ans.push_back(LL(xj-xl)*LL(yi-yk));
                    }
                }
            }
        }
    }
    cout << *min_element(ans.begin(), ans.end()) << endl;
    return 0;
}


Measured memory_bytes: 17000
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	map<char, char> m;
	m['A'] = 'T';
	m['C'] = 'G';
	m['G'] = 'C';
	m['T'] = 'A';
	char b;
	cin >> b;
	cout << m[b] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

int testcase_ends() {
  int N;
  scanf("%d", &N);

  if (N == 0)
    return 1;

  std::map<int, std::pair<int, int>> g;
  g[0] = std::make_pair(0, 0);
  for (int i=1; i<N; ++i) {
    int n, d;
    scanf("%d %d", &n, &d);

    std::pair<int, int> p=g[n];
    switch (d) {
    case 0:
      --p.second;
      break;

    case 1:
      ++p.first;
      break;

    case 2:
      ++p.second;
      break;

    case 3:
      --p.first;
      break;
    }

    g[i] = p;
  }

  int max_i=-2000, max_j=-2000;
  int min_i=2000, min_j=2000;

  for (int i=0; i<N; ++i) {
    std::pair<int, int> p=g[i];

    max_i = std::max(max_i, p.first);
    max_j = std::max(max_j, p.second);

    min_i = std::min(min_i, p.first);
    min_j = std::min(min_j, p.second);
  }

  printf("%d %d\n", max_j-min_j+1, max_i-min_i+1);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

class Main {
	static final long M = 1000000007;

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

		int[] cs = new int[3];
		long[] dp = new long[n + 1];
		dp[0] = 1;

		for (int i = 0; i < n; i++) {
			int t = 0;
			for (int j = 0; j < 3; j++) {
				if (cs[j] == a[i]) t++;
			}

			for (int j = 0; j < 3; j++) {
				if (cs[j] == a[i]) {
					cs[j]++;
					break;
				}
			}

			dp[i + 1] = (dp[i] * t) % M;
		}

		System.out.println(dp[n]);
	}
}


Measured memory_bytes: 50384
#include <iostream>
using namespace std;
int main()
{
long long n;
cin>>n;
long long times=0;//桁数
long long sum=26;
int a[100];
while(n/sum>0)
{
a[times]=n%sum;
if(a[times]==0)a[times]+=26;
n=(n-a[times])/26;
if(n>0)times++;

}
if(n>0)a[times]=n;
char b[50];
b[0]='a';
b[1]='b';
b[2]='c';
b[3]='d';
b[4]='e';
b[5]='f';
b[6]='g';
b[7]='h';
b[8]='i';
b[9]='j';
b[10]='k';
b[11]='l';
b[12]='m';
b[13]='n';
b[14]='o';
b[15]='p';
b[16]='q';
b[17]='r';
b[18]='s';
b[19]='t';
b[20]='u';
b[21]='v';
b[22]='w';
b[23]='x';
b[24]='y';
b[25]='z';


for(int i=times;i>=0;i--)
{

cout <<b[a[i]-1];    
}

}

Measured memory_bytes: 3604
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)
lst = [list(input().rstrip()) for _ in range(3)]
abc = ["a", "b", "c"]
turn = lst[0].pop(0)

while True:
    if lst[abc.index(turn)] == []:
        print(turn.upper())
        break
    turn = lst[abc.index(turn)].pop(0)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define N 2000
int main(void){
	int i,j,k,len,z;
	char str[N],S[N];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		len=strlen(str)-1; j=0;
		for(i=0;i<len;i++){
			if(str[i]=='@'){
				z=(str[i+1]-'\0')%48;
				for(k=0;k<z;k++)
					S[j++]=str[i+2];
				i+=2;
			}					
			else
				S[j++]=str[i];	
		}
		for(i=0;i<j;i++)
			printf("%c",S[i]);
		printf("\n");		
	}
	return 0;
}

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

int main(){
  vector<char>vec(3);
  for (int i = 0; i < 3; i++){
    cin >> vec.at(i);
    if (vec.at(i) == '1' ){
      vec.at(i) = '9';
    }
    else
      vec.at(i) = '1';
    cout << vec.at(i) ;
  }
}
 

Measured memory_bytes: 256
//package Qa
import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = {readLine()!!.toInt()}
private val readLong: ()->Long = {readLine()!!.toLong()}
private val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
private val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
private val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


fun solveA(S: String): Long {
    val N = S.length

    var res = 0L
    for (p in 0 until (0b01 shl N)) {
        var ptn = p
        if ((ptn shr (N-1)) and 0b01 == 0) continue

        var sum = 0L
        var term = 0L
        for (i in 0 until N) {
            term += (S[i] - '0').toLong()
            if (ptn and 0b01 == 1) {
                sum += term
                term = 0L
            } else {
                term *= 10L
            }
            ptn = ptn shr 1
        }
        if (sum == 0L) sum += term
        res += sum
    }

    return res
}


fun main(args: Array<String>) {
    val S = readString()

    val ans = solveA(S)

    println(ans)
}


Measured memory_bytes: 33784
import sys

lucas_nums = [None] * 100
lucas_nums[0], lucas_nums[1] = 2, 1
for i in range(2, 100):
    lucas_nums[i] = lucas_nums[i-2] + lucas_nums[i-1]

def main():
    n = int(sys.stdin.readline().rstrip())
    print(lucas_nums[n])

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {

  long k,mod = 0;
  scanf("%ld", &k);
  for (long i = 1; i <= k; i++) {
    mod = mod*10+7;
    mod %= k;
    if (mod == 0) {
      printf("%ld\n", i);
      return 0;
    }
  }
  printf("-1\n");

  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  double n,a[200];
  cin >> n;
  double sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += 1/a[i];
  }

  cout << fixed << setprecision(10) << 1/sum << endl;  
}

Measured memory_bytes: 3736
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
P = [p-1 for p in P]

# 1,ループを検出
# 2,ループごとの最大値の計算
# 3,結果の出力

visited = set() #探索済みのものを格納する

ans = 0
for i in range(N):
  if i in visited: #探索済みの場合
    continue
  
  # 1,ループを検出
  j = i
  C_tmp = [] #たどる順番にコストを格納
  while j not in visited:
    C_tmp.append(C[j])
    visited.add(j)
    j = P[j] #次のjへ
    
  # 2,ループごとの最大値の計算
  N_tmp = len(C_tmp) #ループ長さ
  tmp = 0 #何も足さないときは0(これが最大になる可能性もあるので注意)
  
  # N_tmp < K の場合には注意が必要
  # C_tmpの全要素の和が正になるときには、できるだけループを多く回したい
  # C_tmpの全要素の和が負になるときには、１周以内に収めたい
  loop_sum = max(0, sum(C_tmp)) #負の場合にはなかったことにすればよい
  #ただし、これらのうち番号が負になるものや、範囲外のものは当然のぞく
  
  #調べたいのは、
  #  sum(C)が正のとき  操作の回数が K-N_tmp+1 から K まで
  #  sum(C)が負のとき  操作の回数が 0 から N_tmp-1 まで
  #　  例1：N_tmp = 5, K = 8, ループ１周の和が正の時
  #       0 　 1 　 2 　 3 　 4 ◯ （「上段」）
  #       5 ◯ 6 ◯ 7 ◯ 8 ◯   　 （「下段」）
  #　  例2：N_tmp = 5, K = 8, ループ１周の和が負の時
  #       0 ◯ 1 ◯ 2 ◯ 3 ◯ 4 ◯ 
  #       5 　 6 　 7 　 8 　
  #    ただし、ループを１周ごとになかったことにするなら、結局次のように考えて良い
  #       0 　 1 　 2 　 3 　 4 ◯ （「上段」）
  #       5 ◯ 6 ◯ 7 ◯ 8 ◯   　 （「下段」）
  #　  例3：N_tmp = 5, K = 3, ループ１周の和が正の時
  #       0 ◯ 1 ◯ 2 ◯ 3 ◯   　 （「上段」）
  
  #ひとまず、回すことができる最大のループ回数を計算し、その和を求めておく
  base = loop_sum * (K // N_tmp)
  
  #はみ出した部分について和を求める。（「下段」については、loop_sumを一回引くことで対処）
  # (操作回数) % N_tmp を lとして、連続したl個の要素の和を調べる
  ans = max(ans, base) # l = 0 のとき
  behind = False #下段を調べているときにTrueとする
  for l in range(1,min(N_tmp, K+1)): # l > 1 のとき
    if (not behind) and l > K % N_tmp: #下段に移るとき、ループを１週戻す
      behind = True
      base -= loop_sum
    summ = sum(C_tmp[0:l]) + base
    for j in range(N_tmp):
      ans = max(ans, summ) #最大値の更新
      summ += C_tmp[(j+l)%N_tmp] - C_tmp[j] #始点を1ずらす
      
      
#3,結果の出力
# K > 1に注意
print(max(C) if max(C) < 0 else ans)


  
    
    

Measured memory_bytes: 75108
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    int d = a-b;

    if(d >= c) Console.WriteLine(0);
    else Console.WriteLine(c-d);
	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(a+b==c+d){
        cout1("Balanced")
    }else if(a+b<c+d){
        cout1("Right")
    }else{
        cout1("Left")
    }
}

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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
int n;
cin>>n;
vector<int> vi(n,0);
REP(i,n-1){
int a;
cin>>a;
a--;
vi[a]++;
}
REP(i,n)
cout<<vi[i]<<endl;
}

Measured memory_bytes: 3940
#include <cstdio>
 
int main() {
    int n;
    scanf("%d", &n);
 
    unsigned long long a;
    unsigned long long allXor[n+1], sum[n+1];
    allXor[0] = sum[0] = 0;
 
    for (int i = 1; i < n + 1; i++) {
        scanf("%llu", &a);
        allXor[i] = allXor[i-1] ^ a;
        sum[i] = sum[i-1] + a;
    }
 
    unsigned long long result = 0;
    int minLeft = 1;
    for (int r = 1; r < n + 1; r++) {
        for (int l = minLeft; l <= r; l++) {
            if ((allXor[r] ^ allXor[l-1]) == (sum[r] - sum[l-1])){
                result += r - l + 1;
                break;
            } else {
                minLeft++;
            }
        }
    }
    printf("%llu\n", result);
 
    return 0;
}

Measured memory_bytes: 3328
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = float('inf')
for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    if l < 0 and r < 0:
        ans = min(ans, max(abs(l), abs(r)))
    elif l <= 0 and r >= 0:
        ans = min(ans, min(abs(l), r)*2 + max(abs(l), r))
    elif l > 0 and r > 0:
        ans = min(ans, max(l, r))
print(ans)

Measured memory_bytes: 14224
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;

ll N, K;

int main(){
	scanf("%lld %lld", &N, &K);
	ll res = (N / K) * (N / K) * (N / K);
	if(K % 2 == 0){
		ll L = N;
		if(L % K > K / 2) L -= L % K - K / 2;
		else if(L % K < K / 2) L -= L % K + K / 2;
		ll num = max(0LL, (L - K / 2) / K + 1);
		res += num * num * num;
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,ac=0;
  cin>>n;
  string s,t;
  cin>>s>>t;
  rep(i,n){
    if(s.substr(i,n-i)==t.substr(0,n-i)){
      ac=n-i;
      break;
    }
  }
  cout<<2*n-ac;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;

ll a[55],b[55];
ll x[55],y[55];
int N,K;
int go(ll xl,ll xh, ll yl, ll yh){
	int cnt=0;
	FORI(0,N){
		if(x[i]>=xl && x[i]<=xh && y[i]>=yl && y[i]<=yh){
			cnt++;
		}
	}
	return cnt;
}

int main() {
	cin>>N>>K;
	FORI(0,N){
		cin>>a[i]>>b[i];
		x[i]=a[i];y[i]=b[i];
	}
	sort(a,a+N);
	sort(b,b+N);
	ll ans=(1LL<<62);//
	for(int i=0;i<(N-1);i++){
		for(int j=i+1;j<N;j++){
			for(int k=0;k<(N-1);k++){
				for(int l=k+1;l<N;l++){
					if(go(a[i],a[j],b[k],b[l])>=K){
						ans=min(ans,((a[j]-a[i])*(b[l]-b[k])));
					}
				}

			}
		}

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




Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VC vector<char>
#define VVI vector<vector<int>>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c.begin(), c.end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b==15){
        cout << "+" << endl;
    }else if(a*b==15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <chrono>
#include <cmath>
using namespace std;


struct cake {
	long long x, y, z;

	bool operator<(const cake &r)const {
		return x + y + z < r.x + r.y + r.z;
	}
};

int main() {
	int N, M; cin >> N >> M;
	vector<cake>cakes[8];
	for (int i = 0; i < N; i++) {
		long long x, y, z; cin >> x >> y >> z;
		cakes[0].push_back(cake({x, y, z}));
		cakes[1].push_back(cake({ -x, y, z }));
		cakes[2].push_back(cake({ x, -y, z }));
		cakes[3].push_back(cake({ x, y, -z }));
		cakes[4].push_back(cake({ -x, -y, z }));
		cakes[5].push_back(cake({ x, -y, -z }));
		cakes[6].push_back(cake({ -x, y, -z }));
		cakes[7].push_back(cake({ -x, -y, -z }));
	}

	long long best_ans = 0;
	for (int i = 0; i < 8; i++) {
		sort(cakes[i].begin(), cakes[i].end());
		reverse(cakes[i].begin(), cakes[i].end());

		long long ans = 0;
		for (int j = 0; j < M; j++) {
			ans += cakes[i][j].x + cakes[i][j].y + cakes[i][j].z;
		}
		best_ans = max(ans, best_ans);
	}
	cout << best_ans << endl;


	return 0;
}


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

int main(){
	int n,l,t;
	cin>>n>>l;
	t=l;
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		t+=x;
		if(x>l) l=x;
	}
	if(l<t-l) cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,k,j,n=1;cin>>k>>a>>b;
  j=k;
  while(k<a){
    n++;
    k=j*n;
  }
  if(k<=b){
    cout<< "OK"<<endl;
  }else{
    cout << "NG"<<endl;
  }
  
}

Measured memory_bytes: 3672
using System;
namespace _2_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a, b;
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);

            if (a > b)
                Console.WriteLine("a > b");

            else if (a < b)
                Console.WriteLine("a < b");

            else if (a == b)
                Console.WriteLine("a == b");



        }
    }
}



Measured memory_bytes: 8804
#include <iostream>
using namespace std;
static const int MAX = 100;

int main()
{
	int N;
	int arr[MAX];
	
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> arr[i];
	}
	for (int i = 0; i < N; i++){
		if (i > 0)
			cout << " ";
		cout << arr[i];

	}
	cout << endl;
	for (int i = 1; i < N; i++){
		int key = arr[i];
		int j = i - 1;
		while (j >= 0 && arr[j] > key){
			arr[j+1] = arr[j];
			j--;
		}
		arr[j+1] = key;
		for (int i = 0; i < N; i++){
			if (i > 0)
				cout << " ";
			cout << arr[i];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
camp_num = gets.to_i
days, remaining_choco = gets.split.map(&:to_i)

a_array = []
camp_num.times do
	a_array << gets.to_i
end

eat_choco = 0
a_array.each do |a|
	eat_choco += (days-1)/a + 1
end

puts eat_choco + remaining_choco



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int a, b;
	cin >> a >> b;
	if(1 != a && 1 != b) {
		cout << 1 << '\n';
	} else if(2 != a && 2 != b) {
		cout << 2 << '\n';
	} else {
		cout << 3 << '\n';
	}
	return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = INF + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int a,b,k;
	cin >> a >> b >> k;
	
	if(a > k)
	{
		a -=k;
		cout << a << " " << b;
	}
	else
	{
		k-=a ;
		a = 0;
		b = max(0LL , b - k  );
		cout << a << " " << b;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    LL cur = 1;
    for(LL i = 0; i < n; ++i){
        if(a[i] == cur) ++cur;
    }
    if(cur == 1){
        cout << -1 << endl;
    }else{
        cout << n - (cur-1) << endl;
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
ll n, k;
vll dp;
vll h;

ll q(ll x){
    if(dp[x]!=-1) return dp[x];
    
    dp[x] = LINF;
    for(ll i=1;x-i>=0 && i<=k;i++){
        dp[x] = min(dp[x],q(x-i)+abs(h[x]-h[x-i]));
    }

    return dp[x];
}

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

    cin >> n >> k;
    vll z(n,0);
    dp = h = z;

    REP(i,n){
        cin >> h[i];
        dp[i] = -1;
    }

    dp[0] = 0;

    ll ans = q(n-1);

    cout << ans <<endl;


    
    return 0;
}



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

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == '?') {
      t[i] = 'D';
    }    
  }
  cout << t << endl;
}

Measured memory_bytes: 3728