akhauriyash/Code-Regression huggingface dataset:
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n = int(input().strip())
    S = input().strip()
    cnt=1
    for i in range(1,n):
        if (S[i]==S[i-1]):
            pass
        else:
            cnt+=1
    print(cnt)
    return

if __name__ == '__main__':
    main()
'''
find x_cnt

for given n (1<=n<=10**5) ,S (1<=|S|=N<=10**5, \forall i \in [0...(N-1)].a<=S[i]<=z)



(i.e.)
aaabbcdfgggxx
abcdfgx


'''


Measured memory_bytes: 39280
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = int(1e9);
const int MAX = 100002;

int N,C;

struct S
{
    int x,y,z;
}A[MAX];

bool cmp(S a,S b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    else if(a.x==b.x)
        return a.z<b.z;
}

S B[MAX];
int bi = 0;

int main()
{
    scanf("%d%d",&N,&C);

    for(int i = 1;i<=N;i++)
        cin>>A[i].x>>A[i].y>>A[i].z;
    sort(A+1,A+1+N,cmp);

    bi = 1;
    B[bi].x = A[1].x;B[bi].y = A[1].y;B[bi].z = A[1].z;
    for(int i = 2;i<=N;i++)
    {
        int minx = INF,minid = -1;
        for(int j = 1;j<=bi;j++)
        {
            if(A[i].z==B[j].z&&A[i].x>=B[j].y&&B[j].y<minx){
                minid = j;
                minx = B[j].y;
            }
            else if(A[i].x>B[j].y&&B[j].y<minx){
                minid = j;
                minx = B[j].y;
            }
        }
        if(minid == -1)
        {
            bi++;
            B[bi].x = A[i].x;B[bi].y = A[i].y;B[bi].z = A[i].z;
        }
        else
        {
             B[minid].x = A[i].x;B[minid].y = A[i].y;B[minid].z = A[i].z;
        }
    }
    cout<<bi<<endl;

    return 0;
}


Measured memory_bytes: 1408
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,m;
	cin>>n>>m;
	vvint vv(3*m);
	vint dp(3*m);
	multiset<int> se;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		a--,b--;
		vv[b].PB(a+m);
		vv[b+m].PB(a+2*m);
	}
	rep(i,3*m){
		if(i) dp[i] = dp[i-1];
		for(cauto x: vv[i]){
			se.insert(x);
		}
		while(se.size() && *se.begin() < i) se.erase(se.begin());
		if(se.size()){
			dp[i]++;
			se.erase(se.begin());
		}
	}
	int ans = 0;
	rep(i,2*m){
		maxs(ans, dp[i+m]-dp[i]);
	}
	cout<<n-ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

using namespace std;
using ll = long long;

const int maxn = 1e5+10;

int p[maxn],sz[maxn];

ll tot;

int find_set(int x){
	return p[x] == x ? x : p[x] = find_set(p[x]);
}

void union_set(int a,int b){
	a = find_set(a);
	b = find_set(b);
	if(a == b) return;
	if(sz[a] > sz[b]) swap(a,b);
	tot=tot-sz[a]*sz[b];
	p[a] = b;
	sz[b]+=sz[a];
	sz[a] = 0;
}

void init(){
	for(int i=0;i<maxn;++i){
		p[i]=i;
		sz[i]=1;
	}
}

void solve(){
	ll n,m;
	cin >> n >> m;
	init();
	vector<pair<int,int>> g(m);
	vector<ll> ans(m);
	for(int i=0,a,b;i<m;++i){
		cin >> g[i].first >> g[i].second;
	}
	tot = (n*(n-1))/2LL;
	for(int i=m-1;i>=0;--i){
		ans[i] = tot;
		union_set(g[i].first,g[i].second);
	}
	for(int i=0;i<m;++i){
		cout << ans[i] << '\n';
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 3712
n = gets.to_i

w = []

is_ok = true

n.times{
	w << gets.chomp
}

if w.uniq.size != w.size then
	is_ok = false
end

if is_ok then
	(1...n).each{ |i|
		if w[i-1][-1] != w[i][0] then
			is_ok = false
			break
		end
	}
end

if is_ok then
	puts 'Yes'
else
	puts 'No'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<ll> ruiseki(N);
  ruiseki[0] = 0;
  for (int i = 1; i < N; i++) {
    ruiseki[i] = ruiseki[i - 1];
    if (S[i - 1] == 'A' && S[i] == 'C') ruiseki[i]++;
  }
  REP(i, Q) {
    int l, r;
    cin >> l >> r,l--,r--;
    ll ans = ruiseki[r] - ruiseki[l];
    cout << ans << endl;
  }
}

Measured memory_bytes: 4312
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}


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

	int x = 0, max = 0;
	int n;
	string s;
	cin >>n>> s;

	for (int i = 0; i < (int)s.length(); i++)
	{
		if (s[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		if (x > max) {
			max = x;
		}

	}

	cout << max << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define double long double
typedef long long ll;
using namespace std;
signed main() {
	int a,b,k;
	cin>>a>>b>>k;
	rep(i,k){
		if(i%2){
			if(b%2)b--;
			b/=2;
			a+=b;
		}
		else{
			if(a%2)a--;
			a/=2;
			b+=a;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0, K = 0;
  cin >> N >> K; 
  int A, B;
  int ans = 1;
  for(int n = 0; n < N; n++){
    A = ans * 2;
    B = ans + K;
    if(A >= B){
      ans = B;
    }else{
      ans = A;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    let mut ans = 0;
    for i in 1..40000 {
        if i * i <= n {
            ans = i * i;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <cstdio>
#define rg register int
#define rep(a, b, c) for(rg a=b; a<=c; ++a)

int n, m;
int psb[100010], tot[100010];

inline int read() {
	int x=0; char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x;
}

int main() {
	int x, y, ans=0;
	n=read(), m=read();
	rep(i, 1, n) tot[i]=1;
	psb[1]=1;
	rep(i, 1, m) {
		x=read(), y=read();
		if(tot[x]==1&&psb[x])
			psb[x]=0, psb[y]=1;
		else if(psb[x]) psb[y]=1;
		--tot[x]; ++tot[y];
	}
	rep(i, 1, n) if(psb[i]) ++ans;
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
int main()
{
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin>>s;
    ll e=0;
    repA(i,a+1,max(c,d))
    if(s[i]=='#'&&s[i-1]=='#')
        e=1;
    if(e==1)
        cout<<"No";
    else if(c<d)
        cout<<"Yes";
    else
    {
        if(s[b-1]=='.'&&s[b+1]=='.')
            cout<<"Yes";
        else
        {
            repA(i,b,d-1)
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')
            {
                cout<<"Yes";
                return 0;
            }
            cout<<"No";

        }
    }
    return 0;
}


Measured memory_bytes: 640
from collections import deque
N,M = map(int,input().split())
to = [[] for _ in range(N)]
for i in range(M):
  a,b = map(int,input().split())
  a-=1;b-=1
  to[a].append(b)
start,end = map(int,input().split())
start -= 1;end -= 1
#print(to)
INF = float("inf")
Q = deque([(start,0)]) #今の点、何歩目か
visit = [[INF,INF,INF] for _ in range(N)] #三歩目、一歩目、二歩目
visit[start][0] = 0
while Q: #今の点、けんけんぱのどれか、一個前に止まった点
  v,step = Q.popleft()
  now = visit[v][step]
  step = (step+1)%3 #ここでstep+1歩目でvへ行く
  for w in to[v]:
    #print(visit[w][step],step,now)
    if visit[w][step] != INF:
      continue
    Q.append((w,step)) #step歩目でwにいて次vへ行く。
    if step %3 == 0:
      visit[w][step] = min(visit[w][step],now+1)
    else:
      visit[w][step] = min(visit[w][step],now)
#print(visit)
if visit[end][0] == INF:
  ans = -1
else:
  ans = visit[end][0]
print(ans)

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

using namespace std;

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int square[15][15];
		memset(square, 0, sizeof(square));
		int x, y;
		x = n/2;
		y = n/2 + 1;
		for (int i = 1; i <= n*n; ++i)
		{
			if (square[y][x])
			{
				x = (x-1+n) % n;
				y = (y+1+n) % n;
			}
			square[y][x] = i;
			x = (x+1) % n;
			y = (y+1) % n;
		}
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
				printf("% 4d", square[i][j]);
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n;
	n=s.size();
	int a=n,b=n;
	rep(i,n){
		if(s[i]-'0'==i%2)a--;
		if(s[i]-'0'==(i+1)%2)b--;
	}
	cout<<min(a,b)<<endl;
}


Measured memory_bytes: 512
n = int(input())
x = sorted(list(map(int, input().split())), reverse = True)
x_2 = list(map(lambda x:x ** 2, x))
ichi = sum(x)
jijou = sum(x_2)
re = 10 ** 100


#def ji(p, x):
#    ans = p * (p - 2 * x)
#    return ans

for p in range(x[-1], x[0] + 1):
    second = n * (p ** 2)
    third = -2 * p * ichi
    summ = jijou + second + third

    if re > summ:
        re = summ

print(re)

#for i in range(x[i]):


Measured memory_bytes: 61700
#include<bits/stdc++.h>
#define pb push_back
#define int long long
//#define M 1000000007
#define M 998244353
using namespace std;
const int inf=4e18;
const double pi=3.14159265358979;
int fact(int n)
{
	if(n==0)
		return 1;
	return n*fact(n-1);
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,i,j;cin>>n;
	double x[n],y[n],o=0;
	for(i=0;i<n;i++)
		cin>>x[i]>>y[i];
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			double dis=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
			o+=2*dis*fact(n-1);
		}
	}
	int d=fact(n);
	o=o/d;
	printf("%0.15lf\n",o);
}

Measured memory_bytes: 256
def main():

    N, A, B = map(int, input().split())
    if A > B:
        A, B = B, A

    if (B-A) % 2 == 0:
        return (B-A) // 2
    else:
        a = N-B + (B-A) // 2 + 1
        b = A-1-0 + (B-A) // 2 + 1
        return min(a, b)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


bool is_prime(int N){
    
    if (N == 1) return false;
    
    int sqn = sqrt(N);
    
    for(auto i = 2; i<=sqn; i++){
        if (N % i == 0) return false;
    }
    return true;
}

const int MAX = 200000;

long long fac[MAX];
long long finv[MAX];
long long inv[MAX];

void binom_init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; ////  inv[i] = div(1,i) =  (1/i) mod M;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long binom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

    
    int temp(m);
    int i = 2;
    map<int,int> mp;
    while(temp != 1){
        while(temp%i ==0){
            mp[i]++;
            temp/=i;
        }
        i++;
    }
    
    
    ll ans = 1;
    
    binom_init();
    
    for(auto p: mp){
        ans *= (ll)binom(n+p.second-1,p.second);
        ans%=MOD;
    }
    
    cout<<ans<<endl;
    
    
    
    return 0;
}






Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v(5,0);
    rep(i,0,5){
        cin>>v[i];
    }
    int ans=0;
    rep(i,0,5){
        ans+=v[i];
        if(ans%10){
            ans+=10-ans%10;
        }
    }
    int res=100;
    rep(i,0,5){
        if(v[i]%10){
            res=min(res,v[i]%10);
        }
    }
    if(res==100) cout <<ans<<"\n";
    else cout <<ans-10+res<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int main()
{
  int N,K;
  cin >> N >> K;

  vector<vector<P> > vec;
  vec.resize(3);
  vec[0].resize(2),vec[1].resize(2),vec[2].resize(2);
  vec[0][0] = vec[1][0] = vec[2][0] = P(1,0);//P(1,2)
  map<int,int> Kdays;
  for(int i=0;i<K;i++)
    {
      int a,b;
      cin >> a >> b;
      a--,b--;
      Kdays[a] = b;
    }
  
  for(int i=0;i<N-1;i++)
    {
      vec[0][1] = vec[1][1] = vec[2][1] = P(0,0);

      int pasta = -1;
      if(Kdays.find(i) != Kdays.end())
	pasta = Kdays[i];
    
      for(int j=0;j<3;j++)
	{
	  if(pasta != -1 && pasta != j)
	    continue;

	  for(int k=0;k<3;k++)
	    {
	      if(vec[j][0].F != 0)
		{
		  if(j == k)
		    vec[k][1].S += vec[j][0].F%10000;
		  else
		    vec[k][1].F += vec[j][0].F%10000;
		} 

	      if(vec[j][0].S != 0 && j != k)
		  vec[k][1].F += vec[j][0].S%10000;
	    }
	}    

    
      vec[0][0] = vec[0][1], vec[1][0] = vec[1][1], vec[2][0] = vec[2][1];
    
    }

  long long ans = 0;
  int pasta = -1;
  if(Kdays.find(N-1) != Kdays.end())
    pasta = Kdays[N-1];
    
  for(int i=0;i<3;i++)
    if(pasta != -1 && pasta != i)
      continue;
    else
      ans += vec[i][0].F%10000,ans += vec[i][0].S%10000;
    
  cout << ans%10000 << endl;

  return 0;
}

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

#define M_C 10e5
int main()
{
	vector<int> D(M_C, INT32_MAX);
	D[0] = 0;

	vector<int> H(M_C);
	int N;
	int K;
	cin >> N;
	cin >> K;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	for (int i = 0; i < N - 1; i++) {
		for (int j = i  + 1; j <= min(i + K, N - 1); j++) {
			D[j] = min(D[j], D[i] + abs(H[i] - H[j]));
		}
	}

	cout << D[N - 1] << endl;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <string.h>
int main()
{
	int i,n;
	int len;
	int k;
	char s[100005];
	scanf("%s", s);
	scanf("%d", &k);
	len = strlen(s);
	if(len == 1)
	{
		for(i = 1 ; i <= k ; i++)
		{
			if(s[0] == 'z')
			{
				s[0] = 'a';
			}
			else
			{
				s[0] = s[0] + 1;
			}
		}
		printf("%s\n",s);
	}
	else
	{
		for(i = 0 ; i < len ; i++)
		{
			if(s[i] == 'a')continue;
			if(k >= 'z' - s[i] + 1)
			{
				k = k - ('z' - s[i] + 1);
				s[i] = 'a';
			}
			else
			{
				continue;
			}
		}
		for(i = 1 ; i <= k ; i++)
		{
			if(s[len - 1] == 'z')
			{
				s[len - 1] = 'a';
			}
			else
			{
				s[len - 1]++;
			}
		}
		printf("%s\n",s);
	}
	return 0;
}


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

int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	if (a==b)
	{
		cout<<2*a<<endl;
	}
	else
	{
		cout<<2*max(a,b)-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    vl A(N);
    in(N,A);
    
    vl sum(N,0);
    for (int i = N-2; i >= 0; i--) {
        sum[i] += (sum[i+1]+A[i+1])%mod;
        sum[i] %= mod;
    }
    ll ans = 0;
    rep(i,N) ans += A[i]*sum[i]%mod,ans %= mod;
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 6340
s = input()
p = input()

s = s + s
s_arr = list(s)
p_arr = list(p)
i = 0
j = 0
flag = False
while i < len(s_arr) :
	if flag : break
	ii = i
	while (s_arr[ii] == p_arr[j]) :
		ii += 1
		j += 1
		if (j == len(p_arr)) :
			flag = True
			break
		if (ii >= len(s_arr)):
			break
	j = 0
	i += 1

if (flag):
	print("Yes")
else:
	print("No")


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

using namespace std;
const int maxn = 5e5 + 5;
const int logn = 30;
int n, arr[maxn], tot, cnt, last[maxn], pre[maxn];
int x, y, k, q;
unordered_map<int, int> mapp;
vector<int> v;
int read() {
    char ch = getchar();
    int x = 0, f = 1;
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    return x * f;
}
struct node {
    node *lson, *rson;
    int l, r, num;
} tr[maxn * logn * 2], *root[maxn];
inline node *Newnode(node *&root) { return root = &tr[tot++]; }
void update(node *cur, node *ls, node *rs) { cur->num = ls->num + rs->num; }
void build(node *cur, int l, int r) {
    cur->l = l, cur->r = r;
    cur->num = 0;
    if (l == r) return;
    int mid = l + r >> 1;
    build(Newnode(cur->lson), l, mid);
    build(Newnode(cur->rson), mid + 1, r);
}
void modify(node *pre, node *cur, int x) {
    *cur = *pre;
    if (cur->l == x && cur->r == x) {
        cur->num++;
        return;
    }
    int mid = cur->l + cur->r >> 1;
    if (x <= mid)
        modify(pre->lson, Newnode(cur->lson), x);
    else
        modify(pre->rson, Newnode(cur->rson), x);
    update(cur, cur->lson, cur->rson);
}
int query(node *a, node *b, int l, int r) {
    if (b->l == l && b->r == r) {
        return b->num - a->num;
    }
    int mid = b->l + b->r >> 1;
    if (r <= mid)
        return query(a->lson, b->lson, l, r);
    else if (l > mid)
        return query(a->rson, b->rson, l, r);
    else
        return query(a->lson, b->lson, l, mid) +
               query(a->rson, b->rson, mid + 1, r);
}
void Discretization() {
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++)
        if (!mapp[v[i]]) ++cnt, mapp[v[i]] = cnt;
}
int main() {
    n = read(), q = read();
    for (int i = 1; i <= n; i++) arr[i] = read(), v.push_back(arr[i]);
    Discretization();
    for (int i = 1; i <= n; i++) {
        last[i] = pre[mapp[arr[i]]];
        pre[mapp[arr[i]]] = i;
    }
    build(Newnode(root[0]), 0, n);
    for (int i = 1; i <= n; i++) modify(root[i - 1], Newnode(root[i]), last[i]);
    for (int i = 1; i <= q; i++) {
        x = read(), y = read();
        printf("%d\n", query(root[x - 1], root[y], 0, x - 1));
    }
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n;
    cin>>n;
    vector<int>h(n);
    rep(i,0,n){
        cin>>h.at(i);
    }
    int c=0;
    rep(i,0,n-1){
        if(h.at(i)-h.at(i+1)>0){
            c+=h.at(i)-h.at(i+1);
        }
    }
    cout<<c+h.at(n-1)<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <list>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {


	list<int> lnk;

	const int SLEN = 20;
	char com[SLEN];
	int n, key = 0;


	

	scanf("%d", &n);

	for (int i = 0;i < n;i++)
	{
		scanf("%s%d", com, &key);

		if (com[0] == 'i') {
			lnk.push_front(key);
		}
		else if (com[0] == 'd') {

			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					lnk.pop_front();
				}
				else if (com[6] == 'L') {
					lnk.pop_back();
				}
			}
			else {
				for (list<int>::iterator it = lnk.begin();it != lnk.end();it++) {
					if (*it == key) {
						lnk.erase(it);
						break;
					}
				}
			}
		}
	}



	int i = 0;
	for (list<int>::iterator it = lnk.begin();it != lnk.end();it++) {
		if (i++) printf(" ");
		printf("%d", *it);
	}
	printf("\n");

	return 0;
}




Measured memory_bytes: 34364
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S,T; cin>>S>>T;
  S+=S;
  string ans="No";
  rep(i,0,S.size()){
    if(S.substr(i,T.size())==T) ans="Yes";
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var nums = new int[3];
        for(var i = 0; i < 3; i++)
        {
            nums[i] = Convert.ToInt32(input[i]);
        }
        Array.Sort(nums);
        var result = nums[0] + nums[1] == nums[2] ? "Yes" : "No";
        Console.WriteLine(result);
    }
}

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

const int INF = (int)1e9;

int A[100000];
int dp[100000];

int main() {
  ios::sync_with_stdio(false);
  int n; cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  fill(dp, dp + n, INF);
  for(int i = 0; i < n; i++ ) {
    *lower_bound(dp, dp + n, A[i]) = A[i];
  }
  cout << (lower_bound(dp, dp + n, INF) - dp) << endl;
}

Measured memory_bytes: 1976
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
rl = sys.stdin.readline

K = Int()
S = input()

if len(S) <= K:
    print(S)
else:
    ans = ''
    c = 0
    for i in S:
        if c < K:
            ans += i
        else:
            break
        c += 1
    print(ans+'...')

Measured memory_bytes: 61996
n = int(input())
s = list(str(input()))
t = list(str(input()))
p = 0
ans = n * 2

for i in range(n):
    if s[i] == t[0]:
        for x in range(n-i):
            if s[i + x] == t[x]:
                p += 1
            else:
                p = 0
                break
        else:
            ans -= p
            break

print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var Ts = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var M = int.Parse(Console.ReadLine());
            var PX = new List<KeyValuePair<int, int>>();
            for(var i = 0;i<M;i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                PX.Add(new KeyValuePair<int, int>(tmp[0], tmp[1]));
            }
            var sum = Ts.Sum();
            for (var i = 0; i < M; i++)
            {
                var result = sum - Ts[PX[i].Key - 1] + PX[i].Value;
                Console.WriteLine(result);
            }
        }
    }

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

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

  vector<long long> A(N);
  vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    cin >> B.at(i);
  }

  long long ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    A.at(i) += ans;
    if (A.at(i) % B.at(i) == 0) continue;
    ans += B.at(i) - A.at(i) % B.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<string.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<queue>
#include<map>
#define ll long long
#define inf 2e9
using namespace std;
ll a[100005];
int main()
{
	ll n, k, x,num=0,num1,ans=inf;
	scanf("%lld %lld", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	for (int i = 1; i + k - 1 <= n; i++) {
		if (a[i]*a[i + k - 1] > 0) {
			ans = min(ans, max(abs(a[i]), abs(a[i + k - 1])));
		}
		else
			ans = min(ans, a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1])));
	}
	printf("%lld", ans);
	return 0;
}




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

map<int ,int > mp;

int main(){

  int n;int cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(mp[a]==0){
      mp[a]=1;
      cnt++;
      //cout<<mp[a]<<endl;
    }
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>
#include <cstring>
#include <unordered_map>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int L[100010], R[100010];
int cu[100010];
int bu[100010];

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        cin >> L[i] >> R[i];
        L[i]; R[i];
        cu[L[i]]++; cu[R[i]+1]--;
    }
    rep(i, 100002) {
        bu[i + 1] += bu[i] + cu[i + 1];
    }
    int ans = 0;
    rep(i, N+1) {
        if (bu[i] == M)ans++;
    }
    cout << ans << endl;
}

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

#define mem(f, v) memset(f,v,sizeof(f))
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

typedef long long ll;
const int maxn = 100010;
const int inf = ~(1u << 31u);
const ll linf = ~(1llu << 63u);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
    return 0;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=2e3+10;

int n;
pii a[maxn];
ll f[maxn][maxn];

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++) {
    	int x;
    	cin>>x;
    	a[i]=MP(x,i);
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	ll ans=0;
	f[0][0]=0;
	for (int k=0;k<=n;k++)
		for (int i=0;i<=k;i++) {
			int j=k-i;
			if (k==n) {
				ans=max(ans,f[i][j]);
				continue;
			}
			f[i+1][j]=max(f[i+1][j],f[i][j]+(ll)a[i+1+j].fi*(ll)(a[i+1+j].se-(1+i)));
			f[i][j+1]=max(f[i][j+1],f[i][j]+(ll)a[i+j+1].fi*(ll)(n-j-a[i+j+1].se));
		}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 26320
#include <bits/stdc++.h>
using namespace std;
 
int getb(int x){
    int res=0;
res=x+(x-1)/99;
return res;
}
 
int main(){
    int a,b,t=1;
    cin >>a >>b;
  for (int i=0;i<a;i++){
    t*=100;}
 //   cout <<getb(b)<<endl;
    cout << t*getb(b) <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int N = in.nextInt();
        int K = in.nextInt();
        int[] A = new int[N];

        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += A[i] = in.nextInt();
        }

        err.println(sum);

        Set<Integer> P = new TreeSet<>();
        for (int i = 1; i * i <= sum; i ++) {
            if (sum % i == 0) {
                P.add(sum / i);
                P.add(i);
            }
        }

        int result = 1;
        for (int p : P) {
            int[] r = new int[N];
            int rs = 0;
            for (int i = 0; i < N; i++) {
                rs += r[i] = A[i] % p;
            }

            Arrays.sort(r);
            int ls = 0, s = rs;
            for (int i = N - 1; 0 <= i ; i--) {
                if (r[i] == 0) {
                    continue;
                }
                ls += p - r[i];
                s -= r[i];
                if (ls == s) {
                    break;
                }
            }

            err.printf("p: %d, r: %s, rs: %d, ls: %d, s: %d%n", p, Arrays.toString(r), rs, ls, s);

            if (s <= K) {
                result = Math.max(result, p);
            }
        }

        out.println(result);
    }
}


Measured memory_bytes: 48328
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a[3];
	cin >> a[0]; cin >> a[1]; cin >> a[2];
	sort(a,a+3);
	a[0] + a[1] == a[2] ?cout<<"Yes" <<endl:cout<<"No"<<endl ;
} 

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
   

    int n,m,x;
    cin>>n>>m>>x;
    int minn=1e8;
    vector<int> v[n];
    ffor(i,0,n)
    {
        ffor(j,0,m+1)
        {
            int x;
            cin>>x;
            v[i].pb(x);
        }
    }

    ffor(i,0,1<<n)
    {
        int arr[m+1]={0};
        int cost=0;
        ffor(j,0,n)
        {
            if(i&(1<<j))
            {
                cost+=v[j][0];
              //  cout<<j<<" "<<v[j][0]<<endl;
                ffor(k,1,m+1) arr[k]+=v[j][k];
            }
        }
      //  cout<<i<<" "<<cost<<" "<<*min_element(arr+1,arr+1+m)<<endl;
        if(*min_element(arr+1,arr+1+m)>=x)
        {
            minn=min(minn,cost);
        }
    }
    if(minn==1e8) cout<<"-1";
    else cout<<minn;
    
    return 0;
}



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

const int CON = 1e9-1;

signed main(void){
  int H,W,h,w; cin >> H >> W >> h >> w; 
  if( H % h == 0 && W % w == 0 ){ cout << "No" << endl; return 0;}
  
  cout << "Yes" << endl;
  //左上の値は、ギリギリまで大きくしたい
  
  int a = CON/(h*w-1);
 
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      
      if( i % h == h-1 && j % w == w-1 ){ cout << -((h*w-1)*a+1) << " ";}
      else{ cout << a << " ";}
      
    }
    
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2944
use proconio::input;

fn main() {
    input! {
        x: (i32, i32, i32, i32, i32)
    }
    println!(
        "{}",
        match x {
            (0, _, _, _, _) => 1,
            (_, 0, _, _, _) => 2,
            (_, _, 0, _, _) => 3,
            (_, _, _, 0, _) => 4,
            (_, _, _, _, 0) => 5,
            _ => unreachable!(),
        }
    );
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define int long long
typedef long long ll;
typedef pair<int,int>pii;
#define MAXN 11234567890123
#define INF INT_MAX/2
#define MOD 1000000007

string s;

pii rec(int i,int num){
    int ch=0;
    if(i==s.size())return {num,1};
    ch=rec(i+1,s[i]-'0').s;
    int nac=ch*num+rec(i+1,s[i]-'0').f;
    if(i==0)return {nac,ch};
    int aco=rec(i+1,10*num+s[i]-'0').f;
    ch+=rec(i+1,10*num+s[i]-'0').s;
    return {aco+nac,ch};
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(1);
    cout.setf(ios::fixed);


    cin>>s;
    cout<<rec(0,0).f<<endl;

    

    return 0;
} 



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

int main(){
  int n,a,flag=0,cnt=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%2==0){
      cnt++;
      if(a%3==0 || a%5==0){
        flag++;
      }
    } 
  }
  if(flag==cnt){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vec<double> X(N),Y(N);
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i];
    double ans = 1e18;
    
    auto calc = [&](double x,double y){
        vec<double> d(N);
        for(int i=0;i<N;i++){
            double dx = X[i]-x,dy = Y[i]-y;
            d[i] = sqrt(dx*dx+dy*dy);
        }
        sort(d.begin(),d.end(),greater<double>());
        double res = 0;
        for(int i=0;i<K;i++) res += d[i];
        ans = min(ans,res);
        return res;
    };

    auto search_y = [&](double y){
        double l = -1000,r = 1000;
        for(int i=0;i<100;i++){
            double ml = (2*l+r)/3,mr = (l+2*r)/3;
            if(calc(ml,y)<calc(mr,y)) r = mr;
            else l = ml;
        }
        return calc(l,y);
    };

    double l = -1000,r = 1000;
    for(int i=0;i<100;i++){
        double ml = (2*l+r)/3,mr = (l+2*r)/3;
        if(search_y(ml)<search_y(mr)) r = mr;
        else l = ml;
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    deque<char> s(n);
    rep(i,n) cin>>s[i];
    int l=0,r=0;
    rep(i,n){
      if(s[i]=='(') l++;
      else r++;
    }
    //'('<')'なので出来るだけ前に'('をつける
    int cnt=0;
    int i=0;
    while(i!=len(s)){
      if(s[i]=='(') cnt++;
      else cnt--;
      i++;
      if(cnt<0){
        s.push_front('(');
        cnt=0;
        i=0;
      }
    }
    if(cnt>0){
      rep(i,cnt){
        s.push_back(')');
      }
    }
    rep(i,len(s)){
      cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=INF,ans2=0,h,w;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >>n>>k;
vLL(X,n);
	for (LL i = 0;i < n - k + 1;++i) {
		LL l = X[i];
		LL r = X[i + k - 1];
		LL m = min(abs(l), abs(r)) + abs(l - r);
		ans = min(ans, m);
	}
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
const int M=100001;
char a[M],b[M];
set<int>s[27];
set<int>::iterator it;
int main(){
	scanf("%s%s",a+1,b+1);
	int n=strlen(a+1),m=strlen(b+1),now=0;
	long long ans=0;
	for(int i=1;i<=n;i++)s[a[i]-'a'].insert(i);
	for(int i=1;i<=m;i++){
		int t=b[i]-'a';
		if(!s[t].size()){
			puts("-1");
			return 0;
		}
		it=s[t].upper_bound(now);
		if(it!=s[t].end()){
			ans+=(*it)-now;
			now=(*it);
		}else{
			it=s[t].begin();
			ans+=n-now;
			ans+=(*it);
			now=(*it);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5248
#include <cstdio>
using namespace std;

long long Xor(long long a) {
    if (a % 4 == 0) return a;
    if (a % 4 == 1) return 1;
    if (a % 4 == 2) return a + 1;
    return 0;
}

int main() {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld", Xor(a -1) ^ Xor(b));
    return 0;
}

Measured memory_bytes: 128
N, K = gets.split(" ").map(&:to_i)

i = K
num = 0
while i <= N + 1  do 
    min = i * (i - 1) / 2
    max = i * (2 * N - i + 1) / 2
    num += max - min + 1
    i += 1
end

puts num % (10**9 + 7)

Measured memory_bytes: 14260
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
	
	int main(void)
{
	char c;
	long long int a,b;
	
	scanf("%d %c %d",&a,&c,&b);
	
	if(c=='+'){
		printf("%d\n",a+b);
	} else{
		printf("%d\n",a-b);
	}
	return 0;
}

Measured memory_bytes: 128