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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) {
        is >> x;
    }
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vi h(n);
    cin >> h;

    bool ans = true;
    int m = h[0];
    REP(i, n) {
        if (h[i] < m - 1) {
            ans = false;
        }
        m = max(m, h[i]);
    }

    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    p = LI()
    dp = [0] * n
    bf = list(itertools.accumulate([i for i in range(1001)]))
    for i in range(n):
        dp[i] = bf[p[i]] / p[i]
    ans = 0
    bf = 0
    for i in range(k):
        ans += dp[i]
    bf = ans
    for i in range(k, n):
        bf -= dp[i - k]
        bf += dp[i]
        ans = max(ans, bf)
    print(ans)

    return


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


Measured memory_bytes: 68208
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int n;
	cin >> n;
	ll ans = 0;
	ll temp = 0;
	string s;
	map<string, int>z;
	rep0(i, n - 1) {
		cin >> s;
		sort(s.begin(), s.end());
		z[s]++;
	}
	for (auto& j : z) {
		if (j.second >= 2) {
			temp = j.second;
			ans += (ll)(temp * (temp - 1)) / 2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

  vector<int> p( N );
  rep( i, 0, N ) cin >> p.at(i);

  sort( p.begin(), p.end() );
  p.back() /= 2;

  int Ans = 0;
  rep( i, 0, N ) {Ans += p.at(i);}

  cout << Ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;

 int g[15][15];

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

    ll n;
    cin >> n;
    ll a;
    int ans = 0;
    rep(i,15)rep(j,15) g[i][j] = -1;
    rep(i,n){
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x >> y;
            g[i][--x] = y;
        }
    }
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n){
            if(i>>j&1){
                d[j] = 1;
            }
        }
        bool ok = true;
        rep(j,n){
            if(d[j]==1){
                rep(k,n){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k])  ok = false;
                }
            }
        }
        if(ok) {
            ans = max(ans,__builtin_popcount(i));
        }
    }
    cout << ans << endl;
    

    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == s[i+1]){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double r, pi = 3.141592653589, enn, nagasa;

	scanf("%lf", &r);

	enn = r * r*pi;
	nagasa = 2 * r*pi;

	printf("%f %f\n", enn, nagasa);

	return 0;
}


Measured memory_bytes: 2044
from collections import deque

n,q = input().split()
n = int(n)
q = int(q)
T = [0] * (n+1)

to = [[] for i in range(n+1)]
cnt = [0] * (n)
for i in range(1,n):
    a,b = [int(j) for j in input().split()]
    to[a].append(b)
    to[b].append(a)
for i in range(1,q+1):
    P,X = [int(j) for j in input().split()]
    T[P] += X
NIL = -1

q =deque()
q.append((1,0,NIL))
while len(q)>0:
    p,x,prev = q.pop()
    x += T[p]
    cnt[p-1] = x
    for i in to[p]:
        if i != prev:
            q.append((i,x,p))
print(*cnt)


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

int main() {
  //vector<int> b(101);
  //b.at(0)=1;
  int N, M, C;
  int i, j;
  cin >> N >> M >> C;
  vector<int> B(M);
  int A, S, CC;
  for (i=0; i<M; i++) cin >>B.at(i);
  for (j=0, CC=0; j<N; j++) {
    S=C;
    for (i=0; i<M; i++) {
      cin >>A;
      S+=B.at(i)*A;
    }
    if (S>0) CC++;
  }
  cout << CC << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#define MAXN 10005
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

const int c[]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const char ch[]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

int n, m, a[MAXN];
string f[MAXN];

string cmp(string a, string b)
{
    if(a.length()!=b.length()) return a.length()>b.length()?a:b;
    int len=a.length();
    for(rint i=0; i<len; ++i)
    {
        if(a[i]!=b[i]) return a[i]>b[i]?a:b;
    }
    return a;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(rint i=1; i<=m; ++i) scanf("%d", &a[i]);
    for(rint i=1; i<=n; ++i)
        for(rint j=1; j<=m; ++j)
        {
            if(i<c[a[j]]) continue;
            if(i==c[a[j]] || f[i-c[a[j]]].length()) f[i]=cmp(f[i], f[i-c[a[j]]]+ch[a[j]]);
        }
    printf("%s\n", f[n].c_str());
    return 0;
}

Measured memory_bytes: 37248
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    string s;
    cin>>s;
    
    for(int i=0;i<5;i++){
        cout<<s[i];
    }
    cout<<" ";
    for(int i=6;i<13;i++){
        cout<<s[i];
    }
    cout<<" ";
    for(int i=14;i<19;i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
   
}






Measured memory_bytes: 256
N = int(input())
L = [str(input()) for i in range(N)]
flag = 1

for i in range(N):
    if L.count(str(L[i]))<2:
        if str(L[i-1])[-1] == str(L[i])[0]:
            pass
        elif i == 0:
            pass
        else:
            flag = 0
    else:
        flag = 0

if flag:
    print("Yes")

else:
    print("No")


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

int main()
{
	ll X, Y;
	cin >> X >> Y;
	if (X % Y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << X << endl;
	}
	return 0;
}


Measured memory_bytes: 764
#include <stdio.h>

int main(void){
    int H,W,i,j;
    scanf("%d %d",&H,&W);
    while(H || W){
        for(i = 0;i<H;i++){
            if(i == 0 || i == H - 1){
                for(j = 0;j < W;j++){
                    printf("#");
                }
                printf("\n");
            } else {
                printf("#");
                for(j = 1;j < W -1;j++){
                    printf(".");
                }
                printf("#");
                printf("\n");
            }
        }
        printf("\n");
        scanf("%d %d",&H,&W);
    }
    return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> A(N + 2), c_A(N + 1);
	for (int i = 1; i <= N; i++) cin >> A[i];
	int sum = 0;
	for (int i = 0; i <= N; i++) {
		c_A[i] = abs(A[i + 1] - A[i]);
		sum += c_A[i];
	}
	for (int i = 1; i <= N; i++) {
		cout << sum - c_A[i - 1] - c_A[i] + abs(A[i - 1] - A[i + 1]) << "\n";
	}
	return 0;
}

Measured memory_bytes: 2048
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using Graph=vector<vector<int>>;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}

signed main(){
	int n;cin>>n;
	int ans=n;
	auto ds=[](int a){
		int res=0;
		while(a){
			res+=a%10;
			a/=10;
		}
		return res;
	};
	rep(a,1,n){
		ans=min(ans,ds(a)+ds(n-a));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
char S[12];
int N;
int chk[256];
int main(){
  int i, k=0, res=0;
  N = rd(S);
  chk['A'] = chk['C'] = chk['G'] = chk['T'] = 1;
  for(i=0;i<N;i++){
    if(chk[S[i]]){
      chmax(res, ++k);
    }
    else{
      k = 0;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// char S[12];
// int N;
// 
// int chk[256];
// {
//   int i, k = 0, res = 0;
// 
//   rd(S@N);
//   chk['A'] = chk['C'] = chk['G'] = chk['T'] = 1;
// 
//   rep(i,N){
//     if(chk[S[i]]) res >?= ++k;
//     else          k = 0;
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)
for i in range(M):
    a, b = AB[i]
    uf.union(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)

Measured memory_bytes: 47236
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define fastio                        \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(NULL);
#define pb push_back
#define mp make_pair

typedef long long ll;

using namespace std;

int main()
{
    fastio;
    int n, k;
    cin>>n>>k;
    if((n-1)%(k-1)==0)
    cout << (n-1)/(k-1)<<endl;
    else cout<<(n-1)/(k-1) +1<<endl;

    //cout<<(n+n/k +1)/k <<endl;
    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int i,c=0;
	string S,T;
	cin>>S>>T;
	for(i=0;i<S.length();i++)
	{
		if(S[i]!=T[i])
		c++;
	}
	cout<<c;
	//printf("%d",a+a*a+a*a*a);
	return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    ll n;
    cin >> n;
    string s[n];
    map<string, ll> mp;
    for(int i = 0; i < n; ++i){
        cin >> s[i];
        mp[s[i]]++;
    }
    cout << "AC x " << mp["AC"] << "\n";
    cout << "WA x " << mp["WA"] << "\n";
    cout << "TLE x " << mp["TLE"] << "\n";
    cout << "RE x " << mp["RE"] << "\n";
    return 0;
}

Measured memory_bytes: 6780
import java.io.IOException;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] Args) throws IOException{
        final String w = sc.next();
        int ans = 0;
        while(true){
            final String t = sc.next();
            if(t.equals("END_OF_TEXT")) break;
            if(w.compareToIgnoreCase(t)==0) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26428
import collections

n,k = map(int,input().split())
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

listB=[] 

for i in range(k):
  listB+=listA[2*i+1]
  
c = collections.Counter(listB)  
print(n-len(c))


Measured memory_bytes: 68084
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int r;
int main()
{
	scanf("%d",&r);
	if(r<1200) printf("ABC\n");
	else if(r<2800) printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

Measured memory_bytes: 128
/*  ex9_1
    Acro   */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10000

typedef struct{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
void initialize_stack(stack *stk);
void print_stack(stack *stk);
void push(stack *stk, char x);
char pop(stack *stk);

stack stk;

int main(void){
    int i;
    char string[SIZE];
    scanf("%s",string);
    initialize_stack(&stk);
    for ( i = 0; i < strlen(string); i++)
    {
        if (string[i] == 'B')
        {
            if (stk.count > 0)
            {
                pop(&stk);
            }
            
        }
        else
        {
            push(&stk,string[i]);
        }
        
    }
    for ( i = 0; i < stk.count; i++)
    {
        printf("%c",stk.data[SIZE-1-i]);
    }
    printf("\n");
    return 0;
}



void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

void push(stack *stk, char x){
    if (stk->count >= stk->size)
    {
        printf("Error : stack overflow\n");
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = x;
        stk->count++;
    }
}

char pop(stack *stk){
    char x;
    if(stk->count <= 0)
    {
        printf("Error : stack underflow\n");
        exit(1);
    }
    else
    {
        x = *(stk->top);
        stk->top++;
        stk->count--;
        return x;
    }
    
}

Measured memory_bytes: 1656
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = long.Parse(spl[0]);
        var b = long.Parse(spl[1]);
        var c = long.Parse(spl[2]);
        var d = long.Parse(spl[3]);

        long l = Count(a, b, 1);

        long perC = Count(a, b, c);
        //Debug.Write(perC);
        //Debug.Write(" ");

        long perD = Count(a, b, d);
        //Debug.Write(perD);
        //Debug.Write(" ");

        long perCD = Count(a, b, LCM(c, d));
        //Debug.Write(perCD);
        //Debug.Write(" ");
        //Debug.WriteLine(" ");

        return l-(perC+perD-perCD);
    }

    static long Count(long a, long b, long n) {
        if(n > b) return 0;

        long f = a;
        if (a % n != 0) {
            f = a + (n - a % n);
        }

        if (f > b) return 0;
        return (b - f) / n+1;
    }

    static long LCM(long a, long b) {
        var x = a * b;
       
      if(a<b){
        var tmp = a;
        a = b;
        b = tmp;
      }
 
      /* ユークリッドの互除法 */
      var r = a % b;
      while(r!=0){
        a = b;
        b = r;
        r = a % b;
      }
 
      return x/b;
    }

}


Measured memory_bytes: 13140
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N;
  cin >> N;
  int x[N], y[N], h[N];
  rep(i, N){
    cin >> x[i];
    cin >> y[i];
    cin >> h[i];
  }
  int prex, prey;
  rep(prex, 101){
    rep(prey, 101){
      int needH = -1;
      rep(i, N){
        if(h[i] > 0){
          int tmp = h[i] + abs(x[i] - prex) + abs(y[i] - prey);
          if(needH == -1) needH = tmp;
          else if(needH != tmp){
            needH = -2;
            break;
          }
        }
      }
      if(needH == -2) continue;
      rep(i, N){
          if(h[i] == 0){
            int dist = abs(x[i] - prex) + abs(y[i] - prey);
            if(needH > dist){
              needH = -2;
              break;
            }
          }
      }
      if(needH == -2) continue;
      cout << prex << " " << prey << " " << needH << endl;
    }
  }
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 1e3+1;
int dp[N][N];
char a[N][N];

int main()
{
  fastio;
  int n, m; cin >> n >> m;
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      if (i == 1 && j == 1) dp[i][j] = 1;
      else {
        if (a[i][j] == '#') continue;
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
      }
    }
  }
  cout << dp[n][m];
  return 0;
}

Measured memory_bytes: 8508
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll N,K,d,A;
	std::cin >> N >> K;
	set<ll> s;
	rep(i, 0, K) {
		std::cin >> d;
		rep(j, 0, d) {
			std::cin >> A;
			s.insert(A);
		}
	}
	std::cout << N - s.size() << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    vector<int> cp(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
        cp[i] = vec[i];
    }

    sort(cp.begin(),cp.end());

    int cnt = 0;
    for(int i=0;i<n;i++){
        if(vec[i] != cp[i]){
            cnt++;
        }
    }

    if((cnt == 2) || (cnt == 0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    V<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int m;cin>>m;
    V<ll>b(m);
    for(int i=0;i<m;i++)cin>>b[i];
    map<ll,int>mm;
    for(int i=0;i<n;i++){
        mm[a[i]]++;
    }
    bool abc=1;
    for(int i=0;i<m;i++){
        if(mm[b[i]]==0){
            abc=0;
            break;
        }
    }
    if(abc==0)cout<<0<<endl;
    else cout<<1<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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

const vector<long> r = { 1, 10, 9, 12, 3, 4 };
const long m = 1000000007;

int main()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<long> count(13);
  count.at(0) = 1;
  for (long i = 0; i < s.size(); i++) {
    vector<long> count_new(13);
    if (s.at(i) != '?') {
      long k = s.at(i) - '0';
      for (long j = 0; j < 13; j++) {
        count_new.at((j + r.at(i % 6) * k) % 13) = count.at(j);
      }
    } else {
      for (long j = 0; j < 13; j++) {
        for (long k = 0; k < 10; k++) {
          count_new.at((j + r.at(i % 6) * k) % 13) += count.at(j);
        }
      }
    }
    for (long j = 0; j < 13; j++) {
      count.at(j) = count_new.at(j) % m;
    }
  }
  cout << count.at(5) % m << endl;
}


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

using namespace std;
#define ll unsigned long long
const int MAXN = 2e5 + 1;
int mass[301][301];
int ans[301][301];
int summcolomn[301];
vector<int> res;
ll rec(int d, ll c, int &who){
    if(c==1){
        who=d;
        return 0;
    }
    if(c%2==0){
        if(d>=5){
            int h=d*2;
            h=h%10+h/10;
            return c+rec(h,c/2, who);
        }
        else{
            return c/2+rec(d*2,c/2, who);
        }
    }
    else{
        if(d>=5){
            int h=d*2;
            h=h%10+h/10;
            ll ans1=c-1+rec(h,c/2, who);
            if(who+d<=9) {
                who+=d;
                return ans1+1;
            }
            else{
                who+=d;
                who=who/10+who%10;
                return ans1+2;
            }

        }
        else{
            ll ans1=c/2+rec(d*2,c/2, who);
            if(who+d<=9) {
                who+=d;
                return ans1+1;
            }
            else{
                who+=d;
                who=who/10+who%10;
                return ans1+2;
            }
        }
    }
}
void solve() {
    int m;
    cin>>m;
    ll ans=0;
    for(int i=0;i<m;i++){
        int d;
        ll c;
        cin>>d>>c;
        int h;
        ans+=rec(d,c, h);
        res.push_back(h);
    }
    /*cout<<ans<<endl;
    for(int i=0;i<res.size();i++){
        cout<<res[i]<<" ";
    }*/
    for(int i=0;i<res.size()-1;i++){
        int now=res[i];
        int last=res[i+1];
        if(now+last>9){
            now+=last;
            ans+=2;
            res[i+1]=now%10+now/10;
        }
        else{
            ans++;
            res[i+1]=now+last;
        }
    }
    cout<<ans;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    string s, t;
    cin >> s >> t;

    s = s + s;
    vector<queue<ll>> jumps(26, queue<ll>());

    REP(i, s.size()){
        jumps[ s[i]-'a' ].push(i+1);
    }

    vector<vector<ll>> jumptable(26, vector<ll>(s.size()/2, -1));
    REP(i, s.size()/2){
        char letter = s[i]-'a';
        REP(j, 26){
            if( !jumps[j].empty() ){
                jumptable[j][i] = jumps[j].front() - i;
            }
        }
        jumps[letter].pop();
    }

    ll index=0;
    REP(i, t.size()){
        ll curindex = index%(s.size()/2);
        char letter =  t[i] - 'a';
        if( jumptable[letter][curindex] == -1){
            index = -1;
            break;
        }else{
            index+=jumptable[letter][curindex];
        }
    }

    cout << index << endl;
}


Measured memory_bytes: 23424
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <queue>
#include <set>
#include <cstring>
#include <cmath>
#include <string>
#define ll long long

void redirect_input(){
    freopen("D:\\in.txt","r",stdin);
}

void redirect_output(){
    freopen("D:\\out.txt","w",stdout);
}

void print_binary(int i){
    int save[33]={0};
    for(int j=0;j<33;j++){
        if((1<<j) & i)save[j]=1;
    }
    for(int i=32;i>=0;i--)printf("%d",save[i]);
}

void print_array(int * begin,int * end){
    int * t=begin;
    while(t!=end){
        printf("%d     ",*t);t++;
    }
    printf("\n");
}

void print_array(int * begin,int * end,char * arr_name){
    printf("print %s:\n",arr_name);
    print_array(begin,end);
}

template<typename T>T max_in(T * begin,T * end){
    T mx=*begin;
    for(T * cur=begin;cur!=end;cur++) if(!(*cur<mx))mx=*cur;
    return mx;
}

template<typename T>T min_in(T * begin,T * end){
    T mx=*begin;
    for(T * cur=begin;cur!=end;cur++) if(*cur<mx)mx=*cur;
    return mx;
}

template<typename T>inline void in(T & p){
    p=0;
    T flag=1;
    char c=getchar();
    while(c<'0' or c>'9'){
        if(c=='-') flag=-1;
        c=getchar();
    }
    while(c>='0' and c<='9') p=p*10+(c-'0'),c=getchar();
    p*=flag;
}

template<typename A,typename B>inline void in(A&x,B&y){in(x),in(y);}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z){in(x),in(y),in(z);}
template<typename A,typename B,typename C,typename D>inline void in(A&x,B&y,C&z,D&w){in(x),in(y),in(z),in(w);}
template<typename T>T gcd(T a,T b){return b==0?a:gcd(b,a%b);}

const int inf=0x3f3f3f3f;
const double dinf=1e300;

using namespace std;

ll A(int k){
    ll ans=1;
    for(int i=1;i<=k;i++)ans*=i;
    return ans;
}

ll pow_is_greater(ll a, ll y, ll cmp){
    if(y==0)return 1;
   // if(pow)
}

void solve(){
    ll X, Y;scanf("%lld%lld", &X, &Y);
    int r=1000, l=1;
    /*
    while(r>l){
        int mid=(r+l)/2;
        if(pow(X, mid)>Y || pow(X, mid)<0){
            r=mid-1;
        }else{
            l=mid+1;
        }
        printf("%d %d\n", l, r);
    }
    printf("%d\n", l);
    */
    for(int i=1;i<1000;i++){
        if(X*2<=Y){
            X*=2;
        }else{
            printf("%d\n", i);
            return ;
        }
    }
}

#define local
int main(){
	#ifdef local

	#endif
	solve();
    ;;;;;;;;;;;;;;   ;;;;;;;;;;;;;;   ;;;;;;;;;;;;;;
                ;;               ;;               ;;
                ;;               ;;               ;;
    ;;;;;;;;;;;;;;   ;;;;;;;;;;;;;;   ;;;;;;;;;;;;;;
    ;;                           ;;               ;;
    ;;                           ;;               ;;
    ;;;;;;;;;;;;;;   ;;;;;;;;;;;;;;   ;;;;;;;;;;;;;;
}


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

using namespace std;

int main()
{
 	int n,c;
  cin>>n>>c;
  int res=c*2;
  if(n-res<0)
  {
   cout<<0<<endl;
  }
  else
  {
   cout<<n-res<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &x: a) cin >> x;
  vector<vector<int> > cnt0(1<<20);
  int zeros = 0;
  int part = 0;
  for(auto x:a) {
    part ^= x;
    if(part) cnt0[part].push_back(zeros);
    else ++zeros;
  }
  if(part) {
    LL pre = 0;
    LL j = 1;
    LL k = 0;
    for(auto c:cnt0[part]) {
      LL tmp = c-pre;
      j += k*tmp;
      j %= p;
      k += j;
      k %= p;
      pre = c;
    }
    cout << j << endl;
    return 0;
  } else {
    LL answer = 1;
    REP(i,zeros-1) {
      answer *= 2;
      answer %= p;
    }
    FOR(i,1,1<<20) {
      LL pre = 0;
      LL j = 1;
      LL k = 0;
      for(auto c:cnt0[i]) {
        LL tmp = c-pre;
        j += k*tmp;
        j %= p;
        k += j;
        k %= p;
        pre = c;
      }
      answer += k;
      answer %= p;
    }
    cout << answer << endl;
    return 0;
  }
}


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

int main(){
    int N,X;
    cin >> N >> X;

    int c = 1;

    int x = 0;

    for(int i=0;i<N;i++ ){
        int tmp;
        cin >> tmp;
        x += tmp;
        //cout << x << endl;
        if(x <= X){
            c++;
        }else{
            break;
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  vector<int> ans;
  int d = 1;
  if(n<0){
    n=-n; d=-d;
  }
  while(n>0){
    if(n&1){
      ans.push_back(1);
      n -= d;
    }else{
      ans.push_back(0);
    }
    n>>=1;
    d=-d;
  }
  rep(i,ans.size()) cout << ans[ans.size()-1-i];
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int tx[2] = {0, 1};
int ty[2] = {1, 0};

struct route{
    int x, y, num;
};

int main(){
    int h, w;
    cin >> h >> w;
    char maze[h][w];
    rep(i,h)rep(j,w) cin >> maze[i][j];
    int ch[h][w];
    rep(i,h)rep(j,w) ch[i][j] = inf;
    ch[0][0] = 0;
    queue<route> q;
    route e = {0,0,0};
    q.push(e);
    while(!q.empty()){
        route p = q.front();
        q.pop();
        int x = p.x;
        int y = p.y;
        int num = p.num;
        if(ch[x][y]<num) continue;

        rep(i,2){
            int nx = x + tx[i];
            int ny = y + ty[i];
            if(nx>=0&&nx<h&&ny>=0&&ny<w){
                int j = num;
                if(maze[x][y]!=maze[nx][ny]) j++;
                if(ch[nx][ny] > j){
                    ch[nx][ny] = j;
                    route r = {nx, ny, j};
                    q.push(r);
                }
            }
        }

    }
    cout << (ch[h-1][w-1]+1)/2 + (maze[0][0]=='#'&&maze[h-1][w-1]=='#'?1:0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define INF 1LL << 40;
#define MOD 1000000007;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
template <class T> inline void chmax(T &a, T b) { a < b ? a = b : a; };
template <class T> inline void chmin(T &a, T b) { a > b ? a = b : a; };
struct edge {
    int to, cost;
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n;
    rep(i, n) {
        cin >> a;
        if(a % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}


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

int main(){
    int a = 1, b = 1;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            cout << a << "x" << b << "=" << a * b << endl;
            b++;
        }
        b = 1;
        a++;
    }
    return 0;
}

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

int main(void){
     int a;
     string s;
     cin >> a;
     cin >> s;
     if(a >= 3200) cout << s << endl;
     else cout << "red" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int min=1145148101;
	for(int i=0;i!=a;i++) {
		int d=scan.nextInt();
		b-=d;
		if(min>d) {
			min=d;
		}
	}
	System.out.println(a+(b/min));
}
}

Measured memory_bytes: 21844
program prob3
    implicit none
    integer :: a,e,i,test,tmp,j
    character(20) :: s
    integer :: b(3)
    read(*,*) e
    b(3) = mod(e, 10)
    e = e / 10
    b(2) = mod(e, 10)
    e = e / 10
    b(1) = mod(e, 10)
    e = e / 10
    a = mod(e, 10)
    e = e / 10
    
    do i = 0, 7
        test = a
        tmp = i
        do j = 1, 3
            if(mod(tmp, 2) == 1) then
                test = test + b(j)
            else
                test = test - b(j)
            end if
            tmp = tmp / 2
        end do
        if(test == 7) then
            write(s,*) a
            write(*,'(a)',advance='no') trim(adjustl(s))
            tmp = i
            do j = 1, 3
                if(mod(tmp, 2) == 1) then
                    write(*,'(a)',advance='no') '+'
                    write(s,*) b(j) 
                    write(*,'(a)',advance='no') trim(adjustl(s))
                else
                    write(*,'(a)',advance='no') '-'
                    write(s,*) b(j) 
                    write(*,'(a)',advance='no') trim(adjustl(s))
                end if
                tmp = tmp /2
            end do
            exit
        end if
    end do

    write(*,'(a)',advance='no') '=7'
    write(*,*) 
    stop
contains
end program prob3

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

int main(void){
        const double k = M_PI / 180;
        while(1){
                double a, b, c, d;
                scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
                if(d==-1) break;

                a*=k; b*=k; c*=k; d*=k;
                double t = sin(a)*sin(c)+cos(a)*cos(c)*cos(b-d);
                printf("%.0lf\n", 6378.1*acos(t));
        }
        return 0;
}


Measured memory_bytes: 2120
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = readints()
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 87208
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll x[105],y[105];
ll par[105],sz[105];
ll find(ll i){
    if(par[i]==i)
    return i;
    return par[i]=find(par[i]);
}
void merge(ll a,ll b){
    a=find(a);
    b=find(b);
    if(a==b)
    return;
    if(sz[b]>sz[a])
    swap(a,b);
    par[b]=a;
    sz[a]+=sz[b];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll res=n;
    for(ll i=0;i<n;i++)
    cin>>x[i]>>y[i];
    for(ll a=0;a<n;a++)
    for(ll b=a+1;b<n;b++){
        ll p=x[b]-x[a],q=y[b]-y[a],sum=0;
        for(ll i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
        for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
        if((x[i]-x[j]==p)&&(y[i]-y[j]==q))
        merge(i,j);
        for(ll i=0;i<n;i++)
        if(par[i]==i)
        sum++;
        res=min(res,sum);
    }
    cout<<res;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int AA[100000];
int BB[100000];
void Calc(){
	int A = rei();
	int B = rei();
	int M = rei();
	int am = 100000;
	for(int i=0;i<A;i++){
		AA[i] = rei();
		am = min(am,AA[i]);
	}
	int bm = 100000;
	for(int i=0;i<B;i++){
		BB[i] = rei();
		bm = min(bm,BB[i]);
	}
	int ans = am+bm;
	for(int i=0;i<M;i++){
		int x = rei()-1;
		int y = rei()-1;
		int c = rei();
		ans = min(ans,AA[x]+BB[y]-c);
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int bad = 0;
  char last = 'z';

  cin >> N;
  vector<string> W(N);
  for(int i = 0; i < N; i++){
    cin >> W[i];
    for(int j = 0; j < i; j++){
      if(W[i] == W[j]){
        bad++;
        // cout << "1" << endl;
        // cout << W[i] << "==" << W[j] << endl;
      }      
    }
    if(i > 0){
      if(last != W[i][0]){
        bad++;
        // cout << "2" << endl;
        // cout << last + "!=" << W[i][0] << endl;
      }
    }
    // cout << "---" << endl; 
    // cout << W[i] << endl; 
    // cout << W[i].length() << endl; 
    last = W[i][W[i].length()-1];
  }
  if(bad == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll nCr(int n, int r){
  ll num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
    int N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    for(int i = 0; i < N+1; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    ll sum = 0;
    for(int i = 0; i < N; i++){
        if(B[i] > A[i]){
            sum += A[i] + min(B[i] - A[i], A[i+1]);
            A[i + 1] = max(A[i + 1] - (B[i] - A[i]), ll(0));
        }else sum+= B[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 4832
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = scan.nextInt();
        }
        for(int i = 0; i < N; i++){
            if(i != N-1){
                System.out.print(A[i]+" ");
            }else{
                System.out.println(A[i]);
            }
        }
        for(int i = 1; i < N; i++){
            int v = A[i];
            int j = i - 1;
            while(j >= 0 && A[j] >v){
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = v;
            for(int k = 0; k < N; k++){
                if(k != N-1){
                    System.out.print(A[k]+" ");
                }else{
                    System.out.println(A[k]);
                }
            }
        }
    }
}


Measured memory_bytes: 31836
#include <iostream>
using namespace std;
static const int MAX = 101;

int main()
{
    int A[MAX][MAX];
    int r, c;
    for (int i = 0; i != MAX; ++i)
    {
        for (int j = 0; j != MAX; ++j)
        {
            A[i][j] = 0;
        }
    }
    cin >> r >> c;
    for (int i = 0; i != r; ++i)
    {
        for (int j = 0; j != c; ++j)
        {
            cin >> A[i][j];
            A[i][MAX-1] += A[i][j];
            A[MAX-1][j] += A[i][j];
        }
    }
    for (int i = 0; i != r; ++i)
    {
        for (int j = 0; j <= c; ++j)
        {
            if (j) cout << " ";
            if (j == c)
            {
                cout << A[i][MAX-1] << endl;
            }
            else
            {
                cout << A[i][j];
            }
        }
        A[MAX-1][MAX-1] += A[i][MAX-1];
    }
    for (int i = 0; i != c; ++i)
    {
        cout << A[MAX-1][i] << " ";
    }
    cout << A[MAX-1][MAX-1] <<endl;
    return 0;
}


Measured memory_bytes: 3136