akhauriyash/Code-Regression huggingface dataset:
import itertools
n, m = [int(i) for i in input().split()]
sss = [[int(i) for i in input().split()][1:] for _ in range(m)]
ps = [int(i) for i in input().split()]

ans = 0
for pro in itertools.product((0, 1), repeat=n):
    for ss, p in zip(sss, ps):
        pp = sum(pro[s-1] for s in ss) % 2
        if pp != p:
            break
    else:
        ans += 1
        # print(pro)

print(ans)

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

const int MAX_N = 10000;

int main()
{
    bool sieve[MAX_N + 1];
    rep(i, MAX_N + 1) sieve[i] = true;
    for (int i = 2; i * i <= MAX_N; i++){
        for (int j = i * i; j <= MAX_N; j += i){
            sieve[j] = false;
        }
    }

    int n;
    while (n = in()){
        while (!(sieve[n] && sieve[n - 2])) n--;
        printf("%d %d\n", n - 2, n);
    }
    return (0);
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void) {
	int d[3],i,t,j;
	for(i=0; i<3; i++){
		scanf("%d",&d[i]);
	}
	for(i=0; i<2; i++){
		for(j=2; j>i; j--){
			if(d[j] < d[j-1]){
				t = d[j];
				d[j] = d[j-1];
				d[j-1] = t;
			}
		}
	}
	for(i=0; i<3; i++){
		printf("%d",d[i]);
		if(i != 2) printf(" ");
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,m,k;

int main()
{
	cin>>n>>k;
	if(n&1)
	{
		for(int i=1;i<=k;i++) cout<<i<<" "<<n-i<<endl;
	}
	else
	{
		int cnt=0,i=1;
		while(1)
		{
			cout<<i<<" "<<n/2+1-i<<endl;
			cnt++,i++;
			if(i>=n/2+1-i||cnt>=k) break;
		}
		if(cnt>=k) return 0;
		else
		{
			i=n/2+1;
			while(true)
			{
				cout<<i<<" "<<3*(n/2)-i<<endl;
				i++,cnt++;
				if(i>=3*(n/2)-i||cnt>=k) break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;


void sieve(vector<int>& IsPrime){
   IsPrime[0] = 0; 
   IsPrime[1] = 0; 
   for(int i=2; i<=sqrt(IsPrime.size()); i++){
     if(IsPrime[i]==1){
       for(int j=2; i*j<=sqrt(IsPrime.size()); j++){
	 IsPrime[i*j]=0;
       }
     }
   }
}
int main() {
	int X;
	cin>>X;
	vector<int> IsPrime(100001,1);
    sieve(IsPrime);
    for(int i=X; i<=100003; i++){
    		int flag=-1;
      		for(int j=2; j<i; j++){
              	if(IsPrime[j]!=1) continue;
              	if(i%j ==0){ flag=1; break;}
            }
      		if(flag==-1){
              cout<<i<<endl;
              return 0;
            }
    }
}
    
    
    
    
    
    

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3f
ll a[2050];ll n;ll x;
ll cyz[2050];
int main(){
	std::ios::sync_with_stdio(false);
	cin>>n;cin>>x;
	for(int i=0;i<n;i++){
		cin>>a[i];cyz[i]=a[i];
	}
	ll minn=inf;ll res=0;
	for(int k=0;k<n;k++){
		ll temp=0;
		for(int i=0;i<n;i++){
			int pos=i-k;
			if(pos<0)pos=n+pos;
			cyz[i]=min(cyz[i],a[pos]);
			temp+=cyz[i];
		}
		temp+=x*k;
		minn=min(temp,minn);
	}
	cout<<minn<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
s = [int(input()) for _ in range(N)]

dp = {0, }
for si in s :
    dp_ = set()
    for dpi in dp :
        dp_.add(dpi+si)
    dp = dp | dp_
    
dp = list(dp)
dp.sort(reverse=True)
for dpi in dp :
    if dpi % 10 != 0 :
        print(dpi)
        break
else :
    print(0)

Measured memory_bytes: 58972
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=(a);i>=(int)(b);i--)
const int mod = 1e9+7;
const int maxn = 1e6+10;
const int inf = 0x3f3f3f3f;
int prime[maxn],p[maxn];
void init(int up) {
    rep(i,1,up) p[i]=i;
    rep(i,2,up) {
        if(p[i]==i) prime[++prime[0]]=i;
        for(int j=1;j<=prime[0]&&i<=up/prime[j];j++) {
            p[i*prime[j]]=prime[j];
            if(i%prime[j]==0) break;
        }
    }
}
int cnt[maxn];
int main()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);
    init(maxn-5);
    int n;
    cin>>n;
    bool f1=true;
    rep(i,1,n) {
        int x;
        cin>>x;
        while(x!=1) {
            int now=p[x];
            while(x%now==0) x/=now;
            if(cnt[now]) f1=false;
            cnt[now]++;
        }
    }
    if(f1) {
        cout<<"pairwise coprime"<<'\n';
    }
    else {
        bool f=false;
        rep(i,1,maxn-1) {
            if(cnt[i]==n) {
                f=true;
                break;
            }
        }
        if(!f) cout<<"setwise coprime"<<'\n';
        else cout<<"not coprime"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 11748
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b>>c){
    int out=0;
    a%=b;
    rep(i,c){
      a*=10;
      out+=a/b;
      a%=b;
    }
    cout<<out<<endl;
  }
}

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

const int N = 1000054;

int n;
char S[N], T[N];
int que[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline int max(const int x, const int y) {return x < y ? y : x;}

int main() {
	int i = 0, j, h = 0, t = 0, ans = 0;
	scanf("%d%s%s", &n, S, T);
	if (!memcmp(S, T, n)) return putchar(48), putchar(10), 0;
	std::reverse(S, S + n), std::reverse(T, T + n);
	for (j = 0; j < n; ++j) {
		for (; T[j] == T[j + 1]; ++j);
		if ((i = std::find(S + max(i, j), S + n, T[j]) - S) == n) return puts("-1"), 0;
		for (; h < t && que[h] - h + t <= j; ++h);
		if (j < i) que[t++] = i;
		up(ans, t - h);
	}
	printf("%d\n", ++ans);
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535
 
int main()
{
  ll a;
  ld b;

  cin >> a >> b;
  
  ld temp = a * b;

  cout << (ll)temp << endl;
 
  return 0; 
}

Measured memory_bytes: 3728
import sys
input = sys.stdin.readline

from collections import deque

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

memo = [[0] * w for _ in range(h)]

dir = [(0, 1), (0, -1), (1, 0), (-1, 0)]

ans = 0
for i in range(h):
    for j in range(w):
        if memo[i][j] == 1:
            continue
        memo[i][j] = 1
        black = 0
        white = 0
        if s[i][j] == ".":
            white += 1
        else:
            black += 1
        q = deque([(i, j)])

        while q:
            x, y = q.popleft()
            for dx, dy in dir:
                if not ((0 <= x + dx <= h-1) and (0 <= y + dy <= w-1)):
                    continue
                if memo[x + dx][y + dy] == 0 and s[x][y] != s[x+dx][y+dy]:
                    memo[x + dx][y + dy] = 1
                    if s[x + dx][y + dy] == ".":
                        white += 1
                    else:
                        black += 1
                    q.append((x+dx, y+dy))

        ans += black * white

print(ans)



Measured memory_bytes: 4844
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

bool cmp(pii a, pii b){
    if(a.ft == b.ft) return a.sd < b.sd;
    return a.ft > b.ft;
}
void solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a+n);
    double ans = a[0];
    for(ll i = 1; i < n; i++){
        ans = (double) (ans+ a[i])/2;
    }
    cout << ans;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let mut d = vec![];
  for _ in 0..n {
    d.push(read::<i64>())
  }
  d.sort();

  let a = d[((n / 2) - 1) as usize];
  let b = d[(n / 2) as usize];
  let ans = b - a;
  println!("{}", ans);
}



Measured memory_bytes: 4352
#include<iostream>

using namespace std;
int main(){
    string str;
    int n;
    while(cin >> str){
        if(str=="-") break;
        cin >> n;
        for(int i=0,h;i<n;i++){
            cin >> h;
            string cat = str.substr(0,h);
            str.erase(0,h);
            str+=cat;
        }
        cout << str << endl;
    }
}


Measured memory_bytes: 3216
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	l := input()

	r := []rune(l)
	if unicode.IsLower(r[0]) == true {
		fmt.Println("a")

	} else {
		fmt.Println("A")
	}
}


Measured memory_bytes: 1772
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# N = INT()
S = list(input())
c = Counter(S)
# print(c)
ans = INF
# if len(c) == 1:
ans = min(ans, c["0"], c["1"])
print(ans * 2)


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N, Y; cin >> N >> Y;

    for(int x = 0; x <= N; ++x) {
        for(int y = 0; y <= N-x; ++y) {
            int z = N-x-y;
            int sum = x*10000 + y*5000 + z*1000;
            if (sum == Y) {
                printf("%d %d %d\n", x, y, z);
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
N = int(input())
rest_list = []
for i in range(N):
    a,b=input().split()
    temp=[i+1,a,(-1)*int(b)]
    rest_list.append(temp)
rest_list.sort(key=lambda x: (x[1], x[2]))
for i in rest_list:
    print(i[0])


Measured memory_bytes: 3060
let prime_p = function
  | 2 -> true
  | n when n < 2 || n mod 2 = 0 -> false
  | n ->
      let rec doit i =
        if i*i > n then true
        else if n mod i = 0 then false
        else doit (i + 2)
      in
      doit 3

let () =
  let n = read_int () in
  let rec read i cnt =
    if i >= n then cnt
    else read (i + 1) (cnt + (if prime_p (read_int ()) then 1 else 0))
  in
  Printf.printf "%d\n" (read 0 0)

Measured memory_bytes: 3048
#include<stdio.h>

 

int main(void){

 

int a,b,c,i,n;




scanf("%d %d %d",&a,&b,&c);




n=0;




for(i=a;i<=b;i++){

  if(c%i==0){

   n++;

 }

 }

 

 printf("%d\n",n);

 

 return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q,b;
  cin>>n>>k>>q;
  vector<int> a(n, k-q);
  for(int i=0; i<q; i++){
    cin>>b;
    a[b-1]++;
  }
  for(int i=0; i<n; i++){
    cout<<( a[i]>0 ? "Yes\n" : "No\n");
  }
}

Measured memory_bytes: 1024
import java.util.*; class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); while(true) { int H = sc.nextInt(), W = sc.nextInt(); if(H == 0 && W == 0) break; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { System.out.print("#"); } System.out.println(); } System.out.println(); } } } 


Measured memory_bytes: 32908
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int K = nextInt();
        int X = nextInt();

        if(500*K>=X) println("Yes");
        else println("No");
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21844
[N,L] = list(map(int,input().split()))
T = [0]*N
for i in range(N):
    T[i] = L+(i+1)-1
T_abs = T[::]
for i in range(N):
    T_abs[i] = abs(T_abs[i])
apple_remove = min(T_abs)
if sum(T) >= 0:
    print(sum(T)-apple_remove)
else:
    print(sum(T) + apple_remove)

Measured memory_bytes: 3068
#include<iostream>
using namespace std;
int main(){
    int i,j,N;
    int C[500],S[500],F[500];
    int ans[500] = {};
    cin>>N;
    for(i=0;i<N-1;i++) cin>>C[i]>>S[i]>>F[i];
    for(i=0;i<N-1;i++){
        ans[i] = S[i]+C[i];
        for(j=i+1;j<N-1;j++){
            if(ans[i] <= S[j]){
                ans[i] = S[j] + C[j];
            }
            else{
                ans[i] += (F[j]- ans[i]%F[j])%F[j] + C[j];
            }
        }
    }
    for(i=0;i<N;i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  int n,a;
  cin >> n >> a;
  n%=500;
  if(n<=a)cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;     
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int kin[100000];
	long long int sum,avg;
	int i;
	sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&kin[i]);
		sum=sum+kin[i];
	}
	avg=sum/n;
	printf("%d\n",avg);
	return 0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,T;
    cin >> N >> T;
    vl A(N);
    rep(i, N) cin >> A[i];

    vl m(N), M(N);
    m[0] = A[0], M[N - 1] = A[N - 1];
    rep(i, N - 1) m[i + 1] = min(m[i], A[i + 1]);
    repr(i, N - 1) M[i] = max(M[i + 1], A[i]);

    ll d = 0;
    rep(i, N - 1) chmax(d, M[i + 1] - m[i]);

    ll ans = 0;
    map<pair<ll, ll>, bool> mp;
    rep(i, N - 1) if (M[i + 1] - m[i] == d) mp[{M[i + 1], m[i]}] = true;

    repa(p, mp) ans += p.second;

    cout << ans << endl;
}

Measured memory_bytes: 8652
#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
int main(){
  long N;cin>>N;
  vector<long>A(N),C(N,0);for(long i=0;i<N;i++)cin>>A[i];
  long ans=1;long t=3;
  for(long i=0;i<N;i++){
    if (A[i]==0){ans=ans*t%MOD;t--;}
    else {ans=ans*C[A[i]-1]%MOD;C[A[i]-1]--;}
    C[A[i]]++;
  }
  cout<<ans;
}



Measured memory_bytes: 1792
#!/usr/bin/python3

import sys

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
#S = input()
#D = list(map(int, input().split()))
S,T = input().split()

st = ""

for i in range(N):
    st += S[i]
    st += T[i]

print(st)


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

#define l 	long
#define ll 	long long
#define vll vector<ll> 
#define vi 	vector<int>
#define pb push_back

// #define rep(j,n,s)  for(long i=j;i<=n;i+=s)
#define forn(j,n,s) for(long i=j; i<n; i+=s)
#define rep(i,n,s) 	for(		; i<n; i+=s)

#define read(k)		ll k; cin>>k;
#define range(v)	begin(v), end(v)
#define X first
#define Y second

void solve() 
{
    //Answer here.
    read(n);
    ll r = n%10;

    if(r==2 || r==5 || r==7 || r==9 || r==4)	cout<<"hon\n";
    else if(r==0 || r==1 || r== 6 || r==8)	cout<<"pon\n";
    else if(r==3)	cout<<"bon\n";
    

}

int main(){

	#ifndef ONLINE_JUDGE
			freopen("input", "r", stdin);
			freopen("output","w",stdout);
	#endif

	ios_base::sync_with_stdio(0);	cin.tie(NULL);	cout.tie(0);
    int t=1;  //cin>>t;
    while(t--)  solve();

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int thau=N/1000;
  int hun=N%1000/100;
  int ten=N%100/10;
  int one=N%10;
  if (thau==hun && hun==ten){
    cout << "Yes" << endl;
  }
  else if (hun==ten && ten==one){
    cout<<"Yes"<<endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
const int mod=1e9+7,N=2010;
ll f[5*N+10],r[5*N+10];
int n,a[N*100],b[N*100],dp[2*N+10][2*N+10];
ll powmod(ll x,ll p)
{
	ll ret=1;
    while(p)
	{
		if(p%2)
		    ret=ret*x%mod;
		x=x*x%mod;
		p>>=1;
	}
    return ret%mod;
}
ll c(ll n,ll m)
{   
	if(m<0||m>n)
	    return 0; 
    return (ll)f[n]*r[m]%mod*r[n-m]%mod;
}
void In()
{
	f[0]=1;
	for(int i=1;i<=5*N;i++)
	    f[i]=f[i-1]*i%mod;	   
	r[5*N]=powmod(f[5*N],mod-2);
	for(int i=5*N;i;i--)
	    r[i-1]=(ll)r[i]*i%mod;
	
}
int main()
{
	In();
	scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",a+i,b+i);
        dp[2001-a[i]][2001-b[i]]++;
    }
    for(int i=1;i<=4001;i++)
        for(int j=1;j<=4001;j++){
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    ll ans=0;
    for(int i=1;i<=n;i++)ans=(ans+dp[2001+a[i]][2001+b[i]])%mod;
    for(int i=1;i<=n;i++)ans=(ans-c(2*a[i]+2*b[i],2*a[i])+mod)%mod;
    printf("%lld\n",ans*powmod(2,mod-2)%mod);
}

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

constexpr int INF = 1e9 + 5;

struct segTree {
    int B = 1;
    vector<int> tag;
    vector<int> t;
    segTree(int n) {
        while (B < n) B *= 2;
        tag.resize(B, 0);
        t.resize(2 * B);
    }
    void pull(int u) {
        t[u] = min(t[u << 1], t[u << 1 | 1]);
    }
    void push(int u, int L, int R) {
        if (tag[u] == 0) return;
        int M = (L + R) / 2, lc = u << 1, rc = u << 1 | 1;
        t[lc] =  tag[u];
        t[rc] = tag[u] + (M - L);
        if (rc < B) {
            tag[lc] = tag[u];
            tag[rc] = tag[u] + (M - L);
        }
        tag[u] = 0;
    }
    void update(int u, int L, int R, int ql, int qr, int v) {
        if (R <= ql || qr <= L)
            return;
        if (ql <= L && R <= qr) {
            t[u] =  v;
            if (u < B) tag[u] = v;
            return;
        }
        push(u, L, R);
        int M = (L + R) / 2, lc = u << 1, rc = u << 1 | 1;
        update(lc, L, M, ql, qr, v);
        update(rc, M, R, ql, qr, v + max(0, (M - max(L, ql))));
        pull(u);
    }
    void update(int l, int r, int v) {
        update(1, 0, B, l, r, v);
    }
    int query(int u, int L, int R, int ql, int qr) {
        if (R <= ql || qr <= L)
            return INF;
        if (ql <= L && R <= qr)
            return t[u];
        push(u, L, R);
        int M = (L + R) / 2, lc = u << 1, rc = u << 1 | 1;
        int ret = min(query(lc, L, M, ql, qr), query(rc, M, R, ql, qr));
        return ret;
    }
    int query(int l, int r) {
        return query(1, 0, B, l, r);
    }
};


int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    bool dead = false;
    int l, r, ans = 0;
    segTree st(m);
    for (int z = 1; z <= n; z++) {
        cin >> l >> r;
        if (dead) {
            cout << "-1\n";
            continue;
        }
        l--, r--;
        int vl = l == 0 ? INF : st.query(l - 1, l);
        st.update(l, r + 1, vl + 1);
        ans = st.query(0, m);
        if (ans >= INF) {
            cout << "-1\n";
            dead = true;
        } else {
            cout << ans + z << '\n';
        }
    }
    return 0;
}

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

typedef long long int lli;

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

    lli l, r, d;
    cin >> l >> r >> d;

    lli counter = 0;
    lli sum = d;

    while(1)
    {
        if(sum > 100)
        {
            break;
        }

        if(sum >= l && sum <= r)
        {
            counter++;
        }
        sum += d;
    }

    cout << counter << endl;
}


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

map<string, vector<int>> genMap();
void printCards(map<string, vector<int>> &cards);
vector<string> suits = {"S", "H", "C", "D"};

int main() {
    int n;
    map<string, vector<int>> cards = genMap();

    cin >> n;
    for (int nc = 0; nc < n; nc++) {
        string s;
        int r;
        cin >> s >> r;
        vector<int>::iterator it = find(cards[s].begin(), cards[s].end(), r);
        if (it != cards[s].end()) {
            cards[s].erase(it);
        }
    }

    printCards(cards);
}

map<string, vector<int>> genMap() {
    map<string, vector<int>> gen;
    for (auto suit : suits) {
        vector<int> kind;
        for (int rank = 1; rank <= 13; rank++) {
            kind.push_back(rank);
        }
        gen.insert(make_pair(suit, kind));
    }
    return gen;
}

void printCards(map<string, vector<int>> &cards) {
    for (auto suit : suits) {
        for (auto card: cards[suit]) {
            cout << suit << " " << card << endl;
        }
    }
}

Measured memory_bytes: 1232
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long double ll;

int main()
{
	ll a,b,n;cin >> a >> b >> n;
	ll x = min(b - 1,n);
	cout << floor(a * x / b) - a * floor(x / b);
	
    return 0;
}


Measured memory_bytes: 3788
<?php

$input = file_get_contents('php://stdin');
$counts = count_chars($input, 1);

$isBeautiful = true;
foreach($counts as $ord => $count) {
    if ($ord >= 97 && $char <= 122 && $count % 2 !== 0) {
        $isBeautiful = false;
        break;
    }
}

echo $isBeautiful ? "Yes" : "No";

Measured memory_bytes: 3576
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[25], B[25], C[25];
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];
    rep(i,0,N-1) cin >> C[i];
    ll ans = 0;
    rep(i,0,N) ans += B[i];
    rep(i,0,N-1){
        if(A[i+1] - A[i] == 1) ans += C[A[i]-1];
    }
    print(ans);
    
}

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

int main() {
    long int S;
    cin >> S;
    long int X2 = 1000000000;
    long int X3, Y3;
    X3 = X2 - S%X2;
    Y3 = 1 + S/X2;
    if(X3 == X2){
        X3 = 0;
        Y3 --;
    }

    cout<<"0 0 1000000000 1 "<<X3<<" "<<Y3;
}


Measured memory_bytes: 256
N = int(input())
CSF = []
for i in range(N-1):
    CSF.append(list(map(int, input().split())))


for i in range(N-1):
    start = CSF[i][1]
    
    goal = 0
    for cur in range(i,N-1):
        start = max(CSF[cur][1], 
                    (goal//CSF[cur][2]+bool(goal%CSF[cur][2])) * CSF[cur][2])
        goal = start + CSF[cur][0]
        
    print(goal)
    
print(0)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
char s[100050];
int mo=1e9+7;
int pre[4],dp[100050],flag,tmp,cnt,ans;
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for (int i=1;i<n;i++)if (s[i]==s[i+1]){flag=1;break;}
	if (!flag){printf("1\n");return 0;}
	dp[0]=1;
	pre[0]=0,pre[1]=pre[2]=-1;
	for (int i=1;i<=n;i++){
		tmp=(tmp+s[i]-'a'+1)%3;
		if (!tmp&&i<n)dp[i]=1;
		for (int j=1;j<=2;j++)if (pre[(tmp+j)%3]!=-1)dp[i]=(dp[i]+dp[pre[(tmp+j)%3]])%mo;
		pre[tmp]=i;
	}
	/*for (int i=1;i<=n;i++){
		cnt=(cnt+s[i]-'a'+1)%3;
		if (cnt==tmp)ans=(ans+dp[i])%mo;
	}*/
	printf("%d",dp[n]);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
//const int mod=998244353;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];
char s[maxn];
int main(){
    int n,m,T;
    cin>>s+1;
	scanf("%s",s+1);
	n=(int)strlen(s+1);
	if(s[n]=='1'||s[1]=='0'||s[n-1]=='0'){
		printf("-1\n");
		return 0;
	}
	int now = 2;
	while(now<=n-now){
		if(s[now]!=s[n-now]) {
			printf("-1\n");
			return 0;
		}
		now++;
	}
	int root=2,num=1;
	now=2;
	printf("2 1\n");
	while(now<=n-now){
		if(s[now]=='1'){
			printf("%d %d\n",++now,root);
			root=now;
		}else{
			printf("%d %d\n",++now,root);
		}
		num++;
	}
	for(int i=num+1;i<n;i++){
		printf("%d %d\n",root,++now);
	}

    return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 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 set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
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;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  int N = sz(s);
  ll ans = 0;
  for(int b = 0; b < (1<<(N-1));b++) {
    ll tmp = (ll)(s[0] - '0');
    rep(i,N-1) {
      if((b>>i) & 1) {
        ans += tmp;
        tmp = (ll)(s[i+1] - '0');
        
      } else {
        tmp = tmp * 10 + (ll)(s[i+1] - '0');
      }
      
    }
    ans += tmp;
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
	ll int k;
	cin>>k;
	string s;
	cin>>s;
	if (s.size()<=k)
	cout<<s<<endl;
	else
	{
		string ans;
		ans=s.substr(0,k);
		ans+="...";
		cout<<ans<<endl;
	}

	
	
	
			
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include "cmath"
#include <cstdlib>
#include <string>
#include <utility>

using namespace std;
typedef long long ll;

const ll INF = 10000000000;

struct node {
    int pointer_i;
    int pointer_j;
    int len;
};

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

    int A, B;
    cin >> A >> B;

    if (A >= 13) {
        cout << B << endl;
    } else if ( A <= 5) {
        cout << 0 << endl;
    } else {
        cout << B / 2 << endl;
    }

    return 0;
}

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

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			int k = cin.ReadInt();
			int s = cin.ReadInt();

			int ans = 0;
			for (int x = 0; x <= k; x++)
			{
				for (int y = 0; y <= k; y++)
				{
					if (s - x - y >= 0 && s - x - y <= k) ans++;
				}
			}
			Console.WriteLine(ans);
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));
	}
}

Measured memory_bytes: 13140
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N, M = map(int, input().split())
AB = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(M)]

ans = 0
for i in range(M):
    tree = UnionFind(N)
    for a, b in (AB[:i] + AB[i + 1:]):
        tree.union(a, b)
    if tree.getComponent() > 1:
        ans += 1
print(ans)


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

using namespace std;

int main(void){

    int n, m;
    cin >> n;
    vector<string> s(n);
    for(int i = 0;i < n;i++) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    for(int i = 0;i < m;i++) cin >> t[i];

    int ans = 0;

    for(int i = 0;i < n;i++){
        int score = 0;
        for(int j = 0;j < n;j++) if(s[i] == s[j]) score++;
        for(int j = 0;j < m;j++) if(s[i] == t[j]) score--;
        ans = max(ans, score);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef struct{
	int a,b;
}data;

int compare(const void *x, const void *y){return (((data*)x)->b - ((data*)y)->b);}

int main(void){
	int N,M,i;
	scanf("%d%d",&N,&M);
	data island[M];
	for(i=0;i<M;i++)scanf("%d%d",&island[i].a,&island[i].b);
		
	qsort(island,M, sizeof(data), compare);
	
	int p = island[0].b-1,ans=1;
	for(i=1;i<M;i++){
		if(p < island[i].a){
			p = island[i].b-1;
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <cstdlib>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

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

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    vector<P> A(H * W + 1, P{0LL, 0LL});
    REP (i, 0, H) REP (j, 0, W) {
        int a;
        cin >> a;
        A[a] = P{j, i};  // {x, y}
    }
    vector<lli> C(H * W + 1, 0LL);
    REP (i, D + 1, A.size()) {
        lli cost = abs(A[i - D].first - A[i].first) + abs(A[i - D].second - A[i].second);
        C[i] = (C[i - D] + cost);
    }

    int Q;
    cin >> Q;
    REP (i, 0, Q) {
        int L, R;
        cin >> L >> R;
        cout << C[R] - C[L] << endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int w[111], v[111];
int dp[111][N];

int solve(int n, int W) {
    if (n == 0) {
        return 0;
    }

    if (dp[n][W] != -1) {
        return dp[n][W];
    }

    int ans = 0;
    if (w[n] <= W) {
        ans = max(ans, v[n] + solve(n - 1, W - w[n]));
    }

    return dp[n][W] = max(ans, solve(n - 1, W));
}

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

    int n, W;
    cin >> n >> W;

    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= W; j++) {
            dp[i][j] = -1;
        }
    }

    cout << solve(n, W) << "\n";
    return 0;
}


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

int main(){
  // 入力
  long long H;
  cin >> H;

  int depth = 0;

  while(H > 0){
    H /= 2;
    depth++;
  }

  long long x = 1;
  long long sum = 0;
  for(int i = 0; i < depth; i++){
    sum += x;
    x *= 2;
  }

  cout << sum << endl;
}
 



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
long int cost(long int arr[],long int n)
{
    long int dp[n+1];
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
    }
    return dp[n-1];
}
int main()
{
	long int n;
    cin>>n;
    long int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    cout<<cost(arr,n)<<endl;
	return 0;
}

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

typedef long long int ll;

const ll MOD = (ll)1e9 + 7;
const int N = 200010;

inline ll exgcd (ll a, ll b, ll &x, ll &y) {
	if (a == 0) return x = 0,y = 1,b;
	ll xn, yn, g;
	g = exgcd(b % a, a, xn, yn),x = yn - xn * (b / a),y = xn;
	return g;
}

inline ll inv (ll a, ll b) {ll x, y, g;return g = exgcd(a, b, x, y), g!=1?-1:(x % b + b) % b;}
inline ll sub (ll a, ll b, ll p) {ll res = a - b;return res<0?res+p:res;}
inline ll add (ll a, ll b, ll p) {ll res = a + b;return res>=p?res-p:res;}
inline ll mul (ll a, ll b, ll p) {return ((a % p) * (b % p)) % p;}

inline ll qpow (ll a, ll b, ll p) {
	if (b == 1) return a % p;
	if (b & 1) return mul(a, qpow(a, b - 1, p), p);
	else {
		ll x = qpow(a, b / 2, p);
		return mul(x, x, p);
	}
}

ll fact[N], n, m, k;

inline ll calc (ll r, ll c) {
	ll a = r * (r - 1) + (n - r) * (n - r + 1), b = c * (c - 1) + (m - c) * (m - c + 1);
	return add(mul(a, m, MOD), mul(b, n, MOD), MOD);
}

int main () {
	fact[0] = 1;
	for (int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i, MOD);
	scanf("%lld %lld %lld", &n, &m, &k);
	ll f = mul(fact[n * m - 2], mul(inv(fact[k - 2], MOD),inv(fact[n * m - k], MOD), MOD), MOD),res = 0;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) res = add(res, mul(f, calc(i, j), MOD), MOD);
	res = mul(res, inv(4, MOD), MOD),
	printf("%lld\n", res);
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

u=input().rstrip().split(",")
for U in u:
    print(U,end=" ")

Measured memory_bytes: 3316
N,M,Q=map(int,input().split())
A=[0]*Q
B=[0]*Q
C=[0]*Q
D=[0]*Q
for i in range(Q):
    a,b,c,d=map(int,input().split())
    A[i]=a-1
    B[i]=b-1
    C[i]=c
    D[i]=d
smax=0
def dfs(L):
    global smax
    # 終端条件 --- N 重ループまで回したら処理して打ち切り
    if len(L) == N:
        s=0
        for i in range(Q):
            if L[B[i]] - L[A[i]] == C[i]:
                s+=D[i]
        if s>smax:
            smax=s
        return

    #数列の最後の値からMまでの範囲を回す。もし最後の値が空なら1になる
    prev_last = L[-1] if len(L) > 0 else 1
    for v in range(prev_last,M+1):
        L.append(v)
        dfs(L)
        L.pop()

dfs([])#L=[]のリストとなっている
print(smax)

Measured memory_bytes: 9192
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	LL ans = max({a * c, a * d, b * c, b * d});
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

	string res = "";

	// s -> t
	for (int x = sx; x < tx; ++x) res += 'R';
	if (sy < ty){
		for (int y = sy; y < ty; ++y) res += 'U';
	}else{
		for (int y = sy; y > ty; --y) res += 'D';
	} // end if

	// t -> s
	for (int x = tx; x > sx; --x) res += 'L';
	if (ty < sy){
		for (int y = ty; y < sy; ++y) res += 'U';
	}else{
		for (int y = ty; y > sy; --y) res += 'D';
	} // end if

	// s -> t
	res += 'L';
	if (sy < ty){
		for (int y = sy; y <= ty; ++y) res += 'U';
	}else{
		for (int y = sy; y >= ty; --y) res += 'D';
	} // end if
	for (int x = sx - 1; x < tx; ++x) res += 'R';
	res += 'D';
	// t -> s
	res += 'R';
	if (ty < sy){
		for (int y = ty; y <= sy; ++y) res += 'U';
	}else{
		for (int y = ty; y >= sy; --y) res += 'D';
	} // end if
	for (int x = tx + 1; x > sx; --x) res += 'L';
	res += 'U';

	cout << res << endl;
	
       return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  vector<ll> N(S.size());
  for(ll i = 0; i < S.size(); i++) {
    N[i] = S[i] - '0';
  }
  ll sum = 0;
  for(ll bit = 0; bit < pow(2, S.size() - 1); bit++) {
    ll tmp = 0;
    for(ll i = 0; i < S.size() - 1; i++) {
      if(bit & (1 << i)) {
        tmp += N[i];
        sum += tmp;
        tmp = 0;
      } else {
        tmp += N[i];
        tmp *= 10;
      }
    }
    tmp += N[S.size() - 1];
    sum += tmp;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

const INF: usize = std::usize::MAX;

#[fastout]
fn main() {
    input! {
    n: usize,
    m: usize,
    ps: [(Usize1, String); m]
    }
    let mut is_ac = vec![0; n];
    let mut wa = 0;
    for i in 0..m {
        let (p, s) = &ps[i];
        if is_ac[*p] == INF {continue}
        if s == "AC" {
            wa += is_ac[*p];
            is_ac[*p] = INF;
        }
        if s == "WA" {
            is_ac[*p] += 1;
        }
    }
    let ac = is_ac.iter().filter(|&&x| x == INF).count();
    println!("{} {}", ac, wa);
}


Measured memory_bytes: 9952
while True:
        a=input()
        b=a.split()
        op=b[1]
        a=int(b[0])
        b=int(b[2])
        if op=="+":
                print(a+b)
        elif op=="-":
                print(a-b)
        elif op=="*":
                print(a*b)
                
        elif op=="/":
                print(a//b)
        else:
                break



Measured memory_bytes: 5596
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
result=0
flag=0
for i in range(n):
    x-=a[i]
    if x<0:
        result=i
        flag=1
        break
    if x==0:
        result=i+1
        flag=1
        break
if flag==1:
    print(result)
    
else:
    print(n-1)

Measured memory_bytes: 3064