akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s,t;cin>>s>>t;
    int n=s.size();
    rep(i,s.size()){
        string u=s.substr(n-i-1,i+1)+s.substr(0,n-i-1);
        if(u==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import itertools

def has_duplicates(seq):
    return len(seq) != len(set(seq))


n=int(input())
l=[int(x) for x in input().split()]
l.sort()

ans = 0

for kumi in itertools.combinations(l, 3):
    if has_duplicates(kumi):
        pass
    else:
        if kumi[0]+kumi[1] > kumi[2] and kumi[2] - kumi[0] < kumi[1]:
            ans +=1
    
print(ans) 

Measured memory_bytes: 9160
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, M = ri_()
H = ri_()
H_ = [1] * N
for _ in range(M):
    A, B = ri_()
    if H[A - 1] >= H[B - 1]:
        H_[B - 1] = 0
    if H[A - 1] <= H[B - 1]:
        H_[A - 1] = 0
print(sum(H_))

Measured memory_bytes: 20036
#include<iostream>
#include<cmath>
#include<bitset>
using namespace std;

int main()
{
    int n, k, b;

    cin >> n;
    cin >> k;

    int u[n];
    double p = pow( 2, (double)n );
    bitset<28> s1(0);

    for( int i = 0; i < n; i++ )
        u[i] = i;

    for( int i = 0; i < k; i++ )
    {
        cin >> b;
        for( int j = 0; j < n; j++ )
        {
            if( u[j] == b )
                s1[j] = 1;
        }
    }

    for( int i = 0; i < (int)p; i++ )
    {
        bitset<28> t(i);

        bool judge = true;
        if( ( s1 | t ) != s1 )
            judge = false;

        if( judge == true )
        {
            cout << i << ":";
            for( int j = 0; j < 28; j++ )
            {
                if( t[j] == 1 )
                    cout << " " << u[j];
            }
            cout << endl;
        }
    }
    return 0;
}


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

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

    long long ans = 0;
    for(int i=0,j=0;S[i];i++)if(S[i] == 'W')ans+=i-j,j++;

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

Measured memory_bytes: 640
import java.util.*; 
import java.lang.*;
public class Main{
 public static void main(String[] args) { 
Scanner sc=new Scanner(System.in); 
int x=sc.nextInt();
 int sum=0; 
for(int i=1;i<=3;i++) 
{ 
int b=(int)Math.pow(x,i);
sum=sum+b;

} 
System.out.println(sum);
 }
 }


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

int main(){
  string S;
  cin >> S;
  ll len = S.size();
  int i = 0;
  bool flag = true;
  while(i < len){
    if(S.substr(i, 5) == "dream"){
      i += 5;
      if(S[i] == 'd' || S[i] == '\0' || S.substr(i, 3) == "era"){
  	continue;
      }else if(S.substr(i, 2) == "er"){
  	if(S[i+2] == 'd' || S[i+2] == 'e' || S[i+2] == '\0'){
  	  i += 2;
  	  continue;
  	}else{
  	  flag = false;
  	  break;
  	}
      }else{
        flag = false;
  	break;
      }
    }else if(S.substr(i, 5) == "erase"){
      i += 5;
      if(S[i] == '\0' || S[i] == 'd' || S[i] == 'e'){
	continue;
      }else if(S[i] == 'r'){
	i++;
	continue;
      }else{
	flag = false;
	break;
      }
    }else{
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  string s;
  cin>>s;
  int n=s.size();

  int ans=0;
  rep(i,n){
    ans+=s[i]-'0';
  }

  cout << (ans%9==0?"Yes":"No") << endl;

}

Measured memory_bytes: 3784
H, W, M = list(map(int, input().split()))

targets = set()
row = [0]*H
col = [0]*W

for _ in range(M):
    h, w = list(map(lambda x: int(x) - 1, input().split()))
    row[h] += 1
    col[w] += 1
    targets.add((h, w))

r_max = max(row)
c_max = max(col)
ans = 0

maxed_h = set([h for h in range(H) if row[h] == r_max])
maxed_w = set([w for w in range(W) if col[w] == c_max])
bomb_option_sites_n = len(maxed_h)*len(maxed_w)
targets_on_bomb_option = 0
for th, tw in targets:
    if th in maxed_h and tw in maxed_w:
        targets_on_bomb_option += 1

if bomb_option_sites_n == targets_on_bomb_option:
    print(r_max + c_max - 1)
else:
    print(r_max + c_max)


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

signed main () {
    int n, m;
    cin >> n >> m;
    vector < pair < pair < int, int >, int > > inp(n);
    set < int > ts[m + 1];
    for (int i = 0; i < n; ++i) {
        cin >> inp[i].first.first >> inp[i].first.second >> inp[i].second;
        ts[inp[i].second].insert(inp[i].first.second);
    }
    vector < pair < int, int > > events(2 * n);
    for (int i = 0; i < n; ++i) {
        int s = inp[i].first.first, t = inp[i].first.second, c = inp[i].second;
        if (ts[c].find(s) == ts[c].end())
            events[i] = make_pair(s - 1, 1);
        else
            events[i] = make_pair(s, 1);
        events[n + i] = make_pair(t, -1);
    }
    sort(events.begin(), events.end());
    int ans = 0, b = 0;
    for (auto event: events) {
        b += event.second;
        ans = max(ans, b);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 7680
S = input()
a1 = [0] * (len(S) + 1)
a2 = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == '<':
        a1[i+1] = a1[i] + 1
    else:
        a1[i+1] = 0

for i in range(len(S)):
    
    if S[-i-1] == '>':
        a2[i+1] = a2[i] + 1
    else:
        a2[i+1] = 0

ans = 0
for i in range(len(S) + 1):
    ans += max(a1[i], a2[-i-1])
print(ans)

Measured memory_bytes: 27308
#include<iostream>

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

int main(){
    int N;
    while(std::cin >> N, N){
        int k_max = -10, challenge = 0;
        REP(i, N){
            int k;
            std::cin >> k;
            k_max = std::max(k, k_max);
            challenge += std::min(k, 1);
        }

        if(k_max < 2){
            std::cout << "NA" << std::endl;
        }else{
            std::cout << challenge + 1 << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
/*problem from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-');
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=5e3,M=2e2;
int L[M+10][N+10],R[M+10][N+10],B[M+10][N+10],stack[N+10];
ll sum[N+10][N+10],A[N+10];
int main(){
	int n=read(),m=read(); ll Ans=0;
	for (int i=2;i<=n;i++)	A[i]=read()+A[i-1];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			B[j][i]=read();
	for (int i=1;i<=m;i++){
		for (int j=1,top=0;j<=n;j++){
			while (top&&B[i][stack[top]]<B[i][j])	top--;
			L[i][j]=top?stack[top]+1:1;
			stack[++top]=j;
		}
		for (int j=n,top=0;j>=1;j--){
			while (top&&B[i][stack[top]]<B[i][j])	top--;
			R[i][j]=top?stack[top]-1:n;
			stack[++top]=j;
		}
		for (int j=1;j<=n;j++){
			sum[L[i][j]][j]+=B[i][j];
			sum[L[i][j]][R[i][j]+1]-=B[i][j];
			sum[j+1][j]-=B[i][j];
			sum[j+1][R[i][j]+1]+=B[i][j];
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++)	sum[i][j]+=sum[i][j-1];
		for (int j=1;j<=n;j++)	sum[i][j]+=sum[i-1][j];
		for (int j=i;j<=n;j++)	Ans=max(Ans,sum[i][j]-A[j]+A[i]);
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 208512
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000000
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
typedef long long int lli;
using namespace std;

int main()
{
  int N,T;
  cin >> N >> T;

  int cost = INF;
  int c ,t;
  
  REP(i,N)
    {
      cin >> c >> t;

      if( t <= T and c < cost )
	{

	  cost = c ;
	  
	  
	}

    }
  


  if( cost < INF )
    {
      printf("%d\n",cost);
	  
	    
    }
  else
    {
      printf("TLE\n");
	  
    }

      

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
long dp[101][100001];

const int INF = 1e9+7;
/*
 *	the dp now is going to be the min total weight of items with value i
 *
 *
 */
 
long knap_value(int N, int V, int W, const std::vector<int>& w, const std::vector<int>& c)
{

	for (int i = 0; i <= N; i++)
		for (int j = 1; j <= V; j++)
			dp[i][j] = INF;

	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= V; j++)
		{
			if (j >= c[i])
				dp[i][j] = std::min(dp[i-1][j], w[i] + dp[i-1][j - c[i]]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}

	long ans = 0;

	for (int i = V; i >= 0; i--)
	{
		if (dp[N][i] <= W)
		{
			ans = i;
			break;
		}
	}
	
	return ans;
}
 
int main() {
	int N, W; std::cin >> N >> W;
	
	std::vector<int> w(N+1), c(N+1);

	int value_sum = 0;
	
	for (int i = 1; i <= N; i++)
	{
		std::cin >> w[i] >> c[i];

		value_sum += c[i];
	}
	
	long ans = knap_value(N, value_sum, W, w, c);

	std::cout << ans << "\n";
}


Measured memory_bytes: 79104
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

const int N = 1e3 + 1;
const int M = 1e9 + 7;

int mod( int m ,int mod = M) {
   m %= mod;
   return (m + mod) % mod;
}
int s;
int dp[2 * N];

int solve(int sum) {
	if(sum >= s)
		return (sum == s);
	int &tmp = dp[sum];
	if(tmp != -1)
		return tmp;
	tmp = 0;
	for(int i = 3; sum + i <= s; i++)
		tmp = mod(tmp + solve(sum + i));
	return tmp;
}

int32_t main() {
	boost;
	cin >> s;
	memset(dp, -1, sizeof dp);
	int ans = solve(0);
	cout << ans << endl;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

void solve() {
    ll N, M; cin >> N >> M;
    vector<ll> a(M), b(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind uf(N);
    vector<ll> res(M);
    ll cur = N*(N-1)/2;
    rep(i, M) {
        ll ai = a[M-1-i], bi = b[M-1-i];
        res[M-i-1] = cur;

        if (uf.issame(ai, bi)) continue;

        cur -= uf.size(ai) * uf.size(bi);
        uf.merge(ai, bi);
    }

    rep(i, M) outl(res[i]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 4480
/*
  第4回ユニリタプログラミングコンテスト～練習サイト～
  C言語用
  ファイル名 qA.c
  作成者 228 金子幸裕 2017/06/14 12:50
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int main( void )
{
    int na, nb, nc;

    scanf( "%d %d %d" , &na, &nb, &nc );

    if ( (nb - na) == (nc - nb) )
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }


    printf("\n");

    return ( 0 );

}


Measured memory_bytes: 128
import Control.Applicative( (<$>))
import Data.List( nub, elem, sort)

main = do
    _n <- getLine
    as_ <- map (read::String->Int) . words <$> getLine
    let
	preColors =  (`quot`400) <$> as_

	(colors,monsters) = span (<8) $ sort preColors
	colorMin = nub colors
	freeColors = length monsters

	(mn,mx) = let
		    numColors = length colorMin
	    in
		if [] /= filter (8<=) preColors
		then (max 1 numColors,  numColors+freeColors)
		else (numColors,    numColors)

    putStr (show mn ++ " ") >> putStr (show mx)

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}



//ここまでライブラリ
//ここから本文
//周りはみんなおとなになってます


int main() {
	int a,b,c;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;

	

}


Measured memory_bytes: 764
if __name__=="__main__":
    # Problem A
    N = int(input())
    ones_digit = int(N)%10
    if ones_digit in [2, 4, 5, 7, 9]:
        print("hon")
    elif ones_digit in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")

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

#define mod 1000000007
#define INF 1000000000

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

using dbl = double;
using ll = long long;
using ull = unsigned ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pi = pair<int,int>;

#define log(x) cout << (x) << endl;
#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}


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

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

	int sm = 0;
	rep(i,n) sm+=a[i];

	if (sm%10)
		log(sm)
	else {
		rep(i,n) if(a[i]%10==0)
			a[i] = -1;
		sort(all(a));

		int j=-1;
		rep(i,n) if (a[i]!=-1) {
			j = i;
			break;
		}

		log(j==-1 ? 0 : sm-a[j])

	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
 long long x;
 scanf("%lld",&x);
  
 long long i,j;
 for(i=-120;i<=120;i++)
  for(j=-120;j<=120;j++) 
   if(x+j*j*j*j*j==i*i*i*i*i){
    printf("%d %d\n",i,j);
    return 0;}
  
  
return 0;}

Measured memory_bytes: 1688
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
B = list(map(int,input().split()))
B.insert(0,0)

cnt = min(A[1],B[1])
x = max(B[1]-A[1],0)
for i in range(2,N+1):
    cnt += min(A[i],x+B[i])
    x = max(B[i]-max(A[i]-x,0),0)
cnt += min(A[N+1],x)
print(cnt)

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
//ll MLG(ll n,ll b){ll a=0;while(n)a++,n/=b;return a-1;}

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        ll x;
        cin>>x;
        ll as=0;
        as=(x/500)*1000;
        x=x%500;
        as+=(x/5)*5;
        cout<<as<<nl;
    }

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        x: i64
    }
    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    string s;
    cin >> s;
    cout << ((count(all(s), 'a') == 1) && (count(all(s), 'b') == 1) && (count(all(s), 'c') == 1) ? ("Yes") : ("No")) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
const int mod = 1e9+7;
#define rep(a,b) for(int a=0;a<b;++a)
signed main(){
  int n,r=0;
  cin>>n;
  int dp[110][5][5][5][5]={0};
  const int A=0,C=1,G=2,T=3;
  rep(a,4)dp[0][T][T][T][a]=1;
  rep(b,4)rep(a,4)dp[1][T][T][a][b]=1;
  rep(c,4)rep(b,4)rep(a,4)dp[2][T][a][b][c]=1;
  dp[2][T][A][G][C] = dp[2][T][A][C][G] = dp[2][T][G][A][C] = 0;
  for(int i=3;i<n;++i){
    rep(a,4)rep(b,4)rep(c,4)rep(d,4)rep(e,4) dp[i][a][b][c][d] = (dp[i][a][b][c][d] + dp[i-1][e][a][b][c]) % mod;
    rep(a,4)dp[i][A][a][G][C] = dp[i][a][G][A][C] = dp[i][a][A][C][G] = dp[i][a][A][G][C] = dp[i][A][G][a][C] = 0;
  }
  rep(a,4)rep(b,4)rep(c,4)rep(d,4)r=(r+dp[n-1][a][b][c][d])%mod;
  cout<<r;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

ll n,k;
vec<ll> a;
bool cut(ll x){
    if(x == 0)return false;
    ll p = 0;
    rep(i,n)p += (a[i] -1)/ x;
    return p <= k;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n); rep(i,n)cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll left = 0,right = a[0],mid;
    while(left +1 < right){
        mid = (left + right)/2;
        cut(mid) ? right = mid : left = mid;
    }
    cout << (cut(left) ? left : right) << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

const int mod = 1e9 + 7;

int n, m;
int two[300 + 5], adj[15 + 5], dp[(1 << 15) + 5];

int main() {
	scanf("%d%d", &n, &m);
	two[0] = 1;
	for (int i = 0; i < m; ++i) two[i + 1] = (two[i] << 1) % mod;
//	for (int i = 0; i <= m; ++i) debug("%d %d\n", i, two[i]);
	for (int i = 0; i < m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y), --x, --y;
		adj[x] |= 1 << y;
//		adj[y] |= 1 << x;
	}
//	for (int i = 0; i < n; ++i) debug("%d %d\n", i, adj[i]);
	dp[0] = 1;
	for (int S = 1; S < (1 << n); ++S) {
		if ((S & 1) != (S >> 1 & 1)) continue;
		for (int T = S; T; (--T) &= S) {
			if ((T & 1) != (T >> 1 & 1)) continue;
//			debug("%d %d\n", S, T);
			int ways = 1, U = S ^ T;
			for (int i = 0; i < n; ++i)
				if (S >> i & 1) {
					if (T >> i & 1) ways = (long long)ways * two[__builtin_popcount(adj[i] & U)] % mod;
					else ways = (long long)ways * (two[__builtin_popcount(adj[i] & T)] - 1) % mod;
				}
			(dp[S] += (long long)dp[S ^ T] * ways % mod) %= mod;
		}
	}
//	for (int i = 0; i < (1 << n); ++i) debug("%d\n", dp[i]);
	printf("%d\n", (two[m] - dp[(1 << n) - 1] + mod) % mod);
}

Measured memory_bytes: 512
#include<iostream>
#define Max 1000001
using namespace std;

int n;
int euler[Max];
long long ans[Max];

int main(){
  for(int i=0;i<Max;i++)euler[i] = i;
  for(int i=2;i<Max;i++){
    if(euler[i] == i){
      for(int j=i;j<Max;j+=i)euler[j] = euler[j] / i *(i-1);
    }
  }

  ans[1] = 0;
  for(int i=2;i<Max;i++)ans[i] = ans[i-1] + euler[i];

  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    cin >> n;
    cout << ans[n] + 2 << endl;
  }
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int q=sc.nextInt();
		for(int i=0;i<q;i++){
			String or= sc.next();
			if(or.equals("print")){
				int a=sc.nextInt();
				int b=sc.nextInt();
				for(int j=a;j<=b;j++){
					System.out.print(str.charAt(j));
				}
				System.out.println();
			}else if(or.equals("reverse")){
				int a=sc.nextInt();
				int b=sc.nextInt();
				String rev = str.substring(a,b+1);
				StringBuffer revsb=new StringBuffer(rev);
				StringBuffer strsb=new StringBuffer(str);
				revsb=revsb.reverse();
				rev=revsb.toString();
				strsb=strsb.replace(a, b+1, rev);
				str=strsb.toString();
			}else{
				int a=sc.nextInt();
				int b=sc.nextInt();
				String r=sc.next();
				StringBuffer repsb=new StringBuffer(str);
				repsb=repsb.replace(a, b+1, r);
				str=repsb.toString();
			}
		}
	}
	
}

Measured memory_bytes: 32316
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 //int v[35];
 
 double triangleArea(double xa,double ya,double xb,double yb,double xc,double yc) 
 {
    double result = ((xa * yb + xb * yc + xc * ya- xb * ya - xc * yb - xa * yc) / 2.0);
    if(result<0) result=-result;
    return result;
 }
 
 int main()
 {
   double x1,y1,x2,y2,x3,y3,xp,yp;
   while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
   {
     double triangleAreaKK = triangleArea(x1,y1, x2,y2, x3,y3);
     double area = triangleArea(xp,yp, x1,y1, x2,y2);
     area += triangleArea(xp,yp, x1,y1, x3,y3);
     area += triangleArea(xp,yp, x2,y2, x3,y3);
     if(((triangleAreaKK-area)<0.00000001)&&((triangleAreaKK-area)>-0.00000001)) puts("YES");
     else puts("NO");     
   }
   //while(1);      
   return 0;    
 }

Measured memory_bytes: 3096
<?php

$in = explode(" ",fgets(STDIN));
$a = $in[0];
$b = $in[1];
$s = $in[2];
$sa = $a-$s;

if($sa <= 0 ){
    $takahashi = 0;
    $aoki = $sa + $b;
    if($aoki <= 0){
        $aoki = 0;
    }
}else{
    $takahashi = $sa;
    $aoki = $b;
}

echo $takahashi." ".$aoki;

?>

Measured memory_bytes: 3700
while True:
    N, Q = map(int, raw_input().split())

    if N == 0 and Q == 0:
        break

    t = [map(int, raw_input().split())[1:] for _ in range(N)]
    table = [[i, 0] for i in range(101)]

    for i in t:
        for j in i:
            table[j][1] += 1

    table.sort(reverse=True, key=lambda x: x[1])

    print table[0][0] if table[0][1] >= Q else 0



Measured memory_bytes: 4676
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int X, A, B; cin >> X >> A >> B;
    string res;
    if (B - A <= 0) {
        res = "delicious";
    }else {
        if (B - A <= X) {
            res = "safe";
        }else{
            res = "dangerous";
        }
    }
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int a[4], b[4];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int n1 = 0, n2 = 0;
		for (int i = 0; i < 4;i++) {
			if (a[i] == b[i])n1++;
		}
		for (int i = 0; i < 4;i++) {
			for (int j = 0; j < 4;j++) {
				if (i == j)continue;
				if (a[i] == b[j]) n2++;
			}
		}
		cout << n1 << " " << n2 << endl;
	}
}

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	unsigned int a;
	unsigned int b;
	unsigned int men;
	unsigned int lo;

	scanf("%d %d", &a, &b);
	men = a * b;
	lo = (a + b)*2;

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

Measured memory_bytes: 596
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    let mut n_calc = n;
    let mut factor = HashMap::new();
    let mut f = 2;

    while f * f <= n {
        if n_calc % f == 0 {
            n_calc /= f;
            let e = factor.entry(f).or_insert(0);
            *e += 1;
            continue;
        }
        f += 1;
    }
    if n_calc != 1 {
        *factor.entry(n_calc).or_insert(0) += 1;
    }

    let ans = if n == 1 {
        0
    } else if factor.is_empty() {
        1
    } else {
        let mut cnt = 0;
        for fi in factor.values_mut() {
            let mut i = 1;
            while *fi >= i {
                *fi -= i;
                i += 1;
                cnt += 1;
            }
        }
        cnt
    };
    println!("{}", ans);
}


Measured memory_bytes: 2216
//fast code to find the ncr % MOD
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 200005;
ll fac[MAX_];
ll inv[MAX_];
ll facinv[MAX_];

inline ll mul(ll a,ll b){ if(a>=MOD)a=a%MOD;if(b>=MOD)b=b%MOD;if(a*b>=MOD)return(a*b)%MOD;return(a*b);}
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
void furious()
{
    fac[1] = 1;fac[0] = 1;
    inv[0] = inv[1] =1 ;
    facinv[0]= facinv[1] = 1;
    for(int i =2;i<MAX_;i++)
    {
        fac[i] = (i*fac[i-1])%MOD;
        inv[i] = (inv[MOD % i] * (MOD - MOD/i))%MOD;
         facinv[i] = (inv[i] * facinv[i-1])%MOD;
    }
}

ll ncrm(ll n, ll r){
   if(n==r || r==0){
       return 1;
   }
   if(n<r){
       return 0;
   }
   return mul(fac[n],mul(facinv[r],facinv[n-r]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    furious();
    int n,k;   cin>>n>>k;
    for(int i = 1;i<=k;i++){
        cout << mul(ncrm(n-k+1,i),ncrm(k-1,i-1))<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>


typedef long long ll;
using namespace std;

#define drobucs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main() {
	drobucs;

	ll l, r;
	cin >> l >> r;

	if (r - l >= 2019) {
		cout << 0;
	}
	else {
		ll mine = 2e9;
		for (int i = l; i <= r - 1; ++i) {
			for (int j = i + 1; j <= r; ++j) {
				int m = ((i % 2019) * (j % 2019)) % 2019;
				if (mine > m)mine = m;
			}
		}
		cout << mine;
	}

	return 0;
}

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

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

    string s;
    int K;
    cin >> s >> K;
    set<string> st;
    for (int i = 0; i <= s.size(); i++) {
        // string tmp = "";
        for (int j = 0; j <= 5; j++) {
            // cout << s.substr(i, j) << endl;
            // cout << i << endl;
            st.insert(s.substr(i, j));
        }
    }
    // cout << s.substr(0, 3) << endl;
    vector<string> tmp;
    for (auto x : st) {
        tmp.push_back(x);
    }
    // int solve(mn[][])
    cout << tmp[K] << endl;
}

Measured memory_bytes: 1920
class UnionFind(object):

    def __init__(self, n):
        # 親のnodeを表す
        self.par = [i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            # 経路圧縮
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        self.par[x] = y


class UnionFindRank(UnionFind):

    def __init__(self, n):
        UnionFind.__init__(self, n)

        self.rank = [0 for _ in range(n)]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

def _abc049_d():
    """連結"""

    N, K, L = list(map(int, input().split(' ')))
    ur = UnionFindRank(N)
    for _ in range(K):
        p, q = list(map(int, input().split(' ')))
        p -= 1
        q -= 1
        ur.union(p, q)

    ut = UnionFindRank(N)
    for _ in range(L):
        r, s = list(map(int, input().split(' ')))
        r -= 1
        s -= 1
        ut.union(r, s)

    def _id(r, t):
        return r * 1e8 + t

    from collections import defaultdict
    d = defaultdict(int)

    for i in range(N):
        d[_id(ur.root(i), ut.root(i))] += 1

    for i in range(N):
        print(d[_id(ur.root(i), ut.root(i))], end=' ')

_abc049_d()

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

int main(){
	int x, y, z, i, v1, v2, a, b, j, max;
	
	while(1){
		max = 0;
		cin>>x>>y>>z;
		
		a = ( z * 100 ) / (100 + x);
		
		b = z - a;
		
		if(x == 0 && y == 0 && z == 0) break;
		
		for(i = 1; i < z; i++){
			for(j = b; i < a + j; j--){
				if((i * (100 + x) / 100 + (a - i + j) * (100 + x) / 100) == z){
					if((i * (100 + y) / 100 + (a - i + j) * (100 + y) / 100) > max){
						max = (i * (100 + y) / 100) + ((a - i + j) * (100 + y) / 100);
					}
				}
			}
		}
		
		cout<<max<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3076
from collections import deque


def bfs(y, x):
    dist = [[-1] * w for _ in range(h)]
    dist[y][x] = 0
    que, frag = deque([(x, y)]), set([(x, y)])

    while que:
        qx, qy = que.popleft()
        near = [(-1, 0), (0, -1), (1, 0), (0, 1)]
        for i, j in near:
            i, j = qx + i, qy + j
            if (i, j) in frag:
                continue
            if 0 <= i < w and 0 <= j < h and s[j][i] == '.':
                dist[j][i] = dist[qy][qx] + 1
                que.append((i, j)), frag.add((i, j))
    return dist[qy][qx]


h, w = map(int, input().split())
s = [input() for _ in range(h)]

ans = 0
for i, si in enumerate(s):
    for j, sij in enumerate(si):
        if sij == '.':
            ans = max(ans, bfs(i, j))
print(ans)


Measured memory_bytes: 74856
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

inline void write_bool(bool b, const string &tval, const string &fval) {
  cout << (b ? tval : fval) << endl;
} 
inline void YESNO(bool b) { return write_bool(b, "YES", "NO"); }
inline void YesNo(bool b) { return write_bool(b, "Yes", "No"); }
inline void yesno(bool b) { return write_bool(b, "yes", "no"); }

int main() {
  int a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    int s = max(a, c), t = min(b, d);
    cout << max(0, t - s) << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    cout << n-k+1 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i32> = get_vec();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    let mut cur = a;
    let mut ans = false;
    loop {
        if cur % b == c {
            ans = true;
            break;
        }
        if cur % b == 0 {
            break;
        }
        cur += a;
    }
    println!("{}", if ans {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i).sort!

arr_max = arr[-1]
hs = Array.new(arr_max+1,true)
ans = 0

(n-1).times do |i|
  next if hs[arr[i]] == false
  v = arr[i] * 2
  while v <= arr[-1] do
    hs[v] = false
    v += arr[i]
  end
  if arr[i] == arr[i+1]
    hs[arr[i]] = false
  end
end

arr.each do |x|
  if hs[x] == true
    ans += 1
  end
end

print ans

Measured memory_bytes: 38204
#include <stdio.h>

int main(void) {
	char S[32];
	int make = 0;
	int i;
	if (scanf("%31s", S) != 1) return 1;
	for (i = 0; S[i] != '\0'; i++) {
		if (S[i] == 'x') make++;
	}
	puts(make < 8 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 1664
n = int(input())
check = {}
word = input()
check[word] = 1
last = word[-1]

for i in range(n-1):
    word = input()
    if word in check:
        print('No')
        exit()

    check[word] = 1
    if word[0] == last:
        last = word[-1]
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n,y;
    std::cin >> n>>y;
    bool han=0;
    reprep(i,j,8000,8000){
        if(n-i-j>=0&&(y-i*5000-j*10000)/1000==n-i-j){
            std::cout << j<<' '<<i<<' '<<n-i-j << std::endl;
            exit(0);
        }
    }
    std::cout <<-1 <<  " "<<-1<< " "<<-1 << std::endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string b;
int a,c;
double d;
stringstream ss;
int main(){
    cin>>a>>b;
    ss<<b;ss>>c;
    d=sqrt(a*pow(10,b.length())+c);
    if(d-(int)d==0)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int a[101];

int main() {

	int n;
	cin>>n;

	double h;
	int t=0;
	rep(i,n){
		cin>>a[i];
		h+=a[i];
	}
	h=double(h)/n;

	double mi=abs(a[0]-h);
	int ans=0;
	rep(i,n-1){
		if(mi>abs(a[i+1]-h)){
			mi=abs(a[i+1]-h);
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,n,m=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		m=m*1.05;
		if(m%1000!=0){
			m=m/1000*1000;
			m=m+1000;
		}
	}
	printf("%d\n",m);
	return 0;
}
	

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N,A,B;
  	int cnt=0;
  	int sum=0;
    cin >> N >> A >> B;
    for(int i=0;i<=N;i++){
      int t=i;
      while(t>0){
        cnt=cnt+t%10;
        t=t/10;
      }
      if(A<=cnt&&cnt<=B){
        sum+=i;
      }
      cnt=0;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3580
#[allow(unused)]
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        a: [i64; n+1],
        b: [i64; n],
    }

    let mut a = a;
    let mut b = b;
    let mut ans = 0;

    for i in 0..n {
        ans += min(a[i], b[i]);
        b[i] = max(0, b[i] - a[i]);
        ans += min(a[i + 1], b[i]);
        a[i + 1] = max(0, a[i + 1] - b[i]);
    }

    println!("{}", ans);
}

Measured memory_bytes: 6396
#include<iostream>
using namespace std;
int main() {
	string S;cin >> S;char prev = S[0];bool skip = false;
	int ans = S.length();
	for (int i = 1; i < S.length(); i++) {
		if (!skip) {
			if (S[i] == prev) {
				ans--;
				skip = true;
			}
			prev = S[i];
		}else {
			skip = false;
			prev = '0';
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int H, W;
    int h, w;
    cin >> H >> W;
    cin >> h >> w;

    int num_tile = H * W;

    num_tile -= h * W;
    num_tile -= H * w;

    num_tile += h * w;
    cout << num_tile << endl;

    return 0;
}

Measured memory_bytes: 256