akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int isRightTriangle(int a, int b, int c){
	int temp;
	if(a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if(b > c){
		temp = b;
		b = c;
		c = temp;
	}
	if(a > b){
		temp = a;
		a = b;
		b = temp;
	}
	
	if(c * c == a * a + b * b){
		return 1;
	}
	return 0;
}

int main(void){
	int i, n, x, y, z;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d", &x, &y, &z);
		if(isRightTriangle(x, y, z) == 1){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
		
			if((1 <= A && B <= 500) && (1 <= C && C <= 1000) && (C <= A + B))
				System.out.println("Yes");
			else System.out.println("No");
			}}

Measured memory_bytes: 23124
// atcoder/abc154/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    cout << string(s.size(), 'x') << endl;
  }

  return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<int>hmin(h,-1);
  vector<int>hmax(h);
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      char s;
      cin >> s;
      if(s == '#'){
        if(hmin[i] == -1) hmin[i] = j;
        hmax[i] = j;
      }
    }
  }
  for(int i = 1;i < h;i++){
    if(hmax[i-1] > hmin[i]){
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int a,b,t;
  cin >> a >> b >> t;
  int num = t / a * b;
  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define maxn 1000005
using namespace std;
typedef long long ll;

template <typename T> void read(T &t)
{
	t=0;int f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

ll n,m;
ll ans;

struct stos
{
	ll a,b;
}s[maxn];

bool cmp(const stos &x,const stos &y)
{
	return x.a<y.a;
}

int main()
{
	read(n),read(m);
	for(register ll i=1;i<=n;++i)
		read(s[i].a),read(s[i].b);
	sort(s+1,s+n+1,cmp);
	for(register ll i=1;i<=n && m>0;++i)
	{
		ll k=min(s[i].b,m);
		ans+=k*s[i].a;
		m-=k;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,dp[105][100005],v[100005],w[100005],W;
long long solve(long long i,long long x)
{
   // cout<<i<<" "<<x<<" "<<W<<" "<<dp[i][x]<<'\n';
    if(x>W)
    return -2000000000;
    if(i==n+1)
    return 0;
    if(dp[i][x]!=-1)
    return dp[i][x];
    dp[i][x]=max(solve(i+1,x+w[i])+v[i],solve(i+1,x));
  //  cout<<i<<" "<<x<<" "<<dp[i][x]<<'\n';
    return dp[i][x];
    
}
int main()
{
    cin>>n>>W;
    for(int i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    v[0]=0;
    w[0]=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=W;j++)
        dp[i][j]=-1;
    }
    cout<<solve(0,0);
    return 0;
}

Measured memory_bytes: 80640
import heapq
n,k=map(int,input().split())
z=[0,1]
for i in range(1,n):
    z.append(z[i]+2)
s=sorted([list(map(int,input().split()))for _ in range(n)],key=lambda x:-x[1])
q=[]
v=0
ans=0
l=[0]*-~n
for a in s[:k]:
    if not l[a[0]]:
        v+=1
        ans+=z[v]
    else:
        heapq.heappush(q,a[1])
    l[a[0]]=1
    ans+=a[1]
tem=ans
for a in s[k:]:
    if not q:break
    if l[a[0]]:continue
    l[a[0]]=1
    v+=1
    t=heapq.heappop(q)
    tem=tem-t+a[1]+z[v]
    ans=max(ans,tem)
print(ans)

Measured memory_bytes: 37060
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < n; ++i)

using namespace std;
typedef long long ll;
const int mod = 1000000007;

ll dp[55][55][2555];

int main() {
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    int sum = 0;
    rep(i, N) sum += x[i];

    dp[0][0][0] = 1;

    rep(j, N+1) {
        rep(k, N+1) {
            rep(l, sum+1) {
                if (j>=1 && k>=0 && l<x[j-1]) {
                    dp[j][k][l] = dp[j-1][k][l];
                }
                else if (j>=1 && k>=1 && l>=x[j-1]) {
                    dp[j][k][l] = dp[j-1][k][l] + dp[j-1][k-1][l-x[j-1]];
                }
                else if (j==0 && k==0 && l==0) dp[j][k][l] = 1;
                else dp[j][k][l] = 0;   
            }    
        }
    } 
    ll ans = 0;
    for (int k=1; k<=N; k++) ans += dp[N][k][A*k];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 57472
S = input()
T = input()

dp = [[0 for j in range(len(T) + 1)] for i in range(len(S) + 1)]

for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j]:
            dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1])
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

res = []
stack = [(len(S), len(T))]

while stack:
    x, y = stack.pop()
    if dp[x][y] == 0:
        break
    if x - 1 >= 0 and dp[x][y] == dp[x - 1][y]:
        stack.append((x - 1, y))
    elif y - 1 >= 0 and dp[x][y] == dp[x][y - 1]:
        stack.append((x, y - 1))
    else:
        res.append(S[x - 1])
        stack.append((x - 1, y - 1))

print(''.join(res[::-1]))

Measured memory_bytes: 147812
"""
O(n^2)??????????§£???
"""

danmen = input()
depth = []
tmp_dpt = 0

for line in danmen:
    depth.append(tmp_dpt)

    if line == "\\":
        tmp_dpt -= 1
    elif line == "/":
        tmp_dpt += 1

# len(depth) = len(danmen) + 1?????¨???
depth.append(tmp_dpt)

# print(depth)

i = 0
L = []

while i < len(danmen):
    if len(set(danmen[i:])) == 1:
        break

    if danmen[i] == "\\":
        if depth[i] in depth[i + 1:]:
            stack = 0
            area = 0

            for line in danmen[i:]:
                if line == "\\":
                    area += 1 + 2 * stack
                    stack += 1
                elif line == "/":
                    stack -= 1
                    area += 1 + 2 * stack
                else:
                    area += 2 * stack

                if stack == 0:
                    break

            if area != 0:
                L.append(area // 2)
                i += depth[i + 1:].index(depth[i])

    i += 1

print(sum(L))
print(len(L), *L)

Measured memory_bytes: 8512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
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
#define trace(...)
#endif

int modpow(int x, int n, int m) {
    x %= m;
    int res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());

    int n, a, b;
    cin >> n >> a >> b;
    int ans = (modpow(2, n, mod) - 1 + mod) % mod;
    int tmp1 = 1, tmp2 = 1;
    for(int i = n - a + 1; i <= n; i++) {
        tmp1 = tmp1 * i % mod;
    }
    for(int i = n - b + 1; i <= n; i++) {
        tmp2 = tmp2 * i % mod;
    }
    int cur = 1;
    for(int i = 1; i <= a; i++) {
        cur = cur * i % mod;
    }
    tmp1 = tmp1 * modpow(cur, mod - 2, mod) % mod;
    for(int i = a + 1; i <= b; i++) {
        cur = cur * i % mod;
    }
    tmp2 = tmp2 * modpow(cur, mod - 2, mod) % mod;
    ans = (ans - tmp1 + mod) % mod;
    ans = (ans - tmp2 + mod) % mod;
    cout << ans;

    return 0;
}

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

int main() {
 int n;
 cin >> n;
 string s;
 bool a = 0;
 for(int i = 0; i < n; i++){
     cin >> s;
     if(s == "Y"){
         a = 1;
         break;
     }
 }
 if(a == 1) cout << "Four" << endl;
 else cout << "Three" << endl;
 }


Measured memory_bytes: 256
import math
n = int(input())

beforeTax = math.floor(n / 1.08)
afterTax = lambda x: math.floor(x * 1.08)

if n == afterTax(beforeTax):
    print(beforeTax)
elif n == afterTax(beforeTax+1):
    print(beforeTax+1)
else:
    print(':(')

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

const int maxn = 202000, MOD = 1000000007;
int c[maxn], tot, n, dp[maxn], sum_occ[maxn], _x;


int main() {
    scanf("%d", &n);
    rep(i, n) {    
        scanf("%d", &_x);
        if(_x == c[tot]) continue;
        c[++tot] = _x;
    }

    dp[0] = 1;
    for(int i = 1; i <= tot; ++i) {
        dp[i] = (dp[i - 1] + sum_occ[c[i]]) % MOD;
        sum_occ[c[i]] = (dp[i - 1] + sum_occ[c[i]]) % MOD;
    }
    cout << dp[tot] << '\n';
    
    
    return 0;
}

Measured memory_bytes: 2560
a1,a2,b1,b2=gets.split.map &:to_i
c1 = b1-(b2-a2)
c2 = b2+(b1-a1)
d1 = c1-(c2-b2)
d2 = c2+(c1-b1)
puts [c1,c2,d1,d2].join(" ")

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool combox(pair<int,int> a,pair<int,int> b)
{
	int ta = a.FI * a.FI + a.SE * a.SE;
	int tb = b.FI * b.FI + b.SE * b.SE;
	
	if(ta > tb)
	{
		return true;
	}
	else if(ta == tb)
	{
		if(a.FI > b.FI)
			return true;
		else
			return false;
	}
	else
		return false;
	
}
	
	
int main()
{
	int h,w;
	while(cin>>h>>w,h|w)
	{
		  pair<int,int> p = MP(h,w);
		  
		  pair<int,int> ans = MP(10*h,10*w);
		  
		  bool flag = true;
		  for(int i = 3;i < h+w+50;i++)
		  {
			  flag = false;
			  for(int j = 1;j < i-j;j++)
			  {
				  pair<int,int> tmp =MP(j,i-j);
				  if(combox(tmp,p)&&combox(ans,tmp))ans = tmp;
			  }
		  }
		  
		  cout << ans.FI << ' ' << ans.SE << endl;
		  
	}
	
	return 0;
}

Measured memory_bytes: 3108
l=list(map(int,input().split()))
l.sort()
a=l[0]
b=l[1]
c=l[2]
if (b-a)%2==0:
    print(c-b+(b-a)//2)
else:
    if c%2==0:
        if b%2==0:
            print((c+1-a)//2+(c-b)//2+1)
        else:
            print((c+1-b)//2+(c-a)//2+1)
    else:
        if b%2==0:
            print((c-a)//2+(c+1-b)//2+1)
        else:
            print((c-b)//2+(c+1-a)//2+1)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> h(M), w(M);
    vector<int> countH(H), countW(W);
    set<pair<int, int>> HW;
    for (int i = 0; i < M; ++i) {
        cin >> h[i] >> w[i];
        --h[i];
        --w[i];
        ++countH[h[i]];
        ++countW[w[i]];
        HW.insert({h[i], w[i]});
    }
    vector<pair<int, int>> countW_sorted;
    for (int w = 0; w < W; ++w) {
        if (countW[w] != 0) {
            countW_sorted.push_back({w, countW[w]});
        }
    }
    sort(countW_sorted.begin(), countW_sorted.end(), [&](auto &A, auto &B){
        return A.second > B.second;
    });
    int cur_max = 0, N = countW_sorted.size();
    for (int h = 0; h < H; ++h) {
        if (countH[h] != 0) {
            for (int i = 0; i < N && countH[h] + countW_sorted[i].second > cur_max; ++i) {
                int sum = countH[h] + countW_sorted[i].second;
                if (HW.count({h, countW_sorted[i].first})) {
                    --sum;
                }
                cur_max = max(cur_max, sum);
            }
        }
    }
    cout << cur_max << '\n';
    return 0;
}

Measured memory_bytes: 26144
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        if(a % 3 == 0 || b % 3 ==0 || (a+b) % 3 ==0){
            System.out.println("Possible");
            System.exit(0);
        } else {
            System.out.println("Impossible");
        }
    }
}


Measured memory_bytes: 22996
k,n=map(int,input().split())
a=list(map(int,input().split()))
tmp = 0
for i in range(len(a)):
  if i == len(a) - 1:
    tmp = max(a[0]+k-a[i], tmp)
    break
  tmp = max(a[i+1]-a[i], tmp)
print(k-tmp)

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

using namespace std;

int main() {
	
	std::string str;
	
	cin >> str;

	if (str == "RSR") {
		cout << 1 << endl;
	}
	else if (str == "RSS") {
		cout << 1 << endl;
	}
	else if (str == "SRS") {
		cout << 1 << endl;
	}
	else if (str == "SSR") {
		cout << 1 << endl;
	}
	else if (str == "SRR") {
		cout << 2 << endl;
	}
	else if (str == "RRS") {
		cout << 2 << endl;
	}
	else if (str == "RRR") {
		cout << 3 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();

        if(a%x==0){
            System.out.println(b / x - a / x + 1);
        }
        else{
            System.out.println(b / x - a / x);
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <set>

using namespace std;

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

    multiset<int> st;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        st.insert(x);
    }
    int ans = 0;
    while (st.size() >= 2) {
        int x = *st.rbegin();
        st.erase(st.find(x));
        for (int i = 30; i >= 0; i--) {
            int y = (1 << i) - x;
            if (st.count(y)) {
                ans++;
                st.erase(st.find(y));
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

ll dp[3001][3001][4];
vector <vl> grid(3001, vl (3001, 0));

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r, c, k;
	cin >> r >> c >> k;

	while (k--) {
		ll a, b, cc;
		cin >> a >> b >> cc;
		grid[a - 1][b - 1] = cc;
	}

	for (ll i = 0; i < r; i++) {
		for (ll j = 0; j < c; j++) {
			for (ll k = 0; k < 4; k++)
				dp[i][j][k] = 0;
		}
	}
	dp[0][0][1] = grid[0][0];
	dp[0][0][0] = 0;
	for (ll j = 1; j < c; j++) {
		dp[0][j][1] = max(dp[0][j - 1][1], dp[0][j - 1][0] + grid[0][j]);
		dp[0][j][2] = max(dp[0][j - 1][1] + grid[0][j], dp[0][j - 1][2]);
		if (j > 1)
			dp[0][j][3] = max(dp[0][j - 1][2] + grid[0][j], dp[0][j - 1][3]);
	}
	for (ll i = 1; i < r; i++) {
		dp[i][0][1] = grid[i][0];
	}
	for (ll i = 1; i < r; i++) {
		for (ll j = 0; j < c; j++) {
			for (ll k = 0; k < 4; k++) {
				dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][k] + grid[i][j]);
			}
			if (j >= 1)
				dp[i][j][2] = max(dp[i][j - 1][2], dp[i][j - 1][1] + grid[i][j]);
			if (j >= 2)
				dp[i][j][3] = max(dp[i][j - 1][3], dp[i][j - 1][2] + grid[i][j]);
			ll ma = dp[i][j][1];
			if (j >= 1)
				dp[i][j][1] = max(dp[i][j - 1][1], dp[i][j - 1][0] + grid[i][j]);
			dp[i][j][1] = max(ma, dp[i][j][1]);
		}
	}
	ll ans = 0;
	for (ll k = 0; k < 4; k++)
		ans = max(ans, dp[r - 1][c - 1][k]);
	cout << ans << "\n";
}


Measured memory_bytes: 355328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int main(){
    int x;cin>>x;
    for(ll i=0;i<201;i++){
        for(ll j=0;j<201;j++){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
        for(ll j=0;j>-201;j--){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4096
// 累積和の学習
// cf. https://qiita.com/drken/items/56a6b68edef8fc605821

#include <bits/stdc++.h>

using namespace std;

int main() {

    int N;
    cin >> N;
    int ans;


    int MAX = 101010;

    // 素数の絞り込み エラトステネスのふるい
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i * 2; j < MAX; j += i) {
            is_prime[j] = 0;
        }
    }

    // 2017に似た数か; N,(N+1)/2 = prime number
    vector<int> a(MAX, 0);
    for (int j = 0; j < MAX; ++j) {
        // Nが素数か
        if (!is_prime[j]) {
            continue;
        }
        // (N+1)/2が素数か
        if (!is_prime[(j + 1) / 2]) {
            continue;
        }
        a.at(j) = 1;
    }

    // 累積和
    vector<int> s(MAX + 1, 0);
    for (int k = 0; k < MAX; ++k) {
        s[k + 1] = s.at(k) + a.at(k);
    }

    // クエリ処理
    for (int q = 0; q < N; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;
        cout << s[r] - s[l] << endl;
    }

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  for(int i=0;i<(int)(v.size());++i) {
    if(i) os << ", ";
    os << v[i];
  }
  return os << "]";
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
bool solve() {
  int n, m; cin >> n >> m;
  if(n == 0) return false;
  vi s(n), d(m), sud(m+1);
  for(int i=0;i<n;++i) {
    cin >> s[i];
  }
  for(int i=0;i<m;++i) {
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  for(int i=0;i<m;++i) {
    sud[i+1] = sud[i] + d[i];
  }
  vi su(1<<n);
  for(int i=0;i<1<<n;++i) {
    for(int j=0;j<n;++j) {
      if(i>>j&1) {
        su[i] = su[i ^ (1<<j)] + s[j];
      }
    }
  }
  int ans = 0;
  for(int i=0;i<m;++i) {
    if(d[i] >= su[(1<<n)-1]) {
      ans += abs(d[i] - su[(1<<n)-1]);
    }
  }
  vi dp(1<<n, INF);
  dp[0] = 0;
  for(int bit=0;bit<1<<n;++bit) {
    for(int i=0;i<n;++i) {
      if((bit>>i)&1) {
        auto it1 = lower_bound(d.begin(),d.end(), su[bit^(1<<i)]);
        auto it2 = lower_bound(d.begin(),d.end(), su[bit]);
        int pos1 = distance(d.begin(), it1);
        int pos2 = distance(d.begin(), it2);
        int now = 0;
        for(int j=pos1;j<pos2;++j) {
          now += min(abs(d[j] - su[bit]), abs(d[j] - su[bit ^ (1<<i)]));
        }
        chmin(dp[bit], dp[bit^(1<<i)] + now);
      }
    }
  }
  cout << ans + dp[(1<<n)-1] << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) break;
  }
}



Measured memory_bytes: 3476
import sys
input = sys.stdin.readline
import numpy as np
A = np.array([int(x) for x in input().split()])
A = np.sort(A)
E = A[np.nonzero(A % 2 == 0)]
O = A[np.nonzero(A % 2 == 1)]
e, o = len(E), len(O)
if e == 0 or o == 0:
    a, b = A[-1] - A[0], A[-1] - A[1]
    print(a // 2 + b // 2)
elif e > o:
    A_2 = np.sort(np.concatenate([(E + 1), O]))
    a, b = A_2[-1] - A_2[0], A_2[-1] - A_2[1]
    print(1 + a // 2 + b // 2)
elif o > e:
    A_2 = np.sort(np.concatenate([(O + 1), E]))
    a, b = A_2[-1] - A_2[0], A_2[-1] - A_2[1]
    print(1 + a // 2 + b // 2)

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

int main(){
	int n, i, buf, m=0;
	cin >> n;
	int a[100002];
	for(i=0; i<100002; i++){
		a[i] = 0;
	}
	for(i=0; i<n; i++){
		cin >> buf;
		a[buf+1]++;
	}
	for(i=0; i<100000; i++){
		m = max(m, a[i]+a[i+1]+a[i+2]);
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 640
main(){int h,w,z,r;while(scanf("%d %d %d",&h,&w,&z),h){if(h>w&&h>z)h=z;if(w>h&&w>z)w=z;scanf("%d ",&z);while(z--){scanf("%d ",&r);printf(w*w+h*h<r*r*4?"OK\n":"NA\n");}}}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> dp(n + 1000);
    dp[0] = 1;
    vector <int> a = {100, 101, 102, 103, 104, 105};
    forn (i, 0, n + 1) {
        for (int j : a)
            dp[i + j] |= dp[i];
    }
    if (dp[n])
        cout << 1;
    else
        cout << 0;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const int MAX_N = 100005;
int par[MAX_N];
int rn[MAX_N];
ll num[MAX_N];
int N, M;

void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        rn[i] = 0;
        num[i] = 1;
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y) return;

    if(rn[x] < rn[y]){
        par[x] = y;
    } else{
        par[y] = x;
        if(rn[x] == rn[y]) rn[x]++;
    }
    ll t = num[x] + num[y];
    num[x] = num[y] = t;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

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

    int A[M], B[M];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
    }

    reverse(A, A+M);
    reverse(B, B+M);

    init(N);
    ll ans = (ll)N*(N-1)/2;
    vector<ll> l;
    for(int i=0; i<M; i++){
        l.push_back(ans);

        if(!same(A[i], B[i])){
            int ra = find(A[i]);
            int rb = find(B[i]);
            ans -= (ll)num[ra]*num[rb];
        }
        unite(A[i], B[i]);
    }

    reverse(l.begin(), l.end());
    for(ll e : l) cout << e << endl;

    return 0;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  reverse(b.begin(), b.end());
  int lhr = 0;
  int rhr = b.size() - 1;
  rep(i, b.size()) {
    if (a[i] == b[i]) {
      if (a[lhr] != b[i] && b[lhr] != b[i]) {
        int t = b[lhr];
        b[lhr] = b[i];
        b[i] = t;
        lhr++;
      } else if (a[rhr] != b[i] && b[rhr] != b[i]) {
        int t = b[rhr];
        b[rhr] = b[i];
        b[i] = t;
        rhr--;
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  rep(i, n - 1) cout << b[i] << " ";
  cout << b[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
    int a,m,d,i,j;
    scanf("%d %d",&m,&d);
    for(i=1;i<=m;i++){
        for(j=1;j<=d;j++){
                int k=j/10;
                int l=j%10;
            if(k>=2 && l>=2 && k*l==i){
                a++;
            }
        }
    }
    printf("%d",a);
}

Measured memory_bytes: 128
s=list(input())
YYMM=False
MMYY=False
#if YYMM
if s[2]=='0' and s[3]!='0': YYMM=True
elif s[2]=='1' and int(s[3])<=2: YYMM=True

if s[0]=='0' and s[1]!='0': MMYY=True
elif s[0]=='1' and int(s[1])<=2: MMYY=True


if YYMM==True and MMYY==True: print('AMBIGUOUS')
elif YYMM==True and MMYY==False: print('YYMM')
elif YYMM==False and MMYY==True: print('MMYY')
else: print('NA')

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

int n, a, see[100010];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        see[a] = i;
    }
    for (int i = 1; i < 100005; i++)
    {
        if (see[i] > 0)
        {
            cout << see[i] << " ";
        }
        
    }
    
}

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

int main()
{
	int a,b,c,k;
	int max_sum=0;

    // 数値取得
    scanf("%d %d %d %d",&a,&b,&c,&k);
	// 枚数により考える
	if( a>=k ) {
		// 全て1が最大
		max_sum=k;
	} else if( a+b>=k ) {
		// 補えない分は0を引く
		max_sum=a;
	} else {
		// さらに補えない分を-1を引く
		max_sum=a-(k-a-b);
	}
	printf("%d\n",max_sum);

    return 0;
}


Measured memory_bytes: 2156
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 宣言
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        boolean check = false;
        
        // 九九全パターンから探索
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                ans = i * j;
                // 処理
                if(ans == n){
                    check = true;
                    break;
                }
            }
        }
        
        // 判定
        if(check){
            System.out.println("Yes");
        }else{
            System.out.println("No");            
        }
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		long[] a = new long[5];//m a r c h
		String str;
		for (int i = 0; i < n; i++) {
			str = sc.next();
			if (str.startsWith("M")) {
				a[0]++;
			} else if (str.startsWith("A")) {
				a[1]++;
			} else if (str.startsWith("R")) {
				a[2]++;
			} else if (str.startsWith("C")) {
				a[3]++;
			} else if (str.startsWith("H")) {
				a[4]++;
			}
		}
		long sum = 0;

		for (int i = 0; i < 3; i++) {
			for (int j = i + 1; j < 4; j++) {
				for (int k = j + 1; k < 5; k++) {
					sum += a[i] * a[j] * a[k];
				}
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 46596
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

const int max_n = i_half_inf;
ll n, a[max_n];

int main() {
    cin >> n;
    ll c_even = 0, c_odd = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 2 == 0) c_even++;
        else c_odd++;
    }
    if (c_odd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
import itertools
import collections
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = lmi()

d = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        d[i][j] = (x[i]-x[j], y[i]-y[j])

dd = []
for i in range(n):
    dd += d[i]

c = collections.Counter(dd)
c1 = c.most_common()[0]
if c1[0] == (0,0) and n != 1:
    c1 = c.most_common()[1]
    print(n-c1[1])
else:
    print(1)


Measured memory_bytes: 3948
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  s <- getLine
  unless (s == "0") $ do
    putStrLn $ solve s 
    solve <$> getLine >>= putStrLn
    solve <$> getLine >>= putStrLn
    main

solve :: String -> String
solve = unwords . map show . f . map length . group . sort . ("AB"++) . tail
  where
    f [x,y] = if x > y then [x,y-1] else [x-1,y]

Measured memory_bytes: 3520
using System;

namespace abc173
{
    class Program
    {
        static void Main(string[] args)
        {
            var hwk = Console.ReadLine().Split(' ');
            var h = int.Parse(hwk[0]);
            var w = int.Parse(hwk[1]);
            var k = int.Parse(hwk[2]);
            var ct = new char[h][];
            for (var i = 0; i < h; ++i)
            {
                ct[i] = Console.ReadLine().ToCharArray();
            }

            var selects = 0;
            for (var x = 0; x < Math.Pow(2, h); ++x)
            {
                for (var y = 0; y < Math.Pow(2, w); ++y)
                {
                    var blacks = 0;
                    for (var i = 0; i < h; ++i)
                    {
                        if (x % Math.Pow(2, i + 1) >= Math.Pow(2, i))
                        {
                            continue;
                        }
                        for (var j = 0; j < w; ++j)
                        {
                            if (y % Math.Pow(2, j + 1) >= Math.Pow(2, j))
                            {
                                continue;
                            }
                            if (ct[i][j] == '#')
                            {
                                ++blacks;
                            }
                        }
                    }
                    if (blacks == k)
                    {
                        ++selects;
                    }
                }
            }
            Console.WriteLine(selects);
        }
    }
}


Measured memory_bytes: 27868
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int card1 = sc.nextInt();
        int card2 = sc.nextInt();
        int card3 = sc.nextInt();
        int card = sc.nextInt();
        sc.close();

        int i = 0;
        int j = 0;
        int k = 0;
        if(card>card1){
            i=card1;
        }else{
            i=card;
        }
        card=card-card1;
        if(card<0){
            card=0;
        }
        if(card>card2){
            j=card2;
        }else{
            j=card;
        }
        card=card-card2;
        if(card<0){
            card=0;
        }
        if(card>card3){
            k=card3;
        }else{
            k=card;
        }
        int ans=0;
        for(int num1=0;num1<i; num1++){
            ans++;
        }
        for(int num2=0; num2<k; num2++){
            ans --;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35804
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int W,H,x,y,r;
		Scanner sc=new Scanner(System.in);
		W=sc.nextInt();
		H=sc.nextInt();
		x=sc.nextInt();
		y=sc.nextInt();
		r=sc.nextInt();
		if(x<r || y<r){
			System.out.println("No");
		}else if((x+r)>W || (y+r)>H){
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
    }
}


Measured memory_bytes: 26372
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

int main(void)
{
  int n, k;
  
  scanf("%d %d", &n, &k);
  
  puts(((n + 1) >> 1) >= k ? "YES" : "NO");
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    //10^18 around((2^63)-1) 64bit整数値
    long long int H;
    cin >> H;
    int i=0;
    while(H>0){
        i++;
        H/=2;
    }

    long long int ans=0;
    for(int j=0;j<i;j++){
        ans = ans + pow(2,j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
int r,c,n,tot,zhan[N],top;
PI q[N];
int check(int x,int y){
	if(y==r)return x;
	if(x==c)return r-y+c;
	if(y==0)return r+c+(c-x);
	if(x==0)return r+c+c+y;
	return -1;
}
signed main(){
	r=read(); c=read(); n=read(); swap(r,c);
	for(int i=1;i<=n;i++){
		int sx=read(),sy=read(),tx=read(),ty=read();
		if(check(sx,sy)!=-1&&check(tx,ty)!=-1){
			int s=check(sx,sy),t=check(tx,ty);
			if(s>t)swap(s,t);
			q[++tot]=mp(s,i); q[++tot]=mp(t,-i); 
		}
	}
	sort(&q[1],&q[tot+1]);
	for(int i=1;i<=tot;i++)if(q[i].second>0){
		zhan[++top]=q[i].second;
	}else if(zhan[top]!=-q[i].second){
		puts("NO"); return 0;
	}else top--;
	puts("YES");
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    ll d, t, s;
    cin >> d >> t >> s;

    if (d <= s * t)
        prt("Yes");
    else
        prt("No");

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    cout<<(n+999)/1000*1000-n<<endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int A,B,C; cin >> A >> B >> C; //3つの整数
    bool ans=true;
    if(A==B && A!=C) ans=false;
    if(A==C && A!=B) ans=false;
    if(B==C && B!=A) ans=false;
    
    if(ans) cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
int w , s;
int main(){
    cin >> s >> w;
    if(w >= s)
        cout << "unsafe";
    else cout <<"safe";
    return 0;
}


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

int main() {
   int a, b;
   cin >> a >> b;
   if (a <= b) {
      rep(i, b) cout << a;
      cout << endl;
   } else {
      rep(i, a) cout << b;
      cout << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
  int X, A, B;
  cin >> X >> A >> B;

  if (A >= B) {
    cout << "delicious";
  } else if(A+X>=B) {
    cout << "safe";
  } else {
    cout << "dangerous";
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int k;
    int a[1000001];

    scanf("%d", &k);

    a[1] = 7 % k;
    for(int i = 2; i <= k; ++i){
        a[i] = (10 * a[i-1] + 7) % k;
    }

    int flag = 0;
    for(int i = 1; i <= k; ++i){
        if(a[i] == 0){
            printf("%d\n", i);
            flag = 1;
            break;
        }
    }
    if(flag == 0) printf("-1\n");

    return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    list<char> s, t;
    for(int i=0; i<S.length(); i++){
        s.push_back(S[i]);
        t.push_back(T[i]);
    }
    
    char ch;
    bool flag=false;
    for(int i=0; i<S.length(); i++){
        ch = S.front(); S.erase(S.begin());
        S.push_back(ch);
        
        if(S==T) flag=true;
    }
    
    cout << ((flag)?"Yes":"No") << endl;
}



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

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

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

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, H[MAX];

int main(){
    cin >> N;
    rep(i, N) cin >> H[i];

    int ans = 0, res = 0;
    for (int i = N - 1; i >= 0; --i) {
        if (H[i - 1] >= H[i]) {
            res++;
        } else {
            ans = max(ans, res);
            res = 0;
        }
    }

    cout << ans << endl;
}

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int s,k;
  cin >> k >> s;
  int x,y,z;
  int count;
  for (x=0; x <= k; x++){
    for (y=0; y <= k; y++){
      if (s-x-y <= k && s-x-y >= 0) count++;
    }
  }
  cout << count << endl;
 
 return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

template <typename T>
void remove(std::vector<T> &vector, lint index)
{
    vector.erase(vector.begin() + index);
}

int main()
{

    lint n;
    cin >> n;
    lint ans, tmp=0,place;
    //lint max;

    vector<lint> a(n),b(n);
    REP(i, n) { cin >> a[i];}
    b = a;


    lint max = *max_element(ALL(a));

    REP(i, n) { if(a[i]==max){
            place = i;
    }}

    remove(b, place);
    lint second = *max_element(ALL(b));

    REP(i, n) {if(a[i]==max){
            tmp += 1;
    }}

    REP(i, n) { 
        if(tmp>1){
            cout << max << "\n";
         }else if (a[i] != max){
                cout << max << "\n";
                }else{
            cout<< second << "\n";
        }
        }
return 0;
}

Measured memory_bytes: 4736
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    long long p=1;
    for (i=n-1;i>0;i--)
    {
        if (a[i]==a[i-1])
        {
            p*=a[i];
            i-=2;
            break;
        }
    }
    for (;i>0;i--)
    {
        if (a[i]==a[i-1])
        {
            p*=a[i];
            i-=2;
            break;
        }
    }
    if (i==0)
    {
        p=0;
    }
    cout<<p<<endl;
    return 0;
} 


Measured memory_bytes: 640
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    li=[int(readline()) for _ in range(5)]
    k=int(readline())

    for i in range(1,5):
        if k<li[i]-li[0]:
            print(":(")
            break
    else:
        print("Yay!")
        
if __name__=="__main__":
    main()

Measured memory_bytes: 9008