akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	seq := make([]int, 360)
	N := io.NextInt()
	for i := 0; i < N; i++ {
		M, D, V, S := io.NextInt(), io.NextInt(), io.NextInt(), io.NextInt()
		M = (M - 1) * 30
		D--
		for j := M + D; j < M+D+V; j++ {
			seq[j%360] = intMax(S, seq[j%360])
		}
		for j := 0; j < S; j++ {
			seq[(M+D-j+360)%360] = intMax(S-j, seq[(M+D-j+360)%360])
			seq[(M+D+V+j-1)%360] = intMax(S-j, seq[(M+D+V+j-1)%360])
		}
	}
	ans := 360
	for _, val := range seq {
		ans = intMin(val, ans)
	}
	io.Println(ans)
}

func intMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 1116
N = int(input())
A = list(map(int,input().split()))
odd, nibai, yonbai = 0, 0, 0

for i in range(N):
    if A[i] % 2 != 0:
        odd += 1
    elif A[i] % 4 == 0:
        yonbai += 1
    else:
        nibai += 1

if nibai == 0:
    if odd > yonbai+1:
        print('No')
    else:
        print('Yes')
else:
    if odd > yonbai:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 14228
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000
#define pll pair<ll, ll>

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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    vector<ll> nums = {A, B, C};
    if (abs(A - B) > (ll)pow(10, 18))
        cout << "Unfair" << endl;
    else {
        if (K % 2 == 1)
            cout << B - A << endl;
        else
            cout << A - B << endl;
    }
}

Measured memory_bytes: 3596
import sys
import math
input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(x):
    res = 0
    for i in a:
        res += math.floor(i / x)
    return res

l = 0
r = 10 ** 9 + 1
for _ in range(100):
    x = (l + r) / 2
    if check(x) > k:
        l = x
    else:
        r = x
print(math.ceil(l))


Measured memory_bytes: 92008
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll int
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


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

    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,sum=0;
    string str2,str1;
    int hoge=0;
    cin>>n>>m;
    string s1[n];
    string s2[m];
    rep(i,n) cin>>s1[i];
    rep(i,m) cin>>s2[i];
    for(ll i=0;i<=n-m;i++){
        for(ll j=0;j<=n-m;j++){
            f=0;
            for(ll k=0;k<m;k++){
                for(ll l=0;l<m;l++){
                    if(s1[i+k][j+l]!=s2[k][l])f=1;
                }
            }
            if(!f){
                Yes;
                return 0;
            }
        }
    }
No;


    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;
long long n;
int main()
{
    cin>>n;
    long long minn=(1LL<<62);
    for(long long i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i+n/i-2<minn) minn=i+n/i-2;
        }
    }
    cout<<minn;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	double r;
	cin>>r;
	cout<<3*r*r<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a = int(input())
    b = int(input())
    print(*(set([1, 2, 3]) - set([a]) - set([b])))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL INF=9e18;

map<LL,LL> m;
LL A[3], D;
LL p[3]={2,3,5};

void dfs(LL N, LL cost){
	if(m[N]!=0 and m[N]<=cost) return;
	m[N]=cost;
	if(N<LL(9e9)) m[0]=min(m[0],cost+D*N);
	if(N==0) return;
	LL n_min[3], n_max[3];
	rep(i,3) n_min[i]=N/p[i], n_max[i]=(N+p[i]-1)/p[i];
	rep(i,3) dfs(n_min[i],cost+A[i]+D*(N-n_min[i]*p[i]));
	rep(i,3) dfs(n_max[i],cost+A[i]+D*(n_max[i]*p[i]-N));
}

int main(){
	int T;
	cin >> T;
	while(T--){
		m.clear();
		LL N;
		cin >> N >> A[0] >> A[1] >> A[2] >> D;
		m[0]=INF;
		dfs(N,0);
		cout << m[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 4420
#include<stdio.h>
#define MAX 250

typedef struct Node {
    int key;
    Node *parent, *left, *right;
} Node;

Node *NIL, T[MAX];

void print(int n) {
    int i;
    Node *N;
    for (i=1; i<=n; i++) {
        N = &T[i];
        printf("node %d: key = %d, ", i, N->key);
        if (N->parent!=NIL) printf("parent key = %d, ", N->parent->key);
        if (N->left!=NIL) printf("left key = %d, ", N->left->key);
        if (N->right!=NIL) printf("right key = %d, ", N->right->key);
        printf("\n");
    }
}

void fill(int i, int k) {
    if (i==1) {
        T[i].key=k;
    } else {
        T[i].key=k;
        T[i].parent=&T[i/2];
        if (i%2==0) T[i/2].left=&T[i];
        else T[i/2].right=&T[i];
    }
}

int main() {
    int n, i, k;
    for (i=0; i<MAX; i++) {
        T[i].parent=T[i].left=T[i].right=NIL;
        T[i].key=0;
    }

    scanf("%d", &n);
    for (i=1; i<=n; i++) {
        scanf("%d", &k);
        fill(i, k);
    }
    
    print(n);

    return 0;
}


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

int selectSort(int A[], int N) {
	int minj, counter, temp;
	counter = 0;
	for (int j = 0 ; j < N-1; j++) {
	minj = j;
		for (int i = j + 1; i < N; i++) {
			if (A[i] < A[minj]) {
				minj = i;	
			}
		}
		if (minj != j) {
			temp = A[j];
			A[j] = A[minj];
			A[minj] = temp;
			counter++;
		} else {
			continue;
		}
		
	}
	return counter;
}


int main() {
	int N, counter, A[100];
	
	cin >> N;
	for ( int i = 0; i < N; i++) scanf("%d", &A[i]);
	
	counter = selectSort(A, N);
		
	for ( int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	
	cout << endl;
	cout << counter << endl;
	
	return 0;
}


Measured memory_bytes: 3244
n, k = map(int,input().split())
p = list(map(int,input().split()))

exps = [(elm+1)/2 for elm in p]
#print(exps)
cum_sums = [0]*(n+1)
for ind in range(n):
  cum_sums[ind+1] = cum_sums[ind]+exps[ind]
#print(cum_sums)
k_exps = [cum_sums[ind+k]-cum_sums[ind] for ind in range(n-k+1)]
#print(k_exps)
print(max(k_exps))

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> ans(N+1, vector<int>(N+1, 0));
    queue<pair<int, int>> que;
    que.push(make_pair(1, N));
    int level = 0;
    while (! que.empty()){
        auto top = que.front();
        que.pop();
        int s = top.first;
        int t = top.second;
        if(s == t) continue;
        int m = (s + t) / 2;
        m++;
        // [s, m-1], [m, t], sのほうが大きくする
        if(s == 1) level++;
        for (int i = s; i < m; ++i) {
            for (int j = m; j <= t; ++j) {
                ans[i][j] = level;
                ans[j][i] = level;
            }
        }
        que.push(make_pair(s, m-1));
        que.push(make_pair(m, t));
    }

    for (int i = 1; i <= N; ++i) {
        for (int j = i+1; j <= N; ++j) {
            if(j != N){
                cout << ans[i][j] << " ";
            } else{
                cout << ans[i][j] << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1536
n = int(input())
x = list(map(int,input().split()))
sum_x = sum(x)
sum_x2 = sum([i**2 for i in x])
p0 = sum_x//n
p1 = p0+1
r0 = n*p0**2 - 2*sum_x*p0 + sum_x2
r1 = n*p1**2 - 2*sum_x*p1 + sum_x2
print(min(r0,r1))

Measured memory_bytes: 38384
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int C[N];
	int V[N];
	int sa = 0;
	int money = 0;
	for(int i = 0; i < N; i++){
		cin >> V[i];
	}
	
	for(int i = 0; i < N; i++){
		cin >> C[i];
	}
	
	for(int i = 0; i < N; i++){
		sa = V[i] - C[i];
		
		if(sa > 0){
			money += sa;
		}
	}
	cout << money << endl;
	return 0;
			
	
}

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

int main() {
    vector<int> vec(3);

    for(int i = 0; i < 3; i++) {
        cin >> vec.at(i);
    }

    vector<int> vec_sort = vec;
    sort(vec_sort.begin(), vec_sort.end());
    int num_min = vec_sort.at(0);

    int before_num = num_min;
    int total = 0;
    for(int i = 1; i <= 2; i++) {
        int cost = abs(vec_sort.at(i) - before_num);
        total += cost;
        before_num = vec_sort.at(i);
    }

    cout << total << endl;
    
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    foods = []
    for _ in range(n):
        foods.append(list(map(int,input().split())))
    limit = list(map(int,input().split()))
    ans = []
    for food in foods:
        if food[1] <= limit[0] and food[2] <= limit[1] and food[3] <= limit[2] and (food[1]+food[3])*4+food[2]*9 <= limit[3]:
            ans.append(food[0])
    if ans == []:
        print("NA")
    else:
        for num in ans:
            print(num)


Measured memory_bytes: 5852
fun main(args : Array<String>) {
    val N = readLine()!!.toLong()
    val A = readLine()!!.toLong()
    val B = readLine()!!.toLong()
    val C = readLine()!!.toLong()
    val D = readLine()!!.toLong()
    val E = readLine()!!.toLong()

    val bottleneck = listOf(A, B, C ,D, E).min()!!
    val div = (N.toDouble() / bottleneck.toDouble())
    var bottleneckCount = Math.floor(div).toLong()
    if (N.mod(bottleneck) != 0L) {
        bottleneckCount++
    }
    val ans = 4 + bottleneckCount

    println(ans)
}

Measured memory_bytes: 35944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		long ans = 0;
		ans += ((b+1)/2-a/2)%2;
		int i = 1;
		while((b>>i)!=0) {
			long num = 1L<<(i+1);
			long a_mod = a%num;
			long b_mod = b%num;
			long start = Math.min(num-a_mod, num>>1);
			long end = Math.max(0, b_mod-(num>>1)+1);
			ans += (start+end)%2==1 ? num>>1 : 0;
			i++;
		}
		System.out.print(ans);
		in.close();
	}

}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 30005;

vector<int> used;
vector<int> v0, v2, v3, v4;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int N;
    cin >> N;

    if(N == 3){
        cout << "2 5 63" << endl;
        return 0;
    }

    for(int a = 1; a <= 30000; a++){
        //we can take a mod 6 = 0, 2, 3, 4
        if(a % 6 == 0){
            v0.push_back(a);
        }
        if(a % 6 == 2){
            v2.push_back(a);
        }
        if(a % 6 == 3){
            v3.push_back(a);
        }
        if(a % 6 == 4){
            v4.push_back(a);
        }
    }

    reverse(allof(v0));
    reverse(allof(v2));
    reverse(allof(v3));
    reverse(allof(v4));

    N -= 2;
    used.push_back(v3.back()); v3.pop_back();
    used.push_back(v3.back()); v3.pop_back();

    N -= 2;
    used.push_back(v2.back()); v2.pop_back();
    used.push_back(v4.back()); v4.pop_back();

    if(N % 2 != 0){
        N--;
        used.push_back(v0.back()); v0.pop_back();
    }

    while(N > 0 && !v3.empty()){
        N -= 2;
        used.push_back(v3.back()); v3.pop_back();
        used.push_back(v3.back()); v3.pop_back();       
    }

    while(N > 0 && !v2.empty()){
        N -= 2;
        used.push_back(v2.back()); v2.pop_back();
        used.push_back(v4.back()); v4.pop_back();       
    }

    while(N > 0){
        N--;
        used.push_back(v0.back()); v0.pop_back();
    }

    for(int i : used){
        cout << i << " ";
    }
}


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

bool tax_check(int n, int A, int B){
    if(floor(n*0.08)==(double)A && floor(n*0.1)==(double)B){
        return true;
    }
    else{
        return false;
    }
}

int main(){
    int A, B;
    cin >> A >> B;
    bool uncheked = true;
    REP(i,1251){
        if(tax_check(i,A,B)){
            cout << i << endl;
            uncheked = false;
            break;
        }
    }
    if(uncheked){
        cout << (-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a);
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++){
     b=b*N+im[j][i]-im[j][i-p]*g;
     roll[j][i]=b;
   }
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=6;
	while(a--)im[i][j*6+a]=t%2,t/=2;
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=6;
	while(a--)pa[i][j*6+a]=t%2,t/=2;
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 10060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
 int a,b,c,d,e,f;
 cin>>a>>b>>c>>d>>e>>f;
 int s = a+5*b+10*c+50*d+100*e+500*f;
 if(s>=1000) cout << 1 << endl;
 else cout << 0 << endl;
 return 0;
}

Measured memory_bytes: 1164
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )
import qualified Data.Set as Set
import           Control.Monad
main :: IO ()
main = do
  [n, k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  sets <- replicateM k $ do
    d <- readLn :: IO Int
    as <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return $ Set.fromList as
  let s = Set.unions sets
  print $ n - Set.size s


Measured memory_bytes: 5064
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split()))for _ in range(D)]

    len_C = len(C)
    types = []
    lasts = [0] * 26

    for i in range(D):
        s = max(S[i])

        c = []
        c_sum = 0
        for j in range(len_C):
            c.append((i + 1 - lasts[j]) * C[j])
            c_sum += (i + 1 - lasts[j]) * C[j]  # 満足度低下の合計

        if c_sum >= s:  # 低下が増加の最高値より高ければ一番大きい低下を無くす
            t = c.index(max(c)) + 1
            lasts[t - 1] = i + 1
        else:
            t = S[i].index(s) + 1

        types.append(t)

    for type in types:
        print(type)


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  ll n,x; cin>>n>>x;
  vector<ll> v(n);
  rep(i, n) {
    ll t; cin>>t;
    v[i] = abs(x - t); 
  }
  ll gcd = __gcd(v[0], v[1]);
  for(int i = 2; i < n; i++) {
    gcd = __gcd(gcd, v[i]);
  }
  cout << gcd;
}


Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
using namespace std;

typedef long long ll;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;

ll absll(ll a){
    if(a<0)return -1*a;
    return a;
}

int main() {
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==k){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    sort(a.begin(),a.end());
    if(k>a.back()){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    unordered_set<int>v;
    
    for(int i=1;i<a.size();i++){
        if(a[i]==a[i-1])continue;
        v.insert(abs(a[i]-a[i-1]));
        
    }
    for(auto vi:v){
        if(vi==0)continue;
        for(auto ai:a){
            
            if((ai-k)%vi==0){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    
    
}


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

int main()
{
  int a,s;
  cin >> a >> s;
  if(a%3==0 || s%3==0 || (a+s)%3==0)
    cout << "Possible" << endl;
    else
      cout << "Impossible" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int b[27];
int main()
{
	char a[1005];
	cin>>a;
	int count1=0;
	for(int i=0;i<strlen(a);i++)
	{if(a[i]>='A'&&a[i]<='Z')
	{count1++;
	b[a[i]-'A']++;
	}
	}
	if(b[0]==1&&b[2]==1&&a[strlen(a)-1]!='C'&&count1==2&&a[0]=='A'&&a[1]!='C')
	cout<<"AC";
	else cout<<"WA";
	return 0;
	}

Measured memory_bytes: 256
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


s = int(input())

a = [0] * 1000000
a[0] = s
for i in range(1, 1000000):
    a[i] = f(a[i - 1])

t = set()
for i in range(1000000):
    if a[i] in t:
        print(i + 1)
        break
    t.add(a[i])


Measured memory_bytes: 10868
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void){

    char s[4], t[4];
    int count = 0;

    cin >> s;
    cin >> t;

    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main()
{
	int n;
	cin >> n;
	int info[4][3][10] = {};
	
	for (int i = 0; i < n; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		info[a-1][b-1][c-1] += d;
	}
	for (int i = 0; i < 15; i++)
	{
		if ((i + 1) % 4 == 0) {
			for (size_t i = 0; i < 20; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		else {
			for (int j = 0; j < 10; j++)
			{
				cout <<" "<< info[(i + 1) / 4][(i + 1) % 4-1][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3076
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
c=[[] for i in range(N)]
for a,b in AB:
    c[a-1].append(b-1)
from collections import deque
import sys
sys.setrecursionlimit(10**9)
def f2(q):
    s=set(q)
    for a,b in AB:
        if a in s and b in s:
            i=q.index(b)
            if q[i-1]!=a:
                break
    if a in s and b in s and q[i-1]!=a:
        q2=deque([a,b])
        while q[(i+1)%len(q)]!=a:
            q2.append(q[(i+1)%len(q)])
            i+=1
        f2(q2)
    print(len(q),*q,sep='\n')
    exit()
v=[0]*N 
w=[0]*N
def f(p,v,q):
    v[p]=1
    w[p]=1
    q.append(p+1)
    for n in c[p]:
        if v[n]:
            f2(q)
        else:
            f(n,v,q)
    q.pop()
    v[p]=0
for p in range(N):
    if w[p]==0:
        f(p,v,deque())
print(-1)


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

int K;
string S;


void input(){
  cin >> K;
  cin >> S;
}

void solve(){
  if(S.length()<=K){
    cout << S << endl;
  }
  else{
    string ans;
    for(int i=0;i<K;i++){
      ans+=S[i];
    }
    ans+="...";
    cout << ans <<endl;
  }
}

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


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a,int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n",max(max(a+b,a-b),a*b));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int a, b;
    cin >> a >> b;
    ll ans = max({a+a-1, b+b-1, a+b});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;

const int mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
Pii d[1000000];

int par[1000000], rk[1000000];
void init(int n){
    for(int i = 0;i < n;i++){
        par[i] = i;
        rk[i] = 0;
    }
}
int compare_int(const void *a, const void *b){
	Pii *A = (Pii *)a;
	Pii *B = (Pii *)b;
    return A->first - B->first;
}
int main(void){
    int n; cin >>n;
    for(int i = 0;i < n;i++){
        cin >> d[i].first;
        d[i].second = i;
    }
    qsort(d, n, sizeof(Pii), compare_int);
    int ans = 0;
    for(int i = 0;i < n;i+=2){
        if((d[i].second)%2 == 1)ans++;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5116
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
  int A,B,C,K,ju=0,i;
  scanf("%d %d %d\n",&A,&B,&C);
  scanf("%d",&K);
  for(i=0;i<K;i++){
  	if(B>A){
	 break;
	}
	B=2*B;
  }
  if(B>A){
  }else{
  C=0;
  }
  for(;i<K;i++){
	if(C>B){
	 ju=1;
	 break;
	}
	C=2*C;
  }
  if(C>B){
	printf("Yes");
  }else{
	printf("No");
  }
  return 0;
}


Measured memory_bytes: 1728
a,b,c,d = map(int,input().split())
ans = 0
dp = [[0]*(d+1) for i in range(c+1)]
mod = 998244353
dp[a][b] = 1
for i in range(a+1,c+1):
    dp[i][b] = dp[i-1][b] * b % mod
for i in range(b+1,d+1):
    dp[a][i] = dp[a][i-1] * a % mod
for i in range(a+1,c+1):
    for j in range(b+1,d+1):
        dp[i][j] = ((dp[i-1][j]*j) + (dp[i][j-1]*i) - (dp[i-1][j-1]*(i-1)*(j-1)))%mod
print(dp[c][d])

Measured memory_bytes: 136852
#include <iostream>
#include <string>
#include <map>
using namespace std;

typedef pair<int,int> result;
#define value first
#define p second

result equation(const string &s, int p = 0);
result factor(const string &s, int p=0);
result term(const string &s, int p=0);

result equation(const string &s,int p) {
    result r = factor(s,p);
    while(s[r.p] == '+' || s[r.p] == '-') {
        result r_ = factor(s, r.p+1);
        if(s[r.p] == '+') r.value += r_.value;
        else r.value -= r_.value;
        r.p = r_.p;
    }
    return r;
}

result factor(const string &s, int p) {
    result r = term(s,p);
    while(s[r.p] == '*' || s[r.p] == '/') {
        result r_ = term(s, r.p+1);
        if(s[r.p] == '*') r.value *= r_.value;
        else r.value /= r_.value;
        r.p = r_.p;
    }
    return r;
}

result term(const string &s, int p) {
    if(s[p] == '(') {
        result r = equation(s,p+1);
        r.p += 1;
        return r;
    }else{
        int value = 0;
        while(isdigit(s[p]))
            value = value*10 + (s[p++] - '0');
        return result(value,p);
    }
}

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

    string s;
    for(int i=0; i<n; ++i) {
        cin>>s;
        result r = equation(s);
        cout<<r.value<<endl;
    }
}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

vector<int> array_left_rotation(vector<int> a, int n, int k) {
    
}

int main(){
  long long int X;
  cin >> X;
  long long int i=0;
  long long int sum=0;
  while(sum<X){
    sum=sum+i+1;
    i=i+1;
  }
  
    cout << i <<endl;
  

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;

int main() {
  int n,ans=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans+=a[i]*a[j];
    }
  }
  cout<<ans;
}

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

int W[4009][4009], B[4009][4009], PW[4009][4009], PB[4009][4009];

int getW(int a, int b, int c, int d) { --a;--b;--c;--d; return PW[c][d] - PW[a][d] - PW[c][b] + PW[a][b]; }
int getB(int a, int b, int c, int d) { --a;--b;--c;--d; return PB[c][d] - PB[a][d] - PB[c][b] + PB[a][b]; }

int main() {
    int N, K; scanf("%d%d",&N,&K);
    for(int i=0; i<N; i++) {
        int a, b; char c; scanf("%d%d %c",&a,&b,&c);
        int x = a % (2*K) + 1, y = b % (2*K) + 1;
        if(c == 'W') {
            ++W[x][y];
            ++W[2*K + x][y];
            ++W[x][2*K + y];
            ++W[2*K + x][2*K + y];
        }
        if(c == 'B') {
            ++B[x][y];
            ++B[2*K + x][y];
            ++B[x][2*K + y];
            ++B[2*K + x][2*K + y];
        }
    }
    for(int i=1; i<=4*K; i++) {
        for(int j=1; j<=4*K; j++) {
            PW[i][j] = PW[i-1][j] + PW[i][j-1] - PW[i-1][j-1] + W[i][j];
            PB[i][j] = PB[i-1][j] + PB[i][j-1] - PB[i-1][j-1] + B[i][j];
        }
    }
    int ans = 0;
    for(int i=1; i<=2*K; i++) {
        for(int j=1; j<=2*K; j++) {
            ans = max(ans, getW(i, j, i+K, j+K) + getW(i+K, j+K, i+2*K, j+2*K) + getB(i+K, j, i+2*K, j+K) + getB(i, j+K, i+K, j+2*K));
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 251264
num=int(input())
board=list(map(int,input().split(" ")))
count=0
flug=1

while(flug):
  
  for i in range(num):
    if board[i]%2 == 0:
      board[i]=board[i]/2
    else:
      flug=0
      break
      
    if i==num-1:
      count+=1
    
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    int outer = (s == 1e9) ? 2 : 1e9;
    for(int i = 0; i < k; i++)
        cout << s << " ";
    for(int i = k; i < n; i++)
        cout << outer << " ";
    return 0;
}




Measured memory_bytes: 1280
#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX], n;
  cin >> n;
  for(int i; i<n;i++) cin>>R[i];

  int maxv = -2000000000;
  int minv = R[0];
  for(int i=1;i<n;i++){
    maxv = max(maxv,R[i]-minv);
    minv = min(minv,R[i]);
  }

  cout << maxv << endl;
}



Measured memory_bytes: 3844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x < 1200) {
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;cin>>n>>k;
  ll a[n];
  ll sum[n+1];
  sum[0]=0;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=sum[i]+a[i];
  }
  ll ys[n+1];
  ys[0]=0;
  for(ll i=0;i<n;i++){
    if(a[i]>0){
      ys[i+1]=ys[i]+a[i];
    }
    else ys[i+1]=ys[i];
  }
  ll ans=0;
  for(ll i=0;i<n-k+1;i++){
    ll ss=ys[n]-ys[i+k]+ys[i]-ys[0];
    ll kk=max(sum[i+k]-sum[i],(ll)0);
    ans=max(ans,ss+kk);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 200005;


vector<int> adj[N];
vector<bool> vis(N,false);

vector<int> a(N);

vector<int> ans(N);

multiset<int> ss;

int timer = 0;

vector<int> entrytimer(N,0),exitimer(N,0);

void dfs(int s)
{
  if(!vis[s])
  {
    vis[s] = true;



    auto it = ss.lower_bound(a[s]);

    

    int y = -1 ;

    ss.insert(a[s]);
    if(it != ss.end())
      {
        y = *it;
        ss.erase(it);
      }


    ans[s] = ss.size();
    for(auto &i : adj[s])
    {
      if(!vis[i])dfs(i);
    }


    auto it1 = ss.find(a[s]);
    if(it1 != ss.end())ss.erase(it1);

    if(y != -1)ss.insert(y);


  }
}

int32_t main()
{

    IOS


    int n;
    cin >> n;


    for(int i = 1; i <=n; i++)cin >> a[i];


    for(int i = 1; i <= n-1; i++)
    {
      int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }


    dfs(1);


    for(int i = 1; i <= n; i++)cout << ans[i] << endl;


    

    return 0;
}



Measured memory_bytes: 32448
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 100005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(int N, int pos){return (bool)(N & (1<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

double maxvolume(double s)
{
    double length = s / 3.0;
    s -= length;
    double breadth = s / 2.0;
    double height = s - breadth;
    return length * breadth * height;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    double L;
    cin>>L;
    cout<<fixed<<setprecision(7)<<maxvolume(L)<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 256
data = []
i = 0

while n = gets
        data[i] = n.chomp.to_s
        data[i] = data[i].split
        data[i] = (data[i][0].to_i + data[i][1].to_i).to_s
        i += 1
end

for i in 0...i
        puts data[i].length
end



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(long long n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(long long n, long long k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(void){
    ll N,K; cin >> N >> K;
    combination C(N+K);
    if(N == K){
        cout << 1 << endl;
        REP(i,K-1) cout << 0 << endl;
        return 0;
    }
    REP(i,K){
        mint ans(0);
        ans += C(K-1,i);
        ans *= C(N-K-1, i-1) + C(N-K-1, i)*2 + C(N-K-1, i+1);
        cout << ans.x << endl;
    }
    return 0;
}

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

typedef long long ll;

ll MOD = 1e9 + 7;

int n;
int m;

ll x[100010],y[100010];

vector<ll> h,w;

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

	for(int i = 0;i < n;i++)
	{
		cin >> x[i];
	}
	for(int i = 0;i < m;i++)
	{
		cin >> y[i];
	}

	w.push_back(0);
	h.push_back(0);

	for(int i = 1;i < n;i++)
	{
		w.push_back(x[i] - x[i - 1]);
	}
	for(int i = 1;i < m;i++)
	{
		h.push_back(y[i] - y[i - 1]);
	}

	vector<ll> wdp(n + 2,0);
	vector<ll> use(n + 2,0);

	for(int i = 1;i < w.size();i++)
	{
		use[i] = (use[i - 1] + i * w[i]) % MOD;
		wdp[i] = (wdp[i - 1] + use[i]) % MOD;
	}

	vector<ll> hdp(m + 2,0);
	use.resize(m + 2,0);

	for(int i = 1;i < h.size();i++)
	{
		use[i] = (use[i - 1] + i * h[i]) % MOD;
		hdp[i] = (hdp[i - 1] + use[i]) % MOD;
	}

	cout << (wdp[w.size() - 1] * hdp[h.size() - 1]) % MOD << endl;
	return 0;
}


Measured memory_bytes: 6644
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
const int mod=1e9+7;
int N,M;
LL dp[100010]={};
bool f[100010]={};
int main(){
    cin>>N>>M;
    dp[0]=1;
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        f[a]=true;
    }
    if(!f[1])dp[1]=1;
    for(int i=2;i<=N;i++){
        int tmp=0;
        if(!f[i])
            dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    cout<<dp[N];
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharp_AtCoder
{


    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[,] A = new int[3, N + 1];
            for(int i = 1; i < 3; i++)
            {
                int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                for(int j = 0; j < N; j++)
                {
                    A[i, j + 1] = input[j];
                }
            }

            int[,] max_candies = new int[3, N + 1];
            for(int i = 1; i < 3; i++)
            {
                for(int j = 1; j < N + 1; j++)
                {
                    max_candies[i, j] = Math.Max(max_candies[i - 1, j], max_candies[i, j - 1]) + A[i, j];
                }
            }

            Console.WriteLine(max_candies[2, N]);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    fastio;
    ll ans=0, N;
    string s;
    cin >> N >> s;
    ll r = count(begin(s), end(s), 'R');
    ll g = count(begin(s), end(s), 'G');
    ll b = count(begin(s), end(s), 'B');
    ans = r * g * b;
    rep1(i,N) for (int j=i+1; j<=N; ++j) {
        int k = 2*j-i;
        if (k > N)
            continue;
        if (s[i-1] != s[j-1] && s[j-1] != s[k-1] && s[i-1] != s[k-1])
            --ans;
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    map<int, int> mp;

    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        mp[a - 1]++;
        mp[b - 1]++;
    }

    rep(i, n)
    {
        cout << mp[i] << endl;
    }

    return 0;
}


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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++) {
    cin >> h[i];
  }

 int ans = 0;
  while (*max_element(h.begin(), h.end()) != 0) {
    for (int i = 0; i < N; i++) {
      if(h[i] != 0)  {
        ans++;
        while (i < N && h[i] > 0) {
          h[i]--;
          i++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
import java.util.*

fun main(arr:Array<String>) {
    val buttons = readLine()!!.split(" ").map { it.toInt()*-1 }
    val queue = PriorityQueue<Int>()
    queue.addAll(buttons)
    var ans = 0
    for(i in (1..2)) {
        var b = queue.poll() * -1
        ans += b
        b--
        if(b > 0) {
            queue.add(b*-1)
        }
    }
    println(ans)
}


Measured memory_bytes: 37908
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var a = int.Parse(inputs[0]);
            var b = int.Parse(inputs[1]);
            
            var result = isInRange(a) && isInRange(b) ? a * b : -1;
            Console.WriteLine(result);
        }

        private static bool isInRange(int num)
        {
            return num >= 1 && num <= 9;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define forn(i,a,b) for (ll i =a; i <=b; ++i)
void debug()
{
    cerr << "\n";
}
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cerr << H << " ";
    debug(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] : ";debug(__VA_ARGS__);
const ll maxn = 1e6 + 10;
const ld lt=1e18;
void solve()
{
    ll n;
    cin>>n;
    ld a[n];
    rep(i,n)
    cin>>a[i];
    sort(a,a+n);
    ld res=1;
    rep(i,n)
    {
        if(res>lt/a[i])
            {res=-1;break;}
        res*=a[i];
    }
    cout<<(ll)res;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t;
    // cin >> t;
    t=1;
    rep(i, t)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5372
#include <stdio.h>

int main() {
	int n;

	scanf("%d\n", &n);
	while (n--) {
		char c;

		scanf("%c ", &c);
		if (c == 'Y') {
			printf("Four\n");
			return 0;
		}
	}
	printf("Three\n");
	return 0;
}


Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	s=input()

	n=len(s)

	l=0
	r=n-1

	ans=0

	while l<r:

		if s[l]==s[r]:
			l+=1
			r-=1

		elif s[l]=="x":
			ans+=1
			l+=1

		elif s[r]=="x":
			ans+=1
			r-=1

		else:
			print(-1)
			exit()

	print(ans)
	return

if __name__ == "__main__":
	main()


Measured memory_bytes: 9320
let a = readLine()!.split(separator: " ").map({Int($0)!})
var arr = [Int]()
let N = a[0]
let X = a[1]

for i in 0 ..< N {
    arr.append(Int(readLine()!)!)
}
var sum = arr.reduce(0, +)
var min = arr.min() ?? 0
print((X - sum)/min+N)

Measured memory_bytes: 8244
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,s;
    vector<LL> c;
    Problem(LL n):n(n),s(100000),c(s){};

    void solve(){
        for(int i=0; i<n; ++i){
            int tmp;
            cin >> tmp;
            c[tmp]++;
        }
        int ans =0;
        for(int i=1; i<=1e5-2; ++i){
            ans = max<int>(ans,c[i-1]+c[i]+c[i+1]);
        }
        cout << ans <<"\n";

    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 1024
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var n = int.Parse(str);

            var zoroStr = "" + str[0] + str[0] + str[0];
            var zoro = int.Parse(zoroStr);
            if (n <= zoro)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    Console.Write(str[0]);
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine(zoro + 111);
            }
        }
    }
}


Measured memory_bytes: 11220