akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++)cin>>p[i];
  sort(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<n-1;i++)sum+=p[i];
  sum+=p[n-1]/2;
  cout<<sum;
}


Measured memory_bytes: 256
<?php
define('DEBUG', false);
fscanf(STDIN, '%d %d', $D, $G);
$G /= 100;
$p = $c = $t = [];
$ans = PHP_INT_MAX;
for ($i = 0; $i < $D; $i++) {
    fscanf(STDIN, '%d %d', $p[$i], $c[$i]);
    $c[$i] /= 100;
    $t[$i] = ($i + 1) * $p[$i] + $c[$i];
    if (DEBUG) echo "[" . $i . "] " . $t[$i] . PHP_EOL;
}
$pat = pow(2, $D - 1);
for ($i = 0; $i < $pat; $i++) {
    $bin = str_pad(decbin($i), $D - 1, "0", STR_PAD_LEFT);
    if (DEBUG) echo $bin . PHP_EOL;
    for ($j = 0; $j < $D; $j++) {
        $tra = str_split(substr($bin, 0, $j) . '2' . substr($bin, $j));
        if (DEBUG) echo "tra: " . implode('', $tra) . PHP_EOL;
        $score = 0;
        $solve = 0;
        for ($k = 0; $k < $D; $k++) {
            if ($tra[$k] === "1") {
                if (DEBUG) echo "FOUND {$k}\n";
                $score += $t[$k];
                $solve += $p[$k];
            }
        }
        if (DEBUG) echo "score: " . $score . PHP_EOL;
        if ($score > $G) continue;
        $next_score = $score + $t[$j];
        if ($next_score >= $G) {
            $solve += min($p[$j], ceil(($G - $score) /  ($j + 1)));
        } else {
            continue;
        }
        if (DEBUG) echo "SOLVE : {$solve}" . PHP_EOL;
        $ans = min($ans, $solve);
    }
}
echo $ans;


Measured memory_bytes: 4728
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N, S;
	int A[3001];
	cin >> N >> S;
	for(int i = 1; i <= N; i++){
		cin >> A[i];
	}
	
	static ll DP[3002][3002][3];
	for(int s = 0; s <= 3001; s++){
		DP[0][s][0] = 0;
		DP[0][s][1] = 0;
		DP[0][s][2] = 0;
	}
	DP[0][0][0] = 1;
	
	for(int n = 1; n <= N; n++){
		for(int s = 0; s <= S; s++){
			DP[n][s][0] = DP[n-1][s][0];
			DP[n][s][1] = DP[n-1][s][1] + DP[n-1][s][0];
			DP[n][s][2] = DP[n-1][s][2];
			
			if(s >= A[n]){
				DP[n][s][1] += DP[n-1][s-A[n]][1] + DP[n-1][s-A[n]][0];
			}
			
			if(s == S){
				DP[n][s][2] += DP[n][s][1];
			}
			
			for(int t = 0; t < 3; t++){
				DP[n][s][t] %= 998244353;
			}
		}
	}
	
	cout << DP[N][S][2] << endl;
	
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,M;
    cin >> N >> M;

    vector<i64> x(N),y(N),z(N);
    vector<int> idx;
    rep(i,0,N){
        cin >> x[i] >> y[i] >> z[i];
        idx.push_back(i);
    }

    i64 ans=0;
    rep(i,0,1<<3){
        i64 p=(i&1)?-1:1,q=(i&2)?-1:1,r=(i&4)?-1:1;
        sort(begin(idx),end(idx),[&](int a,int b){ return p*x[a]+q*y[a]+r*z[a]>p*x[b]+q*y[b]+r*z[b]; });

        i64 s=0,t=0,u=0;
        rep(j_,0,M){
            int j=idx[j_];
            s+=x[j];
            t+=y[j];
            u+=z[j];
        }
        ans=max(ans,abs(s)+abs(t)+abs(u));
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define NIL -1

typedef struct{
  int p, l, r;
}Node;

Node T[100000];
int D[100000];

void print(int);
int rec(int, int);

int main()
{
  int n, id, deg, c, l, r;
  int i, j;
  
  scanf("%d", &n);
  for(i=0;i<n;i++)
    {
      T[i].p = NIL; T[i].l = NIL; T[i].r = NIL;
    }
  
   for(i=0;i<n;i++)
    {
      scanf("%d%d", &id, &deg);
	for(j=0;j<deg;j++)
	  {
	    scanf("%d", &c);
	    if(j==0)T[id].l = c;
	    else T[l].r = c;
	    l = c;
	    T[c].p = id;
	  }
    }

   for(i=0;i<n;i++)
     {
       if(T[i].p == NIL)r = i;
     }

   rec(r, 0);

   for(i=0;i<n;i++)
     {
       print(i);
     }
  
  return 0;
}

void print(int u)
{
  int i=0, c=T[u].l;
  
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l==NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  while(1)
    {
      if(c == NIL)break;
      
      if(i)printf(", ");
      printf("%d", c);

      i++; c=T[c].r;
    }
  printf("]\n");
}

int rec(int u, int p)
{
  D[u] = p;
  if(T[u].r != NIL)rec(T[u].r, p);
  if(T[u].l != NIL)rec(T[u].l, p+1);
}



Measured memory_bytes: 6392
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> a(n);     //順番
    vector<int> b(n);     //満足度
    vector<int> c(n - 1); //追加点

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

    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }

    int tmp = a[0];
    for (int i = 0; i < n; i++)
    {
        sum += b[a[i] - 1];
        if (tmp == a[i] - 1)
        {
            sum += c[tmp - 1];
        }
        tmp = a[i];
        //cout << sum << endl;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    
    int a,b,c;
    std::cin>>a>>b>>c;
    
    if(a<b && b<c){
        std::cout<<"Yes"<<std::endl;
    }
    else{
        std::cout<<"No"<<std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h> 
using namespace std; 
const int mod=1e9+7;
void add(int& a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
void sub(int& a,int b){
    a-=b;
    if(a<0)a+=mod;
}
int main() 
{ 
   int n,k;
   scanf("%d %d",&n,&k);
   vector<int> dp(k+1);
   dp[0]=1;
   for(int i=0;i<n;i++){
       int x;
       scanf("%d",&x);
       vector<int> t(k+1);
       for(int j=k;j>=0;j--){
           int l=j+1,r=min(j+x,k);
           if(l<=r){
               add(t[l],dp[j]);
               if(r+1<=k)sub(t[r+1],dp[j]);
           }
       }
       int ps=0;
       for(int j=0;j<=k;j++){
           add(ps,t[j]);
           add(dp[j],ps);
       }
   }
   printf("%d",dp[k]);
} 


Measured memory_bytes: 1024
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = p
c = [0]
cnt = 0
for i in range(n):
  # 累積和
  cnt += a[i]
  c.append(cnt)
  
from bisect import bisect_right
for i in range(p,n):
  h = a[i]+m
  free = v - (p-1) - (n-i)
  if free >= 0 and h >= a[p-1]:
    d = h * (i-p+1) - (c[i]-c[p-1]) # 余裕
    if d >= free*m:
      ans += 1
  else:
    if h >= a[p-1]:
      ans += 1
print(ans)

Measured memory_bytes: 14484
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int> a;
  for(int i = 0;i<n;i++){
    int temp;
    cin >>temp;
    a.push_back(abs(temp));
  }
  sort(a.begin(),a.end());
  cout << a[a.size()-1]-a[0];
  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll a, b, c;cin >> a >> b >> c;
	if(a < c && c < b)cout << "Yes" << endl;
	else if(b < c && c < a)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
uses math;
const fi='knapsack1.inp';
      fo='knapsack1.out';
      maxn=100;
      maxw=100000;
var n,w:int32;
    we,v:array[1..maxn] of uint32;
    f:array[0..maxn,0..maxw] of uint64;
//=============================
procedure nhap;
var i:int32;
begin
   readln(n,w);
   for i:=1 to n do readln(we[i],v[i]);
end;
//=============================
procedure xuli;
var i,j:int32;
begin
   for i:=1 to w do f[0,i]:=0;
   for i:=1 to n do
    for j:=1 to w do
     begin
        f[i,j]:=f[i-1,j];
        if (j>=we[i]) and (v[i]+f[i-1,j-we[i]]>f[i,j]) then
         f[i,j]:=f[i-1,j-we[i]]+v[i];
     end;
   write(f[n,w]);
end;
//=============================
begin
//   assign(input,fi); reset(input);
//   assign(output,fo); rewrite(output);
   nhap;
   xuli;
//   close(input); close(output);
end.


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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n, m;
long long x[100010], y[100010], memx, memy, mo = 1000000000+7;

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++)  cin >> x[i];
    for(int i = 1; i <= m; i++)  cin >> y[i];
    for(int i = 1; i <= n; i++){
        memx += (i-1)*x[i] - (n-i)*x[i];
    }
    memx %= mo;
    for(int i = 0; i <= m; i++){
        memy += (i-1)*y[i] - (m-i)*y[i];
    }
    memy %= mo;

    cout << (memx * memy) % mo << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int n, y, i, j, z;
  scanf("%d%d", &n, &y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      z=n-i-j;
      if(10000*i+5000*j+1000*z==y&&z>=0){
        printf("%d %d %d\n", i, j, z);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 128
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

@functools.lru_cache(maxsize=None)
def Luca(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return Luca(n-1)+Luca(n-2)

N = I()
print(Luca(N))

Measured memory_bytes: 12488
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    char S[330][330];
    rep(i, N) {
        rep(j, N) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    rep(B, N) {
        char T[330][330];
        rep(i, N) {
            rep(j, N) {
                T[i][j] = S[i][(j + B) % N];
            }
        }
        bool flag = true;
        rep(i, N) {
            Rep(j, i + 1, N) {
                if(T[i][j] != T[j][i]) {
                    flag = false;
                }
            }
        }
        if(flag) ans += N;
    }
    cout << ans << endl;
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C;
    cin >> A >> B >> C;

    cout << A*B/2 << endl;
    return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  long long ans;
  if(n == 2 && m == 2) ans = 0;
  else if(n == 2 && m == 1) ans = 0;
  else if(n == 1 && m == 2) ans = 0;
  else if(n == 1 && m == 1) ans = 1;
  else if(n == 1) ans = m - 2;
  else if(m == 1) ans = n - 2;
  else ans = 1ll * (n - 2) * (m - 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
l = input().split()
q = []

for e in l:
    if e == '+':
        q.append(q.pop() + q.pop())
    elif e == '-':
        q.append(-q.pop() + q.pop())
    elif e == '*':
        q.append(q.pop() * q.pop())
    else:
        q.append(int(e))

print(q[0])

Measured memory_bytes: 7692
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	
	ll N, A, B;
	cin >> N >> A >> B;

	ll ans = 0;
	fori(i, 1, N + 1) {
		ll a = i % 10;
		ll b = (i / pw(10, 1)) % 10;
		ll c = (i / pw(10, 2)) % 10;
		ll d = (i / pw(10, 3)) % 10;
		ll e = (i / pw(10, 4)) % 10;
		ll f = a + b + c + d + e;
		if (A <= f && f <= B) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    
    long long ans=0;
    map<int, int> map;
    for(int i=0;i<n;i++){
        int s = i-A[i];
        ans += map[s];
        int w = i+A[i];
        map[w]++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 21076
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)


typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


/*************************************************************************/
//多次元配列の確保及び初期化用マクロ
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
/*************************************************************************/



const ll INF = 1e9 + 7;


int main() {

	
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	
	vector<int> vec(n);
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
	}

	sort(vec.begin(), vec.end());

	int mini = INF;
	do
	{
		for (int i = 1; i <= 6; i++)
		{
			for (int j = 1; j <= 6; j++)
			{
				for (int k = 1; k <= 6; k++)
				{
					if (i + j + k > n)
					{
						//棒が多すぎる
						continue;
					}

					int cnt = 0;
					int A = 0, B = 0, C = 0;
					for (int idx = 0; idx < i; idx++)
					{
						A += vec[idx];
					}
					cnt += abs(A - a);
					cnt += 10 * (i - 1);

					for (int idx = i; idx < i+j; idx++)
					{
						B += vec[idx];
					}
					cnt += abs(B - b);
					cnt += 10 * (j - 1);

					for (int idx = i + j; idx < i + j + k; idx++)
					{
						C += vec[idx];
					}
					cnt += abs(C - c);
					cnt += 10 * (k - 1);

					mini = min(mini, cnt);
				}
			}
		}

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

	cout << mini << endl;

	return 0;
}


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

int k, r, l;
double p, e, t;

double solve(int k, double r, double l)
{
	if (t + e < r || l < t - e){
		return 0.0;
	}
	if (t - e <= r && l <= t + e){
		return 1.0;
	}
	
	double h = (r + l) / 2;
	
	if (k == 0){
		if (t - e <= h && h <= t + e){
			return 1.0;
		}
		else return 0.0;
	}
	
	double k1 = 1.0 - p, k2 = p;
	if (t > h){
		swap(k1, k2);
	}
	
	return k1 * solve(k - 1, r, h) + k2 * solve(k - 1, h, l);
}

int main()
{
	cin >> k >> r >> l >> p >> e >> t;
	printf("%.20f\n", solve(k, r, l));
}

Measured memory_bytes: 1248
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    char a;cin>>a;
    if(a>='a'&&a<='z'){
        cout<<'a'<<endl;
    }
    else cout<<'A'<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






























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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005], b[100005];
LL sum[100006];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    forn(i, n) cin >> a[i];
    forn(i, n) b[i] = a[i];
    sort(b, b + n);
    sum[n] = 0;
    for (int i = n - 1; i >= 0; --i) {
        sum[i] = sum[i + 1] + b[i];
    }
    int pre = 0;
    LL sub = 0;
    forn(i, n) {
        if (a[i] > pre) {
            int ind = lower_bound(b, b + n, a[i]) - b;
            LL val = sum[0] - sum[ind] + (LL)(n - ind) * a[i];
            LL ans = val - sub;
            sub = val;
            pre = a[i];
            cout << ans << '\n';
        } else {
            cout << "0\n";
        }
    }
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

struct bar{
  ll h,p,q;
  bool operator<(const bar& b){
    return h > b.h;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m, a;
  while(cin >> n >> m >> a && n && m && a){
    vector<bar> b(m);
    rep(i,m){
      cin >> b[i].h >> b[i].p >> b[i].q ;
    }
    sort(all(b));
    ll h = 0;
    rep(i,m){
      if(b[i].p == a && h != b[i].h){
        a = b[i].q;
        h = b[i].h;
      }
      else if(b[i].q == a && h != b[i].h){
        a = b[i].p;
        h = b[i].h;
      }
    }
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	vector<set<pair<int, int>>> a(n);
	vector<pair<int, int>> b(m);
	for(int i = 0, p, y; i < m; ++i)
	{
		scanf("%d%d", &p, &y);
		a[p - 1].insert(make_pair(y, i));
	}
	for(int i = 0; i < n; ++i)
	{
		int k = 0;
		for(auto j : a[i])
		{
			b[j.second] = make_pair(i, k++);
		}
	}
	for(int i = 0; i < m; ++i)
	{
		printf("%06d%06d\n", b[i].first + 1, b[i].second + 1);
	}
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,d,k,l,s; cin >> n >> d;

  k = d*2+1;
  l = n/k;
  
  if(n%k >0) l++;
  
        cout << l << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0, n, k;
string s, t;
//cout<<<<endl;


int main()
{
	cin >> s>>t;
	a = 0;
	rep(i, 3)
	{
		if (s[i] == t[i])
			a++;
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long l1;
#define mod 1000000007
#define f first
#define se second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define set(a,b) memset(a,b,sizeof(a))
#define mn *min_element
#define mx *max_element
#define input l1 t; cin>>t; while(t--)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

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

n = ni()
dp = [[0] * 3 for _ in range(n)]

a, b, c = na()
dp[0][0], dp[0][1], dp[0][2] = a, b, c

for i in range(1, n):
    a, b, c = na()
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c

print(max(dp[n-1]))

Measured memory_bytes: 55276
#include <bits/stdc++.h>
using namespace std;
int main(){
	int s,n,c;
	while(cin>>n,n){
		c=0;for(int i=1;i<n/2+1;i++){s=i;for(int j=1;s<n;j++){s+=(i+j);if(s==n){c++;break;}}}
		cout<<c<<endl;
	}
}

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

using namespace std;
typedef long long ll;

int main() {
    vector<int> a = {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};
    int k;
    cin >> k;
    cout << a[k - 1] << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int n = min(x, y);
    int m = max(x, y);
    if(z >= n && z <= m){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
if(((W>=(x+r))&&(x>=r))&&((H>=(y+r))&&(y>=r))) {
printf("Yes\n");
}
else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  long double a, b, h, m; cin >> a >> b >> h >> m;
  
  long double ans = 0.0;
  double anglea = 30*h+m/(long double)2;
  double angleb = 6*m; 
  long double angle = (long double)abs(anglea-angleb);
  dump(angle);

  angle = angle*(long double)M_PI;
  angle /= (long double)180;
  dump(4*angle);

  long double tmp = (long double)(a*a) + (long double)(b*b) - (long double)(2*a*b*(long double)cos(angle));
  dump(cos(angle));
  dump(tmp);
  ans = (long double)sqrt(tmp);

  cout << fixed << setprecision(20) << ans << endl;
  
  return 0;
}


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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

vector<vector<int>> adj;
vector<int> dst;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	adj.resize(n, vector<int>(n));
	REP(i, n) REP(j, n) {
		char c;
		cin >> c;
		adj[i][j] = c == '1';
	}
	dst.resize(n, -1);

	int ans = 0;
	REP(i, n) {
		deque<int> Q;
		Q.emplace_back(i);
		fill(dst.begin(), dst.end(), -1);
		dst[i] = 0;

		while(!Q.empty()) {
			int v = Q.front();
			debug(v, dst[v]);
			ans = max(ans, dst[v]);
			Q.pop_front();

			REP(u, n) {
				if(adj[v][u]) {
					if(dst[u] == -1) {
						dst[u] = dst[v] + 1;
						Q.emplace_back(u);
					}
					else if(dst[u] % 2 == dst[v] % 2) {
						cout << "-1\n";
						return 0;
					}
				}
			}
		}
	}

	cout << ans + 1 << "\n";
}


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

int main() {
  int x,fx,sum=0,N;
  cin >> x;
  N = x; //最初の値を保持
  
  while (x!=0){
    sum += x%10;
    x /=10;

    /*
    cout << "sum:" << sum << endl;
    cout << "x:" << x << endl;
    */
  }
  
  if(N%sum == 0){
    cout << "Yes" << endl;  
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
?import std.stdio;
import std.conv;
import std.string;

int main() {
  string str[] = chomp(readln).split(" ");
  int a = to!(int)(str[0]);
  int b = to!(int)(str[1]);
  int c = to!(int)(str[2]);
  if(a<b && b<c) writeln("Yes");
  else writeln("No");

  return 0;
}

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

int main()
{
    int n, tmp;
    cin >> n;
    vector<int> a(n);

    bool res = true;

    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        if(tmp % 2 == 0)
        {
            if(tmp % 3 && tmp % 5)
                res = false;
        }
    }

    cout << (res ? "APPROVED" : "DENIED") << "\n";
    return 0;
}

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

int main() {
    int n, tmp, side1 = 0, side2 = 0;
    cin >> n;
    map<int, int>mp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        mp[tmp]++;
    }
    for (auto it: mp) {
        if (it.second >= 4) {
            side1 = side2 = it.first;
        }
        else if (it.second >= 2) {
            side2 = side1;
            side1 = it.first;
        }
    }
    cout << (ll)side1 * side2 << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
using namespace std;
int main(){
    int N;
    int A[110];
    int AMax=0;
    int AMin=1e9;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] > AMax){
            AMax = A[i];
        }
        if(A[i] < AMin){
            AMin = A[i];
        }

    }
            cout << (AMax-AMin) << endl;
return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc114/tasks/abc114_d

from collections import defaultdict

def solve():
    n = int(input())
    
    # 32400 = 2^4 3^4 5^2
    # => 5 x 5 x 3 = 75
    # 75の分割分だけ持てば良い

    # 10! = 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10
    # 10! = 1 x 2 x 3 x (2x2) x 5 x (2x3) x 7 x (2x2x2) x (3x3) x (2x5)
    # 10!の約数 nCk個取ってきた積で割り切れる
    # 1を除いてちょうど74個あるかどうか

    # 2 ~ n までの素因数分解
    e = [0] * (n + 1)
    for i in range(2, n + 1):
        cur = i
        for j in range(2, i + 1):
            while cur % j == 0:
                e[j] += 1
                cur //= j
    
    def num(m):
        return len(list(filter(lambda x: x >= m - 1, e)))

    v1 = num(75) # 75乗を作れるやつ
    v2 = num(25) * (num(3) - 1) # 25乗 x 3乗 (25乗に使った分を含まない)
    v3 = num(15) * (num(5) - 1) # 15乗 x 5乗
    v4 = num(5) * (num(5) - 1) * (num(3) - 2) // 2 # 5乗 x 5乗(-1) x 3乗(-2)
    ans = v1 + v2 + v3 + v4
    # print(e)
    # print(v1)
    # print(v2)
    # print(v3)
    # print(v4)
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38512
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

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

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    String s = sc.next();
    int l = s.length();
    int count = 0;
    for (int i = 0; i < l / 2; i++) {
      if (s.charAt(i) != s.charAt(l - 1 - i)) {
        count++;
      }
    }
    pw.println(count);
  }
}


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

void Main() {
  int x;
  for (int i = 1; i <= 5; i++) {
    cin >> x;
    if (x == 0) cout << i << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;


int s=0,n;

int main()
{
    int i,a;
    cin>>n;
    for (i=1;i<=n;i++)
    {
    	scanf ("%d",&a);
    	s+=a-1;
	}
	cout<<s<<endl;
    return 0;
} 


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

int main() {
  int n, m;
  cin >> n >> m;
  map<int, string> result;
  map<int, int> waresult;
  int correctCnt = 0;
  int ngCnt = 0;

  rep(i, m) {
    int num;
    string ans;
    cin >> num >> ans;
    if (result.count(num) == 0) {
      result[num] = ans;
      if (ans == "AC") correctCnt++;
      if (ans == "WA") {
        waresult[num] = 1;
      }
    } else {
      string old = result[num];
      if (old == "AC")
        continue;
      else {
        if (ans == "AC") {
          correctCnt++;
          ngCnt += waresult[num];
        }
        if (ans == "WA") {
          waresult[num] += 1;
        }
        result[num] = ans;
      }
    }
  }
  cout << correctCnt << ' ' << ngCnt << endl;
  return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
void fail()
{
    printf("No\n");
    exit(0);
}
int n,m,ans,x,y,l;
struct ljb
{
    int y;
    int len;
    int ne;
}e[400003];
int sum,v[100003];
void add(int x,int y,int len)
{
    sum++;
    e[sum].y=y;
    e[sum].len=len;
    e[sum].ne=v[x];
    v[x]=sum;
}
queue<int>q;
int dis[100003];
int vis[100003];
void spfa(int st)
{
    q.push(st);
    int mx=0;
    int mi=0;
    vis[st]=1;
    dis[st]=0;
    while(!q.empty())
    {
        int tmp=q.front();
        q.pop();
        for(int i=v[tmp];i;i=e[i].ne)
        {
            if (vis[e[i].y]==0)
            {
                dis[e[i].y]=dis[tmp]+e[i].len;
                mx=max(mx,dis[e[i].y]);
                mi=min(mi,dis[e[i].y]);
                if (mx-mi>1000000000)fail();
                vis[e[i].y]=1;
                q.push(e[i].y);
            }
            if (vis[e[i].y]==1&&e[i].len+dis[tmp]!=dis[e[i].y])fail();
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
    {
        scanf("%d %d %d",&x,&y,&l);
        add(x,y,l);
        add(y,x,-l);
    }
    for (int i=1;i<=n;i++)
    {
        if (vis[i]==0)spfa(i);
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 6528
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!(
        n: usize,
        k: usize,
        ps: [Usize1; n],
        cs: [i64; n],
    );
    let mut loops = vec![0usize; n];
    let mut dt = vec![Vec::with_capacity(n); n];
    let mut is_back = vec![false; n];
    let mut poss: Vec<usize> = (0..n).collect();
    let mut count = 0;
    let mut i = 0;
    while count < n {
        for j in 0..n {
            if i == 0 {
                poss[j] = ps[poss[j]];
                dt[j].push(cs[poss[j]]); }
            else if !is_back[j] {
                poss[j] = ps[poss[j]];
                let last = dt[j][i - 1];
                dt[j].push(last + cs[poss[j]]);
                if poss[j] == j {
                    loops[j] = i + 1;
                    is_back[j] = true;
                    count += 1;
                }
            }
        }
        i += 1;
    }
    let mut maxs: Vec<i64> = Vec::with_capacity(n);
    for i in 0..n {
        let m = *dt[i].iter().max().unwrap();
        let l = dt[i].iter().position(|&x| x == m).unwrap();
        let s = *dt[i].last().unwrap();

        if l + 1 > k { maxs.push(*dt[i][..k].iter().max().unwrap()); }
        else if s <= 0 { maxs.push(m); }
        else {
            let (q, r) = (k / loops[i], k % loops[i]);
            let q = q as i64;
            if q == 0 { maxs.push(m); }
            else if r == 0 { maxs.push(m + s * (q - 1)); }
            else {
                maxs.push(max(
                    dt[i][..r].iter().max().unwrap() + s * q,
                    m + s * (q - 1)
                ));
            }
        }
    }
    println!("{}", maxs.iter().max().unwrap());
}


Measured memory_bytes: 270512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	S := getStdin()
	var ch1 byte = ' '
	var ch2 byte = ' '
	for idx := range S {
		if ch1 == ' ' {
			ch1 = S[idx]
		} else if ch2 == ' ' && ch1 != S[idx] {
			ch2 = S[idx]
		} else {
			if ch1 != S[idx] && ch2 != S[idx] {
				fmt.Printf("No\n")
				return
			}
		}
	}
	if ch1 == ' ' || ch2 == ' ' {
		fmt.Printf("No\n")
		return
	}
	fmt.Printf("Yes\n")
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int m[5];
	int mn = 10000;
	int idx = 0;
	REP(i,5){
		cin>>m[i];
		if(m[i]%10 && mn > m[i]%10 ){
			mn = m[i]%10;
			idx = i;
		}
	}
	
	int ans = 0;
	REP(i,5){
		if(i==idx) continue;
		ans += ((m[i]/10)+((m[i]%10)?1:0)) * 10;
	}
	
    cout << ans+m[idx] << endl;
    return 0;
}

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

int a,b,c;

////////////////////////////////////////////////////////////////
	 
int main(){

	cin >> a >> b >> c;
	
	if(a+b+c >= 22)cout << "bust" << endl;
  	else cout << "win" << endl;
  
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()

void solve(){
 ll h,w,k;
  cin >> h >> w >> k;
 char c[h][w];
 rep(i,0,h){
  rep(j,0,w) cin >> c[i][j];
 }
  ll ans=0;
  
  rep(a,0,(1<<h)){
   rep(b,0,(1<<w)){
     ll num=0;
     rep(i,0,h){
      rep(j,0,w){
        if((a>>i)&1) continue;
        if((b>>j)&1) continue;
        if(c[i][j]=='#') num++;
      }
     }
     if(num==k) ans++;
   }
  }
  
  cout << ans << endl;
}

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

Measured memory_bytes: 3652
a, b, c, d=gets.split.map(&:to_i)

v=Array.new(200){0}
v[a]+=1; v[b+1]-=1
v[c]+=1; v[d+1]-=1

200.times do |i|
  if i>0
    v[i]+=v[i-1]
  end
end

puts [v.count(2)-1, 0].max


Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
  public static char caesar(char c) {
    if(c == 'z') {
      return 'a';
    }
    else if(c == 'Z') {
      return 'A';
    }
    else if(65 <= (int)c && (int)c <= 122) {
      return (char)(((int)c) + 1);
    }
    else {
      return c;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      String text = sc.nextLine();
      while(true) {
        if(text.contains("the") || text.contains("this") || text.contains("that")) {
          System.out.println(text);
    	  break;
        }
        String tmp="";  
        char[] chars = text.toCharArray();
        for(int i=0; i<chars.length; i++) {
          tmp += caesar(chars[i]);
        }
        text = tmp;
      }
    }
  }
}

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

// main.cpp

int main() {
  std::int_fast64_t n;
  std::cin >> n;

  std::int_fast64_t prev_t = 0, prev_x = 0, prev_y = 0;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t t, x, y;
    std::cin >> t >> x >> y;
    if (std::abs(x - prev_x) + std::abs(y - prev_y) > t - prev_t) goto FAILED;
    if (((t - prev_t) - (std::abs(x - prev_x) + std::abs(y - prev_y))) % 2 != 0) goto FAILED;
    prev_t = t;
    prev_x = x;
    prev_y = y;
  }

  std::cout << "Yes" << std::endl;
  return 0;

FAILED:
  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(int argc, char const *argv[]) {
  int a[9];
  rep(i, 9) cin >> a[i];
  int n;
  cin >> n;
  bool bingo[9] = {};
  rep(i, n) {
    int num;
    cin >> num;
    rep(i, 9) {
      if (num == a[i])
        bingo[i] = 1;
    }
  }

  bool flag = false;
  //縦確認
  rep(i, 3) {
    if (bingo[0 + i] && bingo[3 + i] && bingo[6 + i])
      flag = true;
  }
  //横確認
  rep(i, 3) {
    if (bingo[i * 3] && bingo[i * 3 + 1] && bingo[i * 3 + 2])
      flag = true;
  }
  //斜め確認
  if ((bingo[0] && bingo[4] && bingo[8]) || (bingo[2] && bingo[4] && bingo[6]))
    flag = true;

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> c_s(n);
    rep(i, n)
    {
        cin >> c_s[i].first >> c_s[i].second;
    }
    sort(c_s.begin(), c_s.end());

    // dp[k][s] = [0,k)種類を時刻sに食べ終わる最適値
    vector dp(n + 1, vector(t + 1, -1));
    dp[0][0] = 0;
    FOR(k, 1, n)
    {
        dp[k] = dp[k - 1];
        FOR(s, 0, t - 1)
        {
            if (dp[k - 1][s] < 0)
            {
                continue;
            }
            chmax(dp[k][min(t, s + c_s[k - 1].first)], dp[k - 1][s] + c_s[k - 1].second);
        }
    }

    int ans = accumulate(dp[n].begin(), dp[n].end(), -1, [](int acc, int x) { return max(acc, x); });
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 38440
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  ll num = 1;
  vll a{1};
  while(num<50000000000000000){
    num*=26;
    ll las = (a.size()==0?0:a[a.size()-1]);
    a.push_back(las + num);
  }
  ll l = upper_bound(all(a), n) - a.begin();
  n -= a[l-1];

  string ans(l, '?');

  for(int i=l-1;i>=0;i--){
    char alp = 'a' + n%26;
    ans[i] = alp;
    n/=26;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3124