akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn bsearch(x: i32, s: &[i32]) -> bool {
    if s.len() == 1 {
        if x == s[0] {
            return true;
        }
        return false;
    }

    let m = s.len()/2;
    if x < s[m] {
        bsearch(x, &s[..m])
    } else {
        bsearch(x, &s[m..])
    }
}


fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n = scan.next();
    let mut s = vec![0; n];
    for i in 0..n {
        s[i] = scan.next();
    }
    let q = scan.next();
    let mut t = vec![0; n];
    for i in 0..q {
        t[i] = scan.next()
    }

    s.sort();
    let mut res = 0;
    for i in 0..q {
        if bsearch(t[i], &s) {
            res += 1;
        }
    }
    writeln!(out, "{}", res).ok();
}



Measured memory_bytes: 12456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		boolean ans = false;

		switch (a) {
		case 5:
			if(b ==7) {
				if(c == 5) {
					ans = true;
				}
			}else if(c == 7) {
				if(b == 5) {
					ans = true;
				}
			}
			break;
		case 7:
			if(b == 5 && c == 5) {
				ans = true;
			}
		}
		System.out.println(ans ? "YES" : "NO");
	}

}

Measured memory_bytes: 35768
# -*- coding: utf-8 -*-
import unittest
import math

MOD = 10**9+7


def func(n,m):
    fac = [1 for _ in range(n+100)]
    finv = [1 for _ in range(n+100)]
    inv = [1 for _ in range(n+100)]
    for i in range(2,n+100):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = (MOD - inv[MOD%i] * (MOD//i))%MOD
        finv[i] = (finv[i-1]*inv[i])%MOD

    def comb(a,b):
        return (fac[a]*((finv[b]*finv[a-b])%MOD))%MOD

    fact = {}
    for x in range(2, math.ceil(math.sqrt(m))+1):
        while m%x==0:
            if x not in fact:
                fact[x] = 0
            fact[x] += 1
            m = m//x
        if m==1:
            break
    if m!=1:
        fact[m] = 1

    ret = 1
    for k in fact.values():
        ret *= comb(k+n-1,k)
        ret %= MOD
    return ret

class Test(unittest.TestCase):
    def test(self):
        self.assertEqual(func(2,6), 4)
        self.assertEqual(func(3,12), 18)
        self.assertEqual(func(100000, 1000000000), 957870001)
        self.assertEqual(func(2,3), 2)

if __name__ == '__main__':
    n,m = map(int, input().split())
    print(func(n,m))
    # unittest.main()


Measured memory_bytes: 17772
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int top,a[510],b[510],sta[50010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),cnt=read(),mx=0,ans=0,sum=0;
    for(int i=1;i<=n;i++)a[i]=read(),mx=max(mx,a[i]),sum+=a[i];
    for(int i=1;i<=sqrt(sum);i++)
	{
		if(sum%i==0)
		{
			sta[++top]=i;
			if(i*i!=sum)sta[++top]=sum/i;
		}
	}
    for(int i=1;i<=top;i++)	
    {
    	long long tot=0;int k=sta[i];
    	for(int j=1;j<=n;j++)b[j]=ceil(1.0*a[j]/k)*k-a[j],tot+=b[j];
		sort(b+1,b+n+1);
		if(tot%k!=0)continue;
		long long sum=tot;tot/=k;
		for(int j=n;j>=n-tot+1;j--)sum-=b[j];
		if(sum<=cnt)ans=max(ans,k);
    }pr2(ans);
    return 0;
}

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

public class Main {

	static int count = 0;
	static int input = 0;
	static int ans;

	public static void sum(int x, int y) {
		ans =  (x + y) * (y - x + 1) / 2;
//		return ans;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			input=0;
			count=0;
			String num = br.readLine();
			if (num.equals("0")) {
				return;
			}

			input = Integer.parseInt(num);

			for (int i = 1; i < input; i++) {
				for (int j = i+1; j < input; j++) {
					sum(i,j);
					if (input == ans) {
						count++;
						break;
					}
					if (input < ans) {
						break;
					}
				}
				if(i > 1+input/2 ) {
					break;
				}
			}
			System.out.println(count);
		}
	}

}



Measured memory_bytes: 24916
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
 */
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);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();

            char c = S.charAt(0);
            int sum = 1;
            for (int i = 1; i < N; i++) {
                char c2 = S.charAt(i);
                if (c != c2) {
                    c = c2;
                    sum++;
                }
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 24980
import itertools
s = str(input())

s4  = []
for l in range(2 ** (len(s)-1)):
    s3 = list(s)
    h = 0
    for i in range(len(s)-1):
        if (l >> i) & 1:
            s3.insert(i+h+1,'+')
            h += 1
    s4.append(s3)
print(sum([eval(''.join(i)) for i in s4]))

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

void rec(vector<char>& a,int n,int cnt,int mx) {
    if (cnt == n) {
        for (int i = 0;i < n;++i) cout << a[i];
        cout << "\n";
        return;
    }
    for (int i = 0;i < mx;++i) {
        a[cnt] = 'a'+i;
        rec(a,n,cnt+1,mx);
    }
    a[cnt] = 'a'+mx;
    rec(a,n,cnt+1,mx+1);
}

int main() {
    int n;
    cin >> n;
    vector<char> a(n);
    a[0] = 'a';
    rec(a,n,1,1);
}

Measured memory_bytes: 1536
# 入力
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
import numpy as np
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

def solution():
    N = input_int()
    Ts = input_lines(N,input_int)

    ans = lcm(Ts)
    print(ans)

if __name__ == '__main__':
    solution()

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

signed main(){
    //freopen("input.txt", "r", stdin);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 1e9;
    for (int i=0; i < 200; i++){
        for (int j=0; j < 200; j++){
            for (int k=0; k < 200; k++){
                int A = a+i+j;
                int B = b+i+k;
                int C = c+j+k;
                if (A%2!=B%2 || B%2 != C%2 || C%2 != A%2) continue;
                if (A >= B && A >= C) ans = min(ans, i+j+k+(A-B)/2+(A-C)/2);
                if (B >= A && B >= C) ans = min(ans, i+j+k+(B-A)/2+(B-C)/2);
                if (C >= B && C >= A) ans = min(ans, i+j+k+(C-A)/2+(C-B)/2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define lpx(i,x,n) for(int i=x; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 500000;
int mx = -1e9 , mn = 1e9 ;
int arr[N] ;

int dcmp(double x, double y)
{
    return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}
ul fac(int n)
{
    if(n > 1)
        return n * fac(n - 1);
    else
        return 1;
}



int main()
{
    int n, ans = 0,c=0 ;cin>> n;
    lp(i,n)
        cin >> arr[i];
    for(int i = 1 ; i < n ; ++i){
        if(arr[i] > arr[i-1]){
            if(c > ans)ans = c;
            c = 0;
        }
        else
            ++c;
    }
    if(c > ans)ans = c;
    cout << ans << endl;


    return 0;
}












Measured memory_bytes: 640
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[][] = new int[2][N];
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < N; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int max = 0;
    for (int i = 0; i < N; i++) {
      int c = A[0][0];
      for (int j = 1; j <= i; j++) {
        c += A[0][j];
      }
      for (int j = i; j < N; j++) {
        c += A[1][j];
      }
      if (c > max) max = c;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 23124
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=sc.nextIntArray(n);
        long d[]=new long[n];
        long e[]=new long[n];
        for (int i = 0; i < n; i++) {
        	for (int j = 0; j < a.length; j++) {
				if(a[i]<a[j]) {
					if(i>j)d[i]++;
					e[i]++;
				}
			}
		}
        // 2 1 2 1
        long s=0;
        for (int i = 0; i < d.length; i++) {
			s+=e[i]*((long)k*(k-1)/2%mod)%mod + d[i]*k%mod;
			s%=mod;
			if(s<0)s+=mod;
//			db(i,s);
		}
        
        out.println(s);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21460
import math

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

A_ceil = math.ceil(A/10)*10
B_ceil = math.ceil(B/10)*10
C_ceil = math.ceil(C/10)*10
D_ceil = math.ceil(D/10)*10
E_ceil = math.ceil(E/10)*10

f = max([A_ceil-A, B_ceil-B, C_ceil-C, D_ceil-D, E_ceil-E])

print(A_ceil+B_ceil+C_ceil+D_ceil+E_ceil-f)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,T;

vector<int> G[1111];
bool F[1111][1111];
int X,Y;

int dub(int a){ return a*a; }
int abs( P a, P b ){
  return dub(a.first-b.first)+dub(a.second-b.second);
}

int main(){
  cin >> T;
  while( T-- ){
    for(int i=0;i<N;i++) G[i].clear();
    cin >> N >> X >> Y;
    P s;
    cin >> s.first >> s.second;
    P v[1111];
    for(int i=0;i<N;i++)
      cin>> v[i].first >> v[i].second;    
    queue<int> q;
    int H[1111] = {};
    for(int i=0;i<N;i++){
      if( abs( s, v[i] ) <= 10*10 ) {
        q.push( i );
        H[i] = X;
      }
      for(int j=i+1;j<N;j++){       
        if( abs(v[i],v[j]) <= 50*50 ){
          G[i].push_back( j );
          G[j].push_back( i );
        }
      }
    }
    
    memset(F,0,sizeof(F));
    int res = 0;
    while( !q.empty() ){
      int p = q.front(); q.pop();
      int time = H[p];
      res = max( res, time );
      //  cout<< p << " "<< time << endl;
      for(int i=0;i<(int)G[p].size();i++){
        int to =G[p][i];
        if( H[to] > 0 && H[to] >= time - Y ) continue;
        if( F[i][to] ){
          res = -1; goto end;
        }
        F[i][to] = true;
        q.push( to );
        H[to] = time + X;
      }
    }
  end:;
    if( res == -1 ) cout << "You're always welcome!" << endl;
    else cout << res << endl;
  }
  
}

Measured memory_bytes: 6532
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void){
  string s;
  cin >> s;
  ll dp[100010][3] = {};
  ll branch = 1;
  for(int i = 0;i < (int)s.size();++i){
    if(s[i] == '?'){
      dp[i+1][0] = (dp[i][0] * 3) % mod;
      dp[i+1][0] = (dp[i+1][0] + branch) % mod;

      dp[i+1][1] = (dp[i][1] * 3) % mod;
      dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % mod;
      
      dp[i+1][2] = (dp[i][2] * 3) % mod;
      dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % mod;

      branch = (branch * 3) % mod;
    }else{
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
      dp[i+1][2] = dp[i][2];
      if(s[i] == 'A'){
        dp[i+1][0] = (dp[i+1][0] + branch) % mod;
      }else if(s[i] == 'B'){
        dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % mod;
      }else if(s[i] == 'C'){
        dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % mod;
      }
    }
  }
  ll sz = (ll)s.size();
  cout << dp[sz][2] << endl;
  return 0;
}



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

#define print(x) for(auto it : x) cout<< it << " "; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int a; cin >> a;
    cout << (a + a * a + a * a * a) << endl;
    return 0;
}


Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn Agrawal coderbond007  PLEASE!! PLEASE!! HACK MY SOLUTION!!
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.nextString();
            int[] ct = new int[26];
            for (int i = 0; i < s.length(); ++i) ++ct[s.charAt(i) - 'a'];
            long res = 1L;
            for (int i = 0; i < ct.length; ++i) {
                for (int j = i + 1; j < ct.length; ++j) {
                    res += ct[i] * (1L) * ct[j];
                }
            }
            out.println(res);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = scan.nextInt();
        }
        Arrays.sort(p);
        int ans = 0;
        for (int i = 0; i < K; i++) {
            ans += p[i];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 38604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		long[] dp = new long[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		for(int i = 1;i < n; i++) {
			for(int m = 1; m < k+1; m++) {
				if(i >= m )dp[i] = Math.min(dp[i], dp[i-m] + Math.abs(h[i] - h[i - m]));
			}
		}
		System.out.println(dp[n - 1]);
	}
}

Measured memory_bytes: 51184
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int c=1;
	while(true){
	    int x=sc.nextInt();
	    if(x==0)break;
	    System.out.println("Case "+c+": "+x);
	    c++;
	}
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

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

using namespace std;

int main(){
	
	while(1){
		int n,p;
		
		cin >> n >> p;
		
		if(n==0&&p==0){
			return 0;
		}
		
		int play[n]={};
		
		int t=p;
		int i=0;
		
		while(1){
			if(t!=0){
				play[i] += 1;
				t--;
				if(t==0 && play[i]==p){
					cout << i << endl;
					break;
				}
				i++;
			}else{
				t += play[i];
				play[i] = 0;
				i++;
			}
			if(i==n)
				i=0;
		}
	}
}
			
				


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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=1;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a+b+c >= 22){
        printf("bust");
    }
    else{
        printf("win");
    }
}


Measured memory_bytes: 3720
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
  ll x; cin>>x;
  if(x==7||x==5||x==3) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=100010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
int k;
char s[maxn];
std::vector<int> v1,v2;
ll sum1[maxn];
ll sum2[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
    gbtb;
    cin>>n>>k;
    cin>>s;
    int cnt=0;
//    int i=0;
    if(s[0]=='0')
    {
        v1.pb(0);
    }
    repd(i,0,n-1)
    {
        if(s[i]=='0')
        {
            while(s[i]=='0')
            {
                cnt++;
                i++;
            }
            v2.push_back(cnt);
            cnt=0;
            i--;
        }
        if(s[i]=='1')
        {
            while(s[i]=='1')
            {
                cnt++;
                i++;
            }
            v1.push_back(cnt);
            cnt=0;
            i--;
        }

    }
    int num=max(sz(v1),sz(v2));
    repd(i,1,maxn-2)
    {
        v1.push_back(0);
        v2.push_back(0);
    }
    repd(i,1,maxn-2)
    {
        sum1[i]+=sum1[i-1]+v1[i-1];
        sum2[i]+=sum2[i-1]+v2[i-1];
    }
    int w=0;
    ll ans=0ll;
    repd(i,1,n-k+4)
    {
        int l=i;
        int r=l+k;
        ll temp=sum1[r]-sum1[l-1];
        temp+=sum2[r-1]-sum2[l-1];
        ans=max(ans,temp);
    }
    cout<<ans<<endl;



    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Measured memory_bytes: 3308
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

bool solve() {
    int l = s.size();
    if (s[0] == s[l-1]) {
        return l % 2 == 0;
    } else {
        return l % 2 == 1;
    }
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"First":"Second") << endl;
}

Measured memory_bytes: 512
import java.util.*;

class Main {
  static int[] a;
  static final int INIT = 2147483647;
  static ArrayList<Integer> ansArr = new ArrayList<Integer>();
  static int N = 1;

	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();

    a = new int[INIT/1000];
    while(N < n) N *= 2;n = N;
    for(int i = 0 ; i < n*2-1 ; i++) {
      a[i] = INIT;
    }

    int com,x,y = 0;
    q=q-1;
    while(q != -1) {
      com = sc.nextInt();
      x = sc.nextInt();
      y = sc.nextInt();
      if(com == 0) {
        update(x,y,n);
      } else ansArr.add(find(x,y+1,0,0,n));
      q--;
    }

    for(int ans: ansArr) System.out.println(ans);
	}

  static void update(int x, int y, int n) {
    x += n-1;
    a[x] = y;
    while(x > 0){
      x = (x - 1)/2;
      a[x] = Math.min(a[x*2+1],a[x*2+2]);
    }
  }

  static int find(int x, int y, int i, int l, int r) {
    if(r <= x || y <= l)
      return INIT;
    if(x <= l && r <= y) {
      return a[i];
    } else {
      int vl = find(x,y,i*2+1,l,(l+r)/2);
      int vr = find(x,y,i*2+2,(l+r)/2,r);
      return Math.min(vl,vr);
    }
  }
}



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

int main(){
  vector<vector<char>> c(3, vector<char>(3));
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j) cin >> c.at(i).at(j);
  }
  
  cout << c.at(0).at(0) << c.at(1).at(1) << c.at(2).at(2) << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = sum(B)
    prev = -1
    for a in A:
        if a == prev + 1:
            ans += C[a - 2]
        prev = a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n=int(input())
h=list(map(int,input().split()))
dp=[1000000000]*(n)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[n-1])

Measured memory_bytes: 13924
from collections import deque

t = int(input())
cases = [tuple(int(v) for v in input().split()) for _ in range(t)]


def get_simple_price(n, p, d, m):
    price = 0
    while n != 0:
        mod = n % m
        if mod != 0:
            price += mod * d
            n -= mod
        if n != 0:
            price += p
            n //= m
    return price


def discover(n, a, b, c, d):
    # make limit
    limit = min(
        get_simple_price(n, a, d, 2),
        get_simple_price(n, b, d, 3),
        get_simple_price(n, c, d, 5),
        n * d,
    )
    memo = {}

    queue = deque([(n, 0)])
    while len(queue) > 0:
        t, p = queue.pop()
        if t == 0:
            if p < limit:
                limit = p
            continue
        if t == 1:
            queue.append((0, p + d))
            continue
        if t in memo:
            if p < memo[t]:
                memo[t] = p
            else:
                continue
        else:
            memo[t] = p

        queue.append((0, p + t * d))
        mod = t % 2
        queue.append((t // 2, p + a + d * mod))
        if mod != 0:
            queue.append((t // 2 + 1, p + a + d * (2 - mod)))
        mod = t % 3
        queue.append((t // 3, p + b + d * mod))
        if mod != 0:
            queue.append((t // 3 + 1, p + b + d * (3 - mod)))
        mod = t % 5
        queue.append((t // 5, p + c + d * mod))
        if mod != 0:
            queue.append((t // 5 + 1, p + c + d * (5 - mod)))

    return limit


for n, a, b, c, d in cases:
    print(discover(n, a, b, c, d))


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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int west = 0,east = 0;
	int w[n],e[n];
	REP(i,n){
		if(s[i] == 'W')west++;
		w[i] = west;
	}
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == 'E')east++;
		e[i] = east;
	}
	int min = 1e9;
	REP(i,n){
		if(w[i] + e[i] < min)min = w[i] + e[i];
	}
	cout << min - 1 << endl;
}

Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var t = ReadTexts();
            var A = decimal.Parse(t[0]);
            var B = decimal.Parse(t[1]);

            return Math.Floor(A * B);
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28388
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


const vector<P> dd={{-1,0},{0,1}, {1,0}, {0,-1}};

int main(){
    int h,w; cin>>h>>w;
    vector<string> s(h);
    rep(i,h) cin>>s[i];
    vector<vector<int>> p(h,vector<int>(w,0));
    deque<P> q;
    if(s[0][0]=='#'){
        cout<<-1<<endl;
        return 0;
    }
    q.push_back({0,0});
    while(!q.empty()){
        P now=q[0];
        int nowscore=p[now.first][now.second];
        q.pop_front();
        rep(i,4){
            P kari=now;
            kari.first+=dd[i].first; kari.second+=dd[i].second;
            if(0<=kari.first && kari.first<h && 0<=kari.second && kari.second<w && s[kari.first][kari.second]=='.' && p[kari.first][kari.second]==0){
                q.push_back(kari);
                p[kari.first][kari.second]=nowscore+1;
            }
        }
    }
    if(p[h-1][w-1]==0){
        cout<<-1<<endl;
        return 0;
    }
    int cnt=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') cnt++;
        }
    }
    cout<<h*w-p[h-1][w-1]-cnt-1 <<endl;
    return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
n, m = list(map(int, input().split()))
H = np.array(list(map(int, input().split())))
A = [0]*m
B = [0] * m
path = {}

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if(a in path.keys()):
        path[a].append(b)
    else:
        path[a] = [b]
    if(b in path.keys()):
        path[b].append(a)
    else:
        path[b] = [a]
count = 0
# print(H)
for i, h in enumerate(H):
    if not (i in path.keys()):
        count += 1
        continue
    if (max(H[path[i]]) < h):
        count += 1
print(count)


Measured memory_bytes: 48288
// A - Rotation
#include<iostream>
using namespace std;
string InvertString(string a)
{
	string result;
	for(int i = a.length() - 1; i >= 0; --i)
	{
		result += a.at(i);
	}
	return result;
}

int main()
{
	string a, b;
	cin >> a;
	cin >> b;
	
	string c = InvertString(b);
	string d = InvertString(a);
	
	if(a == c && b == d)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<pii>> g(N);
	vector<int> U(M), V(M), S(M);
	
	REP(i, M) {
		scanf("%d %d %d", &U[i], &V[i], &S[i]);
		--U[i]; --V[i];
		g[U[i]].emplace_back(V[i], i);
		g[V[i]].emplace_back(U[i], i);
	}
	
	vector<int> d(N, -1);
	vector<ll> sum(N, -1);
	
	using pll = pair<ll, ll>;
	pll itv(1, longINF);
	d[0] = 0;
	sum[0] = 0;
	
	auto dfs = [&](auto &&dfs, int u, int par) -> bool {
		if (d[u] & 1) chmin(itv.se, sum[u] - 1);
		else chmax(itv.fi, -sum[u] + 1);
		
		for (pii e : g[u]) {
			int v = e.fi;
			int eidx = e.se;
			if (v == par) continue;
			if (d[v] != -1 && d[u] < d[v]) continue;
			
			if (d[v] == -1) {
				d[v] = d[u] + 1;
				sum[v] = -sum[u] + S[eidx];
				if (!dfs(dfs, v, u)) return false;
			}
			else if ((d[u] - d[v]) % 2 == 0) { // 奇閉路
				// 一意に定まる
				ll nsum = (-sum[u] + S[eidx]) * (d[u] & 1 ? -1 : 1);
				nsum += sum[v] * (d[v] & 1 ? 1 : -1);
				
				if (nsum <= 0 || nsum % 2 == 1) return false;
				else {
					ll uqd = nsum / 2;
					if (itv.fi <= uqd && uqd <= itv.se) itv = pii(uqd, uqd);
					else return false;
				}
			}
			else {
				// 偶閉路
				ll nsum = -sum[u] + S[eidx];
				if (nsum != sum[v]) return false;
			}
		}
		return true;
	};
	
	
	bool ng = false;
	ng |= !dfs(dfs, 0, -1);
	ng |= itv.fi > itv.se;
	
	if (ng) puts("0");
	else cout << itv.se - itv.fi + 1 << endl;
	return 0;
}


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

int rec[10000001] = {};

int main() {
  int a;
  cin >> a;
  for (int i = 1;; i++) {
    if (rec[a]) {
      cout << i;
      break;
    }
    rec[a] = 1;
    if (a % 2)
      a = 3 * a + 1;
    else
      a /= 2;
  }
  return 0;
}

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

using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r)
{
	if (l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve()
{
	pos = 0;
	rec(0, pre.size());
	for (int i; i < n; i++)
	{
		if (i) cout << " ";
		cout << post[i];
	}
	cout << endl;
}

int main()
{
	int k = 0;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> k;
		pre.push_back(k);
	}

	for (int i = 0; i < n; i++)
	{
		cin >> k;
		in.push_back(k);
	}

	solve();

	return 0;
}


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

int cnt[100100];
bool red[100100];

int main() {
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < 100100; i++) {
		cnt[i] = 1;
		red[i] = false;
	}
	red[0] = true;

	for(int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cnt[x]--;
		cnt[y]++;
		if(red[x])
			red[y] = true;
		if(cnt[x] == 0)
			red[x] = false;
	}

	int res = 0;
	for(int i = 0; i < N; i++)
		res += red[i];
	cout << res << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	cin>>a;
	for(int s=1;s<a.size();s++)
	{
		if(a[s]==a[s-1])
		{
			cout<<s<<" "<<s+1<<endl;
			return 0;
		}
	}
	for(int s=2;s<a.size();s++)
	{
		if(a[s]==a[s-2])
		{
			cout<<s-1<<" "<<s+1<<endl;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> s;
    x = 0;
    for(int i = 0; i < 4; ++i)
        x += (s[i] == '2');
    cout << x << endl;
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(c-a)<=d || abs(c-b)<=d && abs(a-b)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}

//経路復元なしDijkstra法
template<class T> 
vector<T> dijkstra(int start, const vector<vector<pair<int,T>>>& Hen){
	T INF = numeric_limits<T>::max();
	int N = Hen.size();
	vector<T> dist(N, INF);
	vector<bool> seen(N);
	dist[start] = 0;
	priority_queue<pair<T,int>, vector<pair<T,int>>, greater<pair<T,int>>> que;
	que.emplace(0, start);
	while(que.size()) {
		int ver = que.top().second;
		T cost = que.top().first; que.pop();
		if(seen[ver])continue;
		seen[ver] = true;
		for(auto i : Hen[ver]) {
			if(dist[i.first] > cost + i.second) {
				dist[i.first] = cost + i.second;
				que.emplace(dist[i.first], i.first);
			}
		}
	}
	return dist;
}


int main()
{
    vector<tuple<double, double, double>> pos;
    {
        double xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb;
        pos.push_back({xa, ya, 0}), pos.push_back({xb, yb, 0});
    }
    int n; cin >> n;
 
    for(int i = 0; i < n; i++) {
        double x, y, r; cin >> x >> y >> r;
        pos.push_back({x, y, r});
    }
 
    vector<vector<pair<int,double>>> hen(n + 2);
    for(int i = 0; i < n + 2; i++) {
        for(int j = i + 1; j < n + 2; j++) {
            double xa, ya, ra, xb, yb, rb, dist;
            tie(xa, ya, ra) = pos[i], tie(xb, yb, rb) = pos[j];
            dist =  sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) - (ra + rb);
            dist = max(dist, 0.0);
            hen[i].push_back({j, dist});
            hen[j].push_back({i, dist});
        }
    }
 
    cout << fixed <<setprecision(12) << dijkstra(0,hen)[1] << '\n';
 
 
}

Measured memory_bytes: 23796
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 2), 25)

    def test_2(self):
        self.assertEqual(think(8, 10), 100)

    def test_3(self):
        self.assertEqual(think(19, 99), -1)


def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    max_a = 100
    min_tax = 0.08
    ceil = int(max_a / min_tax) + 1
    for c in range(1, ceil + 1):
        tax_a = int(c * 0.08)
        tax_b = int(c * 0.10)
        if a == tax_a and b == tax_b:
            return c
    return -1


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 50156
#include<iostream>
using namespace std;
int N,cnt[1<<17];
long mod=998244353;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		if(A==0)
		{
			if(i!=0)
			{
				cout<<0<<endl;
				return 0;
			}
		}
		else
		{
			if(i==0)
			{
				cout<<0<<endl;
				return 0;
			}
		}
		cnt[A]++;
	}
	long ans=1;
	for(int i=1;i<N;i++)
	{
		ans=ans*power(cnt[i-1],cnt[i])%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  
  while(true){
    int n = sc.nextInt();
    if(n==0) break;
    int[] a = new int[n];
    int maxn=0,minn=0,Ave=0;
    for(int i=0;i<n;i++){
      a[i] = sc.nextInt();
      if(i==0){
        maxn=a[0];
        minn=a[0];
      }else{
        if(maxn<a[i]) maxn=a[i];
        if(minn>a[i]) minn=a[i];
      }
      Ave+=a[i];
    }
    Ave=Ave-maxn-minn;
    System.out.printf("%d\n",Ave/(n-2));
  }
  sc.close();
  }
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int A, B, C;
    std::cin >> A >> B >> C;

    if(A == B && B == C){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
main(b,r,g,c,s,t) {
	for(;~scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t)&&t;)printf("%d\n", b*95 + r*63 + g*7 + c*2 + s*3 - t*3 + 100);
}

Measured memory_bytes: 600
N, K = map(int, input().split())

# K|2a,2b,2cなので
# K:oddのときは2とKが互いに素なのでK|a,b,c
# よってa,b,cがN以下のKの倍数となる個数を数えれば良い
# K:evenのときはK=2L,L=K/2としてK/2|a,b,c
# ただしKで割った時のあまりは一致していないと条件を満たさない
# よってa,b,cがN以下のKの倍数となる個数と、N以下のKで割ってK/2余る個数を数えれば良い
# N以下のKで割ってK/2余る個数は(N + K/2)//Kで求まる
if K % 2 == 1:
    ans = (N // K) ** 3
else:
    ans = (N // K) ** 3 + ((N + K // 2) // K) ** 3

print(ans)

Measured memory_bytes: 2940
N, P = map(int, input().split())
S = input()

cnt = 0
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            cnt += (i+1)
            
else:
    dic = dict()
    dic[0] = 1
    r = 0
    for i in range(N):
        s = (pow(10,i,P)*int(S[N-1-i]) + r) % P
        r = s
        if not s in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    for i in dic:
        cnt += dic[i]*(dic[i]-1)/2
        
print(int(cnt))

Measured memory_bytes: 42700
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut acc = vec![0; n + 2];
    for i in 0..n {
        acc[i + 2] = acc[i] + a[i];
    }
    let tot: i64 = a.iter().sum();
    for i in 0..n {
        let tmp = tot / 2 - acc[i] - (acc[n + (i % 2)]
                                      - acc[i + 1]);
        puts!("{}\n", 2 * tmp);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 11644
import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))

for i in range(N):
    A[i]*=-1
#print(A)
heapq.heapify(A)
for i in range(M):
    temp=heapq.heappop(A)
#    print(temp)
    heapq.heappush(A,temp//2+temp%2)
    
print(-sum(A))

Measured memory_bytes: 14180