akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>



bool work()
{
	int left = 1;
	char matrix[16][16];
	int h,w;
	scanf("%d%d", &h, &w);
	for(int i=0; i<h; ++i)
	{
		matrix[i][0] = '.';
		scanf("%s", &matrix[i][1]);
		matrix[i][w+1] = '.';
	}
	for(int i=0; i<h; ++i)
	{
		if(matrix[i][left] != '#') return false;
		for(int j=left-1; j>0; --j)
		{
			if(matrix[i][j]=='#')
			{
				return false;
			}
		}
		for(; left <= w; ++left)
		{
			if(matrix[i][left+1] == '.')
				break;
		}
		for(int j=left+1; j<=w; ++j)
		{
			if(matrix[i][j] == '#')
				return false;
		}
	}
	return left == w;
}
int main()
{
	if(work())
	{
		printf("Possible\n");
	}
	else
	{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
       Scanner scan=new Scanner(System.in);

        String o=scan.next();
        String e=scan.next();

        StringBuilder sb=new StringBuilder();
        boolean jdg=false;

        int iend=0;
        if(o.length()==e.length()) {
            iend=o.length();
            jdg=true;
        }
        else {
            iend = Math.min(o.length(), e.length());
        }


            for(int i=0;i<iend;i++){
                sb.append(o.charAt(i));
                sb.append(e.charAt(i));

            }
        if(!jdg){
            if(o.length()>e.length())
            sb.append(o.charAt(o.length()-1));
            else
                sb.append(e.charAt(e.length()-1));
        }

        System.out.println(sb);

    }
}

Measured memory_bytes: 23124
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
 
ll ans[100010];
 
int main(){
  ll N,p;
  cin >> N;
  REP(i,N){
    cin >> p;
    ans[p]=i+1;
  }
  REP(i,N){
    cout << ans[i+1] <<" ";
  }
}


Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int N = Integer.parseInt(tmp[0]);
		int M = Integer.parseInt(tmp[1]);

		List<Integer> L = new ArrayList<Integer>();
		List<Integer> R = new ArrayList<Integer>();

		for(int i = 0;i<M;i++){
			tmp = br.readLine().split(" ");
			L.add(Integer.parseInt(tmp[0]));
			R.add(Integer.parseInt(tmp[1]));
		}

		L.sort(null);
		R.sort(null);
		int max = R.get(0);
		int min = L.get(L.size()-1);

		if(max-min+1<0){
			System.out.println(0);
		}else{
			System.out.println(max-min + 1);
		}



	}
}


Measured memory_bytes: 49196
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;


int dp[2][110]; // dp[i][j] : i,j まずでの最大値

int main(){
    int n; cin >> n;
    vector<vector<int> > v(3,vector<int>(n+1));
    REP(i,n) cin >> v[0][i];
    REP(i,n) cin >> v[1][i];
    dp[0][0] = v[0][0];
    REP(i,2){
        REP(j,n){
            chmax(dp[i][j+1], dp[i][j] + v[i][j+1]); // yoko
            chmax(dp[i+1][j], dp[i][j] + v[i+1][j]);
        }
    }
    cout << dp[1][n-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> P(N), C(N);
    rep(i,N){
        cin >> P[i];
        P[i]--;
    }
    rep(i,N){
        cin >> C[i];
    }
    ll ans = -1e18;
    rep(i,N){
        ll cur = i;
        ll sum = 0;
        vector<ll> s;
        while(1){
            cur = P[cur];
            s.push_back(C[cur]);
            sum += C[cur];
            if(cur == i) break;
        }
        ll l = s.size();
        ll t = 0;
        rep(j,l){
            t += s[j];
            if(j+1 > K) break;
            ll now = t;
            if(sum > 0){
                ll e = (K-(j+1))/l;
                now += sum*e;
            }
            cmax(ans, now);
        }
    }
    cout << ans << endl;
    /*
    rep(i,N){
        ll Msc = -1e18;
        ll cur = i; 
        ll cnt = 0;
        ll sum = C[P[cur]];
        cnt++;
        vector<ll> memo(N);
        vector<ll> S(N+10);
        memo[P[cur]] = cnt;
        S[cnt] = sum;
        cmax(ans,sum);
        cur = P[cur];
        rep(j,min(N+10,K-1)){
            if(memo[P[cur]] > 0){
                break;
            }
            sum += C[P[cur]];
            cnt++;
            S[cnt] = sum;
            memo[P[cur]] = cnt;
            cur = P[cur];
            cmax(ans,sum);
        }
        cmax(ans, sum);
        if(K <= N) continue;
        cnt = memo[cur] - memo[P[cur]] + 1;
        sum = S[memo[cur]];
        //if(sum <= 0) continue;

        ll q = ll(K/cnt) - 1;
        ll r = K%cnt;
        sum = sum*q;
        cur = i;
        rep(j, cnt+r){
            sum += C[P[cur]];
            cur = P[cur];
            cmax(ans, sum);
        }        
        cmax(ans, sum);
    }
    cout << ans << endl;*/
}

Measured memory_bytes: 3796
#include<stdio.h>
#define N 101

int main(){
  int a[N],i,j,n,p,t,q,m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(p=0;p<n;p++){
    printf("%d",a[p]);
  if(p!=n-1){
      printf(" ");
    }
  }printf("\n");

  for(i=1;i<n;i++){
    t=a[i];
    j=i-1;
    while(j>=0&&a[j]>t){
      a[j+1]=a[j];
      j--;
    }a[j+1]=t;
    for(p=0;p<n;p++){
      printf("%d",a[p]);
    if(p!=n-1){
        printf(" ");
      }
    }printf("\n");
  }
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define PB push_back
#define BE(C) C.begin(),C.end()
using namespace std;
typedef long long LL;
typedef int usetype;
typedef pair<usetype,usetype> pr;
typedef pair<usetype,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef map<usetype,usetype> MP;
typedef vector<usetype> VI;
const int INF=1LL<<30;
const int SQ=100;
const int SIZE=100000;
Vpr edge[SIZE+1];
Vppr edgeAll;
bool unit[SIZE+1];
int dist[SIZE+1];
bool isFesta[SIZE+1];
int master[SIZE+1][30];
int tall[SIZE+1];
int cost[SIZE+1][30];
int N,M,K,Q;
int tops;
ppr pprs(int a,int b,int c){return ppr(a,pr(b,c));}
void dijkstra(){
	PQ qu;
	int k;
	FOR(i,1,N+1)
		dist[i]=INF;
	REP(i,K){
		scanf("%d",&k);
		qu.push(pr(0,k));
		isFesta[k]=true;
		dist[k]=0;
	}
	int dis,now;
	while(!qu.empty()){
		dis=qu.top().F;
		now=qu.top().S;
		qu.pop();
		if(dis!=dist[now]) continue;
		REP(i,edge[now].size()){
			int next=edge[now][i].S;
			int nextDist=edge[now][i].F;
			if(dist[next]>dis+nextDist){
				dist[next]=dis+nextDist;
				qu.push(pr(dist[next],next));
			}
		}
	}
}
void prim(){
	priority_queue<ppr,Vppr> qu;
	int unioned=0;
	FOR(i,1,N+1)
		if(!isFesta[i]){
			qu.push(pprs(dist[i],i,0));
			break;
		}
	int now;
	int from;
	int next;
	while(unioned<N){
		while(!qu.empty() && unit[qu.top().S.F]) qu.pop();
		now=qu.top().S.F;
		from=qu.top().S.S;
		master[now][0]=from;
		unit[now]=true;
		tall[now]=tall[from]+1;
		qu.pop();
		REP(i,edge[now].size()){
			next=edge[now][i].S;
			qu.push(pprs(min(dist[now],dist[next]),next,now));
		}
		unioned++;
	}
}
void LCA(){
	FOR(i,1,30)
		FOR(j,1,N+1)
			master[j][i]=master[master[j][i-1]][i-1];
	FOR(i,1,N+1)
		cost[i][0]=dist[i];
	FOR(i,1,30)
		FOR(j,1,N+1)
			cost[j][i]=min(cost[j][i-1],cost[master[j][i-1]][i-1]);
	
}
int query(int a,int b){
	if(tall[a]<tall[b]) return query(b,a);
	int minium=cost[a][0];
	int now=a;
	int need=tall[a]-tall[b];
	REP(i,25){
		if(need&(1<<i)){
			minium=min(cost[now][i],minium);
			now=master[now][i];
		}
	}
	int nowa=now,nowb=b;
	for(int j=25;j>=0;j--){
		if(master[nowa][j]!=master[nowb][j]){
			minium=min(min(cost[nowa][j],cost[nowb][j]),minium);
			nowa=master[nowa][j];
			nowb=master[nowb][j];
		}
	}
	if(nowa!=nowb)
		minium=min(minium,min(cost[nowa][1],cost[nowb][1]));
	minium=min(minium,min(cost[nowa][0],cost[nowb][0]));
	return minium;
}
int main(){
	cin >> N >> M >> K >> Q;
	int a,b,c;
	REP(i,M){
		scanf("%d%d%d",&a,&b,&c);
		edge[a].push_back(pr(c,b));
		edge[b].push_back(pr(c,a));
	}
	dijkstra();
	prim();
	LCA();
	REP(i,Q){
		scanf("%d%d",&a,&b);
		printf("%d\n",query(a,b));
	}
	return 0;
}

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

int main() {
    string n;
    cin >> n;
    int cnt = 0;
    rep(i, 3) {
        if (n[i] == '7') ++cnt;
    }
    if (cnt > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# 小区間ごとに個数を数えて足し合わせると，
# summationの中身がxとyについて独立になっている

n,m = LI()
x = LI()
y = LI()

xsum = 0
for i in range(n-1):
    xsum += (i+1)*(n-i-1)*(x[i+1]-x[i])
    xsum %= mod

ysum = 0
for j in range(m-1):
    ysum += (j+1)*(m-j-1)*(y[j+1]-y[j])
    ysum %= mod

print(xsum*ysum%mod)

Measured memory_bytes: 75928
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int n;

bool query(vector<int> v){
	cout<<'?';
	REP(i,SZ(v)) cout<<' '<<v[i]+1;
	cout<<endl;
	string s;
	cin>>s;
	return s[0]=='R';
}
bool query(int l){
	cout<<'?';
	for(int i=l;i<l+n;i++) cout<<' '<<i+1;
	cout<<endl;
	string s;
	cin>>s;
	return s[0]=='R';
}

string ans;

int main(){
	IOS;
	cin>>n;
	if(n==1){
		if(query(0)) cout<<"! RB"<<endl;
		else cout<<"! BR"<<endl;
		return 0;
	}
	ans.resize(n+n);
	int idx;
	{
		bool pre=query(0);
		int l=0,r=n;
		while(l!=r-1){
			int mid=(l+r)/2;
			if(query(mid)==pre) l=mid;
			else r=mid;
		}
		idx=r;
		if(pre){
			ans[idx-1]='R';
			ans[idx+n-1]='B';
		}
		else{
			ans[idx-1]='B';
			ans[idx+n-1]='R';
		}
	}
	REP(i,n+n){
		if(i==idx-1||i==idx+n-1) continue;
		if(i<idx-1||i>idx+n-1){
			vector<int> tmp;
			for(int j=idx;j<idx+n-1;j++) tmp.pb(j);
			tmp.pb(i);
			bool meow=query(tmp);
			if(meow) ans[i]='R';
			else ans[i]='B';
		}
		else{
			vector<int> tmp;
			REP(j,n+n) if(j<idx-1||j>idx+n-1) tmp.pb(j);
			tmp.pb(i);
			bool meow=query(tmp);
			if(meow) ans[i]='R';
			else ans[i]='B';
		}
	}
	cout<<"! "<<ans<<endl;
	return 0;
}


Measured memory_bytes: 724
def main():
    H, W = map(int, input().split())
    board = [list(input()) for i in range(H)]

    check = [[False] * W for i in range(H)]

    count = 0
    for i in range(H):
        for j in range(W):
            if not check[i][j]:
                if board[i][j] == ".":
                    check[i][j] = True
                    count += 1
                else:
                    ok = False
                    for tx, ty in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:
                        if 0 <= tx and tx < H and 0 <= ty and ty < W:
                            if board[tx][ty] == "#":
                                ok = True
                                if not check[tx][ty]:
                                    check[tx][ty] = True
                                    count += 1
                    if ok:
                        check[i][j] = True
                        count += 1
    if count == H*W:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()





Measured memory_bytes: 3064
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n,m;cin>>n>>m;
    if(n==1 and m==1){
        cout<<1<<endl;
        return false;
    }
    if(n==1){
        cout<<max<ll>(0,m-2)<<endl;
        return false;
    }
    if(m==1){
        cout<<max<ll>(0,n-2)<<endl;
        return false;
    }
    ll ans=(n-2)*(m-2);
    cout<<ans<<endl;
    
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


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

#define mod 1000000007



using namespace std;

int main() {
    int N;
    string a = "ACL";
    string b = "";
    cin >> N ;
     
    for(int i = 0; i < N; i++){
        b = b + a;
    }

    cout << b << endl;
}



Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n << endl;
    } else {
        cout << 2 * n << endl;
    }
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll A[N], B[N];
  REP(i, N) { cin >> A[i] >> B[i]; }

  ll ans = 0;
  REPR(i, N - 1) {
    ll res = (A[i] + ans) % B[i];
    if (res != 0) {
      ans += B[i] - res;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
N, W = map(int, raw_input().split())
INF = 0x3f3f3f3f
obj = []
for i in xrange(N):
    w, v = map(int, raw_input().split())
    obj.append((w, v))
dp = [[INF for _ in xrange(100001)] for i in xrange(N)]

w, v = obj[0]
dp[0][0] = 0
dp[0][v] = w
for i in xrange(1, N):
    w, v = obj[i]
    for j in xrange(100001):
        if dp[i-1][j] != INF:
            dp[i][j] = dp[i-1][j]
    for j in xrange(v, 100001):
        if dp[i-1][j-v] != INF and dp[i-1][j-v]+w <= W:
            dp[i][j] = min(dp[i][j], dp[i-1][j-v]+w)
res = 0
for i in xrange(100001):
    if dp[N-1][i] != INF:
        res = i
print res


Measured memory_bytes: 112912
def next_start(S, F):
    for i in range(S, S + F + 1):
        if i % F == 0:
            return i


N = int(input())
Cs, Ss, Fs = [], [], []

for i in range(N - 1):
    tmp = list(map(int, input().split()))
    Cs.append(tmp[0])
    Ss.append(tmp[1])
    Fs.append(tmp[2])


for nth in range(N - 1):
    t = 0
    for i in range(nth, N - 1):
        # print(i, nth, t)
        t = max(Ss[i], next_start(t, Fs[i]))
        # print('\t\t', i, nth, t)
        t += Cs[i]
        # print('\t', i, nth, t)
    print(t)
print(0)


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

int main(){
    long d,n; cin >> d >> n;
    long x = pow(100,d);
    long ans_1 = x*n+pow(100,d);
    if(n == 100){
        cout << ans_1;
    }
    else cout << x * n;
}


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

using namespace std;

using vi = vector<int>;

const int Z = 1e9+7;

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

    int n, k;
    cin >> n >> k;
    vi a0, a1, a2;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;

        if (t > 0) {
            a2.push_back(t);
        } else if (t == 0) {
            a1.push_back(t);
        } else {
            a0.push_back(t);
        }
    }

    sort(a0.begin(), a0.end());
    sort(a2.begin(), a2.end());

    int ans = 1;
    if ((int)a0.size() + (int)a2.size() < k) {
        ans = 0;
    } else if (a2.size() > 0) {
        if (k % 2 == 1) {
            ans = a2.back();
            a2.pop_back();
            k--;
        }

        for (int i = 0, p = 0, q = (int)a2.size() - 1; i < k; i += 2) {
            if ((p + 1 >= (int)a0.size() && q - 1 >= 0) || (q - 1 >= 0 && 1ll * a2.at(q) * a2.at(q - 1) >= 1ll * a0.at(p) * a0.at(p + 1))) {
                ans = 1ll * ans * a2.at(q) % Z * a2.at(q - 1) % Z;
                q -= 2;
            } else if ((q - 1 < 0 && p + 1 < (int)a0.size()) || (p + 1 < (int)a0.size() && 1ll * a0.at(p) * a0.at(p + 1) >= 1ll * a2.at(q) * a2.at(q - 1))) {
                ans = 1ll * ans * a0.at(p) % Z * a0.at(p + 1) % Z;
                p += 2;
            } else if (a1.size() > 0) {
                ans = 0;
            } else {
                ans = 1ll * ans * a2.at(q) % Z * a0.at(p) % Z;
                p++, q--;
            }
        }
    } else if (k % 2 == 0) {
        for (int i = 0; i < k; i++) {
            ans = 1ll * ans * a0.at(i) % Z;
        }
    } else if (a1.size() > 0) {
        ans = 0;
    } else {
        for (int i = 0; i < k; i++) {
            ans = 1ll * ans * a0.at(a0.size() - 1 - i) % Z;
        }
    }

    ans = (ans + Z) % Z;

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, M, city[51], a, b;
  cin >> N >> M;
  for (int i = 0; i <= N; i++) {
    city[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    city[a]++;
    city[b]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << city[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

struct edge{long long to,cost;};
typedef pair<long long,long long> P;

vector<edge> G[100010];// 隣接リスト表現
long long d[100010];

void dijkstra(int s,int n){
    priority_queue<P,vector<P>,greater<P> > que;// 距離が小さい順に取り出せるようgreater<P>を指定
    fill(d,d+n,INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;// 更新した頂点の中で距離が最小の頂点v
        if(d[v]<p.first)continue;
        for(auto e:G[v]){// 頂点vから出る辺eを走査
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(){
   int n,q,k;
   cin>>n;
   vector<long long> a(n),b(n),c(n);
   for(int i=0;i<n-1;i++){
       cin>>a[i]>>b[i]>>c[i];
       a[i]--;b[i]--;
       G[a[i]].push_back({b[i],c[i]});
       G[b[i]].push_back({a[i],c[i]});
   }
   cin>>q>>k;
   k--;
   dijkstra(k,n);
   vector<long long> x(q),y(q);
   for(int i=0;i<q;i++){
       cin>>x[i]>>y[i];
       x[i]--;y[i]--;
   }
   for(int i=0;i<q;i++){
       cout<<d[x[i]]+d[y[i]]<<endl;
   }
}
 
   

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

int main() {
    int n;
    cin >> n;
    int t[n], x[n], y[n];
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }

    string ans = "Yes";
    int nx = 0, ny = 0, road = 0, time = 0;
    for (int i = 0; i < n; i++) {
        road = (abs(nx - x[i]) + abs(ny - y[i]));

        if(i == 0) time = t[i];
        else time = t[i] - t[i-1];

        if (road > time || abs(road - time) % 2 == 1) {
            ans = "No";
            break;
        }
        nx = x[i];
        ny = y[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import math
def isprime(x):
    if x == 2:
        return 1
    
    if x < 2 or x % 2 == 0:
        return 0
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return 0
        i = i + 2
    return 1
    
n = int(input())
cnt = 0
for i in range(n):
    cnt += isprime(int(input()))
print(cnt)


Measured memory_bytes: 5676
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int temp;
        scanf("%d", &temp);
        A.push_back(temp);
    }
    sort(A.begin(), A.end());

    int minimum = A[0];
    int maximum = A[N - 1];

    vector<P> result;

    for (int i = 1; i < N - 1; i++) {
        if (A[i] >= 0) {
            result.push_back(make_pair(minimum, A[i]));
            minimum -= A[i];
        } else {
            result.push_back(make_pair(maximum, A[i]));
            maximum -= A[i];
        }
    }
    result.push_back(make_pair(maximum, minimum));
    
    cout << maximum - minimum << endl;

    for (int i = 0; i < result.size(); i++) {
        cout << result[i].first << " " << result[i].second << endl;
    }

    return 0;
}

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

int main(){
	double a,b,c,d,e,f,g,h=0;
	cin>>a>>b>>c>>d;
	e=c-a;
	f=d-b;
	g=e*e+f*f;
	h=sqrt(g);
	cout <<setprecision(12)<<h <<endl;
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#define int long long
using namespace std;
const int oo=1000000007;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	vector<int> v(n+100);
	for (int i=0; i<m; ++i){
		int a;
		cin >> a;
		v[a]=-1;
	}
	if (v[0] != -1) v[0]=1;
	for (int i=0; i<=n; ++i){
		if (v[i] == -1) continue;
		if (v[i+1] != -1) v[i+1] += v[i];
		if (v[i+2] != -1) v[i+2] += v[i];
		v[i+1] %= oo;
		v[i+2] %= oo;
	}
	cout << v[n];
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
#define PI 3.14159265
const ll mod = 998244353;
int ans, vf=-1, l[100001];
string s;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(vf!=-1 && s[l[vf]]!=s[i]){
            ans++;
            vf--;
        }
        else l[++vf]=i;
    }
    cout<<ans*2;
}


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

const int N = 105;

int cache[N][N];

int dp(int x, int y)
{
	int &ans = cache[x][y];
	if(ans != -1)
		return ans;
	ans = 0;
	for(int i = 1; i * 2 <= x; i++)
		ans |= !(dp(x - 2 * i, y + i));
	for(int i = 1; i * 2 <= y; i++)
		ans |= !(dp(x + i, y - 2 * i));
	return ans;
}

int32_t main()
{
	IOS;
	int x, y;
	cin >> x >> y;
	if(abs(x -  y) >= 2)
		cout << "Alice" << endl;
	else
		cout << "Brown" << endl;
	return 0;
}

Measured memory_bytes: 3640
//package com.zhangyong.algorithm;

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        private FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        private FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }


    private void solve() {
        int a, b, c;
        a = in.nextInt();
        b = in.nextInt();
        c = in.nextInt();
        if ((c >= a) && (c <= b)) {
            out.print("Yes");
        } else {
            out.print("No");
        }
    }

    private void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

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


Measured memory_bytes: 21076
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, n) for (size_t i = 0; i < (n); i++)
#define REP(n) FOR(i, n)
#define cinv(v, n) REP(n) {cin>>(v)[i];}
#define nvec(T, v, n) vector<T> v(n); cinv(v, n)
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define pub push_back
#define pof pop_front
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}

int main(){
  char c;
  cin>>c;
  cout<<char(c+1);
}






/* きょむ〜 */

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<cstdio>
int main(){
  int N;
  double sum = 0;
  std::string s;
  std::cin >> N;
  int* x = new int[N];
  int* y = new int[N];
  for(int i=0;i<N;i++)
    std::cin >> x[i] >> y[i];

  for(int i=0;i<N;i++)
    for(int j=i+1;j<N;j++){
      double t = std::sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  	  sum += t;
    }
  
  sum *= 2;
  sum /= N;
  
      
  //std::cout << sum << std::endl;
  printf("%.10f\n",sum);
  delete x;
  delete y;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 998244353;

int32_t main()
{
	FAST_IO;
	
	int n;
	cin >> n;
	
	if (n&1) cout << 0 << endl;
	else {
		int t = n/2;
		int ans = 0;
		int e = 5;
		for (int i = 1; i <= 26; i++) {
			ans += (t/e);
			e *= 5;
		}
		
		cout << ans << endl;
	
	}
}


// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


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

char B[102][102];
bool isOK = false;
void setBlock(int c,int d,int x,int y){
	char Cl = '\0';
	switch(c){
		case 1:Cl='W';break;
		case 2:Cl='Y';break;
		case 3:Cl='G';break;
		case 4:Cl='B';break;
		case 5:Cl='R';break;
	}
	if(d == 0){
		for(int i = x; i <= x+3;i++){
			for(int  j = y;j <= y+1;j++){
				B[i][j] = Cl;
			}
		}
	}else{
		for(int i = x; i <= x+1;i++){
			for(int  j = y;j <= y+3;j++){
				B[i][j] = Cl;
			}
		}
	}
}

void Check(int x, int y,int xG,int yG,char c){
	if(B[x][y] != c || isOK){
		return;
	}
	B[x][y] = '.';
	if(x == xG && y == yG){
		isOK=true;
		return;
	}	
	Check(x  ,y-1,xG,yG,c);
	Check(x+1,y  ,xG,yG,c);
	Check(x  ,y+1,xG,yG,c);
	Check(x-1,y  ,xG,yG,c);
}

int main(){
	int W,H,xS,yS,xG,yG,n;
	while(cin >> W >> H){
		isOK=false;
		if(W == 0 && H == 0){
			break;
		}
		cin >> xS >> yS >> xG >> yG >> n;		
		for(int i = 0;i < n;i++){
			int c,d,x,y;
			cin >> c >> d >> x >> y;
			setBlock(c,d,x,y);
		}
		Check(xS,yS,xG,yG,B[xS][yS]);
		if(isOK){
			cout << "OK\n";
		}else{
			cout << "NG\n";
		}
	}
	return 0;
}


Measured memory_bytes: 1128
def examA():
    N, M = LI()
    l = 1; r = N
    for _ in range(M):
        L, R = LI()
        l = max(L,l)
        r = min(R,r)
    ans = max(0,r-l+1)
    print(ans)
    return

def examB():
    N = I()
    S = [I()for _ in range(N)]
    rest = []
    for s in S:
        if s%10==0:
            continue
        rest.append(s)
    if sum(S)%10==0:
        if not rest:
            print(0)
            return
        ans = sum(S) - min(rest)
    else:
        ans = sum(S)
    print(ans)
    return

def examC():
    N, K = LI()
    K -= 1
    A = LI()
    L = A.index(1)
    #print(L)
    ans = (N-1+K-1)//K
    print(ans)
    return

def examD():
    def ketadp(a):
        n = len(a)
        dp = defaultdict(int)
        dp[0, 0, 0, 0, 0] = 1
        for i, less, has3, has5, has7 in itertools.product(range(n), (0, 1), (0, 1), (0,1), (0,1)):
            max_d = 7 if less else int(a[i])
            for d in range(max_d + 1):
                if d==0 and has3==0 and has5==0 and has7==0:
                    dp[i + 1, 1, has3, has5, has7] += dp[i, less, has3, has5, has7]
                if not (d==3 or d==5 or d==7):
                    continue
                less_ = less or d < max_d
                has3_ = has3 or d == 3
                has5_ = has5 or d == 5
                has7_ = has7 or d == 7
                dp[i + 1, less_, has3_, has5_, has7_] += dp[i, less, has3, has5, has7]

        ans = sum(dp[n, less, 1, 1, 1] for less in (0, 1))
        return ans
    N = SI()
    ans = ketadp(N)
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if(k <= a + b) cout << a << endl;
       else cout << a - (k - a - b) << endl;


	return 0;
}

Measured memory_bytes: 3628
ls = []
for i in range(3):
  a,b = list(map(int, input().split()))
  ls.append(a)
  ls.append(b)
#print(ls)

c1 = ls.count(1)
c2 = ls.count(2)
c3 = ls.count(3)
c4 = ls.count(4)
lst = [c1,c2,c3,c4]

if lst.count(2) == 2 and lst.count(1) == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
import math
def isPrime(x):
  p = True
  for i in range(2, math.ceil(math.sqrt(x)), 1):
    if x % i == 0:
      p = False
  return p

x = int(input())

while True:
  if isPrime(x):
    print(x)
    break
  else:
    x += 1

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const int INF = 1001001001;
const double pi = acos(-1);

ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    ll m, n;
    cin >> m >> n;
    cout << modpow(m, n, 1000000007) << endl;

    return 0;
}



Measured memory_bytes: 3116
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        AtCoder problem = new AtCoder(sc);
        problem.solve(out);
        
        out.flush();
    }
    
}

class AtCoder {
    final int N,K;
    char[] ch;
    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        K = sc.nextInt();
        ch = sc.next().toCharArray();
    }

    void solve(PrintWriter out) {
        ch[K-1] = Character.toLowerCase(ch[K-1]);
        out.println(ch);
    }
    
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
    
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
    
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
# 解説見てAC
# 愚直解法 = O(N^3)でTLE
# 累積和を入れても、O(N^2)でTLE

# S_k をA_1からA_kまでの和として
# 条件を満たす←→S_(l-1)とS_rをMで割ったあまりが等しい
# Mが十分大きいので、Mで割った余りを配列で取るのはダメ、平衡二分木かハッシュマップ（辞書、dict）を使う

n_box, kids = list(map(int, input().split()))
nums = list(map(int, input().split()))

residue_num = {}
residue_num[0] = 1  # S_0のぶん
summ = 0
for i in range(n_box):
    summ += nums[i]
    r = summ % kids
    residue_num[r] = residue_num.get(r, 0) + 1

ans = 0
for i in residue_num.values():
    ans += i * (i-1) // 2

print(ans)


Measured memory_bytes: 14424
N = int(input())
mylist = list(map(int , input().split(" ")))
result = 1

if 0 in mylist:
    result = 0

else:
    for i in mylist:
        
        if result * i > 10 ** 18:
            result = -1
            break
        else:
            result *= i
            
print(result)

Measured memory_bytes: 21648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        if (N <= 8) {
            System.out.println(N);
        } else {
            int nl = String.valueOf(N).length();
            int[] na = new int[nl];
            for (int i = 0; i < nl; i++) {
                na[nl - i - 1] = (int)(N % 10);
                N /= 10;
            }

            boolean f = false;
            for (int i = 1; i < nl; i++) {
                if (na[i] != 9) {
                    f = true;
                }
            }

            if (f) {
                for (int i = 1; i < na.length; i++) {
                    na[i] = 9;
                }
                na[0] = na[0] - 1;
            }
            /*
            for (int i = 0; i < nl; i++) {
                System.out.println(na[i]);
            }
            */

            int ans = 0;
            for (int i = 0; i < nl; i++) {
                ans += na[i];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2e5+5;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int x = 0, t = 0;
	cin >> x >> t;
	if(x <= t){
		cout << 0 << endl;
	}
	else{
		cout << x - t << endl;
	}

    return 0;
}	

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

int main() {
    //cout<<fixed<<setprecision(7);
    int N;
    cin >> N;
  if (N%2 == 0) {
    cout << 0.5000000000<< endl;
  }
  else {
      double ans =(double) (((N-1)/2)+1)/N;
    cout << ans<< endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    
    if(s[a]!='-'){
        cout<<"No";
        return 0;
    }
    for(int i=0; i<s.size(); i++){
        if(i!=a && (s[i]>'9' || s[i]<'0')){
            cout<<"No";
            return 0;
        }
        
        
    }
    
    cout<<"Yes";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> v(100005);
    rep(i, n){
        int a;
        cin >> a;
        v[a]++;
    }

    int kind = 0;
    rep(i, 100005) kind += (v[i] != 0);
    
    if(kind%2 == 1) cout << kind << endl;
    else cout << (kind - 1) << endl;
}

Measured memory_bytes: 768
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int n = sc.nextInt();
		int sum = 0;

		while(n-- > 0){
			String ss = sc.next();
			int m = ss.length();

			while(m-- > 0){
				if(ss.contains(s)){
					sum++;
					break;
				}
				ss = ss.substring(1) + ss.charAt(0);
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string toUpper( string s ){
    string t = s;
    for ( int i = 0; i < s.size(); i++ ){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string target, source;
    
    cin >> target;
    target = toUpper(target);
    
    int cnt = 0;
    
    while(1){
        cin >> source;
        if ( source == "END_OF_TEXT" ) break;
        source = toUpper(source);
        if ( target == source ) cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val a = sc.nextInt                 // 入力Aを受け付けて、aに格納する
  val b = sc.nextInt                 // 入力Bを受け付けて、bに格納する
  val c = sc.nextInt                 // 入力Cを受け付けて、cに格納する
  val d = sc.nextInt
  //println(((k+a-1)/a)*a)
  val n = (x:Int, y:Int)=>(x+y-1)/y
  val res = if(n(a,d)>=n(c,b))"Yes"else"No"

  println(res)                       // 結果を出力する
}

Measured memory_bytes: 55368