akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d\n",&t,&x,&y);
        if(x+y>t){printf("No\n");return 0;}
        if((x+y)%2 != t%2){printf("No\n");return 0;}
    }
    printf("Yes\n");
    return 0;
}

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

int main() {
    int N;
    struct map{
        int index;
        int64_t elem;
    };
    vector<map> A;
    
    cin >> N;
    for(int i=0;i<N;i++){
        int64_t elem;
        cin >> elem;
        A.push_back({i,elem});
    };

    sort(A.begin(), A.end(), [](const map& x, const map& y){ return x.elem > y.elem;});

    struct x_y{
        int x;
        int y;
    };
    vector<x_y> dpnxy;
    vector<x_y> dpnxy1;
    dpnxy.push_back({0,0});

    vector<int64_t> dpn;
    vector<int64_t> dpn1;
    dpn.push_back(0);

    for(int n=1;n<=N;n++){
        for(int i=0;i<dpnxy.size();i++){
            int x = dpnxy.at(i).x;
            int y = dpnxy.at(i).y;
            int n_left = x;
            int n_right = N-1-y;

            if(A.at(n-1).index >= n_left){
                int64_t l = dpn.at(i) + A.at(n-1).elem * (A.at(n-1).index - n_left);
                
                if(i != 0 && dpnxy1.at(dpnxy1.size()-1).x == x+1 && dpnxy1.at(dpnxy1.size()-1).y ==y){
                    if(dpn1.at(dpn1.size()-1) < l){
                        dpn1.at(dpn1.size()-1) = l;
                    }
                }else{
                    dpnxy1.push_back({x+1,y});
                    dpn1.push_back(l);
                }
            }

            if(A.at(n-1).index <= n_right){
                int64_t r = dpn.at(i) + A.at(n-1).elem * (n_right - A.at(n-1).index);
                dpnxy1.push_back({x,y+1});
                dpn1.push_back(r);
            }
        }
        dpnxy = dpnxy1;
        dpn = dpn1;
        // for(int i=0;i<dpn.size();i++){
        //     cout << dpnxy.at(i).x << " " << dpnxy.at(i).y << " " << dpn.at(i) << "|";
        // }
        // cout << endl;
        dpnxy1.clear();
        dpn1.clear();
    }
    int64_t result = 0;
    for(int i=0;i<dpn.size();i++){
        if(result < dpn.at(i)){
            result = dpn.at(i);
        }
    }
    cout << result << endl;
}

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

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

    sort(begin(A), end(A));
    sort(begin(B), end(B));

    if(N & 1) {
        cout << B[(N - 1) / 2] - A[(N - 1) / 2] + 1 << '\n';
    } else {
        cout << (B[(N - 1) / 2] + B[(N + 1) / 2]) - (A[(N - 1) / 2] + A[(N + 1) / 2]) + 1 << '\n';
    }
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  cout << max(a - k, 0ll) << " " << flush;
  cout << max(b - max(k - a, 0ll), 0ll) << endl;
  return 0;
}

Measured memory_bytes: 256
/**
  *  @Author: Pranta Sarker
  *
  */

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define pfn(x , k) printf(k , x)
#define nl puts("")
#define psb push_back
#define mset(c,v) memset(c , v , sizeof c)
#define loop0(n) for(int i=0; i<n; i++)
#define loop1(n) for(int i=1; i<=n; i++)
#define mpair(x , y) make_pair(x , y)
#define all(x) x.begin(), x.end()
#define pi acos(-1.0)
#define psb push_back
#define clr clear()

typedef unsigned long long ull;
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef vector<string>vs;
typedef map<int, int>mpii;
typedef map<string, int>mpsi;
typedef map<char, int>mpci;
typedef map<LL, LL>mpll;

const int mod = 1000007;
const int high = 1e5+3;

LL ar[high];

int main()
{
	fast;
	int i , N, odd=0 , two=0, four=0;
	cin >> N;
	for(i=0; i<N; i++)
	{
		int x;

		cin >> x;

		if(x % 4 == 0) four+=1;
		else if(x % 2 == 0) two+=1;
		else if(x % 2 != 0) odd+=1;
	}

	if(two == 0)
	{
		if(odd <= four + 1) outn("Yes");
		else outn("No");
	}

	if(two > 0)
	{
		if(odd <= four) outn("Yes");
		else outn("No");
	}

	return 0;
}


Measured memory_bytes: 256
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();
$k = $sc->nextInt();
$x = $sc->nextInt();

echo (500 * $k >= $x)? "Yes":"No";

echo "\n";

Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, X;
	int maximum = (1<<10);
	vector<vector<int>> dp;
	
	cin>>N>>X;
	
	dp.resize(maximum, vector<int>(N+1));
	

	for(int i = 0; i <= X; i++){
		dp[i][0] = 1;
		for(int j = 1; j < N; j++){
			for(int k = 0; k < maximum; k++){
				dp[i^k][j] += dp[k][j-1];
				dp[i^k][j] %= MOD;
			}
		}
	}
	
	cout<<dp[X][N-1]<<endl;
	
	return 0;
}


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

using namespace std;

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

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

typedef long long ll;
typedef pair<int, int> pi;

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

    ll n;
    cin>>n;
    ll a, mini = 1e17;
    for (int i=0;i<5;++i){
        cin>>a;
        mini = min(mini, a);
    }

    ll b = n/mini;
    if (b*mini < n) b++;
    b--;

    cout<<5+b<<endl; 
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gtl(x) getline(cin, (x))
#define PI acos(-1)
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    printf("%d %d %d\n", a, b, c);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,K,day,sosu;
int plan[101];
int memo[101][4][4];

int solve(int n,int b1,int b2){
  if(n==N+1) return 1;
  if(memo[n][b1][b2]!=-1) return memo[n][b1][b2];

  if(plan[n]!=0){
    if(b1==b2&&b1==plan[n])
      return 0;
      else
       return solve(n+1,plan[n],b1)%10000;
    }
    int t=0;
    for(int i=1;i<=3;++i){
      if(b1==b2&&b1==i)continue;
      t+=solve(n+1,i,b1)%10000;
    }
    return memo[n][b1][b2]=t%10000;
}

int main(){
  cin>>N>>K;

  for(int i=0;i<K;i++){
    cin>>day>>sosu;
    plan[day]=sosu;
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
	memo[i][j][k]=-1;
      }
    }
  }
  cout<<solve(1,0,0)<<endl;
}

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

signed main() {
	int H, W;
	cin >> H >> W;
	vector<string> letter(H);
	for (int i = 0; i < H; i++) cin >> letter[i];
	for (int i = 0; i < W + 2; i++) cout << "#";
	cout << endl;
	for (int i = 0; i < H; i++) cout << "#" << letter[i] << "#" << endl;
	for (int i = 0; i < W + 2; i++) cout << "#";
	cout << endl;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    uf.unite(a - 1, b - 1)
ans = 0
for i in range(n):
    ans = max(ans, uf.size[uf.find(i)])
print(ans)


Measured memory_bytes: 89776
#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 100;



int main()
{
    int n,l;
    string s;
    cin>>n>>l;
    vector<string> strList;
    for(int i=0;i<n;i++){
        cin>>s;
        strList.push_back(s);
    }
    sort(strList.begin(),strList.end());
    for(int i=0;i<n;i++){
        cout<<strList[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
mod = 10**9+7
dp = [[0]*4 for _ in range(n)]
dp[0] = [8,1,1,0]
for i in range(1,n):
    dp[i][0] = (dp[i-1][0]*8)%mod
    dp[i][1] = (dp[i-1][0] + dp[i-1][1]*9)%mod
    dp[i][2] = (dp[i-1][0] + dp[i-1][2]*9)%mod
    dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3]*10)%mod
print(dp[-1][-1])

Measured memory_bytes: 198168
#include<cstdio>
    #include<algorithm>
    #define fo(i,a,b) for(i=a;i<=b;i++)
    using namespace std;
    typedef long long ll;
    const int maxn=100000+10,mo=1000000007;
    int ans[3][3],a[3][3],b[3][3],d[3][3],o[3][3];
    int x[maxn],sta[80];
    int i,j,k,l,t,n,m,now,num,top;
    void mult(int a[3][3],int b[3][3],int c[3][3]){
        int i,j,k;
        fo(i,0,2)
            fo(j,0,2)
                o[i][j]=0;
        fo(k,0,2)
            fo(i,0,2)
                fo(j,0,2)
                    o[i][j]=(o[i][j]+(ll)a[i][k]*b[k][j]%mo)%mo;
        fo(i,0,2)
            fo(j,0,2)
                c[i][j]=o[i][j];
     
    }
    void work(int n){
        int i,j;
        fo(i,0,2)
            fo(j,0,2)
                d[i][j]=(i==j);
        top=0;
        while (n){
            sta[++top]=n%2;
            n/=2;
        }
        while (top){
            mult(d,d,d);
            if (sta[top--]) mult(d,a,d);
        }
    }
    int main(){
        scanf("%d%d",&n,&m);
        fo(i,1,m) scanf("%d",&x[i]);
        x[++m]=n;
        ans[0][0]=ans[0][2]=1;
        ans[0][1]=2;
        a[0][0]=a[0][2]=a[1][1]=a[1][2]=a[2][0]=1;
        a[0][1]=a[2][1]=a[2][2]=2;
        fo(i,0,2)
            fo(j,0,2)
                b[i][j]=a[i][j];
        b[2][0]--;
        b[2][1]-=2;
        b[2][2]--;
        now=1;
        fo(i,1,m){
            work(x[i]-now);
            mult(ans,d,ans);
            if (i==m) break;
            mult(ans,b,ans);
            now=x[i]+1;
        }
        num=ans[0][2];
        (num+=mo)%=mo;
        printf("%d\n",num);
    }

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

int main(){
    int l,n;
    cin >> n >> l; 
    vector<string> hoge(n);
    for(int i=0;i<n;i++) cin >> hoge[i];
    sort(hoge.begin(),hoge.end());
    for(int i=0;i<n;i++) cout << hoge[i];
    return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Feb  9 15:10:24 2019
//
package main

import "fmt"

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	min, max := 1<<60, -1<<60
	minI, maxI := 0, 0
	for i := range arr {
		fmt.Scan(&arr[i])
		if arr[i] < min {
			min = arr[i]
			minI = i
		}
		if max < arr[i] {
			max = arr[i]
			maxI = i
		}
	}

	if min >= 0 {
		fmt.Println(N - 1)
		for i := 1; i+1 <= N; i++ {
			fmt.Println(i, i+1)
		}
	} else if max <= 0 {
		fmt.Println(N - 1)
		for i := N; i-1 >= 1; i-- {
			fmt.Println(i, i-1)
		}
	} else if abs(min) < abs(max) {
		fmt.Println(2*N - 1)
		for i := 0; i < N; i++ {
			fmt.Println(maxI+1, i+1)
		}
		for i := 0; i < N-1; i++ {
			fmt.Println(i+1, i+2)
		}
	} else {
		fmt.Println(2*N - 1)
		for i := 0; i < N; i++ {
			fmt.Println(minI+1, i+1)
		}
		for i := N - 1; i >= 1; i-- {
			fmt.Println(i+1, i)
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int a;
  scanf("%d", &a);
  int b;
  scanf("%d", &b);

  int x = -1;
  REP(i, 10000 / 8 + 10) {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
      x = i;
      break;
    }
  }
  /*
  if (xa_min > xb_max || xb_min > xa_max) {
    x = -1;
  } else {
    x = max(xa_min, xb_min);
  }
  */

  printf("%d\n", x);
  return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int L,R,d;
  cin>>L>>R>>d;
  vector<int>sum(R+1,0);
  for(int i=0;i<R;i++){
    if((i+1)%d==0)sum[i+1]=sum[i]+1;
    else sum[i+1]=sum[i];
  }
  cout<<sum[R]-sum[L-1]<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

string s;
int N, x, y;
bool dp1[8080][8080 * 2], dp2[8080][8080 * 2];

signed main()
{
    cin >> s >> x >> y;
    N = s.size();
    bool dir = true;
    dp1[0][N + 10] = true;
    dp2[0][N + 10] = true;
    x += N + 10;
    y += N + 10;
    bool flag = false;
    int dis = 1;
    for(int i = 0; i < N; i++){
        if(s[i] == 'T'){
            dir = !dir;
            dis = 1;
            flag = true;
            for(int j = 0; j <= N * 2 + 11; j++){
                dp1[i + 1][j] = dp1[i][j];
                dp2[i + 1][j] = dp2[i][j];
            }
            continue;
        }
        if(dir){
            if(s[i + 1] == 'T' || s[i + 1] == '\0'){
                for(int j = 0; j <= N * 2 + 11; j++){
                    if(dp1[i][j]){
                        dp1[i + 1][j + dis] = true;
                        if(flag)dp1[i + 1][j - dis] = true;
                    }
                    dp2[i + 1][j] = dp2[i][j];
                }
            }
            else{
                dis++;
                for(int j = 0; j <= N * 2 + 11; j++){
                    dp1[i + 1][j] = dp1[i][j];
                    dp2[i + 1][j] = dp2[i][j];
                }
            }
        }
        else {
            if(s[i + 1] == 'T' || s[i + 1] == '\0'){
                for(int j = 0; j <= N * 2 + 11; j++){
                    if(dp2[i][j]){
                        dp2[i + 1][j + dis]  = true;
                        dp2[i + 1][j - dis] = true;
                    }
                    dp1[i + 1][j] = dp1[i][j];
                }
            }
            else {
                dis++;
                for(int j = 0; j <= N * 2 + 11; j++){
                    dp1[i + 1][j] = dp1[i][j];
                    dp2[i + 1][j] = dp2[i][j];
                }
            }
        }
    }
    if(dp1[N][x] && dp2[N][y]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

/*



*/


Measured memory_bytes: 254208
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int H, W;
int a[510][510];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  REP(i, H) REP(j, W) cin >> a[i][j];
  using P = tuple<int, int, int, int>;
  vector<P> v;
  REP(i, H-1) REP(j, W) {
    if (a[i][j] & 1) {
      v.emplace_back(i, j, i+1, j);
      a[i+1][j]++;
    }
  }
  REP(j, W-1) {
    if (a[H-1][j] & 1) {
      v.emplace_back(H-1, j, H-1, j+1);
      a[H-1][j+1]++;
    }
  }
  cout << SZ(v) << endl;
  REP(i, SZ(v)) {
    int p, q, r, s;
    tie(p, q, r, s) = v[i];
    cout << p+1 << " " << q+1 << " " << r+1 << " " << s+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 8432
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var a = cin.ArrayLong(n);

			long ans = 0;
			for (int i = 0; i < 62; i++) {
				long val = (long)1 << i;
				long cnt = 0;
				for (int j = 0; j < n; j++) {
					if ((a[j] & val) != 0) {
						++cnt;
					}
				}

				if (cnt == 0) {
					continue;
				}

				long rem = n - cnt;
				BigInteger temp = (cnt * rem) % MOD;
				BigInteger val2 = val;
				temp = (temp * val2) % MOD;
				ans = (long)((ans + temp) % MOD);
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 52680
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<29)
int N;
int V[111];
int F[111][111];
int dp[111][111];
int solve(int now,int nex){
  if( dp[now][nex] != -1 ) return dp[now][nex];
  if( now == N && nex == N ) return dp[now][nex]=0;
  if( nex > N ) return dp[now][nex] = INF;
  int ret = solve(now,nex+1);
  if( F[now][nex] ){
    ret = min(ret,solve(nex+1,nex+1)+1);
  }
  return dp[now][nex] = ret;
}
int main(){
  //  while(   cin >> N ){
  cin >> N;
  memset(F,0,sizeof(F));
  for(int i=0;i<N;i++){
    cin >> V[i];
    F[i][i]=V[i];
  }
  for(int k=1;k<N;k++){
    for(int i=0;i<N;i++){
      int a = i, b = i+k;
      if( b>=N ) break;
      for(int j=a;j<b;j++){
	if( F[a][j] ){
	  if(F[a][j] == F[j+1][b]){
	    F[a][b] = F[a][j]+F[j+1][b];
	    F[b][a] = F[a][b];
	    break;
	  }
	}
      }
    }
  }
  /*  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      printf("%d %d -> %d\n",i,j,F[i][j]);
  */  memset(dp,-1,sizeof(dp));
  cout << solve(0,0) << endl;
}

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

int main(){
string s;
  long long n ;
  cin >> s >> n;
  bool ans = true;
  char anss;
  for(long long i=0;i<n;i++){
   if(s.at(i)!='1'){
     ans = false;
     anss = s.at(i);
     break;
   }
  }
  if(ans){
    cout << 1 << endl;
}
  else{
   cout <<anss<<endl;
  }
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repi(i, x) for (auto &i : (x))


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
string A[100];
int B[100];
int C[100];

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> N;
    rep(i, N) cin >> A[i] >> B[i];

    rep(i, N) C[i] = i;
    sort(C, C+N, [&](int a, int b) {
        if (A[a] != A[b]) return A[a] < A[b];
        return B[a] > B[b];
    });

    rep(i, N) cout << C[i]+1 << endl;
}

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

using namespace std;

typedef vector<int> vi;

#define PB push_back
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}

int a[100002];

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

	rep(i, N) scanf("%d", &a[i]);

	vi l; l.PB(0); l.PB(0);

	int ma = 0;

	int cnt = 1;

	rep1(i, N - 1) {
		if (a[i] == a[i - 1]) {
			l.PB(cnt);
			cnt = 1;
			chmax(ma, *(l.end() - 1) + *(l.end() - 2) + *(l.end() - 3));
		} else cnt++;
	}
	
	l.PB(cnt);
	chmax(ma, *(l.end() - 1) + *(l.end() - 2) + *(l.end() - 3));

    printf("%d\n", ma);
}

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

typedef long long ll;

ll solve(ll S, ll c) {
  ll ans = 0;
  if (c / 2 < S) {
    ans = c / 2;
  } else {
    ans = S;
    c -= 2 * S;
    ans += c / 4;
  }
  return ans;
}

int main() {
  ll N, M;
  cin >> N >> M;
  cout << solve(N, M) << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i

E = Array.new(N){ [] }
(N-1).times{
	u,v = gets.split.map(&:to_i)
	E[u-1] << v-1
	E[v-1] << u-1
}

P = [nil]*N
P[0] = 0
Q = [0]
while p = Q.shift
	E[p].each{|c|
		next if P[c]
		P[c] = p
		Q << c
	}
end

p N+(1...N).sum{|c|
	p = P[c]
	[(c+1)*(p-c),(p-c)*(c-N),].max
}


Measured memory_bytes: 35716
def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
  
A,B,K = (int(X) for X in input().split())
Count = 0
Divid = Div(min(A,B))
for T in Divid:
    if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break

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

int main(){
int i, N, T, A; cin >> N; long m, c, d, a=1, t=1, ans=2;
for(i=0; i<N; i++){
  cin >> T >> A; c=a/A; d=t/T; m=max(c, d);
  if((c>=d && a%A) || (d>=c && t%T)){ m++; }
  a=m*A; t=m*T; ans=a+t;
}
cout << ans << "\n";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

confetto = B[A[0] - 1]
old = A[0]
#print(confetto)
for i in range(1, N):
    confetto += B[A[i] - 1]
    if old + 1 == A[i]:
        confetto += C[old - 1]
    old = A[i]
    #print(confetto)
print(confetto)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
const int maxn = 1e5+10;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
int d[4][2]={1,0,0,1,-1,0,0,-1};
int n;
ll a,b,c;
string s[maxn];
int main() {
    ios::sync_with_stdio(0);
    #ifdef Uncle_drew
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #else
    #endif
    string ans;
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<n;i++){
       if (s[i] == "AB") {
            if (a + b == 0) {
                puts("No"); return 0;
            }
            if (a > b) { ans += "B\n"; a--; b++; }
            else if (a < b) { ans += "A\n"; a++; b--; }
            else if (s[i + 1] == "BC") { ans += "B\n"; a--; b++; }
            else { ans += "A\n"; a++; b--; }
        }
        else if (s[i] == "AC") {
            if (a + c == 0) {
                puts("No"); return 0;
            }
            if (a > c) { ans += "C\n"; a--; c++; }
            else if (a < c) { ans += "A\n"; a++; c--; }
            else if (s[i + 1] == "BC") { ans += "C\n"; a--; c++; }
            else { ans += "A\n"; a++; c--; }
        }
        else  {
            if (b + c == 0) {
                puts("No"); return 0;
            }
            if (b > c) { ans += "C\n"; b--; c++; }
            else if (b < c) { ans += "B\n"; b++; c--; }
            else if (s[i + 1] == "AC") { ans += "C\n"; b--; c++; }
            else { ans += "B\n"; b++; c--; }
        }

    }
    cout<<"Yes\n"<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int a[maxn],b[maxn],c[maxn];
int dp[maxn][3];
int main()
{
	io();
	int N;
	cin>>N;
	for(int i=1;i<=N;++i)
		cin>>a[i]>>b[i]>>c[i];
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	for(int i=1;i<=N;++i){
		for(int j=0;j<3;++j){
			if(j==0)dp[i][j]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
			else if(j==1)dp[i][j]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
			else dp[i][j]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
		}
	}
	int ans=max({dp[N][0],dp[N][1],dp[N][2]});
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(deftype uint nil `(integer 0 ,(expt 10 9)))

(defun count-2-as-factor (num)
  (loop with i = 0
        until (oddp num)
        do (setf num (ash num -1))
           (incf i)
        finally (return i)))

(defun main ()
  (let ((n (read)))
    (print-line (loop for i below n
                      sum (count-2-as-factor (read))))))

#-swank(main)


;; Für Test
#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank
(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
#+swank(defparameter *this-path* *load-pathname*)
#+swank(defparameter *this-dir-path* (uiop:pathname-directory-pathname *this-path*))
#+swank(defparameter *dat-path* (merge-pathnames "test.dat" *this-dir-path*))

#+swank
(defun gendat ()
  (with-open-file (out *dat-path*
		       :direction :output :if-exists :supersede)
    ))

#+swank
(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 53736
#pragma GCC optimize("O2")
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
ll x[105],y[105],h[105];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    for (ll i=0;i<n;i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    for (ll i=0;i<=100;i++) {
        for (ll j=0;j<=100;j++) {
            ll H;
            for (ll k=0;k<n;k++) {
                if (h[k]!=0) {
                    H = h[k] + abs(x[k]-i) + abs(y[k]-j);
                    break;
                }
            }
            bool check = true;
            for (ll k=0;k<n;k++) {
                if (max(H-abs(x[k]-i)-abs(y[k]-j),(ll)0)!=h[k]) {check=false;break;}
            }
            if (check) {
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long int a, b;
	int n,m;
	cin >> n;
	a = 0;
	for (int i = 1; i <= n; i++) {
		cin >> m;
		a = a + m;
	}
	cout << a / n << endl;
}


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

using namespace std;

#define DIM 407
#define INF 1e18+9
#define MODULO 1000000007
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<int,int>
#define fi first
#define se second
#define ld long double

long long i,j,k,l,n,m;

long long dp[DIM][DIM],a[DIM];

long long get(long long l,long long r){
    if(l>r)return INF;
    if(l==r)return 0;
    if(dp[l][r]!=-INF)return dp[l][r];
    dp[l][r]=INF;
    for(int i=l;i<r;i++){
        dp[l][r]=min(dp[l][r],get(l,i)+get(i+1,r)+a[r]-a[l-1]);
    }
    return dp[l][r];
}

int main()
{
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i],a[i]+=a[i-1];

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            dp[i][j]=-INF;
        }
    }

    cout<<get(1,n)<<endl;

    return 0;
}


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

#define N 36

typedef struct{
  char gara;
  int num;
} Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);


int main(void){

  Card c1[N],c2[N];
  int i,j,k,n;
  char dum;

  scanf("%d ",&n);

  for(i=0;i<n;i++){
    scanf("%c%d%c",&c1[i].gara,&c1[i].num,&dum);
    c2[i] = c1[i];
  }


  BubbleSort(c1,n);
  printf("Stable\n");
  SelectionSort(c2,n);
  for(k=0;k<n;k++){
    if(c1[k].gara != c2[k].gara){
      printf("Not stable\n");
      break;
    }
    if(k == n - 1){
      printf("Stable\n");
    }
  }
  return 0;
}

void BubbleSort(Card *A,int n){

  int i,j;
  Card k;

  for(i=0;i<n;i++){
    for(j=n-1;j>=i;j--){
      if(A[j].num < A[j - 1].num){
	k = A[j];
	A[j] = A[j - 1];
	A[j - 1] = k;
      }
    }
  }
 
  for(i=0;i<n;i++){
    if(i == n - 1){
      printf("%c%d\n",A[i].gara,A[i].num);
      break;
    }
    printf("%c%d ",A[i].gara,A[i].num);
  }
}

void SelectionSort(Card *A, int n){

  int i,j,minj;
  Card k;

  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(A[j].num < A[minj].num){
	minj = j;
      }
    }
    k = A[i];
    A[i] = A[minj];
    A[minj] = k;
  }

  for(i=0;i<n;i++){
    if(i == n - 1){
      printf("%c%d\n",A[i].gara,A[i].num);
      break;
    }
    printf("%c%d ",A[i].gara,A[i].num);
  }
}

Measured memory_bytes: 608
n, m = gets.split.map(&:to_i)
a = n.times.map {gets.split.map(&:to_i)}

b = Array.new(m+1, 0)
n.times {|i| b[a[i][0]] += 1}

i = Array.new(n, 0)
f = Array.new(m+1, true)
ans = n
m.times do |k|
    x, y = b.each_with_index.inject([b[0], 0]) {|r, e| r[0] > e[0] ? r : e}
    ans = x if ans > x
    f[y] = false
    b[y] = 0
    break if k + 1 == m

    n.times do |j|
        next if f[a[j][i[j]]]
        i[j] += 1 until f[a[j][i[j]]]
        b[a[j][i[j]]] += 1
    end
end

p ans

Measured memory_bytes: 15140
list_N = list(input())
n = len(list_N) - 1
ans = 0
for i in range(2 ** (n)):
    cnt = 0
    c = []
    for j in range(n):
        if ((i >> j) & 1):
            c.append(int("".join(list_N[cnt:j+1])))
            cnt = j+1
    c.append(int("".join(list_N[cnt:n+1])))
    ans += sum(c)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;
int a[maxn];



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];

    }
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i+1])
        {
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans<<'\n';

}


Measured memory_bytes: 4424
s = (input())
N = len(s)
count_max = 0

alp = 'BDEFHIJKLMNOPQRSUVWXYZ'
n_alp = "ACGT"

for i in range(N):
  count = 0
  for j in range(N - i):
    if s[j + i] in n_alp:
      count += 1
    else :
      break
  if count > count_max:
    count_max = count

print(count_max)

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

int main()
{
  string s;
  cin >> s;
  
  if (s == "SUN") cout << 7 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += i * (n/i + 1) * (n/i) / 2;
    }
    cout << ans << endl;
}

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


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,a,b;
  cin>>n;
  if(n==1) {
    cout << "Hello World" << endl;
    return 0;
  }
  cin>>a>>b;
  cout << a+b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,m,ans=1;
	cin >> n >> m;
	if(n == m){
		FOR(i,1,n+1){
			ans *= i;
			ans %= 1000000007;
		}
		ans *= ans*2;
	}else if(abs(n-m) == 1){
		FOR(i,1,n+1){
			ans *= i;
			ans %= 1000000007;
		}
		FOR(i,1,m+1){
			ans *= i;
			ans %= 1000000007;
		}
	}
	else{
		ans = 0;
	}
	ans %= 1000000007;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer(16) :: a,b,q,s_ans(2),t_ans(2),i,cs,ct,m,j,ans(8),k
integer(16),allocatable :: s(:),t(:),x(:)

read*, a,b,q
allocate(s(a),t(b),x(q))
read*, s(1:a),t(1:b),x(1:q)

do i = 1, q, 1
  cs = bin_s(x(i),s,a)
  ct = bin_s(x(i),t,b)
  if ( cs == 1 .and. s(cs) >= x(i) ) then
    s_ans(1) = s(cs)
    s_ans(2) = s(cs)
  else if ( cs == a .and. s(cs) <= x(i) ) then
    s_ans(1) = s(cs)
    s_ans(2) = s(cs)
  else
    s_ans(1) = s(cs-1)
    s_ans(2) = s(cs)
  end if
  if ( ct == 1 .and. t(ct) >= x(i) ) then
    t_ans(1) = t(ct)
    t_ans(2) = t(ct)
  else if ( ct == b .and. t(ct) <= x(i) ) then
    t_ans(1) = t(ct)
    t_ans(2) = t(ct)
  else
    t_ans(1) = t(ct-1)
    t_ans(2) = t(ct)
  end if
  k = 1
  do m = 1, 2, 1
    do j = 1, 2, 1
      ans(k) = abs(x(i)-t_ans(m)) + abs(t_ans(m)-s_ans(j))
      k = k + 1
    end do
  end do
  do m = 1, 2, 1
    do j = 1, 2, 1
      ans(k) = abs(x(i)-s_ans(m)) + abs(s_ans(m)-t_ans(j))
      k = k + 1
    end do
  end do
  print'(i0)', minval(ans)
end do

contains
!!!!!! サブルーチンは↓
  logical function isOK(index,key,a,n) !indexが条件を満たすかどうか
    implicit none
    integer(16),intent(in) :: index,key,n
    integer(16),intent(in) :: a(n)
    if ( a(index) >= key ) then !a(index)がkey以下になる最小のindex
      isOK = .true.
    else
      isOK = .false.
    end if
  end function isOK

  integer function bin_s(key,a,n)
    implicit none
    integer(16),intent(in) :: key,n
    integer(16),intent(in) :: a(n)
    integer(16) :: ng,ok,mid
    ng = 0 ; ok = n + 1 !初期値の設定は問題によって違う
    !!!!!!while文はどんな場合でも変更しない
    do while ( abs(ok-ng) > 1 )
      mid = (ok+ng)/2
      if ( isOK(mid,key,a,n) ) then
        ok = mid
      else
        ng = mid
      end if
    end do
    bin_s = ok
    if ( bin_s > n ) then
      bin_s = n
    end if
  end function bin_s
!!!!!!

END PROGRAM ATCODER

Measured memory_bytes: 6528
from collections import deque

h, w = map(lambda x: int(x)+2, input().split())
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

total = 0
for i in range(h):
    for j in range(w):
        if MAZE[i][j] == '.':
            total += 1

# よく考えたらBFSでOKだった
i, j = (1, 1)
INF = 10**18
dist = [[INF] * w for _ in range(h)]
dist[i][j] = 1
next_v = deque([[i, j]])
while next_v:
    i, j = next_v.popleft()
    direction = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    for di, dj in direction:
        x, y = i+di, j+dj
        if MAZE[x][y] == "#":
            continue
        if dist[x][y] <= dist[i][j] + 1:
            continue
        dist[x][y] = dist[i][j] + 1
        next_v.append((x, y))

last = dist[h-2][w-2]
if last != INF:
    ans = total - last
else:
    ans = -1
print(ans)


Measured memory_bytes: 3316
num = int(input())
s = input().rstrip().split(' ')
sum = int(s[0])
maxi = int(s[0])
mini = int(s[0])
lst = []
for i in range(1, num):
  sum += int(s[i])
  if maxi < int(s[i]):
    maxi = int(s[i])
  elif mini > int(s[i]):
    mini = int(s[i])
print(str(mini) + " " + str(maxi) + " " + str(sum))


Measured memory_bytes: 6340
h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(h)]

T = [[0]*(w+1) for _ in range(h)]

for j in range(w):
    for i in range(h):
        if c[i][j] == 1:
            continue
        else:
            T[i][j] = T[i-1][j]+1 if i>0 else 1
            
maxv = 0
for i in range(h):
    S = []
    
    for j in range(w+1):
        rect = [T[i][j],j]
        if S:
            if S[-1][0]<rect[0]:
                S.append(rect)
            elif S[-1][0]>rect[0]:
                target = j
                while(S and S[-1][0]>=rect[0]):
                    pre = S.pop()
                    area = pre[0]*(j-pre[1])
                    maxv = max(maxv,area)
                    target = pre[1]
                rect[1] = target
                S.append(rect)
        else:
            S.append(rect)
            
print(maxv)


Measured memory_bytes: 63204
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var no string = ":("
var yes string = "Yay!"

func main() {
	x := nextInts(6)
	if x[4]-x[0] > x[5] {
		fmt.Println(no)
		return
	}
	fmt.Println(yes)
}

var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}
func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, a, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        cnt = cnt + a - 1;
    }
    cout << cnt << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = 1LL<<40;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
int a[16][16];
vector<ll> all,dp;

ll rec1(int s) {
    if (all[s] > -INF) return all[s];
    all[s] = 0;
    for (int i = 0;i < n;++i) if ((s>>i)&1) {
        for (int j = i+1;j < n;++j) if ((s>>j)&1) all[s] += a[i][j];
        all[s] += rec1((s>>(i+1))<<(i+1));
        break;
    }
    return all[s];
}

ll rec2(int s) {
    if (dp[s] > -INF) return dp[s];
    dp[s] = all[s];
    for (int i = s;;i = (i-1)&s) {
        if (i == 0) break;
        if (i == s) continue;
        dp[s] = max(dp[s],rec2(i)+(rec2(s^i)));
    }
    return dp[s];
}

int main() {
    cin >> n;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) cin >> a[i][j];
    all.resize(1<<n,-INF);
    dp.resize(1<<n,-INF);
    for (int i = 0;i < (1<<n);++i) rec1(i);
    cout << rec2((1<<n)-1) << endl;
    return 0;
}

Measured memory_bytes: 1280
///******* In the name of Allah *******///

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

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//void sieve()
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));+
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//}

char aaa[1013];
void Ok()
{
    long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char bbb,ccc,ddd;
    string spc,in,store;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>aaa;
    l = strlen(aaa);
    if(aaa[l-1]=='s')
    {
        aaa[l] = 'e';
        aaa[l+1] = 's';
        cout<<aaa<<endl;
    }
    else if(aaa[l-1]!='s')
    {
        aaa[l] = 's';
        cout<<aaa<<endl;
    }

    return;
}

int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    Ok();

    return 0;
}


Measured memory_bytes: 3660