akhauriyash/Code-Regression huggingface dataset:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B=MI()
    if(A*B<=0):
        print("Zero")
    else:
        if(A>0):
            print("Positive")
        else:
            if((B-A+1)&1):
                print("Negative")
            else:
                print("Positive")

if __name__ == '__main__':
    main()

Measured memory_bytes: 68972
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);
	
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << endl;
	
	return 0;
cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

Measured memory_bytes: 3680
from collections import*
def s(s):
  f,q=[1]*-~n,deque([(s,0)])
  while q:
    t,c=q.popleft()
    for v in e[t]:
      q+=[(v,c+1)]*f[v]
      f[v]=0
  return t,c
n,*t=map(int,open(0).read().split())
e=[[]for _ in[0]*-~n]
for a,b in zip(t[::2],t[1::2]):
  e[a]+=b,
  e[b]+=a,
print('SFeicrosntd'[s(s(1)[0])[1]%3!=1::2])

Measured memory_bytes: 61748
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int solve(int x, int y, int m, int n, char a[][1000], vector<vector<int>> &dp){
    if(dp[x][y] != -1)return dp[x][y];
    
    if(x < m-1 && y<n-1){
        if(dp[x+1][y] == -1)solve(x+1,y,m,n,a,dp);
        if(dp[x][y+1] == -1)solve(x,y+1,m,n,a,dp);
        //
        dp[x][y] = (dp[x+1][y]+dp[x][y+1])%mod;
    }
    else if(x == m-1 && y<n-1){
        if(dp[x][y+1] == -1)solve(x,y+1,m,n,a,dp);
        //
        dp[x][y] = dp[x][y+1];
    }
    else if(y==n-1 && x<m-1){
        if(dp[x+1][y] == -1)solve(x+1,y,m,n,a,dp);
        //
        dp[x][y] = dp[x+1][y];    
    }
    return dp[x][y];
}

int32_t main() {
	int m,n;
	cin>>m>>n;
	char ch[m][1000];
	int i,j;
	for(i=0;i<m;i++){
	    for(j=0;j<n;j++){
	        cin>>ch[i][j];
	    }
	}
	
	vector<vector<int>> dp;
	for(i=0;i<m;i++){
	    vector<int> v;
	    for(j=0;j<n;j++)v.push_back(0);
	    dp.push_back(v);
	}
	
// 	for(auto x:dp){
// 	    for(auto y:x){
// 	        cout<<y<<" ";
// 	    }
// 	    cout<<endl;
// 	}
	
	for(i=0;i<m;i++){
	    for(j=0;j<n;j++){
	        if(ch[i][j] == '#')dp[i][j] = 0;
	        else dp[i][j] = -1;
	    }
	}
	
	dp[m-1][n-1] = 1;
	
// 	for(auto x:dp){
// 	    for(auto y:x){
// 	        cout<<y<<" ";
// 	    }
// 	    cout<<endl;
// 	}
	
	solve(0,0,m,n,ch,dp);
// 	cout<<endl;
	
// 	for(auto x:dp){
// 	    for(auto y:x){
// 	        cout<<y<<" ";
// 	    }
// 	    cout<<endl;
// 	}

    cout<<dp[0][0]<<endl;
	
	
	return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

int pw(int a, int b) {
    if (b == 0)
        return 1;
    if (b & 1)return a * pw(a, b - 1);
    return pw(a * a, b / 2);
}

void solve() {
    int n, k;
    cin >> n >> k;

    int a = 0, b = 0;
    for (int i = 1; i <= n; i++)
        if (i % k == 0)a++;
        else if (i % k == k / 2)b++;
    if (k & 1)cout << pw(a, 3) << endl;
    else cout << pw(a, 3)+pw(b,3) << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
  long long int N,A,B,q,r;
  scanf("%lld%lld%lld",&N,&A,&B);
  if(A+B==N)
    printf("%lld",A);
  else if(A+B>N)
  {
    if(A>N)
      printf("%lld",N);
    else
      printf("%lld",A);
  }
  else
  {
    q=N/(A+B);
    r=N%(A+B);
    if(r==0)
      printf("%lld",q*A);
    else if(r>A)
      printf("%lld",(q*A+A));
     else
         printf("%lld",(q*A+r));    
  }
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	max := 0
	for i := range a {
		fmt.Scan(&a[i])
		if max < a[i] {
			max = a[i]
		}
	}

	r := 0
	for _, v := range a {
		if abs(v*2-max) < abs(r*2-max) {
			r = v
		}
	}

	fmt.Println(max, r)
}


Measured memory_bytes: 7040
import bisect,collections,copy,heapq,itertools,math,numpy,string,random
import sys
from decimal import Decimal
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

D = I()
C = LI()
s = [LI() for _ in range(D)]

T = [random.randint(1,26) for _ in range(D)]
#print(D,C)
#print(s)
#print(T)
def last(d,i):
    T_d = T[:d]
    n = [j for j, x in enumerate(T_d,1) if x == i]
    if n:
        #print(T_d,i,"n=",n)
        return max(n)
    else:
        return 0
        
        
score = 0
for d in range(1,D+1):
    sum_c = 0
    for i in range(1,26+1):
        sum_c += C[i-1] * (d -last(d,i))
    score += s[d-1][T[d-1]-1] - sum_c
    #print(score)
    #print(max(10**6 + score,0))
for t in T:
    print(t)

Measured memory_bytes: 27304
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int partition(vector<int>&a, int l, int r) {
	int v = a[r];
	int i(l - 1);
	rep(j, l, r) {
		if (a[j] <= v) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	int x = partition(v, 0, N - 1);
	rep(i, 0, N) {
		if (i == x)cout << '[' << v[i] << ']';
		else cout << v[i];
		cout << (i == N - 1 ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 3196
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  char A;
  cin >>A;
  if(A <= 'Z' && A>= 'A'){ cout <<'A';}
  else { cout <<'a';}
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
    int n,D;
    cin>>n>>D;
    vi d(n),a(n),b(n+1),ans(n);
    for(int i=0;i<n;i++) cin>>d[i];
    for(int i=0;i<n;i++)
    {
        a[i]=D;
        D=min(D,abs(D-d[i]));
    }
    ll cur=1;
    for(int i=n-1;i>=0;i--)
    {
        ans[i]=(cur<=a[i]);
        if(cur>d[i]/2)
            cur+=d[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int tt;
        cin>>tt;
        cout<<(ans[tt-1]?"YES":"NO")<<'\n';
    }

}

Measured memory_bytes: 9728
M[100],i,j,h,s;char*N[100],B[9];main(n,m){for(;scanf("%d%d",&n,&m)*n;printf("%d\n",s)){for(i=n;i--;)scanf("%as%d",N+i,M+i);for(s=0;m--;)for(scanf("%s",B),i=n;i--;s+=M[i]*h)for(h=1,j=8;j--;)h&=N[i][j]<43|N[i][j]==B[j];}}

Measured memory_bytes: 492
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    a = list(sorted(a))
    min_a = a.pop(0)
    max_a = a.pop(-1)

    pos_a = filter(lambda x: x >= 0, a)
    neg_a = filter(lambda x: x < 0, a)
    procedure = []
    
    state = min_a
    for _a in pos_a:
        procedure.append((state, _a))
        state -= _a

    procedure.append((max_a, state))
    state = max_a - state

    for _a in neg_a:
        procedure.append((state, _a))
        state -= _a

    print(state)
    for t in procedure:
        print(t[0], t[1])

if __name__ == "__main__":
    solve()

Measured memory_bytes: 19416
n = int(input()) #長さ
s = str(input()) #文字列
cnt = 0 #暗証番号数

for a in range(10): #1文字目
  for b in range(10): #2文字目
    for c in range(10): #3文字目
      flg = False
      check_a = s.find(str(a))
      if check_a != -1:
        tmp_s = s[check_a + 1:]
        check_b = tmp_s.find(str(b))
        if check_b != -1:
          tmp_t = tmp_s[check_b + 1:]
          check_c = tmp_t.find(str(c))
          if check_c != -1:
            cnt = cnt + 1            
print(cnt)

Measured memory_bytes: 3188
import itertools

n, m , q = (int(x) for x in input().split())
list=[]
for i in range(q):
    a, b, c, d = (int(x) for x in input().split())
    list.append((a,b,c,d))
ans = 0
for i in itertools.combinations_with_replacement(range(1,m+1),n):
    score = 0
    for j in range(q):
        if i[list[j][1]-1]-i[list[j][0]-1]==list[j][2]:
            score+=list[j][3]
    if ans<score:
        ans=score
print(ans)

    

            

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

int main() {
  string S;
  cin>>S;
  if(S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)){
    cout<<"Bad"<< endl;
  }
  else{
    cout<<"Good"<< endl;
  }
}

Measured memory_bytes: 256
main = do
  s <- getContents
  putStr . concat . map(++ "\n") . map rect2 . takeWhile (/=[0,0]) . map (map (read :: String -> Int) . words) . lines $ s

rect2 :: [Int] -> String--  putStr . join' "\n" . map rect2 . takeWhile (/=[0,0]) . map (map (read :: String -> Int) . words) . lines $ s

rect2 [1,w] = row "#" w
rect2 [h,w] = (row "#" w) ++ (concat . take (h-2) . repeat $ (row "." w)) ++ (row "#" w)

row :: String -> Int -> String
row _ 1 = "#\n"
row t w = "#" ++ (concat . take (w-2) . repeat $ t) ++ "#\n"

Measured memory_bytes: 5360
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      int cnt = 1;
      int flag = 0;
      for(int i = 0;i < n-1;i++){
      	if(a[i]<a[i+1]){
        	if(flag==-1){
            	cnt++;
                flag = 0;
            }else if(flag==0){
            	flag = 1;
            }
        }else if(a[i]>a[i+1]){
        	if(flag==1){
            	cnt++;
                flag = 0;
            }else if(flag==0){
            	flag = -1;
            }
        }
      }
      System.out.println(cnt);
    }
}

Measured memory_bytes: 50676
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();
		int D = sc.nextInt();

		int train = A > B ? B : A;
		int bus = C > D ? D : C;

		System.out.println(train+bus);

	}
}


Measured memory_bytes: 21716
l=map(str,raw_input().split())
chk=[]
op='-+*'
while len(l):
    k=l.pop(0)
    if k in op:
        b=chk.pop()
        a=chk.pop()
        chk.append(str(eval(a+k+b)))
    else:
        chk.append(k)
print chk[0]

Measured memory_bytes: 4208
#include <stdio.h>

#define DICE 6
#define CMD 128

typedef struct {
  int side[DICE];
} dice_t;

dice_t rotate(dice_t d, int dir);

enum direction {N, S, W, E, R, L};

int main(void){
  int i, j, isEqual;
  dice_t d1, d2, d2copy;

  for (i = 0; i < DICE; i++)
    scanf("%d", &d1.side[i]);
  for (i = 0; i < DICE; i++)
    scanf("%d", &d2.side[i]);
  d2copy = d2;

  // search for top side and fix
  for (j = 0; j < DICE; j++) {
    isEqual = 1;
    d2 = d2copy;
    if (d1.side[0] == d2.side[j]) {
      switch (j) {
      case 0:
	break;
      case 1:
	d2 = rotate(d2, N);
	break;
      case 2:
	d2 = rotate(d2, W);
	break;
      case 3:
	d2 = rotate(d2, E);
	break;
      case 4:
	d2 = rotate(d2, S);
	break;
      default: // case 5:
	d2 = rotate(d2, N);
	d2 = rotate(d2, N);
	break;
      }
    }

    // search for front side
    for (i = 0; i < 3; i++) {
      if (d1.side[1] == d2.side[1])
	break;
      d2 = rotate(d2, R);
    }

    // compare dice1 with dice2
    for (i = 0; i < DICE; i++) {
      if (d1.side[i] != d2.side[i]) {
	isEqual = 0;
	break;
      }
    }
    if (isEqual)
      break;
  }

  if (isEqual)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

dice_t rotate(dice_t d, int dir){
  int tmp;
  switch (dir) {
  case N:
    tmp = d.side[0];
    d.side[0] = d.side[1];
    d.side[1] = d.side[5];
    d.side[5] = d.side[4];
    d.side[4] = tmp;
    return d;
    break;
  case S:
    tmp = d.side[0];
    d.side[0] = d.side[4];
    d.side[4] = d.side[5];
    d.side[5] = d.side[1];
    d.side[1] = tmp;
    return d;
    break;
  case W:
    tmp = d.side[0];
    d.side[0] = d.side[2];
    d.side[2] = d.side[5];
    d.side[5] = d.side[3];
    d.side[3] = tmp;
    return d;
    break;
  case E:
    tmp = d.side[0];
    d.side[0] = d.side[3];
    d.side[3] = d.side[5];
    d.side[5] = d.side[2];
    d.side[2] = tmp;
    return d;
    break;
  case R:
    tmp = d.side[1];
    d.side[1] = d.side[2];
    d.side[2] = d.side[4];
    d.side[4] = d.side[3];
    d.side[3] = tmp;
    return d;
    break;
  case L:
    tmp = d.side[1];
    d.side[1] = d.side[3];
    d.side[3] = d.side[4];
    d.side[4] = d.side[2];
    d.side[2] = tmp;
    return d;
    break;
  default:
    printf("This direction is not available\n");
    return d;
    break;
  }
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main(){

int h,w;cin>>h>>w;

char s[h][w];
rep(i,h){
    rep(j,w){
        cin>>s[i][j];
    }
}

int d[h][w][h][w];
rep(ih,h){
    rep(iw,w){
        rep(jh,h){
            rep(jw,w){
                d[ih][iw][jh][jw]= INFTY;
                if(s[ih][iw]=='.'&& s[jh][jw]=='.'&&ih==jh&&(iw==jw+1||iw==jw-1))d[ih][iw][jh][jw]= 1;
                if(s[ih][iw]=='.'&& s[jh][jw]=='.'&&iw==jw&&(ih==jh+1||ih==jh-1))d[ih][iw][jh][jw]= 1;
                if(s[ih][iw]=='.'&& s[jh][jw]=='.'&&ih==jh&&iw==jw)d[ih][iw][jh][jw]= 0;
            }
        }
    }
}
int mx=0;
rep(kh,h){
    rep(kw,w){
        rep(ih,h){
            rep(iw,w){
                rep(jh,h){
                    rep(jw,w){
                        d[ih][iw][jh][jw]=min(d[ih][iw][jh][jw],d[ih][iw][kh][kw]+d[kh][kw][jh][jw]);
                    }
                }
            }
        }
    }
}
rep(ih,h){
    rep(iw,w){
        rep(jh,h){
            rep(jw,w){
                if(d[ih][iw][jh][jw]==INFTY)continue;
                mx = max(mx,d[ih][iw][jh][jw]);
            }
        }
    }
}
cout<<mx<<endl;
return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  int n;
  string s;
  int x, ans = 0;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'I') x++;
    else x--;
    ans = max(x, ans);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	static List<Long> L;
	static int cnt = 0;
	static Queue <Long> que;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		L = new ArrayList<Long>();
		que = new PriorityQueue<Long>();
		
		for(long i = 1 ; i <= 9 ;i++) {
			que.add(i);
		}
		while(L.size() < n) {
			int c = (int) (que.peek() % 10);
			long next = que.poll();
			//System.out.println(next);
			for(int i = Math.max(0, c-1) ; i <= Math.min(c+1, 9) ; i++) {
				que.add((long)(next*10+i));
			}
			L.add(next);
		}
		
		System.out.println(L.get(n-1));
	}
	
	
}


Measured memory_bytes: 35884
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
    sc.Scan()
    v, _ := strconv.Atoi(sc.Text())
    return v
}

func abs(x int) int {
    return int(math.Abs(float64(x)))
}


func main() {
    sc.Split(bufio.ScanWords)
    var tList []int
    var vList []int
    n := scanInt()
    for i := 0; i < n; i++ {
        tList = append(tList, scanInt())
    }
    for i := 0; i < n; i++ {
        vList = append(vList, scanInt())
    }
    var dp [201][101]float64
    for i := 0; i < 201; i++ {
        for j := 0; j < 101; j++ {
            dp[i][j] = math.Inf(-1)
        }
    }
    dp[0][0] = 0

    for i := 0; i < n; i++ {
        t, v := tList[i], vList[i]
        for vFr := 0; vFr < v + 1; vFr++ {
            preScore := dp[i][vFr]
            for vTo := 0; vTo < v + 1; vTo++ {
                if abs(vTo - vFr) > t {
                    continue
                }
                maxSpeed := math.Min(float64(vTo + vFr + t) / 2, float64(v))
                dp[i + 1][vTo] = 
                    math.Max(dp[i + 1][vTo], 
                    preScore + maxSpeed * float64(t) - 
                    math.Pow(maxSpeed - float64(vTo), 2) / 2 - 
                    math.Pow(maxSpeed - float64(vFr), 2) / 2)
            }
        }
    }
    fmt.Println(dp[n][0])
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    ll ans = 0;
    ll prev = 0;
    cin >> n >> t;
    REP(i, n){
        int ti;
        cin >> ti;
        ans += t;
        if(ti < prev){
            ans -= prev - ti;
        }
        prev = ti + t;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
# include <stdio.h>
#include <math.h>
double to_deg(double r) {
    return r * 180.0 / (atan(1.0) * 4.0);
}
int main(void){
    double a, b, x;
    scanf("%lf%lf%lf", &a, &b, &x);
    int ans;
    if(a * a * b * 0.5 < x){
        double h;//水が斜めになっている部分の長さ
        h = a*a*b - x;
        h /= a*a*0.5;
        printf("%.10lf\n", to_deg(atan(h/a)));
    }else{
        double l;//水が斜めになっている部分の長さ
        l = x / (a*b*0.5);
        printf("%.10lf\n", to_deg(atan(b/l)));
    }
    return 0;
}

Measured memory_bytes: 2428
class UnionFind:
    """
    size の要素数の UnionFind を管理する
    data 中の負数の要素が根となる
    """

    def __init__(self, size):
        # 根は子を含む集合のデータ数を負数でもつ
        self.data = [-1] * size

    def merge(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y: return False

        # y の方がデータ数を多く
        if self.data[x] < self.data[y]:
            x, y = y, x

        # y に x をつなげる
        self.data[y] += self.data[x]
        self.data[x] = y
        return True

    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]

    def size(self, x):
        """
        根は負数でデータ数を管理しているのでそれを返す
        """
        return -self.data[self.root(x)]


N, M, K = [int(_) for _ in input().split()]
MG = [0] * (N + 1)
uf = UnionFind(N + 1)
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    uf.merge(a, b)
    MG[a] += 1
    MG[b] += 1

KG = [[] for _ in range(N + 1)]
for i in range(K):
    a, b = [int(_) for _ in input().split()]
    KG[a].append(b)
    KG[b].append(a)

res = [0]*(N)
for i in range(1,N+1):
    cnt = uf.size(i) - MG[i]-1
    for k in KG[i]:
        if uf.root(i)==uf.root(k):
            cnt-=1
    res[i-1] =cnt
print(*res)


Measured memory_bytes: 31880
#include<stdio.h>
main()
{int m,M,N,J=1000,X;
scanf("%d%d",&N,&X);
for(m=1;m<N+1;m++)
{scanf("%d",&M);
if(M<J) J=M;
X=X-M;
}
printf("%d",X/J+N);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}


int main(){
  int R,G,B; cin >> R >> G >> B;
  if( (G*10+B)%4==0 ) printf("YES\n");
  else printf("NO\n");

}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int s;
  int a[100]={0};
  int i,j,x=0,y=0;

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

  for(i=1;i<=s-1;i++){
    for(j=1;j<=s-i;j++){
      if(a[j]>a[j+1]){
	x=a[j];
	a[j]=a[j+1];
	a[j+1]=x;
	y++;
      }
    }
  }

  
  for(i=1;i<=s;i++){
    if(i!=s)printf("%d ",a[i]);
        if(i==s)printf("%d\n",a[i]);
    }
    printf("%d\n",y);
    
      
  return 0;
}



Measured memory_bytes: 2044
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
n=int(input())
m=10**5+5
l=[]
lx=[]
for _ in range(n):
    a,b=map(int,input().split())
    l.append((a,b+m,1))
    lx.append(a)
edge=np.array(l,dtype=np.int64).T
graph=csr_matrix(((edge[2],edge[:2]-1)),(2*m,2*m))
n,labels=connected_components(graph)
lx=np.array(lx)
x=np.bincount(labels[:m],minlength=n)
y=np.bincount(labels[m:],minlength=n)
e=np.bincount(labels[lx],minlength=n)
print((x*y-e).sum())

Measured memory_bytes: 40912
#include<iostream>
#include<set>
#include<vector>
using namespace std;
const int N=3e5+7;
vector<int>vecc,vecr;
int mxr,mxc,row[N],col[N];
set<pair<int,int> >st;

int32_t main()
{
	int h,w,m;
	scanf("%d%d%d",&h,&w,&m);
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		row[x]++;
		col[y]++;
		if(mxr<row[x])
		{
			mxr=row[x];
			vecr.clear();
		}
		if(mxr==row[x])
			vecr.push_back(x);

		if(mxc<col[y])
		{
			mxc=col[y];
			vecc.clear();
		}
		if(mxc==col[y])
			vecc.push_back(y);
		st.insert({x,y});
	}
	int _is=1;
	for(int i=0;i<vecr.size();i++)
	{
		int x=vecr[i];
		for(int j=0;j<vecc.size();j++)
		{
			int y=vecc[j];
			if(st.count({x,y})==0)
			{
				_is=0;
				break;
			}
		}
		if(_is==0)
			break;
	}
	printf("%d\n",mxr+mxc-_is);
}


Measured memory_bytes: 21956
#include<cmath>
#include<queue>
#include<ctime>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7fffffff
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
} 
int n;
int mx1[1<<19],mx2[1<<19],a[1<<19],tp;
int main()
{
	int i,j,op;
	n=read();
	int t=1<<n;
	for(i=0;i<t;i++) a[i]=read();
	for(i=0;i<t;i++)
	{
		int op=t-1;tp=op^i;
		for(j=tp;j;j=(j-1)&tp)
		{
			op=j^i;
			if(mx1[op]<a[i]) mx2[op]=mx1[op],mx1[op]=a[i];
			else if(mx2[op]<a[i]) mx2[op]=a[i];
		}
		if(mx1[i]<a[i]) mx2[i]=mx1[i],mx1[i]=a[i];
		else if(mx2[i]<a[i]) mx2[i]=a[i];
	}
	int mx3=0;
	for(i=1;i<t;i++) mx3=max(mx3,mx1[i]+mx2[i]),printf("%d\n",mx3);
}

Measured memory_bytes: 8320
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import deque
H, W = map(int, input().split())
areas = []

black_count = 0
for _ in range(H):
    text = list(input().rstrip())
    for char in text:
        if char == '#':
            black_count += 1
    areas.append(text)

# 最短経路探索でかかったコストを使えば、コストが計算できる。全てのますの数から、最初から黒に塗られているを引いて、さらに最短コストを引けば良い
# 0,0からH,wへ行く


def bfs(areas, start_point, goal_point):
    scores = [[10**9 + 7 for _ in range(W)] for _ in range(H)]
    scores[0][0] = 1
    mv = [[-1, 0], [0, -1], [1, 0], [0, 1]]
    queue = deque([start_point])
    while queue:
        now_point = queue.popleft()
        for next_postion in mv:
            next_point = [now_point[0] + next_postion[0],
                          now_point[1] + next_postion[1]]
            if 0 <= next_point[0] < H and 0 <= next_point[1] < W:
                if areas[next_point[0]][next_point[1]] == '#':
                    continue
                if scores[next_point[0]][next_point[1]] > scores[now_point[0]][now_point[1]] + 1:
                    queue.append(next_point)
                    scores[next_point[0]][next_point[1]
                                          ] = scores[now_point[0]][now_point[1]] + 1
    if scores[goal_point[0]][goal_point[1]] == 10**9 + 7:
        return -1
    return scores[goal_point[0]][goal_point[1]]


cost = bfs(areas, [0, 0], [H - 1, W - 1])
if cost == -1:
    print(cost)
else:
    print(H * W - black_count - cost)


Measured memory_bytes: 40304
#include<bits/stdc++.h> 
using namespace std; 
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;} 
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(i,b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(i,b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define MOD                 1000000007 
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}

int main()
{ 
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
  //  start_routine();
    
  // ll t,sum=0,ans=0,n;
  // cin>>t;
ll n;
   //while(t--) {  cin>>n ; }
   cin>>n;
   vector<ll> a(n+1),b(n); 
   loop(i,0,n+1)
   cin>>a[i];
   loop(i,0,n)
   cin>>b[i];
   
   ll ans=0,sum=0;
   for(int i=n-1;i>=0;i--)
 {  
      if(a[i+1]>=b[i])
      sum+=b[i];
      else
      {
          sum+=a[i+1];
          b[i]-=a[i+1];
          if(a[i]>=b[i])
          { sum+=b[i]; a[i]-=b[i];
              if(a[i]<0) a[i]=0;
          }
           else
           {
               sum+=a[i];
               a[i]=0; 
           }
      }
      
 }
   
   cout<<sum;
    
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
data = [a[0]]
m = abs(s - 2 * a[0])

for i in range(1, N - 1):
    data.append(a[i] + data[i - 1])

for i in range(0, N - 1):
    if abs(s - 2 * data[i]) < m:
        m = abs(s - 2 * data[i])

print(m)



Measured memory_bytes: 30516
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++) 
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define co(a) cout<<a<<endl;
using namespace std;
using ll = long long;


int main() {
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  REP(i,n) a[i]-=i+1;
  SORT(a);
  ll sum = 0;
  REP(i,n) sum += abs(a[n/2] - a[i]);
  co(sum)
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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; }

int main() {
	int N,K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	ll mini = 1e18;
	rep(i, (1<<N)) {
		ll res = 0;
		if(__builtin_popcount(i) < K) continue;
		if(!(i & 1)) continue;
		//cout << bitset<5>(i) << endl;
		ll previousHeight = 0;
		ll currentHeight = -1;
		rep(j,N) {
			if(!((i >> j) & 1)) {
				continue;
			}
			for(int k=j+1; k<N; k++) {
				if(!((i >> k) & 1)) {
					chmax(currentHeight, A[k]);
				}
				if((i >> k) & 1) break;
			}
			//cout << j << " ";
			//cout << previousHeight << " " << currentHeight << " " << A[j] << endl;
			ll shouldBe = max(previousHeight, currentHeight);
			if (shouldBe >= A[j]) res += shouldBe + 1 - A[j];
			previousHeight = max(shouldBe+1, A[j]);
			currentHeight = 0;
			/*	
				if(currentHeight < A[j]) {
					currentHeight = A[j];
				}
				else {
					res += currentHeight + 1 - A[j];
					currentHeight++;
				}
			}
			*/
		}
		//cout << res << endl;
		chmin(mini, res);
	}
	cout << mini << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 700000 
#define W 800 
#define H 800 

using namespace std;
typedef long long int ll;


int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
queue< pair<int, int> > que;

char c[H][W];
ll d[H][W];

int main() {
	int h, w;
	ll k, ans;
	scanf("%d %d %d", &h, &w, &k);

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			d[i][j] = INF;
		}
	}

	for (int i = 0; i < h; i++) {
		scanf("\n");
		for (int j = 0; j < w; j++) {
			scanf("%c", &c[j][i]);
			if (c[j][i]=='S') {
				d[j][i] = 0;
				que.push(pair<int, int>(j, i));
			}
		}
	}

	while (!que.empty()) {
		int x, y;
		int x1, y1;
		ll a;
		tie(x, y) = que.front();
		a = d[x][y];
		que.pop();
		for (ll i = 0; i < 4; i++) {
			x1 = x + dx[i];
			y1 = y + dy[i];
			if (x1 >= w | y1 >= h) continue;
			if (x1 < 0 | y1 < 0) continue;
			if (k <= a) break;
			if (c[x1][y1] == '.') {
				if (d[x1][y1] == INF) {
					d[x1][y1] = a + 1;
					que.push(pair<int, int>(x1, y1));
				}
			}
		}
	}

	ll dis;
	ll out = INF;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (d[j][i] != INF) {
				dis = min(min(i, j), min((h-i-1), (w-j-1)));
				if (k >= d[j][i] & out > dis) {
					out = dis;
				}
			}
		}
	}


	ans = 1;
	while(1) {
		if (out <= 0) {
			printf("%d\n", ans);
			return 0;
		}
		out -= k;
		ans++ ;
	}
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
//#include "optimization.h"

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1e18;

const int N = 1e5 + 5;
const int mod = inf + 7;

inline int mul(int x, int y) {
    return (1ll * x * y) % mod;
}

inline void add(int &x, int y) {
    if((x += y) >= mod) x -= mod;
}

int binpow(int x, int p) {
    int res = 1;
    int tmp = x;
    while(p > 0) {
        if(p & 1) {
            res = mul(res, tmp);
        }
        tmp = mul(tmp, tmp);
        p >>= 1;
    }
    return res;
}

int n;
int a[N];
int r[N];

void precalc() {
    for(int i = 0;i < N;i++) {
        r[i] = binpow(i, mod - 2);
        if(i > 0) add(r[i], r[i - 1]);
    }
}

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    precalc();

    scanf("%d", &n);

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

    int res = 0;

    for(int i = 1;i <= n;i++) {
        int sm = r[n - i + 1];
        add(sm, r[i]);
        sm--;
        if(sm < 0) sm += mod;
        add(res, mul(sm, a[i]));
    }

    for(int i = 1;i <= n;i++) {
        res = mul(res, i);
    }

    printf("%d\n", res);

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <complex>
using namespace std;
typedef complex<double> xy_t;
double X1,Y1,X2,Y2,XQ,YQ;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }
int main() {
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&X1,&Y1,&X2,&Y2,&XQ,&YQ)){
        xy_t P1(X1,Y1),P2(X2,Y2),Q(XQ,YQ);
        xy_t R = projection(Q-P1 , P2-P1) + projection(Q-P1, P2-P1) - Q + P1 + P1;
        printf("%.6f %.6f\n", real(R), imag(R));
    }
    return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x) 	memset(a, x, sizeof a)
#define prec(n) 	fixed<<setprecision(n)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)	    cout<<a<<" "
#define pr2(a,b)    cout<<a<<" "<<b<<" "
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le(s)		(ll)s.length()						
#define re 			return 	
#define	mp(a,b)  	make_pair(a,b)
#define se			second
#define fi			first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
void inline minize(ll& a,ll b){a=(a>b?b:a);};
void inline maxize(ll& a,ll b){a=(a<b?b:a);};
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e5;


ll arr[MAXN+5],invmod[MAXN+5],fac[MAXN+5],fac2[MAXN+5],fac3[MAXN+5];
ll mark[MAXN+5];

ll mu(ll a,ll x){
	if(!x)re 1;
	
	if(x&1){
		re (a*mu(a,x-1))%Base;
	}
	else{
		ll t=mu(a,x>>1);
		re (t*t)%Base;
	}
}
ll Solves(){
//	INPUT;
	ll n,k,cnt=0,ans=0,x,p2,p3,y,z,p5;
	// PROCESSING IN HERE
	sc(n);
	n++;
	invmod[1]=invmod[0]=1;
	fu(i,2,n+5){
		invmod[i]=(invmod[i-1]*mu(i,Base-2))%Base;
	}
	fac[n]=n;
	fac[n+1]=fac[0]=1;
	fd(i,n-1,1)fac[i]=(fac[i+1]*i)%Base;
	
	fu(i,1,n+1){
		sc(arr[i]);
		if(mark[arr[i]])p2=i,p3=mark[arr[i]];
		mark[arr[i]]=i;
	}
	
	p3--;
	p5=n-p2+p3;
	
	
	fac3[p5]=p5;
	fac3[0]=fac3[p5+1]=1;
	fd(i,p5,1)fac3[i]=(fac3[i+1]*i)%Base;
	
	fu(i,1,n+1){
		x=min(i,n-i);
		y=min((n-p2)-(i-1),i-1);
		z=min(p5,p5-(i-1));
		cout<<((fac[n-x+1]*invmod[x])%Base-(p5>=i-1?(fac3[p5-z+1]*invmod[z])%Base:0)+2*Base)%Base<<endl;
	}
	
	re 0;
	// Hack it if you can :)
}
int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	Solves();
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    s[3]='8';
    cout1(s)
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    double a, b, h, m, x, y, r, pi = 4.*atan(1);
    cin >> a >> b >> h >> m;
    x = 360.*h/12. + 30.*m/60.;
    y = 360.*m/60.;
    r = min(max(x, y) - min(x, y), min(360 - max(x, y) + min(x, y), max(x, y) + 360 - min(x, y)));
    r = pi*r/180.;
    cout << fixed << setprecision(9);
    if(r)
        cout << sqrt(a*a + b*b - 2*a*b*cos(r));
    else
        cout << abs(a-b);
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e20;

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);

int main() {
	int a;
	cin >> a;
	if (a <= 999)COUT("ABC");
	else COUT("ABD");
	return 0;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli x[550][550];
lli c[550][550];
	
signed main(){

	lli n,m,q;
	cin>>n>>m>>q;

	REP(i,0,m){
		lli l,r;
		cin>>l>>r;
		x[l][r]++;
	}
	REP(i,1,n+1){
		REP(j,1,n+1){
			c[i][j] += c[i][j-1]+x[i][j];
		}
	}

	REP(i,0,q){
		lli l,r;
		cin>>l>>r;
		lli sum=0;
		REP(j,l,r+1)sum += c[j][r]-c[j][l-1];
		cout<<sum<<endl;
	}

	return 0;
 
}

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

int main() {
    long long N;
    cin >> N;
    vector <unsigned long long> A(N);
    unsigned long long ans=1;
    unsigned long long gen = pow(10,18);
    bool iszero = false;
    bool ismin = false;
    for (long long i=0; i<N; i++) {
        unsigned long long A;
        cin >> A;
        long double Amax = (long double)gen/ans;
        if (A>Amax) ismin = true;
        ans = ans*A;
        if (A==0) iszero=true;
//        if (ans>gen) {
//            ismin = true;
//        }
    }
    if (iszero) cout << "0";
    else if (ismin) cout << "-1";
    else cout << ans;
}

Measured memory_bytes: 3996
# 2020/02/22
# AtCoder Beginner Contest 123 - C

# Input
n = int(input())
ae = list()
for i in range(5):
    ae.append(int(input()))

# Calc
minae = min(ae)
ans = n // minae + 4
if n % minae > 0:
    ans = ans + 1

# Output
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(true)  {
			String cards = scanner.next();
			if(cards.equals("-")) {
				break;
			}
			int m = scanner.nextInt();
			char hands[] = new char[cards.length() + 1];
			char oki;
			for (int i = 0; i < cards.length(); i++) {
				hands[i] = cards.charAt(i);
			}
			for (int k = 0; k < m; k++) {
				int shuffle = scanner.nextInt();
				for (int j = 0; j < shuffle; j++) {
					for (int i = 0; i < cards.length() - 1; i++) {
						oki = hands[i];
						while (i < cards.length() - 1) {
							hands[i] = hands[i + 1];
							i++;
						}
						hands[cards.length() - 1] = oki;

					}
				}
			}
			for (int i = 0; i < cards.length(); i++) {
				System.out.print(hands[i]);
			}
			System.out.println();
		}
		scanner.close();
	}
}



Measured memory_bytes: 27040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  const int lim = 1000000;
  vector<bool> primes( lim + 1 );
  fill( primes.begin(), primes.end(), true );
  primes[ 0 ] = primes[ 1 ] = false;
  const int l = (int)sqrt( lim );
  for ( int i = 2; i <= l; i++ ){
	if ( primes[ i ] ) {
	  for ( int j = i * i; j <= lim; j += i ) {
		primes[ j ] = false;
	  }
	}
  }
  
  while( true ) {
	int n, x;
	cin >> n >> x;
	if ( n == 0 and x == 0 ) break;
	
	vector<int> vs( n );
	for ( int i = 0; i < n; i++ ) {
	  cin >> vs[ i ];
	}
	sort( vs.begin(), vs.end() );
	vector<bool> cands( x + 1 );
	int ans = -1;
	fill( cands.begin(), cands.end(), false );
	cands[ 0 ] = true;
	for ( int i = 0; i <= x; i++ ) {
	  if ( cands[ i ] ) {
		for ( int v : vs ) {
		  if ( i + v <= x ) {
			cands[ i + v ] = true;
		  }
		}
		if ( primes[ i ] ) {
		  ans = i;
		}
	  }
	}
	if ( ans == -1 ) {
	  cout << "NA" << endl;	  
	} else {
	  cout << ans << endl;
	}
  }
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <long double> p(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	vector <vector <long double>> dp(n + 1, vector <long double> (n / 2 + 2, 0));
	for (int i = 0; i <= n; i++) {
		dp[i][0] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n / 2 + 1; j++) {
			dp[i][j] = (1 - p[i]) * dp[i - 1][j] + p[i] * dp[i - 1][j - 1];
		}
	}
	cout << setprecision(10) << dp[n][n / 2 + 1] << '\n';
	return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>
int main(void)
{ int i,j,n,m,max,ans;
 scanf("%d\n",&n);
 max=ans=0;
 for(i=n;i>=1;i--)
 { m=0;
  j=i;
  while(j>=1 && j%2==0)
  { j=j/2;
    m++;
  }
  if(m>=max){max=m;ans=i;}
 }
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 128
<?php
$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$result = 0;
for ($l = 0;$l < 10;$l++) {
    if (strpos($s,"$l") !== false) {
        $chk1 = substr($s,strpos($s,"$l") + 1);
        for ($c = 0;$c < 10;$c++) {
            if (strpos($chk1,"$c") !== false) {
                $chk2 = substr($chk1,strpos($chk1,"$c") + 1);
                for ($r = 0;$r < 10;$r++) {
                    if (strpos($chk2,"$r") !== false) {
                        $result++;
                    }
                }
            }
        }
    }
}
echo $result.PHP_EOL;
?>

Measured memory_bytes: 3828