akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    int a[N];
    REP(i, N) cin >> a[i];
    int res[H][W];
    int x=0, y=0;
    REP(i, N){
        while(a[i]>0){
            res[x][y]=i+1;
            a[i]--;
            if(x%2==0){
                if(y!=W-1){
                    y++;
                }else{
                    x++;
                }
            }else{
                if(y!=0){
                    y--;
                }else{
                    x++;
                }
            }
        }
    }
    REP(i, H){
        REP(j, W){
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= print . solve

solve :: String -> Int
solve = count 0 . reverse . map ((,) <$> head <*> length) . group . edit
    where
        edit ('A' : xs) = 0 : edit xs
        edit ('B' : 'C' : xs) = 1 : edit xs
        edit (_ : xs) = 2 : edit xs
        edit _ = []

        count acc (x@(1, xn) : (0, yn) : zs) = count (acc + yn * xn) $ x : zs
        count acc ((1, xn) : (1, yn) : zs) = count acc $ (1, xn + yn) : zs
        count acc (_ : zs) = count acc zs 
        count acc _ = acc 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
string s1,s2,s3;
int main(){
    cin>>s1>>s2>>s3;

    for(int i=0;i<s1.size();i++){
    	s1[i]=toupper(s1[i]);
    }
    for(int i=0;i<s2.size();i++){
    	s2[i]=toupper(s2[i]);
    }
    for(int i=0;i<s3.size();i++){
    	s3[i]=toupper(s3[i]);
    }
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
    return 0;

}


Measured memory_bytes: 256
s=input()

score=0

for i in range(len(s)):
    for j in range(i,len(s)):
        isbad = 0
        for k in range(i,j+1):
            if s[k] != "A" and s[k] != "C" and s[k] != "G" and s[k] != "T": 
                isbad=1
                break
        if isbad==0:
            score = max(j+1-i,score)
            # print(s[i:j+1])
        
print(score)
        

Measured memory_bytes: 61828
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int cnt=0,t;
	string s,a="keyence";
	cin>>s;
	t=s.size();
	if(a[0]==s[0]&&a[1]==s[t-6]&&a[2]==s[t-5]&&a[3]==s[t-4]&&a[4]==s[t-3]&&a[5]==s[t-2]&&a[6]==s[t-1])
	{
		cout<<"YES"<<endl;
	}
	else
	{
		if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[t-5]&&a[3]==s[t-4]&&a[4]==s[t-3]&&a[5]==s[t-2]&&a[6]==s[t-1])
		{
			cout<<"YES"<<endl;
		}
		else
		{
			if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[2]&&a[3]==s[t-4]&&a[4]==s[t-3]&&a[5]==s[t-2]&&a[6]==s[t-1])
			{
				cout<<"YES"<<endl;
			}
			else
			{
				if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[2]&&a[3]==s[3]&&a[4]==s[t-3]&&a[5]==s[t-2]&&a[6]==s[t-1])
				{
					cout<<"YES"<<endl;
				}
				else
				{
					if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[2]&&a[3]==s[3]&&a[4]==s[4]&&a[5]==s[t-2]&&a[6]==s[t-1])
					{
						cout<<"YES"<<endl;
					}
					else
					{
						if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[2]&&a[3]==s[3]&&a[4]==s[4]&&a[5]==s[5]&&a[6]==s[t-1])
						{
							cout<<"YES"<<endl;
						}
						else
						{
							if(a[0]==s[0]&&a[1]==s[1]&&a[2]==s[2]&&a[3]==s[3]&&a[4]==s[4]&&a[5]==s[5]&&a[6]==s[6])
							{
								cout<<"YES"<<endl;
							}
							else
							{
								cout<<"NO"<<endl;
							}
						}
					}
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll n;

string numToAlphabet(ll n) {
  if (n == 1) {
    return "a";
  } else if (n == 2) {
    return "b";
  } else if (n == 3) {
    return "c";
  } else if (n == 4) {
    return "d";
  } else if (n == 5) {
    return "e";
  } else if (n == 6) {
    return "f";
  } else if (n == 7) {
    return "g";
  } else if (n == 8) {
    return "h";
  } else if (n == 9) {
    return "i";
  } else if (n == 10) {
    return "j";
  } else if (n == 11) {
    return "k";
  } else if (n == 12) {
    return "l";
  } else if (n == 13) {
    return "m";
  } else if (n == 14) {
    return "n";
  } else if (n == 15) {
    return "o";
  } else if (n == 16) {
    return "p";
  } else if (n == 17) {
    return "q";
  } else if (n == 18) {
    return "r";
  } else if (n == 19) {
    return "s";
  } else if (n == 20) {
    return "t";
  } else if (n == 21) {
    return "u";
  } else if (n == 22) {
    return "v";
  } else if (n == 23) {
    return "w";
  } else if (n == 24) {
    return "x";
  } else if (n == 25) {
    return "y";
  } else if (n == 26) {
    return "z";
  }
  cout << "error" << endl;
  return "error";
}

void input() { cin >> n; }

void solve() {
  string ans = "";
  while (n >= 26) {
    if (n % 26 != 0) {
      ans = numToAlphabet(n % 26) + ans;
      n /= 26;
    } else {
      ans = "z" + ans;
      n = n / 26 - 1;
    }
  }
  if (n != 0) { ans = numToAlphabet(n) + ans; }
  cout << ans << endl;
}

int main() {
  input();
  solve();
  return 0;
}


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

int main()
{
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x.at(i).at(j);
    }
  }
  int s = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int d2 = 0;
      for (int k = 0; k < d; k++) {
        int dx = x.at(i).at(k) - x.at(j).at(k);
        d2 += dx * dx;
      }
      int d = sqrt(d2) + 0.5;
      if (d * d == d2) {
        s++;
      }
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#define MAXX 200
#define ll long long
using namespace std;

int main() {
    string tS;
    cin>>tS;
    
    int ans = 10000000;
    
    for(int c=0;c<26;c++) {
        
        string S=tS;
        
        
        while(1) {
            bool ok=true;
            for(int j=0;j<S.size();j++)
                if (S[j] != S[0])
                    ok=false;
            if (ok)
                break;
            string nS;
            for(int j=0;j<S.size()-1;j++) {
                // S[j] or S[j+1]
                if (S[j]==c+'a' || S[j+1]==c+'a')
                    nS.push_back(c+'a');
                else
                    nS.push_back(S[j]);
            }
            S=nS;
            

        }
        

        ans = min(ans, (int)tS.size()-(int)S.size());
        
    }
    
    cout << ans << endl;
    
    
}

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;

const int INF = 100000;

int main() {
    ll N, A[200000] = {};
    cin >> N;
    for (int i = 1; i < N; ++i) {
        cin >> A[i];
    }

    ll cnt[200001] = {};
    for (int i = 1; i < N; ++i) {
        cnt[A[i]]++;
    }

    for (int i = 1; i < N+1; ++i) {
        cout << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,Z,W;
    cin >> N >> Z >> W;
    lint A[N];
    rep(i,N) cin >> A[i];
    if(N==1){
        cout << llabs(A[0]-W) << endl;
        return 0;
    }
    lint ans=llabs(A[N-1]-W);
    ans=max(ans,llabs(A[N-2]-A[N-1]));
    cout << ans << endl;
}

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

namespace ABC171B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            int N = int.Parse(NK[0]);
            int K = int.Parse(NK[1]);
            string[] input = Console.ReadLine().Split(' ');
            int[] p = new int[N];
            for (int i = 0; i < N; i++)
            {
                p[i] = int.Parse(input[i]);
            }
            Array.Sort(p);
            int ans = 0;
            for (int i = 0; i < K; i++)
            {
                ans += p[i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27880
#include<stdio.h>
int main(void)
{
	int i,n,a,b,x,y;
	scanf("%d",&n);
	while(n!=0) {
		x=0;
		y=0;
		for(i=1;i<=n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b) {
				x=x+a+b;
			}
			else if(a<b) {
				y=y+a+b;
			}
			else {
				x=x+a;
				y=y+b;
			}
		}
		printf("%d %d\n",x,y);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
def cc095():
    a,b,c,x,y = list(map(int, input().split()))

    prs = [a*x + b*y] # ストレートに購入
    # aを基準にc
    ac = x*2*c
    if y > x:
        z = y - x
        ac += min([b*z, z*2*c])
    prs.append(ac)

    # bを基準にc
    bc = y*2*c
    if x > y:
        z = x - y
        bc += min([a*z, z*2*c])
    prs.append(bc)

    print(min(prs))

cc095()


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

int main() {
    long long N,K;
    cin >> N>>K;
    long long ans=0;
    for(long long i=K;i<N+2;i++){
        long long a=(N-i)*i+i+1;
        ans += a;
        ans = ans%1000000007;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3564
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

#t = [int(input()) for i in range(d)]

ans = []
last = [[0 for i in range(26)] for j in range(26)]

for i in range(1,d+1):
    tmp_ans = [0]*26
    for j in range(26):
        tmp_ans[j] += s[i-1][j]
        last[j][j] = i
        for k in range(26):
            tmp_ans[j] -= (i-last[j][k])*c[k]
    idx = tmp_ans.index(max(tmp_ans))
    for j in range(26):
        for k in range(26):
            last[k][j] = last[idx][j]
    print(idx+1)
    #print(tmp_ans)
#print(ans)
    """
            
    ans += s[i-1][t[i-1]-1]
    last[t[i-1]-1] = i
    for j in range(26):
        ans -= (i-last[j])*c[j]
    print(ans)
    """
    


Measured memory_bytes: 68944
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(input().split())
    return li

# --------------------------------------------

dp = None

def main():
    N = input()

    if N.count("9") >= 1:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 5184
N = int(input())
masu1 = list(map(int,input().split()))
masu2 = list(map(int,input().split()))
masu = list()
leng = N*2
masu.extend(masu1)
masu.extend(masu2)
if(N == 1):
    print(masu[0]+masu[1])
else:
    sum_masu = [0]*leng
    sum_masu[0] = masu[0]
    for i in range(1,leng):
        sum_masu[i] = masu[i]+sum_masu[i-1]
    Max_num = 0
    for i in range(1,N):
        now_num = sum_masu[-1]-sum_masu[i+N-2]+sum_masu[i-1]
        # print(sum_masu[-1],"-",sum_masu[i+N-2],"+",sum_masu[i-1])
        if(Max_num < now_num):
            Max_num = now_num

    print(Max_num)

Measured memory_bytes: 3064
n,t=map(int,input().split())
ts= list(input().split())
ts = [int(i) for i in ts]

ans=0
flag=False
for i in range(0,len(ts)):
  #print(ts[i],flag)
  if flag:
    if ts[i]-ts[i-1] <= t:
      ans+=ts[i]-ts[i-1]
    else:  
      ans+=t
  else:
    if ts[i]<=t and i!=len(ts)-1:
      ans=ts[i+1]
    else:
      if ts[i]-ts[i-1] <= t:
        ans=ts[i]
        
      else:  
        ans=ts[i-1]+t
        flag=True
  #print("ans",ans)

print(ans+t)

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool flag = false;
    for (int i = 0; i < B; i++) {
        if ((A * i) % B == C) {
            flag = true;
        }
    }

    if (flag) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import copy

N = int(input())
A = list(input().split())

def is_stable(sorted_list):
    for i in range(len(sorted_list)-1):
        if sorted_list[i][1] == sorted_list[i+1][1]:
            for j in range(len(A)):
                if A[j] == sorted_list[i]:
                    smaller_idx = j
                if A[j] == sorted_list[i+1]:
                    larger_idx = j
            if smaller_idx > larger_idx:
                return False
    return True

def print_stable_or_not(is_stable):
    if is_stable:
        print("Stable")
    else:
        print("Not stable")

def bubble_sort(A1):
    flg = True
    while flg:
        for i in range(N):
            flg = False
            for j in range(N-1, i, -1):
                if int(A1[j-1][1]) > int(A1[j][1]):
                    A1[j-1], A1[j] = A1[j], A1[j-1]
                    flg = True
    print(" ".join(A1))
    print_stable_or_not(is_stable(A1))

def insertion_sort(A2):
    for i in range(N-1):
        min_idx = i
        for j in range(i+1, N):
            if int(A2[min_idx][1]) > int(A2[j][1]):
                min_idx = j
        if min_idx != i:
            A2[i], A2[min_idx] = A2[min_idx], A2[i]
    print(" ".join(A2))
    print_stable_or_not(is_stable(A2))

if __name__ == '__main__':
    A1 = copy.deepcopy(A)
    A2 = copy.deepcopy(A)
    bubble_sort(A1)
    insertion_sort(A2)


Measured memory_bytes: 6344
#include<iostream>
using namespace std;
int main() {
    while (true)
    {
        int a, b;
        char op;
        cin >> a >> op >> b;
        if (op == '+')
        {
            cout << a + b << endl;
        }
        else if (op == '-')
        {
            cout << a - b << endl;
        }
        else if (op == '*')
        {
            cout << a * b << endl;
        }
        else if (op == '/')
        {
            cout << a / b << endl;
        }
        else
        {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    ll k; cin >> k;
    ll tmp = 0;
    for(int i = 0; i < k+1; i++){
        tmp = tmp*10 + 7;
        tmp %= k;
        if(tmp == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3624
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a == b && b==c) {
			out.println("Yes");

		}else {
			out.println("No");
		}

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    int k[1001];
    int s[10][101];
    int p[101];
    map<string, int> num;
    int swch[11][11] = {};
    long long int ans = 0;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            swch[i][s[i][j]] = 1;
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    for (int i = 0; i < m; i++) {
        for (int bit = 0; bit < (1<<n); ++bit) {
            string a;
            int cnt = 0;

            for (int j = 0; j < n; j++) {
                if (bit & (1<<j)) {
                    a += to_string(1);
                    if (swch[i][j+1] == 1) {
                        cnt++;
                    }
                }
                else {
                    a += to_string(0);
                }
            }
            if (p[i] == cnt%2 && num[a] != -1) {
                num[a] = 1;
            }
            else {
                num[a] = -1;
            }
        }
    }

    for (auto x: num) {
        if (x.second == 1) {
            ans++;
        }
    }

    cout << ans << endl;

}


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

using namespace std;

string nodeInfo[] = { "root", "internal node", "leaf" };

struct Node {
    int id;
    int parent;
    int sibling;
    int degree;
    int depth;
    int height;
    int status;
    int left;
    int right;
} tree[25];

int treeRecur(int u, int d) {
    tree[u].depth = d;
    tree[u].status = 1;
    int l = 0, r = 0;
    if (tree[u].left >= 0) {
        l = treeRecur(tree[u].left, d + 1);
    }
    if (tree[u].right >= 0) {
        r = treeRecur(tree[u].right, d + 1);
    }
    tree[u].height = max(l, r);
    if (tree[u].height == 0)
        tree[u].status = 2;
    return tree[u].height + 1;
}

void treeBuild(int n) {
    int root;
    for (int i = 0; i < n; ++i) {
        if (tree[i].parent == -1) {
            root = i;
            break;
        }
    }
    treeRecur(root, 0);
    tree[root].status = 0;
}

int main() {
    int n, id, l, r;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        tree[i].parent = -1;
        tree[i].sibling = -1;
        tree[i].degree = 0;
    }
    for (int i = 0; i < n; ++i) {
        cin >> id >> l >> r;
        tree[id].id = id;
        tree[id].left = l;
        tree[id].right = r;
        if (l >= 0) {
            tree[id].degree++;
            tree[l].parent = id;
            tree[l].sibling = r;
        }
        if (r >= 0) {
            tree[id].degree++;
            tree[r].parent = id;
            tree[r].sibling = l;
        }
    }

    treeBuild(n);
    int suf[100000];
    for (int i = 0; i < n; ++i) {
        suf[tree[i].id] = i;
    }
    for (int i = 0; i < n; ++i) {
        int s = suf[i];
        cout << "node " << tree[s].id;
        cout << ": parent = " << tree[s].parent;
        cout << ", sibling = " << tree[s].sibling;
        cout << ", degree = " << tree[s].degree;
        cout << ", depth = " << tree[s].depth;
        cout << ", height = " << tree[s].height;
        cout << ", " << nodeInfo[tree[s].status] << endl;
    }

    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (a - 1) * (b - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
<?php
# 整数の入力
// fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d %d", $n, $x, $t);
# 文字列の入力
for ($i = 0; $n > $x * $i; $i++) {
}
// fscanf(STDIN, "%s", $s);
# 出力
echo $i * $t . "\n";


Measured memory_bytes: 16048
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}

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

  int n; cin >> n;
  vector<int> a(100010);
  rep(i, n) cin >> a[i];

  // 累積GCD
  vector<int> l(100010);
  l[0] = a[0];
  for(int i = 1; i < n; ++i) l[i] = gcd(l[i-1], a[i]);
  vector<int> r(100010);
  r[n-1] = a[n-1];
  for(int i = n-2; i > 0; --i) r[i] = gcd(r[i+1], a[i]);

  int ans = 0;
  rep(i, n) ans = max(ans, gcd(l[i-1], r[i+1]));

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1408
N=int(input())
A=list(map(int,input().split()))
visited=[False for i in range(10**6+1)]
ban=[False for i in range(10**6+1)]
from collections import Counter
A.sort()
D=dict(Counter(A))
for n in A:
    if visited[n]==False:
        visited[n]=True
        for j in range(2,10**6):
            if 10**6<n*j:
                break 
            ban[n*j]=True
ans=0
for n in A:
    if D[n]==1 and ban[n]==False:
        ans+=1
print(ans)



Measured memory_bytes: 170256
#include<stdio.h>
main(){
  char kata[2];
  int a=0,b=0,o=0,ab=0;
  int bang,i;
  while(scanf("%d,%s",&bang,&kata)!=EOF){
    if(kata[0]=='A'&& kata[1]=='B') ab++;
    else if(kata[0]=='B') b++;
    else if(kata[0]=='O') o++;
    else if(kata[0]=='A') a++;
    kata[0]=0;
    kata[1]=0;
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}
  

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    string s; cin >> s;
    vint r(n), g(n), b(n);
    if(s[0] == 'R') r[0]++;
    else if(s[0] == 'G') g[0]++;
    else b[0]++;
    rep(i, n - 1) {
        r[i + 1] = r[i];
        g[i + 1] = g[i];
        b[i + 1] = b[i];
        if(s[i] == 'R') {
            r[i + 1]++;
        } else if(s[i] == 'G') {
            g[i + 1]++;
        } else {
            b[i + 1]++;
        }
    }
    /*rfor(x, r) cout << x << " ";
    cout << endl;
    rfor(x, g) cout << x << " ";
    cout << endl;
    rfor(x, b) cout << x << " ";
    cout << endl;*/
    
    ll ans = 0;
    rep(i, n - 2) {
        repi(k, i + 2, n) {
            if(s[i] == s[k]) continue;
            int d = k - i - 1, j = (k + i) / 2;
            int res;
            if('R' != s[i] && 'R' != s[k]) {
                res = r[k] - r[i];
                if(res == 0) continue;
                if(s[j] == 'R' && j - i == k - j) res--;
            } else if('G' != s[i] && 'G' != s[k]) {
                res = g[k] - g[i];
                if(res == 0) continue;
                if(s[j] == 'G' && j - i == k - j) res--;
            } else {
                res = b[k] - b[i];
                if(res == 0) continue;
                if(s[j] == 'B' && j - i == k - j) res--;
            }
            //cout << i << ", " << k << ", " << res << endl;
            ans += res;
        }
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author berat
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BeyzasVacation solver = new BeyzasVacation();
        solver.solve(1, in, out);
        out.close();
    }

    static class BeyzasVacation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            boolean[] visited = new boolean[n];
            boolean found = false;

            for (int i = 0; i < m; i++) {
                int from = in.nextInt();
                int to = in.nextInt();
                if (from == 1) {
                    if (visited[to]) {
                        found = true;
                        break;
                    }
                    visited[to] = true;
                } else if (to == n) {
                    if (visited[from]) {
                        found = true;
                        break;
                    }
                    visited[from] = true;
                }
            }
            out.println(found ? "POSSIBLE" : "IMPOSSIBLE");
        }

    }
}



Measured memory_bytes: 49784
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
ll n,k;
ll h[200000];
ll dp[200000];

ll solve(ll idx)
{
	if(idx>=n) return 0;
	else if(dp[idx]!=-1)return dp[idx];
	
	//if(idx==n-1) return solve(idx+1)+h[idx+]

	ll mi = LLONG_MAX;
	for(int i = 1;i<=k;i++)
	{
		if(idx+i<=n)
			mi =min(mi,solve(idx+i)+abs(h[idx+i]-h[idx]));
	}
//	cout << mi << " ";
	return dp[idx] = mi;

}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i = 1;i<=n;i++) cin >> h[i];	
	for(int i =0;i<200000;i++) dp[i]=-1;
	cout << solve(1) << endl;
//	cout << dp[n-1] << endl;
	return 0;
}


//Hello, this is a snippet.


Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;

void solve() {
	string s;
	cin >> s;
	const char* ans = (s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No";
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1<<14,mo=998244353;
int lgM=14,M=1<<lgM;
int r[N];
ll a[N],b[N],w[N],jc[N],ny[N],c[N];
int n,m;
ll power(ll a,ll b=mo-2){
	ll ans=1;
	while (b){
		if (b&1)ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}return ans;
}
void prep(){
	w[0]=1;
	w[1]=power(3,(mo-1)/M);
	for (int i=2;i<M;i++)w[i]=w[i-1]*w[1]%mo;
	jc[0]=ny[0]=1;
	for (int i=1;i<M;i++)jc[i]=jc[i-1]*i%mo;
	ny[M-1]=power(jc[M-1]);
	for (int i=M-1;i;i--)ny[i-1]=ny[i]*i%mo;
}
void dft(ll *a){
	for (int i=1;i<M;i++){
		r[i]=(r[i>>1]>>1)+(i&1)*(M>>1);
		if (r[i]<i)swap(a[i],a[r[i]]);
	}
	for (int n=1,ax=lgM-1;n<M;n<<=1,ax--){
		for (int i=n;i<M;i=(i+1)|n){
			ll A=a[i]*w[(i&(n-1))<<ax]%mo;
			a[i]=(a[i^n]-A+mo)%mo;
			a[i^n]=(a[i^n]+A)%mo;
		}
	}
}
void idft(ll *a){
	for (int i=1,j=M-1;i<j;i++,j--)swap(a[i],a[j]);
	dft(a);
	ll ny=power(M);
	for (int i=0;i<M;i++)a[i]=a[i]*ny%mo;
}
int main(){
	cin>>n>>m;
	prep();
	a[0]=1;
	for (int i=0;i<=n;i++)b[i]=ny[i+2];
	dft(b);
	for (int i=1;i<=m;i++){
		for (int i=n+1;i<M;i++)a[i]=0;
		for (int i=0;i<=n;i++)c[i]=a[i],a[i]=a[i]*ny[i];
		dft(a);
		for (int i=0;i<M;i++)a[i]=a[i]*b[i]%mo;
		idft(a);
		for (int i=0;i<=n;i++)a[i]=(a[i]*jc[i+2]%mo+c[i]*(mo-i))%mo;
	}
	ll ans=0;
	for (int i=0;i<=n;i++)ans=(ans+ny[i]*ny[n-i]%mo*jc[n]%mo*a[i])%mo;
	cout<<ans<<endl; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y)
{
    if(x==n+1)
    {
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x; i<=n; i++)
    {
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    map<ll,ll>mp;
    set<ll>s;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        s.insert(x);
        mp[x]++;
    }
    ll sum=0;
    for(auto x: s){
        if(x==mp[x])continue;
        else if(x>mp[x]) sum+=mp[x];
        else if(x<mp[x])sum+=(mp[x]-x);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 14156
#include <stdio.h>

int main(){
    char array[1000];
    int i;
    scanf("%s",&array);
    for (i=0;array[i];i++) {
        if (array[i]=='D') printf("A");
        if (array[i]=='E') printf("B");
        if (array[i]=='F') printf("C");
        if (array[i]=='G') printf("D");
        if (array[i]=='H') printf("E");
        if (array[i]=='I') printf("F");
        if (array[i]=='J') printf("G");
        if (array[i]=='K') printf("H");
        if (array[i]=='L') printf("I");
        if (array[i]=='M') printf("J");
        if (array[i]=='N') printf("K");
        if (array[i]=='O') printf("L");
        if (array[i]=='P') printf("M");
        if (array[i]=='Q') printf("N");
        if (array[i]=='R') printf("O");
        if (array[i]=='S') printf("P");
        if (array[i]=='T') printf("Q");
        if (array[i]=='U') printf("R");
        if (array[i]=='V') printf("S");
        if (array[i]=='W') printf("T");
        if (array[i]=='X') printf("U");
        if (array[i]=='Y') printf("V");
        if (array[i]=='Z') printf("W");
        if (array[i]=='A') printf("X");
        if (array[i]=='B') printf("Y");
        if (array[i]=='C') printf("Z");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<string> vec(n);
  vector<pair<ll,ll>> vec_pl,vec_mi;
  string str;
  rep(i,n){
    cin >> vec[i];
  }
  bool can = true;
  ll sum = 0;
  rep(i,n){
    str = vec[i];
    ull len = str.size();
    ll piv = 0;
    t1 = 0;
    rep(j,len){
      if(str[j] == '('){
        piv++;
      }else{
        piv--;
      }
    }
    sum += piv;
    if(piv >= 0){
      piv = 0;
      rep(j,len){
        if(str[j] == '('){
          piv++;
        }else{
          piv--;
        }
        chmin(t1,piv);
      }
      vec_pl.emplace_back(make_pair(t1,piv));
    }else{
      piv = 0;
      rep_rev(j,len){
        if(str[j] == ')'){
          piv++;
        }else{
          piv--;
        }
        chmin(t1,piv);
      }
      vec_mi.emplace_back(make_pair(t1,piv));
    }
  }
  if(sum != 0){
    can = false;
  }
  ll st = 0;
  sort(all(vec_pl),greater<>());
  sort(all(vec_mi),greater<>());
  ull len1 = vec_pl.size(),len2 = vec_mi.size();
  rep(i,len1){
    //cout << vec_pl[i].first << " " << vec_pl[i].second << endl;
    if(vec_pl[i].first + st < 0){
      can = false;
    }
    st += vec_pl[i].second;
    if(st < 0){
      can = false;
    }
  }
  st = 0;
  rep(i,len2){
    //cout << vec_mi[i].first << " " << vec_mi[i].second << endl;
    if(vec_mi[i].first + st < 0){
      can = false;
    }
    st += vec_mi[i].second;
    if(st < 0){
      can = false;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 50356
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

using Pair = pair<LL, int>;

int N;
LL A[114514];
LL ans[114514];
priority_queue<Pair> que;

int main() {
  scanf("%d", &N);

  LL res = 0;
  rep(i, N) {
    scanf("%lld", &A[i]);
    que.push(Pair(A[i], -i));
    res += A[i];
  }

  LL M = que.top().first;
  int midx = -que.top().second;
  que.pop();
  LL tot = M;
  int cnt = 1;
  while (!que.empty() && midx != 0) {
    Pair p = que.top(); que.pop();
    int idx = -p.second;
    if (idx < midx) {
      M = p.first;
      ans[midx] = tot- M*cnt;
      //printf("idx: %d, new M: %lld, tot: %lld, ans[midx:%d]: %lld\n", idx, M, tot, midx, ans[midx]);
      res -= ans[midx];
      cnt++;
      tot = M*cnt;
      midx = idx;
      continue;
    } else {
      tot += p.first;
      cnt++;
    }
  }
  ans[0] = res;
  
  rep(i, N) {
    printf("%lld\n", ans[i]);
  }
}


Measured memory_bytes: 4336
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int n, k;
	vector<int> p;

	cin >> n >> k;

	p.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> p[i];
	}

	double em = 0.0;
	double prev = 0.0;
	for(int i = 0; i < k; i++) {
		em += (p[i] + 1.0) / 2.0;
	}
	prev = em;
	for(int i = 1; i < n-k+1; i++) {
		prev = prev - (p[i-1] + 1.0) / 2.0 + (p[i+k-1] + 1.0) / 2.0;
		em = max(em, prev);
	}

	cout << fixed << setprecision(10) << em;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <iomanip> 
using namespace std;
int main(void){
    const double PI=3.14159265358979323846;
    int A, B, H, M;
    cin >> A;cin >> B; cin >> H; cin >> M;
    
    float angle_h, angle_m, angle;
    angle_m = M * 6;
    angle_h = H * 30 + M * 0.5;
    angle = abs(angle_m - angle_h);
    
    double answer, deg_r;
    deg_r = angle * PI / 180.0;
    answer = A * A + B * B - 2 * A * B * cos (deg_r);
    answer = sqrt(answer);
    cout << fixed << setprecision(10)<< answer << endl;
    
}


Measured memory_bytes: 4180
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;

const int MOD = 998244353;
const int INF = 2e9;
const int MAX_N = 300000;

ll factorial[MAX_N+1];
ll inverse[MAX_N+1];
 
// 繰り返し２乗法による冪乗(x^n)計算 O(log(n))
int exponentiation(ll x, int n) {
  int res = 1;
  while (0 < n) {
    if (n & 1) {
      res = x * res % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
 
// 組み合わせ nCr の計算 O(1)
ll combination(int n, int r) {
  if (n-r==0 || r==0) return 1;
  static bool flag = true;
  if (flag) {
    // 階乗と階乗の逆数の初期化 O(n)
    factorial[0] = 1; inverse[0] = 1;
    for (int i=1; i<=MAX_N; i++) {
      factorial[i] = factorial[i-1] * i % MOD;
      inverse[i] = exponentiation(factorial[i], MOD-2);
    }
    flag = false;
  }
  return factorial[n] * inverse[n-r] % MOD * inverse[r] % MOD;
}

int main() {
  ll N, A, B, K, ans = 0;
  vii XYs;
  cin >> N >> A >> B >> K;
  for (int x = 0; x <= N; x++) {
    if (A * x > K) { break; }
    if ((K - A*x) % B != 0) { continue; }

    ll y = (K - A*x) / B;
    if (y <= N) {
      // cout << x << ", " << y << endl;
      ans += (combination(N, x) % MOD) * (combination(N, y) % MOD);
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

import javax.naming.InitialContext;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();

		System.out.println((a + b) * h / 2);

	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 10068
m,n,T,C[10][2],c,d,O[10][2],t,s,u,v,o,h,f;
D(h){
	if(C[s][h]&&T>=O[s][h]){
		f=printf(" %d"+!f,C[s][h]);
		C[s][h]=0;
		c--;
	}
}
main(){
	for(;scanf("%d%d",&m,&n),m;){
		memset(C,T=c=d=f=0,sizeof(C));
		for(;d<n||c;T++){
			for(s=m;s--;){
			//for(s=0;s<m;s++){
				D(1);
				C[s][1]||D(0);
			}
			for(;T>=d*10&d<n&c<m*2;){
				h=scanf("%d",&t);
				u=v=-1;
				for(s=m;h&&s--;){
				//for(s=0;h&s<m;s++){
					if(!C[s][0]){
						u=s;
						h=0;
					}else if(!C[s][1]){
						o=O[s][0]-(T+t);
						o<0?
							!~v||o>O[v][0]-T-t?v=s:0:
							!~u||o<O[u][0]-T-t?u=s:0;
					}
				}
				s=~u?u:v;
				C[s][h]=++d;
				O[s][h]=T+t;
				c++;
			}
		}
		puts("");
	}
	exit(0);
}

Measured memory_bytes: 0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import deque


MOD = 1000000007 


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

dp = [1 for _ in range(N+1)]
for a in An:
  dp[a] = 0


for i in range(2,N+1):
  if dp[i] > 0:
    dp[i] = (dp[i-1]+dp[i-2]) % MOD
print(dp[N])

Measured memory_bytes: 8184
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
    return 0;
}



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

using namespace std;
typedef pair<int, int> P;
typedef vector<P> pairs;

int main(){
    int N, M, a, b, x, ans = 0;
    pairs vi;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        vi.push_back(make_pair(a,b));
    }
    sort(vi.begin(), vi.end(), greater<P>());

    x = vi[0].first + 1;
    ans++;
    for(int i = 0; i < M; i++){
        if(vi[i].first <= x && vi[i].second >= x){
            continue;
        }else{
            // cout << vi[i].first << vi[i].second << endl;
            // cout << "x: " << x << endl;
            x = vi[i].first + 1;
            ans++;
        }
    }
    cout << ans<< endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}
void merge(int arr[],int a[],int l, int m, int r)
{
	int i, j, k;
	int n1 = m - l + 1;
	int n2 = r - m;

	/* create temp arrays */
	int L[n1],R[n2],LL[n1],RR[n2];

	/* Copy data to temp arrays L[] and R[] */
	for (i = 0; i < n1; i++)
	{
		L[i] = arr[l + i];
		LL[i]=a[l+i];
	}
	for (j = 0; j < n2; j++)
	{
		R[j] = arr[m + 1+ j];
		RR[j]=a[m+1+j];
	}
	/* Merge the temp arrays back into arr[l..r]*/
	i = 0; // Initial index of first subarray
	j = 0; // Initial index of second subarray
	k = l; // Initial index of merged subarray
	while (i < n1 && j < n2)
	{
		if (L[i] <= R[j])
		{
			arr[k] = L[i];
			a[k]=LL[i];
			i++;
		}
		else
		{
			arr[k] = R[j];
			a[k]=RR[j];
			j++;
		}
		k++;
	}

	/* Copy the remaining elements of L[], if there
	are any */
	while (i < n1)
	{
		arr[k] = L[i];
		a[k]=LL[i];
		i++;
		k++;
	}

	/* Copy the remaining elements of R[], if there
	are any */
	while (j < n2)
	{
		arr[k] = R[j];
		a[k]=RR[j];
		j++;
		k++;
	}
}

/* l is for left index and r is right index of the
sub-array of arr to be sorted */
void mergeSort(int arr[],int a[],int l, int r)
{
	if (l < r)
	{
		// Same as (l+r)/2, but avoids overflow for
		// large l and h
		int m = l+(r-l)/2;

		// Sort first and second halves
		mergeSort(arr,a,l, m);
		mergeSort(arr,a, m+1, r);

		merge(arr,a,l, m, r);
	}
}
int prime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        int k,n;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        int ans=0;
        for(int i=0;i<k;i++)
            {
                ans+=a[i];
            }
        cout<<ans;
}


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

def main():
    N = int(input())
    ta = [list(map(int, input().split())) for i in range(N)]

    a, b = 1, 1
    for i in range(N):
        x, y = ta[i]
        if a%x == 0:
            tmp = a//x
        else:
            tmp = a//x + 1
        if b%y == 0:
            tmp = max(tmp, b//y)
        else:
            tmp = max(tmp, b//y + 1)
        a = x * tmp
        b = y * tmp
    print(a+b)

if __name__ == "__main__":
    main()

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

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

if(a<40)
 a = 40;

if(b<40)
 b = 40;

if(c<40)
 c = 40;

if(d<40)
 d = 40;

if(e<40)
 e = 40;


cout<<(a+b+c+d+e)/5<<'\n';
 
return 0;
}

Measured memory_bytes: 1160
//
//  main.cpp
//  ABC152A
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {

    int N,M;
    cin>>N>>M;
    if(N==M){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll now=A[0];
  for(int i=0;i<n-1;i++){
    if(i%2==0){
      now-=A[i+1];
    }else{
      now+=A[i+1];
    }
  }
  cout<<now<<" ";
  for(int i=1;i<n;i++){
    now = 2*(A[i-1]-now/2);
    cout<<now<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin>>N;
  int b,min=1<<30;
  for(int a=1;a<N;a++){
    int t=a,u=N-a,suma=0,sumb=0;
    while(t!=0||u!=0){
      suma+=t%10;
      t/=10;
      sumb+=u%10;
      u/=10;
    }
    
    if(min>suma+sumb){
      min=suma+sumb;
    }


  }
  printf("%d",min);
}

Measured memory_bytes: 256