akhauriyash/Code-Regression huggingface dataset:
mod=10**9+7
n=int(input())
from collections import defaultdict
d=defaultdict(int)#各点の方向ベクトルを管理
z=0#原点にいる際は例外処理したいので別途数える
from math import gcd 
for i in range(n):
    x,y=map(int,input().split())
    if x==y==0:z+=1
    else:
        f=gcd(x,y)
        x//=f;y//=f#非本質な定数倍を削除
        if x<0:x*=-1;y*=-1#偏角は|theta|<=pi/2で十分
        if x==0 and y<0:y=-y
        d[(x,y)]+=1
ans=1
for (a,s) in d:
    if d[(a,s)]==0:continue#すでに数えた
    ng=0
    if (s,-a)in d:ng+=d[(s,-a)];d[(s,-a)]=0
    if (-s,a)in d:ng+=d[(-s,a)];d[(-s,a)]=0
    ans*=(pow(2,d[(a,s)],mod)-1 + pow(2,ng,mod)-1 +1)%mod
    #(a,s)を一本以上使う,ngを((a,s)と直交するもの)を一本以上使う,どちらも使わない
    ans%=mod
    d[(a,s)]=0
print((ans+z-1)%mod)#原点はそれ1つのみでしか使えない　+　1つも使わない例を除外


Measured memory_bytes: 49396
#include <iostream>
#include <string>
using namespace std;
struct shai{
	int num[7];
}; 

int main() {
	struct shai s;
	int book[105];
	for(int i=1;i<=6;i++){
		cin>>s.num[i];
		book[s.num[i]]=i;
	}
	
	int n;
	cin>>n;
	while(n--){
		int shang,qian;
		cin>>shang>>qian;
		switch(book[shang]){
			case 1:
				switch(book[qian]){
					case 2:
						cout<<s.num[3]<<endl;
						break;
					case 3:
						cout<<s.num[5]<<endl;
						break;
					case 4:
						cout<<s.num[2]<<endl;
						break;
					case 5:
						cout<<s.num[4]<<endl;
						break;
					default:
						break;
				}
				break;
			case 2:
				switch(book[qian]){
					case 1:
						cout<<s.num[4]<<endl;
						break;
					case 3:
						cout<<s.num[1]<<endl;
						break;
					case 4:
						cout<<s.num[6]<<endl;
						break;
					case 6:
						cout<<s.num[3]<<endl;
						break;
					default:
						break;
				}
				break;
			case 3:
				switch(book[qian]){
					case 1:
						cout<<s.num[2]<<endl;
						break;
					case 2:
						cout<<s.num[6]<<endl;
						break;
					case 5:
						cout<<s.num[1]<<endl;
						break;
					case 6:
						cout<<s.num[5]<<endl;
						break;
					default:
						break;
				}
				break;
			case 4:
				switch(book[qian]){
					case 1:
						cout<<s.num[5]<<endl;
						break;
					case 2:
						cout<<s.num[1]<<endl;
						break;
					case 5:
						cout<<s.num[6]<<endl;
						break;
					case 6:
						cout<<s.num[2]<<endl;
						break;
					default:
						break;
				}
				break;
			case 5:
				switch(book[qian]){
					case 1:
						cout<<s.num[3]<<endl;
						break;
					case 3:
						cout<<s.num[6]<<endl;
						break;
					case 4:
						cout<<s.num[1]<<endl;
						break;
					case 6:
						cout<<s.num[4]<<endl;
						break;
					default:
						break;
				}
				break;
			case 6:
				switch(book[qian]){
					case 2:
						cout<<s.num[4]<<endl;
						break;
					case 3:
						cout<<s.num[2]<<endl;
						break;
					case 4:
						cout<<s.num[5]<<endl;
						break;
					case 5:
						cout<<s.num[3]<<endl;
						break;
					default:
						break;
				}
				break;
			default:
				break;	
		}
	} 

	return 0;
}

Measured memory_bytes: 3072
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def solve():
    while True:
        n = input()
        if n > 0:
            tmp_lst = []
            for i in xrange(n):
                tmp_lst.append(input())
            lst = compress(tmp_lst)
            accumurate_lst = calc_accumurate_lst(lst)
            max_value = - (10 ** 100)
            size = len(lst)
            for to in xrange(size):
                for frm in xrange(to + 1):
                    value = accumurate_lst[to] if frm == 0 else accumurate_lst[to] - accumurate_lst[frm - 1]
                    if max_value < value:
                        max_value = value
            print max_value
        else:
            sys.exit()

def calc_accumurate_lst(lst):
    accum = [0 for i in lst]
    accum[0] = lst[0]
    for i in xrange(1, len(lst)):
        accum[i] = accum[i - 1] + lst[i]
    return accum
        
#同じ符号の数列は圧縮できる
def compress(tmp_lst):
    lim = len(tmp_lst)
    #リスト圧縮
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9776
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut s: String = iterator.next().unwrap().to_string();

    let patterns: Vec<&str> = vec!["dream", "dreamer", "erase", "eraser"];

    while !s.is_empty() {
        let result = patterns.iter().find(|it| s.ends_with(**it));
        if let Some(x) = result {
            let len = s.len();
            s.truncate(len - x.len());
        } else {
            break;
        }
    }

    if s.is_empty() {
        return "YES".to_string();
    }

    return "NO".to_string()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	int a,b,c,d;
	a=N/1000;
	b=N/100%10;
	c=N/10%10;
	d=N%10;
	if(a==b||b==c||c==d){
		cout<<"Bad"<<endl;
		return 0;
	}
	
	cout<<"Good"<<endl;
}
	
	
	
	
	
	
	

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

using namespace std;

typedef long long LL;

LL n, a[5];

int main() {
    scanf("%lld", &n);
    for (LL i = 0; i < 5; ++i) scanf("%lld", a + i);
    sort(a, a + 5);
    LL ans = (LL)ceil((double)n / (double)a[0]) + 4;
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong H, W, A, B;
	vector<vector<llong>> ans;
	cin >> H >> W >> A >> B;

	ans.resize(H, vector<llong>(W, 0));
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if ((w < A && h < B) || (w >= A && h >= B)) {
				ans[h][w] = 1;
			}
		}
	}

	for (auto h : ans) {
		for (auto w : h)
			cout << w;
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 9088
N = int(input())
A = list(map(int, input().split()))

A.insert(0, 0)
A.append(0)

dist = 0
for i in range(N+1): # 0からN
    dist += abs(A[i+1] - A[i])

for i in range(1, N+1): # 1からN
    if A[i-1] <= A[i] <= A[i+1] or A[i+1] <= A[i] <= A[i-1]:
        ans = dist
        print(ans)
    else:
        ans = dist - 2 * min(abs(A[i-1] - A[i]), abs(A[i+1] - A[i]))
        print(ans)

Measured memory_bytes: 14176
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
stack<P<int,int> > s; 
P<int,int> p[200005];
int ans[200005],mod=998244353;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i,1,n)cin>>p[i].F>>p[i].S;
	sort(p+1,p+n+1);
	ans[n+1]=1;
	s.emplace(MP(2e9,n+1));
	for(int i=n;i>=1;i--){
		while(s.top().F<p[i].F+p[i].S)s.pop();
		ans[i]=ans[i+1];
		ans[i]=(ans[i]+ans[s.top().S])%mod; 
		s.emplace(MP(p[i].F,i));
	}
	cout<<ans[1];
	RE 0;
}




Measured memory_bytes: 3456
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        int[] ABC = new int[3];
        for (int i = 0; i < 3; ++i) {
            ABC[i] = sc.nextInt();
        }
        sc.close();
        Arrays.sort(ABC);

        boolean parity = (ABC[0] + ABC[1] + ABC[2]) % 2 == ABC[2] % 2;
        int tar = 0;
        if (parity) {
            tar = ABC[2];
        } else {
            tar = ABC[2] + 1;
        }

        int ans = 0;
        for (int i = 0; i < 3; ++i) {
            ans += tar - ABC[i];
        }

        System.out.println(ans / 2);
    }
}

Measured memory_bytes: 21844
s = input()

if 0 < int(s[:2]) <= 12 and 0 < int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12 and int(s[2:]) >= 12:
    print('MMYY')
elif 0 < int(s[:2]) < 12 and int(s[2:]) == 0:
    print('MMYY')
elif int(s[:2]) >= 12 > 0 and 0 < int(s[2:]) <= 12:
    print('YYMM')
elif int(s[:2]) == 0 and 0 < int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 9140
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N, X = LI()
X_list = LI()
X_list.sort()

bisect.insort_left(X_list, X)
#  print(X_list)
X_diff = [j-i for i, j in zip(X_list[:-1], X_list[1:])]
result = min(X_diff)
# 全部行けない場合がある
# 1 4 9 など
# すべてステップ幅-1で割り切れなければ不可

for i in range(result+1, 0, -1):
    if all(x % i == 0 for x in X_diff):
        print(i)
        exit()



Measured memory_bytes: 16636
n=int(input())
T=0
H=0
for i in range(n):
    card_t,card_h=input().split()
    if card_t==card_h:
        T+=1
        H+=1
    else:
        if card_t>card_h:
            T+=3
        else:
            H+=3
print(T,H)


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())

def digit_list(num):
    num = str(num)
    num = list(num)
    num = list(map(int,num))
    return num

n = digit_list(n)

if n[0] == n[-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int ans[] = {11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381};

int main(){

  llong n;
  scanf("%lld", &n);

  REP(i,n-1){
    printf("%d ", ans[i]);
  }
  printf("%d\n", ans[n-1]);
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
int A, B, X;
int main() {
	std::cin >> A >> B >> X;
	if (X <= A + B && X >= A) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
static const ll MOD = 1000000007;
 
int N;
vector<vector<int>> G;
vector<ll> memo, memo2;
 
void rec(int p, int v){
	memo[v] = 1, memo2[v] = 1;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		rec(v, G[v][i]);
		memo[v] *= ((memo[G[v][i]] + memo2[G[v][i]]) % MOD);
		memo[v] %= MOD;
		memo2[v] *= memo[G[v][i]];
		memo2[v] %= MOD;
	}
}
 
int main(){
	cin >> N;
	G.resize(N);
	for(int i = 0; i < N - 1; i++){
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	memo.resize(N);
	memo2.resize(N);
	fill(memo.begin(), memo.end(), 0);
	fill(memo2.begin(), memo2.end(), 0);
	rec(-1, 0);
	cout << (memo[0] + memo2[0]) % MOD << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int k, x;
	cin >> k >> x;
	if (500 * k >= x)co("Yes");
	else co("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
ll a[200005];
int main()
{
	int n;
	cin>>n;
	int k;
	cin>>k;
	for(int i=1;i<=n;i++)
	 cin>>a[i];
	ll tmp=1;
	//for(int i=1;i<=k;i++)
	 //tmp=tmp*a[i];
	for(int i=k+1;i<=n;i++)
	{
		if(a[i]>a[i-k])
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, ans = 1000;
  scanf("%d", &n);
  for(int i = 1; i < n; i++){
    int s = i, t = n-i, c = 0;
    for(; s || t; s /= 10, t /= 10) c += s%10 + t%10;
    ans = min(ans, c);
  }
  printf("%d", ans);
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
iter = 0
if len(l)<3:
  print(iter)
  exit()
for i in range(n):
  lst = [j for j in l if j > l[i]]
  if len(lst)<2:
    break
  else:
    #print(lst)
    for k in range(len(lst)):
      for m in range(len(lst)):
        if l[i]+lst[k]>lst[m] and l[i]+lst[m]>lst[k] and lst[m]+lst[k]>l[i] and l[i]!=lst[k] and lst[k]!=lst[m] and lst[m]!=l[i]:
          iter+=1
  
print(int(iter/2))

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define M 998244353
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
  long long int sum=0;
  if(k<=a)
  {
    cout<<k;
    return 0;
  }
  sum+=a;
  if(k<=a+b)
  {
    cout<<sum;
    return 0;
  }
  k=k-a-b;
  cout<<sum-k;
	return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
ll pre[N], pre1[N];
ll a[N];

void solve() {
	int n, k;
    sc(n, k);
    fr(i, 1, n) {
        sc(a[i]);
        pre[i] = pre[i - 1] + a[i];
        pre1[i] = pre1[i - 1] + max(0LL, a[i]);
    }
    ll ans = 0;
    fr(i, k, n) {
        ll val = max(0LL, pre[i] - pre[i - k]) + pre1[n] - pre1[i] + pre1[i - k];
        ans = max(ans, val);
    }
    cout << ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5960
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
string s1,s2;
int memo[1001][1001];

int solve(int l1,int l2){
  if(l1 < 0 or l2 < 0)return 0;
  if(memo[l1][l2] >= 0)return memo[l1][l2];
  //cout << s1[l1] << s2[l2] << endl;
  if(s1[l1] == s2[l2]){
    return memo[l1][l2] = solve(l1 - 1,l2 - 1) + 1;
  }
  return memo[l1][l2] = max(solve(l1,l2-1), solve(l1-1,l2));
}
int main(){
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    fill(memo[0],memo[1001],-1);
    cin >> s1 ;
    cin >> s2;
    cout << solve(s1.length(),s2.length()) - 1 << endl;
  }
}

Measured memory_bytes: 5204
(defparameter abcd (mapcar #'digit-char-p (concatenate 'list (read-line))))

(defun calc (a op1 b op2 c op3 d)
  (+ a (* op1 b) (* op2 c) (* op3 d)))

(defun print-exp (a op1 b op2 c op3 d)
  (format t "~a~a~a~a~a~a~a=7~%"
          a
          (if (= op1 1) "+" "-")
          b
          (if (= op2 1) "+" "-")
          c
          (if (= op3 1) "+" "-")
          d))

(defun solve (abcd)
  (destructuring-bind (a b c d) abcd
      (loop for i below 8
            with  f = 0
            while (= f 0)
            do (destructuring-bind (op1 op2 op3)
                  (loop for j below 3
                        collect (if (= 1 (logand (ash i (* j -1)) 1))
                                  1
                                  -1))
                  (when (= (calc a op1 b op2 c op3 d) 7)
                    (setf f 1)
                    (print-exp a op1 b op2 c op3 d))))))

(solve abcd)


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  ll N, K;
  cin >> N >> K;
  cout << min(N%K, K-N%K) << endl;
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
typedef long long lint;

// solve
int main(){

    lint N, K;
    cin >> N >> K;
    vector<lint> a(N);
    rep(i, N){
        cin >> a[i];
        a[i] %= K;
    }

    vector<lint> sum(N + 1, 0);
    rep(i, N)sum[i + 1] = (sum[i] + a[i]) % K;
    rep(i, N + 1){
        sum[i] -= i;
        sum[i] %= K;
        if(sum[i] < 0)sum[i] += K;
    }

    lint ans = 0;
    map<lint, lint> mp;
    rep(i, N + 1){
        if(i - K >= 0)mp[sum[i - K]]--;
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    
    cout << ans << '\n';
    return 0;

}


Measured memory_bytes: 15872
package main

import (
	"fmt"
)

type Dice struct {
	T, S, E, W, N, B int
}

func (p *Dice) roll(direction rune) {

	if direction == 'S' {
		p.S, p.B, p.N, p.T = p.T, p.S, p.B, p.N
	} else if direction == 'N' {
		p.N, p.B, p.S, p.T = p.T, p.N, p.B, p.S
	} else if direction == 'W' {
		p.W, p.B, p.E, p.T = p.T, p.W, p.B, p.E
	} else if direction == 'E' {
		p.E, p.B, p.W, p.T = p.T, p.E, p.B, p.W
	}

}

func (p *Dice) matching(d Dice) bool {

	ret := false
	
	for j := 0; j < 6; j++ {

		for j := 0; j < 4; j++ { 
			if (p.T == d.T) && (p.S == d.S) && (p.E == d.E) && (p.W == d.W) && (p.N == d.N) && (p.B == d.B) {
				ret = true
				break
			} else {
				p.roll('N')
				p.roll('W')
				p.roll('S')
			}
		}

		if j%2 == 0 {
			p.roll('N')
		} else {
			p.roll('W')
		}
	}
	return ret
}

func main() {

	var t, s, e, w, n, b int

	fmt.Scanln(&t, &s, &e, &w, &n, &b)
	dice1 := Dice{t, s, e, w, n, b}

	fmt.Scanln(&t, &s, &e, &w, &n, &b)
	dice2 := Dice{t, s, e, w, n, b}

	if dice2.matching(dice1) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}



Measured memory_bytes: 1156
#include <stdio.h>
#include <stdlib.h>

int gcd(int a, int b){
    if(a%b == 0)return b;
    else return gcd(b, a%b);
}
int main(void){
    int n, x, a;
    scanf("%d %d %d", &n, &x, &a);
    int ans=abs(a-x);
    for(int i=1; i<n; i++){
        scanf("%d", &a);
        ans=gcd(ans, abs(a-x));
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <cstdio>
using namespace std;
int n;
long long sum=1,qwq=1,m,ans=0;
long long qwqqwq()
{
	for (;n;--n,sum=(sum-3)/2,qwq=(qwq-1)/2)
	{
		if (m==sum/2+1)	return ans+(qwq-1)/2+1;
		else if (m<=sum/2)
			if (m==1) return ans;
			else m--;
		else if (m==sum) return ans+qwq;
		else m=m-sum/2-1,ans+=(qwq-1)/2+1;
	}
	return ans+1;
} 
int main()
{
	scanf("%d%lld",&n,&m);
	for (int i=1;i<=n;++i) sum=sum*2+3,qwq=qwq*2+1;
	cout<<qwqqwq();
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) cout << setfill('0') << setw(len) << right << a << endl;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    int D, N;
    cin >> D >> N;

    int ans;
    if (D == 0) {
        ans = N;
        if (N == 100) ans += 1;
    } else if (D == 1) {
        ans = N * 100;
        if (N == 100) ans += 100;
    } else {
        ans = N * 10000;
        if (N == 100) ans += 10000;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 10005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	const int MOD = 998244353;
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
	inline int Ksm(int x, int k) {
		int ret = 1;
		for (; k; k >>= 1) {
			if (k & 1) ret = Mul(ret, x);
			x = Mul(x, x);
		}
		return ret;
	}
	inline int Inv(int x) {
		return Ksm(x, MOD - 2);
	}
} 
using namespace ModCalculator;

char a[MAXN], b[MAXN];
int n, A, B;
int fac[MAXN], finv[MAXN], dp[MAXN][MAXN];

inline int C(int x, int y) {
	return Mul(fac[x], Mul(finv[y], finv[x - y]));
}

void init() {
	scanf("%s", a + 1);
	scanf("%s", b + 1);
	n = strlen(a + 1);
	for (int i = 1; i <= n; ++i) {
		if (a[i] == '1') {
			(b[i] == '1'? A : B) += 1;
		}
	}
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac[i] = Mul(fac[i - 1], i);
	}
	finv[n] = Inv(fac[n]);
	for (int i = n; i >= 1; --i) {
		finv[i - 1] = Mul(finv[i], i);
	}
}

void solve() {
	dp[0][0] = 1;
	for (int i = 0; i <= A; ++i) {
		for (int j = 1; j <= B; ++j) {
			Inc(dp[i][j], Mul(dp[i][j - 1], j * j));
			if (i > 0) {
				Inc(dp[i][j], Mul(dp[i - 1][j], i * j));
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= A; ++i) {
		Inc(ans, Mul(dp[A - i][B], Mul(Mul(fac[i], fac[i]), Mul(C(A, i), C(A + B, i)))));
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 73860
def main():
    X, K, D = map(int, input().split())

    if X < 0:
        X = -X
    #Xは正の数
    #min abs(X-kD) ただし k = K-2n

    def f(n: int):
        k = K - 2*n
        return X-k*D

    def is_ok(arg):
        #print("n=", arg)
    # 条件を満たすかどうか？問題ごとに定義
        if f(arg) >= 0:
            return True
        else:
            return False

    def meguru_bisect(ng, ok):
        '''
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng ok は  とり得る最小の値-1 とり得る最大の値+1
        最大最小が逆の場合はよしなにひっくり返す
        '''
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    n = meguru_bisect(0, K//2)
    
    ans = min(abs(f(max(0, n-1))),
        abs(f(n)),
        abs(f(min(K//2+1, n+1)))
    )
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 62052
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main()
{
    ll n; cin>>n; ll a[n+2]; for(ll i=1;i<=n;i++) cin>>a[i];
    ll c=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]%2!=0 && i%2!=0) c++;
    }
    cout<<c;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string a,b;
    cin >> a >> b;
    a += b;
    if(sqrt(stoi(a)) == (int)sqrt(stoi(a)))
        cout << "Yes\n";
    else
        cout << "No\n";
    
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	bool ex = false;
	int a, b;
	cin >> a >> b;
	vector<pair<int, int> > p;
	REP(i, b){
		int s, c;
		cin >> s >> c;
		p.push_back(make_pair(s, c));
	}
	REP(i, 1000){
		string nu = to_string(i);
		bool ch = true;
		if(nu.size() != a) ch = false;
		REP(j, b){
			if(nu[p[j].first-1] != '0' + p[j].second) ch = false;
		}
		if(ch){
			ans = i;
			ex = true;
			break;
		}
	}
	if (ex) cout << ans << endl;
	else cout << "-1" << endl;
	
	//cout << ans << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if(A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> H >> W;
	vector<string>vs(H);
	for (auto &i : vs)cin >> i;
	int ans = 0;
	for (int i = 1; i < W; i++) {
		vector<vector<int>>cost(H + 1, vector<int>(H + 1, MOD));
		for (int j = 0; j <= H; j++) {
			cost[j][H] = 0;
			cost[H][j] = 0;
		}
		for (int j = H - 1; j >= 0; j--) {
			for (int k = H - 1; k >= 0; k--) {
				cost[j][k] = cost[j + 1][k + 1] + (vs[H - j - 1][i - 1] == vs[H - k - 1][i]);
			}
		}
		vector<vector<int>>dp(H + 1, vector<int>(H + 1, MOD));
		dp[0][0] = 0;
		for (int j = 0; j <= H; j++) {
			for (int k = 0; k <= H; k++) {
				if (j) {
					dp[j][k] = min({ dp[j][k], dp[j - 1][k] + cost[j - 1][k] });
				}
				if (k) {
					dp[j][k] = min(dp[j][k], dp[j][k - 1] + cost[j][k - 1]);
				}
			}
		}
		ans += dp.back().back();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
//problem_b.go

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	//"strings"
)

const (
	mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

// -----------------------------------------

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

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

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

func sortIntSlice(ns []int) []int {
	sort.Sort(sort.IntSlice(ns))
	return ns
}

func rsortIntSlice(ns []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	return ns
}

// -----------------------------------------

func solve() {
	a := getIntSlice(9)
	n := getInt()
	b := getIntSlice(n)

	var o [9]int

	for i := 0; i < n; i++ {
		for j := 0; j < 9; j++ {
			if b[i] == a[j] {
				o[j] = 1
			}
		}
	}

	if o[0] == 1 && o[3] == 1 && o[6] == 1 || o[1] == 1 && o[4] == 1 && o[7] == 1 || o[2] == 1 && o[5] == 1 && o[8] == 1 || o[0] == 1 && o[1] == 1 && o[2] == 1 || o[3] == 1 && o[4] == 1 && o[5] == 1 || o[6] == 1 && o[7] == 1 && o[8] == 1 || o[0] == 1 && o[4] == 1 && o[8] == 1 || o[2] == 1 && o[4] == 1 && o[6] == 1 {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}

// -----------------------------------------

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
#define mod2 998244353

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main(){
	int N;
	cin>>N;
	vector<int>v;
	for(int i=1;i*i<=N;i++){
		if(N%i)continue;
		v.push_back(i);
		v.push_back(N/i);
	}
	for(int i=1;i*i<=N-1;i++){
		if((N-1)%i)continue;
		v.push_back(i);
		v.push_back((N-1)/i);
	}
	sort(all(v));v.erase(unique(all(v)),v.end());
	int ans=0;
	for(int i:v){
		if(i==1)continue;
		int memo=N;
		while(memo%i==0)memo/=i;
		if(memo%i==1)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
s1=input()
s2=input()

table=[[0 for i in range(len(s1)+1)] for j in range(len(s2)+1)]


for j in range(len(s2)+1):
    table[j][0]=j
for i in range(len(s1)+1):
    table[0][i]=i


for i in range(1,len(s1)+1):
    for j in range(1,len(s2)+1):
        if s1[i-1]==s2[j-1]:
            table[j][i]=min(table[j-1][i]+1,table[j][i-1]+1,table[j-1][i-1])
        else:
            table[j][i]=min(table[j-1][i],table[j][i-1],table[j-1][i-1])+1



print(table[-1][-1])



Measured memory_bytes: 43480
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  if(2*k-1<=n)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

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

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
p = LI()
cnt = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
        cnt += 1
print(cnt)
    



Measured memory_bytes: 68076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner s = new Scanner(System.in);
        int N = Integer.parseInt(s.next());
        int[] a = new int[100];
        for(int i=0;i<100;i++) a[i] = 0;
        for (int i = 0; i < N; i++) a[Integer.parseInt(s.next()) - 1] += 1;
        int count = 0;
        for (int i = 0; i < 100; i++) {
            if (a[i] != 0){
                count ++;
            }
        }
        System.out.println(count);
    }
}


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

int main() {
  string s,t;
  cin>>s>>t;
  int ts=t.size(),ss=s.size();
  int i,j,memo;
  bool key=false;
  
  for(i=0;i<ss-ts+1;i++){
    key=false;
    if(s[ss-i-1]=='?' || s[ss-1-i]==t[ts-1]){
      key=true;
      for(j=1;j<ts;j++){
        if(s[ss-i-1-j]!='?' && s[ss-i-1-j]!=t[ts-1-j]){
          key=false;
          break;
        }
      }
    }
      if(key){
        memo=ss-ts-i;
        break;
      }
    }
    if(key){
    for(i=0;i<ss;i++){
      if(i<memo && s[i]=='?'){
        s[i]='a';
      }
      else if(i<=memo+ts-1 && s[i]=='?'){
        s[i]=t[i-memo];
      }
      else if(s[i]=='?')
        s[i]='a';
    }
      cout<<s;
    }
    else cout<<"UNRESTORABLE";

}

Measured memory_bytes: 256
import itertools

N = int(input())
P = [int(i)-1 for i in input().split()]
Q = [int(i)-1 for i in input().split()]

perm = list(itertools.permutations(range(N),N))

a = sum([1 if list(p)<=P else 0 for p in perm])
b = sum([1 if list(p)<=Q else 0 for p in perm])

print(abs(a-b))


Measured memory_bytes: 8376
n,m=map(int,input().split())
a={}
s=[]
for i in range(m):
    p,y=map(int,input().split())
    if p not in a:
        a[p]=[]
    a[p].append(y)
    s.append((p,y))
b={}
for i in a.keys():
    a[i].sort()
    for j in range(len(a[i])):
        b[(i,a[i][j])]=j+1
for p,y in s:
    print(str(p).zfill(6)+str(b[(p,y)]).zfill(6))

Measured memory_bytes: 53700
N = int(input())
HList = [int(i) for i in input().split(" ")]

count = 0
countList = []

for i in range(N-1) :
    if HList[i+1] <= HList[i] :
        count += 1
    else :
        countList.append(count)
        count = 0
countList.append(count)
print(max(countList))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

int ar[101], chk[101];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int x, n, i, ans, pore = 101, aage = 0;
    cin >> x >> n;
    //pore = aage = x;
    for(i = 0; i < n; i++){
        cin >> ar[i];
        chk[ar[i]]++;
    }
    for(i = x; i < 101; i++){
        if(!chk[i]){
            pore = i;
            break;
        }
    }
    for(i = x; i >= 1; i--){
        if(!chk[i]){
            aage = i;
            break;
        }
    }
    if(pore-x < x-aage) ans = pore;
    else if(pore-x > x-aage) ans = aage;
    else ans = min(pore, aage);
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

char O[100];
char E[100];
char output[100];
void work() {
	scanf("%s", O);
	scanf("%s", E);
	int oi = 0, ei = 0;
	int index = 0;
	int n = min(strlen(O), strlen(E));
	for(int i = 0; i < n; i++) {
		output[index++] = O[oi++];
		output[index++] = E[ei++];
	}
	while(oi <= strlen(O)) {
		output[index++] = O[oi++];
	}
	while(ei <= strlen(E)) {
		output[index++] = E[ei++];
	}
	
	printf("%s", output);
}
int main() {
	work();
	return 0;
}

Measured memory_bytes: 256
/*
============================================================================
Name        : AtCoder3.c
Author :
Version:
Copyright: Your copyright notice
Description : Hello World in C, Ansi - style
============================================================================
*/
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int A, B, tmp, r;

	i_cin2(A, B);
	

	tmp = (B -1) / (A - 1);
	r = (B - 1) % (A - 1);

	if (r) tmp++;
	i_cout(tmp);
	return 0;
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}






Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int N,M,C;
	int B[21];
	int A[15001][21];
	int sum=0;
	int succeed=0;
	int i,j;
	scanf("%d %d %d",&N,&M,&C);
	for(i=1; i<=M; i++){
		scanf("%d",&B[i]);
	}
	for(i=1; i<=N; i++){
		for(j=1; j<=M; j++){
			scanf("%d",&A[i][j]);
		}
	}
	
	for(i=1; i<=N; i++){
		for(j=1; j<=M; j++){
			sum += A[i][j] * B[j];
		}
		if(sum+C > 0)succeed++;
		sum=0;
	}
	printf("%d",succeed);
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
lis = [[int(p) for p in input().split()] for _ in range(2*k)]
people = [0]*n

for i in range(k):
  
  for j in range(lis[2*i][0]):
    print()
    num = lis[2*i+1][j]
    people[num-1] = 1

count = 0
for i in people:
  if i == 0:
    count += 1
    
print(count)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int		main(void)
{
	int h, a;
	cin >> h >> a;
	if (h % a) 
		cout << h / a + 1 << endl;
	else
		cout << h / a << endl;
}


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

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

    vector<vector<int>> adj(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++)
    {
        int a, k;
        cin >> a >> k;
        for (int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            adj[a - 1][x - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << adj[i][j];
            if (j < n - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  
  x=max(a,b)-min(a,b)

  if x%2==1:
    return 'IMPOSSIBLE'

  return max(a,b)-x//2

# main()
print(main())


Measured memory_bytes: 6860
#include <bits/stdc++.h>
using namespace std;
int mat[15][15];
int jym;
int cc(int a,int b,int c,int d,int e)
{
    if(mat[mat[mat[mat[mat[0][a]][b]][c]][d]][e]==0) return 1;
    else return 0;
}

int check(int a,int b,int c,int d)
{
    int ans=0;
    int jym=mat[mat[mat[mat[0][a]][b]][c]][d];
    for(int i=0;i<=9;i++)
    {
        if(i!=a) ans+=cc(i,b,c,d,jym);
    }
    for(int i=0;i<=9;i++)
    {
        if(i!=b) ans+=cc(a,i,c,d,jym);
    }
    for(int i=0;i<=9;i++)
    {
        if(i!=c) ans+=cc(a,b,i,d,jym);
    }
    for(int i=0;i<=9;i++)
    {
        if(i!=d) ans+=cc(a,b,c,i,jym);
    }
    for(int i=0;i<=9;i++)
    {
        if(i!=jym) ans+=cc(a,b,c,d,i);
    }
    ans+=b==a?0:cc(b,a,c,d,jym);
    ans+=b==c?0:cc(a,c,b,d,jym);
    ans+=c==d?0:cc(a,b,d,c,jym);
    ans+=d==jym?0:cc(a,b,c,jym,d);
    return ans;
}

int main()
{
    int ans=0;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            scanf("%d",&mat[i][j]);
        }
    }
    for(int a=0;a<=9;a++)
    {
        for(int b=0;b<=9;b++)
        {
            for(int c=0;c<=9;c++)
            {
                for(int d=0;d<=9;d++)
                {
                    if(check(a,b,c,d)) ans++;
                }
            }
        }

    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3224