akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  ll N;
  cin >> N;
  ll a[100100];
  rep(i, N) cin >> a[i];
  ll sho;
  
  ll zeroflag = 1;
  rep(i, N) if(a[i]!=0) zeroflag = 0;
  if(zeroflag==1){
    cout << "Yes" << endl;
    return 0;
  }
  
  sort(a, a+N);
  
  if(N%3!=0){
    cout << "No" << endl;
    return 0;
  }else{
    sho = N/3;
  }  
  
  ll flag = 1;
  FOR(i, 0, sho-1) if(a[i] != a[i+1]) flag = 0;
  FOR(i, sho, 2*sho-1) if(a[i] != a[i+1]) flag = 0;
  FOR(i, 2*sho, 3*sho-1) if(a[i] != a[i+1]) flag = 0;
  
  if(flag==0){
    cout << "No" << endl;
    return 0;
  }
  
  if((a[0]^a[sho])==a[2*sho]){
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
    return 0;
  }
  
}

Measured memory_bytes: 1024
package main

import "fmt"

func main()  {
	var s,t string

	fmt.Scan(&s)
	fmt.Scan(&t)

	var crct int

	for i:=0; i<3 ; i++ {
		if s[i] ==t[i]{
			crct ++
		}

	}

	fmt.Println(crct)






}


Measured memory_bytes: 512
import std.stdio, std.format, std.string, std.conv, std.algorithm;

void main()
{
  while ( true ) {
	immutable int n = to!int( strip( readln ) );
	if ( n == 0 ) break;

	int w, h;
	string input = strip( readln );
	formattedRead( input, "%d %d", &w, &h );
	auto table = new int[][]( h + 1, w + 1 );
	foreach ( ary; table ) {
	  ary[] = 0;
	}
	foreach ( i; 0 .. n ) {
	  input = strip( readln );
	  int x, y;
	  formattedRead( input, "%d %d", &x, &y );
	  table[ y ][ x ]++;
	}
	for ( int i = 0; i <= h; i++ ) {
	  for ( int j = 0; j <= w - 1; j++ ) {
		table[ i ][ j + 1 ] += table[ i ][ j ];
	  }
	}
	for ( int i = 0; i <= h - 1; i++ ) {
	  for ( int j = 0; j <= w; j++ ) {
		table[ i + 1 ][ j ] += table[ i ][ j ];
	  }
	}

	int s, t;
	input = strip( readln );
	formattedRead( input, "%d %d", &s, &t );
	int ans = -1;
	for ( int i = t; i <= h; i++ ) {
	  for ( int j = s; j <= w; j++ ) {
		ans = max( ans, table[ i ][ j ] - table[ i - t ][ j ] - table[ i ][ j - s ] + table [ i - t ][ j - s ] );
	  }
	}
	writeln( ans );
  }
}

Measured memory_bytes: 1780
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      t = (i*500) + (j*100) + (k*50)
      if t == x:
        ans = ans + 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

using namespace std;

 
int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i=0 ; i<N ; i++){
        cin >> s.at(i);
    }
    int M;
    cin >> M;
    vector<string> t(M);
    for(int i=0 ; i<M ; i++){
        cin >> t.at(i);
    }
    
    int yen = 0;
    for(int i=0 ; i<N ; i++){
        int ap = 0;
        string &word = s.at(i);
        for(int j=0 ; j<N ; j++){
            if(word == s.at(j)){ap++;}
        }
        for(int j=0 ; j<M ; j++){
            if(word == t.at(j)){ap--;}
        }
        if(ap>yen){yen=ap;}
    }
    cout << yen << endl;
}


Measured memory_bytes: 256
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli, lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
    opt;
    lli a,b,c;
    cin>>a>>b>>c;
    lli i=1;
    rep(i,1,1000001)
    {
        if((i*a)%b==c)
        {
            cout<<"YES";
            exit(0);
        }
    }
    cout<<"NO";
}


Measured memory_bytes: 256
import math
N, M = map(int, input().split())

if N == M:
  print((2 * math.factorial(N) * math.factorial(M))%((10**9)+7))
else:
  if abs(N-M) == 1:
    print((math.factorial(N) * math.factorial(M))%((10**9)+7))
  else:
    print(0)

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

const int x[4] = { 0,1,0,-1 }, y[4] = { -1,0,1,0 };
int H, W;
char S[52][52];

int main(){
	cin >> H >> W;
	for (int i = 0; i <= H + 1; ++i) {
		for (int j = 0; j <= W + 1; ++j) {
			S[i][j] = '.';
		}
	}
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			cin >> S[i][j];
		}
	}
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (S[i][j] == '#') {
				bool f = true;
				for (int k = 0; k < 4; ++k) {
					if (S[i + x[k]][j + y[k]] == '#') {
						f = false;
						continue;
					}
				}
				if (f) {
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	multiset<int> S;
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		S.insert(a);
	}
	int ans = 0;
	while (!S.empty()) {
		int x = *S.rbegin();
		S.erase(S.find(x));
		int t = 32 - __builtin_clz(x);
		int sum = 1 << t;
		int y = sum - x;
		auto it = S.find(y);
		if (it == S.end()) continue;
		S.erase(it);
		++ans;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<ll> a(100010);
vector<ll> b(100010);
vector<ll> c(100010);
vector<ll> ab(100010);

int main() {
  ll x, y, _a, _b, _c;
  cin >> x >> y >> _a >> _b >> _c;
  a.resize(_a);
  b.resize(_b);
  c.resize(_c);
  ab.resize(x + y);

  rep(i, _a) cin >> a[i];
  rep(i, _b) cin >> b[i];
  rep(i, _c) cin >> c[i];

  // 赤いリンゴを逆ソートしてx個、緑いリンゴ逆ソートしてy個とって合成して逆ソートして、
  // 白いリンゴも逆ソートして、
  // 白いリンゴの先頭と赤緑リンゴの先頭を比較しつつ、白いほうが大きければswapするのを c だけ繰り返す

  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  rep(i, x) {
    ab[i] = a[i];
  }
  rep(i, y) {
    ab[i + x] = b[i];
  }
  sort(ab.begin(), ab.end());
  sort(c.rbegin(), c.rend());

  int ab_cur = 0;
  rep(i, _c) {
    if (ab[ab_cur] < c[i]) {
      ab[ab_cur] = c[i];
      ab_cur++;
    }
  }

  ll ans = 0;
  rep(i, x + y) {
    ans += ab[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<cstdio>
#include<math.h>
#include <stdlib.h>
#define M 100000
using namespace std;
  
int main(){
    int n, m,l = 0;
    int pos = 0;
    int ans = 0;
    int x[100010];
    scanf("%d %d",&n,&m);
    x[0] = 0;
    for (int i = 1; i < n; i++){
        scanf("%d", &x[i]);
        x[i] += x[i - 1];
    }
    while (m--){
        scanf("%d", &l);
        if(l > 0){
            ans += x[pos + l] - x[pos];
        }
        else{
            ans -= x[pos + l] - x[pos];
        }
        pos += l;
        ans %= M;
    }
    printf("%d\n", ans);
}

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

int main(){
	int n;
	cin>>n;
	vector<double> p(n);
	for(int i=0;i<n;i++)
		cin>>p[i];
	vector<vector<double> > dp(n+1,vector<double>(n+1));
	double s=0;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){

			dp[i][j]=dp[i-1][j]*(1-p[i-1])+(j>0?dp[i-1][j-1]*p[i-1]:0);
			
		}
	}
	for(int j=n;j*2>n;j--)s+=dp[n][j];
	
	cout.precision(10);
	cout<<s<<endl;
}

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

int main(){

  int n,memo[100][100]={0},mini=100,v,memo2[100];
  string s[100],ans;
  cin >> n;
  FOR(i,n){
    cin >> s[i];
  }
  FOR(i,n){
    FOR(j,s[i].size()){
      memo[i][s[i].at(j)-'`']++;
    }
  }
  FOR(i,27){
    FOR(j,n){
      v=memo[j][i];
      if(mini>v){
        mini=v;
      }
    }
    memo2[i]=mini;
    mini=100;
  }
  for(int i=1;i<27;i++){
    FOR(j,memo2[i]){
      ans+=('`'+i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def backtrack(nums, step, result):
    if len(step) == 3:
        if len(set(step)) == 3:
            sorted_step = sorted(step)
            a,b,c = sorted_step
            if a+b > c:
                result.append(step[:])
    else:
        for i in range(len(nums)):
            step.append(nums[i])
            backtrack(nums[i+1:], step, result)
            step.pop()

def solve():
    N = int(input())
    L = [int(i) for i in input().split()]
    result = []
    backtrack(L, [], result)
    print(len(result))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 25504
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

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

    if(N%2!=0){
        cout << 0 << endl; return 0;
    }

    ll ans = 0;
    ll d = 10;
    while(N > 0){
        ans += N / d;
        N /= 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main(n,A,B):
  AB=[[a,b] for a,b in zip(A,B)]
  dp=[0]*(n+1)
  dp[0]=n
  # dp[i]:どんぐりをi個交換した時の最大獲得どんぐり
  for a,b in AB:
    #if a>b:continue
    ddp=[0]*(n+1)
    ddp[0]=n
    for i in range(n+1):
      ddp[i]=max(dp[i],ddp[i-a]+b-a if i-a>=0 else 0)
    dp=ddp
  n=max(dp)
  dp=[0]*(n+1)
  dp[0]=n
  for a,b in AB:
    if b>a:continue
    ddp=[0]*(n+1)
    ddp[0]=n
    for i in range(n+1):
      ddp[i]=max(dp[i],ddp[i-b]+a-b if i-b>=0 else 0)
    dp=ddp
  return max(dp)

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
print(main(n,A,B))


Measured memory_bytes: 457036
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = [(1 + p[i]) / 2 for i in range(n)]
s = [sum([e[i] for i in range(k)])]
for i in range(n - k):
    s.append(s[-1] - e[i] + e[i + k])
print(max(s))

Measured memory_bytes: 25060
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(c >= a && c <= b){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 23124
s=input()
t=input()
n1=len(s)
n2=len(t)
m=1000
for i in range(n1-n2+1):
    x=s[i:i+n2]
    c=0
    for j in range(n2):
        if x[j]!=t[j]:
            c=c+1
    m=min(m,c)
print(m)

Measured memory_bytes: 9044
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int h, w; cin >> h >> w;

    int hf = h, wf= w;
    char a[h][w];

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }

    set<int> sh;
    for(int i=0; i<h; i++){
        bool allwhite = true;
        for(int j=0; j<w; j++){
            if(a[i][j] == '#'){
                allwhite = false;
                break;
            }
        }
        if(allwhite){
            sh.insert(i);
        }
    }

    set<int> sw;
    for(int j=0; j<w; j++){
        bool allwhite = true;
        for(int i=0; i<h; i++){
            if(a[i][j] == '#'){
                allwhite = false;
                break;
            }
        }
        if(allwhite){
            sw.insert(j);
        }
    }

    for(int i=0; i<h; i++){
        if(sh.find(i) == sh.end()){
            for(int j=0; j<w; j++){
                if(sw.find(j) == sw.end()){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  Graph G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    A--,B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }

  int ans=0;
  for(int i=0;i<N;i++){
    bool flag=true;
    for(auto ni:G.at(i)){
      if(H.at(ni)>=H.at(i)){
        flag=false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 8800
import java.util.*;

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

        String S = sc.next();
        String T = sc.next();

        if (T.startsWith(S) && (T.length() == S.length() + 1)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 35688
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*a-b;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = br.readLine()) != null) {
			StringBuffer sb = new StringBuffer(line);
			System.out.println((sb.reverse()).toString());
		}
	}
}

Measured memory_bytes: 9180
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{

	int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	cin>>K;
	cout<<num[K-1]<<endl;
	return 0;	
} 

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

root = [ [] for _ in range(n+1)]

for i in range(m):
    a,b = map(int, input().split())
    root[a].append(b)
    root[b].append(a)

ans = 0
for i in range(n+1):
    height = h[i-1]
    flag = 1
    for j in root[i]:
        if height <= h[j-1]:
            flag = 0
            break
    
    if flag == 1:
        ans += 1
        

print(ans-1)

Measured memory_bytes: 29512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
		long k = sc.nextLong();

		while ( n*2l >= k ) {
			if ( n>=k ) {
				n = n%k;
			} else if ( n*2l>=k ) {
				n = Math.abs(n-k);
			}
		}
		System.out.println(n);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  vector<ll> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }

  ll sum=0;
  for(ll i=N-1;i>=0;i--){
    int x=(A.at(i)+sum)%B.at(i);
    sum+=(B.at(i)-x)%B.at(i);
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stack>
using namespace std;
const int maxn=100000+5;
const int maxnm=1500+5;
const int mod=1000000007;
const int base=131;
int n;
int hs[maxn];
stack<int> sum;
int main (){
	string s;
    cin>>s;
    int n=s.length();
	for (int i=0;i<n;i++){
        int k=1;
		k=(k*base+s[i]-'0')%mod;
		hs[i]=k;
	}
    int res=0;
	for (int i=0;i<n;i++){
        if(!sum.empty()&&hs[i]!=sum.top()){
        sum.pop();
        res+=2;
        }
        else sum.push(hs[i]);
    }
    cout<<res;
	return 0;
}

Measured memory_bytes: 4544
//============================================================================
// Name        : aaa.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	double N;
	cin >> N;
	if(N == 1)cout << 1 << endl;
	else if(fmod(N, 2) == 0)cout << 0.5 << endl;
	else if(fmod(N, 2) == 1)cout <<  double(int(N / 2.0) + 1) / N << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int mo=1000000007;
const int N=10000005;
const int M=5005;
int fac[N],inv[N],Inv[N];
int n,m,f[M][M],g[M][M];
void init(){
	fac[0]=inv[0]=inv[1]=Inv[0]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1) Inv[i]=1ll*Inv[i-1]*inv[i]%mo;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
}
int C(int x,int y){
	return 1ll*fac[x]*Inv[y]%mo*Inv[x-y]%mo;
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	For(i,0,m) f[i][0]=1ll*fac[i+n-m-1]*i%mo;
	For(i,0,m) For(j,1,m-i){
		int val=1ll*f[i][0]*C(i+j,i)%mo;
		f[i+j][0]=(f[i+j][0]+mo-val)%mo;
		f[i+j][j]=val;
	}
	For(i,1,m) For(j,0,m-i){
		g[i][j]=f[i-1][j];
		g[i][j]=(g[i][j]+1ll*g[i-1][j]*(n-m+(i-1)-(j+1)+1))%mo;
		g[i][j]=(g[i][j]+1ll*g[i-1][j+1]*(j+1))%mo;
	}
	int ans=(g[m][0]+f[m][0])%mo;
	cout<<ans<<endl;
}
/*
>_<
*/



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

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

    unsigned long long ans = 0;
    for (int i=1; i<=n; i++) {
        if (0==i%3 || 0==i%5) {
            continue;
        }
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#define MAXN 2000

// ノードを表す構造体
struct Node {
  int data ;
  struct Node * next ;
} ;

typedef struct Node Node ;

// 新しいノードのメモリを確保する
Node *create_node(int new_data) {
  Node *new_node = (Node *) malloc(sizeof(Node));
  if (!new_node) {
    fprintf(stderr, "could not allocate a node.\n");
    exit(1);
  }
  new_node->data = new_data;
  new_node->next = NULL;
  return new_node;
}

// リストのメモリを解放する
void clear_list(Node * head) {
  while (head) {
    Node * target = head ;
    head = head->next ;
    free(target) ;
  }
}

// リストの先頭へ新しいノードを追加する
// リストの先頭のポインタを差し替えるため、リストの先頭へのポインタへのポインタを渡す
void push_front(Node **head, int new_data) {
  Node *new_node = create_node(new_data) ;
  new_node->next = *head;
  *head = new_node;
}

//リストの先頭からノードを削除する
int pop_front(Node **head){
  Node *tmp = *head;
  int c = (*head)->data;
  *head = (*head)->next;
  free(tmp);
  return c;
}

// リストの要素を先頭から順に出力する
void print_list(const Node * head) {
  while(head) {
    printf("| %d |-> ", head->data);
    head = head->next;
  }
  printf("NULL\n");
}

int main(void) {

  Node * top = NULL ;
  int data ;

  char s[MAXN];
  fgets(s, MAXN, stdin);
  //printf("%s\n", s);

  int c,i = 0, f = 1, x = 0, tmp;
  while((c = s[i++]) != '\n' && c != '\0'){
    switch(c){
    case '+':
      push_front(&top, pop_front(&top) + pop_front(&top));
      f = 0;
      break;
    case '*':
      push_front(&top, pop_front(&top) * pop_front(&top));
      f = 0;
      break;
    case '-':
      tmp = pop_front(&top);
      push_front(&top, pop_front(&top) - tmp);
      f = 0;
      break;
    case(' '):
      if(f){
	push_front(&top, x);
	x = 0;
      }
      break;
    default:
      x = 10 * x + c - '0';
      f = 1;
      break;
    }
  }

  printf("%d\n", pop_front(&top));
  
  /*
  for (size_t i = 0 ; i < size ; ++i) {
    scanf("%d", &data) ;
    push_front(&head, data) ;
  }

  print_list(head) ;

  pop_front(&head);
  print_list(head);

  push_back(head, 10);
  print_list(head);

  pop_back(&head);
  print_list(head);
  */
  
  clear_list(top) ;

  return 0 ;
}



Measured memory_bytes: 2104
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    la = rli()
    for i in range(k, n):
        if la[i] > la[i-k]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 31664
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = {}
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns.setdefault(u-1, set())
    ns.setdefault(v-1, set())
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
ans[0][s] = 0
done = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     if ans[u][ss] is not None and ans[u][ss] <= dd:
#         continue
#     ans[u][ss] = dd
    
    if done[u][ss]:
        continue
    done[u][ss] = True
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or done[v][ss-a[e]] :
            continue
        ans[v][ss-a[e]] = min(ans[v][ss-a[e]], dd + b[e]) if ans[v][ss-a[e]] is not None else dd+b[e]
#         if ss<a[e] or ans[v][ss-a[e]] is not None:
#             continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        sss = ss+c[u]
    elif ss < maxs:
        sss = maxs
    else:
        continue
    heapq.heappush(h, (dd + d[u], u, sss))
#     print(sss, maxs, ss, c[u])
    ans[u][sss] = min(ans[u][sss], dd + d[u]) if ans[u][sss] is not None else dd+d[u]

for item in ans[1:]:
    print(min(item))

Measured memory_bytes: 125668
use proconio::input;

fn main() {
    input! {
        n: i64,
    }
    let mut sum: i64 = 0;

    for i in 1..n + 1 {
        if !((i % 3 == 0) || (i % 5 == 0)) {
            sum = sum + i;
        }
    }
    println!("{}", sum);
}

Measured memory_bytes: 2112
A[20000];z(int*a,int*b){return*b-*a;}
main(n,i,j){for(;scanf("%d",&n),n;puts(i<n?"No":"Yes")){
for(i=0;i<n*2;i++)scanf("%d",A+i);
qsort(A,n,4,z);
for(i=0;i<n;i++){for(j=n;j<n*2;j++)if(A[j])A[i]--,A[j]--;if(A[i])break;}
}exit(0);}

Measured memory_bytes: 736
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
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 f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    if (i * 108 / 100 == n) kek(i);
  }
  kek(":(");
  
  return 0;
}


Measured memory_bytes: 256
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nuko = 10

n = []
for i in range(5):
    n.append(iin())
    if (n[i]%10 < nuko)and(n[i]%10 != 0):
        nuko = n[i]%10
    n[i] = math.ceil(n[i]/10)*10
print(sum(n)-10+nuko)

Measured memory_bytes: 9124
#include<stdio.h>
#include<iostream>
#include<stack>
#include<algorithm>
#define MAX 1400

using namespace std;

struct Rectangle{int height; int pos;};

int getLargestRectangle(int size, int buffer[]){
    stack<Rectangle> S;
    int maxv = 0;
    buffer[size] = 0;

    for(int i=0; i<=size; i++){
        Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if(S.empty()){
            S.push(rect);
        }else{
            if(S.top().height < rect.height){
                S.push(rect);
            }else if(S.top().height > rect.height){
                int target = i;
                while (!S.empty() && S.top().height >= rect.height){
                    Rectangle pre = S.top(); S.pop();
                    int area = pre.height * (i - pre.pos);
                    maxv = max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle(){
    for(int j=0; j<W; j++){
        for(int i=0; i<H; i++){
            if(buffer[i][j]){
                T[i][j] = 0;
            }else{
                T[i][j] = (i>0) ? T[i-1][j] + 1 : 1;
            }
        }
    }

    int maxv = 0;
    for(int i=0; i<H; i++){
        maxv = max(maxv, getLargestRectangle(W, T[i]));
    }

    return maxv;
}

int main(){
    scanf("%d %d", &H, &W);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            scanf("%d", &buffer[i][j]);
        }
    }
    cout << getLargestRectangle() << endl;

    return 0;
}


Measured memory_bytes: 18568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int h,n,sum,g=0;
  	cin >> h >> n;
  	while(n--)
    {	
      cin >> g;
      sum = sum+g;
    }
  	h-sum<1 ? cout <<"Yes"<<endl : cout<< "No";
  	
}

Measured memory_bytes: 256
# https://arc096.contest.atcoder.jp/tasks/arc096_b


def inp(): return map(int, input().split())


N, C = inp()
l = [tuple(inp()) for _ in range(N)]

r1 = [0] * N
r2 = [0] * N
l1 = [0] * N
l2 = [0] * N

cal = 0
ans1 = 0
ans2 = 0
for i, (x, v) in enumerate(l):  # clockwise
    cal += v
    ans1 = max(ans1, cal - x)
    ans2 = max(ans2, cal - 2 * x)
    r1[i] = ans1
    r2[i] = ans2

cal = 0
ans1 = 0
ans2 = 0
for i, (x, v) in enumerate(l[::-1]):  # counter clockwise
    x = C - x
    cal += v
    ans1 = max(ans1, cal - x)
    ans2 = max(ans2, cal - 2 * x)
    l1[-1 - i] = ans1
    l2[-1 - i] = ans2

ans = 0

for i in range(N - 1):
    ans = max(ans, r2[i] + l1[i + 1], r1[i] + l2[i + 1])

ans = max(ans, r1[-1], l1[0])
print(ans)



Measured memory_bytes: 29896
#include <iostream>

using namespace std;

void solve(){

}
int encnt[101], ans;
int main(){
  int n;

  while(cin >> n){
    encnt[n]++;
    ans = max(ans, encnt[n]);
  }
  for(int i = 0; i < 100; i++){
    if(encnt[i] == ans){
      cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  float N,n=0;
  cin >> N;
  vector<float>A(N);
  for(int i=0;i<N;i++){
      cin >> A[i];
  }
  for(int i=0;i<N;i++){
      n += 1/A[i];
  }
  n = 1/n;

  cout << n;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int n, a[10001] = {0}; //10001回
   cin >> n;
   for(int i = 0; i < n; i++) {
       cin >> a[i];
   }
   long long int min = 1000000, max = -1000000, sum = 0;
   for(int i = 0; i < n; i++) {
       cin >> a[i];
       if(a[i]<min) {
           min = a[i];
       }
       if(a[i]>max) {
           max = a[i];
       }
       sum = sum + a[i];
   }
   cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3124
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft
import numpy as np

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def count_lr_old(n, m, a):
    count = 0
    for l in range(n):
        for r in range(l, n):
            if not sum(a[l:r+1]) % m:
                count += 1
    return count


def count_lr(n, m, a):
    b_acm = 0
    mod_m_counts = {}
    for ai in a:
        b_acm = (b_acm + ai) % m
        mod_m_counts.setdefault(b_acm, 0)
        mod_m_counts[b_acm] += 1

    # print(mod_m_counts)

    # print('len a:', len(a))
    count = 0
    all_ = 0
    for k, v in mod_m_counts.items():
        all_ += v
        count += v * (v - 1) // 2
        if k == 0:
            count += v

    # print('all_', all_)
    return count


if __name__ == "__main__":
    n, m = LI()
    a = LI()

    print(count_lr(n, m, a))


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	int lef[n];
	int rig[n];

	lef[0] = s[0] == 'W' ? 1 : 0; 
	rep(i,n-1){
		lef[i+1] = lef[i] + (s[i+1] == 'W' ? 1 : 0); 
	}
	
	rig[n-1] = s[n-1] == 'E' ? 1 : 0;
	rrep(i,n-1){
		rig[i] = rig[i+1] + (s[i] == 'E' ? 1 : 0);
	}

	int ans = 1e7;
	rep(i,n){
		ans = min(ans, lef[i] + rig[i] - 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 2964
from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

def main():
	n,k = map(int,read().split())
	a = list(map(int,read().split()))
	a.sort()
	write('{}\n'.format(sum(a[:k])))

if __name__ == "__main__":
	main()

Measured memory_bytes: 85164
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
S = list(input().strip())
T = list(input().strip())

def gcd(x, y):
    if y > x:
        x, y = y, x
    if x % y == 0:
        return y
    return gcd(y, x % y)

l = N * M // gcd(N, M)

# m = [None] * l
m = {}

for i in range(N):
    m[i * (l // N)] = S[i]

for i in range(M):
    index = i * (l // M)
    if m.get(index) == None:
        m[index] = T[i]
    elif m[index] == T[i]:
        pass
    else:
        print(-1)
        exit()

print(l)

Measured memory_bytes: 16772
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int digl, digr, l, r;

int n(int d){
    int r = 1;
    REP(i,d) r *= 10;
    return r;
}
string ins;
bool check(){
    cin >> ins;
    return ins[0] == 'Y';
}
void ask(int i){
    cout << "? " << i << endl;
}
void decide(int i){
    cout << "! " << i << endl;
}

signed main(){
    digr = 10;

    ask(n(10));
    if (check()){ // 10^n
        while(digr - digl > 1){
            int mid = (digr+digl)/2;
            ask(9 * n(mid-1));
            if( !check()) {
                digl = mid;
            } else {
                digr = mid;
            }
        }
        decide(n(digl));
    } else { // それ以外
        // 桁
        digr--; //10^9 はない
        while(digr - digl > 1){
            int mid = (digr+digl)/2;
            ask(n(mid));
            if( check()) {
                digl = mid;
            } else {
                digr = mid;
            }
        }
        l = n(digl);
        r = n(digl+1);
        while(r-l > 1){
            int mid = (l+r)/2;
            ask((mid-1)*10);
            if(check()){
                r = mid;
            } else {
                l = mid;
            }
        }
        decide(l);
    }
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int i, j, tab[3][N], T[3][N], res, k, n;

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) for (j=0;j<3;j++) scanf("%d", &tab[j][i]);
for (j=0;j<3;j++) T[j][0] = tab[j][0];
for (i=1;i<n;i++) {
	for (j=0;j<3;j++) {
		T[j][i] = 0;
		for (k=0;k<3;k++) if (k != j) T[j][i] = max(T[j][i], T[k][i - 1] + tab[j][i]);
	}
}
res = 0;
for (j=0;j<3;j++) res = max(res, T[j][n - 1]);
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 2560
def euq(A, B):
    while B> 0:
        A, B = B, A % B
    return A

A, B, C = map(int, input().split())

r = euq(A, B)
R = []
for i in range(1, r+1):
    if r % i == 0:
        R.append(i)
print(R[-C])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
typedef long long ll;
using namespace std;
 
int main(){
  int n,k;
  cin >> n >>k;
  
  int ans;
  
  if(n%k==0) ans = 0;
  else ans =1;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	while (scanf("%d", &n) != EOF){
		int i;
		int flag;

		flag = 0;
		for (i = 0; i < 20; i++){
			if (((n >> i) & 1) != 0){
				if (flag == 0){
					printf("%d", 1 << i);
				}
				else {
					printf(" %d", 1 << i);
				}
				flag = 1;
			}
		}
		puts("");
	}
	return (0);
}

Measured memory_bytes: 1036
#include<iostream>
#include<cmath>

using namespace std;

long long Sunuke(long long x){
    long long sum = 0;
    while(x > 0){
        sum += x%10;
        x = x/10;
    }
    return sum;
}
int main(){
    long long N,K,d;
    d=1;
    cin >> K;
    N = 1;
    cout << 1 << endl;
    for(long long i = 1;i<K;i++){
        if((N+d*10)*Sunuke(N+d)<(N+d)*Sunuke(N+d*10)){
            d *= 10;
        }
        N += d;
        cout << N << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

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

    ll a, b;
    for (ll i = 1; i*i <= N; ++i){
        if (N % i == 0) a = i;
    }
    b = N / a;
    cout << a + b - 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int N;
  int sum = 0;

  cin >> N;
  int tmp = N;
  while (tmp > 0) {
    sum += tmp % 10;
    tmp /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = [int(m) for m in input().split()]
x.sort()
if m <= n:
    print(0)
else:
    dist = []
    for i in range(1, m):
        dist.append(x[i] - x[i - 1])
    tmp = 0
    dist.sort(reverse=True)
    for i in range(n - 1):
        tmp += dist[i]
    print(sum(dist) - tmp)

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

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

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll a, b; cin >> a >> b;

  if (a <= 0 && b >= 0) {
    outl("Zero");
  } else if (a > 0 || (b - a) % 2 == 1) {
    outl("Positive");
  } else {
    outl("Negative");
  }
}

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

  solve();
}


Measured memory_bytes: 888
from fractions import gcd
from functools import reduce
def main(n,x,lst):
    lst.append(x)
    lst.sort()
    ans = [0for i in range(n)]
    for i in range(n):
        ans[i] = lst[i+1]-lst[i]
    return reduce(gcd,ans,0)
n,x = map(int,input().split())
lst = list(map(int,input().split()))
print(main(n,x,lst))


Measured memory_bytes: 16308
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

constexpr ll MOD = 998244353;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll a, ll b) {
    return (a % MOD) * calc_pow(b, MOD - 2) % MOD;
}

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % MOD);
}

int main() {
    init_fact(1e7 + 1);

    int n;
    cin >> n;
    ll ret = calc_pow(3, n);
    for (int i = n; i > n / 2; i--) {
        ll now = 2 * calc_comb(n, i) % MOD;
        now *= calc_pow(2, n - i), now %= MOD;
        ret += MOD - now, ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}

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

int main(){
	int n,t,a;
	cin >> n >> t >> a;
	double ans = 1000000000;
    int minnum;
	rep(i,n){
		int h;
		cin >> h;
		double temp = t - h * 0.006;
        if(ans > abs(temp-a)){
            ans = abs(temp-a);
            minnum = i+1;
        }
	}
	cout << minnum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define f(a)(a%5==1?5:2)
using namespace std;
typedef pair<int, int>P;

int c[17];
int cnt[100];
int main() {
	memset(c, -1, sizeof(c));
	priority_queue<P, vector<P>, greater<>>p;
	queue<int>que;
	int time = 0;
	while (1) {
		if (que.empty() && time / 5 + 1 >= 100)break;
		if (time % 5 == 0 && time / 5 < 100)que.push(time / 5);
		while (!p.empty() && p.top().first <= time) {
			replace(c, c + 17, p.top().second, -1);
			p.pop();
		}
		bool flag = true;
		while (flag && !que.empty()) {
			int id = que.front();
			flag = false;
			rep(i, 18 - f(id)) {
				bool ok = true;
				rep(j, f(id)) {
					if (~c[i + j])ok = false;
				}
				if (ok) {
					rep(j, f(id))c[i + j] = id; que.pop();
					cnt[id] = time - 5 * id;
					p.push(P(time + 17 * (id % 2) + 3 * (id % 3) + 19, id));
					flag = true;
					break;
				}
			}
		}
		int Min = INT_MAX;
		if (!p.empty())Min = p.top().first;
		Min = min(Min, (time / 5 + 1)*5);
		time = Min;
	}
	int n; while (~scanf("%d", &n))printf("%d\n", cnt[n]);
}

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



// ABC129A - A - Airplane
// https://atcoder.jp/contests/abc129/tasks/abc129_a
void ABC129A() {


	int P, R, Q;
	cin >> P >> R >> Q;

	int ans = min(P+Q, min(R+Q, min(P+R,min(Q+R,min(R+P, Q+P)))));
	cout << ans;
}

int main() {
	ABC129A();

	return 0;
}



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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    for (auto& x: a) cin >> x;
    vector<vector<int>> g(n);
    for (int _ = 0; _ < m; _++) {
        int x,y;
        cin >> x >> y;
        --x;--y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        bool none = true;
        for (int j:g[i]) if (a[i] <= a[j]) {
            none = false; break;
        }
        cnt += none;
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    map<int,int> d;
    rep(i,40){
        d[i]=0;
    }
    rep(i,n){
        cin>>a[i];
        bitset<40> s(a[i]);
        rep(i,40){
            if (s.test(i)){
                d[i]+=1;
            }
        }
    }
    ll num=1;
    bitset<40> kk(k);
    int s;
    for (int i=39;i>=0;i--){
        if (kk.test(i)){
            s=i;
            break;
        }
    }
    rep(i,41){
        num*=2;
    }
    ll ans=0;
    ll now=0;
    int b=1;
    //cout<<s<<endl;
    for (int i=40;i>=0;i--){
      num/=2;
        if (i>s){
			ans+=num*d[i];
          //cout<<ans<<endl;
        }
      else{
        //cout<<num<<endl;
        //num/=2;
        if (d[i]>n/2){
            ans+=num*d[i];
            if (kk.test(i)){
                b=0;
            }
        }
        else{
            if (b==0){
                ans+=num*(n-d[i]);
            }
            else{
                if (kk.test(i)){
                    ans+=num*(n-d[i]);
                }
                else{
                    ans+=num*d[i];
                }
            }

        }
    }}
        
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int dp[100000];
int h[100000];
const int inf = 2000000000;

int main(){
  int N, K;
  cin >> N >> K;
  rep(i, N){
    cin >> h[i];
    dp[i] = inf;
  }
  dp[0] = 0;
  rep(i, N){
    rep(k, 1, K + 1){
      if(i + k < N){
        dp[i + k] = min(dp[i + k], dp[i] + abs(h[i + k] - h[i]));
      }
    }
  }

  int ans = dp[N - 1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
xy = [[] for i in range(N)]
alr = [1 for i in range(N)]
for i in range(M):
    x,y,z = map(int,input().split())
    xy[x-1].append(y-1)
    xy[y-1].append(x-1)
    alr[x-1] = 0
    alr[y-1] = 0
count = sum(alr)
stack = []
for i in range(N):
    if not alr[i]:
        stack.append(xy[i])
        alr[i] = 1
        if xy[i]:
            count += 1
        while stack:
            now = stack.pop()
            for j in now:
                if not alr[j]:
                    alr[j] = 1
                    stack.append(xy[j])
print(count)

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

int main()
{

  int n;
  cin>>n;
  if(n==1) cout<<"0"<<endl;
  else if(n==0) cout<<"1"<<endl;

  return 0;
}


Measured memory_bytes: 3632