akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
using ll=long long;
const int limit=100010;
using edge=struct{int to;ll cost;};
vector<edge> tree[limit];
ll depth[limit];


void dfs(int v,int p,ll d){
    depth[v]=d;
    for(auto &e:tree[v]){
        if(e.to==p)continue;
        dfs(e.to,v,d+e.cost);
    }
}


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

for(int i=0;i<n-1;++i){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
}

int q,k;
cin>>q>>k;
k--;

dfs(k,-1,0);

for(int i=0;i<q;++i){
    int x,y;
    cin>>x>>y;
    x--;y--;
    cout<<depth[x]+depth[y]<<endl;
}

 return 0;
}

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

int main()
{
	int N, sum, max;
	cin >> N;
	max  = 0;
	
	int A[N], B[N];
	for(int i = 1; i<=N; i++){ cin >> A[i]; }
	for(int i = 1; i<=N; i++){ cin >> B[i]; }

	for(int i = 1; i<=N; i++)
	{
		sum = 0;
		for(int j = 1; j<=i; j++)
		{
			sum += A[j];
		}
		for(int k = i; k<=N; k++)
		{
			sum += B[k];
		}
		if(sum > max){max = sum;}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			int n = sc.nextInt();
			long[] array = new long[n];
			for (int i=0; i<n; i++) array[i] = sc.nextLong();
			int times = sc.nextInt();  //queryの数
			for (int i=0; i<times; i++) {
				int start = sc.nextInt();
				int end = sc.nextInt();
				int target = sc.nextInt();
				//count(start,end,target)
				int count = 0;
				for (int j=start; j<end; j++) {
					if (array[j] == target) count++;
				}
				System.out.println(count);
			}
		}
	}
}




Measured memory_bytes: 36848
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int L;
    cin>>L;
    string s,t;
    cin>>s>>t;
    if(s>t) swap(s,t);
    string ans="";
    REPR(i,L) {
        if(SZ(s)*i<=L) {
            int tmp=L-SZ(s)*i;
            if(tmp%SZ(t)==0) {
                int A=i,B=tmp/SZ(t);
                REP(j,A) ans+=s;
                REP(j,B) ans+=t;
                break;
            }
        }
    }
    string ans2="";
    REPR(i,L) {
        if(SZ(t)*i<=L) {
            int tmp=L-SZ(t)*i;
            if(tmp%SZ(s)==0) {
                int A=i,B=tmp/SZ(s);
                REP(j,A) ans2+=t;
                REP(j,B) ans2+=s;
                break;
            }
        }
    }
    cout<<min(ans,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 1300
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

ll INFTY = 1e14;

class edge{
  public:
  ll to, cost, time;
  edge(ll t, ll c, ll ti){
    to = t;
    cost = c;
    time = ti;
  }
};

class path{
  public:
  ll city, money, time;
  path(ll c, ll m, ll t){
    city = c;
    money = m;
    time = t;
  }

  bool operator >(const class path &another) const{
    return time > another.time;
  }
};

int main(){
  ll N, M, S, tmp1, tmp2, tmp3, tmp4;
  cin >> N >> M >> S;

  vector<vector< class edge> > G(N);
  for(ll i = 0; i < M; i++){
    cin >> tmp1 >> tmp2 >> tmp3 >> tmp4;
    G[tmp1-1].push_back(edge(tmp2-1, tmp3, tmp4));
    G[tmp2-1].push_back(edge(tmp1-1, tmp3, tmp4));
  }

  vector<ll> C, D;
  for(ll i = 0; i < N; i++){
    cin >> tmp1 >> tmp2;
    C.push_back(tmp1);
    D.push_back(tmp2);
  }

  // solve problem
  vector<vector<ll> > dp(N, vector<ll>(50*4*M+1));

  priority_queue<path, vector<path>, greater<path> > path_que;

  for(ll i = 0; i < N; i++){
    for(ll j = 0; j <= 200*M; j++){
      dp[i][j] = INFTY;
    }
  }
  if(S > 200*M){
    S = 200*M;
  }
  path_que.push(path(0, S, 0));
  
  vector<ll> visit_list(N);
  vector<ll> ans_vec(N);
  for(ll i = 0; i < N; i++){
    ans_vec[i] = INFTY;
  }
  ll visited = 0;
  ll ctmp, mtmp, ttmp;
  class path path_tmp(0,0,0);
  while(visited < N && !path_que.empty()){
    path_tmp = path_que.top();
    path_que.pop();
    ctmp = path_tmp.city;
    mtmp = path_tmp.money;
    ttmp = path_tmp.time;
    if(ttmp < dp[ctmp][mtmp]){
      // update time
      dp[path_tmp.city][path_tmp.money] = path_tmp.time;
      ans_vec[ctmp] = min(ans_vec[ctmp], ttmp);
      // update visited
      if(visit_list[path_tmp.city] == 0){
        visit_list[path_tmp.city]= 1;
        visited++;
      }
      // increase money
      if(mtmp != 100*M){
        if(dp[ctmp][min(200*M, mtmp+C[ctmp])] == INFTY){
          path_que.push(path(ctmp, min(200*M, mtmp+C[ctmp]), ttmp+D[ctmp]));
        }
      }
      // move
      for(ll i = 0; i < G[ctmp].size(); i++){
        if(G[ctmp][i].cost <= mtmp){
          if(dp[G[ctmp][i].to][mtmp-G[ctmp][i].cost] == INFTY){
            path_que.push(path(G[ctmp][i].to, mtmp-G[ctmp][i].cost, ttmp+G[ctmp][i].time));
          }
        }
      }
    }
  }

  cerr << "Answer:" << endl;
  for(ll i = 1; i < N; i++){
    cout << ans_vec[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 35544
from itertools import combinations as comb
N,K = map(int,input().split())
a = [int(i) for i in input().split()]
ans = float("INF")

for c in comb(range(1,N),K-1):
    cnt = 0
    color = 0
    mh = a[0]
    for i in range(1,N):
        if i == c[color]:
            cnt += max(mh-a[i]+1,0)
            color += 1
            if color == K-1: break
            mh = max(mh+1,a[i])
        else:
            mh = max(mh,a[i])
    ans = min(cnt ,ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    int len = S.size();

    string rs = S;
    reverse(rs.begin(), rs.end());

    string S_left;
    for(int i=0; i<(len-1)/2; ++i){
        S_left += S[i];
    }
    string S_left_r = S_left;
    reverse( S_left_r.begin(), S_left_r.end() );
    

    string S_right;
    for(int i=(len+3)/2 -1; i<len; ++i){
        S_right += S[i];
    }
    string S_right_r = S_right;
    reverse(S_right_r.begin(), S_right_r.end());


    string ans = "No";
    if(S == rs){
        if( S_left_r == S_left && S_right == S_right_r){
            ans = "Yes";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
# coding : utf-8
s=list(map(lambda c:ord(c)-ord('a'),input()))
k=int(input())
for i in range(len(s)):
    if 26-s[i]<=k and s[i]!=0:
        k-=(26-s[i])
        s[i]=0
s[-1]=(s[-1]+k)%26
for n in s:
    print(chr(ord('a')+n),end='')
print()


Measured memory_bytes: 5444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

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

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

    vector<string> s(n);

    rep(i, n)
    {
        cin >> s[i];

    }

    int ac = 0;
    int t = 0;
    int w = 0;
    int r = 0;

    rep(i, n) {
        if(s[i] == "AC") {
            ac++;
        } else if(s[i] == "WA") {
            w++;
        } else if(s[i] == "TLE") {
            t++;
        } else {
            r++;
        }
    }

    cout << "AC x " << ac << "\n";
    cout << "WA x " << w << "\n";
    cout << "TLE x " << t << "\n";
    cout << "RE x " << r << "\n";
}

Measured memory_bytes: 6436
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
if ((($N % 7) == 0) || (($N % 4) == 0)) {
  printf("Yes\n");
  exit;
}
for($i=4;$i<$N;$i=$i+4) {
  if (($N - $i) % 7 == 0) {
    printf("Yes\n");
    exit;
  }
}
printf("No\n");


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int du[] = { -1,1,0,0 };
int dv[] = { 0,0,-1,1 };

int main() {

    int uMax, vMax;
    cin >> uMax >> vMax;
    vector<vector<bool>> isWhite(uMax);
    int countWhite = 0;
    for (int u = 0; u < uMax; u++) {
        isWhite[u] = vector<bool>(vMax);
        string s;
        cin >> s;
        for (int v = 0; v < vMax; v++) {
            isWhite[u][v] = (s[v] == '.');
            if (isWhite[u][v]) countWhite++;
        }
    }

    // BFSで最短距離を求める。
    vector<vector<int>> minDis(uMax);
    for (int u = 0; u < uMax; u++) minDis[u] = vector<int>(vMax, -1);
    queue<pair<int, int>> todo;

    // スタート代入
    todo.push(make_pair(0, 0));
    minDis[0][0] = 1;
    bool finished = false;
    while (!todo.empty() && !finished) {
        auto t = todo.front();
        todo.pop();
        int u = t.first, v = t.second;
        for (int k = 0; k < 4; k++) {
            int u2 = u + du[k], v2 = v + dv[k];
            if (u2 < 0 || u2 >= uMax || v2 < 0 || v2 >= vMax) continue;
            if (isWhite[u2][v2] && minDis[u2][v2] == -1) {
                todo.push(make_pair(u2, v2));
                minDis[u2][v2] = minDis[u][v] + 1;
                if (u2 == uMax - 1 && v2 == vMax - 1) finished = true;
            }
        }
    }

    if (minDis[uMax - 1][vMax - 1] == -1) {
        cout << -1 << endl;
    }
    else {
        cout << (countWhite - minDis[uMax - 1][vMax - 1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)

max = h.max
arr = Array.new(n) { Array.new(max) { 0 } }
h.each_with_index { |e, idx| arr[idx].fill(1, 0...e) }

puts arr.transpose.map { |e| e.join.squeeze.count('1') }.inject(0, :+)

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>

int solve(int *arr, int n, int k)
{
	int dp[n+1];

	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	// exit(0);
	for(int i=2;i<n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=1;j<=k && i-j>=0 ;j++)
		{
			dp[i]=min(dp[i], abs(arr[i]-arr[i-j])+ dp[i-j]);
		}
	}
	return dp[n-1];
}

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

    ll n,x,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
	cin>>arr[i];
}
int ans=solve(arr,n,k);
cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <numeric>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int ans[11];
int f(string s){
  int n=s.length();
  rep(i,s.length()){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      ans[i]=1;
    }
  }
  for(int i=1;i<n;i++){
    if(ans[i] && ans[i-1]){
      ans[i]+=ans[i-1];
    }
  }
  int max=0;
  rep(i,n){
if(max<ans[i])max=ans[i];
  }
  return max;
}
int main(){
  string s;cin>>s;
  int n=s.length();
  rep(i,n)ans[i]=0;
  cout<<f(s)<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print(700 + 100*S.count("o"))

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

int N;
string s;
int r = 0;
int b = 0;

int main() {
  cin >> N >> s;
  for( int i = 0; i < N; i++ ) {
    if( s.at(i) == 'R' ) {
      r++;
    }
    if( s.at(i) == 'B' ) {
      b++;
    }
  }
  
  if( r > b ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
    int N,T;cin >> N >> T;
    int res = 1001;
    rep(i,N){
        int c,t;cin >> c >> t;
        if(t<=T){
            res = min(res,c);
        }
    }
    if(res == 1001){
        cout << "TLE" << endl;
    }else{
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;

ll dp[2000];

ll n, x;

/*
ll make_dp(vector<ll> &a){
    // init
    int index = distance(a.begin(), min_element(a.begin(), a.end()));
    cout << index << endl;
    for (int i = 0; i < n - index; i++){
        dp[i] = a[i + index];
    }
    for (int i = n-index; i < n; i++){
        dp[i] = a[i - (n - index)];
    }
    for (int i = 0; i < n; i++){
        cout << dp[i] << ", ";
    }
    cout << endl;
    for (int j = 0; j < n; j++){
        for (int i = 0; i < n-1; i++){
            dp[i+1] = min(dp[i] + x, dp[i+1]);
        }
        dp[0] = min(dp[n-1] + x, dp[0]);
    }

    ll sum = 0;
    for (int i = 0; i < n ; i++){
        sum += dp[i];
        cout << dp[i] << ", ";
    }
    cout << endl;

    return sum;
}
*/

int main(){
    cin >> n >> x;
    vector<ll> a(n);

    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll ans = INF;
    for (int i = 0; i < n; i++){
        dp[i] = a[i];
    }
    for (int i = 0; i < n; i++){
        ll can = i * x;
        for (int j = 0; j < n; j++){
            dp[j] = min(dp[j], a[(j - i + n) % n]);
        }
        for (int k = 0; k < n; k++){
            can += dp[k];
        }
        ans = min(ans, can);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a = input()
b = 0
if a[0] == "A":
    for i in range(1, len(a)):
        if a[i] == "C" and (1 < i < len(a) - 1):
            b += 1
        else:
            if a[i] != a[i].lower():
                print("WA")
                exit()
if b == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
def gcd(a, b):
    big = max(a, b)
    small = min(a, b)
    
    r = small
    while r != 0:
        r = big % small
        big = small
        small = r
    
    return big

def divisor(n):
    div = []
    for i in range(1, n + 1):
        if n % i == 0:
            div.append(i)
    
    return div

a, b, k = map(int, input().split())
k -= 1

num = gcd(a, b)
div = divisor(num)

div.sort(reverse=True)

print(div[k])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll nCr(int n)
{
	if(n<2)return 0;
	return (1LL*n*(n-1))/2;
} 

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n,c=0;
	unordered_map<int,int> f;
	unordered_set<int> st;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];f[v[i]]++;st.insert(v[i]);
		if(f[v[i]]==2)c++;
	}
	ll ans = 0,tp;
	for(int x: st)
		ans += nCr(f[x]);
			
	for(int i=0;i<n;i++)
	{
		tp = ans;
		ans = ans - ( nCr(f[v[i]]) ) + (nCr(f[v[i]]-1));
		cout<<ans<<'\n';
		ans = tp;
	}
}


Measured memory_bytes: 14352
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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

    int N, K;

    cin >> N >> K;

    vector<long long int> a(N);

    vector<long long int> vSM(100001);
    vector<long long int> vZR(100001);

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        vSM[i + 1] = vSM[i] + a[i];
        vZR[i + 1] = vZR[i] + max(a[i], 0LL);
    }

    long long int score = 0LL;
    for (int i = 0; i < N - K + 1; i++)
    {
        int l = i;
        int r = i + K;

        // 最後に塗るところ以外
        long long int pre = vZR[l] + (vZR[N] - vZR[r]);

        // 最後に白く塗る(0LL)、黒く塗る(vSM[r] - vSM[l])
        score = max(score, pre + max(vSM[r] - vSM[l], 0LL));
    }

    cout << score << endl;
    return 0;
}


Measured memory_bytes: 2688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int main(){
	string str;

	cin >> str;
	reverse(str.begin(), str.end());
	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int a,b,c,k;
 cin>>a>>b>>c>>k;
 long long int ans=0;
 ans+=min(k,a);
 k-=min(k,a);
 if(k>0)
 {
 	k-=min(k,b);
 }
 if(k>0)
 {
 	ans-=min(k,c);
 	k=0;
 }
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var count = new int[alphabet.Length];
        foreach (var c in CRL())
        {
            count[(int) c - (int) 'a']++;
        }

        if (count.Any(x => x.IsEven() == false))
        {
            CWL("No");
        }
        else
        {
            CWL("Yes");
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this double d) => (int) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

Measured memory_bytes: 13268
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	string s;
	cin >> s;
	sort(all(s));
	cout << (s == "abc" ? "Yes" : "No") << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


void solve()
{
    int A, B; cin >> A >> B;
    if(B % A == 0) cout << A + B << endl;
    else cout << B - A << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
import itertools

l = list(input().split())
n = int(l[0])
total = int(l[1])

exist = False
for x, y in itertools.product(range(0, n + 1), range(0, n + 1)):
    z = n - x - y
    if 0 <= z and  (x + y + z == n) and ((x * 10000 + y * 5000 + z * 1000) == total):
        print("{} {} {}".format(x, y, z))
        exist = True
        break

if not exist:
    print("-1 -1 -1")

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;

int n, a[N];
int last;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++ )
	{
		scanf("%d", a + i);
		if (a[i] == last + 1) last ++ ;
	}
	
	if (!last) puts("-1");
	else printf("%d\n", n - last);
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

int gcd(int a, int b) {
	if (b == 0)return a;

	return gcd(b, a%b);
}

signed main(void) {
	int A,B;
	cin >> A >>B;
	print(A*B / gcd(A, B));
}

Measured memory_bytes: 256
a = input()
a_num = int(len(a))
a_list = [i for i in a]
b = 0
for j in range(0,a_num,2):
     try:   
      if a_list[j] == "L" or a_list[j+1] == "R":
        print("No")
        b = 1
        break
     except:
         break
if b == 0:
    print("Yes")

Measured memory_bytes: 3060
N=int(input())

flag=False
def chk(h,n,w,N):
    val1=4*h*n*w
    val2=N*(n*w+h*w+h*n)
    if val1==val2:
        return True
    else:
        return False
def calc(h,n,N):
    if (4*h*n-(n+h)*N)==0:
        return -1
    val=(N*h*n)//(4*h*n-(n+h)*N)
    return val
for h in range(1,3501):
    for n in range(1,3501):
        w=calc(h,n,N)
        if w<=0:
            continue
        else:
            if chk(h,n,w,N):
                ans=[h,n,w]
                print(*ans)
                exit()


Measured memory_bytes: 41324
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    A = sorted(list(map(lambda x: A[x] - (x + 1), range(n))))
    b = A[n // 2]
    print(sum(list(map(lambda x: abs(x - b), A))))


if __name__ == '__main__':
    main()


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

int main() {
	// your code goes here
	long long n;
	cin>>n;
	long long a[n];
	for(int i = 0;i<n;i++) {
	    cin>>a[i];
	}
	
	long long dp[n];
	
	dp[0] = 0;
	for(int i = 1;i<n;i++) {
	    dp[i] = INT_MAX;
	    for(int j = i-2;j<i;j++) {
	        dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
	    }
	}
	
	cout<<dp[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		ll n; cin>>n;
		ll a[n],s=0;
		for (ll i = 0; i < n; ++i)
		{
			/* code */
			cin>>a[i];
			s=s^a[i];
		}
		for (ll i = 0; i < n; ++i)
		{
			/* code */
			ll p=s^a[i];
			cout<<p<<space;
		}
	}

	signed main()
	{

	fast;
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 5168
h, w = map(int, input().split())

a = []
for i in range(h):
    a += [input()]

[print('#', end='') for i in range(w + 2)]
print()

for i in range(h):
    print('#', end='')
    print(a[i], end='')
    print('#')

[print('#', end='') for i in range(w + 2)]
print()


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			for(int i = 1; i <= n ; i++){
				for(int j = 1; j <=i ; j++){
					for(int k = 1; k <=j ; k++){
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	}
}

Measured memory_bytes: 25036
n = gets.to_i
red = []
blue = []
n.times { red << gets.split.map(&:to_i) }
n.times { blue << gets.split.map(&:to_i) }
red.sort! { |x, y| x[1] <=> y[1] }.reverse!
blue.sort!
ans = 0
blue.each { |x|
  pair = red.find { |y| y[0] < x[0] and y[1] < x[1] }
  unless pair == nil
    ans += 1
    red.delete(pair)
  end
}
p ans

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    vector<int> x(11, 0);
    int r, D, x2000; cin >> r >> D >> x2000;
    x[0] = x2000;
    for (int i = 1; i <= 10; i++) {
        x[i] = r * x[i-1] - D;
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 256
n=int(input()) #Nを入力
lista=input().split() #Aを入力
p=int(lista[0])#p最小値
q=int(lista[0])#q最大値
for i in range(1,n):
    k=int(lista[i])
    if k<=p:
        p=k
    elif k>=q:
        q=k
print(int(q-p))

Measured memory_bytes: 9172
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n,x = map(int,input().split())
  m = [int(input()) for _ in range(n)]
  su_ = sum(m)
  cnt = len(m)
  m_so = sorted(m)
  
  re_ = x - su_ # remaining
  
  cnt += re_ // m_so[0]
  
  print(cnt)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--; c--; d--;

    string s;
    cin >> s;

    int r = 0;
    if (c > d) {
        int t = 0;
        for (int i = b; i <= d; i++) {
            if (s[i] != '#' && s[i - 1] != '#' && s[i + 1] != '#') {
                t = 1;
                break;
            }
        }
        if (t == 0) r = 1;
    }
    for (int j = 0; j < 2; j++) {
        if (r) break;
        for (int i = a; i < c; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                r = 1;
                break;
            }
        }
        a = b; c = d;
    }

    cout << (r == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
#include<stdlib.h>
#define MAX 100001

main()
{
  short *A, change, x;
  int i, j, r, n, p=0, kakko;

  scanf("%d", &n);
  A = malloc(sizeof(short)*n + 1);

  for(i=0; i<n; i++)
    {
      scanf("%hu", &A[i]);
    }

  r = i-1;
  x = A[r];
  i = p - 1;
  for(j=p; j<r; j++)
    {
      if(A[j] <= x)
	{
	  i = i + 1;
	  change = A[j];
	  A[j] = A[i];
	  A[i] = change;
	}
    }
  change = A[r];
  A[r] = A[i+1];
  A[i+1] = change;
  kakko = i+1;

  for(i=0; i<n; i++)
    {
      if(i == kakko)
	{
	  printf("[%d] ", A[i]);
	  continue;
	}

      printf("%d", A[i]);
      if(i != n-1)
	{
	  printf(" ");
	}
    }
  printf("\n");

  free(A);
  return 0;
}

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

int main() {
  int a;
  int b;
  
  cin >> a >> b;
  
  if( (a % 2) && (b % 2))
  {
    cout << "Odd" <<endl;
  }
  else
  {
    cout << "Even" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dp0[101][4],dp1[101][4],k,n;
string s;
int main(void){
    cin>>s>>k;
    dp1[0][0]=1;
    for(int i=1;i<=s.size();i++){
        if(i>1)dp0[i-1][0]=1;
        n=s[i-1]-'0';
        //cout<<n<<"W"<<endl;
        if(n!=0){
            for(int j=0;j<3;j++){
                dp1[i][j+1]=dp1[i-1][j];
                dp0[i][j+1]=(n-1)*dp1[i-1][j]+9*dp0[i-1][j]+dp0[i-1][j+1]+dp1[i-1][j+1];
            }
        //cout<<dp0[1][0]<<endl;    
        }
        else{
            for(int j=1;j<=3;j++){
                dp1[i][j]=dp1[i-1][j];
                dp0[i][j]=9*dp0[i-1][j-1]+dp0[i-1][j];
            }
            //cout<<dp0[1][0]<<endl;
        }
    }
    cout<<dp0[s.size()][k]+dp1[s.size()][k]<<endl;
}


Measured memory_bytes: 256
import math

A, B, N = map(int, input().split())
max = 0
temp = 0
bk_temp = 0

if B <= N:
    max = math.floor(A * (B - 1) / B) - (A * math.floor((B - 1) / B))
else:
    # for i in range(1, N + 1):
    #     temp = math.floor(A*i/B) - (A * math.floor(i/B))
    #     print(str(i) + ' ' + str(temp))
    #     if bk_temp > temp:
    #         max = bk_temp
    #         break
    #     if max < temp:
    #         max = temp
    #     bk_temp = temp
    max = math.floor(A * N / B) - (A * math.floor((N) / B))

print(max)

Measured memory_bytes: 9016
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,i,j,f,sum;
int main(){
    cin>>n;
    vector<int>a(n+1),b(n+1,0);
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=n;i>0;i--){
        for(f=0,j=i;j<=n;j+=i){
            f^=b[j];
        }
        if(a[i]==0&&f==1||a[i]==1&&f==0){
            b[i]=1;
        }
    }
    for(i=1;i<=n;i++)sum+=b[i];
    cout<<sum<<endl;
    for(i=1;i<=n;i++)if(b[i])cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 2432
#!/usr/bin/env python3

def main():
    *I, = map(int, open(0).read().split())
    N = I[0]
    K = I[1]
    h = I[2:]

    cnt=0
    for i in range(0, N):
        if h[i] >= K:
            cnt += 1
    print(cnt)

main()

Measured memory_bytes: 11908
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    rep(i, N - M + 1) {
        rep(j, N - M + 1) {
            bool flag = true;
            rep(k, M) {
                rep(l, M) {
                    if (B[k][l] != A[k + i][l + j]) {
                        flag = false;
                        break;
                    }
                }
                if (!flag) break;
            }
            if (flag) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = next().map { it - 'a' }
    val T = next().map { it - 'a' }
    val sa = IntArray(26)
    val ta = IntArray(26)
    for (n in 0 until S.size) {
        if (sa[S[n]] == 0) sa[S[n]] = T[n]
        else if (sa[S[n]] != T[n]) {
            println("No"); return
        }
        if (ta[T[n]] == 0) ta[T[n]] = S[n]
        else if (ta[T[n]] != S[n]) {
            println("No"); return
        }
    }
    println("Yes")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 38980
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int n;
  cin >> n;
  long long limit = (long long)pow(10, 18);
  long long cur = 1;
  long long x;
  bool over = false;
  for(int i = 0; i < n; i++) {
    cin >> x;

    if(x == 0) {
      cout << 0 << endl;
      return 0;
    }

    if(over == true) {
      continue;
    }

    if(limit / x >= cur) {
      cur *= x;
    }
    else {
      over = true;
    }
  }

  if(over) {
    cout << -1 << endl;
  }
  else {
    cout << cur << endl;
  }

  return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000, MOD = 1000000007;

int freq[26 + 2];
char S[MAXN + 2];

int main() {
	int N;
	cin >> N >> S;
	for(int i = 0; i < N; i++)
		freq[S[i] - 'a']++;
	int ans = 1;
	for(int i = 0; i < 26; i++)
		ans = (ll)ans * (freq[i] + 1) % MOD;
	ans = (ans + MOD - 1) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 384
//???????????????????????????????????????????????¢?????????
#include<stdio.h>

int main(void){
    int h, w;
    int i,j;
    
    while(1){
        scanf("%d", &h);
        scanf("%d", &w);
        
        if(h == 0) break;
        
        for(i = 0; i < h; i++){
            for(j =0; j < w; j++)
                putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 572
a,s,d,f,g=map(int,input().split())
if(a==0):
    print(1)
    exit()
if(s==0):
    print(2)
    exit()
if(d==0):
    print(3)
    exit()
if(f==0):
    print(4)
    exit()
if(g==0):
    print(5)
    exit()


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

int main(void){
    string s,t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    ll a,b,k;
    cin >> a >> b >> k;

    if(a+b<=k)  puts("0 0");
    else if(a<=k){
        cout << 0 << " " << b-(k-a) << endl;
    }else{
        cout << a-k << " " << b << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

ll INF = 10000000;
ll mod = 1000000007;//10^9+7


//番号ズレ注意！！
int main() {
    ll N, A[5];
    cin >> N;
    REP(i, 5) { cin >> A[i]; }
    ll RLS = 0;
    REP(i, 5) {
        if (A[i] < A[RLS]) { RLS = i; }
    }
    printAns((N-1) / A[RLS] + 5);
}

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

int main(){
  string O,E;
  cin >> O >> E;
  for(int i=0;i<E.length();i++){
    cout << O[i] << E[i];
  }
  if(O.length()-E.length()==1)cout << O[O.length()-1];
}



Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

void solve(long long N, long long K, std::vector<long long> x,
           std::vector<long long> y) {
  ll ans = INF;
  rep(xl, 0, N) {
    rep(xr, 0, N) {
      rep(yu, 0, N) {
        rep(yd, 0, N) {
          ll xld = x[xl];
          ll yld = y[yd];
          ll xru = x[xr];
          ll yru = y[yu];

          if (xld > xru) {
            continue;
          }

          if (yld > yru) {
            continue;
          }

          ll cnt = 0;
          rep(i, 0, N) {
            if (xld <= x[i] && x[i] <= xru && yld <= y[i] && y[i] <= yru) {
              cnt++;
            }
          }

          if (cnt >= K) {
            ans = min(ans, (xld - xru) * (yld - yru));
          }
        }
      }
    }
  }
  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, K, std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int alpha[26];

int main(){
	string s;
	cin >> s;
	rep(i,s.length())alpha[s[i]-'a']++;
	rep(i,26){
		if(alpha[i]<2)
			continue;
		else{
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define FO(n) for (ll i = 0; i < n; i++)
#define endl "\n"
const long long int M = 10e9 + 7;
void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    FO(n)
    cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < a[i - 1])
        {
            ans += llabs(a[i] - a[i - 1]);
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
}

int main()
{
    faster;
    // int t;
    //cin >> t;
    //while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n;
    cin >> n;
    if(n&1 || n == 0){
        puts("0");
    }else {
        ll m = n/10, ans = 0;
        while(m){
            ans += m;
            m /= 5;
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

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

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

  int n;
  cin >> n;

  int ans = 0;

  ans = 800 * n;
  ans = ans - (n / 15) * 200;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,K=gets.chomp.split.map(&:to_i)
if (N-1)*(N-2)/2 < K
  puts -1
else
  puts (N-1) + ((N-1)*(N-2)/2 - K)
  2.upto(N) do |i|
    printf("1 %d\n",i)
  end

  cnt = (N-1)*(N-2)/2 - K
  2.upto(N) do |i|
    (i+1).upto(N) do |j|
      if cnt == 0
        exit
      end
      printf("%d %d\n",i, j)
      cnt -= 1
    end
  end

end

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

int dp[201][201][2];

int main() {
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    for(int j=0; j<s.size(); j++) {
      dp[i][j][0]=1<<29;
      dp[i][j][1]=-(1<<29);
    }
    if(isdigit(s[i])) dp[i][i][0]=dp[i][i][1]=s[i]-'0';
  }
  for(int i=1; i<s.size(); i++) {
    for(int j=0; j<s.size()-i; j++) {
      if(s[j]=='(') {
        dp[j][j+i][0]=min(dp[j][j+i][0],dp[j+1][j+i][0]);
        dp[j][j+i][1]=max(dp[j][j+i][1],dp[j+1][j+i][1]);
      }
      if(s[j+i]==')') {
        dp[j][j+i][0]=min(dp[j][j+i][0],dp[j][j+i-1][0]);
        dp[j][j+i][1]=max(dp[j][j+i][1],dp[j][j+i-1][1]);
      }
    }
    for(int j=0; j<s.size()-i; j++) {
      if(s[j]=='+'||s[j]=='-'||s[j+i]=='+'||s[j+i]=='-') continue;
      for(int k=j+1; k<=j+i-1; k++) {
        if((j+2<=k&&s[k-2]=='(')||(k<=j+i-2&&s[k+2]==')')) continue;
        if(s[k]=='+') {
          for(int x=0; x<2; x++) {
            for(int y=0; y<2; y++) {
              if(abs(dp[j][k-1][x])>=(1<<29)||abs(dp[k+1][j+i][y])>=(1<<29)) continue;
              dp[j][j+i][0]=min(dp[j][j+i][0],dp[j][k-1][x]+dp[k+1][j+i][y]);
            }
          }
          for(int x=0; x<2; x++) {
            for(int y=0; y<2; y++) {
              if(abs(dp[j][k-1][x])>=(1<<29)||abs(dp[k+1][j+i][y])>=(1<<29)) continue;
              dp[j][j+i][1]=max(dp[j][j+i][1],dp[j][k-1][x]+dp[k+1][j+i][y]);
            }
          }
        } else if(s[k]=='-') {
          for(int x=0; x<2; x++) {
            for(int y=0; y<2; y++) {
              if(abs(dp[j][k-1][x])>=(1<<29)||abs(dp[k+1][j+i][y])>=(1<<29)) continue;
              dp[j][j+i][0]=min(dp[j][j+i][0],dp[j][k-1][x]-dp[k+1][j+i][y]);
            }
          }
          for(int x=0; x<2; x++) {
            for(int y=0; y<2; y++) {
              if(abs(dp[j][k-1][x])>=(1<<29)||abs(dp[k+1][j+i][y])>=(1<<29)) continue;
              dp[j][j+i][1]=max(dp[j][j+i][1],dp[j][k-1][x]-dp[k+1][j+i][y]);
            }
          }
        }
      }
    }
  }
  cout << dp[0][s.size()-1][1] << endl;
  return 0;
}

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

int main(){
    int n,a,b,c,x;
    int rand[100];
    while(1){
        cin >> n >> a >> b >> c >> x;
        if(n==0) break;
        for(int i=0; i<n; i++){
            cin >> rand[i];
        }

        int idx=0;
        int frame;
        for(frame=0; frame<=10000; frame++){
            if(rand[idx]==x){
                idx++;
                if(idx==n){
                    break;
                }
            }
            x = (a*x + b)%c;
        }

        if(idx==n){
            cout << frame << endl;
        }else{
            cout << -1 << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 2988
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  int out=700;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o'){
      out+=100;
    }
  }
  cout<<out<<endl;
  return 0;
}


Measured memory_bytes: 256