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

int main(void){

   int h = 0, m = 0, s;

   scanf("%d", &s);

   while(s >= 3600){
      s = s - 3600;
      h++;
   }

   while(s >= 60){
      s = s - 60;
      m++;
   }

   printf("%d:%d:%d\n", h, m, s);

   return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;



string S, T;
int S_a_cnt[100001], T_a_cnt[100001];


int main(){
    cin >> S;
    cin >> T;
    for(int i = 1; i <= S.length(); i++){
        S_a_cnt[i] = S_a_cnt[i-1];
        if(S[i-1] == 'A'){
            S_a_cnt[i]++;
        }
        //cout << S_a_cnt[i] << " ";
    }
    //cout << endl;
    for(int i = 1; i <= T.length(); i++){
        T_a_cnt[i] = T_a_cnt[i-1];
        if(T[i-1] == 'A'){
            T_a_cnt[i]++;
        }
    }

    int q;
    cin >> q;
    for(int q_ = 0; q_ < q; q_++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int x = S_a_cnt[b] - S_a_cnt[a-1];
        int y = (b-a+1) - x;
        int z = T_a_cnt[d] - T_a_cnt[c-1];
        int w = (d-c+1) - z;
        //printf("x = %d, y = %d, z = %d, w = %d\n", x, y, z, w);
        if((x+1000000 - y) % 3 == (z+1000000 - w)%3){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

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

int n, m;
int arr[20][20];

bool input() {
    scanf("%d %d", &n, &m);
    if (!n && !m) return 0;
    for (int i = 0 ; i < n ; i++ ) {
        for ( int j = 0 ; j < m ; j++ ) {
            scanf("%d", &arr[i][j]);
        }
    }
    return 1;
}

int check(int x, int y, int a, int b) {
    int out = 10000;
    for (int i = y ; i <= b ; i++ ) out = min(out, arr[x][i]);
    for (int i = y ; i <= b ; i++ ) out = min(out, arr[a][i]);
    for (int i = x+1 ; i < a ; i++ ) out = min(out, arr[i][y]);
    for (int i = x+1 ; i < a ; i++ ) out = min(out, arr[i][b]);

    int res = 0;
    for (int i = x+1 ; i < a ; i++ ) {
        for ( int j = y+1 ; j < b ; j++ ) {
            if ( arr[i][j] >= out  ) return 0;
            else res += out - arr[i][j];
        }
    }
    return res;
}

void solve() {
    int mx = 0;
    for (int i = 0 ; i < n ; i++ ) {
        for (int j = 0 ; j < m ; j++ ) {
            for (int a = i + 2 ; a < n ; a++ ) {
                for ( int b = j + 2 ; b < m ; b++ ) {
                    mx = max(mx, check(i, j, a, b));     
                }
            }
        }
    }
    cout <<mx << endl;
}

int main(){
    while(input())
    solve();
}

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

int main() {
    cin >> s;
    int i = 0;
    while (i < s.size() && s[i] == 'T') i++;
    int res = 0;
    while (i < s.size()) {
        int j = i;
        int cnt = 0;
        int T = 0, S = 0;
        while (cnt >= 0) {
            if (j < s.size()) {
                if (s[j] == 'S') {
                    cnt++;
                    T++;
                } else {
                    cnt--;
                    S++;
                }
            } else break;
            if (cnt < 0) break;
            j++;
        }
        res += 2 * min(T, S);
        i = j;
        while (i < s.size() && s[i] == 'T') i++;
    }
    cout << s.size() - res << endl;
}


Measured memory_bytes: 640
N=int(input())

A=[0]*(100)
B = [0]*(100)
M=10

A=[[0 for j in range(M)]for i in range(M)]
B = [[0 for j in range(M)]for i in range(M)]

for n in range(1,N+1):
    if n>N:
        continue
    sn=list(map(int,list(str(n))))
    #tmp=str(sn[0])+str(sn[-1])
    if sn[0]==0 or sn[-1]==0:
        continue
    
    A[sn[0]][sn[-1]]+=1    
    #B[sn[-1]][sn[0]] += 1


"""
     tmp =10*sn[0]+sn[-1]
    A[tmp]+=1
    tmp = 10*sn[-1]+sn[0]
    B[tmp] += 1 
"""

res=0
for n in range(1,9+1):
    if n > N:
        continue

    #res+=1


res=0

for top in range(1,10):
    for tail in range(1,10):


        tmp = (A[top][tail]*A[tail][top])
        if tmp>0:
            #print(top, tail, tmp, A[top][tail])
            res+=(A[top][tail]*A[tail][top])
            #res+=(A[10*top+tail]*B[10*tail+top])


print(res)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    double n;
    cin>>n;
    double a = n/3;
    a = a*a*a;
    cout<<fixed<<setprecision(9)<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> L(N, 0);
  for (int i = 1; i < N; i++){
    if (S[i - 1] == 'W'){
      L[i] = L[i - 1] + 1;
    } else {
      L[i] = L[i - 1];
    }
  }
  vector<int> R(N, 0);
  for (int i = N - 2; i >= 0; i--){
    if (S[i + 1] == 'E'){
      R[i] = R[i + 1] + 1;
    } else {
      R[i] = R[i + 1];
    }
  }
  int ans = INF;
  for (int i = 0; i < N; i++){
    ans = min(ans, L[i] + R[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
S = input()

def is_even_string(string):
    # print("str1: {}, str2: {}".format(string[:len(string)//2], string[len(string)//2:]))
    if string[:len(string)//2] == string[len(string)//2:]:
        return True
    else:
        return False

for i in range(2, len(S), 2):
    new_S = S[:len(S)-i]
    # print("new_S: {}".format(new_S))
    if is_even_string(new_S):
        print(len(new_S))
        exit(0)


Measured memory_bytes: 2940
#include <stdio.h>

int n, k;

// ?°?????????????????????¢??°
int min(int a, int b)
{
	if (a < b) {
		return a;
	}

	else {
		return b;
	}
}

// ???????????????????????????????????¢???????°?
int solve1(int a, int b)
{
	return ((min(min(a - 1, b - 1), min(n - a, n - b))) % 3 + 1);
}

// ????§??????§????????£???????????§??????????±???????
int solve2(int a, int b)
{
	if (a <= b) {
		if (a + b <= n) {
			return (a - 1) % 3 + 1;
		}
		else {
			return (n - b) % 3 + 1;
		}
	}
	else {
		if (a + b <= n) {
			return (b - 1) % 3 + 1;
		}
		else {
			return (n - a) % 3 + 1;
		}
	}
}

int main(void)
{
	int i;
	int a, b;

	scanf("%d %d", &n, &k);
	for (i = 0; i < k; ++i) {
		scanf("%d %d", &a, &b);

		printf("%d\n", solve1(a, b));
		//printf("%d\n", solve2(a, b));
	}

	return (0);
}

Measured memory_bytes: 2712
from itertools import permutations
n, m = map(int, input().split())
pair = [tuple(map(int, input().split())) for i in range(m)]
num = [i for i in range(1,n+1)]
ans = 0
for p in permutations(num):
    if p[0] != 1:
        continue
    already = []
    state = True
    for i in range(n-1):
        if p[i] in already:
            state = False
            break
        if (min(p[i], p[i+1]), max(p[i], p[i+1])) not in pair:
            state = False
            break
        already.append(p[i])
    if state:
        ans += 1
print(ans)


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

int main( void )
{
	ll x;

	reps( i, 5 ) {
		cin >> x;

		if ( x == 0 ) {
			cout << i << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3624
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	while(input.hasNextInt()){
    		int a = input.nextInt();
    		int b = input.nextInt();
    		int c = input.nextInt();
    		int d = input.nextInt();
    		int e = input.nextInt();
    		int f = input.nextInt();
    		
    		double det = a*e-b*d;
    		double x = (double)(c*e-b*f)/det;
    		double y = (double)(-c*d+a*f)/det;
    		System.out.println(new BigDecimal(x).setScale(3, BigDecimal.ROUND_FLOOR)+" "+new BigDecimal(y).setScale(3, BigDecimal.ROUND_HALF_UP));
    
    	}
    }
}

Measured memory_bytes: 18208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

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

    bool can;
    if ((b - a) % 2 == 0) can = false;
    else can = true;

    if (!can) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAXN 3000
using namespace std;

int R, G, B, N;
long long int num[MAXN+5];

int main() {
  cin >> R >> G >> B >> N;
  num[0] = 1;
  for (int i = R; i <= N; i++) {
    num[i] += num[i-R];
  }
  for (int i = G; i <= N; i++) {
    num[i] += num[i-G];
  }
  for (int i = B; i <= N; i++) {
    num[i] += num[i-B];
  }
  cout << num[N] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int deg[100001], c[100001], used[100001];

int main(){
	int N; cin >> N;
	vector<P> G[N];
	for(int i=0; i<N-1; i++){
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(P(b, i));
		G[b].push_back(P(a, i));
		deg[a]++; deg[b]++;
	}
	int K = 0;
	for(int i=1; i<N; i++){
		if(deg[K] < deg[i]) K = i;
	}
	cout << deg[K] << endl;
	queue<int> que;
	que.push(K);
	used[K] = 1; c[K] = 0;
	int ans[N-1];
	while(que.size()){
		int aa = que.front(); que.pop();
		int cnt = 1;
		for(int i=0; i<G[aa].size(); i++){
			if(used[G[aa][i].first] == 0){
				if(cnt == c[aa]) cnt++;
				c[G[aa][i].first] = cnt;
				ans[G[aa][i].second] = cnt;
				cnt++;
				used[G[aa][i].first] = 1;
				que.push(G[aa][i].first);
			}
		}
	}
	for(int i=0; i<N-1; i++){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 10112
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<stack>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
#include<iomanip>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int>> s(m);
    for(int i=0;i<m;i++){
        int k; cin >> k;
        s[i].resize(k);
        for(int j=0;j<k;j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    int p[m]; cinf(m,p);
    int ans = 0;
    for(int bit=0;bit<(1<<n);bit++){
        bool light = true;
        for(int i=0;i<m;i++){
            int c =0;
            for(int id:s[i]){
                if((bit>>id)&1) c++;
            }
            c %= 2;
            if(c!=p[i]) light=false;
        }
        if(light) ans++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e6 + 2;
int primes[N];
void sieve(){
    //memset(primes,1,sizeof(primes));
    for(int i = 0; i < N; i++)
        primes[i] = i;
    for(int i = 2; i < N; i++)
        if(primes[i] == i)
        {
            for(int j = i+i ; j < N; j += i)
                primes[j] = min(primes[i],primes[j]);
        }
}
int ans = 0;
void pf(int n)
{
    int p = n, res = 1;
    while(p > 1)
    {
        int cn = 0;
        int x = primes[p];
        while(p%x == 0)
        {
            p/=x;
            cn++;
        }
        res *= (cn+1);
    }
    ans += res;
}
signed main(){
    int t = 1; //cin >> t;
    while(t--){
        int n; cin >> n;
        sieve();
        for(int i = 1; i < n; i++)
            pf(i);
        cout << ans;
    }    
}

Measured memory_bytes: 11440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    struct lnk
    {
        int next;
        int loopNum;
    };


    int N;
    ll K;
    cin >> N >> K;

    vector<int> v(N);

    rep(i, N)
    {
        cin >> v[i];
        v[i]--;
    }

    vector<bool> th(N);
    rep(i, N)
    {
        th[i] = false;
    }

    int i=0;
    vector<int> route;
    int loopP=-1;
    while(true)
    {
        if(th[i])
        {
            loopP=i;
            break;
        }
        th[i]=true; //足跡
        route.push_back(i);
        i = v[i];
    }

    int loopLength = 0;
    {
        int p = route.size()-1;
        while(route[p]!=loopP && p>=0)
        {
            ++loopLength;
            --p;
        }
        ++loopLength;
    }


    {
        int p=0;
        while(K>0 && p!=loopP)
        {
            p=v[p];
            --K;
        }
        
        if(K>0)
        {
            K = K%loopLength;
            p=loopP;
            rep(i, K)
            {
                p=v[p];
            }
        }
        cout << p+1 << endl;
    }

    



    return 0;
}

Measured memory_bytes: 5072
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fLL
#define rep(i,a,b) for(register ll i=(a);i<=(b);i++)
#define dep(i,a,b) for(register ll i=(a);i>=(b);i--)
using namespace std;
const int maxn=50+5;
const int maxm=5000+5;
//const double pi=acos(-1.0);
//const double eps=1e-9;
const ll mo=1e9+7;
int n,m,k;
int a[maxn];
int ans,tmp,cnt;
ll dp[maxn][2510];
char s[maxn];
ll power(ll a,ll n)
{
    ll sum=1;
    while(n)
    {
        if(n&1) sum=sum*a%mo;
        n>>=1;
        a=a*a%mo;
    }
    return sum;
}
int main()
{
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int sum=0;
        rep(i,1,n)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        memset(dp,-1,sizeof(dp));
        dp[0][0]=1;
        rep(i,1,n)
        {
            dep(k,i-1,0)
            dep(j,sum,a[i])
            if(dp[k][j-a[i]]!=-1){
                dp[k+1][j]=max(dp[k+1][j],0LL);
                dp[k+1][j]+=dp[k][j-a[i]];
                //if(j==18)
                //cout<<k<<" * "<<i<<" "<<dp[k][j-a[i]]<<endl;
            }
        }
        //rep(i,1,n)
        //rep(j,0,sum)
        //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        ll ans=0;
        rep(i,1,n)
        if(i*m<=sum&&dp[i][i*m]>0){
            ans+=dp[i][i*m];
            //cout<<i<<" "<<i*m<<" "<<dp[i][i*m]<<endl;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1280
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool ok = s == "keyence";
    for(size_t i = 0; i < s.size(); i++){
        for(size_t j = 0; j < s.size(); j++){
            string ss = s;
            ok |= ss.erase(i, j) == "keyence";
        }
    }
    cout << (ok ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;

int N;

int main() {
  std::vector<ll> plus;
  std::vector<ll> minus;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    ll x, y;  std::cin >> x >> y;
    plus.push_back(x + y);
    minus.push_back(x - y);
  }
  std::sort(plus.begin(), plus.end());
  std::sort(minus.begin(), minus.end());

  std::cout << std::max(plus[N-1] - plus[0],
                        minus[N-1] - minus[0]) << "\n";

  return 0;
}


Measured memory_bytes: 6584
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll gcd(ll a, ll b){

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

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

int main() {
    ll N, M;
    string S, T;

    cin >> N >> M;
    cin >> S;
    cin >> T;

    ll L = lcm(N, M);

    map<ll, char> good;

    for (int i = 0; i < N; ++i) {
        good[i * (L / N) + 1] = S[i];
    }
    for (int i = 0; i < M; ++i) {
        if(good.find(i *(L/M) + 1)!=good.end() && good[i * (L/M) + 1] != T[i]){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << L << endl;


    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int sum = 0;
	for (int i = 0; i < n; i++)
		sum += s[i];
	sort(s.begin(), s.end());
	int keep = sum;
	if (sum % 10 == 0) {
		for (int i = 0; i < n; i++) {
			if (s[i] % 10 == 0)
				continue;
			keep -= s[i];
			break;
		}
		if (sum == keep) {
			cout << 0 << endl;
			return 0;
		}
		cout << keep << endl;
		return 0;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a=[0]
b=[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

#print(a)
#print(b)

ans=0
j=M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    #print(i,j)
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47496
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
#define N 200010

int main() {
	int n, a[N], b[N] = { 0 }, c[N] = { 0 }; ll k;
	scanf("%d %lld", &n, &k);
	Rep(i, 1, n + 1)scanf("%d", &a[i]);
	int ch = 1, start, end;//行ってみる,startはループ開始,endはループ2週目の最初の何番目か
	if(a[1]==1){printf("1");return 0;}
	if(k==1){printf("%d",a[1]);return 0;}
	Rep(i, 1, N+10) {
		if (b[ch]!=0){ start = b[ch]; end = i; break; }
		b[ch] += i;
		ch = a[ch];
    }
	c[0]=ch;
	Rep(i,1,end-start+1) {
		c[i] = a[ch];
		ch = a[ch];
	}
	if (k<=start) {
		ch=1;int K = k;
		rep(i,K) {
			ch = a[ch];
		}
		printf("%d",ch);
	}
	else if(end-start==1){
    	a[0]=1;
		printf("%d", ch);
	}
	else{
		k++;
		k = k-start;
		k = k%(end-start);
		printf("%d",c[k]);
	}
}

Measured memory_bytes: 4072
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

uint64_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;

	uint64_t count = (N / 11)*2;
	if (N % 11 > 6) { ++count; }
	if (N % 11 > 0) { ++count; }

	std::cout << count << std::endl;

	return 0;
}
#endif


Measured memory_bytes: 384
import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]

g=nx.Graph()
g.add_nodes_from([i for i in range(1,n+1)])

for x in s:
    g.add_edge(x[0],x[1])
di=nx.predecessor(g,source=1)

if len(di)!=n:
    print("No")
    exit()

print("Yes")
for x in range(2,n+1):
    print(di[x][0])

Measured memory_bytes: 226076
function main(input) {
  const N = parseInt(input);

  let res = 0;

  for (let i = 1; i <= N; ++i) {
    const num = i % 3 === 0 || i % 5 === 0 ? 0 : i;

    res += num;
  }

  console.log(res);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 33224
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a=n%10;
  if(a==2 || a==4 || a==5 || a==7 || a==9){
    cout << "hon" << endl;
  }
  else if(a==0 || a==1 || a==6 || a==8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string a,b;
  cin>>a>>b;
  if(a>b)cout<<">"<<endl;
  else if(a<b)cout<<"<"<<endl;
  else cout<<"="<<endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
using namespace std;


int main(){
    int a,b;
    string op;
    cin >> a >> op >>b;
    while(op!="?"){
        if(op=="+"){
            cout << a+b << endl;
        }
        else if(op=="-"){
            cout << a-b << endl;
        }
        else if(op=="*"){
            cout << a*b << endl;
        }
        else{
            cout << a/b << endl;
        }
        cin >> a >> op >>b;
    }



}


Measured memory_bytes: 3140
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int c[111][111];
int t[111][111];
int main(void){
  while(1){
    int n,m;
    cin >> n >> m;

    if(!n && !m) break;

    for(int i = 1 ; i <= m; i++){ 
      fill(c[i], c[i] + m + 1, 1 << 20);
      fill(t[i], t[i] + m + 1, 1 << 20);
      c[i][i] = 0;
      t[i][i] = 0;
    }
    for(int i = 0 ; i < n; i++){
      int a,b,cost,time;
      cin >> a >> b >> cost >> time;
      c[a][b] = min(c[a][b],cost);
      c[b][a] = min(c[b][a],cost);
      t[a][b] = min(t[a][b],time);
      t[b][a] = min(t[b][a],time);
    }
    for(int k =1; k <= m; k++){
      for(int i = 1; i <= m; i++){
	for(int j = 1; j <= m; j++){
	  c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
	  t[i][j] = min(t[i][j],t[i][k] + t[k][j]);
	}
      }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
      int a,b,f;
      cin >> a >> b >> f;
      if(f){
	cout << t[a][b] << endl;
      }else{
	cout << c[a][b] << endl;
      }
    }
  }
}

Measured memory_bytes: 1252
n,q=map(int,input().split())
s=input()
a=[0]*(n+10)
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]
for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Measured memory_bytes: 52824
import java.util.Scanner;

//Sum of Nth decimal places
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			int k = 1;
			int s = 0;
			int r = a%b;
			while(k<=n&&r>0){
				s += r*10/b;
				r = r*10%b;
				k++;
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forall(it,p) \
    for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1

#define R 1000000007
#define MAXN 100
#define MAXK 100001
int a[MAXN];
long b[MAXN][MAXK];
long c[MAXK];

int main() {
  int n,k;
  cin >> n >> k;
  forr(i,0,n-1)
    cin >> a[i];

  forr(i,0,n-1)
    forr(j,0,k)
      b[i][j] = 0;

  forr(j,0,a[0])
    b[0][j] = 1;

  forr(i,1,n-1) {
    c[0] = b[i-1][0];
    forr(j,1,k)
      c[j] = (c[j-1] + b[i-1][j])%R;
    forr(j,0,k) {
      b[i][j] =
        (R + c[j] - (j<=a[i] ? 0 : c[j-a[i]-1])) % R;
    }
  }
  cout << b[n-1][k];
}


Measured memory_bytes: 79104
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<pii> A;
    for (int i = 1; i <= M; i++) {
        if (i&1) {
            A.emplace_back(N-i,i);
        } else {
            A.emplace_back(i,N-i);
        }
    }
    sort(all(A));
    reverse(all(A));
    rep(i,M) {
        //cout << A[i].first << " " << A[i].second << ln;
        cout << i+1 << " " << i+1+A[i].first << ln;
    }
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  string s,t;
  cin>>s>>t;
  string r;
  REP(i,s.size()){
    r+=t[i];
  }
  if(s==r){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 3628
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <queue>
#include <math.h>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

constexpr auto NMAX = (int)1e5 + 20;

using namespace std;

typedef unsigned long long ull;

queue<ull> nbs;
int k, cntr;

int main()
{
	cin >> k;
	if (k <= 10)
	{
		cout << k << '\n';
		exit(0);
	}
	for (ull i = 1; i < 10; i++)
	{
		nbs.push(i);
	}

	cntr = 1;
	while (cntr < k)
	{
		ull current = nbs.front();
		nbs.pop();
		cntr++;

		int last_digit = current % 10;
		if (last_digit == 0)
		{
			nbs.push(current * 10 + last_digit);
			nbs.push(current * 10 + last_digit + 1);
			continue;
		}

		if (last_digit == 9)
		{
			nbs.push(current * 10 + last_digit - 1);
			nbs.push(current * 10 + last_digit);
			continue;
		}

		nbs.push(current * 10 + last_digit - 1);
		nbs.push(current * 10 + last_digit);
		nbs.push(current * 10 + last_digit + 1);
	}

	cout << nbs.front() << '\n';
	return 0;
}

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

using namespace std;

int main(){
    int a,b,c=0,max=0,x=0;
    cin>>a>>b;
    c=b-a;
    for(int i=1;i<=c;i++){
        max=max+i;
    }
    x=max-b;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
*a, = map(int, input().split())
v = sum(a)
c = Counter(a)

for n in range(N+1)[::-1]:
    if v-(N-1)*n>=0 and (v-(N-1)*n)%N==0:
        k = (v-(N-1)*n)//N
        if (k==0 and n==N) or (k and (N-n)%k==0):
            if c[n+k]==N-n and c[n+k-1]==n:
                print("Yes")
                break
else:
    print("No")


Measured memory_bytes: 18656
def dfs(i, sum, cnt, memo):
    if i == d + 1:
        if sum >= g:
            tmp.append(cnt)
        else:
            cnt += min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100)))
            if sum + min(p_lst[max(memo) - 1], -(-(g - sum) // (max(memo) * 100))) * max(memo) * 100 >= g:
                tmp.append(cnt)
        
    else:
        dfs(i + 1, sum + 100 * i * p_lst[i - 1] + c_lst[i - 1], cnt + p_lst[i - 1], memo)
        dfs(i + 1, sum, cnt, memo + [i])

d, g = map(int, input().split())
p_lst = []
c_lst = []
tmp = []
for i in range(d):
    p, c = map(int, input().split())
    p_lst.append(p)
    c_lst.append(c)


dfs(1, 0, 0, [])
print(min(tmp))

Measured memory_bytes: 3064
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
xy.sort()

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        p = xy[j][0]-xy[i][0]
        q = xy[j][1]-xy[i][1]
        merge = 0
        for k in range(N):
            if [xy[k][0]+p, xy[k][1]+q] in xy:
                merge += 1
        ans = max(ans, merge)
print(N-ans)


Measured memory_bytes: 3064
H,W = map(int,input().split())
S = [["." for _ in range(W+2)]]
for _ in range(H):
    row = list(input())
    row.insert(0,".")
    row.append(".")
    S.append(row)
S.append(["." for _ in range(W+2)])
A = [["#" for _ in range(W)] for _ in range(H)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]==".":
            cnt = 0
            if S[i][j+1]=="#":
                cnt += 1
            if S[i-1][j+1]=="#":
                cnt += 1
            if S[i-1][j]=="#":
                cnt += 1
            if S[i-1][j-1]=="#":
                cnt += 1
            if S[i][j-1]=="#":
                cnt += 1
            if S[i+1][j-1]=="#":
                cnt += 1
            if S[i+1][j] =="#":
                cnt += 1
            if S[i+1][j+1]=="#":
                cnt += 1
            A[i-1][j-1] = str(cnt)
for i in range(H):
    print("".join(A[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
int gcd(int a, int b){
	return b?gcd(b, a%b):a;
}

int main(){
	int n; scanf("%d", &n);
	int x = 0, a;
	REP(i, n) scanf("%d", &a), x=gcd(x, a);
	printf("%d\n", x);
}


Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
set<int>gr[maxn];
int h[maxn];
void solve()
{
    int n,m;
    cin>>n>>m;
    rep1(i,n) cin>>h[i];
    rep0(i,m){
        int x,y;
        cin>>x>>y;
        gr[x].in(y);
        gr[y].in(x);
    }
    int ans=0;
    rep1(i,n){
        bool p=true;
        for(auto x:gr[i]){
            if(h[x]>=h[i]){
                p=false;
                break;
            }
        }
        if(p) ans++;
    }
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //srand(time(0));
    //freopen("sp.txt","w",stdout);
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 18460
#include<stdio.h>

int n, A[50];

// 入力値の M から選んだ要素を引いていく再帰関数
int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define md 1000000007


int main() 
{ 
    ll a,b,sum,mul,sub,m=-999999999;
    cin>>a>>b;
    sum=a+b;
    sub=a-b;
    mul=a*b;
    m=max(sum,sub);
    m=max(m,mul);
    
    cout<<m;
    
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll x[n],y[n];
  for(int i=0;i<n;i++) x[i]=0,y[i]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i]>a[j]){
        x[i]++;
        if(i<j) y[i]++;
      }
    }
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=x[i]; ans%=mod;
  }
  ll t=k*(k-1)/2%mod;
  ans*=t; ans%=mod;
  ll s=0;
  for(int i=0;i<n;i++){
    s+=y[i]; s%=mod;
  }
  cout << (ans+s*k)%mod << endl;
}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

X = NI()

y = math.ceil(math.pow(X/5,1/4))
for i in range(-y,y+1):
    for j in range(-y,y+1):
        if i**5 - j**5 == X:
            print(i,j)
            exit(0)

Measured memory_bytes: 75508
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	ll m,n;
	cin >> m >> n;
	vector<ll> vec(n);
	rep(i,n) cin >> vec[i];
	vector<int> num;
	int tmp;
	rep(i,n){
		tmp = 1;
		while(vec[i] == vec[i+1] && i < n - 1){
			tmp++;
			i++;
		}
		num.pb(tmp);
	}
	ll ans = 0;
	ll sum1 = 0,sum2 = 0;
	if(m > 2){
		rep(i,num.size()){
			ans += num[i]/2;
		}
	}
	else{
		rep(i,n){
			if(i%2 == 0){
				if(vec[i]%2 != 0){
					sum1++;
				}
				else{
					sum2++;
				}
			}
			else{
				if(vec[i]%2 != 1){
					sum1++;
				}
				else{
					sum2++;
				}
			}
		}
		ans = min(sum1,sum2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 1005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int num_rows,num_cols,A,B;

int main(){
	scanf("%d %d %d %d",&num_rows,&num_cols,&A,&B);
	for(int i=1; i<=num_rows-B; i++){
		for(int k=0; k<num_cols-A; k++) printf("1");
		for(int k=0; k<A; k++) printf("0");
		printf("\n");
	}
	for(int i=1; i<=B; i++){
		for(int k=0; k<num_cols-A; k++) printf("0");
		for(int k=0; k<A; k++) printf("1");
		printf("\n");
	}
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=999999+10;
int n,cnt,t;
int pre[maxn],prime[maxn];
int get(int x){
	int l=0,r=t-1,mid;
	while(l<=r){
		mid=(l+r)>>1;
		if(prime[mid]>=x)
			r=mid+1;
		else
			l=mid+1;
	}
	return r;
}
int main(){
	memset(pre,0,sizeof(pre));
	memset(prime,0,sizeof(prime));
	t=1;
	for(int i=2;i<maxn;i++){
		if(!pre[i])
			prime[t++]=i;
		for(int j=1;j<=t&&i*prime[j]<maxn;j++){
			pre[prime[j]*i]=prime[j];
			if(i%prime[j]==0)
				break;
		}
	}
	while(cin>>n){
		int ans=0;
		while(prime[ans]<=n)
			ans++;
		cout<<ans-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 8980
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

ll dp[10101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll h, n;
	cin >> h >> n;
	vector<ll>a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	rep(i, h + 1) {
		dp[i] = INF;
	}
	dp[0] = 0;
	rep(i, n) {
		for (ll j = 0;j < h;++j) {
			ll nj = min(h, a[i] + j);
			dp[nj] = min(dp[nj], dp[j] + b[i]);
		}
	}
	cout << dp[h] << endl;
	return 0;
}


Measured memory_bytes: 3704
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())

    ans = 0
    for k in range(K, N + 2):
        a = k * (k - 1) // 2
        b = k * (2 * N - (k - 1)) // 2
        ans = (ans + (b - a + 1)) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9080
import itertools

N, M, X = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(N)]

ans = -1

for i in range(N):
    for choices in itertools.combinations(range(N), i + 1):
        cost = 0
        a = [0] * M
        for choice in choices:
            cost += books[choice][0]
            for j in range(M):
                a[j] += books[choice][j + 1]

        if min(a) >= X:
            ans = min(cost, ans) if ans >= 0 else cost

print(ans)


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

int main() {
    int num[3], k;
    cin >> num[0] >> num[1] >> num[2] >> k;
    sort(num, num+3);
    for (int i = 0; i < k; i++) {
        num[2] *= 2;
    }
    cout << num[0]+num[1]+num[2] << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

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

  int n; cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  sort(l.begin(), l.end());
  //debug(l);
  int ans = 0;

  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int mx = l[i] + l[j];
      int pos = distance(l.begin(), lower_bound(l.begin(), l.end(), mx));
      ans += pos - j - 1;
    }
  }

/*
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int mn = max(l[i] - l[j], l[j] - l[i]);
      int mx = l[i] + l[j];
      for (int k = 0; k < n; ++k) {
        if (k == i || k == j) continue;
        if (l[k] > mx) break;
        ans += mn <= l[k] && l[k] <= mx;
      }
    }
  }
*/
  cout << ans << endl;

  return 0;
}

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

int main()
{
    ll n,m,i;
    cin>>n>>m;
    ll arr[n];
    ll sum=0;
    for(i=0;i<n;i++) 
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    //for(i=0;i<n;i++) cout<<arr[i]<<" ";
    //cout<<endl;
    long double temp=(sum)/(m*4.0);
    //cout<<temp<<endl;
    ll req=ceil(temp);
    //cout<<req<<endl;
    ll count=0;
    for(i=0;i<n;i++) if(arr[i]>=req) count++;
    if(count>=m) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val M = sc.nextInt()

    type Node = Int
    type Edge = (Node, Int)
    val E = Array.fill[ListBuffer[Edge]](N)(ListBuffer.empty)
    (0 until M) foreach { _ =>
      val l, r = sc.nextInt() - 1
      val d = sc.nextInt()
      E(l) += ((r, d))
      E(r) += ((l, -d))
    }

    val INF = 1000000010
    val d = Array.fill[Int](N)(INF)

    (0 until N) foreach { i =>
      if (d(i) == INF) bfs(E(i))
    }

    type Elm = (Node, Int)
    def bfs(nodes: Seq[Elm]): Unit = {
      val next = mutable.ListBuffer.empty[Elm]
      nodes foreach { case (v, cost0) =>
        if (d(v) == INF) {
          d(v) = cost0
          next ++= E(v) collect {
            case (u, cost) if d(u) == INF => (u, cost + cost0)
          }
        }
      }
      if (next.nonEmpty) bfs(next)
    }

    var valid = true
    (0 until N) foreach { v =>
      E(v) foreach { case (u, cost) =>
        valid &= d(v) + cost == d(u)
      }
    }

    if (valid) println("Yes") else println("No")
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 110984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll i,j,k,n,m,c,t;
    scanf("%lld",&n);
    ll a[n+4];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    } ll g=a[0];
    for(i=1;i<n;i++){
      g=__gcd(g,a[i]);
    } printf("%lld\n",g);
}



Measured memory_bytes: 4568
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Measured memory_bytes: 62204