akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a[5];
	for(int S = 0; S < 5; S++){
	cin >> a[S];
	}
	sort(a, a + 5, greater<int>());
	for(int i = 0; i < 5; i++){
		if(i == 4){
			cout << a[i];
		}
		else cout << a[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3136
unittest
{
	assert( [ "3 4", "269-6650" ].parse.expand.solve == "Yes" );
	assert( [ "1 1", "---" ].parse.expand.solve == "No" );
	assert( [ "1 2", "7444" ].parse.expand.solve == "No" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	input.popFront;
	auto s = input.front.strip;
	return tuple( ab[ 0 ], ab[ 1 ], s );
}

auto solve( long a, long b, string s )
{
	if( s.length != a + 1 + b ) return "No";
	
	foreach( i, c; s )
	{
		if( i == a )
		{
			if( c != '-' ) return "No";
		}
		else
		{
			if( c < '0' || '9' < c ) return "No";
		}
	}
	
	return "Yes";
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x;
    cin >> n >> x;
    int cnt=1;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int now=0;
    for(int i=1;i<n+1;i++){
        if(now+a[i-1]<=x){
            cnt++;
            now+=a[i-1];
        }
        else{
            break;
        }
    }
    cout << cnt ;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int k, x;
	cin >> k >> x;

	int minrange = -1000000;
	int maxrange = 1000000;
	chmax(minrange, x - k + 1);
	chmin(maxrange, x + k - 1);

	for (int i = minrange; i <= maxrange; ++i)
	{
		cout << i << " ";
	}
	//cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define mid (low+high)/2
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n,a,b;

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

    cin >> a >> b >> n;

    cout << ((min(b-1,n)*a)/b);

    return 0;
}



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

int main(){
  int n; 
  vector<int> v; 
  scanf("%d", &n); 
  v.resize(n); 
  long res = 0; 
  bool run = true; 
  for(int i = 0; i<n; ++i){
    scanf("%d", &v[i]); 
    if(v[i]%2) {
      run = false; 
      break; 
    }
  }
  while(run){
    res++; 
    for(int i = 0; i<n; ++i){
      v[i] /= 2; 
      if(v[i]%2) {
        run = false; 
        break; 
      }
    }
  }
  printf("%ld\n", res); 
}

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

int main()
{
    long long ans=0;
    int n,m;
    cin>>n>>m;
    int bef=0;
    priority_queue<int> q;
    for(int i=0;i<n;i++){
        cin >> bef;
        q.push(bef);
    }

    for(int i=0;i<m;i++){
        bef=q.top();
        q.pop();
        q.push(bef/2);
    }

    for(int i=0;i<n;i++){
        ans+=(long long)q.top();
        q.pop();
    }
    cout<< ans;
}

Measured memory_bytes: 892
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


from collections import defaultdict

def BellmanFord(g, s, N):
    dist = [INF] * (N+1)
    dist[s] = 0
    for i in range(N):
        for u in range(1, N+1):
            if dist[u] == INF:
                continue
            for v in g[u]:
                if dist[v] > dist[u] + g[u][v]:
                    dist[v] = dist[u] + g[u][v]
    for i in range(N//2):
        for u in range(1, N+1):
            if dist[u] == INF:
                continue
            for v in g[u]:
                if dist[v] > dist[u] + g[u][v]:
                    if dist[v] != INF:
                        dist[v] = -INF
    return dist


@mt
def slv(N, M, P, ABC):
    g = defaultdict(dict)
    for a, b, c in ABC:
        if a in g and b in g[a]:
            g[a][b] = min(g[a][b], -(c - P))
        else:
            g[a][b] = -(c - P)

    d = BellmanFord(g, 1, N)
    if -d[N] >= INF:
        return -1
    return max(0, -d[N])





def main():
    N, M, P = read_int_n()
    ABC = [read_int_n() for _ in range(M)]
    print(slv(N, M, P, ABC))


if __name__ == '__main__':
    main()


Measured memory_bytes: 49832
import java.io.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		try {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = new String(in.readLine());
		String[] input = line.split(" ", 0);
		int age = Integer.parseInt(input[0].trim());
		int price = Integer.parseInt(input[1].trim());
		//System.out.println("入力値は、" + age + "と" + price);
		
			if(age <= 5) {
				System.out.print("0");
			}else if(age <= 12) {
				System.out.print(price / 2);
			}else {
				System.out.print(price);
			}
		} catch (IOException e) {
			System.out.print(e);
		}
	}

}


Measured memory_bytes: 20692
/**
 * Problem: test.cpp
 * Author: babhishek21
 * Lang: C++11
 */

#include <bits/stdc++.h> // using GCC/G++
// #include "custom/prettyprint.hpp" // G++11 only
using namespace std;

static const int MOD = 1000000007;
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#define debug(x) cerr << #x << " : " << x << endl;
#define whole(func, x, ...) ([&](decltype((x)) var) { return (func)(begin(var), end(var), ##__VA_ARGS__); })(x)

int h[100010], arr[100010];

int main() {
  // ios_base::sync_with_stdio(false); // for fast I/O

  int n;

  cin >> n;

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

  arr[1] = abs(h[1] - h[0]);

  for(int i=2; i<n; i++)
    arr[i] = min(arr[i-1] + abs(h[i] - h[i-1]), arr[i-2] + abs(h[i] - h[i-2]));


  cout << arr[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int n;cin>>n;
string s;cin>>s;
int t[s.size()];
rep(i,s.size()){
    t[i]=s[i]-'A';
    t[i]+=n;
    s[i]=(t[i]%26+'A');
}
cout<<s<<endl;
}

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

int main()
{
   int K,N;
   cin>>K>>N;
   int A[N];
    for (int i = 0; i <N ; ++i) {
        cin>>A[i];
    }
    sort(A,A+N);
    int B[N];
    for (int j = 0; j <N-1 ; ++j) {
        B[j]=A[j+1]-A[j];
    }
    B[N-1]=K-A[N-1]+A[0];
    sort(B,B+N);
    cout<<K-B[N-1];
    return 0;
}

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

#define                                 pai                                         acos(-1)
#define                                 ll                                          long long
#define                                 pb                                          push_back
#define                                 mp                                          make_pair
#define                                 pll                                         pair<ll,ll>
#define                                 sz(a)                                       (ll)a.size()
#define                                 endl                                        "\n"
#define                                 gcd(a, b)                                   __gcd(a, b)
#define                                 lcm(a, b)                                   (((a)*(b))/gcd(a,b))
#define                                 all(vec)                                    vec.begin(),vec.end()
#define                                 ms(a, b)                                    memset(a,b,sizeof(a))
#define                                 TEST_CASE(t)                                for(int www=1;www<=t;www++)
#define                                 PRINT_CASE                                  printf("Case %d: ",z)
#define                                 fii                                         freopen("input.txt","r",stdin);
#define                                 foo                                         freopen("output.txt","w",stdout);
#define                                 fast                                        ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll mod  = 1e9 +07;
const ll mxn  = 1e6 +10;

int  main()
{
    ll i,j,k,a,b,c,d=0,n,m,t,h,u,v,x,y,z;
    string s;
    cin>>s;
    reverse(all(s));
    char ch = s[0];
    if(ch=='2'||ch=='4'||ch=='5'||ch=='7'||ch=='9')
    {
        cout<<"hon"<<endl;
    }
    else if(ch=='0'||ch=='1'||ch=='6'||ch=='8')
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    return 0;
}




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

using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	vector<ll> a(100001);
	for (ll i = 0; i < n; i++) {
		ll m;
		cin >> m;
		a[m]++;
	}
	for (ll i = 1; i < 100000; i++) {
		ll temp = a[i - 1] + a[i] + a[i + 1];
		ans = max(ans, temp);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

  VVll c(3, Vll(n+1));

  string ref = "RGB";
  rep(i, n) {
    rep(j, 3) c[j][i+1] = c[j][i];
    rep(j, 3) {
      if (s[i] == ref[j]) c[j][i+1]++; 
    }
  }

  ll ans = 0;
  rep2(j, 1, n-1) {
    int x, y;
    if (s[j] == ref[0]) x = 1, y = 2;
    if (s[j] == ref[1]) x = 2, y = 0;
    if (s[j] == ref[2]) x = 0, y = 1;
    ans += c[x][j] * (c[y][n] - c[y][j+1]);
    ans += c[y][j] * (c[x][n] - c[x][j+1]);
  }

  rep2(j, 1, n-1) rep2(x, 1, n) {
    if (j-x < 0 || j+x >= n) continue;
    if (s[j]!=s[j-x] && s[j]!=s[j+x] && s[j-x]!=s[j+x]) --ans;
  }

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


Measured memory_bytes: 3748
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	int x,k,d;
	cin>>x>>k>>d;
	int pl=(x%d+d)%d;
	if(abs(pl-x)/d%2!=k%2)
		pl-=d;
	cout<<(abs(pl-x)/d<=k?abs(pl):pl>=x?abs(x+d*k):abs(x-d*k))<<endl;
}

Measured memory_bytes: 3628
if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    a.sort(reverse=True)
    total = sum(a)

    for i in range(m):
        if a[i] < total / (4*m):
            print('No')
            exit()

    print('Yes')


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

int main() {
    int N, x[100010], y[100010], t[100010];

    cin >> N;
    x[0] = y[0] = t[0] = 0;
    for (int i=0; i<N; i++) { cin >> t[i+1] >> x[i+1] >> y[i+1]; }

    bool can_solve = true;
    for (int i=0; i<N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);

        if (dt < dist) can_solve = false;
        if (dist % 2 != dt % 2) can_solve = false;
    }
    if (can_solve) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
//const int N=2e5+5;
bool visited[100005] = {false};
signed main(){
	FAST
	int n;
	cin>>n;
	int arr[n],b[n];
	for(int i = 0;i<n;i++) cin>>arr[i];
	b[0]=arr[0];
	for(int i = 1;i<n;i++){
		if(i==1){
			b[i]=abs(arr[i]-arr[i-1]);
		}
		else if(i==2){
			b[i]=min(b[i-1]+abs(arr[i]-arr[i-1]),abs(arr[i]-arr[i-2]));
		}
		else{
			b[i]=min(b[i-1]+abs(arr[i]-arr[i-1]),b[i-2]+abs(arr[i]-arr[i-2]));
		}
		//cout<<b[i]<<" ";
	}
	//cout<<b[n-1];
	cout<<b[n-1];
}

Measured memory_bytes: 1792
// atcoder/abc078/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  char a, b;
  while (cin >> a >> b) {
    if (a == b) cout << '=' << endl;
    else if (a < b) cout << '<' << endl;
    else cout << '>' << endl;
  }

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, R;
    cin >> N >> R;
    ll res;
    if(N>=10) res = R;
    else res = R + 100*(10-N);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int len=sz(s);
  if(len&1) {
    cout << "No" << endl;
    return 0;
  }
  rep(i,len) {
    if(i&1&&s[i]!='i') {
      cout << "No" << endl;
      return 0;
    }
    if(!(i&1)&&s[i]!='h') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>

int main(void){

  char s[101],t[101];
  scanf("%s %s", s, t);
  int length = strlen(s);
  int flag;
  for (int i = 0; i < length; i++) {
    flag = 1;
    for (int j = 0; i+j < length; j++) {
      if (t[j] != s[i+j]) {
        flag = 0;
        break;
      }
    }
    if (flag == 0) {
      continue;
    }
    for (int j = length-i; j < length; j++) {
      if (t[j] != s[i+j-length]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }
  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#define int long long
#define mod 998244353
int n,ans,a[300100],p[300100],cnt,sum[300100];
char s[300100];
signed main(){
	scanf("%lld",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++)
		a[i]=s[i]-'0';
	p[++cnt]=1;
	for(int i=3;i<=n;i+=2)
		if(n%i==0)p[++cnt]=i;
	for(int i=cnt;i>=1;i--){
		int len=n/p[i];
		for(int j=0;j<len;j++)
			sum[i]=(sum[i]*2+a[j])%mod;
		sum[i]++;
		for(int j=0;j<n;j++)
			if(((a[j%len])^(j/len&1))<a[j])break;
			else if(((a[j%len])^(j/len&1))>a[j]){
					--sum[i];
					break;
				}
		for(int j=i+1;j<=cnt;j++)
			if(p[j]%p[i]==0)(sum[i]-=sum[j]-mod)%=mod;
		(ans+=sum[i]*n/p[i]*2%mod)%=mod;
	}
	printf("%lld\n",ans%mod);
}

Measured memory_bytes: 4864
#include <iostream>

using namespace std;

int main(void){
	int n;
	int t[110000], x[110000], y[110000];
	cin >> n;
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < n; i++) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];	//1-indexにしておく

	bool can = true;
	for (int i = 0; i < n; i++){
		int dt = t[i + 1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < dist)can = false;
		if (dist % 2 != dt % 2)can = false;	// dist と dt の偶奇は一致する必要あり！
	}
	if (can)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
a, b=input().split()
a=int(a)
b=int(b)
if a<=1 and b<=1:
  print("0")
else:
  if a<=1:
    k=b*(b-1)//2
    print(k)
  elif b<=1:
    k=a*(a-1)//2
    print(k)
  else:
    k=a*(a-1)//2+b*(b-1)//2
    print(k)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b;
  cin >> a >> b;
  cout << max({a + b, a + a - 1, b + b - 1}) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  int ans=0;
  for(int i=1;i<str.size();i++){
    if(str[i-1]==str[i]){
      ans++;
      if(str[i]=='0'){
        str[i]='1';
      }
      else{
        str[i]='0';
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int L = S.size();
    string ans = "AC";
    if(S.at(0)!='A'){
        ans = "WA";
    }
    int cnt =0;
    for( int i=1; i<L; i++){
        if(isupper(S.at(i))){ // if Capital
            if( i==1 || i == L-1 || S.at(i) !='C'){
                ans = "WA";
            }
            cnt++; // count C
        }
    }
    if( cnt!=1){
        ans = "WA";
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s;
  cin >>s;
  
  cout << (s[0]==s[1] ||s[1]==s[2] ||s[2]==s[3]?"Bad":"Good") << endl;
  
  
}


Measured memory_bytes: 256
/**
 *       Author:  kulubat
 *       Written on Thursday, 16 April 2020.
 **/

#include <bits/stdc++.h>


using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;

    cin >> s;

    int n = s.length();

    int skip = 0;
    for(int i = n-1; i >= 0; --i) {
        if(s[i] == 'B') {skip++; continue;};

        if(skip > 0) {s[i] = 'B'; --skip;}
    }

    s.erase(remove(s.begin(), s.end(), 'B'), s.end());

    cout << s << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1
/*------------------------------------------------------------*/

int main(){
	string s;
	cin>>s;
	int ans=0;
	FOR(i,0,5){
		if(s[i]=='1')ans++;
	}
	out(ans);
}

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

using ll = int64_t;
ll dp[105][2][4];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    
    dp[0][1][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int x = 0; x < 10; ++x){
            int num = s[i] - '0';
            if(x == 0){
                for(int j = 0; j <= 3; ++j){
                    dp[i + 1][0][j] += dp[i][0][j];
                    if(x == num)    dp[i + 1][1][j] += dp[i][1][j];
                    else    dp[i + 1][0][j] += dp[i][1][j];
                }
            }
            else{
                if(x < num){
                    for(int j = 0; j < 3; ++j){
                        dp[i + 1][0][j + 1] += dp[i][0][j];
                        dp[i + 1][0][j + 1] += dp[i][1][j];
                    }
                }
                else if(x == num){
                    for(int j = 0; j < 3; ++j){
                        dp[i + 1][0][j + 1] += dp[i][0][j];
                        dp[i + 1][1][j + 1] += dp[i][1][j];
                    }
                }
                else{
                    for(int j = 0; j < 3; ++j){
                        dp[i + 1][0][j + 1] += dp[i][0][j];
                    }
                }
            }
        }
    }
    ll ans = dp[n][0][k] + dp[n][1][k];
    cout << ans << endl;
}

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


using namespace std;
#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 repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
ll x[100005], l[100005];
void solve() {
    cin >> n;
    vector<pair<ll, ll>> v(n);
    rep(i, n) {
        cin >> x[i] >> l[i];
        v[i] = make_pair(x[i] + l[i], 2 * l[i]);
    }

    all(sort, v);

    int ans = n;
    ll b = iinf;
    rep(i, n) {
        if (i == 0) { b = v[i].first; continue; }
        if (b > v[i].first - v[i].second)
            --ans;
        else
            b = v[i].first;
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
bool isPalindrome(string s)
{
    bool b=true;
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
    	if(s[i]!=s[n-i-1])
    	{
    		b=false;
    		break;
		}
	}
	return b;
}
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
   string s;
   cin>>s;
   string s1,s2;
   int n=s.size();
   s1=s.substr(0,(n-1)/2);
   s2=s.substr((n+3)/2-1,n-(n+3)/2+1);//
   if(isPalindrome(s)and(isPalindrome(s1))and(isPalindrome(s2)))
   {
   	cout<<"Yes";
   }
   else
   {
   	cout<<"No";
   }
}



Measured memory_bytes: 256
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const n = Number(spi[0]);
    let ans = 0n;
    for (let i = 1; i <= n; i++) {
        if (i % 3 !== 0 && i % 5 !== 0) ans += BigInt(i);
    }

    console.log(ans.toString());
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    long double a, b;
    cin >> a >> b;
    cout << (ll)floor(a * b) << endl;
    return 0;
}

Measured memory_bytes: 3732
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
 *	   "Winners Never Quit and Quitters Never Win".
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
// const int N = 300005;

/*******************************************************************/


int N = 10000005;
vector<int> p(N, -1);
void pre() {
	p[0] = 0; p[1] = 1;
	for (int i = 2; i < N; i++) {
		if (p[i] == -1) {
			for (int j = i; j < N; j += i) p[j] = i;
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t = 1, z = 1;
	// cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	pre();
	int n; cin >> n;
	unordered_map<int, int> m;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i == 1) {
			ans += 1; continue;
		}
		m.clear();
		int g = i, h = i;
		while (g != 1) {
			m[p[g]]++;
			g /= p[g];
		}
		for (auto x : m) {
			h *= (1 + x.second);
		}
		ans += h;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
  int a, b, d, r;
  double f;

  cin >> a >> b;

  d = a/b;
  r = a%b;
  f = double(a)/b;
  cout << fixed << std::setprecision(8);
  cout << d << " " << r << " " << f << endl;

}


Measured memory_bytes: 3284
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N + 1];
        int[] C = new int[N + 1];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
        }
        A[N] = Integer.MAX_VALUE;
        B[N] = Integer.MAX_VALUE;
        C[N] = Integer.MAX_VALUE;
        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);
        long[] BTC = new long[N + 1];
        for (int i = 0, j = 0; i < N; i++) {
            for (;; j++) {
                if (B[i] < C[j]) {
                    break;
                }
            }
            BTC[i] = N - j;
        }
        BTC[N] = 0;
        for (int i = N - 1; i >= 0; i--) {
            BTC[i] += BTC[i + 1];
        }
        long[] ATB = new long[N];
        for (int i = 0, j = 0; i < N; i++) {
            for (;; j++) {
                if (A[i] < B[j]) {
                    break;
                }
            }
            ATB[i] = BTC[j];
        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += ATB[i];
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int x; cin >> x;
  if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   cin>>n ;
   cout<<n+(n*n)+(n*n*n) ;
   return 0; }


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;

	cout << (n - 1) * (m - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void)
{
	int x, y;
	std::cin >> x >> y;
	while (x != 0 || y != 0) {
		if (x > y) {
			std::cout << y << " " << x << std::endl;
		}
		else {
			std::cout << x << " " << y << std::endl;
		}
		std::cin >> x >> y;
	}
	return 0;
}

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

int main(){

    int q;
    cin >> q;
    map<string, int> mp;
    for(int i = 0; i < q; ++i){
        int com;
        string key;
        cin >> com;
        if(com != 3){
            cin >> key;
        } 

        if(com == 0){
            int x;
            cin >> x;
            mp[key] = x;
        }
        else if(com == 1){
            if(mp.find(key) != mp.end()){
                cout << mp.at(key) << endl;
            }
            else{
                cout << 0 << endl;
            }
            
        }
        else if(com == 2){
            mp.erase(key);
        }
        else{
            string L, R;
            cin >> L >> R;
            auto l = mp.lower_bound(L);
            auto r = mp.upper_bound(R);
            for(auto it = l; it != r; ++it){
                cout << (*it).first << " " << (*it).second << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 27768
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x;
    cin >> x;
    int aa = 1000LL * (x/500LL);
    int ab = 5 * ((x % 500LL) / 5LL);

    cout << ab + aa << '\n';

    return 0;
}


Measured memory_bytes: 256
x=input().split()
num=[]
for k in range(3):
  num.append(int(x[k]))
num.sort()

a=num[1]-num[0]
b=num[2]-num[1]
if a*b!=0:
  print('No')
else:
  if a+b==0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 3060
#include<queue>
#include<ctime>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<memory.h>
#include<map>
#include<ctime>
#include<algorithm>
#include<ctime>
#include<set>
#define ll int
#define For(i,j,k)  for(ll i=j;i<=k;++i)
#define FOr(i,j,k)  for(ll i=j;i>=k;--i)
#define rep(i,j,k)	for(ll i=j;i<k;++i)
#define ld double
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; }
inline void wrote(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) wrote(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){ wrote(x);   puts("");   }
char s[10000];
ll n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	For(i,1,n-1)	if (s[i]=='A'&&s[i+1]=='C')	return puts("Yes"),0;
	puts("No");
}

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

int main(){
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(i<b^j<a) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;
#define ll long long

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

    string s;

    cin >> s;

    for(int i = 0; i < s.size(); ++i){
        cout << "x";
    }
    cout << "\n";

	return 0;
}


Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto A = scan!long(N);

  long solve() {
    long ans;

    long current = A[0];
    foreach(a; A) {
      if (a >= current) {
        current = a;
        continue;
      }

      ans += current - a;
    }

    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 10088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

const int MAX = 100005;
const int P = 1000000007; //shuoud be prime

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

void COMBinit() {
    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 % P;
        inv[i] = P - inv[P%i] * (P / i) % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
}

long long N, M;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	COMBinit();

	if(abs(N - M) > 1){
		printf("0\n");
		return 0;
	}

	long long ans = fac[N];
	ans *= fac[M];
	if(N == M){
		ans *= 2;
	}
	ans = ans % P;
	if(ans < 0) ans += P;

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int H,i,*A;
    scanf("%d",&H);
    A=malloc(sizeof(int)*(H+1));
    for(i=1;i<=H;i++)
        scanf("%d",A+i);

    for(i=1;i<=H;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if(i/2>0) printf("parent key = %d, ",A[i/2]);
        if(2*i<=H) printf("left key = %d, ",A[2*i]);
        if(2*i<H) printf("right key = %d, ",A[2*i+1]);
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 1764
# coding: utf-8
import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 番兵を左右に置いて、4通り試す
A, B, Q = lr()
INF = 10 ** 12
S = [-INF] + [ir() for _ in range(A)] + [INF]
T = [-INF] + [ir() for _ in range(B)] + [INF]
S.sort(); T.sort()
for _ in range(Q):
    x = ir()
    si = bisect_left(S, x)
    ti = bisect_left(T, x)
    temp = []
    temp.append(max(S[si], T[ti]) - x)
    y = abs(S[si] - x)
    z = abs(T[ti-1] - x)
    temp.append(min(y, z) * 2 + max(y, z))
    y = abs(S[si-1] - x)
    z = abs(T[ti] - x)
    temp.append(min(y, z) * 2 + max(y, z))
    temp.append(x - min(S[si-1], T[ti-1]))
    print(min(temp))

# 46


Measured memory_bytes: 12944
def main():
  N = int(input())
  nl = list(map(int,input().split()))

  if 0 in nl:
    print(0)
    return

  ans=1
  lim=10**18

  for i in nl:
    ans *= i
    if ans>lim:
      print(-1)
      return
    
  print(ans)
  
main()

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
typedef long long lint;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;

class SegmentTree {
private:
	int size__;
	Vec< pii > data;
	
	inline int left_t(int k) { return (k << 1) + 1; }
	inline int right_t(int k) { return (k << 1) + 2; }
	inline int center(int l, int r) { return (l + r) >> 1; }
	
	pii calc(pii d1, pii d2) { return min(d1, d2); }
	
	pii query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return pii(1e9, 1e9);
		if (a <= l && r <= b) return data[k];
		return calc(query(a, b, left_t(k), l, center(l, r)),
					query(a, b, right_t(k), center(l, r), r));
	}
	
public:
	SegmentTree() {}
	
	SegmentTree(int n) {
		for (size__ = 1; size__ < n; size__ <<= 1);
		data.assign(2 * size__ - 1, pii(1e9, 1e9));
	}
	
	void update(int k, pii a) {
		k += size__ - 1;
		data[k] = a;
		
		while (k > 0) {
			k = (k - 1) >> 1;
			data[k] = calc(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	pii query(int a, int b) { return query(a, b, 0, 0, size__); }
};

int N;
SegmentTree seg[2];

int m;
Vec< pii > piece;
Vec< int > nxt[200010];
map< pii, int > piece_to_id;

void divide(int l, int r, int par) {
	if (l >= r) return;
	
	pii a = seg[l % 2].query(l, r-1);
	pii b = seg[(l + 1) % 2].query(a.second+1, r);
	
	if (par != -1) nxt[par].push_back(m);
	piece.push_back(pii(a.first, b.first));
	piece_to_id[pii(a.first, b.first)] = m;
	int new_par = m;
	++m;
	
	if (l < a.second) divide(l, a.second, new_par);
	divide(a.second + 1, b.second, new_par);
	if (b.second + 1 < r) divide(b.second + 1, r, new_par);
}

void divideStack() {
	struct STK { int l, r, par; };
	
	stack< STK > stk;
	stk.push(STK{0, N, -1});
	
	while (!stk.empty()) {
		STK s = stk.top(); stk.pop();
		int l = s.l, r = s.r, par = s.par;
		if (l >= r) continue;
		
		pii a = seg[l % 2].query(l, r-1);
		pii b = seg[(l + 1) % 2].query(a.second+1, r);
		
		if (par != -1) nxt[par].push_back(m);
		piece.push_back(pii(a.first, b.first));
		piece_to_id[pii(a.first, b.first)] = m;
		
		if (l < a.second) stk.push(STK{l, a.second, m});
		stk.push(STK{a.second + 1, b.second, m});
		if (b.second + 1 < r) divide(b.second + 1, r, m);
		
		++m;
	}
}

int main() {
	cin >> N;
	
	for_(i,0,2) seg[i] = SegmentTree(N);
	
	for_(i,0,N) {
		int p; cin >> p;
		seg[i % 2].update(i, pii(p, i));
	}
	
	m = 0;
	divide(0, N, -1);
	//divideStack();
	
	Vec< int > ans;
	priority_queue< pii, Vec< pii >, greater< pii > > que;
	que.push(piece[0]);
	
	while (!que.empty()) {
		pii p = que.top(); que.pop();
		ans.push_back(p.first);
		ans.push_back(p.second);
		
		int id = piece_to_id[p];
		for (int i : nxt[id]) que.push(piece[i]);
	}
	
	for_(i,0,N) cout << ans[i] << (i < N - 1 ? " " : "\n");
}

Measured memory_bytes: 200436