akhauriyash/Code-Regression huggingface dataset:
//Problem C- Prison
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int l = 1, r = n;
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }
    if(r-l+1 >= 0)
        cout << r-l+1 << endl;
    else
    {
        cout << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  int n,h[111];
  cin>>n;
  for(int i=1;i<=n;i++)cin>>h[i];
  h[0]=0;
  
  int ans=0;
  for(int i=0;i<111;i++){
    for(int j=1;j<=n;j++){
	 if(h[j-1]==0&&h[j]>0){
	   ans++;
	 }
    }
    for(int j=1;j<=n;j++){
	 if(h[j])h[j]--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x) {
  return x * x;
}

signed main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  rep(i, N) {
    if (ans < K)
      ans *= 2;
    else
      ans += K;
  }
  cout << ans << endl;
  return 0;
}


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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll d, t, s;
    cin>>d>>t>>s;
    if(t * s >= d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4632
using System;

class T1PBCB
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[] A = new int[N];
		int[] B = new int[N];
		string[] vals;
		int b = 0;
		int bi = 0;
		for(int i=0; i<N; i++)
		{
			vals = Console.ReadLine().Split(' ');
			A[i] = int.Parse(vals[0]);
			B[i] = int.Parse(vals[1]);
			if(b < A[i])
			{
				b = A[i];
				bi = i;
			}
		}
		Console.WriteLine(A[bi] + B[bi]);
	}
}


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

using namespace std;

struct Restaurant {
  int id;
  string city;
  int point;
};

int main(int argc, const char *argv[])
{
  int n;
  cin >> n;

  std::vector<Restaurant> restaurants;
  for (int i = 0; i < n; i++) {
    Restaurant r;
    r.id = i + 1;
    cin >> r.city;
    cin >> r.point;
    restaurants.push_back(r);
  }
  
  sort(restaurants.begin(), restaurants.end(),
      [](auto &a, auto &b) {
        if (a.city != b.city) {
          return a.city < b.city;
        } else {
          return b.point < a.point;
        }
      });
  
  for (auto &r : restaurants) {
    cout << r.id << "\n";
  }
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

int main() {
    string S;
    cin >> S;

    string divide[4] = {
        "dream",
        "dreamer",
        "erase",
        "eraser"
    };

    reverse(S.begin(), S.end());

    rep(i,4) {
        reverse(divide[i].begin(), divide[i].end());
    }

    bool ans = true;

    for(int i=0; i<S.size(); ) {
        bool can = false;

        for(int j=0; j<4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can = true;
                i += d.size();
            }
        }

        if (!can) {
            ans = false; 
            break;
        }
    }

    cout << ((ans == true) ? "YES" : "NO") << endl;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main(){
  char s[11],r[1000];
  int n,c=0;
  scanf("%s %d",s,&n);
  while(n--){
    scanf("%s",r);
    strcat(r,r);
    if(strstr(r,s))c++;
  }
  printf("%d\n",c);
  return 0;
}
  

Measured memory_bytes: 616
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n>>a>>b;
    sum=n/a;
    if(n%a) sum++;
    sum*=b;
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<numeric>

using namespace std;

int main() {
    long long buf, ans=1;
	int N;
	bool flag = false;
	bool over = false;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> buf;
		if (buf == 0) {
			cout << 0;
			flag = true;
			break;
		}
		else if (ans * buf <= 1000000000000000000 && ans * buf > 0) {
			ans = ans * buf;
		}
		else if (ans * buf > 1000000000000000000 || ans * buf < 0) {
			over = true;
		}
	}
	if (!flag && !over)cout << ans;
	if (!flag && over)cout << -1;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,ans=9999999999999999,i,ok=0;
    cin>>n;
    ///cout<<ans el;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            ans=min(ans,i-1+n/i-1);
            ok++;
        }
    }
    if(!ok) ans=n-1;
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3608
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

int main()
{
    string S;
    cin >> S;
    regex re("A[a-z]+C[a-z]+");
    if (regex_match(S, re)) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    int ans[1000][11][21], p = 0;
    for (int y = 999; y >= 1; y--) {
        for (int m = 10; m >= 1; m--) {
            int ed = (y % 3 == 0 || (m % 2) == 1) ? 20 : 19;
            for (int d = ed; d >= 1; d--) {
                ans[y][m][d] = ++p;
            }
        }
    }

    int C;
    cin >> C;

    while (C-- > 0) {
        int y, m, d;
        cin >> y >> m >> d;
        cout << ans[y][m][d] << endl;
    }
}

Measured memory_bytes: 2060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {

    ll N; cin >> N;

    ll ans = 0;
    for (ll i = 2; i * i <= N; ++i) {

        int e = 0;
        while (N % i == 0) {
            ++e;
            N /= i;
        }
        
        int k = 0;
        while (k * (k + 1) / 2 <= e) ++k;
        if (k * (k + 1) / 2 > e) --k;
        
        ans += k;
    }

    if (N != 1) {
        ++ans;
    }

    cout << ans << endl;

    return 0;
}









Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;

ll N, P, A;

int main() {
  cin >> N >> P;
  for (int i = 0; i < N; i++)
  {
    cin >> A;
    if(A&1) {
      cout << (1LL<<~-N);
      return 0;
    }
  }
  if(P) cout << 0;
  else cout << (1LL<<N);
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

def main():
    x,n = inpl()
    Pls = inpl()

    for k in range(100):
        if x-k not in Pls:
            print(x-k)
            return
        elif x+k not in Pls:
            print(x+k)
            return
main()


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

map<string, int> m;

string itos(int number) {
     stringstream ss;
     ss << number;
     return ss.str();
}


int cal(string s){
	int ret = 0;
	rep(i, s.size()){
		int n = 1;
		if(isalpha(s[i])) ret += m[s.substr(i, 1)];
		else{ ret += stoi(s.substr(i, 1)) * m[s.substr(i+1, 1)]; i++;}
	}
	return ret;
}

int main(){
	m["m"] = 1000; m["c"] = 100; m["x"] = 10; m["i"] = 1;
	int p;
	cin >> p;
	rep(q, p){
		string s, t;
		cin >> s >> t;
		int ret = cal(s) + cal(t);
		string r;
		if(ret / 1000 != 0){if(ret/1000 > 1) r += itos(ret/1000); r +=  "m"; ret -= 1000*(ret/1000);}
		if(ret / 100 != 0){if(ret/100 > 1) r += itos(ret/100);r += "c"; ret -= 100*(ret/100);}
		if(ret / 10 != 0){if(ret/10 > 1) r += itos(ret/10);r +="x"; ret -= 10*(ret/10);}
		if(ret / 1 != 0){if(ret/1 > 1) r += itos(ret/1);r += "i"; ret -= 1*(ret/1);}
		cout << r << endl;
	}
}

Measured memory_bytes: 1244
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll int
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
ll n,m;




//注意

vector<set<ll>> s(200020);
vector<pair<ll ,bool>> f(2000020);
deque<ll> q;


void search(){

   // cout<<endl;
    search();
}

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

    ll c,d,maxi=0,mini=INF,sum=0;
    string str;
    cin>>n>>m;
    vector<ll> a(m);
    vector<ll> b(m);
    s.resize(n);
    f.resize(n);
    rep(i,n) f[i].second=false;
    rep(i,m){
        cin>>c>>d;
        c--;
        d--;
        s[c].insert(d);
        s[d].insert(c);
    }
    q.push_back(0);
    while(!q.empty()){
    if(q.size()==0) continue;;
    ll num=q.front();
    q.pop_front();
    //if(f[num].second==true) return;
    //cout<<"num= "<<num<<" ";
    for(auto itr=s[num].begin();itr!=s[num].end();++itr){
        //cout<<*itr<<" ";
        if(f[*itr].second==false){
            f[*itr].second=true;
            f[*itr].first=num;
            q.push_back(*itr);
        }
    }
    }    ll flag=1;
    rep(i,n){
        if(f[i].second==false) flag=0;
    }
    if(flag==0) No;
    else{
        Yes;
        for(ll i=1;i<n;i++){
            cout<<f[i].first+1<<endl;
        }
    }

    return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string c1, c2, c3;
	cin >> c1;
	cin >> c2;
	cin >> c3;
	cout << c1[0] << c2[1] << c3[2];
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int num[4][4]={{2, 5, 4, 3}, {0, 7, 6, 1}, {1, 6, 5, 2}, {3, 4, 7, 0}};
unordered_map<ll, ll> mp, mp2;
ll ans;
ll c2[8];
void dfs(int i){
	if(i==4){
		ll ans1=1;
		for(auto p:mp2){
			ll x=mp[p.first];
			for(ll l=0; l<p.second; l++) ans1*=(x-l);
		}
		ans+=ans1;
		return;
	}
	for(int j=0; j<4; j++){
		ll p=1, c=0;
		for(int k=0; k<4; k++){
			c+=c2[num[i][(j+k)%4]]*p;
			p*=1000;
		}
		if(mp.find(c)==mp.end()) continue;
		mp2[c]++;
		dfs(i+1);
		mp2[c]--;
	}
}
int main()
{
	int n;
	cin>>n;
	vector<ll> c;
	for(int i=0; i<n; i++){
		ll c1[4], cp[4];
		for(int j=0; j<4; j++) cin>>c1[j];
		for(int j=0; j<4; j++){
			ll p=1; cp[j]=0;
			for(int k=0; k<4; k++){
				cp[j]+=(c1[(j+k)%4]*p);
				p*=1000;
			}
		}
		sort(cp, cp+4);
		mp[cp[0]]++;
	}
	for(auto p:mp) c.push_back(p.first);
	for(int i=0; i<c.size(); i++){
		ll c1=c[i];
		for(int j=0; j<4; j++){
			c2[j]=c1%1000;
			c1/=1000;
		}
		for(int j=0; j<c.size(); j++){
			for(int k=0; k<4; k++){
				ll c3=c[j];
				for(int l=0; l<4; l++){
					c2[4+(k+l)%4]=c3%1000; c3/=1000;
				}
				mp2.clear(); mp2[c[i]]++; mp2[c[j]]++;
				dfs(0);
			}
		}
	}
	cout<<ans/6<<endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
int h, w;
int sx, sy, tx, ty;
bool inrange(int i, int j) {
	return i >= 0 && i < h&&j >= 0 && j < w;
}
int dfs(vvi &v, int i, int j, int cnt) {
	if (cnt == 10)return INF;
	int ret = INF;
	REP(k, 4) {
		int ni = i + dx[k * 2], nj = j + dy[k * 2];
		if (inrange(ni, nj) && v[ni][nj] == 0) {
			if (tx == ni && ty == nj)return cnt + 1;
			while (inrange(ni + dx[k * 2], nj + dy[k * 2]) && v[ni + dx[k * 2]][nj + dy[k * 2]] == 0) {
			
				ni += dx[k * 2];
				nj += dy[k * 2];
				if (tx == ni && ty == nj)return cnt + 1;
			}
		
			if (!inrange(ni+dx[k*2], nj+dy[k*2])) {
				continue;
			}
			else {
				assert(v[ni+dx[k*2]][nj+dy[k*2]] == 1);
				v[ni+dx[k*2]][nj+dy[k*2]] = 0;

				ret = min(ret, dfs(v, ni, nj, cnt + 1));
				v[ni+dx[k*2]][nj+dy[k*2]] = 1;

			}

		}
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> w >> h) {
		if (h == 0 && w == 0)break;
		vvi v(h, vi(w));
		REP(i, h)REP(j, w)cin >> v[i][j];

		REP(i, h) {
			REP(j, w) {
				if (v[i][j] == 2) {
					sx = i;
					sy = j;
					v[i][j] = 0;
				}
				else if (v[i][j] == 3) {
					tx = i;
					ty = j;
					v[i][j] = 0;
				}
			}
		}
		int d = dfs(v, sx, sy, 0);
		if (d == INF)cout << -1 << endl;
		else cout << d << endl;
	}


}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  i64 ans = 0;
  for (i64 i = 1; i <= N; i++)
    if (i % 3 != 0 && i % 5 != 0)
      ans += i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;

namespace abc123_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadLong();
      var l = CIn.ReadLongArray(5);

      Array.Sort(l);

      Console.WriteLine((n - 1) / l[0] + 5);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 13396
#c
x, k, d=map(int, input().split())
rest = k - (abs(x) // abs(d))

if abs(x) >= k*d:
    if x >= 0:
        print(abs(x-(k*d)))
    else:
        print(abs(x+(k*d)))

else:
    if x >= 0:
        near = x- d*(abs(x) // abs(d))
    else:
        near = x+ d*(abs(x) // abs(d))

    if rest % 2 == 0:
        print(abs(near))
    else:
        if near >= 0:
            print(abs(near - d))
        else:
            print(abs(near + d))

Measured memory_bytes: 9156
#include<stdio.h>
int main()
{
    int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int num2;
    scanf("%d",&num2);

    printf("%d",num[num2 - 1]);

    return 0;
}

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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

static const auto io_sync_off = []() {
    // turn off sync
    std::ios::sync_with_stdio(false);
    // untie in/out streams
    std::cin.tie(nullptr);
    return nullptr;
}();

int main(int argc, char *argv[]) {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vi a(n), b(m);

    REP(i, n) cin >> a[i];
    REP(j, m) cin >> b[j];

    bool ck = true;
    for (int z = x + 1; z <= y; z++) {
        bool f = true;
        REP(i, n) if (a[i] >= z) { f = false; break; }
        if (f) REP(j, m) if (b[j] < z) { f = false; break; }
        if (f) { ck = false; break; }
    }

    if (ck) cout << "War" << endl; else cout << "No War" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
#define inf 10e18L+5
using namespace std;
ll sum(ll l,ll r,ll a[])
{
    ll s=0;
    for(int i=l;i<=r;++i)
    {
        s+=a[i];
    }
    return s;
}
int main()
{
    ll n;
    scanf("%lld",&n);
    ll dp[n+5][n+5];
    ll a[n];
    for(int i=0;i<n;++i)
    {
        scanf("%lld",&a[i]);
    }
    for(int l=n-1;l>-1;--l)
    {
        for(int r=l;r<n;++r)
        {
            if(l==r)
            {
                dp[l][r]=0;
            }
            else
            {
                ll s=sum(l,r,a);
                dp[l][r]=inf;
                for(int i=l;i<r;++i)
                {
                    dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+s);
                }
            }
        }
    }
    printf("%lld",dp[0][n-1]);
    return 0;
}




Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
    int a,c,b;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c){
        printf("1\n");
    }
    else if(a==b||b==c||a==c){
        printf("2\n");
    }
    else {
        printf("3\n");
    }



    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const long long  mod = 1000000007;



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

  string t ="MARCH";
  ll mp[5] = {0};
  rep(i,n){
    string s;
    cin >> s;
    rep(i,5){
      if(s[0] == t[i]) mp[i]++;
    }
  }

  ll ans = 0;
  rep(i,3){
    for(int j = i+1; j < 4; j++){
      for(int k = j+1; k < 5; k++){
        ans += mp[i]*mp[j]*mp[k];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
r1 = list(map(int,input().split()))
r2 = list(map(int,input().split()))
r3 = list(map(int,input().split()))
r1.extend(r2)
r1.extend(r3)
N = int(input())
for i in range(N):
    num = int(input())
    if num in r1:
        r1[r1.index(num)] = 0
ans = False
if sum(r1[::3]) == 0 or sum(r1[1::3]) == 0 or sum(r1[2::3]) == 0:
    ans = True
elif sum(r1[:3]) == 0 or sum(r1[3:6]) == 0 or sum(r1[6:]) == 0:
    ans = True
elif (r1[0]+r1[4]+r1[8]) == 0 or (r1[2]+r1[4]+r1[6]) == 0:
    ans = True
if ans:
    print("Yes")
else:
    print("No")

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

arr1 = Array.new(100, 0)
arr2 = Array.new(100, 0)
a.upto(b - 1){|i| arr1[i] = 1}
c.upto(d - 1){|i| arr2[i] = 1}

count = 0
arr1.zip(arr2){|i, j| count += i * j}
puts count

Measured memory_bytes: 1788
require "set"
 
n = gets.to_i
a = gets.split.map(&:to_i).sort

m = 10**6
num = a.tally # 重複判定
seen = Set.new

ans = 0
a.each do |i|
  next if seen === i
  ans += 1 if num[i] == 1 # 昇順に見ているので重複してなければカウント

  # iの倍数を記録していく
  i.step(m, i) do |j|
    seen << j
  end
end

puts ans


Measured memory_bytes: 73648
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  13 - 6 - 2020 +   13 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int, int>
#define pb push_back
#define pi acos(-1.0)
#define eps 1e-12
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    string c;
    cin>>c;
    if (c[2] == c[3] && c[4] == c[5]){
        puts("Yes\n");
    }
    else{
        puts("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N >> M;

  ll K = (ll)sqrt(M);

  if(N<=K){
    ll min_ans = 1;
    for(ll i=N; i<=K+1; ++i){
      if(M%i!=0) continue;
      cout << M/i << "\n";
      return 0;
    }
    for(ll i=N-1; i>0; --i){
      if(M%i!=0) continue;
      cout << i << "\n";
      return 0;
    }
  }else{
    ll min_ans = 1;
    for(ll i=M/N; i>0; --i){
      if(M%i!=0) continue;
      cout << i << "\n";
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int map[100][100];
int b[100];
int c[100];
int main(void) {
	int x, y;
	cin >> x >> y;
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			cin >> map[i][j];
		}
	}
	for (int i = 0; i < y; i++) {
		cin >> b[i];
	}
	for (int j = 0; j < x; j++) {
		int sum = 0;
		for (int i = 0; i < y; i++) {
			sum += map[j][i] * b[i];
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    bool key=true;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
        if(a[i]%3!=0&&a[i]%5!=0){
            key=false;
        }
        }
    }
    if(key) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll ans = (n / (a + b)) * a;
    ll cnt = (n/(a+b)) * (a + b);
    ans += min(a, n-cnt);

    cout << ans << endl; 
}

Measured memory_bytes: 256
use std::thread;

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_s = input.next().unwrap();
    let ans: Vec<char> = "CODEFESTIVAL2016".chars().collect();
    let mut wrong = 0;
    for (i, c) in in_s.chars().enumerate() {
        if c != ans[i] {
            wrong += 1;
        };
    }
    println!("{:?}", wrong);
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vector<int>day[100010];
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		day[a].push_back(b);
	}
	int ans = 0;
	priority_queue<int>pq;
	for(int i=1;i<=m;i++){
		for(auto it:day[i]){
			pq.push(it);
		}
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans <<"\n";
}


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

int main() {
    int H,W;

    while ( 1 ) { 
        cin >> H >> W;
        if ( H==0 && W==0 ) break;
        for (int i=1;i<=H;i++) {
            if ( i==1 || i==H) {
                for (int j=1;j<=W;j++) {
                    cout << "#";
                }   
                cout << endl;
            }else {
                cout << "#";
                for (int j=2;j<W;j++) {
                    cout << ".";
                }   
                cout << "#" << endl;
            }   
        }   
        cout << endl;
    }   

    return 0;
}



Measured memory_bytes: 3072
import copy
n = int(input())
p = list(map(int, input().split()))

A = copy.copy(p)
A.sort()
cnt = 0

for i in range(n):
    if A[i] != p[i]:
        cnt += 1

if cnt == 2 or cnt == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9256
def p(u):
 if u+1:print(s,u,end=s);p(T[u]);p(T[u+N])
def i(u):
 if u+1:i(T[u]);print(s,u,end=s);i(T[u+N])
def o(u):
 if u+1:o(T[u]);o(T[u+N]);print(s,u,end=s)
s=''
N=int(input())
T=[0,0]*N
for _ in[0]*N:
 e=list(map(int,input().split()))
 T[e[0]],T[e[0]+N]=e[1:]
r=(set(range(N))-set(T)).pop()
print('Preorder');p(r)
print('\nInorder');i(r)
print('\nPostorder');o(r)
print()


Measured memory_bytes: 5624
int main(){
    char s[64],t[64];
    int i;
    scanf("%s%s",s,t);
    for(i=0;i<64;i++){
        if(s[i] == 0){break;}
        if(t[i] == 0){printf("%c",s[i]);break;}
        printf("%c%c",s[i],t[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,A,B,C[100000];
bool func(int X){
  int ret=0;
  rep(i,0,N) ret+=(max(0ll,(C[i]-B*X))+A-B-1)/(A-B);
  if(ret<=X) return 1;
  return 0;
}
signed main(){
  cin>>N>>A>>B;
  rep(i,0,N) cin>>C[i];
  int left=0,right=1000000000*N/B;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)) right=mid;
    else left=mid;
  }
  int ans=right;
  if(func(left)) ans=left;
  cout<<ans<<endl;
  }



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

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i = 0; i < N; i++) cin >> A[i];
    long long tmp = A[0], ans = 0;
    for(long long i = 1; i < N; i++){
        if(A[i] >= tmp) tmp = A[i];
        else ans += tmp - A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4776
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

a, b = ril()
x = str(a) * b
y = str(b) * a
print(min(x, y))

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

int main(int argc, char *argv[]) {
  int a, b;
  std::cin >> a >> b;

  std::string op = "==";
  if (a > b) {
    op = ">";
  }
  if (a < b) {
    op = "<";
  }
  std::cout << "a " << op << " b" << std::endl;
}



Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main(void){
  int N, T;
  cin >> N >> T;
  int c[N], t[N];
  int i;
  for(i=0; i<N; i++)
    cin >> c[i] >> t[i];

  int min = 1000; //0番目を仮の最小値とする
  int exist_min = 0; //最小値が存在するかのflag
  for(i=0; i<N; i++){
    if(t[i] <= T){
      exist_min = 1;
      if(c[i] < min)
	min = c[i];
    }
  }

  if(exist_min)
    cout << min << endl;
  else
    cout << "TLE" << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b=0,c=0;
  scanf("%d",&a);
  for(int i=0; i<a; i++){
    int d;
    scanf("%d",&d);
    if(b<d){
      c+=b;b=d;
    }else{
      c+=d;
    }
  }
  printf(c>b?"Yes":"No");
  return 0;}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
X = [0]*N

S = sum(A)
ans = 10**11

for i in range(N-1):
    X[i+1] = X[i] + A[i]

print(min(abs(S-2*X[i]) for i in range(1,N)))

Measured memory_bytes: 24812
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


int main(){
    int a;
    cin >> a;
    cout << a * a <<endl;
}



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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

// -------------------------------------------

const string YES = "Yes";

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
  map<ll,vector<ll>> m;
  rep(i,N) m[i] = vector<ll>();
  rep(i,M) {
    m[A[i]].push_back(B[i]);
    m[B[i]].push_back(A[i]);
  }
  queue<ll> q;
  q.push(1);
  vector<ll> v(N+1, 0);
  v[1] = 1;
  while(!q.empty()) {
    ll now = q.front();
    q.pop();
    for(auto next : m[now]) {
      if(v[next]) continue;
      q.push(next);
      v[next] = now;
    }
  }
  std::cout << YES << std::endl;
  for(int i=2; i<=N; i++)
    std::cout << v[i] << std::endl;
}

int main(){
    long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 21548
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
char a,b;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b;
    if(a=='H'){
        if(b=='H')Cout("H");
        else Cout("D");
    }
    else{
        if(b=='D')Cout("H");
        else Cout("D");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int ans = r*100+g*10+b;

  if (ans%4 == 0){
    cout << "YES" << endl;
  } else{
    cout << "NO" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        check(S);
        System.out.println("yes");
    }
    static void check(String S){
        int [] num = new int [26];
        for(int i=0; i<S.length(); i++){
            int A = S.charAt(i)-'a';
            num[A]++;
            if(num[A]>=2){
                System.out.println("no");
                System.exit(0);
            }
        }
    }
}

Measured memory_bytes: 22996
n=int(input())
arr=list(map(int,input().split()))
cnt=0
while 1:
  tmp=[]
  flag=0
  for i in range(n):
    val=arr[i]
    if val<=n-1:
      flag+=1
    if (val+1)%(n+1):
      times=(val+1)//(n+1)
    else:
      times=(val+1)//(n+1)
    arr[i]-=times*n
    tmp.append(times)
  if flag==n:
    break
  sums=sum(tmp)
  cnt+=sums
  for i in range(n):
    arr[i]+=(sums-tmp[i])
print(cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb(x) push_back(x)
using namespace std;
typedef long long i64;
const int N = 5e5+5;
int n, d[N], v[N], q[N], l, r; char s[N]; i64 ans; vector<int> e[N];
int main()
{
    scanf("%s", s+1), n = strlen(s+1)+1, l = 1;
    for(int i = 1; i < n; ++i) 
        if(s[i] == '<') e[i].pb(i+1), ++d[i+1];
        else e[i+1].pb(i), ++d[i];
    for(int i = 1; i <= n; ++i) if(!d[i]) q[++r] = i;
    while(l <= r) 
    {
        int x = q[l++];
        for(int y:e[x]) 
        {
            v[y] = max(v[y], v[x]+1);
            if(--d[y] == 0) q[++r] = y;
        }
    }
    for(int i = 1; i <= n; ++i) ans += v[i]; printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 37500
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    priority_queue<int> pq;
    vi a(n);
    REP(i, n)
    {
        int tmp;
        cin >> tmp;
        pq.push(tmp);
        a[i] = tmp;
    }

    int v1 = pq.top();
    pq.pop();

    int v2 = pq.top();
    pq.pop();

    REP(i, n)
    {
        if(a[i] == v1)
            cout << v2 << endl;
        else
        {
            cout << v1 << endl;
        }
    }

}

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

using ll = long long;

ll n, a[2];
ll S[100010];
std::vector<ll> A[2];
ll dp[100010][2];

int main() {
    std::cin >> n >> a[0] >> a[1];
    
    for(int i = 0; i < n; ++i) {
        std::cin >> S[i];
        
        if(i != 0) {
            if(S[i] - S[i - 1] < a[0]) {
                A[0].push_back(i - 1);
            }
            if(S[i] - S[i - 1] < a[1]) {
                A[1].push_back(i - 1);
            }
        }
    }
    
    dp[0][0] = dp[0][1] = 1;
    
    for(int i = 1; i < n; ++i) {
        for(int j = 0; j < 2; ++j) {
            int l = std::upper_bound(S, S + i, S[i] - a[j]) - S - 1;
            
            if(l == -1) {
                if(std::lower_bound(A[!j].begin(), A[!j].end(), i - 1) == A[!j].begin()) {
                    dp[i][j] += 1;
                }
            }else {
                if(l == i - 1) {
                    dp[i][j] += dp[l][!j] + dp[l][j];
                }else {
                    if(std:: lower_bound(A[!j].begin(), A[!j].end(), i - 1) <= std::lower_bound(A[!j].begin(), A[!j].end(), l + 1)) {
                        dp[i][j] += dp[l + 1][!j];
                    }
                }
            }
            dp[i][j] %= ll(1e9 + 7);
        }
    }
    std::cout << (dp[n - 1][0] + dp[n - 1][1]) % ll(1e9+7) << std::endl;
}

Measured memory_bytes: 4332
#include <stdio.h>

int main(void)
{
  char O[100],E[100],ans[200];
  int i = 0,j = 0,k;

  fgets(O,100,stdin);
  fgets(E,100,stdin);

 while(1)
    {
      if(O[i] != '\0')
        {
          ans[k] = O[i];
          i++;
          k++;
        }
      if(E[j] != '\0')
        {
          ans[k] = E[j];
          j++;
          k++;
        }

      if(O[i] == '\0' && E[j] == '\0')
        {
          ans[k] = '\0';
          break;
        }
    }

  printf(ans);
  return 0;
}


Measured memory_bytes: 128