akhauriyash/Code-Regression huggingface dataset:
count = 0


def dfs(num):
    global count
    if len(str(num)) == 10:
        return
    else:
        tmp = int(str(num)[len(str(num))-1])
        for j in range(tmp-1, tmp+2):
            if 0 <= j <= 9:
                out = int(str(num) + str(j))
                ans.append(out)
                count += 1
                dfs(out)


if __name__ == "__main__":
    k = int(input())

    # まず100000個のルンルン数を列挙しよう

    ans = list()

    for i in range(1, 10):
        ans.append(i)
        count += 1
        dfs(i)

    ans.sort()

    print(ans[k-1])


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << 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; }

int main()
{   
    int n, m, k;
    cin >> n >> m >> k;
    vi a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(j, m) cin >> b[j];

    vll sb(m+1);
    sb[0] = 0;
    rep(i, m) sb[i+1] = sb[i] + b[i];
    

    int ans = 0;
    ll sum = 0;
    rep(i, n+1) {
        if(i > 0) sum += a[i-1];
        if(sum > k) break;
        int num = upper_bound(all(sb), k - sum) - sb.begin() - 1;
        chmax(ans, num + i);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	int n;
	cin >> n;
	n %= 10;
	if (n == 3) {
		cout << "bon" << endl;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon" << endl;
	}
	else cout << "hon" << endl;


}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

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

  int x[n], y[n], i, j;
  for (i=0; i<2; i++) {
    for (j=0; j<n; j++) {
      if (i==0) scanf("%d", &x[j]);
      else scanf("%d", &y[j]);
    }
  }

  double ans=0, max=0;
  for (i=0; i<n; i++) {
    ans+=abs(x[i]-y[i]);
    if (abs(x[i]-y[i])>max) max=abs(x[i]-y[i]);
  }
  printf("%lf\n", ans);

  ans=0;
  for (i=0; i<n; i++) {
    ans+=pow(x[i]-y[i], 2.0);
  }
  printf("%lf\n", pow(ans, 1/2.0));

  ans=0;
  for (i=0; i<n; i++) {
    ans+=abs(pow(x[i]-y[i], 3.0));
  }
  printf("%lf\n", pow(ans, 1/3.0));

  printf("%lf\n", max);
  return 0;
}


Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int n, s, count;

void DFS(int sum, int pre, int depth)
{
	if(depth > n || sum > s)
	{
		return;
	}
	else if(sum == s && depth == n)
	{
		++count;
		return;
	}
	else
	{
		for(int i = pre + 1; i < 10; ++i)
		{
			DFS(sum + i, i, depth + 1);
		}
	}
}

void solve()
{
	while(cin >> n >> s, n || s)
	{
		count = 0;
		for(int i = 0; i < 10; ++i)
		{
			DFS(i, i, 1);
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(int argc,char **argv)
{
  int A,B,C,D;

  cin >> A >> B >> C >> D;

  int st = max(A,C);
  int end = min(B,D); 
  
  if(end-st <= 0)
    cout << 0 << endl;
  else
    cout << (end-st) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t;
  cin>>n>>t;
  vector<int >nos(n,0);
  for(int i=0;i<n;i++)cin>>nos[i];
  int tot=0;
  for(int i=0;i<n-1;i++){
  tot+=min(t,nos[i+1]-nos[i]);
  	}
  cout<<tot+t;
}

Measured memory_bytes: 3964
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

long long int N;


bool func(string s){
	bool seven=false, five=false, three=false;
	for(int i=0;i<s.size();i++){
		if(s[i]=='7'){
			seven=true;
		}else if(s[i]=='5'){
			five=true;
		}else if(s[i]=='3'){
			three=true;
		}else{
			return false;
		}
	}
	if(seven && five && three){
		return true;
	}
	return false;
}

long long int dfs(string s){
	long long int ret=0;
//	cout<<s<<endl;
	
	if(s != "" && stoll(s) > N){
//		cout<<s + "b"<<endl;
		return 0;
	}
//	cout<<s + "c"<<endl;
	if(func(s)) ret = 1;
	ret += dfs(s + "7");
	ret += dfs(s + "5");
	ret += dfs(s + "3");
//	cout<<s + "a"<<endl;
	return ret;
}

int main(){
	
	cin>>N;

	cout<<dfs("")<<endl;
	return 0;
}

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


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            char[] S = sc.chararr;
            int sum = 700;

            for(int i=0; i<3; i++)
            {
                if(S[i] == 'o')
                {
                    sum += 100;
                }
            }

            wr.wri(sum);

        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

int main() {
	string S;
	cin >> S;
	int sum = 0;

	if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0)!=S.at(2)) {
		sum++;
	}
	if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1)) {
		sum++;
	}
	if (S.at(0) == S.at(3) && S.at(2) == S.at(1) && S.at(0) != S.at(2)) {
		sum++;
	}

	if (sum) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

map <int, int> M;

void solution() {
    int n, x;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        if (M[x]) {
            cout << "NO" << endl;
            return;
        }
        M[x]++;
    }
    cout << "YES" << endl;
    
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

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

int a;

int main() {
	string s, g;
	cin >> s >> g;
	int jum = 0;
	for(int k = 0; k<s.length(); k++){
		if(s[k]!=g[k]){
			jum++;
		}
	}
	cout << jum << '\n';
}

Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
// vector<string> vs[110];
bool cmp(pair<string,int> &p1 , pair<string,int> &p2){
	if(p1.first!=p2.first)
		return p1.first<p2.first;
	else
		return p1.second>p2.second;
}
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n; cin >> n;
    vector<pair<string,int> > v;
    map<int,int> mp;
    for(int i=0;i<n;i++){
    	string s;
    	int a;
    	cin >> s >>a;
    	v.pb(mb(s,a));
    	mp.insert(mb(a,i));
    }
   	sort(v.begin(),v.end(),cmp);
   	for(int i=0;i<n;i++){
   		// cout << v[i].first<< " " << v[i].second << endl;
   		cout << (*(mp.find(v[i].second))).second+1 << endl;
   	}
    








    // // vector<pair<int,string> > v;
    // // map<int,int > mp;
    // for(int i=0;i<n;i++){
    // 	string s;
    // 	int a;
    // 	cin >> s >> a;
    // 	vs[s]=a;
    // 	mp.insert(mb(a,i));
    // }
    // sort(v.begin(),v.end());
    // vector<pair<string,int> > v2;
    // for(int i=0;i<n;i++){
    // 	string a = to_string(v[i].first);
    // 	v[i].second+=a;
    // 	// cout << v[i].second << endl;
    // 	v2.pb(mb(v[i].second,v[i].first));
    // }
    // sort(v2.begin(),v2.end());
    // for(int i=0;i<n;i++){
    // 	 cout << v2[i].first << " " << v2[i].second << endl;
    // 	pair<int,int> p=*(mp.find(v2[i].second));
    // 	cout << p.second+1 << endl;
    // }


    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007

void solve()
{
    int n;cin>>n;
    int dp[n][3];
    for(int i=0;i<n;i++)
    {
        dp[i][0]=dp[i][1]=dp[i][2]=0;
    }
    for(int i=0;i<n;i++)
    {
        int a,b,c;cin>>a>>b>>c;
        if(i==0)
        {
            dp[i][0]=a;dp[i][1]=b;dp[i][2]=c;
        }
        else
        {
            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
            dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
        }
    }
    int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;

    while(t--)
    {
      solve();
    }
    return 0;
}


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

int main() {
	int N,T;
	cin >> N >> T;
	int c,t,cmin=10000;
	for (int i = 0; i < N; ++i) {
		cin >> c >> t;
		if(T >= t && cmin > c){
			cmin = c;
		}
	}
	if(cmin == 10000){
		cout << "TLE" << endl;
	}else{
		cout << cmin << endl;
	}
}


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

struct student
{
  int id;
  int record;
};


int main()
{
  int n;
  std::cin >> n;
  std::vector<student>a(n);
  std::vector<int> vec(n);
  for (int i = 0; i < n; i++)
  {
    std::cin >> vec[i];
  }
  
  std::vector<int> reverse(n);
  for (int i = 0; i < n; i++)
  {
    reverse[vec[i]-1] = i;
  }
  
  // std::sort(a.begin(), a.end(), 
  // [](student& left, student& right)
  // {return left.record < right.record;});
  
  for (int i = 0; i < n; i++)
  {
    std::cout << reverse[i]+1 << " ";
    // std::cout << a[i].record << " ";
  }
  
  
  return 0;
}

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

using namespace std;

int main(){

    int n,x,v[100];

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

    sort(v,v+n);
    int cont=0;

    for(int j=0;j<n;j++){
        if(v[j] != v[j+1]){
            cont++;
        }
    }

    cout << cont << endl;
    

    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split(" "))
    num = [-1] * n
    if m == 0 and n == 1:
        print("0")
        return
    else:
        for i in range(m):
            s, c = map(int, input().split(" "))
            if num[s - 1] != -1 and num[s - 1] != c:
                print("-1")
                return
            num[s - 1] = c
    ans = ""
    if num[0] == 0 and n > 1:
        print("-1")
        return
    first = True
    for v in num:
        if first:
            if v == -1:
                ans += "1"
            else:
                ans += str(v)
            first = False
        else:
            if v == -1:
                ans += "0"
            else:
                ans += str(v)
    print(ans)


if __name__ == '__main__':
    main()


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n, k;
int a[5005];
bool f(int s) {
    vector<vector<int>> dp(n + 1, vector<int>(k, 0));

    dp[0][0] = 1;
    rep(i, n) rep(j, k) {
        dp[i + 1][j] |= dp[i][j];
        if (i != s && j >= a[i]) dp[i + 1][j] |= dp[i][j - a[i]];
    }

    loop(j, max(0, k - a[s]), k) if (dp[n][j] > 0) return true;

    return false;
}

void solve() {
    cin >> n >> k;

    rep(i, n) cin >> a[i];

    sort(a, a + n);

    int l = -1, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;

        if (f(mid)) r = mid;
        else l = mid;
    }

    cout << l + 1 << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 98232
#include<iostream>

int main() {
	long long N;
	long long S = 0;

	std::cin >> N;

	long long temp = N;

	while (temp)
	{
		S += temp % 10;
		temp /= 10;
	}

	if ((N%S) == 0)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int A[2][N];
    for(int a = 0; a < 2; ++a) {
        for(int b = 0; b < N; ++b) {
            cin >> A[a][b];
        }
    }
    int ans = 0;
    for(int a = 0; a < N; ++a) {
        int temp = 0;
        for(int b = 0; b < N; ++b) {
            if(a < b){
                temp += A[1][b];
            }else if(a == b){
                temp += A[0][b] + A[1][b];
            }else{
                temp += A[0][b];
            }
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repR(i,a,b)for(int i=a;i>=b;i--)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define vec vector<int>
#define vecl vector<long long int>
#define sz(x) (int) (x).size()
#define f(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define el '\n'
#define c(m) cout<<"-1"<<endl
#define YY  cout<<"YES"<<endl
#define NY  cout<<"NO"<<endl
#define i(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
const int MOD=1000000007;
const int Nm=-MOD;
const int N=100005;
typedef long long ll;
ll add(ll x, ll y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

ll inv(ll x)
{
    return binpow(x, MOD - 2);
}

ll divide(ll x, ll y)
{
    return mul(x, inv(y));
}


ll fact[N];

void precalc()//factorial
{
    fact[0] = 1;
    for(int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

ll C(ll n, ll k)//nCr
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
vector<int>v[N];
int vis[N];
void dfs(int i,int p)
{ vis[i]=1;
   for(auto it:v[i])
   {
          if(it==p||vis[it]==1)
          continue;
          else
          {
              
              dfs(it,i);
          }
          
   }
}
int main()
{ ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int tc;
    tc=1;
   //cin>>tc;
    while(tc--)
    { f(vis);
          int n,m;
          cin>>n>>m;
          int m1=m;
          while(m--)
          {
              int a,b;
              cin>>a>>b;
              v[a].pb(b);
              v[b].pb(a);
          }
          int ctr=0;

   repA(i,1,n)
{
    if(vis[i]==0)
    {
        ctr++;
        dfs(i,-1);
    }
    
}
cout<<ctr-1;

          
    }

	return 0;
}




Measured memory_bytes: 10412
n = int(input())
s = str(input())
ans = s.count('.')
L = [[0, s.count('.')]]
for i in range(n):
    if s[i] == '#':
        L.append([L[i][0]+1, L[i][1]])
    else:
        L.append([L[i][0], L[i][1]-1])
    ans = min(ans, L[-1][0] + L[-1][1])
print(ans)


Measured memory_bytes: 30056
#include <stdio.h>
#include <ctype.h>
#include <string.h>

void strtolower(char *str)
{
	for(int i = 0; str[i]; ++i)
	{
		str[i] = tolower(str[i]);
	}
}

int main()
{
	int cnt = 0;
	char W[16], T[1024];

	scanf("%s", W);
	strtolower(W);

	while(scanf("%s", T), strcmp(T, "END_OF_TEXT"))
	{
		strtolower(T);
		if(strcmp(T, W) == 0)
		{
			++cnt;
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn =2e5+5;
const int mod=10000019;
const int inf=0x3f3f3f;
char a[maxn];
int b[maxn];
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    ll mx=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    if(k==0)
    {
        cout<<mx<<endl;
        return 0;
    }
    ll l=1,r=mx;
    ll ans_min=mx;
    while(r-l>=1)
    {
        ll mid=(l+r)/2;
        ll sum=0;
        for(int i=0; i<n; i++)
            sum+=(a[i]+mid-1)/mid-1;
        if(sum<=k)
        {
            r=mid;
            ans_min=min(mid,ans_min);
        }
        else
            l=mid+1;
    }
    cout<<ans_min<<endl;
    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

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

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>s;
      rep(i,Size(s)-8)cout<<s[i];
      cout<<"\n";
    
       
return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys
N,K,L=map(int,raw_input().split())

# https://www.kumilog.net/entry/union-find#Python%E3%81%A7%E5%AE%9F%E8%A3%85
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

ufR=UnionFind(N+1)
ufT=UnionFind(N+1)
for i in range(K):
    p,q=map(int,sys.stdin.readline().split())
    ufR.union(p,q)
for i in range(L):
    p,q=map(int,sys.stdin.readline().split())
    ufT.union(p,q)    
from collections import defaultdict
R=defaultdict(set)
T=defaultdict(set)
for i in range(1,N+1):
    R[ufR.find(i)].add(i)
    T[ufT.find(i)].add(i)

P=defaultdict(int)
for i in range(1,N+1):
    P[ufR.find(i),ufT.find(i)]+=1

for i in range(1,N+1):
    print(P[ufR.find(i),ufT.find(i)])


    


Measured memory_bytes: 193308
#include <stdio.h>

int main(void)
{
	int r, c, a[101][101] = { 0 }, i, t;

	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++)
	{
		for (t = 0; t < c; t++)
		{
			scanf("%d", &a[i][t]);

			a[i][c] = a[i][c] + a[i][t];
			a[r][t] = a[r][t] + a[i][t];
		}
		a[r][c] = a[r][c] + a[i][c];
	}

	
	for (i = 0; i <= r; i++)
	{
		for (t = 0; t <= c; t++)
		{
			printf("%d", a[i][t]);
			if (t!=c)
			{
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	lnt a, b, c, d; cin >> a >> b >> c >> d;
	cout << max({a*c, a*d, b*c, b*d}) << ln;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
    string s;
    cin>>s;
    int n = sz(s);
    if (s[n-1]=='s')s+="es";
    else s+='s';
    cout<<s<<endl;
    return;
}

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

Measured memory_bytes: 3648
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N+1];
        long max = Long.MIN_VALUE;
        long min = Long.MAX_VALUE;
        int maxPos = -1;
        int minPos = -1;
        for(int i=1;i<=N;i++){
            a[i] = sc.nextLong();
            if(max<a[i]){
                max = a[i];
                maxPos = i;
            }
            if(min>a[i]){
                min = a[i];
                minPos = i;
            }
        }
        if(max==min){
            System.out.println(0);
            System.exit(0);
        }
        if(Math.abs(max)>=Math.abs(min)){
            System.out.println(2*N-1);
            for(int i=1;i<=N;i++){
                StringBuilder sb = new StringBuilder();
                sb.append(maxPos);
                sb.append(" ");
                sb.append(i);
                System.out.println(sb.toString());
            }
            for(int i=1;i<N;i++){
                StringBuilder sb = new StringBuilder();
                sb.append(i);
                sb.append(" ");
                sb.append(i+1);
                System.out.println(sb.toString());
            }
        }
        else{
            System.out.println(2*N-1);
            for(int i=1;i<=N;i++){
                StringBuilder sb = new StringBuilder();
                sb.append(minPos);
                sb.append(" ");
                sb.append(i);
                System.out.println(sb.toString());
            }
            for(int i=N;i>=2;i--){
                StringBuilder sb = new StringBuilder();
                sb.append(i);
                sb.append(" ");
                sb.append(i-1);
                System.out.println(sb.toString());
            }
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

int main(void) {
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;

    FOR(i, A, B + 1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}


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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}

ll inf = 1e15;
ll x[200010],y[200010];
vector<ll> u[400010],d[400010],u2[400010],d2[400010];
vector<pair<ll,ll> > vec1[400010],vec2[400010];

int main()
{
	fastio;
	ll n,i,j,mi=1e15;
	cin>>n;
	string str;
	vector<pair<ll,ll> > l,r;
	for(i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		cin>>str;
		if(str=="U")
		{
			u[x[i]+y[i]].pb(x[i]);
			u2[x[i]-y[i]+200001].pb(-x[i]);
			vec1[x[i]].pb({y[i],1});
		}
		else if(str=="L")
		{
			l.pb({x[i],i});
			vec2[y[i]].pb({x[i],-1});
		}
		else if(str=="R")
		{
			r.pb({x[i],i});
			vec2[y[i]].pb({x[i],1});
		}
		else 
		{
			d[x[i]-y[i]+200001].pb(x[i]);
			d2[x[i]+y[i]].pb(-x[i]);
			vec1[x[i]].pb({y[i],-1});
		}
	}
	// sort(u.begin(),u.end());
	sort(r.begin(),r.end());
	sort(l.begin(),l.end());
	// sort(d.begin(),d.end());
	for(j=0;j<400010;j++)
	{
		sort(u[j].begin(),u[j].end());
		sort(d[j].begin(),d[j].end());
		sort(u2[j].begin(),u2[j].end());
		sort(d2[j].begin(),d2[j].end());
		sort(vec1[j].begin(),vec1[j].end());
		sort(vec2[j].begin(),vec2[j].end());
	}
    	
	for(i=0;i<sz(r);i++)
	{
		ll ind = r[i].s;
		ll sum = x[ind]+y[ind];
		ll diff = x[ind]-y[ind]+200001;
		if(!u[sum].empty())
		{
			j=upper_bound(u[sum].begin(),u[sum].end(),x[ind])-u[sum].begin();
			if(j!=sz(u[sum]))
				mi=min(mi,(u[sum][j]-x[ind])*10);
		}
		if(!d[diff].empty())
		{
			j=upper_bound(d[diff].begin(),d[diff].end(),x[ind])-d[diff].begin();
			if(j!=sz(d[diff]))
				mi=min(mi,(d[diff][j]-x[ind])*10);
		}
	}
	// cout<<mi<<endl;
	for(i=sz(l)-1;i>=0;i--)
	{
		ll ind = l[i].s;
		ll sum = x[ind]+y[ind];
		ll diff = x[ind]-y[ind]+200001;
		if(!d2[sum].empty())
		{
			j=upper_bound(d2[sum].begin(),d2[sum].end(),-x[ind])-d2[sum].begin();
			if(j!=sz(d2[sum]))
			{
				mi=min(mi,(d2[sum][j]+x[ind])*10);
				// cout<<ind<<" "<<x[ind]<<" "<<y[ind]<<" "<<mi<<" "<<d2[sum][j]<<endl;
			}
		}
		if(!u2[diff].empty())
		{
			j=upper_bound(u2[diff].begin(),u2[diff].end(),-x[ind])-u2[diff].begin();
			if(j!=sz(u2[diff]))
			{
				mi=min(mi,(u2[diff][j]+x[ind])*10);
				// cout<<mi<<endl;
			}
		}
	}
	// cout<<mi<<endl;
	for(i=0;i<400010;i++)	
	{
		ll pre=-inf;
		for(j=0;j<sz(vec1[i]);j++)
		{
			pair<ll,ll> p = vec1[i][j];
			if(p.s==-1)
				mi=min(mi,(p.f-pre)*5);
			else
				pre=p.f;
		}
		pre=-inf;
		for(j=0;j<sz(vec2[i]);j++)
		{
			pair<ll,ll> p = vec2[i][j];
			if(p.s==-1)
				mi=min(mi,(p.f-pre)*5);
			else
				pre=p.f;
		}
	}
	if(mi>=inf)
		cout<<"SAFE"<<endl;
	else
		cout<<mi<<endl;

    return 0;	
}





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

using namespace std;
using ll = long long;

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

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

  vector<vector<int>> tree(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    tree[u].push_back(v);
    tree[v].push_back(u);
  }

  // LIS
  ll inf = pow(10, 10);
  vector<ll> lis(n + 10, inf);
  // idx, lis_idx, lis_orig
  stack<array<ll, 3>> lis_updates;

  // stack (idx, p)
  stack<array<ll, 2>> st;
  st.push({0, -1});
  vector<bool> used(n, false), reverted(n, false);
  vector<int> ans(n);
  while (!st.empty()) {
    auto [idx, p] = st.top();
    st.pop();

    if (used[idx]) {
      continue;
    }

    used[idx] = true;

    // 元に戻す
    while (!lis_updates.empty() && lis_updates.top()[0] != p) {
      auto [idx, lis_idx, org] = lis_updates.top();
      lis_updates.pop();
      lis[lis_idx] = org;
    }

    // LISを求める
    auto lw_it = lower_bound(lis.begin(), lis.end(), va[idx]);
    lis_updates.push({idx, distance(lis.begin(), lw_it), *lw_it});
    *lw_it = va[idx];
    ans[idx] = distance(lis.begin(), lower_bound(lis.begin(), lis.end(), inf));

    for (auto ch : tree[idx]) {
      st.push({ch, idx});
    }
  }

  for (auto a : ans) {
    cout << a << '\n';
  }
}

Measured memory_bytes: 22896
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  cin >> S;

  if(S.at(sz(S)-1) != 's')  cout << S << "s" << endl;
  else  cout << S << "es" << endl;

  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i<n; i++){
			a[i]= sc.nextLong();
		}
		Arrays.sort(a);
		int[] co=new int[n];
		for(int i=0; i<n-1; i++){
			if(i%2==0){
				co[i]--;
				co[i+1]++;
			}else{
				co[i]++;
				co[i+1]--;
			}
		}
		Arrays.sort(co);
		long sum1=0;
		for(int i = 0; i<n; i++){
			sum1+=(long)a[i]*co[i];
		}
		Arrays.fill(co,0);
		for(int i=0; i<n-1; i++){
			if(i%2==0){
				co[i]++;
				co[i+1]--;
			}else{
				co[i]--;
				co[i+1]++;
			}
		}
		Arrays.sort(co);
		long sum2=0;
		for(int i = 0; i<n; i++){
			sum2+=(long)a[i]*co[i];
		}
		System.out.println(Math.max(sum1,sum2));
	}
}


Measured memory_bytes: 62628
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N, M; cin >> N >> M;

	if (M % 2 == 1)M--;

	if(N == M/2){
		cout << N << endl;
		return 0;
	}
	else if (N < M / 2) {
		cout << N + ((M - 2 * N) / 4) << endl;
		return 0;
	}
	else {
		cout << M / 2 << endl;
	}
}

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

void rotate_S(int minase_inori[6]) {
	int hayami_saori = minase_inori[0];
	minase_inori[0] = minase_inori[4];
	minase_inori[4] = minase_inori[5];
	minase_inori[5] = minase_inori[1];
	minase_inori[1] = hayami_saori;
}

void rotate_NES(int kugimiya_rie[6]) {
	int kitamura_eri = kugimiya_rie[1];
	kugimiya_rie[1] = kugimiya_rie[3];
	kugimiya_rie[3] = kugimiya_rie[4];
	kugimiya_rie[4] = kugimiya_rie[2];
	kugimiya_rie[2] = kitamura_eri;
}

void check(const int asumi_kana[6], const int iguti_yuka[6]) {
	int sakura_ayane;
	int satou_satomi[6];
	for (sakura_ayane = 0; sakura_ayane < 6; sakura_ayane++) {
		satou_satomi[sakura_ayane] = iguti_yuka[sakura_ayane];
	}
	for (sakura_ayane = 0; sakura_ayane < 4; sakura_ayane++) {
		int tateno_kanako;
		for (tateno_kanako = 0; tateno_kanako < 6; tateno_kanako++) {
			if (asumi_kana[tateno_kanako] != satou_satomi[tateno_kanako]) break;
		}
		if (tateno_kanako >= 6) {
			puts("Yes");
			exit(0);
		}
		rotate_NES(satou_satomi);
	}
}

int main(void) {
	int mizuki_nana[6], fukuenn_misato[6];
	int horie_yui;
	for (horie_yui = 0; horie_yui < 6; horie_yui++) {
		if (scanf("%d", &mizuki_nana[horie_yui]) != 1) return 1;
	}
	for (horie_yui = 0; horie_yui < 6; horie_yui++) {
		if (scanf("%d", &fukuenn_misato[horie_yui]) != 1) return 1;
	}
	check(mizuki_nana, fukuenn_misato);
	for (horie_yui = 0; horie_yui < 4; horie_yui++) {
		rotate_NES(fukuenn_misato);
		rotate_S(fukuenn_misato);
		check(mizuki_nana, fukuenn_misato);
		rotate_S(fukuenn_misato);
		rotate_S(fukuenn_misato);
		rotate_S(fukuenn_misato);
	}
	rotate_S(fukuenn_misato);
	rotate_S(fukuenn_misato);
	check(mizuki_nana, fukuenn_misato);
	puts("No");
	return 0;
}


Measured memory_bytes: 2148
#include <iostream>
// B - Red or Blue

using namespace std;

int main() {
    int N,r,b;
    string s;

    cin >> N;
    cin >> s;

    r = 0;
    b = 0;
    for (char c : s) {
        if (c == 'R')
            r++;
        else
            b++;
    }

    if (r > b)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
while str = gets
  arr = str.split(',').map(&:to_i)
  cards = Array.new(13, 0)
  arr.each do |a|
    cards[a - 1] += 1
  end

  result = if cards.max == 4
             'four card'
           elsif cards.max == 3 && cards.select { |i| i == 2 }.count == 1
             'full house'
           elsif cards.join('') =~ /(1{5}|10{8}1{4})/
             'straight'
           elsif cards.max == 3
             'three card'
           elsif cards.select { |i| i == 2 }.count == 2
             'two pair'
           elsif cards.select { |i| i == 2 }.count == 1
             'one pair'
           else
             'null'
           end
  puts result
end

Measured memory_bytes: 8640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  string s; cin>>s;
  sort(s.begin(),s.end());
  bool can = true;
  for(int i=1; i<s.size(); i++) {
    if(s[i]==s[i-1]) {
      can = false;
      break;
    }
  }
  cout<<(can ? "yes" : "no");
}

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

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

#define INF LLONG_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pll pair<lli,lli>


int main(){
	lli A[3],f=0;
	cin >> A[0] >> A[1] >> A[2];

	sort(A, A + 3);
	
	rep(i, 3){
		if (A[i] % 2 == 0)
			f++;
	}
	if (f == 0){
		cout << A[0] * A[1] << endl;
	}
	else{
		cout << 0<<endl;
	}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, A; cin >> H >> A;
    if(H % A == 0) cout << H / A << endl;
    else cout << H / A + 1 << endl;
    return 0;
}

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

int main() {
    long long int last = -1, ans = 0;
    vector<vector<int>> v(26);
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); ++i) {
        v[s[i]-'a'].push_back(i);
    }
    for(int i = 0; i < t.size(); ++i) {
        if(v[t[i]-'a'].size() == 0) {
            cout << -1 << '\n';
            return 0;
        } else {
            int isReturn = 1;
            int idx = distance(v[t[i]-'a'].begin(), lower_bound(v[t[i]-'a'].begin(), v[t[i]-'a'].end(), last));
            for(int j = idx; j < v[t[i]-'a'].size(); ++j) {
                int n = v[t[i]-'a'][j];
                if(n > last) {
                    ans += n - last;
                    last = n;
                    isReturn = 0;
                    break;
                }
            }
            if(isReturn) {
                ans += s.size() - last + v[t[i]-'a'][0];
                last = v[t[i]-'a'][0];
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1216
# -*- coding: utf-8 -*-
import math



def main():
    N = int(input())
    E = []
    for i in range(N):
        x, y = map(int,input().split())
        E.append((math.atan2(y,x),x,y))
    E = sorted(E) * 2

    answer = 0
    for i in range(N):
        x = 0
        y = 0
        for j in range(i, i+N):
            x += E[j][1]
            y += E[j][2]
            answer = max(answer, x * x + y * y)

    answer = math.sqrt(answer)
    print(answer)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
// N 길이의 문자열 S가 주어질 때, Q 쿼리를 답해라
// Qi 쿼리 : 1 <= i <= Q에 대해 li와 ri가 주어질 때 li~ri 사이의 부분문자열 S에 대해 AC가 얼마나 등장하는가? 

#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n, q;
	string s;
	int l, r;
	cin >> n >> q;
	vector<int> res;
	cin >> s;
	res.push_back(0);
	if (s.at(1) == 'C' && s.at(0) == 'A')
		res.push_back(1);
	else
		res.push_back(0);
	for (int j=2; j<n; j++)
	{
		if (s.at(j) == 'C' && s.at(j-1) == 'A')
			res.push_back(res.at(j-1)+1);
		else
			res.push_back(res.at(j-1));
	}
	res.push_back(res.at(n-1));
	for (int i=0; i<q; i++)
	{
		cin >> l >> r;
		cout << res.at(r-1) - res.at(l-1) << "\n";
	}
}

Measured memory_bytes: 1528
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

static const int INF = 1001001001;

using namespace std;

int main()
{
	int num_5 = 0, num_7 = 0;
	for (int i = 0; i < 3; ++i) {
		int input;
		cin >> input;
		if (input == 5)
			num_5++;
		if (input == 7)
			num_7++;
	}
	if (num_5 == 2 && num_7 == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        d: usize,
        n: usize,
    }

    let ans = if d==0 {
        1
    } else if d==1 {
        100
    } else {
        100_00
    };
    
    if n==100 {
        println!("{}", ans*(n+1));
    } else {
        println!("{}", ans*n);
    }

}


Measured memory_bytes: 2196
S = gets.chomp
x = S[0..1].to_i
y = S[2..3].to_i
# p x
# p y
if (1 <= x) && (x <= 12) && (1 <= y) && (y <= 12) then
  puts 'AMBIGUOUS'  
elsif (1 <= x) && (x <= 12) then
  puts 'MMYY'
elsif (1 <= y) && (y <= 12) then
  puts 'YYMM'
else
  puts 'NA'
end

Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//






//入力
int N,M;
vector<vector<int>> G;

//メモ化再帰
int dp[100100];
int rec(int v){
        if(dp[v] != -1) return dp[v];

        int res = 0;
        for(auto nv : G[v]){
                chmax(res, rec(nv)+1);
        }

        return dp[v] = res;
}

int main(){
        cin >> N >> M;
        G.assign(N, vector<int>());
        for(int i = 0; i < M; i++){
                int x, y;
                cin >> x >> y;
                x--, y--; //0indexed
                G[x].push_back(y);
        }

        //初期化
        for(int v = 0; v < N; v++) dp[v] = -1;

        //全ノードを一通り更新しながら答えを求める
        int res = 0;
        for(int v = 0; v < N; v++) chmax(res, rec(v));
        cout << res << endl;
        return 0;
}











































Measured memory_bytes: 8192