akhauriyash/Code-Regression huggingface dataset:
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *CSP-S 2019 RP++                                          *
 ***********************************************************/
#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
	return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
#define int ll
int n,ans,num;
char s[5020];
ull has[5020],fr[5020];
inline ull f(int l,int r){
	return (has[r]-1ull*has[l-1]*fr[r-l+1]);
}
signed main(){
#ifdef LOCAL_LIGEN
	// freopen("0.in","r",stdin);
	// freopen("0.out","w",stdout);
	double be=clock();
#endif
	n=read();
	scanf("%s",s+1);
	fr[0]=1;
	FOR(i,1,n)fr[i]=1ull*fr[i-1]*131,has[i]=has[i-1]*131ull+s[i];
	ans=0;
	FOR(i,1,n){
		num=0;
		FOR(j,i+1,n)while(i+num<j&&f(i,i+num)==f(j,j+num))++num;
		// writeln(i,num,fr[i],has[i]);
		ans=Max(ans,num);
	}
	writeln(ans);
#ifdef LOCAL_LIGEN
	double en=clock();
	printf("Time: %.0lfms\n",en-be);
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

struct LazySegmentTree{
   int n;
   vector<ll> node,lazy,flag;
public:
   LazySegmentTree(int sz,ll init){
       n=1;
       while(n<sz)n*=2;
       node.resize(2*n-1,init);
       lazy.resize(2*n-1,longinf);
   }

   void eval(int k,int l,int r){
       if(lazy[k]!=longinf){
           node[k]=lazy[k];
       if(r-l>1){
            lazy[2*k+1]=lazy[k]/2;
           lazy[2*k+2]=lazy[k]/2;
       }
       }
       lazy[k]=longinf;
    }
       //[a,b)にxを加算
    void update(int a,int b,ll x,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
           lazy[k]=x*(r-l);
           eval(k,l,r);
        }
        else {
           update(a,b,x,2*k+1,l,(l+r)/2);
           update(a,b,x,2*k+2,(l+r)/2,r);
           node[k]=node[2*k+1]+node[2*k+2];
        }
    }
   //[a,b)での和を返す
   ll get(int a,int b,int k=0,int l=0,int r=-1){
       if(r<0)r=n;
       eval(k,l,r);
       if(r<=a||b<=l)return 0;
       if(a<=l&&r<=b)return node[k];
       ll xl=get(a,b,2*k+1,l,(l+r)/2);
       ll xr=get(a,b,2*k+2,(l+r)/2,r);
       return xl+xr;
   }
};
int main(){
   int n,q;
   cin>>n>>q;
   LazySegmentTree sg(n,0);
   rep(i,q){
       int t;cin>>t;
       if(t){
           int a,b;
           cin>>a>>b;
           b++;
           cout<<sg.get(a,b)<<endl;
       }
       else {
           int a,b,c;
           cin>>a>>b>>c;
           sg.update(a,b+1,c);
       }
   }
   return 0;
}


Measured memory_bytes: 7056
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N,K;
    cin >> N >> K;
    // Odd
    ll res = pow(N / K, 3LL);
    if (K % 2 == 0) {
        cout << (ll)pow((N + K / 2LL) / K, 3LL) + res << endl;
    } else {
        cout << res << endl;
    }
}


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

#define int long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;

    vector<pair<int,int>> fact;

    for(int i = 2 ; i*i <= N ; i++)
    {
    	if(N%i == 0)
    	{
    		int cont = 0;
    		while(N%i == 0)
    		{
    			cont++;
    			N /= i;
    		}
    		fact.push_back({i,cont});
    	}
    }

    if(N != 1)fact.push_back({N,1});

    int res = 0;

    for(auto x : fact)
    {
    	int e = x.second;
    	int cont = 1;
    	while(e-cont >= 0)
    	{
    		e -= cont;
    		cont++;
    		res++;
    	}
    }

    cout << res << '\n';

    return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

const ll MOD = (ll) 1e9 + 7;

ll pow_mod(ll n, ll k, ll m = MOD) {
    if (k == 0)return 1;
    else if (k % 2 == 1) {
        return pow_mod(n, k - 1, m) * n % m;
    } else {
        ll t = pow_mod(n, k / 2, m);
        return t * t % m;
    }
}

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

    ll ans = 1LL;
    map<char, int> cnt;
    for (int i = 0; i < N; ++i) {
        cnt[S[i]]++;
    }
    for (auto mp : cnt) {
        ans *= (mp.second + 1);
        ans %= MOD;
    }

    cout << ((ans == 0) ? MOD : ans - 1) << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static boolean isPalindrome(int n) {
		String s = ""+n;

		String a = "";
		for (int i = s.length()-1; i>=0; i--) {
			a += s.charAt(i);
		}

		return s.equals(a);
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new File("B.txt"));

		int a = sc.nextInt();
		int b = sc.nextInt();

		int count = 0;
		for (int i = a; i <= b; i++) {
			if (isPalindrome(i)) count++;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 42304
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

ll dp[110][120000];
int main()
{
  int N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  REP(i, N) cin >> w[i] >> v[i];
  REP(i, N) {
    REP(j, W + 1) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (j + w[i] <= W)
        dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
    }
  }
  cout << dp[N][W] << endl;

  return 0;
}

Measured memory_bytes: 95360
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int main() {
    int x[6],y[6];
    for (int i=0; i<6; i++) {
        cin >> x[i];
    }
    for (int i=0; i<6; i++) {
        cin >> y[i];
    }
    char a[30]= {'N','N','N','N','E','E','E','N','N','N','E','E','E','N','N','N','E','N','N','N','E','N','N','N','E','E','E','N','N','N'};
    int b,c,d,e;
    b=c=d=e=0;
    for (int i=0;i<30;i++){
        if (a[i]=='E') {
            b=y[0];c=y[2];d=y[3];e=y[5];
            y[2]=b;y[5]=c;y[0]=d;y[3]=e;
            if(x[0]==y[0]&&x[1]==y[1]&&x[2]==y[2]&&x[3]==y[3]&&x[4]==y[4]&&x[5]==y[5]){
                cout << "Yes"<<endl;
                break;
            }
            }
        if(a[i]=='N'){
            b=y[0];c=y[1];d=y[4];e=y[5];
            y[4]=b;y[0]=c;y[5]=d;y[1]=e;
            if(x[0]==y[0]&&x[1]==y[1]&&x[2]==y[2]&&x[3]==y[3]&&x[4]==y[4]&&x[5]==y[5]){
                cout << "Yes" <<endl;
                break;
            }
            
        }
        if(i==29){
            cout << "No"<<endl;
            break;
        }
        }
    }




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

int v,e;
ll dp[101][101];
const ll inf=9999999999;

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 cin>>v>>e;
 for(int i=0;i<101;i++)for(int j=0;j<101;j++)if(i!=j)dp[i][j]=inf;
 for(int i=0;i<e;i++){
  int a,b,c;cin>>a>>b>>c;
  dp[a][b]=c;
 }
 for(int k=0;k<v;k++){
  for(int i=0;i<v;i++){
   if(dp[i][k]==inf)continue;
   for(int j=0;j<v;j++){
    if(dp[k][j]==inf)continue;
    dp[i][j]=min(dp[i][k]+dp[k][j],dp[i][j]);
   }
  }
 }
 for(int i=0;i<v;i++)if(dp[i][i]<0){cout<<"NEGATIVE CYCLE"<<"\n";return 0;}
 for(int i=0;i<v;i++){
  for(int j=0;j<v;j++){
   if(dp[i][j]!=inf)cout<<dp[i][j];
   else cout<<"INF";
   if(j!=v-1)cout<<" ";
  }
  cout<<"\n";
 }
}

Measured memory_bytes: 3284
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Set as Set

main :: IO ()
main = do
  [n,k] <- readInts
  replicateM k (readInts >> readInts) >>= output . solve n . concat

solve :: Int -> [Int] -> _
solve n = Set.size . (xs Set.\\) . Set.fromList
  where
    xs = Set.fromAscList [1..n]

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 4860
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll a,b,k; cin >> a >> b >> k;
 
  for(ll i=a; i <= b; i++){
    if(i <= max(a+k-1,a) or min(b-k+1,b) <= i) cout << i << endl;
  }
  
}

Measured memory_bytes: 3552
n = int(input())
ans = 0
max_t = 0
max_a = 0
for _ in range(n):
    t, a = map(int, input().split())
    x = max(max_t//t, max_a//a, 1)
    while 1:
        if max_t <= t*x and max_a <= a*x:
            max_t = t * x
            max_a = a * x
            break
        else:
            x += 1
print(max_t + max_a)

Measured memory_bytes: 3188
S = input()

a = ['A', 'C', 'G', 'T']
count = 0
ans = 0

f = False
for i in S:
  if f:
    if i in a:
      count += 1
      ans = max(count, ans)
    else:
      count = 0
      f = False
  else:
    if i in a:
      count += 1
      ans = max(count, ans)
      f = True

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace  std;
int main() {
//    ios::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
    long long n,k;
    while(~scanf("%lld %lld",&n,&k))
    {
        n%=k;
        if(k==1)
        {
            printf("0\n");
       }
        else
        {
            long long minn=n;
            while(1) {
                long long flag = abs(minn - k);
                if (flag < minn) {
                    minn = flag;
                } else {
                    break;
                }
            }

            printf("%lld\n",minn);
        }

    }
    return 0;
}

Measured memory_bytes: 3816
#include <iostream>
using namespace std;
int main()
{
    int A, B, C;
    int Ex = 0;
    int allow = 0;
    cin >> A >> B >> C;
    allow = A - B;
    Ex = C - allow;
    if (Ex < 0)
    {
        Ex = 0;
    }

    cout << Ex << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    a = LI()
    f = list(set(a))
    f.sort()
    s = [0]*len(f)
    ind = [0]*n
    for i in range(n):
        j = bisect.bisect_left(f,a[i])
        s[j] += 1
    ls = list(accumulate(s))
    rs = list(accumulate(s[::-1]))[::-1]
    ans = 0
    fact = [1]
    N = 10**5
    for i in range(1,N+1):
        fact.append(fact[-1]*i%mod)
    inv = [0]*(N+1)
    inv[N] = pow(fact[N],mod-2,mod)
    for i in range(N)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    comb = lambda x,y:fact[x]*inv[y]*inv[x-y]%mod
    for j in a:
        i = bisect.bisect_left(f,j)
        l = ls[i]-1
        r = rs[i]-1
        cl = comb(l,k-1) if l >= k-1 else 0
        cr = comb(r,k-1) if r >= k-1 else 0
        ans += f[i]*(cl-cr)
        ans %= mod
        ls[i] -= 1
        rs[i] -= 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 63432
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, M;
    int P[100005], Y[100005];
    vector<int> v[100005];

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        scanf("%d %d", &P[i], &Y[i]);
        v[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++) {
        sort(v[i+1].begin(), v[i+1].end());
    }

    for (int i = 0; i < M; i++) {
        printf("%06d", P[i]);
        printf("%06d\n", lower_bound(v[P[i]].begin(), v[P[i]].end(), Y[i]) - v[P[i]].begin() + 1);
    }
    return 0;
}

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

using namespace std;

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

    int note[n+1];

    for(int i = 1; i < n+1; i++) {
        note[i] = 1;
    }

    for(int i = 2; i < n+1; i++) {
        for(int j = i; j < n+1; j += i) {
            note[j]++;
        }
    }

    int count = 0;
    for(int i = 1; i < n+1; i+=2) {
        if(note[i] == 8) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3592
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

d = make_divisors(n)
for i in d:
    if i >= n ** 0.5:
        break
print((i + n // i) - 2)


Measured memory_bytes: 38896
S = input()
T = input()
S_map = {}
T_map = {}
l = len(S)
S_cnt = 0
T_cnt = 0
for i in range(l):
	s,t = S[i], T[i]
	if s in S_map:
		s_id = S_map[s]
	else:
		s_id = S_cnt
		S_map[s] = S_cnt
		S_cnt += 1
	if t in T_map:
		t_id = T_map[t]
	else:
		t_id = T_cnt
		T_map[t] = T_cnt
		T_cnt += 1
	if s_id != t_id:
		print("No")
		exit()
print("Yes")

Measured memory_bytes: 3632
#include <vector>
#include <algorithm>
using namespace std;
template<class T> class PriorityQueue {
private:
	size_t size_; vector<T> heap;
public:
	PriorityQueue() : size_(1), heap(vector<T>(1, 0)) {};
	PriorityQueue(PriorityQueue& que) : size_(que.size_), heap(que.heap) {};
	size_t size() { return size_ - 1; }
	inline void insert(int x) {
		unsigned ptr = size_++; heap.push_back(x);
		while (ptr > 1) {
			if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
			ptr >>= 1;
		}
	}
	inline int extract() {
		int ret = heap[1]; unsigned ptr = 1;
		while ((ptr << 1) + 1 < size_) {
			ptr <<= 1;
			if (heap[ptr] > heap[ptr + 1]) swap(heap[ptr >> 1], heap[ptr]);
			else swap(heap[ptr + 1], heap[ptr >> 1]), ptr++;
		}
		heap[ptr] = heap[--size_], heap[size_] = 0;
		while (ptr > 1) {
			if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
			ptr >>= 1;
		}
		heap.pop_back();
		return ret;
	}
};
char c[9]; int v;
int main() {
    PriorityQueue<int> que;
    while(scanf("%s", c), c[3]) {
        if(*c == 'i') scanf("%d", &v), que.insert(v);
        else printf("%d\n", que.extract());
    }
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>

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

	std::string str;

	if (n == 0) {
		std::cout << "0" << std::endl;
		exit(0);
	}

	while (n!=0) {
		if (n % 2 == 0) {
			str ="0"+str;
		}
		else {
			str = "1"+str;
			n--;
		}

		n/=-2;
	}

	std::cout<<str<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  string s;
  cin>>n>>m;
  if(n<10 && m<10) cout<<n*m<<endl;
  else cout<<-1<<endl;

  return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<ll>a(n),s(n,0),t(n,0);

rep(i,n){
    cin>>a[i];
}
s[0]=a[0];
t[n-1]=a[n-1];
rep(i,n-1){
    int idx_s=i;
    int idx_t=n-1-i;
    s[idx_s+1]=s[idx_s]+a[idx_s+1];
    t[idx_t-1]=t[idx_t]+a[idx_t-1];
}
ll min_cost=INF;
rep(i,n-1){
    min_cost=min(min_cost,abs(s[i]-t[i+1]));
}
cout<<min_cost<<endl;
return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    if (n == 100000) n = 99999;
    
    int ans;
    if (n < 10) {
        ans = n;
    } else if (n < 1000) {
        n = max(99, n);
        ans = 9 + n-99;
    } else {
        n = max(9999, n);
        ans = 9 + 900 + n-9999;
    }

    cout << ans << endl;

    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n,h;
	cin>>n>>h;
	int a[n],b[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	sort(b,b+n);
	reverse(b,b+n);
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		if (a[0]<b[i])
		{
			++ans;
			h-=b[i];
			if (h<=0)
			{
				break;
			}
		}
		else
		{
			break;
		}
	}
	if (h>0)
	{
		ans+=(h+a[0]-1)/a[0];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1152
/* #include <bits/stdc++.h>
using namespace std;
#define M 1000000007

int n;

int main() {
    cin>>n;
    double a[n],b[n],c[n];
    vector<vector<int>> G(200005,vector<int>(0));
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        c[i]=a[i]/b[i];
    }
    map<double,int> m;
    for(int i=0;i<n;i++){
        if(!m.count(-c[i])) m[c[i]]=i;
        else{
            G[m[c[i]]].push_back(i);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<G[i].size();j++){
            G[G[i][j]].push_back(i);
        }
    }
    vector<int> ans(200005);
    ans[0]=1;
    for(int i=0;i<n;i++){
        
    }

} */




#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
using ll=long long;

const int mod=M;
struct mint{
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-()const{
        return mint(-x);
    }
    mint &operator+=(const mint &a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;        
    }
    mint &operator-=(const mint &a){
        if((x+=mod-a.x)>=mod) x-=mod;
        return *this;        
    }
    mint &operator*=(const mint &a){
        (x*=a.x)%=mod;
        return *this;        
    }
    mint operator+(const mint &a)const{
        return mint(*this)+=a;        
    }
    mint operator-(const mint &a)const{
        return mint(*this)-=a;        
    }
    mint operator*(const mint &a)const{
        return mint(*this)*=a;        
    }
    mint pow(long long t)const{
        if(!t){
            return 1;
        }
        mint a=pow(t>>1);
        a*=a;
        if(t&1){
            a*=*this;
        }
        return a;
    }
    mint inv()const{
        return pow(mod-2);
    }
    mint &operator/=(const mint &a){
        return (*this)*=a.inv();
    }
    mint operator/(const mint &a)const{
        return mint(*this)/=a;
    }
};
istream &operator>>(istream &is,const mint &a){
    return is>>a.x;
}
ostream &operator<<(ostream &os,const mint &a){
    return os<<a.x;
}

ll gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main(){
    int n;
    cin>>n;
    vector<ll> a(200005),b(200005);
    int zero=0;
    map<pair<ll,ll>,pair<int,int>> mp;
    
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        ll g=gcd(a[i],b[i]);
        ll x,y;
        if(g==0){
            zero++;
        }
        else{
            x=a[i]/g;
            y=b[i]/g;
            if(y<0){
                x=-x;
                y=-y;
            }
            if(y==0&&x<0){
                x=-x;
            }
            if(x>0){
                mp[{x,y}].first++;
            }
            else{
                swap(x,y);
                y=-y;
                mp[{x,y}].second++;                
            }            
        }        
    }

    mint ans=1;
    for(auto p:mp){
        int a=p.second.first;
        int b=p.second.second;
        ans*=mint(2).pow(a)+mint(2).pow(b)-1;        
    }
    ans+=zero-1;

    cout<<ans<<endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll N;
    cin >> N;
    for(ll h = 1; h <= 3500; h++) {
        for(ll n = 1; n <= 3500; n++) {
            if(4 * h * n - N * n - h * N == 0) continue;
            if(n * h * N % (4 * h * n - N * n - h * N) != 0) continue;
            ll w = n * h * N / (4 * h * n - N * n - h * N);
            if(w <= 0) continue;
            cout << h << " " << n << " " << w << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {

    int x,a,b;
    cin >> x>>a>>b;
    
    cout << ((abs(x-a)>abs(x-b))?"B":"A") << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string n;
    cin >> n;
    ll ans=0;
    for(ll i=0;i<4;i++){
        if(n[i]=='2'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == -1) {
            break;
        }
        double coord[] = {1, 0, };
        for (int i = 0; i < n - 1; i++) {
            double angle = atan2(coord[1], coord[0]) + M_PI / 2;
            coord[0] += cos(angle);
            coord[1] += sin(angle);
        }
        printf("%.2f\n%.2f\n", coord[0], coord[1]);
    }
}

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



public class Main {

	static int[] C, D;
	static int M, N; //N??????M??\
	static int[][] memo;

	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = in.readLine().split(" ");
		N = Integer.parseInt(strs[0]);
		M = Integer.parseInt(strs[1]);
		memo = new int[N][M];
		D = new int[N];
		for (int i = 0; i < N; i++) {
			D[i] = Integer.parseInt(in.readLine());
		}
		C = new int[M];
		for (int i = 0; i < M; i++) {
			C[i] = Integer.parseInt(in.readLine());
		}

		System.out.println(func(0, 0));
	}

	static int func(int town, int day) {
		//??????town?????????day??\????????¨???????????????????????????????????´??????????°???????????????¢??°
		//?????´??????????°?????????????????????¨????´¢
		if (day == M) {
			if (town == N) {
				return 0;
			}
			return Integer.MAX_VALUE >> 1;
		}
		if (town == N) {
			return 0;
		}
		//??????????????????
		if (memo[town][day] != 0) return memo[town][day]+1;
		int T1 = func(town, day+1); //??¨?????£????????¨???
		int T2 = func(town+1, day+1) + D[town]*C[day]; //???????????¨???
		if (T1 < T2) {
			memo[town][day] = T1 - 1;
			return T1;
		}
		memo[town][day] = T2 - 1;
		return T2;
	}
}

Measured memory_bytes: 28936
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;

int main()
{
	string s, t;
	cin >> s >> t;
	vector<string> v;
	rep(i, s.length() - t.length() + 1)
	{
		bool find = true;
		rep(k, t.length())
		{
			if(s[i+k] != t[k] && s[i+k] != '?'){
				find = false;
				break;
			}
		}
		if(!find)
			continue;
		string ans = "";
		rep(k, s.length())
		{
			if(i!=k){
				ans += (s[k] == '?' ? 'a' : s[k]);
				continue;
			}
			rep(l,t.length()){
				ans += t[l];
				if(l==0)
					continue;
				k++;
			}
		}
		v.push_back(ans);
	}
	sort(all(v));

	cout << (v.size() <= 0  ? "UNRESTORABLE" : v[0]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
int cnt;

int main(){

  n = in();
  REP( i , n ){
    if( in() % 2 == 1 ){
      cnt++;
    }
  }

  if( cnt % 2 == 1 ){
    puts( "NO" );
  } else {
    puts( "YES" );
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <tuple>

using namespace std;
typedef long long ll;

struct Data {
    ll x;
    ll y;
    ll z;

    ll get(int idx)
    {
        ll ret = (idx & 1) ? x : -x;
        ret += (idx & 2) ? y : -y;
        ret += (idx & 4) ? z : -z;
        return ret;
    }
};

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

    vector<Data> vs;
    for (int i = 0; i < n; i++)
    {
        Data d;
        cin >> d.x >> d.y >> d.z;
        vs.push_back(d);
    }

    ll ret = 0;

    for (int i = 0; i < 8; i++)
    {
        vector<pair<ll, int>> vv;

        for (int j = 0; j < n; j++)
        {
            vv.push_back(make_pair(vs[j].get(i), j));
        }
        sort(vv.begin(), vv.end());
        reverse(vv.begin(), vv.end());
        
        Data d;
        d.x = d.y = d.z = 0;

        for (int j = 0; j < m; j++)
        {
            auto v = vv[j];
            d.x += vs[v.second].x;
            d.y += vs[v.second].y;
            d.z += vs[v.second].z;
        }
        ret = max<ll>(ret, abs(d.x) + abs(d.y) + abs(d.z));
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 3005
double dp[1503][MAX];
double a[MAX],s;
signed main()
{
	int n,i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	for(i=0;i<=(n-1)/2;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(j==0&&i==0)
			dp[i][j]=1;
			else
			{
			if(i>0)
			dp[i][j]=(dp[i-1][j-1])*a[j]+dp[i][j];
			dp[i][j]+=dp[i][j-1]*(1-a[j]);
		}
		}
	
		s=s+dp[i][n];
	}
	cout<<fixed<<setprecision(10)<<1-s<<"\n";
}

Measured memory_bytes: 38960
n, a, b = map(int, input().split())
if a == 0:
    print(0)
elif n <= a:
    print(n)
else:
    r = int(n / (a + b))
    if n % (a + b) < a:
        print(n - r * b)
    else:
        print(a * (r + 1))


Measured memory_bytes: 2940
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		if(X < 600)
			System.out.println(8);
		else if(X < 800)
			System.out.println(7);
		else if(X < 1000)
			System.out.println(6);
		else if(X < 1200)
			System.out.println(5);
		else if(X < 1400)
			System.out.println(4);
		else if(X < 1600)
			System.out.println(3);
		else if(X < 1800)
			System.out.println(2);
		else
			System.out.println(1);
	}

}


Measured memory_bytes: 35688
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#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 all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n;
int a[100005];

int main(){
	scanf("%d ", &n);
	set<int> s;
	int t;
	rep(i, n) {
		scanf("%d ", &t);
		s.insert(t);
	}
	if (s.size() % 2)
		cout << s.size() << endl;
	else
		cout << s.size() - 1 << endl;
	return 0;
}


Measured memory_bytes: 4992
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := 0
	for i := 1; i <= n; i += 2 {
		c := 0
		for j := 1; j <= i; j += 2 {
			if i%j == 0 {
				c++
			}
		}
		if c == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{
    string str;
    cin>>str;
    ll ans=0;
    if(str[0]=='R'&&str[1]=='R'&&str[2]=='R')ans=3;
    else if(str[0]=='R'&&str[1]=='R')ans=2;
    else if(str[1]=='R'&&str[2]=='R')ans=2;
    else if(str[0]=='R'||str[1]=='R'||str[2]=='R')ans=1;
    else ans=0;
    
    cout<<ans<<endl;
        
    
	return 0;
}


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

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

int main()
{
	int n;
	int i, j, k;
	cin >> n;
	long ans = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			for (k = 1; k <= n; k++) {
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int int64_t
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	int num1, num2;
    char n;
    cin >> num1 >> n >> num2;
    if(n == '+') cout << num1+num2;
    else cout << num1-num2;
}




Measured memory_bytes: 3636
#include <iostream>
#include <vector>
//#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
  int ans1=0,ans2=0,ans;
  string S;
  cin >> S;
  //0からのパターン
  for(int i = 0; i<S.length(); i++){
    if(i%2 == 0){//偶数番目
      if(S[i]!='0'){
        ans1++;
      }
    }else{
      if(S[i]!='1'){
        ans1++;
      }
    }
  }
  //1からのパターン
    for(int i = 0; i<S.length(); i++){
    if(i%2 == 0){//偶数番目
      if(S[i]!='1'){
        ans2++;
      }
    }else{
      if(S[i]!='0'){
        ans2++;
      }
    }
  }
  ans = min(ans1,ans2);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<int >nos(n,0);
  for(int i=0;i<n;i++)cin>>nos[i];
  int tot=0;
  while(1){
  	int no=0;
    for(int i=0;i<n;i++){
    	if(nos[i]%2==0){no++;nos[i]/=2;}
      else break;
    }
    if(no==n)tot++;
    else break;
  }
  cout<<tot;
}

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

int hoge[9];
bool three, five, seven;
int fuga, cnt = 0, n;

void mknum(int i){
  if(i == 9){
    three = false;
    five = false;
    seven = false;
    fuga = 0;
    for(int j = 0; j < 9; j++){
      if(hoge[j] == 1){
        three = true;
        fuga += 3 * powl(10, 8 - j);
      }
      if(hoge[j] == 2){
        five = true;
        fuga += 5 * powl(10, 8 - j);
      }
      if(hoge[j] == 3){
        seven = true;
        fuga += 7 * powl(10, 8 - j);
      }
    }
    if(three && five && seven){
      if(n >= fuga) cnt++;
    }
  }
  else{
    while(hoge[i] < 4){
      mknum(i + 1);
      hoge[i] += 1;
    }
    hoge[i] = 1;
  }
}

int main(){
  std::cin >> n;
  mknum(0);
  std::cout << cnt << std::endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j=0;
    string s;
    string s1;
    cin>>s;
    getchar();
    cin>>s1;
    for(i=0;i<3;i++)
    {
        if(s[i]==s1[i]){j++;}
        else{continue;}
    }
    cout<<j<<endl;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
q=int(input())
liq=[]
for i in range(q):
    b,c=map(int,input().split())
    liq.append([b,c])
#print(liq)
ans=sum(a)
co=Counter(a)
for i in range(q):
    bi,ci=liq[i][0],liq[i][1]
    ans=ans+co[bi]*(ci-bi)
    num=co[bi]
    print(ans)
    co[bi]=0
    co[ci]+=num


Measured memory_bytes: 37216
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include <iomanip>
#include<algorithm>
#include<vector>
#include <map>
#define rep(i,N) for(int (i)=0;(i) < (N); ++(i))

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  int c[n];
  rep(i, n){
    cin >> a[i];
  }

  int count = 0;
  for(int i = n - 1; i >= 0; --i){
      if(i >= n/2){
        c[i] = a[i];
        if(a[i] == 1){
          ++count;
        }
      }else{
        int sum = 0;
        for(int j = 2; (i + 1) * j <= n; ++j){
          sum += c[(i + 1) * j - 1];
        }
        //printf("%d, %d\n", i + 1, sum);
        if(sum % 2 == a[i]){
          c[i] = 0;
        }else{
          c[i] = 1;
          ++count;
        }
      }
  }

  cout << count << "\n";
  if(count != 0){
    rep(i, n){
      if(c[i] == 1){
        cout << i + 1 << " ";
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cmath>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

const double PI = acos(-1);

int main() {
  double a, b, c, d;
  while (true) {
    cin >> a >> b >> c >> d;
    if (a == -1 && b == -1 && c == -1 && d == -1) break;
    a *= PI / 180;
    b *= PI / 180;
    c *= PI / 180;
    d *= PI / 180;
    cout << int(6378.1 * acos(cos(PI / 2 - a) * cos(PI / 2 - c) + cos(b - d) * sin(PI / 2 - a) * sin(PI / 2 - c)) + 0.5) << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long        
using namespace std;
 
void scan()
{
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
 
}
const int N = 1e6 + 500;
const int mod = 1e9 + 7;
 
vector<pair<int,int>> g[N];
int ans[N];
void dfs(int v, int p,  int s)
{
	if (s % 2 == 0)
	{
		ans[v] = 0;
	}
	else 
	{
		ans[v] = 1;
	}
	for (int i = 0; i < g[v].size(); i++)
	{
		if (g[v][i].first == p)
		{
			continue;	
		}
		dfs(g[v][i].first, v, s + g[v][i].second);
	}
}
int main() 
{
    scan();     
    int n;
    cin >> n;
    for (int i = 1; i <= n - 1; i++)
    {
    	int u, v;
    	cin >> u >> v;
    	int w;
    	cin >> w;
    	g[u].pb({v, w});
    	g[v].pb({u, w});
    }
    int start = -1;
    for (int i = 1; i <= n; i++)
    {
    	if (g[i].size() == 1)
    	{
    		start = i;
    		break;
    	}
    }
    dfs(start, -1, 0);
    for (int i = 1; i <= n; i++)
    {
    	cout << ans[i] << " ";
    }
}     
//JUDGE_ID: 295965SY
//Tis I

Measured memory_bytes: 34528
#include <iostream>
#include <string>

using namespace std;

int main() {
		int sx, sy, tx, ty;
		cin >> sx >> sy >> tx >> ty;

		string iki_x(tx-sx, 'R');
		string iki_y(ty-sy, 'U');
		string kaeri_x(tx-sx, 'L');
		string kaeri_y(ty-sy, 'D');
		
		cout << iki_x << iki_y << kaeri_x << kaeri_y;

		cout << "D" << iki_x << "R" << iki_y << "U" << "L";
		cout << "U" << kaeri_x << "L" << kaeri_y << "D" << "R";
		
		cout << endl;

		return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  vector<vector<int>> A(N, vector<int>(M));
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  int ans =0;
  for(int i=0;i<N;i++){
    int sum = 0;
    for(int j=0;j<M;j++){
      sum += A[i][j]*B[j];
    }
  if(sum + C > 0){
    ans++;
  }
 }
  cout << ans << endl;
}
    

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $H, $W, $K);
$map = [];
for ($i = 0; $i < $H; $i++) {
    fscanf(STDIN, "%s", $c);
    $map[$i] = str_split($c);
}
$HW = pow(2, $H+ $W);
$ans = 0;
for ($i = 1; $i < $HW; $i++) {
    $cnt = 0;
    $selH = intdiv($i, pow(2, $W));
    $selW = $i - pow(2, $W) * $selH;
    if ($selH === 0 || $selW === 0) continue;
    $cnt = 0;
    for ($y = 0; $y < $H; $y++) {
        if (($selH & pow(2, $y)) === 0) continue;
        for ($x = 0; $x < $W; $x++) {
            if (($selW & pow(2, $x)) === 0) continue;
            if ($map[$y][$x] === '#') $cnt++;
        }
    }
    if ($cnt === $K) $ans++;
}
printf("%d", $ans);


Measured memory_bytes: 16252
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define mod  1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

void solve() {

	int n; cin >> n;
	int a[n];
	vector<int>b(n + 1, 0);

	forn(i, n) {
		cin >> a[i];
		b[i + 1] = b[i] + a[i];
	}
	// for (auto x : b)cout << x << endl;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int s = (b[n] - b[i + 1]) % mod;
		ans = (ans + ((a[i] % mod) * (s % mod)) % mod) % mod;
	}

	cout << ans << endl;


}

int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

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

	while (t--) {
		solve();
	}

	return 0;
}

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

int n;
int x[25],y[25],r[25],c[25];
int cover[25];
double d[25][25];
bool check[1<<25];
int cnt,comb,a,b;
int m,ans;
int u;

double dis(int i,int j){
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]) );
}

void cov(int a){
  cover[a] = -1;
  for(int j=a-1;j>=0;j--){
    if(d[j][a]<r[a]+r[j] && u>>j & 1){
      cover[a] = j;
      break;
    }
  }
} 

  
void rec(void){
  int cnt;

  if(check[u])return;
  check[u] = true;

  for(int i=1;i<=4;i++){
    cnt = 0;
    for(int j=0;j<n;j++){
      if( (u>>j & 1) && cover[j]<0 && c[j] == i)cnt++;
    }
    if(cnt==6){
      for(int j=0;j<n;j++){
	if(c[j] == i)u -= 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);

      ans += 6;
      m = max(m,ans);
      rec();
      if(!u)return;
      ans -= 6;

      for(int j=0;j<n;j++){
	if(c[j] == i)u += 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);
    }else{
      for(int j=0;j<n;j++){
	if( (u>>j & 1) && cover[j]<0 && c[j] == i){
	  for(int k=j+1;k<n;k++){
	    if( (u>>k & 1) && cover[k]<0 && c[k] == i){
	      u -= 1<<j;
	      u -= 1<<k;
	      for(int l=0;l<n;l++)cov(l);

	      ans += 2;
	      m = max(m,ans);
	      rec();
	      if(!u)return;
	      ans -= 2;

	      u += 1<<j;
	      u += 1<<k;
	      for(int l=0;l<n;l++)cov(l);
	    }
	  }
	}
      }
    }
  }
}



int main(){
  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)d[i][j] = dis(i,j);
    }

    u = (1<<n) - 1;
    for(int i=0;i<(1<<n);i++)check[i] = false;
    for(int i=0;i<n;i++)cov(i);

    
    m = 0;
    ans = 0;
    rec();

    cout << m << endl;
  }
}

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

using namespace std;
int main() {
    int N;
    cin >> N;
    int mx = 0;
    int now;
    bool res = true;
    for (int i = 0; i < N; i++) {
        cin >> now;
        if (mx - now > 1) {
            res = false;
            break;
        }
        mx = max(now, mx);
    }
    if (res) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
S = np.array(list(S))

ans = None
for c in string.ascii_lowercase:
    cnt = 0
    start = None
    for i, s in enumerate(S):
        if s == c:
            cnt += 1
            if start is not None:
                ans = start + 1, i + 1
                break
            start = i
        else:
            cnt -= 1
            if cnt < 0:
                start = None
                cnt = 0
    if ans:
        break
if ans:
    print(*ans)
else:
    print(-1, -1)


Measured memory_bytes: 14640
def gcd(a,b)
  return b if a % b == 0
  gcd(b, a % b)
end

def lcm(a,b)
  a*b/gcd(a,b)
end

n=gets.to_i
arr=[]
arr=gets.chomp.split(" ").map(&:to_i)
i = 1
x = arr[0]
while i < n
  x = lcm(x, arr[i])
  i = i + 1
end
sum = 0
arr.each do |z|
  sum = sum + x / z
end
print("#{sum % 1000000007}\n")

Measured memory_bytes: 65640