akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int n;
vector<int>a;
int dp[201010];
int lis(){
    rep(i,201010)dp[i] = INT_MAX;
    rep(i,n){
        *lower_bound(dp,dp+201010,a[i]) = a[i];
    }
    return (int)(lower_bound(dp,dp+201010,INT_MAX)-dp);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1 > x2){
        swap(x1,x2);
        swap(y1,y2);
    }
    cin >> n;
    vector<pii>p(n);
    rep(i,n){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    rep(i,n){
        if(p[i].first >= x1 && p[i].first <=x2 && p[i].second >= min(y1,y2) && p[i].second <= max(y1,y2)){
            if(y1 <= y2){
                a.push_back(p[i].second);
            }else{
                a.push_back(y1-p[i].second);
            }
            
        }
    }
    n = (int)a.size();
    int k = lis();
    //cout << k << endl;
    int x = abs(x2-x1);
    int y = abs(y2-y1);
    long double hoge = 20.0-5.0*M_PI;
    long double fuga = 10.0*M_PI - 20.0;
    cout<<setprecision(100);
    if(k == min(x,y)+1){
        cout << 100.0*(long double)(x+y) - hoge*(k-1) + fuga << endl;
    }else cout << 100.0*(long double)(x+y)- hoge*k << endl;
}

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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    
    int count = 0;
    for(int i = a; i <= b; i++){
        if(c%i == 0){
            count++;
        }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3108
n=int(input())
ar=[]
for i in range(n):
    a,b = map(int,input().split())
    ar.append((a,b))
ans=0
ar.reverse()
for ab in ar:
    a = ab[0]+ans
    b = ab[1]
    if a%b!=0:
        ans+=b*(a//b+1)-a
print(ans)


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

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

int n, m;
vec<int> X;

signed main() {
  cin >> n >> m;
  X.resize(m);
  rep (i, m) {
    cin >> X[i];
  }
  sort(all(X));

  vec<int> v;
  repp (i, 1, m) {
    v.push_back(X[i] - X[i-1]);
  }
  sort(all(v));

  int num = m - n;
  int ans = 0;
  rep (i, num) {
    ans += v[i];
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	auto a = vector<int>(n);
	for(auto& b : a) cin >> b;
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

H, W = map(int, readline().split())

import math

if H == 1 or W == 1:
    print(1)
    exit()

total = H * W
ans = (total + 2 - 1) // 2
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

void solve()
{ 
  int x,y;
  cin>>x>>y;
  if (y%2 == 0 && (y<=4*x && y>=2*x)){
    cout<<"Yes";
  }
  else cout<<"No";
}


/*
  
*/
signed main(){
  // int t;
  // cin>>t;
  // while (t--)
  solve();
}
// Check MOD values plox :(


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 solve(long long N, long long M, std::vector<long long> A) {
    priority_queue<long long> Q(A.begin(), A.end());

    while(M--){
        auto q = Q.top(); Q.pop();
        Q.push(q/2);
    }
    long long tot = 0;
    while(Q.size()){
        tot += Q.top(); Q.pop();
    }
    cout << tot << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

int main(){
  int n, x;
  int m[100];

  cin >> n >> x;

  int ans = 0;
  int minv = 1001;

  for(int i=0; i<n; i++){
    cin >> m[i];
    x-=m[i];
    ans++;
    if(m[i] < minv)
      minv = m[i];
  }

  while(x >= minv){
    ans++;
    x-=minv;
  }

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
 
int a[100000];
 
int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];
 
	map<int, int> mp;
	for (int i = 0; i < N; i++)
		mp[a[i]]++;
 
	int ans = 0;
	for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 5120
#[allow(unused)]
use std::io::Write;
use std::collections::{HashMap, HashSet};

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let divs = divisors(n);
    let mut min = std::usize::MAX;
    for d in divs {
        let tmp = d + n / d - 2;
        if tmp < min {
            min = tmp
        }
    }
    println!("{}", min);
}

fn prime_sieve(n: usize) -> Vec<usize> {
    let mut table: Vec<usize> = vec![0; (n + 1) as usize];
    let mut primes: Vec<usize> = Vec::new();

    for i in 2..(n+1) {
        if table[i as usize] == 0 {
            primes.push(i);
            for j in 2..n {
                if i * j > n {
                    break
                }
                table[(i * j) as usize] = 1
            }
        }
    }

    primes
}

fn prime_factor(n: usize) -> HashMap<usize, usize> {
    let mut factors = HashMap::new();

    let primes = prime_sieve((n as f64).sqrt() as usize);
    let mut rest = n;
    for p in primes {
        while rest % p == 0 {
            let count = factors.entry(p).or_insert(0);
            *count += 1;
            rest /= p;
        }
    }
    if rest != 1 {
        factors.insert(rest, 1);
    }

    factors
}

fn divisors(n: usize) -> Vec<usize> {
    prime_factor(n).iter().fold(vec![1], |acc, (&p, &pow)| {
        (0..(pow + 1)).flat_map(|i| acc.iter().map(move |a| a * p.pow(i as u32))).collect()
    })
}


Measured memory_bytes: 12540
#include <iostream>
#include <vector>
using namespace std;
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  void unite(int a, int b) {
    int pa = find(a);
    int pb = find(b);
    int total = s[pa] + s[pb];
    if(pa == pb) return;
    if(s[pa] < s[pb]) p[pa] = pb;
    else p[pb] = pa;
    s[pa] = total;
    s[pb] = total;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  UnionFind uf;
  uf.init(n);
  for(int i=0;i<m;i++) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }
  for(int i=0;i<n;i++) {
    if(uf.p[i] == -1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
def c_guess_the_number():
    N, M = [int(i) for i in input().split()]
    Conds = [[int(i) for i in input().split()] for j in range(M)]

    digit = [-1] * N
    # 同じ桁に異なる数字を割り当てている場合を検出
    for s, c in Conds:
        if digit[s - 1] not in (-1, c):
            return -1
        digit[s - 1] = c

    # N 桁目に 0 を割り当てなければならない場合
    # 基本的に N+1 桁の数となり矛盾するが、例外的に N = 1 だと 0 とすればよい。
    if digit[0] == 0:
        return -1 if N >= 2 else 0

    # 指定されなかった桁は基本的に 0 とすればよいが、N 桁目は 0 にできない。
    # 例外的に、N = 1, M = 0 だと N 桁目も 0 にできる。
    if N == 1 and M == 0:
        return 0
    for d, value in enumerate(digit):
        if value == -1:
            digit[d] = 0 if d != 0 else 1
    return ''.join(map(str, digit))

print(c_guess_the_number())

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string direction;
	cin >> direction;

	int sz = direction.size();

	bool s, n, e, w;
	s = n = e = w = false;
	for (int i = 0; i < sz; ++i) {
		if (direction[i] == 'S') {
			s = true;
		}
		else if (direction[i] == 'N') {
			n = true;
		}
		else if (direction[i] == 'E') {
			e = true;
		} else {
			w = true;
		}
	}

	if (n == s && e == w) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;

}

Measured memory_bytes: 3620
#include<iostream>

using namespace std;

#define MAX 16
#define INV -128

const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

bool dfs(int si, int sj, int n, int map[][MAX], bool vis[][MAX], int now, int left){

  //cout << si << ' ' <<  sj << endl;

  //if( now > 0 ) return false;

  if( now == 0 ){
    --left;
    if( left == 0 ){
      for(int i = 0; i < n; ++i){
	for(int j = 0; j < n; ++j){
	  if( !vis[i+1][j+1] ) return false;
	}
      }
      return true;
    }else{
      for(int i = 0; i < n; ++i){
	for(int j = 0; j < n; ++j){
	  if( map[i+1][j+1] < 0 && !vis[i+1][j+1] ){
	    vis[i+1][j+1]=true;
	    if( dfs( i+1,j+1, n, map,vis,map[i+1][j+1],left) )return true;
	    vis[i+1][j+1]=false;
	    return false;
	  }
	}
      }
    }
  }else{
    for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
      int ti = si+di[k];
      int tj = sj+dj[k];
      if( map[ti][tj] > 0 && map[ti][tj] != INV && !vis[ti][tj] && now+map[ti][tj] <= 0){ 
	vis[ti][tj]=true;
	if( dfs( ti, tj, n, map, vis, now+map[ti][tj],left ) ) return true;
	vis[ti][tj]=false;
      }
    }
  }
  return false;
}

int main()
{
  while(true){
    int n;
    int left=0;
    bool ans=false;
    int map[MAX][MAX];
    bool vis[MAX][MAX];
    cin >> n;
    if( n == 0 ) break;
    for(int i = 0; i < MAX; ++i){
      for(int j = 0; j < MAX; ++j){
	map[i][j] = INV;
	vis[i][j] = false;
      }
    }
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	cin >> map[i+1][j+1];
	if( map[i+1][j+1] < 0 ) ++left;
      }
    }

    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	if( map[i+1][j+1] < 0 ){
	  vis[i+1][j+1]=true;
	  if( dfs( i+1, j+1, n, map, vis, map[i+1][j+1], left ) ) ans = true;
	  else ans = false;
	  goto END;
	}
      }
    }

  END:;
    if( ans ){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 868
# coding: utf-8
# Your code here!

import numpy as np

N, M = map(int, input().rstrip().split(' '))

max_l = 0
min_r = int(1e9)
for _ in range(M):
    l, r = map(int, input().rstrip().split(' '))
    max_l = max(max_l, l)
    min_r = min(min_r, r)
    
output = min_r - max_l + 1
if output < 0:
    print(0)
else:
    print(output)

Measured memory_bytes: 21132
#include <iostream>
using namespace std;
 
int gcd(int a, int b){
    if(b > 0){
        return gcd(b, a % b);
    }else{
        return a;
    }
}
 
int lcm(int a, int b){
    return ((a / gcd(a, b)) * b);
}
 
int main(){
    int a, b;
 
    while( cin >> a >> b ){
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    sc.close();
    long bigger = Math.max(A, B);
    long i = bigger;
    while (true) {
      if (i % A == 0 && i % B == 0) {
        System.out.println(i);
        break;
      }
      i += bigger;
    }
  }
}


Measured memory_bytes: 22356
#include <cstdio>
#include <cstring>
 
int Hash[244140625];
char s[13];  

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(){
  int sum = 0, p = 1;
  
  for(int i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}

int main(){
  int n;
  char com[7];
 
  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);
 
    if(com[0] == 'i'){
      Hash[getKey()] = 1;
    }else{
      if(Hash[getKey()]){
        puts("yes");
      }else{
        puts("no");
      }
    }
  }
 
  return 0;
}



Measured memory_bytes: 19496
import math
N,H=map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
  
B.sort(reverse=True)
max_a = max(A)
count = 0
for b in B:
    if max_a <= b:
        H -= b
        count += 1
        if H <= 0:
            break
    else:
        break
if H > 0:
    count += math.ceil(H / max_a)
print(count)


Measured memory_bytes: 11312
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL check(LL a){
	LL s=0;
	while(a>0)s+=a%10,a/=10;
	return s;
}

int main(){
	LL n,m;
	LL i,j,k;
	LL a,b,c;
	cin>>n;
	a=1,b=1;
	for(i=0;i<n;){
		for(;i<n;){
			cout<<a*b+b-1<<endl;
			i++,a++;
			if(a%10==0)break;
		}
		c=check(a*b+b-1);
		c=(a*b+b-1)/c;
		if(c>=b){
			a/=10,b*=10;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    string s;
    cin >> s;
    bool left[2] = {0}, right[2] = {0};
    if(s[0] >= '0' && s[1] >= '0') left[0] = true;
    if(s[0] >= '0' && s[1] >= '1' && s.substr(0, 2) <= "12") left[1] = true;
    if(s[2] >= '0' && s[3] >= '0') right[0] = true;
    if(s[2] >= '0' && s[3] >= '1' && s.substr(2, 2) <= "12") right[1] = true;
    if(left[0] && left[1] && right[0] && right[1]) cout << "AMBIGUOUS" << endl;
    else if(left[0] && right[1]) cout << "YYMM" << endl;
    else if(right[0] && left[1]) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int inf = 10000000;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll a[N];
    ll max = 0;
    for(int i = 0; i < N; i++){
      cin >> a[i];
      max += a[i] -1;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    int n, k, a, cnt = 0;
    cin >> n >> k;
    map<int, int> m;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> a;
        m[a]++;
        if (m[a] == 1) cnt++;
    }
    for (map<int, int>::iterator it = m.begin();it != m.end();it++) {
        int p = it->second;
        v.push_back(p);
    }
    int ans = 0;
    sort(v.begin(), v.end());
    for (int i = 0; i < cnt-k;i++) {
        ans += v[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 10748
#!/usr/bin/env python3
import sys


def solve(N: int):
    dp = list(range(N + 1))
    for i in [6,9]:
        j = 1
        while i ** j <= N:
            base = i ** j
            idx = 0
            while idx + base <= N:
                dp[idx + base] = min(dp[idx + base], dp[idx] + 1)
                idx += 1
            j += 1
    #print(dp)
    ret = dp[N]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6900
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=1000001;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-M/i*inv[M%i]%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll COMBI(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M*finv[K]%M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    COMinit(MOD);
    ll ans=1;
    FOR(i,2,sqrt(M)+1){
        ll res=0;
        while(M%i==0){
            M/=i;
            res++;
        }
        ans*=COMBI(N+res-1,res,MOD);
        ans%=MOD;
    }
    if(M!=1){
        ans*=N;
        ans%=MOD;
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 27120
#include <iostream>

using namespace std;

int main()
{
    int n;
    int c[50], v[50];
    int sum = 0;
    cin >> n;

    for (int i=0; i<n; ++i)
    {
        cin >> v[i];
    }

    for (int i=0; i<n; ++i)
    {
        cin >> c[i];
    }

    for (int i=0; i<n; ++i)
    {
        if (v[i] - c[i] > 0) sum += v[i] - c[i]; 
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    int n, i;
    char s[4];
    int c[4] = {0};

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

        if (!strcmp(s, "AC")) c[0]++;
        else if(!strcmp(s, "WA")) c[1]++;
        else if(!strcmp(s, "TLE")) c[2]++;
        else if(!strcmp(s, "RE")) c[3]++;

    }

    printf("AC x %d\n"
            "WA x %d\n"
            "TLE x %d\n"
            "RE x %d\n", c[0], c[1], c[2], c[3]);

    return 0;
}



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

using namespace std;

int main()
{
  int64_t N;

  cin >> N;

  vector<int64_t> d;
  d.resize(N);

  for(int64_t i = 0;
      i < N;
      ++i)
    {
      cin >> d[i];
    }

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

  int64_t ans = d[N/2] - d[N/2 - 1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

const int MAXN = 100000 + 10;

int n, m;
bool vis[MAXN];
int a[MAXN], b[MAXN];
int pre[MAXN << 1], to[MAXN << 1], head[MAXN], wcnt;

inline void addedge(int u, int v) {
	wcnt++;
	pre[wcnt] = head[u];
	head[u] = wcnt;
	to[wcnt] = v;
}
inline void add2edge(int u, int v) {
	addedge(u, v);
	addedge(v, u);
}

void solve(int a[], int u) {
	int i;
	
	while(u) {
		vis[u] = true;
		a[0]++;
		a[a[0]] = u;
	
		i = head[u];
		while(i and vis[to[i]])
			i = pre[i];
	
		u = to[i];
	}
}

int main() {
	int i, u, v;
	
	scanf("%d %d", &n, &m);
	for(i=1; i<=m; i++) {
		scanf("%d %d", &u, &v);
		add2edge(u, v);
	}
	
	vis[to[head[1]]] = true;
	solve(a, 1);
	solve(b, to[head[1]]);
	
	printf("%d\n", a[0] + b[0]);
	for(i=a[0]; i; i--)
		printf("%d ", a[i]);
	for(i=1; i<=b[0]; i++)
		printf("%d ", b[i]);
	putchar('\n');
	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

int lbidx(vector<int> x, int y) {
  return lower_bound(x.begin(), x.end(), y) - x.begin();
};

int upidx(vector<int> x, int y) {
  return upper_bound(x.begin(), x.end(), y) - x.begin();
};

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  rep(i, 0, N) {
    cin >> A[i];
  }
  rep(i, 0, N) {
    cin >> B[i];
  }

  int ans = 0;
  int T = 1;
  rep(k, 0, 30) {
    int mod = 2 * T;
    vector<int> Amod(N);
    vector<int> Bmod(N);
    rep(i, 0, N) {
      Amod[i] = A[i] % mod;
      Bmod[i] = B[i] % mod;
    }
    sort(All(Amod));

    ll counter = 0;
    rep(i, 0, N) {
      int bi = Bmod[i];
      // int l1 = lbidx(Amod, T - bi);
      // int r1 = lbidx(Amod, 2 * T - bi);
      // int l2 = lbidx(Amod, 3 * T - bi);
      // int r2 = lbidx(Amod, 4 * T - bi);
      auto l1 = lower_bound(Amod.begin(), Amod.end(), T - bi);
      auto r1 = lower_bound(Amod.begin(), Amod.end(), 2 * T - bi);
      auto l2 = lower_bound(Amod.begin(), Amod.end(), 3 * T - bi);
      auto r2 = lower_bound(Amod.begin(), Amod.end(), 4 * T - bi);
      counter += (r1 - l1) + (r2 - l2);
    }
    if (counter % 2 == 1) ans += T;
    T *= 2;
  }

  cout << ans << endl;
};


Measured memory_bytes: 3432
import math
#import numpy as np 

#参照
#https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 5*10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


X,Y =map(int,input().split())
#x,y = np.sum(1/3*(np.array([[ 2., -1.],[-1.,  2.]])*np.array([X,Y])),axis=1).astype(np.int32)
#print(x)
x = int(X-(X+Y)//3)
y = int(Y-(X+Y)//3)
if (X+Y)%3==0 and x>=0 and y>=0:
    print(cmb(x+y,x,mod))
else:
    print(0)
    


Measured memory_bytes: 255532
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

signed main()
{
  int h,w,n;
  cin>>h>>w>>n;
  int x=max(h,w);
  int y=n%x;
  if(y==0)
    cout<<n/x;
  else
    cout<<(n/x)+1<<endl;
}





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

using namespace std;

#define LL long long int
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// const int oo = 1e9;
const LL oo = 1e18;
// const int MOD = 1e9 + 7;
const int MOD = 998244353;
const int N = 1e5 + 5;
// const long double PI = acos(-1);

pair<int, int> v[N];
int b[N], vis[N];
pair<int, int> ind[N];

void solve() {
    int n, m, i;
    cin >> n;
    for (i=0;i<n;i++) cin >> v[i].first;
    for (i=0;i<n;i++) cin >> v[i].second;
    sort(v, v+n);
    for (i=0;i<n;i++) {
        b[i] = v[i].second;
        ind[i] = {b[i], i};
    }
    sort(b, b+n);
    sort(ind, ind+n);
    int j=0, cnt = 0, more = 0;
    for (i=0;i<n;i++) {
        if (b[i] < v[j].first) {
            cout << "No\n";
            return;
        } 
        cnt = 0;
        while(j + 1 < n && b[i] >= v[j+1].first) {
            j++;
            cnt++;
        }
        i = j;
        if (cnt) more++;
        j++;
    }
    if (more) {
        cout << "Yes\n";
        return;
    }
    for (i=0;i<n;i++) vis[i] = 0;
    int cntvis = 0, now = 0;
    while(!vis[now]) {
        vis[now] = 1;
        now = ind[now].second;
        cntvis++;
    }
    if (cntvis == n) {
        cout << "No\n";
    } else cout << "Yes\n";
}

int main() {
    // FASTIO; 
    int t = 1; 
    // cin >> t;
    for (int tc = 1; tc <= t; ++tc) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _ << ' ' <<
using namespace std;
using vi = vector<int>;
using ll = long long;
void view(const vector<int>& v){for(const auto& e : v)cout << e << " ";cout << endl;}
int gcd(int m, int n){return !n ? m : gcd(n, m%n);}


int main(){
	int i, j;
	ll n;
	cin >> n;
	vi a(n+2);
	a[0] = a[a.size()-1] = 0;
	for(i=1; i<=n; i++) cin >> a[i];
	vi l = a;	vi r = a;
	for (int i = 1; i <= n; ++i) l[i] = gcd(l[i - 1], l[i]);
	for (int i = n; i >= 1; --i) r[i] = gcd(r[i + 1], r[i]);

	int maxCommonDivisor = 0;
	for(i=1; i<=n; i++)
		maxCommonDivisor = max(maxCommonDivisor, gcd(l[i-1], r[i+1]));
	cout << maxCommonDivisor << endl;
	return 0;
}


Measured memory_bytes: 1408
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)})

n, m = map(int,input().split())
p = list(map(int,input().split()))

uf = UnionFind(n)
for i in range(m):
    x, y = map(int,input().split())
    uf.union(p[x - 1], p[y - 1])

cnt = 0
for i in range(n):
    check = uf.check(p[i], i + 1)
    if check:cnt += 1
print(cnt)

Measured memory_bytes: 13812
#include<stdio.h>

int main(void){
    int i,n,m,l,r,ans;

    scanf("%d %d",&n,&m);

    int first = 1;
    int last = n;

    for(i = 0; i < m ;i++){
        scanf("%d %d",&l,&r);

        if(l >= first){
            first = l;
        }
        if(r <= last){
            last = r;
        }
    }
    ans = last - first +1;

    if(ans >= 1){
        printf("%d\n",ans);
    }else{
        printf("0\n");
    }
    
}

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

int main()
{
    int a,b,i,j;
    
    cin >> a >> b;
    while( a != 0 and b != 0)
    {
        for(i=0; i < a ; i++)
        {
            for(j=0; j < b ; j++)
            {
                cout << "#";
            }

            cout << endl;
        }

        cout << endl;
        cin >> a >> b;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#define BASE 26LL
using namespace std;

int main(int argc, char** argv)
{
	char s[12];
	int cnt = 0;
	long long n;
	scanf("%lld", &n);
	while(n > 0)
	{
		n --;
		s[cnt++] = n % BASE + 'a';
		n /= BASE;
	}
	for(int i=cnt-1; i>=0; i--) putchar(s[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 1644
fn main() {
    b();
}

fn first_words(s: &String) -> usize  {
    let bytes = s.as_bytes();
    for (i,&item) in bytes.iter().enumerate() {
        if item == b' ' {
            return i;
        }
    }
    s.len()
}

fn a() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let nums: Vec<i32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    println!("{}",(nums[0] - 1)*(nums[1] - 1));
}

fn b() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let num: i32 = s.trim().parse().unwrap();
    if num < 105 {
        println!("{:?}",0);
    } else if num < 135 {
        println!("{:?}",1);
    } else if num < 165 {
        println!("{:?}",2 );
    } else if num < 189 {
        println!("{:?}",3 );
    } else if num < 195 {
        println!("{:?}",4 );
    } else {
        println!("{:?}",5 );
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 10000;
  REP(i, SZ(s) - SZ(t) + 1) {
    int tmp = 0;
    REP(j, SZ(t)) {
      if (s[i + j] != t[j]) {
        tmp++;
      }
    }
    ans = min(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}


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

print(' '.join(str(a) for a in A))

for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(' '.join(str(a) for a in A))


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>
enum D{E,W,S,N} D;
int n,f,t,i,j,r[7],h[105][105],num[105][105];
int dr[7][5]={{},{4,5,3,2},{1,3,6,4},{1,5,6,2},{1,2,6,5},{1,4,6,3},{3,5,4,2}},M[4][2]={{0,1},{-1,0},{0,-1},{1,0}};//SWNE

void rot(int *f,int *t,int d)
{
	int tmp,i;
	for(i=0;i<4;i++)if(dr[*f][i]==*t)break;
	if(d==3){*t=dr[*f][(i-1+4)%4];return;}//E
	if(d==1){*t=dr[*f][(i+1)%4];return;}//W
	if(d==0){tmp=7-*f;*f=*t;*t=tmp;return;}//S
	if(d==2){tmp=7-*t;*t=*f;*f=tmp;return;}//N
	return;
}

void drop(int y,int x,int t,int f)
{
	int mv[2]={0},mm[2]={-1,-1},s,i,j,a,m;
	for(s=0;s<4;s++)if(dr[t][s]==f)break;
	for(i=0;i<4;i++,s=(s+1)%4)
	{
		if(dr[t][s]>3)
		{
			a=dr[t][s];m=i;
			for(j=0;j<2;j++)
				if(mm[j]<dr[t][s])
				{
					a^=mm[j]^=a^=mm[j];
					m^=mv[j]^=m^=mv[j];
				}
		}
	}
	for(i=0;i<2;i++)
	{
		if(h[y+M[mv[i]][1]][x+M[mv[i]][0]]<h[y][x])
		{
			rot(&f,&t,mv[i]);
			drop(y+M[mv[i]][1],x+M[mv[i]][0],t,f);
			return;
		}
	}
	h[y][x]++;
	num[y][x]=t;
	return;
}

int main()
{
	for(;scanf("%d",&n),n;)
	{
		memset(r,0,sizeof(r));
		memset(h,0,sizeof(h));
		memset(num,0,sizeof(num));
		for(;n--;)
		{
			scanf("%d%d",&t,&f);
			drop(51,51,t,f);
		}
		for(i=0;i<105;i++)
			for(j=0;j<105;j++)
				r[num[i][j]]++;
		for(i=1;i<7;i++)
			printf("%d%s",r[i],i==6?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int h, w, ans, a[N], b[N], cnt[N];
map<int, int> mp;
int main()
{
    std::ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i = 1; i <= h; i++) cin >> a[i] >> b[i];
	for(int i = 0; i < w; i++) mp[i] = i;
	cnt[0] = w;
	for(int i = 1; i <= h; i++)
	{
		a[i]--;
		b[i]--;
		auto it = mp.lower_bound(a[i]);
		int pos = -1;
		while(it != mp.end() and it -> first <= b[i] + 1)
		{
			pos = max(pos, it -> second);
			cnt[it -> first - it -> second]--;
			it = mp.erase(it);
		}
		if(pos >= 0 and b[i] + 1 < w)
		{
			mp[b[i] + 1] = pos;
			cnt[b[i] + 1 - pos]++;
		}
		while(!cnt[ans] and ans < w) ans++;
		if(ans == w) cout << -1 << endl;
		else cout << i + ans << endl;
	}
	return 0;
}


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

num = 0
flg = True
while flg:
  for i in range(N):

    if A[i] %2 != 0:
      flg = False
      break
    else:
      A[i] //=  2
	
  if flg:
    num += 1

print(num)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
        printf("a < b\n");

    else if(a>b)
        printf("a > b\n");

    else if(a==b)
        printf("a == b\n");

    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#define int long long
using namespace std;
signed main(){

  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e=b+c;
  f=a+c;
  if(d%2) cout<<e-f<<endl;
  else cout<<a-b<<endl;
  return 0;

}


Measured memory_bytes: 256
from collections import Counter
n, x, m = map(int, input().split())
appear = [False] * m
r = [x]
appear[x] = True
a = x
i = 1
while True:
    a = (a * a) % m
    if appear[a]:
        if a == 0:
            print(sum(r))
            exit()
        # print(a)
        break
    else:
        appear[a] = True
        r.append(a)
        # if a == 10000:
        #     print(i, a)
        i += 1
        if i == n:
            print(sum(r))
            exit()
cycle_start_i = r.index(a)
cycle_len = len(r) - cycle_start_i
cycle_sum = sum(r[cycle_start_i:])
# print(r[:4]) [10, 100, 10000, 41000]
# print('aa,', cycle_start_i)
# print(cycle_len)
# print(r)
c = Counter(r)
# ans = sum(r) * (n // cycle_len) + sum(r[:(n % cycle_len)])
ans = sum(r[:cycle_start_i]) + cycle_sum * ((n - cycle_start_i) // cycle_len) + sum(r[:((n - cycle_start_i) % cycle_len)])
ans = sum(r[:cycle_start_i]) + cycle_sum * ((n - cycle_start_i) // cycle_len) + sum(r[cycle_start_i:cycle_start_i + ((n - cycle_start_i) % cycle_len)])
print(ans)


Measured memory_bytes: 79324
s = input()
t = input()

def find_common(s1, s2):
    count = 0
    for c,y in zip(s1, s2):
        if c == y:
            count += 1
    return count

start = 0 
end =  len(t)
ans  = 0
while end <= len(s):
    ans  = max(ans, find_common(t, s[start:end]))
    start+=1
    end+=1
print(len(t)- ans)

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

class Main
{
       public static void main(String args[]) throws java.lang.Exception
{
Scanner s= new Scanner(System.in);
double n = Math.sqrt(s.nextDouble());
n= Math.floor(n);
System.out.println((int)Math.pow(n,2));
}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> input(H);
  for (int i = 0; i < H; i++) cin >> input[i];

  for (int i = 0; i < H * 2; i++) {
    cout << input[i / 2] << endl;
  }
}


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

int n;

long long lucas(long long  l1, long long l2)
{
    return l1 + l2;
}

int main(){
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    long long l1 = 1, l2 = 2;
    long long buf;
    for(int i = 1; i < n; i++){
        buf = l1;
        l1 = lucas(l1, l2);
        l2 = buf;
    }

    cout << l1 << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * ((10**6) + 1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10**6) + 1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10**6) + 1)

a = list(set(a))

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans += 1

print(ans)



Measured memory_bytes: 47424
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	N = int(input())
	A = getlist()
	Lmin = [0] * (N + 1)
	Lmax = [0] * (N + 1)
	Lmin[-1] = A[-1]
	Lmax[-1] = A[-1]
	for i in range(N - 1, -1, -1):
		if Lmin[i + 1] % 2 == 0:
			Lmin[i] = A[i] + int(Lmin[i + 1] // 2)
		else:
			Lmin[i] = A[i] + int(Lmin[i + 1] // 2) + 1
		
		Lmax[i] = Lmax[i + 1] + A[i]

	# print(Lmin)
	# print(Lmax)

	if Lmin[0] > 1:
		print(-1)
		return

	Node = [0] * (N + 1)
	Node[0] = 1
	for i in range(N):
		Node[i + 1] = min((Node[i] - A[i]) * 2, Lmax[i + 1])

	# print(Node)
	print(sum(Node))


if __name__ == '__main__':
	main()

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

int main() {
	string s;
	cin>>s;
	
         if(s[2]==s[3] && s[4]==s[5] && s[0]!=s[1]){
               cout<<"Yes"<<endl;
          }else{
	        cout<<"No"<<endl;
          }
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
bool check(int n, int x, int y) {return x>=0&&x<n&&y>=0&&y<=x;}
int dx[6]={-1,-1,0,0,1,1},dy[6]={-1,0,-1,1,0,1},n;
vector<int> a[11];
bool u[11][11];

P dfs(int nx, int ny, int k) {
  P p=P(1,0);
  u[nx][ny]=1;
  for(int i=0; i<6; i++) {
    int x=nx+dx[i],y=ny+dy[i];
    if(!check(n,x,y)) continue;
    if(a[x][y]==0) p.second|=1;
    if(a[x][y]==k&&!u[x][y]) {
      P q=dfs(x,y,k);
      p.first+=q.first;
      p.second|=q.second;
    }
  }
  return p;
}

int main() {
  int k;
  while(cin >> n >> k && n) {
    vector<int> v[n];
    for(int i=0; i<n; i++) {
      for(int j=0; j<=i; j++) {
        int x;
        cin >> x;
        v[i].push_back(x);
      }
    }
    int ans=-(1<<29);
    for(int i=0; i<n; i++) {
      for(int j=0; j<=i; j++) {
        if(v[i][j]) continue;
        for(int l=0; l<n; l++) a[l]=v[l];
        a[i][j]=k;
        memset(u,0,sizeof(u));
        int d[11];
        memset(d,0,sizeof(d));
        for(int x=0; x<n; x++) {
          for(int y=0; y<=x; y++) {
            if(a[x][y]&&!u[x][y]) {
              P p=dfs(x,y,a[x][y]);
              if(!p.second) d[a[x][y]]+=p.first;
            }
          }
        }
        int sum=-d[k]*2;
        for(int l=1; l<10; l++) sum+=d[l];
        ans=max(ans,sum);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1216
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int m,n;
int a[max_n];
int main(){
    scanf("%d%d",&n,&m);
    int sum=0;
    for(int i=1;i<=n;i++)scanf("%d",a+i),sum+=a[i];
    int cnt=0;
    for(int i=1;i<=n;i++)if(a[i]*4*m>=sum)cnt++;
    if(cnt>=m)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

ll modpow(ll p, ll q) {
	ll ans = 1;
	ll pp = p % MOD;
	while (q) {
		if (q & 1) {
			ans *= pp;
			ans %= MOD;
		}
		q = q >> 1;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}
V<ll> fac, invfac;
void precom(int n) {
	fac.resize(0);invfac.resize(0);
	rep(i, n + 1) {
		if (i == 0)fac.push_back(1);
		else fac.push_back((fac[i - 1] * i) % MOD);
		invfac.push_back(modpow(fac[i], MOD - 2));
	}
	return;
}
ll com(int n, int r) {
	if (n < r || n < 0 || r < 0)return 0;
	int k = n - r;
	ll ans = fac[n];
	ans *= invfac[r];
	ans %= MOD;
	ans *= invfac[k];
	ans %= MOD;

	return ans;
}

int main() {

	precom(2200000);
	
	int k;
	string s;
	cin >> k >> s;

	int n = s.size();
	k += n;

	ll ans = 0;
	rep_lr(i, n, k + 1) {
		ll pt = 1;
		pt *= com(i - 1, n - 1);
		pt %= MOD;
		pt *= modpow(25, (ll)i - n);
		pt %= MOD;
		pt *= modpow(26, (ll)k - i);
		pt %= MOD;
		ans += pt;
		ans %= MOD;
	}
	cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  int count = 0;
  int ch = 0;
  while(ch == 0)
  {
    for(i = 0; i < n; i++)
    {
      if(a.at(i) / 2 *2 != a.at(i))
      {
        ch = 1;
        break;
      }
      a.at(i) /= 2; 
    }
    if(ch == 0)
    {
      count++;
    }
  }
  cout << count << endl;
}

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

 
char abc[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
vector<string> s;
int n;
 
void solve(int cnt, string now, int t){
    cnt++;
    for(int i=0; i < t; ++i){
        if(cnt == n){
            s.push_back(now+abc[i]);
        }
        else{
            if(i == t-1)solve(cnt, now+abc[i], t+1);
            else solve(cnt, now+abc[i], t);
        }
    }
    return;
}
 
int main() {
    cin >> n;
    solve(0, "", 1);
    sort(s.begin(), s.end());
    for(int i = 0; i < s.size(); ++i){
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 7796
A, B = input().split()

A = int(A)
#B = float(B)
B1, B2, B3 = int(B[0]), int(B[2]), int(B[3])
#print(B1, B2, B3)

A1 = A*B1*100
A2 = A*B2*10
A3 = A*B3*1

ans = (A1+A2+A3) // 100

print(ans)


Measured memory_bytes: 9200
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    X = int(inputs[0])
    i = 1
    current = 0
    while current < X:
        current += i
        i += 1
    return i - 1


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 38748