akhauriyash/Code-Regression huggingface dataset:
def main():
    n, k = [int(x) for x in input().split()]
    r, s, p = [int(x) for x in input().split()]
    points = {"r":p, "s":r, "p":s}
    flags = [True] * k
    t = input()
    score = 0
    # retstr = ""
    # retstr2 = ""
    for i in range(n):
        score += points[t[i]]
        # retstr2 += str(i % k)
        if not flags[i % k]:
            if t[i] == t[i - k]:
                flags[i % k] = True
                score -= points[t[i]]
                # retstr += "l"
            # else:
            #     retstr += "w"
        else:
            flags[i % k] = False
            # retstr += "w"
        # else:
        #     flags[i % k] = False
    # print(retstr2)
    # print(retstr)
    print(score)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 3828
N = int(input())
plus = []; minus = []
for i in map(int,input().split()):
    if i >= 0:
        plus.append(i)
    else:
        minus.append(i)

lenP = len(plus); lenM = len(minus)

if minus and plus:
    print(sum(plus)-sum(minus))
    for _ in range(lenP-1):
        p = plus.pop(); m = minus.pop()
        print(m, p)
        minus.append(m-p)
    p = plus[0]
    while minus:
        m = minus.pop()
        print(p, m)
        p -= m
    exit()

elif not minus:
    plus = sorted(plus)
    minP = plus[0]
    print(sum(plus)-2*minP)
    if lenP == 2:
        print(plus[1], minP)
        exit()
    for i in range(1, lenP-1):
        print(minP, plus[i])
        minP -= plus[i]
    print(plus[-1], minP)
    exit()

else:
    minus = sorted(minus, reverse=True)
    maxM = minus[0]
    print(2*maxM-sum(minus))
    if lenM == 2:
        print(maxM, minus[1])
        exit()
    for i in range(1, lenM-1):
        print(maxM, minus[i])
        maxM -= minus[i]
    print(maxM, minus[-1])


Measured memory_bytes: 60172
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000000
#define endl "\n"
#define PI 3.14159265358979323846264338327950288

using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

char ch[30][30] ;
bool visited[30][30] ;
int dx[] = { 1 , -1 , 0 , 0 } ;
int dy[] = { 0 , 0 , 1 , -1 } ;
int dist[30][30] ;
int N , M ;
bool isValid( int x , int y ){
    if( x > N || x < 1 || y > M || y < 1 || visited[x][y] || ch[x][y] == '#' )
        return false ;
    return true ;
}
int ans ;
void bfs( int x , int y ){
    queue<pair< int , int> > q ;
    q.push({x , y}) ;
    visited[x][y] = 1 ;
    while( !q.empty() ){
        pair<int, int> p = q.front() ;
        q.pop() ;
        int X = p.first , Y = p.second ;
        for( int i = 0 ; i < 4 ; i++ ){
            if( isValid(X + dx[i], Y + dy[i] ) ){
                visited[X+dx[i]][Y+dy[i]] = 1 ;
                q.push({ X + dx[i] , Y + dy[i]}) ;
                dist[X+dx[i]][Y+dy[i]] = dist[X][Y] + 1 ;
                ans = max( ans , dist[X][Y] + 1 ) ;
            }
        }
    }
}

int main(){
    FAST_IO ;
    cin >> N >> M ;
    
    for( int i = 1 ; i <= N ; i++ ){
        for( int j = 1 ; j <= M ; j++ ){
            cin >> ch[i][j] ;
        }
    }
    for( int i = 1 ; i <= N ; i++ ){
        for( int j = 1 ; j <= M ; j++ ){
            if( ch[i][j] != '#' ){
                bfs(i, j) ;
                memset(visited, 0, sizeof(visited)) ;
                memset(dist, 0, sizeof(dist)) ;
            }
        }
    }
    cout << ans << endl ;
    return 0 ;
  }










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

int main()
{
  string s;
  cin >> s;

  if(s.at(2) == s.at(3)){
    if(s.at(4) == s.at(5)){
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";

  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 repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)


int main(){
  string s;
  cin>>s;
  int l=0,r=s.size()-1,ans=0;
  while(l<=r){
    if(s[l]!=s[r]&&s[l]!='x'&&s[r]!='x'){ans=-1;
    break;}else if(s[l]==s[r]){
      l++,r--;
    }else if(s[l]=='x'){
      l++,ans++;
    }else{r--,ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bitset>
#include <tuple>
#include <string>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cmath>
#ifdef LOCAL
  #include <iostream>
#endif
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;

#ifdef LOCAL
  #define debug_echo(e) cout << "L" << __LINE__ << ": " << e << "\n"
  #define debug_repr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n"
#else
  #define debug_echo(e)
  #define debug_repr(e)
#endif

#define defread(T, fmt) \
  inline T read_ ## T() { \
    T result; \
    scanf(fmt, &result); \
    return result; \
  }
defread(int, "%d")
defread(ll, "%lld")
defread(float, "%f")
defread(double, "%lf")

int gcd(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  while (m != n) {
    if (m > n) m -= n;
    else       n -= m;
  }
  return m;
}
int lcm(int m, int n) {
  if ((0 == m) || (0 == n)) return 0;
  return (m / gcd(m, n)) * n;
}

int main() {
  vector<int> a(4);
  vector<int> b(2);
  a[0] = read_int();
  a[1] = read_int();
  a[2] = read_int();
  a[3] = read_int();
  b[0] = read_int();
  b[1] = read_int();

  sort(all(a));
  sort(all(b));

  printf("%d\n", a[1] + a[2] + a[3] + b[1]);
}

Measured memory_bytes: 2756
A = int(input())
B = int(input())
C = int(input())
X = int(input())
kotae = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500 * i + 100 * j + 50 * k == X:
        kotae += 1
print(kotae)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int N;
  cin >> N;
  cout << N*800-200*(N/15) << endl;

  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll x, y;
        cin >> x >> y;
        if(y >= 2*x && (y)%2 == 0 && 4*x >= y)
            std::cout << "Yes" << std::endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    #preとnowを用意する
    pre = ""
    now = ""
    cnt = 0
    for s in S:
        now += s
        if pre != now:
            cnt += 1
            pre = now
            now = ""
        else:
            pass
    print(cnt)
if __name__ == '__main__':
  main()


Measured memory_bytes: 6044
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] input = sc.nextLine().split(" ");

        int count = 0;
        boolean flag = true;
        while(flag) {
            for(int i = 0;i < n;i++){
                int tmp = Integer.parseInt(input[i]);
                if(tmp % 2 != 0){
                    flag = false;
                    break;
                }
                input[i] = Integer.toString(tmp/2);
            }
            if(flag) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    let mut res = 0;
    for i in 1..=n {
        res += ((i + (n/i)*i) * (n/i)) / 2
    }
    // for i in 1..=n {
    //     for j in 1..=n {
    //         if i % j == 0 {
    //             res += i;
    //         }
    //     }
    // }
    println!("{}", res);
}

// fn calc_multiple_num(base: usize, upper_limit: usize) -> usize {
//     ;
// }

// #[fastout]
// fn main() {
//     input! {
//         n: usize,
//     }
//     let mut res = 0;
//     for k in 1..=n {
//         res += k * f(k);
//     }
//     println!("{}", res);
// }
// 
// fn f(k: usize) -> usize {
//     let mut res = 0;
//     let mut upper_bound = usize::MAX;
//     for i in 1..=k {
//         if i >= upper_bound {
//             break;
//         }
//         if k % i == 0 {
//             res += 1;
//             if k / i == i {
//                 break;
//             } else {
//                 res += 1;
//                 upper_bound = k / i;
//             }
//         }
//     }
//     res
// }


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ac = a*c,ad = a*d,bc = b*c,bd = b*d;
  print(max(max(ac,ad),max(bc,bd)));
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
signs = [1, -1]
coefs = [[-1],[1]]
i = 0
while i < N-2:
  j = 0
  while j < 2:
    coefs[j].append(2*signs[j])
    signs[j] *= -1
    j += 1
  i += 1
coefs[0].append(signs[0])
coefs[1].append(signs[1])
coefs[0].sort()
coefs[1].sort()
A = sorted([int(input()) for _ in range(N)])
print(max([sum([A[i]*coef[i]  for i in range(N)]) for coef in coefs]))

Measured memory_bytes: 61680
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
int h, w, n, m, s, ans = 0, a[100000], num = 0, sum = 0;
int flag = 0;
string str,stt;
int main() {
	cin >> n >> m >> w >> h;
	n = abs(n - w);
	m = abs(m - h);
	for (int i = 0; i < n; i++)
		cout << "R";
	for (int i = 0; i < m; i++)
		cout << "U";
	for (int i = 0; i < n; i++)
		cout << "L";
	for (int i = 0; i < m; i++)
		cout << "D";
	cout << "L";
	for (int i = 0; i < m+1; i++)
		cout << "U";
	for (int i = 0; i < n+1; i++)
		cout << "R";
	cout << "DR";
	for (int i = 0; i < m + 1; i++)
		cout << "D";
	for (int i = 0; i < n + 1; i++)
		cout << "L";
	cout << "U" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

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


Measured memory_bytes: 3528
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
        x: usize,
        ys: [usize; n],
    }

    let mut zs = vec![];
    let mut d = 0;
    zs.push(d);
    
    for y in ys {
        d += y;
        zs.push(d);
    }

    let ans = zs.iter().filter(|z| **z <= x).count();

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


Measured memory_bytes: 4352
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;

ll n;
ll a[81];



void solve(int t)
{
	cin >> n;

	for (int i = 0; i < n; i++) cin >> a[i];

	ll b[n + 1] = {0};
	b[0] = 0;

	for (int i = 1; i < n; i++)
	{
		if (a[i] >= a[i - 1])
		{
			b[i] = b[i - 1] + 1;

		}
	}
	/*
	for (int i = 0; i < n; i++)
	{
		cout << b[i] << " ";
	}*/

	ll rem = 1000;
	ll d = 0;
	for (int i = 0; i < n; i++)
	{
		if (b[i] == 0 and b[i + 1] == 1)
		{
			d = rem / a[i];
			rem -= d * a[i];
		}
		else if (b[i] >= 1 and b[i + 1] == 0)
		{
			rem += d * a[i];
			d = 0;
		}

	}

	cout << rem << endl;





}




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);



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

	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int main(){
	setIO();
	int k, a, b;
	cin>>k>>a>>b;
	for(;a<=b;a++){
		if(a%k==0){
			cout<<"OK\n";
			return 0;
		}
	}
	cout<<"NG\n";
}

Measured memory_bytes: 3600
while True:
    ins = list(map(int, input().split()))
    ls = range(1,ins[0]+1)
    
    if ins[0] == 0 and ins[1] == 0:
        break
        
    else:
        counter = 0
        for i in range(ins[0]-2):
            if ls[i]+ls[i+1]+ls[i+2] <= ins[1]:
                      for j in range(i+1, ins[0]-1):
                        for k in range(j+1, ins[0]):
                            if ls[i] + ls[j] + ls[k] == ins[1]:
                                counter += 1
    print(counter)

Measured memory_bytes: 7656
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);		
	ll a;
	cin>>a;
	string b;
	cin>>b;
	int x = (b[0]-'0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
	ll ans = a*x;
	cout<<ans/100<<endl;
	return 0;
}


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

using namespace std;

#define FOR(i,n)	for(int i=0;i<(int)n;i++)
#define FOB(i,n)	for(int i=n;i>=1;i--)
#define MP(x,y)	make_pair((x),(y))
#define ii pair<int, int>
#define lli long long int
#define ulli unsigned long long int
#define lili pair<lli, lli>
#ifdef EBUG
#define DBG	if(1)
#else
#define DBG	if(0)
#endif
#define SIZE(x) int(x.size())
const int infinity = 2000000999 / 2;
const long long int inff = 4000000000000000999;

typedef complex<long double> point;

template<class T>
T get() {
    T a;
    cin >> a;
    return a;
}

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont){
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T,U> &cont){
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}"; return out;
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  FOR(i, v.size()){
    if(i) out << " ";
    out << v[i];
  }
  out << endl;
  return out;
}

bool ccw(point p, point a, point b){
  if((conj(a - p) * (b - p)).imag() <= 0) return(0);
  else return(1);
}

int main(){
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    
    int k = get<int>();
    vector<lli> A;
    FOR(i, k) A.push_back(get<int>());
    
    lli nmin = 2, nmax = 2;
    
    for(int i = k - 1; i >= 0; i --){
        lli nmx = nmax / A[i];
        nmax = A[i] * nmx;
        DBG cout << "Po tomto muselo ostat najviavc " << nmax << endl;
        if(!nmax){
            cout << -1 << endl;
            return 0;
        }
        nmax += A[i] - 1;
        lli nmn = (nmin + A[i] - 1) / A[i];
        nmin = nmn * A[i];
        DBG cout << "Nehmohlo ostat menej ako " << nmn << " * " << A[i] << endl;
        if(nmin > nmax){
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << nmin << " " << nmax << endl;
    
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

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

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    string buf;
    int a, b, c;
    cin >> buf;
    int answer = 0;
    int n= buf.size();
    for (int i=0;i<(n-1-i);i++)
        if (buf[i] != buf[n-1-i])
            answer ++;
        cout << answer << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;
int main() {
	int h, w; cin >> h >> w;

	vector<vector<char>> c(h * 2, vector<char>(w));

	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
		}
	}

	vector<vector<char>> a(h * 2, vector<char>(w));

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			a[i * 2][j] = c[i][j];
			a[i * 2 + 1][j] = c[i][j];
		}
	}

	rep(i, h * 2) {
		rep(j, w) {
			cout << a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int a,b;
    cin >> a >> b;
    if (b%a == 0) PRINT(a+b);
    else PRINT(b-a);
}

Measured memory_bytes: 256
from math import sqrt, sin, cos, pi


a, b, h, m = list(map(int, input().split()))
ha = ((h * 60 + m) / (12 * 60))
ma = m / 60

d = sqrt(
    (a * sin(2 * pi * ha) - b * sin(2 * pi * ma)) ** 2
     +
    (a * cos(2 * pi * ha) - b * cos(2 * pi * ma)) ** 2
    )
print(d)


Measured memory_bytes: 9500
from bisect import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

INF = 10**10
dp = [-INF]
for a in A:
    if a <= -dp[-1]:
        dp.append(-a)
    else:
        i = bisect(dp, -a)
        dp[i] = -a
ans = len(dp) - 1
print(ans)


Measured memory_bytes: 56024
n, m, x = map(int, input().split())
mtx = []
for i in range(n):
    tmp_ls = list(map(int, input().split()))
    mtx.append(tmp_ls)

cand = []
for i in range(2 ** n):
    text = []
    for j in range(n):
        if ((i >> j) & 1):
            text.append(j)
    cand.append(text)

ret = 10 ** 100

for item in cand:
    kakaku = 0
    rikai = [0] * m
    for val in item:
        kakaku += mtx[val][0]
        for j in range(1, m+1):
            rikai[j-1] += mtx[val][j]
    is_ok = True
    for val in rikai:
        if val < x:
            is_ok = False
            break
    if is_ok:
        ret = min(ret, kakaku)

if ret == 10 ** 100:
    print(-1)
else:
    print(ret)


Measured memory_bytes: 9396
fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" "). map { it.toInt() }
    val A = readLine()!!.split(" "). map { it.toInt() }
    var ret = true
    A.forEach {
        if (it % 2 == 0) {
            if (it % 3 == 0 || it % 5 == 0) {
                // OK
            } else {
                ret = false
            }
        }
    }
    if (ret) {
        println("APPROVED")
    } else {
        println("DENIED")
    }
}

Measured memory_bytes: 37856
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define re(a,n) reverse(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=2e5+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
char ST[twx];
char s[twx];
int topp=0;
void init() 
{
    cin>>s;
    int len=strlen(s);
    ST[++topp]=s[0];
    f1(1,len-1,i)
    {
        if(s[i]=='T'&&ST[topp]=='S') 
        {
            topp--;
        }
		else 
        {
            ST[++topp]=s[i];
        }
    }
	printf("%d\n",topp);
}
void work()
{
	
}
void print()
{
	
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var X = int.Parse(ReadLine());

        var a = X / 500;
        var b = (X % 500) / 5;

        var ans = a * 1000 + b * 5;

        WriteLine(ans);
    }
}


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

int main() {
  int N;
  cin >> N;
  int a;
  a = N % 1000;
  int b;
  if (a == 0){
  cout << 0 << endl;
  }
  else{
    cout << 1000 - a << endl;
  }
  }


Measured memory_bytes: 3624
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
ll gcd(ll a, ll b ){
    ll r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll lcm(ll a, ll b ){
    if(a==0||b==0) return 0;
    return ((a/gcd(a,b))*b);
}
ll pow(ll x, ll ntimes) {
    ll ret = 1;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
        }
        x = x * x;
        ntimes >>= 1;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    vll b(n);
    REP(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    ll amax = 1000000;
    vll cnt(amax+1,0LL);
    REP(i,n){
        for(ll j=2;j*j<=b[i];j++){
            ll c = 0;
            while(a[i]%j==0){
                a[i]/=j;
                c++;
            }
            cnt[j] = max(cnt[j],c);
        }
        cnt[a[i]] = max(cnt[a[i]],1LL);
    }
    mint p = mint(1);
    for(ll j=2;j<=amax;j++){
        p *= mint(pow(j,cnt[j]));
    }
    mint ans = mint(0);
    REP(i,n){
        ans += p/mint(b[i]);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int dx[] = { 1,-1,0,0 };
const int dy[] = { 0,0,-1,1 };
const int maxn = 1e3+5;
int vis[maxn][maxn];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int h,w;
    while (cin >> h >> w) {
        memset(vis,0,sizeof(vis));
        set<PII> dp[2]; int cur,nxt; cur = 0, nxt = 1;
        FOR(i,0,h) {
            FOR(j,0,w) {
                char ch; cin >> ch;
                if (ch == '#') {
                    dp[cur].insert(PII(i,j));
                    vis[i][j]++;
                }
            }
        }
        int ans = 0;
        while (dp[cur].size()) {
            dp[nxt].clear();
            FOR_ALL(k,dp[cur]) {
                const int i = k->first;
                const int j = k->second;
                FOR(d,0,4) {
                    const int x = i+dx[d];
                    const int y = j+dy[d];
                    if (0 <= x && x < h && 0 <= y && y < w && !vis[x][y]) {
                        dp[nxt].insert(PII(x,y));
                        vis[x][y]++;
                    }
                }
            }
            ans++;
            swap(cur,nxt);
        }
        cout << ans-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 51072
#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define tr(x,n) for(int i=x;x<n?i<n:i>=n;x<n?i++:i--)
#define ll long long int
#define pb push_back
#define em emplace_back
#define mp make_pair
#define mt make_tuple
#define debug(c) cout<<c<<endl;
#define isro ios_base::sync_with_stdio(false);
#define find(v,x) find(all(v),x)!=v.end()


using namespace std;
typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;

int main(){
    isro;
    ll X,A;
    cin>>X>>A;
    if(X<A){
        cout<<0<<endl;
    }
    else{
        cout<<10<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
	int A, B, s,t,u,v, w;
	int count = 0;
	int rev = 0;
	cin >> A >> B;
	for(int i = A; i < B+1; i++){
		s = i % 10;
		t = i / 10 %10;
		u = i / 100 % 10;
		v = i / 1000 % 10;
		w = i / 10000;
		if(s == w && t == v){
			count += 1;
		}
	}
	
	cout << count << endl;
}

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

int main(){
  long A;
  cin >> A;
  
  string B;
  char x,p,y,z;
  cin >> x >> p >> y >> z;
  if (x != '0'){
   B = x;
   B += y;
   B += z;
  }
  else{
   B=y;
   B+=z;
  }
  
  int n = stoi(B);
  long long ans = A*n/100;
  cout << ans << endl;
  return 0;
    
}

Measured memory_bytes: 3592
#include<stdio.h>
void trace(int a[],int n){
    int i;
    for(i=0;i<n;i++){
	if(i>0) printf(" ");
	printf("%d",a[i]);
    }
    printf("\n");
}

void insertionSort(int a[],int n){
    int i,j,v;
    for(i=1;i<n;i++){
	v=a[i];
	j=i-1;
	while(j>=0 && a[j]>v){
	    a[j+1]=a[j];
	    j--;
	}
	a[j+1]=v;
	trace(a,n);
    }
}

int main(void){
    int i,n,a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    trace(a,n);
    insertionSort(a,n);
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    S += '.';

    int ans = 0;
    char a = S[0];
    for (int i = 1; i < N+1; i++) if(a != S[i]) a = S[i], ans++;
    
    //cout << ans << endl;
    if(N-ans+2*K >= N) cout << N-1 << endl;
    else cout << N-ans+2*K << endl;
    
    return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

int a[1010];

int main() {
    int i, n;
    scanf("%d", &n);
    bool allneg = true;
    for (i=1; i<=n; ++i) {
        scanf("%d", a+i);
        if (a[i] > 0) {
            allneg = false;
        }
    }
    if (allneg) {
        int mx = -1.5e9;
        int i, mxidx = -1;
        for (i=1; i<=n; ++i) {
            if (mx < a[i]) {
                mx = a[i];
                mxidx = i;
            }
        }
        printf("%d\n", mx);
        printf("%d\n", n - 1);
        for (i=n; i>mxidx; --i) {
            printf("%d\n", i);
        }
        for (i=1; i<mxidx; ++i) {
            puts("1");
        }
    } else {
        lli mx = -1e15;
        int mxidx = -1;
        for (int k=1; k<=2; ++k) {
            lli s = 0;
            for (i=k; i<=n; i += 2) {
                s += max(0, a[i]);
            }
            if (mx < s) {
                mx = s;
                mxidx = k;
            }
        }
        vector<int> v;
        printf("%lld\n", mx);
        int ed = n, cnt = n;
        while ((mxidx & 1) != (ed & 1) || a[ed] <= 0) {
            v.push_back(ed--);
            --cnt;
        }
        int st = 1;
        while ((mxidx & 1) != (st & 1) || a[st] <= 0) {
            v.push_back(1);
            ++st;
            --cnt;
        }
        for (i=ed; i>=st; i-=2) {
            if (a[i] < 0) {
                v.push_back(i - st + 1);
                cnt -= 2;
            }
        }
        while (cnt > 1) {
            v.push_back(2);
            cnt -= 2;
        }
        printf("%d\n", (int)v.size());
        for (int f : v) {
            printf("%d\n", f);
        }
    }
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto A = to!ulong(tokens[0]);
	auto B = to!ulong(tokens[1]);
	auto C = to!ulong(tokens[2]);

	ulong ans = min(A + B + 1, C) + B;
	writeln(ans);
	stdout.flush();
	/*}catch (Throwable e)
	{
	writeln(e.toString());
	}
	readln();*/
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<int> count(N);
  for (int i: range(1, N)) {
    int a;
    std::cin >> a;
    --a;
    ++count[a];
  }
  for (int i: range(0, N)) {
    std::cout << count[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int>x(n),y(n);
    rep(i,n)cin>> x[i] >> y[i];
    auto dist = [&](int i, int j){
        double dx  = x[i] - x[j];
        double dy  = y[i] - y[j];
        return sqrt(dx*dx+dy*dy);
    };
    vector<int> p(n);
    rep(i,n) p[i] = i;
    double len = 0;
    int cnt=0;
    do{
        rep(i,n-1){
            len += dist(p[i],p[i+1]);
        }
        cnt++;
    }while(next_permutation(p.begin(),p.end()));
    cout << fixed << setprecision(10) << len/cnt <<endl;
    return 0;
}

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

int main(){
  int n;
  string str;
  cin >> n >> str;
  for(int i=0; i<str.length(); i++){
    char ch = str[i] + n;
    if(ch > 'Z') cout << (char)('A' + ch - 'Z' - 1);
    else cout << ch;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()


Measured memory_bytes: 13924
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int bit[2*maxn];
int a[maxn];
int n;
void add(int x,int k){for(;x<=2*n;x+=lowbit(x))bit[x]+=k;}
int getsum(int x){int sum=0; for(;x;x-=lowbit(x))sum+=bit[x]; return sum;}
int check(int mid)
{
	for(int i=1;i<=2*n;i++)bit[i]=0;
	ll tot=0,sum=0;
//	printf("***\n");
	add(n,1);
	for(int i=1;i<=n;i++){
		sum+=(a[i]>=mid?1:-1);
		tot+=getsum(sum+n);
		add(sum+n,1);
//		printf("%d %lld %lld\n",i,sum,tot);
//		for(int i=1;i<=2*n;i++)
//			printf("%d ",getsum(i));
//		printf("\n");
	}
//	printf("&&& %d %lld\n",mid,tot);
	return tot>=1ll*n*(n+1)/4;
}
int main()
{
	n=read();
	int mx=-inf,mn=inf;
	for(int i=1;i<=n;i++){
		a[i]=read();
		mx=max(mx,a[i]); mn=min(mn,a[i]);
	}
	int l=mn,r=mx;
	while(l<r){
		int mid=(l+r+1)>>1;
		if(check(mid))l=mid;
		else r=mid-1;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 1408
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N;
    cin>>N;
    if(N % 2 == 1){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 0;
    ll tmp = 5;
    /*
    while(tmp <= N){
        ans += (N / tmp);
        tmp *= 10;
    }
    */
    N /= 2;
    while(tmp <= N){
        ans += N / tmp;
        tmp *= 5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <map>
#include <unordered_map>

#include <type_traits>

using namespace std;
const long long INF = (long long) (1e18)+1;

vector<pair<int, int>> nums;

int main() {
  int n;
  cin >> n;
  unordered_map<int, long long> nums;
  for(int i=0; i<n; ++i) {
    int temp;
    cin >> temp;
    nums[temp]++;
  }

  long long ans = 0;
  for (auto num : nums) {
    ans += (num.first * num.second);
  }

  int q;
  cin >> q;
  for (int i=0; i<q; ++i) {
    long long b,c;
    cin >> b >> c;
    ans += (-b * nums[b]);
    ans += (c * nums[b]);

    nums[c]+=nums[b];
    nums[b] = 0;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 7132
#include <iostream>
#define ll long long
#define f(i, n) for (int i=1; i <= n; i++)
// sort(bb, bb+n);
 
using namespace std;
int main()
{
    ll a,b;
    cin >> a >> b;
    f(i,1000){
        int c = i*.08;
        int d = i*.1;
        if(a == c && b ==d){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll t = n % k;
    cout << min (t, abs(t-k)) << endl;
}


Measured memory_bytes: 256
#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) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << 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++) {
			cerr << " " << Array[i][j];
		}
		cerr << 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)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N, M;
int rui[111111];

signed main() {
	cin >> N >> M;
	rep (i, M) {
		int l, r;
		cin >> l >> r;
		rui[l]++;
		rui[r+1]--;
	}

	repp (i, 1, 1e5+100) {
		rui[i] += rui[i-1];
	}

	int ans = 0;
	repp (i, 1, 1e5+100) {
		if (rui[i] == M) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024