akhauriyash/Code-Regression huggingface dataset:
/*
                        Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
    #include <bits/stdc++.h>
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
                
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
            int result=1;
            while(n>0)
            {   if(n % 2 ==1)
                result=(result * x) % M;
                x=(x*x)% M;
                n=n/2;
            }
        return result % M;
        }     
    signed main()
    {	int a,b;
    	cin>>a>>b;
    	if(a>9 || b>9)
    	cout<<-1;
    	else
    	cout<<a*b;
    
    }

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a%3==0 || b%3==0 || (a+b)%3==0)
			System.out.println("Possible");
		else
			System.out.println("Impossible");
	}
}

Measured memory_bytes: 21972
function main()
    N = pread(Int)
    a = readvec(Int, N)
    c = 0
    for i in 1:2:N
        if isodd(a[i])
            c += 1
        end
    end
    println(c)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 mod_inverse(i64 a, i64 m) {
    i64 x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;
}

void solve(){
    i64 N;
    cin >> N;

    vector<i64> A(N+1);
    rep(i,1,N+1) cin >> A[i];

    i64 mod=1000'000'007;

    vector<i64> fact(200000);
    fact[0]=1;
    rep(i,1,200000) fact[i]=fact[i-1]*i%mod;

    vector<i64> h(200000),s(200000);
    rep(i,1,200000){
        h[i]=(1+mod_inverse(i,mod)*s[i-1]%mod)%mod;
        s[i]=(s[i-1]+h[i])%mod;
    }

    i64 ans=0;
    rep(i,1,N+1){
        i64 c=fact[N]*(h[i]+h[N-i+1]-1+mod)%mod;
        ans+=c*A[i];
        ans%=mod;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    //rep(i,0,10) cout << f(i) << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main () {
int i,j;
char n[100000] = {0};
int  x[1001] = {0};

i = 0;
j = 0;


while(1) {
scanf("%c",&n[i]);
if(n[i] == '0' && n[i-1] == '\n'|| n[0] == '0') {break;}

if(n[i] >= '1' && '9' >= n[i] && n[i] != '\n') {
x[j] += n[i]-48;
}
  if(n[i] == '\n') {
j = j + 1;
}

i= i+1;

}

for(i=0; i < j;i++) {
printf("%d",x[i]);
printf("\n"); 

} 

return 0;

}



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

A = A + A

s1 = [0]
for i in range(N):
    s1.append((A[i] - s1[-1] // 2) * 2)

X = (s1[-1]) // 2
ans = [X]
for i in range(N):
    ans.append((A[i] - ans[-1] // 2) * 2)

print(*ans[:-1], sep=' ')


Measured memory_bytes: 72932
#include <bits/stdc++.h>
using namespace std;
const int thr = 753;

int main(){

    string S;
    cin >> S;

    string buf;
    int temp, diff, diff_min = 1e5;

    // use stoi
    for (int i=0; i<S.size()-2; i++){
        buf = S.at(i);
        buf += S.at(i+1);
        buf += S.at(i+2);
        temp = stoi(buf);
        diff = abs(thr - temp);
        diff_min = min(diff_min, diff);
    }

    cout << diff_min << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    int m = A.back();
    for(int i=N-1; i>=0; i--) {
        if(A[i] < m) {
            B[i] = m - A[i];
        } else {
            m = A[i];
        }
    }

    int max = *max_element(B.begin(), B.end());
    cout << count(B.begin(), B.end(), max) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int a,b;
  char op;
  int bool=1;


  while(bool){
    scanf("%d %c %d",&a,&op,&b);
    switch(op){
      case '+':
        printf("%d\n",a+b);
      break;
      case '-':
        printf("%d\n",a-b);
      break;
      case '*':
        printf("%d\n",a*b);
      break;
      case '/':
        printf("%d\n",a/b);
      break;
      case '?':
        bool=0;
      break;

    }
  }
}



Measured memory_bytes: 2068
def solve():
    from sys import stdin
    f_i = stdin
    
    N, K = map(int, f_i.readline().split())
    p = tuple(map(int, f_i.readline().split()))
    
    idx = 0
    max_s = sum(p[:K])
    s = max_s
    for i, t in enumerate(zip(p, p[K:]), start=1):
        pi, pj = t
        s += (pj - pi)
        if s > max_s:
            max_s = s
            idx = i
    
    ans = (sum(p[idx:idx+K]) + K) / 2
    
    print(ans)

solve()

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	int N;
	cin >> N;
	int t = max(N%10, N/10);
	PRINT(t == 9);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >

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

    ll a, b, k;
    cin >> a >> b >> k;

    ll c = min(a, k);

    a -= c;
    k -= c;

    c = min(b, k);

    b -= c;
    k -= c;

    cout << a << " " << b << "\n";
}


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

int main() {
  string s;cin>>s;
  int n=s.size();
  ll ans=0;
  rep(bit,1<<(n-1)){
    ll a=s[0]-'0';
    rep(i,n-1){
      if(bit&(1<<i)){
        ans+=a;
        a=0;
      }
    a=10*a+s[i+1]-'0';
    }
    ans+=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int>u(m + 3), v(m + 3), w(m + 3);
    int path[n + 3][n + 3];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            path[i][j] = 1e8;
        }
        path[i][i] = 0;
    }
    for(int i = 1; i <= m; i++){
        cin >> u[i] >> v[i] >> w[i];
        path[u[i]][v[i]] = w[i];
        path[v[i]][u[i]] = w[i];
    }
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(path[i][k] + path[k][j] < path[i][j]){
                    path[i][j] = path[i][k] + path[k][j];
                }
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= m; i++){
        if(path[u[i]][v[i]] < w[i]){
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3664
using System;
using System.Linq;

namespace abc080_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] channels = new int[x[1],100010];
            for (int i = 0; i < x[0]; i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); a[2]--;
                channels[a[2],a[0]]++; channels[a[2],a[1]]--;
            }
            int[] b = new int[100010];
            for (int i = 0; i < 100010; i++)
            {
                for (int j = 0; j < x[1]; j++)
                {
                    if (channels[j,i] == 1) b[i - 1]++;
                    else b[i] += channels[j,i];
                }
            }
            int now = 0; int max = 0;
            for (int i = 0; i < 100010; i++)
            {
                now += b[i];
                max = Math.Max(now,max);
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 28856
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

vector<int> P,C;
int D,G;
ll f(int now, ll remain, int chosei){

	if(remain <= 0){
		return 0;
	}
	if(chosei != -1 && now == D && remain <= P[chosei]*(chosei+1)*100 + C[chosei]){
		if(chosei == 1){
			//cout<<remain<<" "<<(P[chosei]-1)*100 * (chosei+1)<<" "<<remain/(chosei+1)/100 + (remain%((chosei+1)*100) == 0 ? 0 : 1)<<" ";
		}
		if(remain <= (P[chosei]-1)*100 * (chosei+1)){
			return remain/(chosei+1)/100 + (remain%((chosei+1)*100) == 0 ? 0 : 1);
		}else{
			return P[chosei];
		}
	}
	if(now == D){
		return LINF;
	}
	ll retval=LINF;
	if(chosei == -1){
	retval = min(retval, f(now+1,remain, -1));
	retval = min(retval, f(now+1,remain, now));
	retval = min(retval, f(now+1,remain-P[now]*(now+1)*100-C[now], -1) + P[now]);
	if(retval == 3){
		//cout<<now<<" "<<remain<<" "<<chosei<<endl;
	}
	}else{
		retval = min(retval, f(now+1,remain, chosei));
		retval = min(retval, f(now+1,remain-P[now]*(now+1)*100-C[now], chosei)) + P[now];
	}
	return retval;

}

int main(void){
	int n,m;
	string s,t;
	int p,c;
	cin>>D>>G;
	rep(i,D){
		cin>>p>>c;
		P.push_back(p);
		C.push_back(c);
	}
	cout<<f(0,G,-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int ans,num;
char ch;
int main(){
  cin>>ans;
  while(1){
    cin>>ch;
    if(ch=='=')break;
    cin>>num;
    if(ch=='+')ans+=num;
    else if(ch=='-')ans-=num;
    else if(ch=='*')ans*=num;
    else ans/=num;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  bool ni = true;
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp%2==1) ni = false;
  }
  if(ni) cout<<"second"<<endl;
  else cout<<"first"<<endl;
}


Measured memory_bytes: 3604
f=!1;while(n=gets.to_i)!=0;f ? puts : 0;f=i=0;puts (1..n).map{t,a,b,c=gets.split;[t,a.to_i*3+c.to_i]}.sort_by{|v|[-v[1],i+=1]}.map{|x|x.join","}.join"\n";end

Measured memory_bytes: 6120
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int m = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      if(m  == -1 && f == -1 && r == -1){
        break;
      }else{
        if(m==-1||f==-1){
          System.out.println("F");
        }else if(m+f>79){
          System.out.println("A");
        }else if(m+f>=65 && m+f<80){
          System.out.println("B");
        }else if(m+f>=50 && m+f<65){
          System.out.println("C");
        }else if(m+f>=30 && m+f<50){
          if(r>=50){
            System.out.println("C");
          }else{
            System.out.println("D");
          }
        }else{
          System.out.println("F");
        }
      }
    }
    sc.close();
  }
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;
 
template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_H = 300;
int h,w,k;
string cake[MAX_H];
int ans[MAX_H][MAX_H];

int main()
{
    fastio();

    cin >> h >> w >> k;
    forn(i,h) cin >> cake[i];

    forn(i,h) forn(j,w) ans[i][j] = 0;

    int c = 1;
    forn(i,h) {
        auto it = find(cake[i].begin(), cake[i].end(), '#');
        if (it == cake[i].end()) continue;
        int fi = it - cake[i].begin();
        forn(j,w) {
            //cout << i << " " << j  << " " << c << endl;
            if (cake[i][j] == '#' && fi < j) c++;
            ans[i][j] = c;
        }
        c++;
    }

    assert(c == k+1);

    forn1 (i,h-1) {
        forn(j, w) {
            if (ans[i][j] == 0)
                ans[i][j] = ans[i-1][j];
        }
    }

    for (int i = h-2; i >= 0; i--) {
        forn(j, w) {
            if (ans[i][j] == 0)
                ans[i][j] = ans[i+1][j];
        }
    }

    forn(i,h) {
        forn(j,w) cout << ans[i][j] << (j == w-1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
long long N, a[100100], bbh[100100], ans = 1;
long long F(long long x){
    if(x == 1) return 0;
    if(bbh[x-1] * 2 >= a[x]) {
        return F(x-1) + 1;
    }
    return 0;
}
int main(){
    long long i;
    cin>>N;
    for(i=1; i<=N; i++) cin>>a[i];
    sort(a+1, a+1+N);
    for(i=1; i<=N; i++) bbh[i] = bbh[i-1] + a[i];
    printf("%lld", F(N)+1);
}


Measured memory_bytes: 1792
use std::str::FromStr;

fn parse() -> Vec<u8> {
    let mut line = String::new();

    // skip first line
    std::io::stdin().read_line(&mut line).unwrap();
    line.clear();

    std::io::stdin().read_line(&mut line).unwrap();
    line.split_whitespace().map(|s| u8::from_str(s).unwrap()).collect()
}

fn main() {
    let hs = parse();

    let mut m = 0;
    let mut count = 0;
    for i in &hs {
        if m <= *i {
            m = *i;
            count += 1;
        }
    }

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


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

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)          memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i,0,v.size())cout << v[i] <<" "; cout << endl;
#define prarr(arr,n)      loop(i,0,n)cout << arr[i] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define db                 ;
#define ld               long double
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) {  db cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{    
     db const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


 
 
void solve()
{

   int n,w;
   cin>>n>>w;
   vii dp(w+1);
   for(int i=0;i<n;i++)
   {
   		int wi,vi;
   		cin>>wi>>vi;
   		for(int wt=(w-wi);wt>=0;wt--)
   		{
   			dp[wt+wi]=max(dp[wt]+vi,dp[wt+wi]);
   		}
   }
   int ans=0;
   for(auto a:dp)ans=max(ans,a);
   	cout<<ans<<endl;
}
 
int32_t main() 
{
    fastio;
  	int t = 1; 
  	//cin>>t;
  	while(t--) solve();
}


Measured memory_bytes: 1024
s=gets.chomp.bytes.map{|b|b-97}
n=gets.to_i
s.size.times{|i|n>=(m=(26-s[i])%26)&&n-=m-s[i]=0}
s[-1]=(s[-1]+n)%26
puts s.map{|e|(e+97).chr}*''

Measured memory_bytes: 7668
from itertools import accumulate
N, M = map(int, input().split())
imos = [0] * (N + 2)
for i in range(M):
    l, r = map(int, input().split())
    imos[l] += 1
    imos[r + 1] -= 1

imos = list(accumulate(imos))

ans = 0
for im in imos:
    ans += (im == M)

print(ans)


Measured memory_bytes: 8120
fun main() {
  val (N, M) = readInts()
  val edges = Array(N + 1) { mutableSetOf<Int>() }
  repeat(M) {
    val (a, b) = readInts()
    edges[a].add(b)
    edges[b].add(a)
  }
  fun isOk(list: List<Int>): Boolean {
    if (list.first() != 1) return false
    for (i in 0 until N - 1) {
      val a = list[i]
      val b = list[i + 1]
      if (!edges[a].contains(b)) return false
    }
    return true
  }

  val permList = permute((1..N).map { it })
  var sum = 0L
  for (perm in permList) {
    if (isOk(perm)) sum++
  }
  println(sum)
}

fun <Int> permute(list: List<Int>): List<List<Int>> {
  if (list.size == 1) return listOf(list)
  val perms = mutableListOf<List<Int>>()
  val sub = list[0]
  for (perm in permute(list.drop(1)))
    for (i in 0..perm.size) {
      val newPerm = perm.toMutableList()
      newPerm.add(i, sub)
      perms.add(newPerm)
    }
  return perms
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 44280
#include <iostream>
using namespace std;
long long N;
int cnt, Dig[30];
int sum = 0;
int ans = 0;
void desc()
{
    while(N > 0)
    {
        Dig[++cnt] = N % 10;
        sum += N % 10;
        N /= 10;
    }
}
void Solve()
{
    ans = sum;
    int s = 0;
    sum = 0;
    for(int i = cnt; i >= 1; i--)
    {
        if(Dig[i] == 0)
            continue;
        sum += Dig[i];
        s = sum - 1 + 9 * (i - 1);
        ans = max(ans, s);
    }
    cout << ans << "\n";
}
int main()
{
    cin >> N;
    desc();
    Solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] arr = new int[n + 1];

        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(sc.next());
        }

        arr[n] = x;
        int[] memo = new int[n+1];
        for (int i = 0; i < n; i++) {
            memo[i] = arr[i + 1] - arr[i];
        }

        int gcd = IntStream.of(memo).mapToObj(BigInteger::valueOf) 
                .reduce(BigInteger::gcd) 
                .orElse(BigInteger.ZERO)
                .intValue();

        System.out.println(gcd);

    }
}

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

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

    vector<int> memo1(n+1, 1001001001);
    vector<int> coins;
    coins.push_back(1);
    for(int i = 6; i <= n; i *= 6) coins.push_back(i);
    for(int i = 9; i <= n; i *= 9) coins.push_back(i);
    memo1[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < coins.size(); j++){
            if(i-coins[j] >= 0){
                if(memo1[i] > memo1[i-coins[j]]+1){
                    memo1[i] = memo1[i-coins[j]]+1;
                }
            }
        }
    }
    cout << memo1[n] << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int r; 
    cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

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

using namespace std;

#define MAX 1000000
 
int main()
{
    int m, n;
     
    while (cin >> m, m) {
        cin >> n;
        int cnt = 0;
        for (int i = m; i <= n; i++) {
            int tmp = i;
            while (!(tmp%2) || !(tmp%3) || !(tmp%5)) {
                if (!(tmp%2)) tmp /= 2;
                else if (!(tmp%3)) tmp /= 3;
                else if (!(tmp%5)) tmp /= 5;
            }
            if (tmp == 1) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string sa,sb,sc;cin >> sa >> sb >> sc;
  queue<char> qa,qb,qc;
  int i,j,k;
  rep(i,sa.size()) qa.push(sa[i]);
  rep(i,sb.size()) qb.push(sb[i]);
  rep(i,sc.size()) qc.push(sc[i]);
  char ans = 'a';
  while(1){
    if(ans=='a'){if(qa.empty()) break;ans=qa.front();qa.pop();}
    if(ans=='b'){if(qb.empty()) break;ans=qb.front();qb.pop();}
    if(ans=='c'){if(qc.empty()) break;ans=qc.front();qc.pop();}
  }
  cout << (char)(ans+'A'-'a') << endl;
}


Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define pi   3.14159265359
#define N  100005

int main()
{
	ios
	double a,b,h,m,ans;
	cin>>a>>b>>h>>m;
	double a1=(h*30+m*0.5l),a2=m*6;
	while(a1>360)a1-=360;
	while(a2>360)a2-=360;
	if(a1>a2)a1=a1-a2;
	else a1=a2-a1;
	ans=sqrt(a*a+b*b-2*a*b*cos((pi*a1)/180.0l));
	printf("%.16lf",ans);
	return 0;
}

Measured memory_bytes: 4204
/* 165-D.cpp
 *     Created on : May 2, 2020 
 *     Time       : 7:34:17 PM
 *     Author     : null_ptr
 */
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
	long long a,b,n;
	cin>>a>>b>>n;
	long long tmp=min(n,b-1);
	long long ans=floor(1.0*a*tmp/b);
  	cout<<ans<<'\n';
}


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

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  bool ans = true;
  int M = (N - 1) / 2;
  for (int i = 0; i < M / 2; i++) {
    if (S[i] != S[M - i - 1]) ans = false;
  }
  for (int i = 0; i < N / 2; i++) {
    if (S[i] != S[N - i - 1]) ans = false;
  }

  if (ans == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
void main()
{
    string s = readln.chomp;

    string t = "keyence";
    bool ok;
    foreach (i; 0 .. 8)
    {
        if (s[0..i] == t[0..i] && s[$-7+i..$] == t[i..$])
        {
            ok = true;
        }
    }

    writeln(ok ? "YES" : "NO");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************
ll mod=1000000007;
void solve()
{
	ll n;
	cin >> n;
	vector<pair<ll,ll>> v(n+1);
	vector<vector<ll>> dp(n+1);
	dp[0].resize(n+1);
	for(int i=1;i<=n;i++)
	{
		dp[i].resize(n+1);
		ll x;
		cin >> x;
		v[i]=make_pair(x,i);
	}
	sort(++v.begin(),v.end());
	reverse(++v.begin(),v.end());
	dp[1][0]=v[1].first*(abs(n-v[1].second));
	dp[1][1]=v[1].first*(abs(1-v[1].second));
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			int bp=n-(i-1-j);
			dp[i][j]=max(dp[i][j],dp[i-1][j]+v[i].first*(abs(bp-v[i].second)));
			dp[i][j+1]=max(dp[i][j+1],dp[i-1][j]+v[i].first*(abs(j+1-v[i].second)));
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		if(ans<dp[n][i])
		ans=dp[n][i];
	}
	cout << ans << endl;

}


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

	return 0;
}

Measured memory_bytes: 34624
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        
        int tmp = scanner.nextInt();
        int max = tmp;
        int min = tmp;
        long sum = tmp;
        
        for (int i=1; i<n; i++) {
            tmp = scanner.nextInt();
            if (tmp > max) max = tmp;
            if (tmp < min) min = tmp;
            sum += tmp;
        }

        System.out.println(Integer.toString(min) + " " + Integer.toString(max) + " " + String.valueOf(sum));
    }
}




Measured memory_bytes: 41672
#include<stdio.h>
int main()
{int n=0;int fh=0,f=0;
  scanf("%d",&n);
 while(n>5)
 {
   fh=n/500;
   n=n%500;
   f=n/5;
   n=n%5;
 }
 printf("%d",f*5+fh*1000);
 return 0;
}


Measured memory_bytes: 128
while true
    s = []
    s[0] = gets.chomp
    break if s[0] == "."
    s[1] = gets.chomp

    answer = "DIFFERENT"
    if s[0] == s[1]
        answer = "IDENTICAL"
    else
        arr = [[], []]
        arr2 = ["", ""]
        s.each_with_index{|ss, i|
            str, flag = "", false
            ss.each_char{|c|
                if c == '"'
                    flag = !flag
                    if !flag
                        arr[i] << str 
                        str = ""
                    end
                    arr2[i] += c
                else
                    if flag
                        str += c
                    else
                        arr2[i] += c
                    end
                end
            }
        }
        if arr2[0] == arr2[1] && arr[0].length == arr[1].length
            n = 0
            arr[0].zip(arr[1]){|a, b| n += 1 if a != b}
            answer = "CLOSE" if n == 1
        end
    end
    puts answer
end


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int ans = max<int>({
        10 * A + B + C,
        A + 10 * B + C,
        A + B + 10 * C,
    });
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			

			int n = sc.nextInt();
			
			int[] mCount = new int[n];
			
			for(int i = 1 ; i < n ; i++ ) {
				
				int id = sc.nextInt();
				
				mCount[id-1]++;
			}
			
			for(int i = 0 ; i < n ; i++ ) {
				System.out.println(mCount[i]);
			}
			
			
		}
	}

}

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

struct edge
{
	int u,v;
}e[100001];

int fa[100001];

int findfa(int x)
{
	if(x!=fa[x]) fa[x]=findfa(fa[x]);
	return fa[x];
}

int main()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=1;i<=n;i++)
		fa[i]=i;
	
	int f1,f2,temp;
	for(int i=1;i<=m;i++)
	{
		cin>>e[i].u>>e[i].v>>temp;
		f1=findfa(e[i].u);
		f2=findfa(e[i].v);
		if(f1!=f2) fa[f1]=f2;
	}
	
	int cnt=0;
	for(int i=1;i<=n;i++)
    	if(fa[i]==i) cnt++;
    
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
 int main(){
 char x[1000],y[1000];
 int n,i,j;
 scanf("%d",&n);
 for(i = 0;i < n;i++){
    scanf("%s %s",x, y);
   printf("%d\n",cal(x,y));
 }
 return 0;     
}
  
int cal(char x[], char y[]){
  
 int i,j;
 int m = strlen(x);
 int n = strlen(y);
 int cou[m+1][n+1];
  
 for(i = 0;i <= m; i++){
  cou[i][0] = 0;
  }
 for(j = 0;j <= n; j++){
  cou[0][j] = 0;
  }
 for(i = 1;i <= m; i++){
  for(j = 1;j <= n; j++){
    if(x[i-1] == y[j-1])
     cou[i][j] = cou[i-1][j-1] + 1;
    else if(cou[i-1][j] >= cou[i][j-1]){
     cou[i][j] = cou[i-1][j];
  }
    else
     cou[i][j] = cou[i][j-1];
  }
 }
 return cou[m][n];
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9+7;

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

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

class Mll
{
    public:
    ll x;

    Mll() : x(0){}
    Mll(ll x=0) : x((x%MOD+MOD)%MOD){}

    Mll operator-() const
    {
        return Mll(-x);
    }

    Mll& operator+=(const Mll& A)
    {
        if((x += A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator-=(const Mll& A)
    {
        if((x += MOD - A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator*=(const Mll& A)
    {
        (x *= A.x) %= MOD;
        return *this;
    }
    
    Mll operator+(const Mll& A)
    {
        Mll res(*this);
        return res+=A;
    }
    Mll operator-(const Mll& A)
    {
        Mll res(*this);
        return res-=A;
    }
    Mll operator*(const Mll& A)
    {
        Mll res(*this);
        return res*=A;
    }
    
    Mll pow(ll t) const // t乗
    {
        if(t==0) return 1;
        Mll A = pow(t>>1);
        A *= A;
        if(t&1) A *= *this;
        return A;
    }

    // for prime mod
    Mll inv() const
    {
        return pow(MOD-2);
    }
    Mll& operator/=(const Mll& A)
    {
        return (*this) *= A.inv();
    }
    Mll operator/(const Mll& A) const
    {
        Mll res(*this);
        return res/=A;
    }

    friend ostream& operator<<(ostream& os, const Mll& M)
    {
        os << M.x;
        return os;
    }
};

vector<Mll> ALLIN_MLL(ll N)
{
    vector<ll> numbers_ll(N);
    ALLIN1_NUMBER(numbers_ll);

    vector<Mll> numbers_Mll;
    for(ll i=0;i<N;i++)
    {
        Mll add(numbers_ll[i]);
        numbers_Mll.push_back(add);
    }

    return numbers_Mll;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

int main()
{
    ll L,R,d;
    cin >> L >> R >> d;

    ll ret = 0;

    for(ll i=1;i<=100;i++)
    {
        if(i>=L && i<=R && i%d==0)
        {
            ret++;
        }
    }

    cout << ret << endl;

    return 0;
}

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

int main(){
  int n, k, r, s, p;
  string str;
  cin >> n >> k >> r >> s >> p;
  cin >> str;
  string myhand = "";
  int sum = 0;
  for(int i=0; i<n; i++){
    if(str[i] == 'r'){
      myhand += "p";
      sum += p;
    }else if(str[i] == 's'){
      myhand += "r";
      sum += r;
    }else{
      myhand += "s";
      sum += s;
    }
  }
  for(int i=0; i<k; i++){
    int now = i;
    while((now + k) < n){
      int cnt = 1;
      for(int j=now; j+k<n; j+=k){
        if(myhand[j] != myhand[j+k]){
          break;
        }else{
          cnt++;
        }
      }
      if(cnt > 1){
        if(myhand[now] == 'r') sum -= r*(cnt/2);
        else if(myhand[now] == 's') sum -= s*(cnt/2);
        else sum -= p*(cnt/2);
      }
      now += (k*cnt);
    }
  }
  cout << sum << endl;
  return 0;
}
      
      
      
      
      
      

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
//#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

//using Graph = vector<vector<pair<int, int>>>;
using Graph = vector<vector<int>>;

int n;
vector<bool> seen(n,false);
vector<int> cost(n);
Graph G(n);

void dfs(int v){
    seen[v] = true;
    for(auto next_v : G[v]){
        if(seen[next_v]) continue;
        cost[next_v]+=cost[v];
        dfs(next_v);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int q;
    cin>>n>>q;
    //Graph G(n);
    //vector<int> cost(n);
    //vector<bool> seen(n,false);
    G.resize(n);
    cost.resize(n);
    seen.resize(n,false);
    int a,b;
    rep(i,n-1){
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int p,x;
    rep(i,q){
        cin>>p>>x;
        p--;
        cost[p]+=x;
    }

    seen[0]=true;
    dfs(0);

    rep(i,n){
        cout<<cost[i]<<endl;
    }   
}

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

typedef long long ll;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;
int arr[100005];
int dp[100005];



int main()
{
    optimize();
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    dp[2]=abs(arr[1]-arr[2]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));

    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define MAX 50
#define NIL -1
int F[MAX] = {NIL};

int main() {
  int n, i;
  scanf("%d", &n);

  F[0] = 1;
  F[1] = 1;
  for (i = 2; i <= n; i++) F[i] = F[i - 2] + F[i - 1];
  printf("%d\n", F[n]);

  return 0;
}



Measured memory_bytes: 2756
S = int(input())

x1 = 0
y1 = 0
x2 = 10 ** 9
y2 = 1

tmp = S % (10 ** 9)

if tmp != 0:
  x3 = abs(S % (10 ** 9) - 10 ** 9)
  y3 = S // (10 ** 9) + 1
else:
  x3 = 0
  y3 = S // (10 ** 9)
    
print(*[x1, y1, x2, y2, x3, y3])

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  h.push_back(0);
  int ans = 0;
  while(true) {
    bool ok = true;
    rep(i, n) {
      if(h[i] == 0) continue;
      ok = false;
      if(h[i] > 0 && h[i+1] > 0) {
        --h[i];
      }
      else if(h[i] > 0 && h[i+1] == 0){
        --h[i];
        ++ans;
        ++i;
      }
    }
    if(ok) {
      cout << ans << endl;
      return 0;
    }
  }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).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 debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

ll N, A, B;
ll X[111111];

int main() {
   cin >> N >> A >> B;
   rep (i, N) {
      cin >> X[i];
   }

   ll sum = 0;
   repp (i, 1, N) {
      sum += min((X[i] - X[i-1])*A, B);
   }
   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 1024
k = int(input())

x = 7 % k

s = [0] * k
i = 1

while s[x] == 0:
    if x == 0:
        print(i)
        exit()
    s[x] = 1
    x = (x * 10 + 7) % k
    i += 1

print('-1')

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    int n,k;cin >> n>> k;
    cout << n-k+1-n/k << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 500001;


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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;
    string s;

    cin >> s;
    n = s.length();
    if(n%2 == 1){
        cout << "No\n";
        return 0;
    }
    for(int c1 = 0; c1 < n; c1 += 2){
        if(s[c1] != 'h' || s[c1+1] != 'i'){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	bool num[10];
	int a[4],b[4],hit,blow;
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
		cin>>b[0]>>b[1]>>b[2]>>b[3];
		hit=0;blow=0;
		for(int i=0;i<10;i++){
			num[i]=false;
		}
		for(int i=0;i<4;i++){
			num[a[i]]=true;
		}
		for(int i=0;i<4;i++){
			if(b[i]==a[i])hit++;
			else if(num[b[i]])blow++;
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

#include<queue>

using namespace std;

int main() {

	int N = 0;
	int X = 0;
	cin >> N >> X;

	vector<int> dot(N, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> dot[i];
	}

	int result = 1;
	int distance = 0;
	for (int i = 0; i < N; i++)
	{
		distance += dot[i];
		if (distance > X)
		{
			break;
		}
		++result;
	}
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i, a, b) for (register int i = (a), _b = (b); i <= _b; i++)
inline int rd(void) {
	int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	int x = 0; for (; isdigit(c); c = getchar()) x = x*10+c-'0'; return x*f;
}

const int N = 200005;
const int S = 8000;
const int M = 2000;
const int P = 1e9 + 7;

int n, a[N], b[N];
int fac[S+5], inv[S+5], ifac[S+5];
int f[4005][4005];
int ans;

inline void add(int &x, int y) { x = (x + y) % P; }
inline int C(int n, int m) { return 1LL * fac[n] * ifac[m] % P * ifac[n-m] % P; }

int main(void) {
	n = rd();
	F(i, 1, n) a[i] = rd(), b[i] = rd();

	fac[0] = 1;
	F(i, 1, S) fac[i] = 1LL * fac[i-1] * i % P;
	inv[1] = 1;
	F(i, 2, S) inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
	ifac[0] = 1;
	F(i, 1, S) ifac[i] = 1LL * ifac[i-1] * inv[i] % P;
	
	F(i, 1, n) f[-a[i] + M][-b[i] + M]++;
	F(i, -M, M) F(j, -M, M) if (f[i+M][j+M] != 0) {
		if (i < M) add(f[i+1+M][j+M], f[i+M][j+M]);
		if (j < M) add(f[i+M][j+1+M], f[i+M][j+M]);
	}
	
	F(i, 1, n)
		add(ans, f[a[i]+M][b[i]+M]);
	F(i, 1, n)
		add(ans, -C(a[i]+a[i]+b[i]+b[i], a[i]+a[i]));
	ans = 1LL * ans * inv[2] % P;
	printf("%d\n", (ans + P) % P);
	
	return 0;
}

Measured memory_bytes: 64512