akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<vector<vector<ll> > > vec(4, vector<vector<ll> >(3, vector<ll>(10, 0)));

void solve() {
  ll N;
  cin >> N;
  rep (i, N) {
    ll b, f, r, v;
    cin >> b >> f >> r >> v;
    b--;
    f--;
    r--;
    vec[b][f][r] += v;
  }
  rep (b, 4) {
    if (b > 0) cout << "####################" << endl;
    rep (f, 3) {
      rep (r, 10) cout << " " << vec[b][f][r];
      cout << endl;
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3136
from collections import deque

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
a = deque(a)
l = []
ans = []

for i in range(m):
    b, c = map(int, input().split())
    l.append([c, b])

l = sorted(l)[::-1]
ref = a.popleft()

for num, cnt in l:
    while ref >= num:
        ans.append(ref)
        if len(a) == 0:
            print(sum(ans))
            exit()
        ref = a.popleft()

    while cnt > 0:
        if ref < num:
            ans.append(num)
            cnt -= 1
            if len(a) == 0:
                print(sum(ans))
                exit()
            ref = a.popleft()
        else:
            break

ans.append(ref)

while a:
    ref = a.popleft()
    ans.append(ref)

print(sum(ans))

Measured memory_bytes: 29740
open System

let rec gcd a b =
    if b = 0L
    then a
    else gcd b (a % b)

let lcm a b = a / gcd a b * b


let n = stdin.ReadLine() |> int
let t = [| for _ in [1..n] -> stdin.ReadLine() |> int64 |]

printfn "%d" <| Array.fold lcm 1L t


Measured memory_bytes: 14288
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    if(n==3){
        reverse(be(s));
    }
    cout<< s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
	double w;
	double t, y;

	while(scanf("%lf\n", &w)==1) {
		t = w / 9.8;
		y = 4.9 * t * t;
		printf("%.0lf\n", ceil(y / 5) + 1);
	}
	
	return 0;
}

Measured memory_bytes: 656
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
 
int main()
{
  int n;
  int *mark;
  double mean,sig;

  while (1){
    cin >> n;
    if( n==0 ){
      break;
    }
    
    double sum=0;
    double sig=0;
    
    mark = new int [n];
    for (int i=0; i<n; i++){
      cin >> mark[i];
      sum += mark[i];
    }
    mean = sum/n;
    
    for (int i=0; i<n; i++){
      sig += pow(mark[i] - mean, 2.0);
    }
    sig = sqrt( sig/n );
    
    
    cout << fixed
      << setprecision(5)
        << sig
          << endl;

    delete [] mark;
    
  }
  
  return(0);
}

Measured memory_bytes: 1268
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#include <map>

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp(A, B) make_pair(A, B)
#define pb push_back
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define v(A, B, C) vector<ll> (A)((B), (C));
#define v0(A, B) v((A), (B), 0);


using namespace std;

typedef pair<int, int> pi;

void perform() {
  int n; cin >> n;
  int arr[200001] = {0};
  fu0(i, n - 1) {
    int t; cin >> t;
    arr[t]++;
  }
  fu(i, 1, n+1) {
    cout << arr[i] << endl;
  }
}

/*
int n; cin >> n;
cout << (2 * M_PI * n) << endl;
*/

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1; //cin >> t;
  fu0(i, t) {perform();}
}


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

int main(int argc, char const *argv[]) {
    int a, b;
    cin >> a >> b;

    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
s=input()
K=int(input())

S=[]
for n in range(len(s)):
    for i in range(1,len(s)-n+1):
        if len(S)<5:
            S.append(s[n:i+n])
            S = list(set(S))
            S.sort()
        elif S[4]>s[n:i+n]:
            S.append(s[n:i+n])
            S = list(set(S))
            S.sort()
        else:
            break
S=list(set(S))
S.sort()

print(S[K-1])



Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, n; cin >> h >> n;
    V< P<ll, ll> > ab(n);
    REP(i, n) {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ALL(ab));
    vvll dp(n + 1, vll(h + 1, HIGHINF));
    REP(i, n + 1) dp[i][0] = 0;
    REP(i, n) {
        REP(j, h + 1) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][max(0LL, j - ab[i].first)] + ab[i].second);
        }
    }

    // REP(i, n) {
    //     DEBUG_VLL(dp[i + 1])
    // }

    ll ans = HIGHINF;
    REP(i, n) chmin(ans, dp[i + 1][h]);
    cout << ans << '\n';
    return 0;
}


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

int main(){
	string str;
	bool first, piriod;
	unsigned int loc;
	
	getline(cin, str);
	for(int i = 0; i < str.size(); i++){
		if(str[i]=='a' && str[i + 1]=='p' && str[i + 2]=='p' && str[i + 3]=='l' && str[i + 4]=='e'){
			str[i] = 'p';
			str[i + 1] = 'e';
			str[i + 2] = 'a';
			str[i + 3] = 'c';
			str[i + 4] = 'h';
		}
		else if(str[i]=='p' && str[i + 1]=='e' && str[i + 2]=='a' && str[i + 3]=='c' && str[i + 4]=='h'){
			str[i] = 'a';
			str[i + 1] = 'p';
			str[i + 2] = 'p';
			str[i + 3] = 'l';
			str[i + 4] = 'e';
		}
	}
	
	cout << str << endl;
	
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

#define PI 3.1415926535897932

int main() {
	int a,b,c;
	double S, L, h;
	double si,co;
	cin >> a >> b >> c;

	si = sin((double)c / 180.0 * PI);
	co = cos((double)c / 180.0 * PI);


	if (si > 0.999999) {
		si = 1.0;
	}

	if (si < -0.999999) {
		si = -1.0;
	}

	if (co > 0.999999) {
		co = 1.0;
	}

	if (co < -0.999999) {
		co = -1.0;
	}

	S = (double)a * (double)b * si * 0.5;
	L = (double)a + (double)b + sqrt(pow((double)a, 2) + pow((double)b, 2) - 2.0 * (double)a * (double)b * co);
	h = (double)b * si;

	printf("%.8f\n%.8f\n%.8f\n", S, L, h);

	return 0;
}

Measured memory_bytes: 1196
S=str(input())

N=int(len(S))

count = 0
counta=0
for i in range((N-1)//2):
    if S[i]==S[(N-1)//2-i-1]:
        count+=0
    else:
        count+=1

for i in range((N-1)//2):
    if S[i+(N+1)//2]==S[N-1-i]:
        count+=0
    else:
        count+=1
for i in range(N):
    if S[i]==S[N-1-i]:
        count+=0
    else:
        count+=1

if count == 0 :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    long long x, y = 0;
    cin >> x;
    y += x / 11 * 2;
    if(x % 11 > 6) y += 2;
    else if(x % 11 > 0) y += 1;
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll N; cin >> N;
  vector<pair<ll,ll>>  vec(N);
  for(int i = 0; i < N; i++){ cin >> vec[i].first >> vec[i].second;}
  
  sort(vec.rbegin(),vec.rend());

  cout << vec.front().first + vec.front().second << endl; return 0;}

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

int main() {
    int H, W;
    cin >> H >> W;
    string a[101];
    rep(r, H) cin >> a[r];

    rep(r, H)
    {
        bool f=false;
        rep(c, W) {
            bool f1=true, f2=true;
            rep(r2, H) if (a[r2][c] == '#') f1=false;
            rep(c2, W) if (a[r][c2] == '#') f2=false;
            if (f1 or f2) continue;
            f=true;
            cout << a[r][c];
        }
        if (f) cout << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s,a[1010];
	int w,j=0,temp=0
	;
	cin>>s>>w;
	if(w==1)
	{
		cout<<s;
		return 0;
	}
	for(int i=0;i<s.size();i+=w)
		cout<<s[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    priority_queue<double> que;
    lli n;
    cin >> n;
    rep(i, n){
        lli a;
        cin >> a;
        que.push(-a);
    }
    while(que.size() > 1){
        double a = -que.top(); que.pop();
        double b = -que.top(); que.pop();
        que.push(-((a+b)/2.0));
    }
    cout << -que.top() << endl;
}

Measured memory_bytes: 256
//https://github.com/mostafa-saad/MyCompetitiveProgramming/blob/master/UVA/UVA_10740.txt
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)

int n,m,p[100010],ran[100010],r[100010];

int findset(int f)
{
    if(p[f]==f)
        return f;
    else
        return p[f]=findset(p[f]);
}
void conect(int x,int y)
{
    x=findset(x);
    y=findset(y);
    if(ran[x]>ran[y])swap(x,y);
    p[x]=y;
    if(ran[x]==ran[y])
        ran[y]++;
}
bool isconect(int x,int y)
{
    if(findset(x)==findset(y))
        return 1;
    else
        return 0;
}
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
input;
cin>>n>>m;
int x,y,z,ans=n;
forr(i,1,n)p[i]=i;
forr(i,1,m)
{
    cin>>x>>y>>z;
    if(isconect(x,y)==0)
    {
        ans--;
        conect(x,y);

    }
}
cout<<ans;
return 0;
}


Measured memory_bytes: 1024
// Ryo Kamoi
#define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

int n;
int a, b, c, d;
string s;

bool conseq_stones(int st, int gl) {
  bool prev = false;
  for (int i=st; i<=gl; i++) {
    if (s[i] == '#') {
      if (prev) {
        return true;
      }
      prev = true;
    } else {
      prev = false;
    }
  }
  return false;
}

bool three(int st, int gl) {
  int num = 0;
  for (int i=st; i<=gl; i++) {
    if (s[i] == '#') {
      num = 0;
    } else {
      num++;
      if (num == 3) return true;
    }
  }
  return false;
}

int main(){
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  if (c<a || d<b) {
    cout << "No" << endl;
    return 0;
  }

  if (s[a-1]=='#' || s[b-1]=='#' || s[c-1]=='#' || s[d-1]=='#') {
    cout << "No" << endl;
    return 0;
  }


  if (conseq_stones(a-1, c-1) || conseq_stones(b-1, d-1)) {
    cout << "No" << endl;
    return 0;
  }
  
  if ((b>a && c>d || a>b && d>c)) {
    if (!three(max(a, b)-2, min(c, d))) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    
    int match = 0;
    bool all_match = true;
    for(int i = 0; i < n; i++){
        int sub = 0;
        if(s[i] == t[0]){
            string s_sub = s.substr(i, n);
            sub = s_sub.size();

            // cout << "substring\n";
            // cout << "s: " << s_sub << " t: " << t.substr(0, sub) << endl;
            if(s_sub == t.substr(0, sub)){
                match = max(match, sub);
            }
        }
    }
    
    cout << 2*n-match << endl;
    return 0;
}


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

using namespace std;

class lect{
  int w;
  int h;
public:
  lect(int a,int b){
    w=a;h=b;
  }
  int size() const{
    return w*h;
  }
  pair<lect,lect> cut(int n){
    n%=(w+h);
    if(n<w){
      return make_pair(lect(n,h),lect(w-n,h));
    }else{
      n-=w;
      return make_pair(lect(w,n),lect(w,h-n));
    }
  }
};

bool operator < (const lect &a,const lect &b){
  return a.size() < b.size();
}

int main(){
  int n,w,d;
  while(cin>>n>>w>>d,n+w+d){
    vector<lect> cake;
    cake.push_back(lect(w,d));
    for(int i=0;i<n;i++){
      int p,s;cin >> p >> s;
      vector<lect>::iterator it = cake.begin()+(p-1);
      pair<lect,lect> cut = it->cut(s);
      cake.erase(it);
      if(cut.first < cut.second){
        cake.push_back(cut.first);
        cake.push_back(cut.second);
      }else{
        cake.push_back(cut.second);
        cake.push_back(cut.first);
      }
    }
    vector<int> tmp(cake.size());
    for(int i=0;i<tmp.size();i++) tmp[i]=cake[i].size();
    sort(tmp.begin(),tmp.end());
    for(int i=0;i<cake.size();i++){
      cout << tmp[i] << (i!=cake.size()-1?" ":"\n");
    }
  }
  return 0;
}

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

void solve(ll N, vector<ll> A)
{
    bool flg = true;
    rep(i, N){
        if(A[i]%2 == 0)
            if(A[i]%5!=0&&A[i]%3!=0){
                flg = false;
                break;
            }
    }
    if(flg)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input for
    ll N;
    scanf("%lld", &N);
    vector<ll> A(N);
    rep(i, N){
        scanf("%lld", &A[i]);
    }
    solve(N, A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (long double k) {
    return Point(x * k, y * k);
  }

  long double norm(Point p) {
    return p.x * p.x + p.y + p.y;
  }

  long double abs(Point p) {
    return sqrt(norm(p));
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int judge(Point v1, Point v2) {
  if (cross(v1, v2) == 0) return 2;
  else if (dot(v1, v2) == 0) return 1;
  else return 0;
}

int main() {
  int q;
  cin >> q;
  Point p0, p1, p2, p3, v1, v2;
  rep(i, q) {
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    v1 = p1 - p0;
    v2 = p3 - p2;
    cout << judge(v1, v2) << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3208
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

int main() {
	int a, b, c, d, t;
	cin >> a >> b >> c >> d;
	t = min(b, d) - max(a, c);
	if (t < 0)
		cout << 0 << endl;
	else
		cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int n;
ll h[100010];
ll dp[100010];

ll solve(int i) {
    if(i == n-1) return 0;
    if(i >= n) return 1000000000000000000LL;
    if(dp[i] != -1) return dp[i];

    return dp[i] = min(abs(h[i] - h[i+1]) + solve(i+1), abs(h[i] - h[i+2]) + solve(i+2));
}

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    cout << solve(0) << "\n";
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define true 1
#define false 0



int main(void){
	int r,l;
	int powr,powl;
	int k = 0;
	lli ans = 0;
	lli s,t,u;
	int a[10];
	scanf("%lld",&s);
	t = 1;
	while(s>=t){
		t*=10;
		k++;
	}
	t = 1;
	u = 1;
	for(r=0;r<k;r++){
		powr = max(r-1,0);
		u = 1;
		for(l=r;l<k;l++){
			powl = max(k-l-2,0);
			u*=10;
			//printf("%lld\n",(s/t)%u);
			//printf("%d %d\n",(int)pow(2,powl),(int)pow(2,powr));
			ans += (int)pow(2,powl)*(int)pow(2,powr)*((s/t)%u);

		}
		t*=10;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 2e5+10,MAX = 5000000;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t1 = (c/b);
    if(c%b!=0) t1++;
    int t2 = (a/d);
    if(a%d!=0) t2++;
    if(t1<=t2) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    cin>>S;
    N = S.size();
    rep(i,N) if(S[i] == '?') S[i] = 'D';
    cout<<S<<endl;
}

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX 27
int ash[2][MAX]={0};
int MOD[2]={1145141919,1145148109};
int x[2]={381038107,524524524};
int power[2][MAX];
int main(){
  string s,t;
  cin>>s>>t;
  if(s.size()>t.size())swap(s,t);
  rep(i,2){
    power[i][0]=1;
    rep(j,MAX)power[i][j+1]=(ll)power[i][j]*x[i]%MOD[i];
  }
  for(int n=s.size();n>0;n--){
    map<pii,int>ma;
    vi co(26);
    rep(i,n)co[s[i]-'a']++;
    rep(p,s.size()-n+1){
      pii has;
      rep(i,2){
	int ha=0;
	rep(j,26)(ha+=(ll)power[i][j]*co[j]%MOD[i])%=MOD[i];
	if(i)has.second=ha;
	else has.first=ha;
      }
      ma[has]=true;
      if(p==s.size()-n)break;
      co[s[n+p]-'a']++;
      co[s[p]-'a']--;
    }

    co=vi(26);
    rep(i,n)co[t[i]-'a']++;
    bool h=false;
    rep(p,t.size()-n+1){
      pii has;
      rep(i,2){
	int ha=0;
	rep(j,26)(ha+=(ll)power[i][j]*co[j]%MOD[i])%=MOD[i];
	if(i)has.second=ha;
	else has.first=ha;
      }
      //      cout<<has.first<<" "<<has.second<<endl;
      if(ma.count(has)){
	h=true;
	break;
      }
      if(p==t.size()-n)break;
      co[t[n+p]-'a']++;
      co[t[p]-'a']--;
    }
    if(h){
      cout<<n<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
}

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

int N;

int calc(int* arr, int count){
    bool f = false;
    for(int i = 0; i< N; i++){
        if (arr[i] % 2 == 0) arr[i] /= 2;
        else break;
        if (i == N - 1) f = true;
    };
    if(f) calc(arr, count + 1);
    else return count;
}

int main(){
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    cout << calc(A, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int A,B;
  cin >> A >> B;
  cout << (A - 1) * (B - 1) << endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main
{
    public static void main(String[] arg)
    {
        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)
            {
                if(m==-1 && f==-1 && r==-1) break;
                else System.out.println("F");
            }
            else if(m+f>=80) System.out.println("A");
            else if(m+f>=65) System.out.println("B");
            else if(m+f>=50) System.out.println("C");
            else if(m+f>=30)
            {
                if(r>=50) System.out.println("C");
                else System.out.println("D");
            }
            else if(m+f>=0) System.out.println("F");
        }

        sc.close();
    }
}


Measured memory_bytes: 26240
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N], y[M];
    int Max=-1000;
    int Min=1000;
    rep(i, N){
        cin >> x[i];
        Max=max(Max,x[i]);
    } 
    rep(i, M){
      cin >> y[i];
      Min= min(Min, y[i]);  
    } 

    bool flag=false;
    for(int i=X+1;i<=Y;i++){
        if(Max<i && i<=Min) flag=true;
    }
    if(flag) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
//Moh_K_Imar .......
//22/08/2020  ... 11,50 . 
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;

    return 0;
}



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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}


struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, p; scan(n, p);
      LI xs(n); rep(i, n) scan(xs[i]);
      long dp[128][2] = {{}};
      dp[0][0] = 1;
      dp[0][xs[0]%2] += 1;
      for(long i = 1; i < n; ++i) {
         dp[i][0] = dp[i-1][0];
         dp[i][1] = dp[i-1][1];
         if( xs[i] % 2 == 0 ) {
            dp[i][0] += dp[i-1][0];
            dp[i][1] += dp[i-1][1];
         }
         else {
            dp[i][0] += dp[i-1][1];
            dp[i][1] += dp[i-1][0];
         }
      }
      printf("%ld\n", dp[n-1][p]);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int main() {
	int n;
	long long int k;
	cin >> n >> k;
	vector<int> v;
	v.push_back(0);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	int now = 1;
	for (int i = 1; i <= 1000000; i++) {
		now = v[now];
		if (i == k) {
			cout << now;
			return 0;
		}
	}
	int susum[200030] = {};
	k = k - 1000000;
	vector<int>roop;
	for (int i = 1; i <= 1000000; i++) {
		if (susum[v[now]] == 0) {
			roop.push_back(v[now]);
			susum[v[now]] = 1;
			now = v[now];
		}
		else {
			break;
		}
	}
	long long int f = roop.size();
	long long int t = k % f;
	if (t == 0) {
		cout <<roop[roop.size() - 1];
	}
	else {
		cout << roop[t-1];
	}
}

Measured memory_bytes: 8012
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!long).array;
    auto BC = M.iota.map!(_ => readln.split.map!(to!long).array).array;
    BC.sort!"a[1] > b[1]";
    auto pq = new BinaryHeap!(Array!long, "a > b");
    foreach (a; A) pq.insert(a);

    long ans = 0;
    foreach (bc; BC) {
        int cnt = 0;
        while (!pq.empty && pq.front < bc[1] && cnt < bc[0]) {
            ans += bc[1];
            cnt += 1;
            pq.removeFront;
        }
    }

    while (!pq.empty) {
        ans += pq.front;
        pq.removeFront;
    }

    ans.writeln;
}


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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = a+b;
    ll p_count = n/c;
    ll r = 0;
    r = n%c;
    ll sum;
    if (a != 0) {
    	if (r > a) r = a;
    	sum = a*p_count+r;
    } else sum = 0;
    cout << sum << endl;
    return 0;
}


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

int main() {
  int n, c, k;
  cin >> n >> c >> k;

  vector<int> t(n);
  rep (i, n) cin >> t[i];

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

  int ans = 0;
  for (int i = 0; i < n;) {
    int start = i;
    while (i < n && t[i] - t[start] <= k && i - start < c)
      i++;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  long long a,b,c=0,d,e;cin>>a>>b;
  vector<long long>q(a);
  vector<bool>p(a,true);
  rep(i,a)cin>>q[i];
  rep(i,b){
    cin>>d>>e;
    d--;
    e--;
    if(q[d]>q[e])p[e]=false;
    else p[d]=false;
    if(q[d]==q[e]){
      p[d]=false;
      p[e]=false;
    }
  }
  rep(i,a){
    if(p[i])c++;
  }
  cout<<c;
  }


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

int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S[i];
  
  int ans = 0;
  for (int is = 0; is < (1<<H); is++) {
    for (int js = 0; js < (1<<W); js++) {
      int cnt = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (is & (1<<i)) continue;
          if (js & (1<<j)) continue;
          if (S[i][j] == '#') cnt++;
        }
      }
      if (cnt == K) ans++;
    }
  }
  
  cout << ans << endl;  
}

Measured memory_bytes: 3512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    for(int i = 1; i<=9; i++){
      if((n/i>=1 && n/i<=9) && n%i==0){
        System.out.println("Yes");
        break;
      } else if(i==9 && n%9!=0){
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 21332
#include <stdio.h>

int main(void) {

int n,i,j,k,p=1,q=1;
int ari[5][4][11]={};
int a[500]={},b[500]={},c[500]={},d[500]={};

scanf("%d",&n);

for(i=1;i<=n;i++)
scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);

for(p=1;p<=n;p++)
 for(i=1;i<5;i++)
  for(j=1;j<4;j++)
   for(k=1;k<11;k++){
      if(i==a[p] && j==b[p] && k==c[p])
       ari[i][j][k]+= d[p];
//printf("%d",ari[i][j][k]);
    }
   
for(i=1;i<5;i++){
 for(j=1;j<4;j++){
  for(k=1;k<11;k++)
    printf("%2d",ari[i][j][k]);
  printf("\n");
}

if(i<4)
  printf("####################\n");

}
    return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a,b;
    cin >> a >> b;
    cout << (n-a) % b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i) 
#define per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)

#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define maxn 400020
#define N 8000020
#define int long long
using namespace std;
int n; 
struct Node
{int x,id,ty;}node[maxn]; 
bool cmp(Node a,Node b)
{return a.x<b.x;}
int m1,m2,mn;
int bel[2][maxn];
signed main()
{cin>>n;
 rep(i,1,n)
  {cin>>node[i].x>>node[i+n].x;
   m1+=node[i].x;m2+=node[i+n].x;
   node[i].id=i; node[i+n].id=i;
   node[i].ty=0; node[i+n].ty=1;
  }
 sort(node+1,node+n+n+1,cmp);	
 rep(i,1,n) mn+=node[i].x; 
 rep(i,1,2*n)
 {bel[node[i].ty][node[i].id]=i;}
 int cmin=(1ll)<<50;	
 rep(i,1,n)
 {if(bel[0][i]<=n&&bel[1][i]<=n) {cmin=min(cmin,0ll);continue;}
  if(bel[0][i]>n&&bel[1][i]>n) {cmin=min(cmin,node[bel[0][i]].x+node[bel[1][i]].x-node[n].x-node[n-1].x);continue;}
  if( (bel[0][i]==n&&bel[1][i]==n+1)||(bel[0][i]==n+1&&bel[1][i]==n) ) {cmin=min(cmin,node[n+1].x-node[n-1].x);continue;}
  if(bel[0][i]>n) {cmin=min(cmin,node[bel[0][i]].x-node[n].x);continue;}
  if(bel[1][i]>n) {cmin=min(cmin,node[bel[1][i]].x-node[n].x);continue;}
 }
 mn=mn+cmin;
 cout<<min(mn,min(m1,m2));
return 0;	
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      string a,b,c;cin >> a >> b >> c;
      if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])cout << "YES";
      else cout << "NO";
}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
S = input()
R = []
G = []
B = []
cnt = 0
for b in range(N-1,-1,-1):
    if S[b] == 'R':
        cnt += 1
    R.append(cnt)
R.reverse()
cnt = 0
for b in range(N-1,-1,-1):
    if S[b] == 'G':
        cnt += 1
    G.append(cnt)
G.reverse()
cnt = 0
for b in range(N-1,-1,-1):
    if S[b] == 'B':
        cnt += 1
    B.append(cnt)
B.reverse()

ans = 0
for r in range(N-2):
    if S[r] == 'R':
        for g in range(r+1,N-1):
            if S[g] == 'G' and B[g] > 0:
                ans += B[g]
                if g + (g-r) < N:
                    ans -= S[g+(g-r)] == 'B'
        for b in range(r+1,N-1):
            if S[b] == 'B' and G[b] > 0:
                ans += G[b]
                if b + (b-r) < N:
                    ans -= S[b+(b-r)] == 'G'

for r in range(N-2):
    if S[r] == 'G':
        for g in range(r+1,N-1):
            if S[g] == 'B' and R[g] > 0:
                ans += R[g]
                if g + (g-r) < N:
                    ans -= S[g+(g-r)] == 'R'
        for b in range(r+1,N-1):
            if S[b] == 'R' and B[b] > 0:
                ans += B[b]
                if b + (b-r) < N:
                    ans -= S[b+(b-r)] == 'B'

for r in range(N-2):
    if S[r] == 'B':
        for g in range(r+1,N-1):
            if S[g] == 'R' and G[g] > 0:
                ans += G[g]
                if g + (g-r) < N:
                    ans -= S[g+(g-r)] == 'G'
        for b in range(r+1,N-1):
            if S[b] == 'G' and R[b] > 0:
                ans += R[b]
                if b + (b-r) < N:
                    ans -= S[b+(b-r)] == 'R'

print (ans)




Measured memory_bytes: 71524
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	ll n, ans;
	cin >> n;
	ans = 0;
	rep(i, n+1)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			ans += i;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define sc second
#define inf    1000000000LL
#define MP make_pair
#define N 
#define MOD 1000000007
#define orta ((a+b)/2)
using namespace std;
typedef long long int lint;
typedef pair<int,int> ii;



/*
   A!
---------
B! * (A-B)!

*/
long long int f_p(long long int a,long long int b) // It has %MOD
{
    assert(b>=0);// cant be negative
    if(b<=1) return (b&1) ? a%MOD : 1;
    long long int tmp=f_p(a%MOD,b/2);
    return (((tmp*tmp)%MOD)*((b&1) ? a : 1))%MOD;
}

int solve(lint a,lint b)
{
	if(b<0 || b>a || a<0) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
    lint ust=1,alt=1;
    for (int i = 1; i <= a; ++i)
        ust= (ust*i)%MOD;
    for (int i = 1; i <= b; ++i)
        alt= (alt*i)%MOD;
    for (int i = 1; i <= a-b; ++i)
        alt= (alt*i)%MOD;
    return ( ust * f_p(alt,MOD-2) ) %MOD;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	if(m>n) swap(m,n);
	int t=n-m;
	if((m- (t)*1) * 2 % 3)
	{
		cout << 0;
		return 0;
	}
	n =  (m- (t)*1) * 2 / 3;
	cout << solve(n+t,n/2);
}

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

using namespace std;

int n, m;

double a[1005], sum, cnt;

int main () {
    cin >> n >> m;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
        sum += a[i];
    }sort (a + 1, a + n + 1);
    reverse (a + 1, a + n + 1);
    for (int i = 1;i <= m;i ++) {
        if (a[i] < sum / (4 * m)) {
            cout << "No";
            exit (0);
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
n,ma,mb = map(int,input().split())
info =[list(map(int,input().split())) for i in range(n)]

max_a = sum(list(zip(*info))[0]) + 1
max_b = sum(list(zip(*info))[1]) + 1

dp = [[[float("inf")]*(max_b) for i in range(max_a)] for i in range(n+1)]

dp[0][0][0] = 0

for ni in range(1,len(info)+1):
  for ai in range(0,max_a):
    for bi in range(0,max_b):
      if ai-info[ni-1][0] < 0 or bi-info[ni-1][1] < 0:
        dp[ni][ai][bi] = dp[ni-1][ai][bi]
      else:
        dp[ni][ai][bi] = min(dp[ni-1][ai][bi],dp[ni-1][ai-info[ni-1][0]][bi-info[ni-1][1]]+info[ni-1][2])
    
ans = float("inf")
for ai in range(1,max_a):
  for bi in range(1,max_b):
    if ai*mb == bi*ma:
      ans = min(ans,dp[n][ai][bi])
#print(dp[n])
if ans == float("inf"):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 95964
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt = Counter(a)
sm = sum(a)
q = int(input())
for i in range(q):
    b,c = [int(i) for i in input().split()]
    diff = c - b
    sm += diff * cnt[b]
    print(sm)
    cnt.setdefault(b, 0)
    cnt.setdefault(c, 0)
    cnt[c] += cnt[b]
    cnt[b] = 0


Measured memory_bytes: 24204
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0].split(" ").map(Number)
    var a = data[0]
    var b = data[1]
    var a_s=""
    var b_s=""
    for (var i = 0; i < a; i++) {
        b_s += b
    }
    for (var i = 0; i < b; i++) {
        a_s += a
    }
    var ans = [a_s, b_s].sort()
    console.log(ans[0])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
N = int(input())
happy = [[0, 0, 0]]
for _ in range(N):
    happy.append(list(map(int, input().split())))

dp = [[0, 0, 0] for _ in range(N+1)]

for i in range(1,N+1):
    for today in range(3):
        for yesterday in range(3):
            if today == yesterday: continue

            dp[i][today] = max(dp[i][today], dp[i-1][yesterday] + happy[i][today])

print(max(dp[N][0], dp[N][1], dp[N][2]))

Measured memory_bytes: 50164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  int N,K;
  double T,U,V,L;
  cin>>N>>K>>T>>U>>V>>L;
  vector<double> D(N);
  double crt = 0.0;
  double time = 0.0;
  REP(i,N){
    cin>>D[i];
    if(i) {
      int dist = D[i] - D[i-1];
      if(crt > 0.0) {
        if(dist < T*V*crt) {
          crt -= dist/(T*V);
          time += dist / V;
        } else {
          time += T*crt;
          time += (dist-T*V*crt)/U;
          crt = 0.0;
        }
      } else {
        time += dist / U;
      }
    } else {
      time += D[0] / U;
    }
    if(crt < K)
      crt += 1.0;
    else
      crt = K + 1.0;
  }
  int dist = L - D[N-1];
  if(crt > 0.0) {
    if(dist < T*V*crt) {
      crt -= dist/(T*V);
      time += dist / V;
    } else {
      time += T*crt;
      time += (dist-T*V*crt)/U;
      crt = 0.0;
    }
  } else {
    time += dist / U;
  }
  cout << fixed << setprecision(10) << time << endl;
  return 0;
}

Measured memory_bytes: 1300