akhauriyash/Code-Regression huggingface dataset:
N, A, B, C, D = map(int, input().split())

for i in range(N):
    minimum = A + C * i - (N - 1 - i) * D
    maximum = A + D * i - (N - 1 - i) * C
    if minimum <= B <= maximum:
        print('YES')
        exit()
else:
    print('NO')


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            string revS = "";

            revS = Reverse(str);

            if (str != revS)
            {
                Console.WriteLine("No");
                return;
            }

            string Astr = str.Substring(0, (str.Length - 1) / 2);

            revS = Reverse(Astr);

            if (Astr != revS)
            {
                Console.WriteLine("No");
                return;
            }

            string Bstr = str.Substring((str.Length + 3) / 2 - 1, str.Length - (str.Length + 3) / 2 + 1);

            revS = Reverse(Bstr);

            if (Bstr != revS)
            {
                Console.WriteLine("No");

                return;
            }

            Console.WriteLine("Yes");

        }

        static string Reverse(string r)
        {
            string revS = "";

            for (int i = 0; i < r.Length; i++)
            {
                revS += r.Substring(r.Length - 1 - i, 1);
            }

            return revS;
        }
    }
}


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

int N;
int A[200];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,maxn;

int main()
{
	scanf("%lld%lld",&n,&m);
	if(m%n==0)
	{printf("%lld",m/n);
	return 0;
	}
	for(long long i=1;i<=m;i++)
	{
		if(i*n>m)break;
		if(m%i==0&&i*n<=m)maxn=i;
		
	}
	printf("%lld",maxn);
	return 0;
}

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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var Arg = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var House = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var Result = Arg[0] - House[House.Length - 1] + House[0];
            for (int i = 1; i < House.Length; i++)
            {

                if (House[i] - House[i - 1] > Result) Result = House[i] - House[i - 1];

            }

            Console.WriteLine(Arg[0] - Result);

        }

    }
}


Measured memory_bytes: 36444
#include <stdio.h>

int main(void)
{
    char X[2], Y[2];

    scanf("%s%s", X, Y);

    if (X[0]<Y[0])      printf("<\n");
    else if (X[0]>Y[0]) printf(">\n");
    else                printf("=\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define outc cout
#define int long long
signed main(){
  int a,g[1000000];
  int b=0,c=1,d;
  cin>>a;
  for(int i=0;i<a*3;i++){
    cin>>g[i];
  }
  for(int i=1;i<a;i++){
    if(g[i-1]==g[i]) b++,g[i]=-1;
  }
  cout<<b<<"\n";
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,c,a[100000],b;
int main(){
  for(cin>>n,i=1;i<=n;i++){
    cin>>b;
    a[b]=i;
  }
  for(i=1;i<=n;i++)cout<<a[i]<<" ";
}

Measured memory_bytes: 1152
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int main(void)
{
    int n, k;
    cin >>n >>k;

    vector<int> dice;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        dice.push_back(tmp);
    }

    double maxsum = 0;
    double sum = 0;
    for(int i = 0; i < n; i++){
        sum +=  (double)(dice[i] + 1) * 0.5;
        if(i >= k){
            //sum -= dice[i-k];
            sum -=  (double)(dice[i-k] + 1) * 0.5;
        }
        maxsum = max(sum, maxsum);
    }

    printf("%.8lf\n", (double)maxsum);

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


const int MAX = 2000010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int dfs(int r, int c){
	int num = 0;
	for(int i=1;i<=r+1;i++){
		num += COM(c+i, i);
		num %= MOD;
	}
	return num;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	COMinit();
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	--r1; --c1;
	int ans = dfs(r2, c2) + dfs(r1, c1) - dfs(r2, c1) - dfs(r1, c2);
	while(ans < 0) ans += MOD;
	while(ans >= MOD) ans -= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=200005;
const int mod=1e9+7;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int flag=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            flag=1;
            break;
        }
        else if(i<s.size()-2&&s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            flag=1;
            break;
        }
    }
    if(!flag)
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    int cnt = 0;
    char[] c = s.toCharArray();
    if(c[0] == 'R' && c[1] == 'R' && c[2] == 'R') {
      cnt = 3;
    } else if(c[0] == 'R' && c[1] == 'R') {
      cnt = 2;
    } else if(c[1] == 'R' && c[2] == 'R') {
      cnt = 2;
    } else if(c[0] == 'R' || c[1] == 'R' || c[2] == 'R') {
      cnt = 1;
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 26848
# coding: utf-8
"""Fighting over Candies

@author: hijiri.n
@modified: 11-19-2016

"""


def solve():

    candies = list(map(int, input().split()))
    ach = sum(candies) / 2

    for c in candies:
        if c == ach:
            return "Yes"
    return "No"
 

print(solve())


Measured memory_bytes: 3064
n=int(input())
prev=[0,0,0]
for i in range(n):
    dp=[0,0,0]
    c=list(map(int,input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                dp[i]=max(dp[i],prev[j]+c[i])
    prev=dp[:]
print(max(prev))


Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;

    vector<ll> C(n - 1), S(n - 1), F(n - 1);
    REP(i, n - 1) cin >> C[i] >> S[i] >> F[i];

    REP(i, n) {
        ll t = 0;
        FOR(j, i, n - 1) {
            if (t < S[j]) {
                t = S[j] + C[j];
            } else {
                t = (t + F[j] - 1) / F[j] * F[j] + C[j];
            }
        }
        print(t);
    }


}

Measured memory_bytes: 3540
#include<stdio.h>
int main()
{
    int a,b,c,d,n;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a>c){
        if(b>d)
            n=d-a;
        else n=b-a;
    }
    else{
        if(b>d)
            n=d-c;
        else n=b-c;
    }
    if(n>=0)
        printf("%d",n);
    else printf("0");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;
vector<string> v;

bool comp(string &a,string &b){
  if(b.length()!=a.length())  return b.length()>a.length();
  return b>a;
    
}

void f(string s){
    if(s.length()>10)return ;
    v.push_back(s);
    if(s.back()!='0'&&s.back()!='9'){
        string t=s+char(s[s.length()-1]-1),tt=s+char(s[s.length()-1]+1),ttt=s+s[s.length()-1];
        f(t);f(tt);f(ttt);
    }
    else if(s.back()=='9'){
        string t=s+char(s[s.length()-1]-1),tt=s+s[s.length()-1];
        f(t);f(tt);
    }
    else if(s.back()=='0'){
        string t=s+char(s[s.length()-1]+1),tt=s+s[s.length()-1];
        f(t);f(tt);
    }
    return ;
}

int main(){
    int k;cin>>k;
    for(int i=1;i<10;i++)f(to_string(i));
    sort(v.begin(),v.end(),comp);
    //for(string s:v)cout<<s<<endl;
    cout<<v[k-1];
    
}

Measured memory_bytes: 15728
#include<iostream>

using namespace std;


bool StringCompare(const char*Str1, const char*Str2) {
	while (*Str1 != '\0' || *Str2 != '\0') {
		if (*Str1 != *Str2)return false;
		Str1++;
		Str2++;
	}
	return true;
}

int main() {
	char str[1001];
	char command[8];
	int q;
	int a, b;

	cin >> str;
	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> command >> a >> b;
		if (StringCompare(command, "print")) {
			for (int j = a; j <= b; j++) {
				cout << str[j];
			}
			cout << endl;
		}
		else if (StringCompare(command, "reverse")) {
			char tmp[1001];
			for (int j = b; j >= a; j--) {
				tmp[j] = str[a + b - j];
			}
			for (int j = a; j <= b; j++) {
				str[j] = tmp[j];
			}
		}
		else if (StringCompare(command, "replace")) {
			char Input[1001];
			cin >> Input;
			for (int j = a; j <= b; j++) {
				str[j] = Input[j - a];
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1156
var
	n,m,i,j,k,l,f:Longint;
	a,b:array[1..50]of String[50];
begin
	readln(n,m);
	for i:=1 to n do readln(a[i]);
	for j:=1 to m do readln(b[j]);
	for i:=0 to n-m do for j:=0 to n-m do begin
		f:=1;
		for k:=1 to m do begin
			for l:=1 to m do
				if a[i+k][j+l]<>b[k][l] then begin
					f:=0;
					break;
				end;
			if f=0 then break;
		end;
		if f>0 then begin
			writeln('Yes');
			exit;
		end;
	end;
	writeln('No');
end.


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

const int nax = 5e5+5;
vector<long long> ft(nax, 0), arr(nax);
int n;

int LSBOne(int x) {
	return x&(-x);
}

void modify(int p, int v) {
	//for(st[p+=n] += v;p>0;p>>=1) st[p>>1] = st[p] + st[p^1];
	for(int i = p; i <= n; i += LSBOne(i)) ft[i] += v; 
}

long long sum(int l) {
	long long ans = 0;
	for(int i = l; i > 0; i -= LSBOne(i)) ans += ft[i];
	return ans;
}

int main() {
	int q, a, b, t;
	cin >> n >> q;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
      	modify(i+1, arr[i]);
	}
	//ft[0] = 0;
	//for(int i = 1; i < n; i++) ft[i] = ft[i-1] + arr[i];
	while(q--) {
		cin >> t >> a >> b;
		if(!t) {
			modify(a+1, b);
		}
		else cout << sum(b) - sum(a) << endl;
	}
	return 0;
}


Measured memory_bytes: 12136
#include<bits/stdc++.h>
typedef long long ll;
#define m 1000000007
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s')
        s.append("es");
    else
        s.append("s");
    cout<<s<<endl;
    return 0;

}


Measured memory_bytes: 3596
N = int(input())
p = [int(x) for x in input().split()]
cnt = 0
flag = True
for ind,i in enumerate(p):
    if(ind+1==i and flag):
        cnt+=1
        if(ind!=N-1):
            if(p[ind+1]==ind+2):
                flag = False
    else:
        flag = True
print(cnt)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

vector<int> sieve(int n) {
    vector<int> res(n);
    iota(ALL(res), 0);
    for(int i = 2; i * i <= n; i++) {
        if(res[i] < i) {
            continue;
        }
        for(int j = i * i; j < n; j += i) {
            if(res[j] == j) {
                res[j] = i;
            }
        }
    }
    return res;
}

vector<int> factor(int n, const vector<int> &min_factor) {
    vector<int> res;
    while(n > 1) {
        res.emplace_back(min_factor[n]);
        n /= min_factor[n];
    }
    return res;
}

vector<vector<int>> cnt(1000010);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> can(n, true);
    set<int> se;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(!cnt[a[i]].empty()) {
            se.insert(a[i]);
        }
        cnt[a[i]].emplace_back(i);
    }
    for(auto i : se) {
        for(auto j : cnt[i]) {
            can[j] = false;
        }
    }
    vector<int> b = a;
    sort(ALL(b));
    b.erase(unique(ALL(b)), b.end());
    for(int i : b) {
        for(int j = i + i; j < 1000010; j += i) {
            assert(0 <= j && j < 1000010);
            if(!cnt[j].empty() && (int)cnt[j].size() == 1) {
                can[cnt[j].front()] = false;
            }
        }
    }
    print(count(ALL(can), true));
}

Measured memory_bytes: 35344
def is_palindrome(s):
    len_s = len(s)
    ans = True
    for i in range(len_s // 2):
        if s[i] != s[-(i + 1)]:
            ans = False
    return ans

s = input()
len_s = len(s)
ans = True
if is_palindrome(s) == False:
    ans = False
if is_palindrome(s[0:(len_s - 1) // 2]) == False or is_palindrome(s[(len_s + 1) // 2:len_s]) == False:
    ans = False
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import sys
n = int(input())
ans = []

# 6で割った余りで整理

# 3: 5000個 ニコイチで入れると必ず和が6の倍数になる
mod3 = 3

# 0: 5000個 自由に入れられる。調整用。最後にいれる
mod0 = 6

# 2: 5000個 余り4と組ませると和が6の倍数になる
mod2 = 2

# 4: 5000個 余り2と組ませると和が6の倍数になる
mod4 = 4

# 突っ込んだ要素は必ず2か3の倍数になっている
# 要素として2, 3を含むので全体のgcdは1
# 全体の和は6の倍数なので各要素と残りの要素の和は必ず公約数として2か3を持つ

c = 0
ans = []

# n = 3のときだけ例外
if n == 3:
    print(2, 3, 25)
    sys.exit()

while True:
    if c + 2 > n or mod4 > 30000:
        break
    if c % 4 and mod3 + 6 <= 30000:
        ans.append(mod3)
        ans.append(mod3 + 6)
        mod3 += 12
    else:
        ans.append(mod2)
        ans.append(mod4)
        mod2 += 6
        mod4 += 6

    c += 2

for _ in range(c, n):
    ans.append(mod0)
    mod0 += 6
print(" ".join([str(item) for item in ans]))


Measured memory_bytes: 5108
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;
using boost::algorithm::join;
// TOP

void	Main()
{
	ll	n;
	cin >> n;
	ll	root;
	root = sqrt(n);
	while (1)
	{
		if (n % root == 0)
		{
			cout << root + n / root - 2 << endl;
			return ;
		}
		root--;
	}
}
// END
















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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  map<int, int> mp;
  REP(i, n){
    int a;
    cin >> a;
    mp[a]++;
  }
  int ans = 0;
  for(auto p : mp){
    if(p.first < p.second) ans += p.second-p.first;
    else if(p.second < p.first) ans += p.second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

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


int main() {
	int i, j, k;
	
	int N, M, K;

	cin >> N;
	string S;
	N %= 10;
	switch (N)
	{
	case 2:
		S = "hon";
		break;
	case 4:
		S = "hon";
		break;
	case 5:
		S = "hon";
		break;
	case 7:
		S = "hon";
		break;
	case 9:
		S = "hon";
		break;
	case 0:
		S = "pon";
		break;
	case 1:
		S = "pon";
		break;

	case 6:
		S = "pon";
		break;

	case 8:
		S = "pon";
		break;
	case 3:
		S = "bon";
		break;

	}
	cout << S;




	return 0;

}


Measured memory_bytes: 3624
N, M = map(int, input().split())
if N % 2 == 1:
    for i in range(M):
        print(str(i + 1) + " " + str(N - i))
else:
    if M <= N // 4:
        for i in range(M):
            print(str(i + 1) + " " + str(N - i))
    else:
        for i in range(N // 4):
            print(str(i + 1) + " " + str(N - i))
        for i in range(N // 4, M):
            print(str(i + 1) + " " + str(N - i - 1))


Measured memory_bytes: 69084
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define KAISU 150000

int inD;
int c[27] = {0};
int s[366][27] = {0};
int t[366] = {0};
int last[366] = {0};
long long int man = 0;

long long int cal_manzoku(void);
void input_A(void);
void input_t(void);
long long int exec_query(int &d, int &q);
void print_t(void);

int main(){

    srand((unsigned) time(NULL));

    input_A();
    // input_t();
    for(auto i=1; i<=inD; ++i){
        t[i] = rand() % 26 + 1;
    }
    man = cal_manzoku();
    // printf("%lld\n", man);

    for(auto i=0; i<KAISU; ++i){
        int rand_day = rand()%365 + 1;
        int rand_t = rand()%26 + 1;
        int t_pre = t[rand_day];
        long long man_pre = man;

        t[rand_day] = rand_t;
        man = cal_manzoku();
        if(man_pre > man){
            t[rand_day] = t_pre;
        }

    }
    print_t();

    // int m;
    // scanf("%d", &m);
    // for(int i=1; i<=m; ++i){
    //     int d,q;
    //     scanf("%d %d", &d, &q);
    //     man = exec_query(d, q);
    //     print_t();
    //     printf("%lld\n", man);
    // }

}

void print_t(void){
    for(int i=1; i<=inD; ++i){
        printf("%d\n", t[i]);
    }
    // printf("\n");
}

void input_A(){
    scanf("%d", &inD);
    for(int i=1; i<=26; ++i){
        scanf("%d", &c[i]);
    }
    
    // // Test
    // for(int i=1; i<=26; ++i){
    //     printf("%d ", c[i]);
    // }
    // printf("\n\n");

    for(int i=1; i<=inD; ++i){
        for(int j=1; j<=26; ++j){
            scanf("%d", &s[i][j]);
        }
    }
    // // Test
    // for(int i=1; i<=inD; ++i){
    //     for(int j=1; j<=26; ++j){
    //         printf("%d ", s[i][j]);
    //     }
    //     printf("\n");
    // }
    // printf("\n\n");

    return;
}

void input_t(){

    // 問題B入力
    for(int i=1; i<=inD; ++i){
        scanf("%d", &t[i]);
    }

    // // Test
    // for(int i=1; i<=inD; ++i){
    //     printf("%d ", t[i]);
    // }
    // printf("\n\n");
}

long long int cal_manzoku(){

    long long int manzoku=0;

    for(int day=1; day<=inD; ++day){
        long long int down = 0;
        last[t[day]] = day;
        for(int i=1; i<=26; ++i){
            down += c[i]*(day - last[i]);
            // printf("down %d %lld %d %d\n", day, down, c[i], last[i]);
        }

        manzoku = manzoku + s[day][t[day]] - down;
        // printf("manzoku %d %d %lld %d %lld\n", day, t[day], manzoku, s[day][t[day]], down);
        // printf("last %d %d\n", t[day], last[t[day]]);

        // printf("%lld\n", manzoku);
    }

    return(manzoku);

}

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

int main() {
    char a, b;
    cin >> a >> b;

    string ans;
    if (a >= b) {
        for (int i = 0; i < a - '0'; i++)
            ans.push_back(b);
    }
    else {
        for (int i = 0; i < b - '0'; i++)
            ans.push_back(a);
    }

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

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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	//ll n, ans;
	ll n, m;
	in n >> m;
	vector<int> num(n, 0);
	bool ans = true;
	rep(i, m)
	{
		int a, b;
		in a >> b;
		if (a > n)
		{
			ans = false;
			break;
		}
		if (a == 1 && n != 1 && b == 0)
		{
			ans = false;
			break;
		}
		if (num.at(a - 1) == 0)
			num.at(a - 1) = b;
		else if (num.at(a - 1) != b)
		{
			ans = false;
			break;
		}
	}
	if (n != 1 && num.at(0) == 0)
		num.at(0) = 1;
	if (ans)
	{
		rep(i, n)
		{
			out num.at(i);
		}
		out endl;
	}
	else
		out - 1 en;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int h, w;

ll ans = (ll)(1e10 + 5);

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

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = w / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(h - i) * (ll)(j);
      ll trd = (ll)(h - i) * (ll)(w - j);

      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = (h - i) / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(j) * (ll)(w);
      ll trd = (ll)(h - i - j) * (ll)(w);
      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  swap(h, w);

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = w / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(h - i) * (ll)(j);
      ll trd = (ll)(h - i) * (ll)(w - j);

      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = (h - i) / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(j) * (ll)(w);
      ll trd = (ll)(h - i - j) * (ll)(w);
      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::string stmax(std::string a, std::string b)
{
	if (a.length() > b.length()) return a;
	else if (a.length() < b.length()) return b;
	else
	{
		rep(i, a.length())
		{
			if (a[i] - '0' > b[i] - '0') return a;
			else if (a[i] - '0' < b[i] - '0') return b;
		}
	}
	return a;
}

std::vector<LL>A, cost;
std::vector<std::string>memo;

std::string dp(LL i)
{
	if (i < 0) return "-1";
	if (i == 0) return "";
	if (memo[i].length() > 0) return memo[i];
	std::string ans = "";
	for (LL j : A)
	{
		std::string res = dp(i - cost[j]);
		if (res != "-1") ans = stmax(ans, std::to_string(j) + res);
	}
	if (ans == "") ans = "-1";
	return memo[i] = ans;
}

int main()
{
	LL N, M;
	in >> N >> M;
	A.resize(M);
	rep(i, M) in >> A[i];

	std::sort(A.rbegin(), A.rend());
	cost.resize(10);
	cost[1] = 2;
	cost[2] = 5;
	cost[3] = 5;
	cost[4] = 4;
	cost[5] = 5;
	cost[6] = 6;
	cost[7] = 3;
	cost[8] = 7;
	cost[9] = 6;
	memo.resize(N + 1);
	out << dp(N) << std::endl;
}


Measured memory_bytes: 30976
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long

using namespace std;

typedef pair<int, int> td;

int main(){
    #ifdef ZERBRA
        freopen("code.inp", "r", stdin);
        //freopen("code.out", "w", stdout);
    #endif // ONLINE_JUDGE
    int n;
    scanf("%d", &n);
    ll a[100000], op[100000];
    for (int i = 0; i < n; ++i){
        scanf("%I64d", &a[i]);
        op[i] = 1e9 + 5;
    }
    op[0] = 0;
    for (int i = 0; i < n; ++i){
        op[i+1] = min(op[i+1], op[i] + abs(a[i]-a[i+1]));
        op[i+2] = min(op[i+2], op[i] + abs(a[i]-a[i+2]));
    }
    printf("%lld", op[n-1]);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=2.2e6;
int const MD=998244353;

int madd(int x,int y) {
	if (x+y<MD) return x+y; else return x+y-MD;
}
int msub(int x,int y) {
	if (x-y>=0) return x-y; else return x-y+MD;
}
int mmul(int x,int y) {
	return int(ll(x)*y % MD);
}
int mpow(int x,int p) {
	int res=1;
	while (p>0) {
		if (p%2) res=mmul(res,x);
		x=mmul(x,x);
		p/=2;
	}
	return res;
}
int minv(int x) {
	return mpow(x,MD-2);
}
int mdiv(int x,int y) {
	return mmul(x,mpow(y,MD-2));
}

template<int N>
struct mod_comb {
	int f[N],rf[N];
	mod_comb() {
		f[0]=rf[0]=1;
		rep(i,1,N) {
			f[i]=mmul(f[i-1],i);
			rf[i]=minv(f[i]);
		}
	}
	int comb(int n,int k) {
		if (n<k) return 0;
		return mmul(f[n],mmul(rf[n-k],rf[k]));
	}
	int distr(int n,int k) {
		return comb(n+k-1,k-1);
	}
};
mod_comb<MAXN> mcomb;
#define comb(n,k) mcomb.comb(n,k)
#define distr(n,k) mcomb.distr(n,k)

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,M;
	cin>>N>>M;
	
	int res=0;
	rep(i,0,min(N,M)+1) if ((3*M-i)%2==0) {
		int add=mmul(comb(N,i),distr((3*M-i)/2,N));
		res=madd(res,add);
	}
	rep(i,0,min(N,M)+1) if ((M-i)%2==0) {
		int sub=mmul(comb(N,i),distr((M-i)/2,N));
		res=msub(res,mmul(sub,N));
	}
	rep(i,0,min(N,M)+1) if ((M-i)%2==0) {
		int add=mmul(comb(N-1,i),distr((M-i)/2,N-1));
		res=madd(res,mmul(add,N));
	}
	cout<<res<<'\n';
}


Measured memory_bytes: 17408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        StringTokenizer st;
        try {
            String line;
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                double x1 = Double.parseDouble(st.nextToken());
                double y1 = Double.parseDouble(st.nextToken());
                double r1 = Double.parseDouble(st.nextToken());
                double x2 = Double.parseDouble(st.nextToken());
                double y2 = Double.parseDouble(st.nextToken());
                double r2 = Double.parseDouble(st.nextToken());
                double distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
                if (distance < r1 - r2) {
                    System.out.println("2");
                } else if (distance < r2 - r1) {
                    System.out.println("-2");
                } else if (distance <= r1 + r2) {
                    System.out.println("1");
                } else{
                    System.out.println("0");
                }

            }
        } catch (
                Exception e
                )

        {
            e.printStackTrace();
        }

    }
}

Measured memory_bytes: 24028
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll x;
	cin>>x;
	ll r = 2;
	while(x--){
		r = r*2+2;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    string S; cin >> S;
    ll res = 1000000000;

    rep(i, S.size()-2){
        int tmp = (S[i] - '0')*100 + (S[i+1] - '0')*10 + (S[i+2]-'0');
        int tmp2 = abs(tmp - 753);
        if(tmp2 < res){
            res = tmp2;
        }
    }
        cout << res << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[] x = new int[n];
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
		}

		int[] y = x.clone();
		Arrays.sort(y);

		for (int i=0;i<n;i++) {
			if(x[i] >= y[n/2]) {
				System.out.println(y[n/2-1]);
			} else {
				System.out.println(y[n/2]);
			}
		}
	}

}


Measured memory_bytes: 91788
#include <cstdio>

using namespace std ;
#define maxn 60

char A[maxn][maxn], B[maxn][maxn] ;
int n, m ;

int main(void){

	scanf("%d %d",&n,&m ) ;
	for(int i=0; i<n; i++ )
		scanf("%s",A[i]) ;
	for(int i=0; i<m; i++ )
		scanf("%s",B[i]) ;
	for(int i=0; i<=n-m; i++)
		for(int j=0; j<=n-m; j++) {
			int flag = 1 ;
			for(int i0=i; i0<i+m; i0++ )
				for(int j0=j; j0<j+m; j0++ ) {
					if(A[i0][j0]!=B[i0-i][j0-j]) flag = 0 ;
				}
			if(flag ==1 ) {
				printf("Yes\n") ;return 0 ;
			}
	}
	printf("No\n") ;
	return 0 ;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
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);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);
  
  int a[4], i = 3;
  while(i >= 0){
    a[i--] = n % 10;
    n /= 10;
  }

  int op[8][3] = {{1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1}, {-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1}};
  int out, k;

  for(int i = 0; i < 8; i++){
    out = a[0];
    for(int j = 0; j < 3; j++){
      out += op[i][j] * a[j + 1];
    }
    if(out == 7){
      k = i; break;
    }
  }

  printf("%d", a[0]);
  for(int i = 0; i < 3; i++){
    printf("%c%d", (op[k][i] == 1 ? '+' : '-'), a[i + 1]);
  }
  printf("%c%d", '=', 7);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s, t;
    cin >> s >> t;

    int n = s.length();

    string s2;
    rep(i, n) {
        s2 = "";
        srep(j, i, n) s2 += s[j];
        rep(j, i) s2 += s[j];
        if (s2 == t) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
    cin >> a;
    for(int s = 1;s < a.size();s++)
        if(a[s] == a[s - 1])
        {
            cout << s << " " << s + 1 << endl;
            return 0;
        }
    for(int s = 2;s < a.size();s++)
        if(a[s] == a[s - 2])
        {
            cout << s - 1 << " " << s + 1 << endl;
            return 0;
        }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		if(N>0){
			N = N*(N-1)/2;
		}
		if(M>0){
			M = M*(M-1)/2;
		}
		long ans = N+M;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-28:14:54:39
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

struct edge {
  int from, to;
  int64 cost;
};

constexpr int64 INF = 2e18;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; int64 p; cin >> n >> m >> p;
  vector<int64> dis(n, INF);
  vector<edge> es;

  for (int i = 0; i < m; ++i) {
    int a, b; int64 c;
    cin >> a >> b >> c;
    --a; --b;
    es.push_back({a, b, p - c});
  }

  dis[0] = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (const auto &e : es) {
      if (dis[e.from] == INF) continue;
      if (dis[e.to] > dis[e.from] + e.cost) {
        dis[e.to] = dis[e.from] + e.cost;
      }
    }
  }

  bool neg[n] = {};
  for (int i = 0; i < n; ++i) {
    for (const auto &e : es) {
      if (dis[e.from] == INF) continue;
      if (dis[e.to] > dis[e.from] + e.cost) {
        dis[e.to] = dis[e.from] + e.cost;
        neg[e.to] = true;
      }
      if (neg[e.from]) {
        neg[e.to] = true;
      }
    }
  }

  int64 ans = -dis[n - 1];

  if (neg[n - 1]){
    cout << -1 << endl;
  } else {
    cout << max(0LL, ans) << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include<iostream>

int main(){
  int d,S;
  while(std::cin >> d){
    for(int i = 1; i < 600/d; ++i){
      S += (i*d) * (i*d) * d;
    }
    std::cout << S << std::endl;
    S = 0;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
# define ALL(x) (x).begin(), (x).end()
using namespace std;
int main()
{int A,B,C,X;
 cin>>A>>B>>C>>X;
 int count=0;
 for(int i=0;i<=A;i++){
 	for(int k=0;k<=B;k++){
    	for(int n=0;n<=C;n++){
        if(500*i+100*k+50*n==X){count++;}
        
        }}
 
 }
   cout<<count<<endl;
}


Measured memory_bytes: 256
from itertools import groupby
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))


# RUN LENGTH ENCODING str -> tuple


def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


if __name__ == "__main__":
    n = int(input())
    cnt = 0
    for i in range(n):
        d, e = iparse()
        if d == e:
            cnt += 1
        else:
            cnt = 0
            
        if cnt == 3:
            print("Yes")
            exit()
    print("No")
    


Measured memory_bytes: 9264
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
N = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

b=a.inject(:+)
c=0

minval=99999999
(0..N-1).each do |i|
    c+=a[i]
    b-=a[i]
    tmp=(b-c).abs
    if tmp<minval
        minval=tmp
    end
end

puts minval


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

using namespace std;

int dp[100001],n,m,a,b;
int solve(vector<vector<int> > &arr,int i)
{
	if(dp[i]!=-1)return dp[i];
	
	for(int j=0;j<arr[i].size();j++)
	{
		dp[i]=max(1+solve(arr,arr[i][j]),dp[i]);
	}
	return dp[i];
}
int main()
{

ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
memset(dp,-1,sizeof(dp));
cin>>n>>m;
vector<vector<int> >arr(n+1);
for(int i=0;i<m;i++)
{
	cin>>a>>b;
	arr[a].push_back(b);
}
for(int i=1;i<=n;i++)
{
	if(arr[i].size()==0)
	{
		dp[i]=0;
	}
}
int maxi=INT_MIN;
for(int i=1;i<=n;i++)
{
	maxi=max(maxi,solve(arr,i));
}
cout<<maxi;

}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int N,M; cin >> N >> M;
    vector<char> S(N,'.');
    vi s(M);
    vector<char> c(M);
    rep(i,M) cin>>s[i]>>c[i];
  
    bool flag=true;
  
    rep(i,M){
      if(S[s[i]-1]=='.'|| S[s[i]-1]==c[i] ){
        S[s[i]-1]=c[i];
      }else{
        flag = false;
      }
    }
    if(S[0] == '0'&&N!=1) flag = false;
    rep(i,N){
      if( S[i]=='.') {
        if(N!=1&&0==i)
          S[i]='1';
        else
          S[i]='0';
      }
      
    }
    
  
    if(flag) rep(i,N)cout<< S[i];
    else cout<<-1;
    return 0;
}


Measured memory_bytes: 3592
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
ans += b[a[0]-1] 
for i in range(1,n):
    ans += b[a[i]-1]
    if a[i-1]+1 ==  a[i]:
        ans += c[a[i]-2]

print(ans)

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

int main() {
    int N, L; cin >> N >> L;
    vector<string> S(N);
    for(auto &e : S) cin >> e;
    sort(S.begin(), S.end());
    for(auto &e : S) cout << e;
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	double n,k; cin >>n>>k;
	double ans=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		while(pow(2,cnt)*i<k)cnt++;
		ans+=(1/(n*pow(2,cnt)));
	}
	printf("%.9f\n",ans);
}


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

int main(){
  int i,n,m;
  bool p = false;
  bool y = false;
  bool w = false;
  bool g = false;
  string t;
  
  m = 0;
  cin >> n;
  
  for(i=0;i<n;i++){
    cin >> t;
    if(t=="P") p = true;
    if(t=="Y") y = true;
    if(t=="W") w = true;
    if(t=="G") g = true;
  }
  
  if(p) m++;
  if(y) m++;
  if(w) m++;
  if(g) m++;
  
  if(m == 3) cout << "Three" << endl;
  else if(m == 4) cout << "Four" << endl;
  else cout << "Error" << endl;
}

Measured memory_bytes: 256
// ABC_052_A

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

using ll = long long;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if ((a*b) <= (c*d)) cout << c * d << "\n";
  else cout << a * b << "\n";

  return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
using namespace std;
int h,w,dir[4][2] = {{1,0},{-1,0},{0,-1},{0,1}};
char mmap[105][105];
bool vis[105][105];
void dfs(int x,int y,char c)
{
    vis[x][y] = 1;
    for(int i = 0;i < 4;i++)
    {
        int dx = x + dir[i][0];
        int dy = y + dir[i][1];
        if(dx >=0 &&dx < h&&dy >= 0&&dy < w&&!vis[dx][dy]&&mmap[dx][dy] == c)
            dfs(dx,dy,c);
    }
    return ;
}
int main()
{
    while(scanf("%d %d",&h,&w) != EOF)
    {
        if(h == 0||w == 0)
            break;
        memset(vis,0,sizeof(vis));
        int ans = 0;
        for(int i = 0;i < h;i++)
        {
            getchar();
            for(int j = 0;j < w;j++)
                scanf("%c",&mmap[i][j]);
        }
        for(int i = 0;i < h;i++)
        {
            for(int j = 0;j < w;j++)
            {
                if(!vis[i][j])
                {
                    ans++;
                    dfs(i,j,mmap[i][j]);
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>

int main (void)
{
  int i, cnt = 0;
  char str[4];

  scanf("%s", str);

  for (i = 0; i < 3; i++) {
    if (str[i] == '1') {
      cnt++;
    }
  }
  printf("%d", cnt);

  return 0;
}

Measured memory_bytes: 128