akhauriyash/Code-Regression huggingface dataset:
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pii pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    int a[N];
	void main()
	{
		int n=qread();fo(i,1,n+n+n) a[i]=qread();
		sort(a+1,a+n+n+n+1);ll sum=0;for(int i=n+1;i<=n+n+n;i+=2) sum+=a[i];write(sum);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1408
#include"bits/stdc++.h"
#define int ll
using namespace std;
using ll = long long ;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
//#define endl '\n'
///       Author
///        ::
///    (  NOBODY  )
///   No Copyright .....You can copy and paste it without my permission...................................
///    Another Loser...........
/// !!!!!!!!!!!!!!!
#define pb push_back
#define N 1000020
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

int32_t main()
{


    int a,b,c,x;
    set<int>st;
    for(int i=0; i<3; i++)
    {
        cin>>x;
        st.insert(x);
    }
    if(st.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n, a[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    int x = n, y = n - 1;
    forn(i, 1, n) {
        int v;
        cin >> v;
        if (i & 1)
            a[++y] = v;
        else
            a[--x] = v;
    }
    if (n & 1)
        for1(i, y, x)
            cout << a[i] << " ";
    else
        forn(i, x, y)
            cout << a[i] << " ";

    return 0;
}


Measured memory_bytes: 2944
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    K = int(input())
    x = int(input())
    y = int(input())

    ans = x * min(N, K) + y * max(N - K, 0)

    print(ans)

if __name__ == '__main__':
    solve()

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

int main()
{
  string s;
  cin >> s;
  
  string ans = "";
  int minans = 1000;
  int n = s.size();
  rep(i,n-2){
    ans += s[i];
    ans += s[i+1];
    ans += s[i+2];
    if(abs(stoi(ans) - 753) < minans){
      minans = abs(stoi(ans) - 753);
    }//if
    ans = "";
  }
  
  cout << minans << endl;
}


Measured memory_bytes: 3584
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var N = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var len = a.Length;
        var count = 0;
        if (!a.Contains(1)) return -1;
        var i = 1;
        for (int j = 0; j < len; j++) {
            if (a[j] != i) count++;
            else i++;
        }
        return count;
    }
}

Measured memory_bytes: 43172
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

//C++11

int main() {
	for (int w; cin >> w;) {
		string s = "";
		for (int i = 9; i >= 0; i--) {
			int a = pow(2, i);
			if (w / a) {
				if (s == "")
					s = to_string(a);
				else
					s = to_string(a) + " " + s;
				w -= a;
			}
		}
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int t = 0;
  int x = 0;
  int y = 0;
  int t_next, x_next, y_next;
  bool success = true;
  REP(i,n){
      cin >> t_next >> x_next >> y_next;
      int dist = abs(x_next-x) + abs(y_next-y);
      if (t_next - t < dist || (t_next-t+dist)%2==1)success = false;
      t = t_next;
      x = x_next;
      y = y_next;
  }
  if (success)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
def func(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n-1-i]:
            return False
    else:
        return True

if func(s[0:(n-1)//2]) and func(s[(n+3)//2-1:]) and func(s):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ll MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll n;
    cin>>n;
    
    VEC(ll,a,n);
    ll m=0;
    REP(i,n){
        cin>>a[i];
        m=max(m,a[i]);
    }
    ll mb=0,mabs=INF;
    ll mmm=(m+1)/2;
    REP(i,n){
        ll t=abs(mmm-a[i]);
        //sl(mabs,mb,t)
        if(mabs>=t){
            mabs=t;
            mb=a[i];
        }
    }
    cout<<m<<" "<<mb;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N + 1), B(N);
    for (int i = 0; i < N + 1; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    long long ans = 0; 
    for (int i = 0; i < N; i++) {
        if (A[i] <= B[i]) {
            ans += A[i];
            if (A[i + 1] <= (B[i] - A[i])) {
                ans += A[i + 1];
                A[i + 1] = 0;
            }
            else {
                ans += B[i] - A[i];
                A[i + 1] -= B[i] - A[i];
            }
            A[i] = 0;
        }
        else ans += B[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

string A;
int Path[26][200010];
int From[200010];
string ans;

void dp(){
    A = "#" + A;
    int L = A.size();
    for(int i = 0; i < 26; i++){
        Path[i][L-1] = 200005;
        for(int j = L-1; j > 0; j--){
            if(A[j] - 'a' == i)Path[i][j-1] = j;
            else Path[i][j-1] = Path[i][j];
        }
    }
}

void bfs(){
    for(int i = 0; i < 200010; i++)From[i] = -1;
    queue<int>Q;
    Q.push(0);
    while(true){
        int pos = Q.front();
        Q.pop();
        if(pos == 200005)break;
        for(int i = 0; i < 26; i++){
            if(From[Path[i][pos]] != -1)continue;
            From[Path[i][pos]] = pos;
            Q.push(Path[i][pos]);
        }
    }
}

void backTrack(){
    ans = "";
    for(int pos = 200005; pos; pos = From[pos]){
        for(int i = 0; i < 26; i++){
            if(Path[i][From[pos]] == pos){
                ans += string(1, 'a'+i);
                break;
            }
        }
    }
    reverse(ans.begin(), ans.end());
}

int main(){
    cin >> A;
    dp();
    bfs();
    backTrack();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 21696
from collections import defaultdict


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


class Solution:
    def main(self):
        N, M = map(int, input().split())
        ufind = UnionFind(N)
        for _ in range(M):
            X, Y, Z = map(int, input().split())
            ufind.union(X-1, Y-1)
        print(len(set([ufind.find(i) for i in range(N)])))


if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 18276
import sys,collections as cl,bisect as bs,math,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
mod = 10**9+7 #出力の制限
N = 10**6
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def p(n,r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
# a = cmb(n,r)
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

x,y = m()


li = []
count = 0

for i in range(0,x+1):
    nx = x - i
    ny = y - 2*i

    if nx >= 0 and ny >= 0 and nx == 2*ny:
        count += cmb(i+ny,i)
        count %= mod
print(count)


Measured memory_bytes: 128508
#B問題
S =input()
if "00" < S[0:2] <="12" and "13" <= S[2:4] <= "99":
    print("MMYY")
elif "13" <= S[0:2] <= "99" and "00" <S[2:4] <= "12":
    print("YYMM")
elif "00" < S[0:2] <= "12" and "00" < S[2:4] <= "12":
    print("AMBIGUOUS")
elif "00" == S[0:2] and "00" < S[2:4] <= "12":
    print("YYMM")
elif "00" < S[0:2] <= "12" and S[2:4] == "00":
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
)

func toDigits(s string) []int {
	ret := make([]int, 0)
	for _, r := range s {
		i, _ := strconv.Atoi(string(r))
		ret = append(ret, i)
	}
	return ret
}

func calc(is []int, plus []bool) int {
	sum := 0
	n := is[0]
	for i, b := range plus {
		if b {
			sum += n
			n = is[i+1]
		} else {
			n = n*10 + is[i+1]
		}
	}
	return sum + n
}

func solve(is []int) int {
	l := len(is) - 1
	sum := 0
	for mask := 0; mask < 1<<uint(l); mask++ {
		ops := make([]bool, l)
		for i := 0; i < l; i++ {
			ops[i] = 1<<uint(i)&mask > 0
		}
		sum += calc(is, ops)
	}
	return sum
}

func main() {
	var s string
	fmt.Scan(&s)
	is := toDigits(s)
	fmt.Println(solve(is))
}


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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair


int main()
{
    ll X;
    INX(X);

    //ユークリッドの互除法で360との最大公約数を求める
    ll B = 360;
    ll A = X;
    ll r = 0;
    while(true)
    {
        r = B % A;
        if(r == 0)
        {
            //このときのAが最大公約数
            OUTX(360 / A);
            break;
        }
        else
        {
            B = A;
            A = r;
        }
    }
    


    return 0;
}


Measured memory_bytes: 3532
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	char S[100];
	scanf("%s",S);
	int N = strlen(S);
	int NN = N;
	for(int i=0; i<N/2; i++){
		if(S[i] != S[N-1-i]){
			printf("No\n");
			return 0;
		}
	}
	NN = N/2;
	if(NN %2 != 0){
		for(int i=0; i<NN/2; i++){
			if(S[i] != S[NN-1-i]){
				printf("No\n");
				return 0;
			}	
		}
		for(int i=0; i<NN/2;i++){
			if(S[NN+1+i] != S[N-1-i]){
				printf("No\n");
				return 0;				
			}
		}
		printf("Yes\n");
	}
	else{
		for(int i=0; i<NN/2; i++){
			if(S[i] != S[NN-1-i]){
				printf("No\n");
				return 0;
			}
			else if(S[NN+1+i] != S[NN -1 -i]){
				printf("No\n");
				return 0;
			}		
		}
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#                               #
    # author : samars_diary #
    # 17-09-2020 │ 20:30:32 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=li();b=li();c=0
    for i in range(len(a)):
        if a[i]!=b[i]:
            c+=1
    print(c)
for _ in range(1):
    solve()

Measured memory_bytes: 12396
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[1003];
	int i,len,k=0;
	scanf("%s",s);
	len=strlen(s);
	if(s[len-1]=='s'){ 
		s[len]='e';
		s[len+1]='s';
		k=1;
	}
	else	s[len]='s';
	if(k==1){
		for(i=0;i<len+2;i++) printf("%c",s[i]);
	}
	else{
		for(i=0;i<=len;i++) printf("%c",s[i]);
	}
	return 0;
}
		

Measured memory_bytes: 1624
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sa = set(A)
sb = set(B)
row, col = 0, 0
ans = 1
MOD = 10**9+7

for i in range(N*M, 0, -1):
    if (i in sa) and (i in sb):
        row += 1
        col += 1
    elif (i not in sa) and (i in sb):
        ans *= col
        row += 1
    elif (i in sa) and (i not in sb):
        ans *= row
        col += 1
    else:
        ans *= row*col-(N*M-i)
    
    ans %= MOD

print(ans)

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

int main()
{
  int n;
  cin >> n;
  for(int a = 1; a <= 9; ++a) {
    for(int b = 1; b <= 9; ++b){
     if(a * b == n) {
       cout << "Yes" << endl;
       return 0;
     }
    }
  }
  cout << "No" << endl;
}


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

class Program{

  static string ans;

  static int Main() {

    string nyu = Console.ReadLine();

    // ここまで入力

    if (nyu == "A") {
      ans = "T";
    } else if (nyu == "T") {
      ans = "A";
    } else if (nyu == "C") {
      ans = "G";
    } else if (nyu == "G") {
      ans = "C";
    }

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


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

int main() {
  int A , B, C , D;
  cin >> A >> B >> C >> D;
  
  if ( A + B == C + D ){
    cout << "Balanced" << endl;
  }
  else if ( A + B > C + D){
    cout << "Left" << endl;
  }
  else if ( A + B < C + D){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    REP(i,n+1){
        cin >> a[i];
    }
    REP(i,n){
        cin >> b[i];
    }

    ll ans = 0;
    REP(i,n){
        if(a[i]<=b[i]){
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }
        else{
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }

        if(a[i+1]<=b[i]){
            ans += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
        }
        else{
            ans += b[i];
            a[i+1] -= b[i];
            b[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int a,b;
  cin >> a >> b;
  int f1=0,f2=0,f3=0;
  if(a%3==0)
    f1=1;
  if(b%3==0)
    f2=1;
  if((a+b)%3==0)
    f3=1;
  if(f1==1 || f2==1 || f3==1)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}


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

string S;

int main(){

    cin >> S;
    int size, i, j;
    int flg_a=1, flg_b=1, flg_c=1;

    size = S.size();
    j = size-1; 

    for (i=0; i<size/2; i++){
        if (S.at(i) == S.at(j)){
            j--;
            continue;
        }
        else{
            flg_a = 0;
            break;
        }
    }

    j = size/2-1;
    for (i=0; i<((size/2)/2); i++){
        if (S.at(i) == S.at(j)){
            j--;
            continue;
        }
        else{
            flg_b = 0;
            break;
        }
    }

    j = size-1;
    for (i=size/2+1; i<(size/2+size/4+1); i++){
        if (S.at(i) == S.at(j)){
            j--;
            continue;
        }
        else{
            flg_c = 0;
            break;
        }
    }

    if (flg_a == 1 && flg_b == 1 && flg_c == 1){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
/**
* @author khokharnikunj8
**/
#include <bits/stdc++.h>

using namespace std;

//macros
#define ll long long
#define endl "\n"
#define pb push_back

//debug

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }


template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    map<char, char> mp;
    mp['r'] = 'p';
    mp['p'] = 's';
    mp['s'] = 'r';
    int n, k;
    cin >> n >> k;
    map<char, int> add;
    cin >> add['r'] >> add['s'] >> add['p'];
    string T;
    cin >> T;
    string c = "";
    for (char temp : T) c += (mp[temp]);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (i - k >= 0) {
            if (c[i - k] == c[i]) c[i] = '#';
            else ans += add[c[i]];
        } else {
            ans += add[c[i]];
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int a, b;
  double c;
  cin >> a >> b;
  
  c = (a + b) / 2.0;
  
  if((a + b) % 2 == 1){
    c = c + 0.5;
  } 
  
  cout << c << endl;
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int w,d,n;cin>>w>>d>>n;
	
	const int inf=LLONG_MAX/3;
	vvc<int> mx(w,vi(d,-inf));
	vc<tuple<int,int,int>> cs;
	rep(i,n){
		int x,y,z;cin>>x>>y>>z;
		x--;y--;
		cs.eb(x,y,z);
		rep(p,w)rep(q,d)
			chmax(mx[p][q],z-abs(p-x)-abs(q-y));
	}
	for(auto c:cs){
		int x,y,z;tie(x,y,z)=c;
		if(mx[x][y]!=z){
			cout<<"No"<<endl;
			return 0;
		}
	}
	int ans=0;
	rep(i,w)rep(j,d)ans+=mx[i][j];
	cout<<ans<<endl;
}



Measured memory_bytes: 3228
#include <iostream>
#define rep(i, n) for (i = 0; i < n; i++)

using namespace std;

const int N = 2e5 + 10;

int k, n, i;
int a[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k >> n;
	rep(i, n) cin >> a[i];
	a[n] = k + a[0];
	
	int res = k;
	rep(i, n) {
		int dist = k - (a[i + 1] - a[i]);
		res = min(res, dist);
	}
	
	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c;
	d=0;
	
	while(a<=b){
		if(c%a==0){
			d=d+1;
		}
			a++;
	}
	
	cout<<d<<endl;
	
return 0;
}


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

int main(){
  ll n,d,x,y,ans=0;
  cin>>n>>d;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    if(x*x+y*y<=d*d)ans++;
  }
  cout<<ans<<endl;
}


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

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 9223372036854775807LL
#define INF 1000000000
#define EPS 1e-8
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))
#define bits(a) __builtin_popcount(a)

using namespace std;

int DP[5005][5005], m;
bool v[5005][5005];

int solve(int ind, int rem)
{
  if(ind < 0) ind = 0;
  if(!rem) return ind == m;
  int &temp = DP[ind][rem];
  if(v[ind][rem]) return temp;
  v[ind][rem] = true;
  temp = solve(ind + 1, rem - 1) * 2;
  if(temp >= mod) temp -= mod;
  temp += solve(ind - 1, rem - 1);
  if(temp >= mod) temp -= mod;
  return temp;
}

int power(int a, int b)
{
  if(b == 0) return 1;
  int temp = power(a, b / 2);
  temp = (temp * 1LL * temp) % mod;
  if(b & 1) temp = (temp * 1LL * a) % mod;
  return temp;
}

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  m = s.size();
  cout << (solve(0, n) * 1LL * power(power(2, m), mod - 2)) % mod;
  return 0;
}

Measured memory_bytes: 91392
n = gets.to_i
x,y = 0,0
t = 0

while line = gets
	tn,xn,yn = line.split.map &:to_i

	dt = tn - t
	t = tn

	dl = (x - xn).abs + (y - yn).abs
	x = xn
	y = yn
	
	if dl > dt
		puts "No"
		exit
	end
	
	unless (dl - dt) % 2 == 0
		puts "No"
		exit
	end
end

puts "Yes"


Measured memory_bytes: 1788
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

//  COMMAND TO USE WHEN RUNNING CODE: g++ day6.cpp -o day6 -std=c++11 -O2  | to run: ./(name of file)  //

int D, N;

int main() {
    cin >> D;
    N = 25 - D;
    cout << "Christmas";
    for ( int i=0; i < N; i++ ) {
        cout << " Eve";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    double ma=0;
    int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    int ansa,ansb;
    for(int i=0;(i*100*a)<=f;i++){
        for(int j=0;(i*100*a+j*100*b)<=f;j++){
            for(int k=0;(i*100*a+j*100*b+k*c)<=f;k++){
                for(int l=0;(i*100*a+j*100*b+k*c+l*d)<=f;l++){
                    double aa=100*(i*a+b*j);
                    double bb=k*c+l*d;
                    double no=100*bb/(aa+bb);
                    if(ma<no&&(aa/100)*e>=bb){
                        ma=no;
                        ansa=aa+bb;
                        ansb=bb;
                    }
                }
            }
        }
    }   
    if(ansa==0){
        ansa=a*100;
    }
    cout<<ansa<<" "<<ansb<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<ll> a_accum(n + 1);
    a_accum[0] = 0;
    map<ll, ll> mp;
    ++mp[0] ;
    rep(i, n) {
        ll a;
        cin >> a;
        a_accum[i+1] = a_accum[i] + a;
        ++mp[a_accum[i+1]];
    }
    ll ans = 0;
    for ( auto tmp_mp : mp ) {
//        if ( tmp_mp.first == 0 ) {
//            ans += tmp_mp.second;
//        }
        if ( tmp_mp.second >= 2 ) {
            ans += ( tmp_mp.second * ( tmp_mp.second - 1 ) / 2 );
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14336
# 先に相手の隣に立ったら負け確定
# 一方が距離を縮め、一方が逆方向にいく -> 距離は縮まらない(+-0)
# 両方とも縮める/外側にいく -> 距離は2減る/増える
# 先攻と後攻の間が1 -> 先攻が先に横に立つので負け
# 2 -> 後攻, 3 -> 先攻, .....
n, a, b = map(int, input().split())
dif = max(a, b) - min(a, b)
print("Borys" if dif % 2 == 1 else "Alice")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   //#ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<int> a,b,c,d;
 
  for(int i=0;i<n;i++ )
  {
     int x;
     cin>>x;
     c.push_back(x);
  }

  for(int i=0;i<n;i++ )
  {
     int y;
     cin>>y;
     d.push_back(y);
  }

   for(int i=0;i<n;i++)
  {
  	a.push_back(i+1);
  	b.push_back(i+1);
  }
   
  if(c==d)
  {
  	cout<<0<<endl;
  }
  else
  {
  	int cnt1=0,cnt2=0;
  	
  	while(a!=c)
  	{
  		cnt1++;
  		next_permutation(a.begin(),a.end());
  	}

  	while(b!=d)
  	{
  		cnt2++;
  		next_permutation(b.begin(),b.end());
   	}
     cout<<abs(cnt1-cnt2)<<endl;
  }

 

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
  long long x, pos, plus_min, minus_min;
  unsigned long k, d;
  cin >> x >> k >> d;
  pos = x;
  plus_min = pow(10, 15) + 1;
  minus_min = -pow(10, 15) - 1;
  
  long long quotient =  abs(x) / d, mod = abs(x) % d;
  if (k * d <= abs(x)) {
    if (x < 0) {
      cout << - x - k * d;
    } else {
      cout << x - k * d;
    }
    return 0;
  } else {
    k -= quotient;
    pos = x < 0 ? -mod : mod;
  }
  
  for (unsigned long i = 1; i <= k; i++) {
    if (pos < 0) {
      pos += d;
      if (pos == plus_min) {
        if ((k - i) % 2) {
          cout << -minus_min;
          return 0;
        } else {
          cout << plus_min;
          return 0;
        }
      }
      if (pos >= 0 && pos < plus_min) plus_min = pos;
    } else {
      pos -= d;
      if (pos == minus_min) {
        if ((k - i) % 2) {
          cout << plus_min;
          return 0;
        } else {
          cout << -minus_min;
          return 0;
        }
      }
      if (pos < 0 && pos > minus_min) minus_min = pos;
    }
  }
  
  cout << abs(pos);
  
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=1;
    cin>>n;
    char s[n];
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
            c++;
    }

    cout<<c<<endl;
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<998244353>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? fact[i - 1] * i : 1;
  inv_fact[n] = power(fact[n], mint::mod - 2);
  for (int i = n; i--; ) inv_fact[i] = (i + 1) * inv_fact[i + 1];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template <> mint& mint::operator/=(mint b) {
  return *this *= b.v < minv.size() ? minv[b.v] : power(b, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  prepare(n);
  mint res;
  for (int i = n - k; i <= n; ++i) {
    res += binom(n - 1, i - 1) * m * power<mint>(m - 1, i - 1);
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 5512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main() {
    int n;
    cin >> n;
    set< vector <int> >st;
    rep(i,n){
        vector<int> a(3);
        cin >> a[0] >> a[1] >> a[2];
        sort(a.begin(),a.end());
        st.insert(a);
    }
    cout << n - st.size() << endl;
	return 0;
}


Measured memory_bytes: 3176
n, m = map(int, input().split())
h = list(map(int, input().split()))
path = [[] for i in range(n)]
ans = 0
for i in range(m):
    a, b = map(int, input().split())
    path[a - 1].append(b - 1)
    path[b - 1].append(a - 1)

for i in range(n):
    if len(path[i]) == 0:
        ans += 1
    for j in range(len(path[i])):
        if h[path[i][j]] >= h[i]:
            break
        if j == len(path[i]) - 1:
            ans += 1
print(ans)

Measured memory_bytes: 29392
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[1]*N

for i in range(M):
  a,b=map(int,input().split())
  if H[a-1]<=H[b-1]:
    A[a-1]-=A[a-1]
  if H[a-1]>=H[b-1]:
    A[b-1]-=A[b-1]

print(sum(A))

Measured memory_bytes: 20024
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main()
{
    fastio;
    file();
    vv v;
    int start = 1;
    int n; cin>>n;
    int arr[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>arr[i];
    }
    for (int i = 0; i < n; ++i)
    {
        if (start == arr[i])
        {
            //cout<<"arr[i]: "<<arr[i]<<endl;
            v.pb(start);
            start++;
            //cout<<"Start: "<<start<<endl;
        }
    }

    if (v.size() == 0)
    {
        cout<<-1;
    }
    else {
        cout<<n-v.size();
    }
    return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>

main(){
  int a, b, c;
  int n;
  int i;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d %d", &a, &b, &c);
    if((a*a==b*b+c*c) || (b*b==a*a+c*c) || (c*c==a*a+b*b)){
      printf("YES\n");
    }
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int N, K, A[200200], B[200200];

int main()
{
	scanf ("%d %d", &N, &K);
	if (K > 200) K = 200;
	for (int i = 1; i <= N; i++) scanf ("%d", &A[i]);
	for (int k = 0; k < K; k++){
		for (int i = 0; i <= N; i++) B[i] = 0;
		for (int i = 1; i <= N; i++){
			int s = i - A[i], e = i + A[i] + 1;
			if (s <= 0) s = 1;
			if (e > N) e = N + 1;
			B[s]++; B[e]--;
		}
		for (int i = 1; i <= N; i++){
			B[i] += B[i - 1];
			A[i] = B[i];
		}
	}

	for (int i = 1; i <= N; i++) printf ("%d ", A[i]); puts("");

	return 0;
}

Measured memory_bytes: 4780
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Data.Char

main :: IO ()
main = do
  [n] <- readInts
  s <- getLine
  putStrLn $ solve n s

solve n s = chr <$> (+ ordA) <$> (`mod` 26) <$> (+ n) <$> (flip (-) ordA) <$> ord <$> s
  where
    ordA = ord 'A'

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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

    rep(ite,n){
        ll i = ite;
        ll j = n-1 - ite;
        ll ma = a + j*d - i*c;
        ll mi = a + j*c - i*d;
        if(mi<=b && b<=ma){
            cout << "YES" << endl;
            return 0;
        }
    }


    cout << "NO" << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
S = input()
M = 10**9+7

case = [1] + [0] * 12
temp = [0] * 13
unit = 1
before = 0
for i in reversed(range(len(S))):
    if(S[i] == '?'):
        for k in range(13):
            for j in range(10):
                before = (k - unit * j) % 13
                temp[k] += case[before]
            temp[k] %= M
    else:
        for k in range(13):
            before = (k - unit * int(S[i])) % 13
            temp[k] = case[before]
    case = temp
    unit *= 10
    unit %= 13
    temp = [0] * 13

print(case[5])


Measured memory_bytes: 43372
#include<iostream>
using namespace std;
int main() {
	int cards[201];
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < 2 * n; i++)
		cards[i] = i + 1;
	for (int i = 0; i < m; i++){
		int k; cin >> k;
		if (!k) {
			//a == 0 --- refleshuffle
			int a[101];
			int b[101];
			for (int i = 0; i < n; i++){
				a[i] = cards[i];
				b[i] = cards[i + n];
			}
			for (int i = 0; i < n; i++){
				cards[2 * i] = a[i];
				cards[2 * i + 1] = b[i];
			}
		}
		else{
			//cut
			int a[201], b[201];
			for (int i = 0; i < k; i++)
				a[i] = cards[i];
			for (int i = 0; i < 2 * n - k; i++)
				b[i] = cards[i + k];
			for (int i = 0; i < 2 * n - k; i++)
				cards[i] = b[i];
			for (int i = 0; i < k; i++)
				cards[i + (2 * n - k)] = a[i];
		}
	}
	for (int i = 0; i < 2 * n; i++) {
		cout << cards[i] << endl;
	}
	char c; cin >> c;
	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	char str[256];
	int i, nums;
  	int AC = 0;
  	int WA = 0;
  	int TLE = 0;
  	int RE = 0;
	scanf("%d", &nums);
  	for(i = 0; i <= nums; i++){
      fgets(str,sizeof(str),stdin);
      if(strcmp(str, "AC\n") == 0){
        	AC++;
      }
      else if(strcmp(str, "WA\n") == 0){
        	WA++;
      }
      else if(strcmp(str, "TLE\n") == 0){
        	TLE++;
      }
      else if(strcmp(str, "RE\n") == 0){
        	RE++;
      }
      else if(strcmp(str, "AC") == 0){
        	AC++;
      }
      else if(strcmp(str, "WA") == 0){
        	WA++;
      }
      else if(strcmp(str, "TLE") == 0){
        	TLE++;
      }
      else if(strcmp(str, "RE") == 0){
        	RE++;
      }
    }
  	printf("AC x %d\n",AC);
  	printf("WA x %d\n",WA);
  	printf("TLE x %d\n",TLE);
  	printf("RE x %d", RE);

	return 0;
}


Measured memory_bytes: 1756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String V = sc.nextLine();
		String C = sc.nextLine();
		sc.close();
		
		String[] Vspl = V.split(" ");
		int[] Vi = new int[N];
		String[] Cspl = C.split(" ");
		int[] Ci = new int[N];
		
		int sum = 0;
		
		for(int i = 0;i < N;i++){
			Vi[i] = Integer.parseInt(Vspl[i]);
			Ci[i] = Integer.parseInt(Cspl[i]);
			if(Vi[i] - Ci[i] >= 0){
				sum += Vi[i] - Ci[i];
			}
		}
		System.out.println(sum);
	}

}

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

using pii = pair<int, int>;

struct edge {
    int to, cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr int INF = 1e9;

int main() {
    int N, M, cap;
    while(cin >> N >> M >> cap, N) {
        unordered_map<string, int> idx;
        string src, dest;
        cin >> src >> dest;
        graph g(6001);
        idx[src] = 0; idx[dest] = 1;
        cap *= 10;
        for(int i=0; i<N; ++i) {
            string c1, c2;
            int d;
            cin >> c1 >> c2 >> d;
            if(idx.count(c1) == 0) {
                idx[c1] = idx.size();
            }
            if(idx.count(c2) == 0) {
                idx[c2] = idx.size();
            }
            g[idx[c1]].push_back(edge{idx[c2], d});
            g[idx[c2]].push_back(edge{idx[c1], d});
        }
        vector<bool> gas(6001);
        for(int i=0; i<M; ++i) {
            string s;
            cin >> s;
            gas[idx[s]] = true;
        }
        vector<vector<int>> res(6001, vector<int>(cap+1, INF));
        res[0][cap] = 0;
        using state = tuple<int, int, int>;
        priority_queue<state, vector<state>, greater<state>> que;
        que.push(make_tuple(0, cap, idx[src]));
        while(!que.empty()) {
            int cd, rest, c;
            tie(cd, rest, c) = que.top();
            que.pop();
            //cout << "c: " << c << " rest: " << rest << "  cd: " << cd << endl;
            if(res[c][rest] < cd) {
                continue;
            }
            for(auto& e : g[c]) {
                if(e.cost > rest) {
                    continue;
                }
                int nr = (gas[e.to] ? cap : rest - e.cost);
                if(res[e.to][nr] > res[c][rest] + e.cost) {
                    res[e.to][nr] = res[c][rest] + e.cost;
                    que.push(make_tuple(res[e.to][nr], nr, e.to));
                }
            }
        }
        int r = *min_element(res[idx[dest]].begin(), res[idx[dest]].end());
        cout << (r == INF ? -1 : r ) << endl;
    }
}

Measured memory_bytes: 75032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << a*b/2 << endl;
}

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

typedef pair<int,int> P;
typedef pair<int,P> File;

void debug(const vector<File>& v){
	cout << "[debug]" << endl;
	for(int i=0 ; i < v.size() ; i++ ){
		int id = v[i].first;
		int L = v[i].second.first;
		int R = v[i].second.second;
		cout << "[" << L << " , " << R << "] : " << id << endl;
	}
	cout << endl;
}

int main(){
	int n;
	
	while( cin >> n , n ){
		// [0,10^9] が 空(-1)
		File ini( -1 , P(0,1e+9) );
		vector<File> v;
		v.push_back( ini );
		
		for(int i=0 ; i < n ; i++ ){
			char command;
			cin >> command;
			
			if( command == 'W' ){ // 書き込み
				int l, s;
				cin >> l >> s;
				
				// ファイル番号が小さい方(-1)でさらにセクタの番号が小さい順にソート
				sort( v.begin() , v.end() );
				// 全部書き込みが終わるまで走査
				for(vector<File>::iterator it = v.begin() ; it != v.end() ; ++it){
					if( s == 0 ) break;
					
					int id = it->first;
					int L = it->second.first;
					int R = it->second.second;
					int width = R - L + 1;
					if( id != -1 ) continue;
					
					// 書き込める十分なスペースがあるとき
					if( s <= width ){
						v.erase( it );
						int L1 = L;
						int R1 = L + s - 1;
						int id1 = l;
						File f1( id1 , P(L1,R1) );
						v.push_back( f1 );
						if( s != width ){
							int L2 = L + s;
							int R2 = R;
							int id2 = -1;
							File f2( id2 , P(L2,R2) );
							v.push_back( f2 );
						}
						s = 0;
					}else{ // スペースが足りないときは全部埋めて次へ
						it->first = l;
						s -= width;
					}
				}
			}else if( command == 'D' ){ // 削除
				int l;
				cin >> l;
				for(vector<File>::iterator it = v.begin() ; it != v.end() ; ++it){
					if( it->first == l ){
						it->first = -1;
					}
				}
			}else if( command == 'R' ){ // 参照
				int p;
				cin >> p;
				for(int i=0 ; i < v.size() ; i++ ){
					int id = v[i].first;
					int L = v[i].second.first;
					int R = v[i].second.second;
					if( L <= p && p <= R ){
						cout << id << endl;
						break;
					}
				}
			}
			sort( v.begin() , v.end() );
			//debug( v );
		}
		cout << endl;
	}
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
#define forna(i,a,n) for(int i=a;i<n;i++)
typedef long long int lli;
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli t,n,m,a,b,c,d;string s;
cin>>a>>b>>c>>d;
cout<<max(a*c,max(a*d,max(b*c,b*d)));
}


Measured memory_bytes: 3648