akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
string cube[6] = {"..rr....",
                  "..rr....",
                  "ggyybbww",
                  "ggyybbww",
                  "..oo....",
                  "..oo...."};
 
 
 
 
 
void U(){
 
 
   for(int i = 0; i < 2; i++){
    char tmp = cube[2][0];
    cube[2][0] = cube[2][1];
    cube[2][1] = cube[2][2];
    cube[2][2] = cube[2][3];
    cube[2][3] = cube[2][4];
    cube[2][4] = cube[2][5];
    cube[2][5] = cube[2][6];
    cube[2][6] = cube[2][7];
    cube[2][7] = tmp;
   }
 
 
    char tmp = cube[0][2];
    cube[0][2] = cube[1][2];
    cube[1][2] = cube[1][3];
    cube[1][3] = cube[0][3];
    cube[0][3] = tmp;
}
 
void F(){
 
  for(int i = 0; i < 2; i++){
  char tmp = cube[1][2];
  cube[1][2] = cube[2][1];
  cube[2][1] = cube[3][1];
  cube[3][1] = cube[4][2];
  cube[4][2] = cube[4][3];
  cube[4][3] = cube[3][4];
  cube[3][4] = cube[2][4];
  cube[2][4] = cube[1][3];
  cube[1][3] = tmp;
  }
 
  char tmp = cube[2][2];
  cube[2][2] = cube[3][2];
  cube[3][2] = cube[3][3];
  cube[3][3] = cube[2][3];
  cube[2][3] = tmp;
 
}
 
void R(){
 
  for(int i = 0; i < 2; i++){
   char tmp = cube[0][3];
   cube[0][3] = cube[1][3];
   cube[1][3] = cube[2][3];
   cube[2][3] = cube[3][3];
   cube[3][3] = cube[4][3];
   cube[4][3] = cube[5][3];
   cube[5][3] = cube[3][6];
   cube[3][6] = cube[2][6];
   cube[2][6] = tmp;
  }
 
   char tmp = cube[2][4];
   cube[2][4] = cube[3][4];
   cube[3][4] = cube[3][5];
   cube[3][5] = cube[2][5];
   cube[2][5] = tmp;
}
 
void D(){
 
  for(int i = 0; i < 2; i++){
  char tmp = cube[3][7];
  cube[3][7] = cube[3][6];
  cube[3][6] = cube[3][5];
  cube[3][5] = cube[3][4];
  cube[3][4] = cube[3][3];
  cube[3][3] = cube[3][2];
  cube[3][2] = cube[3][1];
  cube[3][1] = cube[3][0];
  cube[3][0] = tmp;
  }
 
  char tmp = cube[4][2];
  cube[4][2] = cube[5][2];
  cube[5][2] = cube[5][3];
  cube[5][3] = cube[4][3];
  cube[4][3] = tmp;
}
 
void B(){
 
  for(int i = 0; i < 2; i++){
 
  char tmp = cube[0][2];
  cube[0][2] = cube[0][3];
  cube[0][3] = cube[2][5];
  cube[2][5] = cube[3][5];
  cube[3][5] = cube[5][3];
  cube[5][3] = cube[5][2];
  cube[5][2] = cube[3][0];
  cube[3][0] = cube[2][0];
  cube[2][0] = tmp;
 
  }
 
  char tmp = cube[2][6];
  cube[2][6] = cube[3][6];
  cube[3][6] = cube[3][7];
  cube[3][7] = cube[2][7];
  cube[2][7] = tmp;
 
 
}
 
void L(){
 
 
  for(int i = 0; i < 2; i++){
  char tmp = cube[0][2];
  cube[0][2] = cube[2][7];
  cube[2][7] = cube[3][7];
  cube[3][7] = cube[5][2];
  cube[5][2] = cube[4][2];
  cube[4][2] = cube[3][2];
  cube[3][2] = cube[2][2];
  cube[2][2] = cube[1][2];
  cube[1][2] = tmp;
 
  }
 
 
  char tmp = cube[2][0];
  cube[2][0] = cube[3][0];
  cube[3][0] = cube[3][1];
  cube[3][1] = cube[2][1];
  cube[2][1] = tmp;
 
}
 
void print(){
  for(int i = 0; i < 6; i++)
      cout << cube[i] << endl;
}
 
int main() {
  string s;
  cin >> s;
 
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'U') U();
    if(s[i] == 'F') F();
    if(s[i] == 'R') R();
    if(s[i] == 'D') D();
    if(s[i] == 'B') B();
    if(s[i] == 'L') L();
 
  }
 
  print();
 
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int main() {
    int n, m, x, *a;
    cin >> n >> m >> x;
    a = new int[m];
    for (int i = 0; i < m; i++)
        cin >> a[i];
    
    int i = 0, sum = 0;
    while (i < m && a[i] < x) {
        sum++;
        i++;
    }

    cout << min(sum, m-sum) << endl;
    return 0;
}

Measured memory_bytes: 384
N,K = map(int,input().split())
S = list(input())

if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
print(''.join(S))

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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;

    if(K<=A){
        cout << K << endl;
    }
    else if(K<=A+B){
        cout << A << endl;
    }
    else{
        cout << 2*A+B-K << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
import bisect

N = int(input())

An = sorted(map(int, input().split()))
Bn = map(int, input().split())
Cn = sorted(map(int, input().split()))


def main():
    print(sum([bisect.bisect_left(An, Bi)
               * (N - bisect.bisect(Cn, Bi)) for Bi in Bn]))

    return


main()


Measured memory_bytes: 26656
N, T = list(map(int, input().split()))

a = []
for i in range(N):
    tmp = list(map(int, input().split()))
    min_time = 10000
    if tmp[1] <= T:
        a.append(tmp[0])

if len(a) == 0:
    print('TLE')
else:
    print(min(a))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

double dist(pii a, pii b){
    return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
int main(){
    int n;
    cin >> n;
    vector<pii> a(n);
    for(auto& i : a) cin >> i.first >> i.second;
    double ans = 0;
    int fact = 2;
    for(int i = 1; i < n; i++) fact *= i;
    for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) ans += dist(a[i], a[j]) * fact;
    for(int i = 1; i <= n; i++) ans /= i;
    cout << fixed << setprecision(20) << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

const int N = 1e6 + 10;
int go[N];
int fre[N];
int a[N];

void solve()
{
   int n;
    cin >> n;
    
   f(i,n) cin >> a[i];
    
    int gc = a[0];
    
    f(i,n) gc = __gcd(gc,a[i]);
    
    f(i,n) fre[a[i]]++;
    
    for(int i=N-1;i>=1;i--)
      for(int j=i;j<N;j+=i) go[i]+=fre[j];
    
   for(int i=2;i<N;i++)
    {
        if(go[i] > 1)
        {
            if(gc == 1) cout << "setwise coprime";
            else cout <<"not coprime";
            return;
        }
    }
    
    cout <<"pairwise coprime";
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 27012
public class Main {


  
  private static void solve() {
    int n = ni();
    int k = ni();
    int[][] a = ntable(n, 2);
    

    long max = 0;
    
    for (int[] v : a) {
      if ((v[0] & k) == v[0]) {
        max += v[1];
      }
    }

    for (int i = 0; i <= 30; i ++) {
      int b = 1 << i;
      if ((k & b) != 0) {
        int x = k ^ b | (b - 1);

        long sum = 0;
        for (int[] v : a) {
          if ((v[0] & x) == v[0] || (v[0] & (k ^ b)) == v[0]) {
            sum += v[1];
          }
        }
        max = Math.max(sum, max);
      }
    }

    System.out.println(max);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

int main()
{
    int ans = 0;
    int count = 0;
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            count++;
            if (ans <= count)
            {
                 ans = count;
            }
        }
        else
        {
            count = 0;
        }
    }

    cout << ans << endl;
    
}   

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

int main()
{
    int n , a{};
    std :: cin >> n;

    for(int i = 1 ; i <= n ; i++)
    {
        int x;
        std :: cin >> x;
        if(x != i)
            a++;
    }

    std :: cout << (a > 2 ? "NO\n" : "YES\n");
}


Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    int m = sc.nextInt();
    int ac_count = 0;
    int wa_count = 0;
    int[] ac_list = new int[n];//正解の数
    int[] wa_list = new int[n];//不正解の数
    int p=0 ;
    String s ;



    for(int i=0; i<m; i++){
      p = sc.nextInt() -1;
      s = sc.next();

      if(ac_list[p]<1){//問題が正解になっていない
        if(s.equals("AC")){
          ac_list[p] += 1;
        }else if(s.equals("WA")){
          wa_list[p] += 1;
        }
      }
    }
    for (int i = 0; i < n; i++) {
    if (ac_list[i] < 1) {
        wa_list[i] = 0;
    }
    }

    int ac_sum = 0;
    int wa_sum = 0;

    for(int i=0; i<n; i++){
    ac_sum += ac_list[i];
    wa_sum += wa_list[i];
    }


    System.out.println(ac_sum + " " + wa_sum);
  }
}

Measured memory_bytes: 63564
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#define x first
#define y second
#define m_p make_pair
using namespace std;
vector<int> adj[1010];
int val[1010],sz[1010];
class dp{
	public:
		bool a[5010];
		int mx;
		inline void clear(){
			memset(a,0,sizeof(a));
		}
		inline void add(int xx){
			if (xx<=mx) a[xx]=1;
		}
};
int dfs(int i){
	if (!sz[i]) return 0;
	int tot=0;
	dp cur,tmp;
	cur.clear();
	cur.a[0]=1;
	cur.mx=val[i];
	for (int j=sz[i]-1;~j;j--){
		int nxt=adj[i][j],nv=val[nxt],nl=dfs(nxt);
		tot+=nv+nl;
		tmp=cur;
		cur.clear();
		cur.mx=val[i];
		for (int k=0;k<=val[i];k++){
			if (tmp.a[k]) cur.add(k+nv),cur.add(k+nl);
		}
	}
	for (int j=val[i];~j;j--){
		if (cur.a[j]) return tot-j;
	}
	printf("IMPOSSIBLE");
	exit(0);
}
int main(void){
	int n;
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		int ff;
		scanf("%d",&ff);
		sz[ff]++;
		adj[ff].push_back(i);
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&val[i]);
	}
	dfs(1);
	printf("POSSIBLE");
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    long k;
    cin >> k;
    int l = k % 10;
    if (l != 1 && l != 3 && l != 7 && l != 9) {
        cout << -1 << endl;
        return 0;
    }

    unordered_map<int, vector<int>> m;
    m[1] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    m[3] = {0, 7, 4, 1, 8, 5, 2, 9, 6, 3};
    m[7] = {0, 3, 6, 9, 2, 5, 8, 1, 4, 7};
    m[9] = {0, 9, 8, 7, 6, 5, 4, 3, 2, 1};

    vector<int>& ml = m[l];

    long a = k * ml[7] / 10;
    int ans = 1;
    while (true) {
        if (a == 0) {
            break;
        }
        ans += 1;
        int e = a % 10;
        if (e == 0) {
            a = (a + k * ml[7]) / 10;
            continue;
        }
        if (e == 7) {
            a = a / 10;
            continue;
        }
        if (e < 7) {
            a = (a + k * ml[7 - e]) / 10;
        } else {
            a = (a + k * ml[17 - e]) / 10;
        }
    }
    cout << ans << endl;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = 0; i < n - m + 1; i++) {
        bool match = true;
        for (int j = 0; j < m; j++) {
            if (s[n - 1 - i - j] != '?' && s[n - 1 - i - j] != t[m - 1 - j]) {
                match = false;
                break;
            }
        }
        if (match) {
            for (int j = 0; j < m; j++){
                s[n - 1 - i - j] = t[m - 1 - j];
            }
            for (int j = 0; j < n; j++){
                if (s[j] == '?') {
                    s[j] = 'a';
                }
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}


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

int max_fnc(int a[], int n){
	int max = 0;
	for ( int i = 0 ; i < n ; i++ ) {
		if ( a[i] > max ) {
			max = a[i];
		}
	}
	return max;
}

int min_fnc(int a[], int n){
	int min = 9999;
	for ( int i = 0 ; i < n ; i++ ) {
		if ( a[i] < min ) {
			min = a[i];
		}
	}
	return min;
}

int main(){
	int n,a[1002];

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

	cout << max_fnc(a, n) - min_fnc(a, n) << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int g;
  cin>>g;
  vector<int64_t> l(87);
  l.at(0)=2;
  l.at(1)=1;
  for(int z=2;z<=g;z++) l.at(z)=l.at(z-1)+l.at(z-2);
  cout<<l.at(g)<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N + 1);
    vec[0] = 2;
    vec[1] = 1;
    FOR(i, 2, N + 1) {
        vec[i] = vec[i - 1] + vec[i - 2];
    }
    cout << vec[N] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int sim(int m,int d){
  int i,ans=0;
  for(i=1;i<m;i++){
    if(i==1||i==3||i==5||i==7||i==8||i==10)
      ans+=31;
    else if(i==2)
      ans+=29;
    else
      ans+=30;
  }
  ans+=d;
  return ans%7;
}

int main(void){
  int m,d;
  char s[7][20]={
    "Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"
  };
  while(scanf("%d %d",&m,&d),m+d){
    printf("%s\n",s[sim(m,d)]);
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;
 
int main()
{
  int n;
  cin>>n;
  if(n>999)
  {
    cout<<"ABD";
  }
  else
  {
    cout<<"ABC";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 103;
int n, cnt[N], k;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++){
		int x; scanf("%d", &x); ++ cnt[x]; k = max(k, x);
	}
	if(k & 1){
		for(Rint i = k + 1 >> 1;i <= k;i ++){
			if(cnt[i] < 2){puts("Impossible"); return 0;}
			cnt[i] -= 2;
		}
		for(Rint i = 0;i <= (k + 1 >> 1);i ++)
			if(cnt[i]){puts("Impossible"); return 0;}
	} else {
		if(!cnt[k >> 1]){puts("Impossible"); return 0;}
		-- cnt[k >> 1];
		for(Rint i = (k >> 1) + 1;i <= k;i ++){
			if(cnt[i] < 2){puts("Impossible"); return 0;}
			cnt[i] -= 2;
		}
		for(Rint i = 0;i <= (k >> 1);i ++)
			if(cnt[i]){puts("Impossible"); return 0;}
	}
	puts("Possible");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位


int main(void){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    ll MAX = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        MAX = max(MAX, a[i]);
    }
    ll check = a[0];
    for(ll i = 1; i < n; i++)
        check = __gcd(check, a[i]);
    //bool ok = true;
    if(k%check==0 && MAX >= k)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define ss second
#define ff first
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define pb push_back
#define pf push_front
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vc4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
const ll oo=(1ll<<60);
int gg(){
    int x=0,w=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=0,ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return w?x:-x;
}

int main()
{
     io;
    int T=1;
    //T=gg();
    //cin>>T;
    //for(int cas=1;cas<=T;cas++)
    while(T--)
    {
       ll n,i,j,k,l,sum=0;
       cin>>n>>k;
       for(i=1;i<n;i++)
       {
           cin>>j;
           if(j<k)sum+=(k-j),j=k;
           k=j;
       }
       cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 3600
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

void solve(){
	int n = rint, k = rint;
	
	int[] as, bs, cs;
	foreach(i; 0 .. n){
		if(i % 2 == 0){
			as ~= k + i / 2;
			bs ~= k + n + n / 2 + i / 2;
			cs ~= k + n + n + i;
		}
		else{
			as ~= k + (n + 1)/ 2 + i / 2;
			bs ~= k + n + i / 2;
			cs ~= k + n + n + i;
		}
	}
	
	foreach(i; 0 .. n){
		if(as[i] + bs[i] > cs[i]){
			"-1".writeln;
			return;
		}
	}
	
	foreach(i; 0 .. n){
		writeln(as[i], " ", bs[i], " ", cs[i]);
	}
	

	
}


Measured memory_bytes: 6268
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    char c;
    cin >> c;
    cout << char('a' + (c - 'a' + 1)) << endl;
    return (0);
}

Measured memory_bytes: 256
import copy
n,k = map(int,input().split())
r,s,p = map(int,input().split())
T = list(input())

mo = [[] for i in range(k)]

for i in range(n):
    num = i % k
    mo[num].append(T[i])
    
mo1 = copy.deepcopy(mo)
for i in range(k): 
    for j in range(len(mo[i])):
        if mo[i][j] == "r":
            mo1[i][j] = "p"
        elif mo[i][j] == "p":
            mo1[i][j] = "s"
        else:
            mo1[i][j] = "r"
        if j > 0 and mo1[i][j] == mo1[i][j-1]:
            mo1[i][j] = "x"

ans = 0
for i in range(k):
    for j in range(len(mo1[i])):
        if mo1[i][j] == "r":
            ans += r
        elif mo1[i][j] == "p":
            ans += p
        elif mo1[i][j] == "s":
            ans += s
print(ans)

Measured memory_bytes: 38776
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(a>x)cout<<"NO"<<endl;
  else if(a+b<x)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
string s;
cin >> s;
if(s=="Sunny") {
  cout << "Cloudy" << endl;
} else if(s=="Cloudy") {
  cout << "Rainy" << endl;
} else {
  cout << "Sunny" << endl;
}
return 0;
}


Measured memory_bytes: 256
#define N 10000
#include <stdio.h>
#include <math.h>
int isprime(int);

int main(){
  int a[N],n,c = 0,i,b;
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&a[i]);
  }
  


  for(i = 0; i < n; i++){
    b = isprime(a[i]);
    if( b == 1 ){
      c++;
    }
  }
  printf("%d\n",c);

  return 0;
}

int isprime(x){
  int i;
  if(x == 2) return 1;

  if(x < 2 || x % 2 == 0) return 0;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0){
      return 0;
    }
    i = i + 2;
  }

  return 1;
}

Measured memory_bytes: 628
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,i,j,k;
int a[100005];
long long l,r;

void work(int A)
{
	if(A>l)l=A;
	if(l>r)
	{
		printf("-1\n");
		exit(0);
	}
	if(l%A)l+=(A-l%A);
	r+=(A-1-r%A);
	if(l>r)
	{
		printf("-1\n");
		exit(0);
	}
}

int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	l=r=2;
	for(i=n;i>=1;--i)work(a[i]);
	printf("%lld %lld\n",l,r);
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
    int count = 0;
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        int n = input.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) S[i] = input.nextInt();
        
        count = 0;
        mergeSort(S, 0, S.length);
        print(S);
        System.out.println(count);
    }
    
    private void merge(int[] A, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] L = new int[n1+1], R = new int[n2+1];
        
        for (int i = 0; i < n1; i++) {
            L[i] = A[left + i];
        }
        for (int i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
        L[n1] = Integer.MAX_VALUE;
        R[n2] = Integer.MAX_VALUE;
        
        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
            count++;
            if (L[i] <= R[j]) {
                A[k] = L[i++];
            } else {
                A[k] = R[j++];
            }
        }
    }
    private void mergeSort(int[] A, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(A, left, mid);
            mergeSort(A, mid, right);
            merge(A, left, mid, right);
        }
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) sb.append(x).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

Measured memory_bytes: 81100
#include<iostream>
using namespace std;
int main() {
	int x, y,a,b;
  	cin>>x>>y;
  	b = (y-(2*x))/2;
  	a = x-b;
  	if(a>=0 && b>=0 && 2*a + 4*b==y)
      cout<<"Yes";
  	else 
      cout<<"No";
  	return 0;
}


Measured memory_bytes: 3592
a, b, c = map(int, input().split())
if c > a+b and 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")
'''
浮動小数点は長い数を扱うと誤差が生じる
また、整数で計算しようとした時も√の中身は0以上であるという条件から
c > a+b　を忘れてはいけない
'''


Measured memory_bytes: 2940
// #pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second
#define mod 1000000007

using namespace std;

int n, m;
ll a[110], b[110];
ll dp[110][100100];        

int main() {    
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (j - a[i] > 0 && dp[i - 1][j - a[i]] > 0)
                dp[i][j] = max(dp[i - 1][j - a[i]] + b[i], dp[i - 1][j]);
            else dp[i][j] = dp[i - 1][j];
            dp[i][a[i]] = max(dp[i][a[i]], b[i]);
        }

    ll mx = 0;
    for (int i = 1; i <= m; i++)
        mx = max(mx, dp[n][i]);

    cout << mx;
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	cin>>n;
	map<string ,int>m;
	string s;
	m["AC"]=0;
	m["WA"]=0;
	m["TLE"]=0;
	m["RE"]=0;
	while(n--)
    {
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
	return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<queue>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> p(m);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        a = m - a;
        if(a >= 0) p[a].push_back(b);
    }
    priority_queue<int> q;
    int ans = 0;
    for(int i = m - 1; i >= 0; i--){
        for(auto&& j : p[i]){
            q.push(j);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
import java.util.Scanner;

class Problem {
    private String b;

    Problem() {
        Scanner sc = new Scanner(System.in);
        b = sc.next();
    }

    String solve() {
        if (b.equals("A")) {
            return "T";
        } else if (b.equals("C")) {
            return "G";
        } else if (b.equals("G")) {
            return "C";
        } else {
            return "A";
        }
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


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

using ll = long long int;

const int MAX_N = (int)(1e5 + 5);
const ll MAX = (ll)(1e9 + 7);

string s;

ll dp[MAX_N][4];

int main(void) {
  // Here your code !
  cin >> s;

  int length = s.size();

  dp[length][3] = 1;
  dp[length][2] = 0;
  dp[length][1] = 0;
  dp[length][0] = 0;

  map<char, int> char_ind;
  char_ind['A'] = 0;
  char_ind['B'] = 1;
  char_ind['C'] = 2;

  for (int l = length - 1; l >= 0; --l) for (int j = 3; j >= 0; --j) {
    if (j == 3) {
      int m = (s[l] == '?') ? 3 : 1;
      dp[l][j] = m * dp[l + 1][j];
      dp[l][j] %= MAX;
    }
    else {
      int m1 = (s[l] == '?') ? 3 : 1;
      int m2 = (s[l] == '?' || char_ind[s[l]] == j) ? 1 : 0;
      dp[l][j] = m1 * dp[l + 1][j] + m2 * dp[l + 1][j + 1];
      dp[l][j] %= MAX;
    }
  }

  printf("%lld\n", dp[0][0]);

  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
int a[100000+10];
int c[100000+10]= {0};
int d[100000+10]= {0};
string b[100000+10];
int main()
{
    int n,m,sum=0,h=0;
    cin>>n>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1; i<=m; i++)
    {
        if(c[a[i]]==0&&b[i]=="WA"&&a[i]<=n)
            d[a[i]]++;
        else if(b[i]=="AC"&&c[a[i]]==0&&a[i]<=n)
        {
            c[a[i]]=1;
            h+=d[a[i]];
            sum++;
        }
    }
    cout<<sum<<" "<<h;
}



Measured memory_bytes: 6784
class Factorial:
    def __init__(self,n,mod):
        self.f=f=[0]*(n+1)
        f[0]=b=1
        self.mod=mod
        for i in range(1,n+1):f[i]=b=b*i%mod
        self.inv=inv=[0]*(n+1)
        inv[n]=b=pow(self.f[n],mod-2,mod)
        for i in range(n,0,-1):inv[i-1]=b=b*i%mod
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.inv[i]
    def comb(self,n,k):
        if n>=k:
            return self.f[n]*self.inv[n-k]%self.mod*self.inv[k]%self.mod
        else:
            return 0
    def homp(self,n,k):
        return self.comb(n+k-1,n-1)
M=10**9+7
n,k=map(int,input().split())
f=Factorial(n*2,M)
c=f.comb
h=f.homp
a=0
for i in range(min(k+1,n)):
    a+=c(n,i)*h(n-i,i)%M
print(a%M)

Measured memory_bytes: 46832
#include<stdio.h>
int main(void)
{
	int w,h,c,n,r,tmp,a,b,k;
	scanf("%d %d %d",&w,&h,&c);
	a=w; b=h;
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	k=(w/b)*(h/b);
	printf("%d\n",k*c);
	return 0;
}


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

int main() {
  int X, N, ans;
  cin >> N;
  X = N;
  ans = 0;

  while (N) {
    ans += N % 10;
    N /= 10;
  }
  cout << (X % ans == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 203000;

    void solve() {
      char c;
      cin >> c;
      if(c == 'A') cout << 'T';
      else if(c == 'G') cout << 'C';
      else if(c == 'C') cout << 'G';
      else cout << 'A';

    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
S=input()
data=[]
now=[]
idx=0
while idx<len(S):
    if S[idx]=="A":
        now.append(0)
        idx+=1
    elif S[idx]=="B" and idx+1<len(S):
        idx+=1
        if S[idx]=="C":
            now.append(1)
            idx+=1
        elif len(now)>0:
            data.append(now)
            now=[]
    else:
        idx+=1
        if len(now)>0:
            data.append(now)
            now=[]
if len(now)>0:
    data.append(now)

def calc(x):
    cnt=0
    ans=0
    for i in x:
        if i==0:
            cnt+=1
        elif i==1:
            ans+=cnt
    return ans
ans=0
for x in data:
    ans+=calc(x)
print(ans)

Measured memory_bytes: 9064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0, K = 0;
  std::cin >> N >> K;
  std::vector<uint32_t> p(N, 0);
  for (size_t i = 0; i < N; i++) std::cin >> p[i];
  std::sort(p.begin(), p.end());

  uint32_t sum = 0;
  for (size_t i = 0; i < K; i++) sum += p[i];
  
  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 3604
from itertools import permutations
import math

n = int(input())
P = []
for _ in range(n):
    P.append(tuple(map(int, input().split())))
distance = 0
for array in permutations(P):
    for i in range(n - 1):
        p1 = array[i]
        p2 = array[i + 1]
        diff_x = p1[0] - p2[0]
        diff_y = p1[1] - p2[1]
        distance += math.sqrt(diff_x ** 2 + diff_y ** 2)
print(distance / math.factorial(n))


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for (int i = 1; i < n; i++) {
		int cnt = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;
			for (int j = 0; j < i; j++) {
				if (s[j] == c) {
					left = true;
				}
			}
			for (int j = i; j < n; j++) {
				if (s[j] == c) {
					right = true;
				}
			}
			if (left && right) {
				cnt++;
			}
			if (ans < cnt) {
				ans = cnt;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
long long N,A,B;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%lld %lld %lld",&N,&A,&B);
	if(!(A+B<=N+1&&A*B>=N)) {
		printf("-1");
	} else {
		while(N>0) {
			long long x=min(A,N-B+1);
			for(long long i=N-x+1;i<=N;i++)
				printf("%lld ",i);
			N-=x;
			B--;
		}
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int a, b, c, d, e, f;
  double x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    y = (double)(d*c - a*f) / (b*d - a*e);
    x = (c - b*y) / a;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e4;
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;
}

int main()
{
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  string s;
  cin >> s;
  if (s[0] == s[2])
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  // cout << ans << endl;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  
  int A_MAX = 0 ;
  int A_MIN = INF ;
  int B_MIN = INF ;
  
  rep(i,n){
    int a , b ; 
    cin >> a >> b ;
    A_MAX = max(A_MAX,a) ;
    B_MIN = min(B_MIN,b) ;
  }
  
 
  cout << A_MAX + B_MIN  <<endl ;
  
  


}


Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest20191031
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string s1 = s[0].ToString() + s[1].ToString();
            string s2 = s[2].ToString() + s[3].ToString();
            int n1 = int.Parse(s1);
            int n2 = int.Parse(s2);
            bool successN1 = false;
            bool successN2 = false;

            if (n1 > 0 && n1 < 13)
                successN1 = true;

            if (n2 > 0 && n2 < 13)
                successN2 = true;

            if (successN1 && successN2)
                Console.WriteLine("AMBIGUOUS");

            else if (!successN1 && !successN2)
                Console.WriteLine("NA");

            else if (!successN1 && successN2)
                Console.WriteLine("YYMM");

            else if (successN1 && !successN2)
                Console.WriteLine("MMYY");

        }
    }
}


Measured memory_bytes: 11092
//
// Created by kuribohkute on 20/04/2019.
//
#include <unordered_map>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define mp make_pair
#define X first
#define Y second
int h, w, n, sr, sc;
string s1, s2;
const int N = 1003;
bool inRange(int x, int y) {
    return x && x <= h && y && y <= w;
}
typedef pair <int, int> pii;
int dx[4] = {0, 0, -1, 1},
    dy[4] = {-1, 1, 0, 0};
vector <char> dir1 = {'L', 'R'},
              dir2 = {'U', 'D'};
unordered_map <char, int> mm;

bool solve (char c1, char c2) {
    vector <int> a, b;
    for (auto c: s1) {
        if (c == c1 || c == c2) {
            a.push_back(mm[c]);
        } else {
            a.push_back(-1);
        }
    }
    for (auto c: s2) {
        if (c != c1 && c != c2) {
            b.push_back(mm[c]);
        } else {
            b.push_back(-1);
        }
    }
    int x = sr, y = sc;
    for (int i = 0; i < n; i++) {
        if (a[i] != -1) {
            x += dx[a[i]];
            y += dy[a[i]];
        }
        if (!inRange(x, y)) {
            return true;
        }
        if (b[i] != -1 && inRange(x + dx[b[i]], y) && inRange(x, y + dy[b[i]])) {
            x += dx[b[i]];
            y += dy[b[i]];
        }
    }
    return false;
}
int main () {
    mm['L'] = 0;
    mm['R'] = 1;
    mm['U'] = 2;
    mm['D'] = 3;
    cin >> h >> w >> n;
    cin >> sr >> sc;
    cin >> s1 >> s2;
    for (auto c1: dir1) {
        for (auto c2: dir2) {
            if (solve(c1, c2)) {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e17;

LL dp[100010];

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

  LL N, A, B;
  cin >> N >> A >> B;
  VL xs(N);
  REP(i,N) cin >> xs[i];

  fill(dp, dp+100010, INF);
  dp[1] = 0;
  FOR(i,1,N)
	dp[i+1] = min(dp[i] + A * (xs[i] - xs[i-1]), dp[i] + B);

  cout << dp[N] << endl;

  return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, ab[5];
	cin >>n;
	rep(i, 5) cin >>ab[i];
	
	ll mn = *min_element(ab, ab+5);
	ll ans = (n + mn -1) / mn + 4;
	cout << ans <<endl;
	return 0;
}


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

int a, b, c, d, e, f;

typedef pair<double, pair<int, int> > P;

bool visited[4000][4000];
P memo[4000][4000];

P dp(int i, int j){

    if(visited[i][j]){
        return memo[i][j];
    }

    P ans = {(double)j/(double)(i+j), {i, j} };


    if(i+j+a <= f){
        ans = max(ans, dp(i+a, j));
    }

    if(i+j+b <= f){
        ans = max(ans, dp(i+b, j));
    }

    if(i+j+c <= f && ((double)(j+c)/(double)(i+j+c)) <= (double)e/(double)(100.0+e)){
        ans = max(ans, dp(i, j+c));
    }

    if(i+j+d <= f && ((double)(j+d)/(double)(i+j+d)) <= (double)e/(double)(100.0+e)){
        ans = max(ans, dp(i, j+d));
    }

    visited[i][j] = 1;

    return memo[i][j] = ans;
}


int main(){
    cin >> a >> b >> c >> d >> e >> f;
    a*=100;
    b*=100;

    pair<int, int> ans;
    if(b <= f){
        ans = max(dp(a, 0), dp(b, 0)).second;
    }else{
        ans = dp(a, 0).second;
    }

    cout << (ans.first + ans.second) << " " << (ans.second) << endl;

    return 0;
}


Measured memory_bytes: 55552