akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    vector<int> ans(S + 1, 0);
    ans[0] = 1;

    REP(i, 0, S) {
        vector<int> next(S + 1, 0);
        bool changed = false;
        for (int j = S; j >= 3; j--) {
            for (int k = 0; k + j <= S; k++) {
                next[k + j] += ans[k];
                next[k + j] %= MOD;
                // cout << k + j << " : " << next[k + j] << endl;
                changed = true;
            }
        }
        next[S] += ans[S];
        next[S] %= MOD;
        if (!changed) {
            // cout << "not changed " << endl;
            break;
        }
        ans = next;
        // cout << "------- next" << endl;
        // for (auto a : ans) cout << a << " ";
        // cout << endl;
        // cout << "------- next" << endl;
    }
    cout << ans[S] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

#define MAX 100000

int n, k;
double T[MAX];

int check(double p){
  int i = 0, j;
  double s;
  for( j = 0 ; j < k ; j++){
    s = 0.0;
    while( s + T[i] <= p){
      s += T[i];
      i++;
      if( i == n ) return n;
    }
  }
  return i;
}

int solve(){
  double left = 0.0;
  double right = 100000*10000;
  double mid;
  int v;

  while( right - left > 1){
    mid = ( left + right ) / 2;
    v = check(mid);
    if( v >= n ) right = mid;
    else left = mid;
  }
  return right;
}

int main(){
  int i;
  double ans;
  scanf("%d%d", &n, &k);
  for( i = 0 ; i < n ; i++) scanf("%lf", &T[i]);
  ans = solve();
  printf("%d\n", (int)ans);

  return 0;
}



Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    cin >> a >> b;
    string ans = "Odd";
    if ((a*b)%2==0) ans = "Even";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
n,k = gets.split.map(&:to_i)

ans = 0
li = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]
idx = -1
li.each_with_index do |v,i|
  if v >= k
    idx = i
    break
  end
end

nn = n
if n >= k
  nn = k - 1
end

nn.times do |i|
  z = i + 1
  cnt = 0
  (1..idx+1).each do |ii|
    z *= 2
    if z >= k
      cnt = ii
      break
    end
  end
  hh = 1/n.to_f
  jj = 1.to_f/(2**cnt).to_f
  ans += hh * jj
end

if n != nn
  ans += (n-k+1) / n.to_f
end

puts ans


Measured memory_bytes: 1788
"""
AtCoder Beginner Contest 051
B - Sum of Three Integers
"""

if __name__ == "__main__":
    K, S = map(int, input().split())

    ans = 0
    A = [i for i in range(K+1)]
    for x in A:
        for y in A:
            if x + y > S or S - (x + y) > K:
                continue
            ans += 1

    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a+b>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//ここまでで習っていないので、配列の値の削除pop_back()は使用しないで解くこととする
int main() {
	int H , W;
  	cin >> H >> W;
    //列と行のそれぞれの数値を読み込む
  	vector<vector<char>> hyo(H, vector<char>(W));
  	for(int i = 0; i < H; i++){
    	for(int j = 0; j < W; j++){
        	cin >> hyo.at(i).at(j);
        }
    }
    //列がすべて'.'の数を数えるためにcount変数を用意する
    int count = 0;
    for(int i = 0; i < W; i++){
        //列がすべて'.'かどうかを調べるためにtate_check変数を用意する
      	bool tate_check = true;
        //各行のi - count 列目がすべて'.'がかどうかを調べる  
        for(int j = 0; j < H; j++){
            //もしi - count列目で'.'ではない値があればtate_checkをfalseにしてループを抜ける
           	if(hyo.at(j).at(i - count) != '.'){
               	tate_check = false;
               	break;
            }
        }
        // i - count列目がすべて'.'だったらtate_check == trueなので
        // i - count列目以降の右側の値をひとつずつ左にずらしていく
        if(tate_check == true){
            for(int k = 0; k < H; k++){
               	for(int l = i - count; l < W - 1; l++){
                    hyo.at(k).at(l) = hyo.at(k).at(l + 1);
                }
            }
            //count変数を1増やす
            count++;
        }
    }
  	for(int i = 0; i < H; i++){
        //行がすべて'.'かどうかを調べるためにyoko_check変数を用意する
        bool yoko_check = true;
    	for(int j = 0; j < W ; j++){
            //もしi行目で'.'ではない値があればyoko_checkをfalseにしてループを抜ける
        	if(hyo.at(i).at(j) != '.'){
              	yoko_check = false;
            	break;
            }
        }
        //もしi行目のyoko_check変数がfalseだったらi行目をw - count列まで出力する
        //つまり列がすべて'.'だったcount列分の右側は出力しないし
        //yoko_check変数がtrueだったらそもそもi行目自体出力しない
      	if(yoko_check == false){
        	for(int j = 0 ; j < W - count; j++){
            	cout << hyo.at(i).at(j);
            }
            //次の行の出力に向けて改行する
          	cout << endl;
        }
    }
}

Measured memory_bytes: 256
n = int(input())

a = []
max_a = 0
next_a = 0
count_max_a = 0
for _ in range(n):
    v = int(input())
    a.append(v)
    if (max_a < v):
        next_a = max_a
        max_a = v
        count_max_a = 1
    elif (max_a == v):
        count_max_a += 1
    elif (next_a < v):
        next_a = v

for v in a:
    if v != max_a:
        print(max_a)
    else:
        if count_max_a == 1:
            print(next_a)
        else:
            print(max_a)


Measured memory_bytes: 12532
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
int n,h,w;
int cnt=0;
cin >>n>>h>>w;
rep(i,n){
int a,b;
cin >>a>>b;
if (a>=h&&b>=w)
	cnt++;
}
cout<<cnt;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    if(n < 10) {
        r += 100 * (10 - n);
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A, B, K;
  cin >> A >> B >> K;
  
  int count = 0;
  int kouyaku = 100;
  for(int i = 0; i < 100; ++i){
    if( A%kouyaku == 0 && B%kouyaku == 0) ++count;
     if(count == K) break;
    --kouyaku;
  } 
    cout << kouyaku << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 1e5+10;
int n;
int ans[N][3];

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 3; ++j) {
      int v;
      cin >> v;
      for (int k = 0; k < 3; ++k) {
        if (k == j) continue;
        ans[i][j] = max(ans[i][j], ans[i-1][k] + v);
      }
    }
  }
  cout << *max_element(ans[n], ans[n]+3) << nl;

  return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>

#define M 1046527
#define NIL (-1)
#define L 14

using namespace std;

char H[M][L];

int getChar(char ch) {
    switch(ch) {
        case 'A':return 1;
        case 'C':return 2;
        case 'G':return 3;
        case 'T':return 4;
    }
    return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1;
    for(int i=0; i<strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {return key % M;}
int h2(int key) {return 1 + (key % (M - 1));}

bool Find(char str[]) {
    long long key, h;
    key = getKey(str);
    for(int i=0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(!strcmp(H[h],str))return true;
        else if(strlen(H[h])==0)return false;
    }
}

void Insert(char str[]) {
    long long key, h;
    key = getKey(str);
    for(int i=0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(strlen(H[h])==0) {
            strcpy(H[h],str);
            return;
        } else if(!strcmp(H[h], str))return;
    }
}

int main() {

    int n, h;
    char str[L], com[9];
    for(int i = 0; i<M; i++)H[i][0] = '\0';
    cin>>n;
    while(n--) {
        scanf("%s %s", com, str);

        if(!strcmp(com, "find")) {
            Find(str)?printf("yes\n"):printf("no\n");
        } else if(!strcmp(com, "insert"))Insert(str);
    }
    return 0;
}



Measured memory_bytes: 17476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<int> v(n+1);
  rep(i,n+1) {
    if (i == 0) continue;
    cin >> v[i];
  } 
  vector<int> ans(n+1);

  int len = v.size();
  int cnt = 0;
  for (int i = len-1;i > 0;i--){
    if (i*2 > len-1){
      ans[i] = v[i];
      if (ans[i] == 1) cnt++;
      //cout << i << ":" << "skip" << endl;
    }
    else{
      //cout << i << ":" << "do" << endl;
      int now = i + i;
      int cnow = i;
      int sum = 0;
      while(now <= len-1){
        sum += ans[now];
        now += cnow; 
      }
      if (sum%2 == 1 && v[cnow] == 0) ans[cnow] = 1,cnt++;
      else if (sum%2 == 1 && v[cnow] == 1) ans[cnow] = 0;
      else if (sum%2 == 0 && v[cnow] == 0) ans[cnow] = 0;
      else ans[cnow] = 1,cnt++; 
    }
  }
  cout << cnt << endl;
  if (cnt > 0){
    rep(i,n+1){
      if (i == 0) continue;
      if (ans[i] == 1){
        cout << i << " ";
      }
    }
    cout << endl;
  }


    
  return 0;
}


Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, A[110]; 
	cin >> N; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	for(int i = 0; i < N; i++){
		if(A[i] % 2) continue; 
		if((A[i] % 3) && (A[i] % 5)){
			cout << "DENIED" << endl; return 0; 
		}
	}
	cout << "APPROVED" << endl; 
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int ketawa(int i) {
    if (i < 10) return i;
    return i % 10 + ketawa(i / 10);
}

void test(int k) {
    FOR(i, 1, k) {
        cout << i << ":" << (double) i / ketawa(i) << endl;
    }
}


double sunuke(string n) {
    int t = stoul(n);
    return (double) t / ketawa(t);
}

int f(int n) {
    if (n < 10) return n;

    string str = to_string(n);
    int keta = str.size();

    double res = INF;
    string ans;

    FOR(i, str[0] - '0', 9) {
        if (keta <= 2) {
            string t = to_string(i) + '9';
            if (sunuke(t) < res) {
                ans = t;
                res = sunuke(t);
            }
            continue;
        }
        FOR(j, str[1] - '0', 9) {
            if (keta <= 3) {
                string t = to_string(i) + to_string(j) + '9';
                if (sunuke(t) < res) {
                    ans = t;
                    res = sunuke(t);
                }
                continue;
            }
            FOR(k, str[2] - '0', 9) {
                string t = to_string(i) + to_string(j) + to_string(k);
                REP(l, keta - 3) {
                    t += '9';
                }
                if (sunuke(t) < res) {
                    ans = t;
                    res = sunuke(t);
                }
            }
        }
    }
    return stoul(ans);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int K;
    cin >> K;

    int cur = 0;
    while (K--) {
        cur = f(cur + 1);
        cout << cur << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


void oneCase () {
   int n, k, r, p, s;
   cin >> n >> k >> r >> s >> p;
   string ml;
   cin >> ml;


   ll ans = 0;
   for (int pos = 0; pos < n; ++pos) {
       if (ml[pos] == 'r') {
           if (pos < k || ml[pos - k] != 'R') {
               ml[pos] = 'R';
               ans += p;
           }
       } else if (ml[pos] == 'p') {
           if (pos < k || ml[pos - k] != 'P') {
               ml[pos] = 'P';
               ans += s;
           }
       } else {
           if (pos < k || ml[pos - k] != 'S') {
               ml[pos] = 'S';
               ans += r;
           }
       }
   }
   cout << ans << "\n";
}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

#define INF 1LL << 50 
using namespace std;


void bs(vector<long long>& v, long long x, long long& low, long long& upp) {
	// find low: number that is smaller than x
	if (x < v[0]) {
		low = -INF;	
	} else {
		int l = 0, r = v.size() - 1;
		while (l + 1 < r) {
			int mid = l + (r - l) / 2;
			if (v[mid] > x)
				r = mid;
			else 
				l = mid;
		}
		if (v[r] <= x) {
			low = v[r];	
		} else {
			low = v[l];
		}			
	}
	
	if (x > v.back()) {
		upp = INF;	
	} else {
		int l = 0, r = v.size() - 1;
		while (l + 1 < r) {
			int mid = l + (r - l) / 2;
			if (v[mid] > x)
				r = mid;
			else 
				l = mid;
		}
		if (v[l] >= x) {
			upp = v[l];	
		} else {
			upp = v[r];
		}			
	}
}

long long solve(vector<long long>& s, vector<long long>& t, long long x) {
	long long ls, us;
	bs(s, x, ls, us);
	long long lt, ut;
	bs(t, x, lt, ut);
	//cout << x << ":  "<< ls << " " << us << " " << lt << " " << ut<<endl;
	long long ans;
	ans = x - min(ls, lt);
	ans = min(ans, max(us, ut) - x);
	ans = min(ans, ut - ls + min(x - ls, ut - x));
	ans = min(ans, us - lt + min(us - x, x - lt));
	return ans;
}

int main()
{
	int a, b, q;
	cin >> a >> b >> q;//cout<<q<<endl;
	vector<long long> s(a);
	vector<long long> t(b);
	for (int i = 0; i < a; ++i) {
		cin >> s[i];	
	}
	for (int i = 0; i < b; ++i) {
		cin >> t[i];	
	}
	long long x = 0;
	for (int i = 0; i < q; ++i) {		
		cin >> x;
		//cout <<"x = "<< x<<endl;
		cout << solve(s, t, x)<<endl;	
	}
	//cout << solve(s, t, 2LL)<<endl;	
	//cout << solve(s, t, 9999999999LL)<<endl;	
	///cout << solve(s, t, 5000000000LL)<<endl;	
	return 0;
}

Measured memory_bytes: 2944
#include "iostream"
#include "string"
#include "algorithm"
#include "cmath"
#define eps 10e-10
using namespace std;
typedef struct crop
{
	string name;
	double eff;

	static bool comp(const crop& l, const crop& r)
	{
		if(abs(l.eff-r.eff)>eps) return l.eff>r.eff;
		return l.name<r.name;
	}
}crop;


int main(void)
{
	int n;
	while (cin>>n,n) {
		crop in[n];
		for (int i = 0; i < n; i++) {
			cin>>in[i].name;
			int p,a,b,c,d,e,f,s,m;
			cin>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			int t=a+b+c+(d+e)*m;
			in[i].eff=(f*m*s-p)*1.0/t;
		}
		sort(in,in+n,crop::comp);
		for (int i = 0; i < n; i++) {
			cout<<in[i].name<<endl;
		}
		cout<<"#"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int shiryoku[4][2];

int main() {
	double left,right;
	while(cin>>left>>right){
		if(left<0.2)shiryoku[3][0]++;
		else if(left<0.6)shiryoku[2][0]++;
		else if(left<1.1)shiryoku[1][0]++;
		else shiryoku[0][0]++;
		if(right<0.2)shiryoku[3][1]++;
		else if(right<0.6)shiryoku[2][1]++;
		else if(right<1.1)shiryoku[1][1]++;
		else shiryoku[0][1]++;
	}
	cout<<shiryoku[0][0]<<" "<<shiryoku[0][1]<<endl;
	cout<<shiryoku[1][0]<<" "<<shiryoku[1][1]<<endl;
	cout<<shiryoku[2][0]<<" "<<shiryoku[2][1]<<endl;
	cout<<shiryoku[3][0]<<" "<<shiryoku[3][1]<<endl;
	return 0;
}

Measured memory_bytes: 0
#入力
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
#すべての合計をsとする
s = 0
#とりあえずBで与えられた満足度は確実に得られる
sb = sum(B)
#Cで追加で与えられるかもしれない満足度をscとする
sc = 0
#食べた料理番号が連続している場合追加の満足度が増加する(問題の条件から)
for i in range(N-1):
  if A[i+1] == A[i] + 1:
    sc += C[A[i]-1]
#すべての合計=Bで与えられる満足度+Cの追加分の満足度
s = sb + sc
#結果
print(s)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, P; cin >> A >> P;
  P += 3 * A;
  int k = P / 2;
  cout << k << endl;
  return 0;
}

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

int X[100], Y[100];


// 最大公約数を求める
long long int GCD (long long int a, long long int b) {
    long long int tmp, x, r;
    if (a<b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while (r!=0) {
      a = b;
      b = r;
      r = a % b;
    }
    return b;
}


int main() {
  long long A, B, G, result;
  int i;
  scanf ("%lld %lld", &A, &B);
  
  G = GCD(A,B);
//  printf("G=%lld\n",G);
  result = 1;
  for (i=2;i<=sqrt(G);i++) {
     if (G%i==0) result++;
     while (G%i==0) {G/=i;}
  }
  
  if (G!=1) result++;
  
  printf("%lld", result);
  return 0;
}




Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        String str=in.next();
        int ans=0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(i)=='1'){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


class Fast {
    BufferedReader br;
    StringTokenizer st;

    public Fast() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 21204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

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

	vector<ll> a(n);
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0) {
			a[i] *= -1;
			cnt++;
		}
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i];
	}
	sort(a.begin(), a.end());
	if (cnt % 2) {
		ans -= a[0] * 2;
	}
	dump(ans);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
char s[100001];
int main(){
    scanf("%s",s);
    int ans=0,i;
    for(i=0;s[i]!='\0';i++){
        if((i%2==0&&s[i]=='1')||(i%2==1&&s[i]=='0'))ans++;
    }
    printf("%d\n",std::min(ans,i-ans));
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    # 桁数を求める
    n_digit = 0
    idx = 0
    while True:
        n_digit += 1
        n_str = 26 ** n_digit
        if idx + 1 <= N <= idx + n_str:
            idx += 1
            break
        else:
            idx += n_str

    k = N - idx
    ans = ''
    for i in range(n_digit):
        ans += chr(ord('a') + k % 26)
        k //= 26
    print(ans[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 61968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int N;
    cin >> N;
    int ans;
    ans = pow(N,3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<int> c(n),s(n),f(n);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n) {
        int ans=0;
        repr(j,i,n-1) {
            int chunk=ans/f[j];
            if (ans%f[j]>0) ++chunk;
            ans=max(chunk*f[j]+c[j],s[j]+c[j]);
        }
        cout << ans << endl;
    }
    
    

    return 0;
}


Measured memory_bytes: 3564
s = input()
n = len(s)

left = 0
right = n-1
ans = [-1 for i in range(n)]

def judge(m):
    if n>=2*m:
        return 1

    for i in range(n-m,m-1):
        if s[i] != s[i+1]:
            return 0
    return 1

while left <= right:
    mid = (left+right)//2
    #print(mid)

    if judge(mid+1):
        ans[mid]  = 1
        left = mid+1

    else:
        ans[mid]  = 0
        right = mid-1
#print(ans)

for i in range(n):
    if ans[-i-1] ==1:
        print(n-i)
        break


Measured memory_bytes: 45168
#include<stdio.h>

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

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

const int MAX=1e5+5;
int n,a[MAX],b[MAX],c[MAX];

int bs1(int val) {
	int l=1,r=n,rs=0;
	while(l<=r) {
		int mid=(l+r)/2;
		if(a[mid]<val) {
			rs=mid;
			l=mid+1;
		} else
			r=mid-1;
	}
	return rs;
}

int bs2(int val) {
	int l=1,r=n,rs=n+1;
	while(l<=r) {
		int mid=(l+r)/2;
		if(val<c[mid]) {
			rs=mid;
			r=mid-1;
		} else
			l=mid+1;
	}
	return rs;
}

int main() {
	cin>>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++)
		cin>>c[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	int64_t rs=0;
	for(int i=1;i<=n;i++) {
		int64_t t1=bs1(b[i]);
		int64_t t2=bs2(b[i]);
		rs+=t1*(n-t2+1);
	}
	cout<<rs;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();

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

  vector<int> ans;
  while (N != 0) {
    int s0 = abs(N % (2));
    ans.push_back(s0);
    N = (N - s0) / (-2);
  }
  reverse(ALL(ans));

  REP(i, ans.size()) cout << ans[i];
  cout << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
int main(void){
    int N,X,i;
    int L[100];
    int bound=0,D[100];

    scanf("%d %d",&N,&X);
    for(i=0;i<N;i++){
    scanf("%d",&L[i]);
    }

    for(i=0;i<N+1;i++){
        if(i==0)
            D[i]=0;
        else
            D[i]=D[i-1]+L[i-1];
    }

    for(i=0;i<N+1;i++){
        if(D[i]<=X)
        bound++;
    }
    printf("%d\n",bound);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

using namespace std;

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int NIL = -1;
static const int MAX = 100;
static const int INFTY = 10000000;


int colors[MAX] = { WHITE };	//各頂点の訪問状態
int graph[MAX][MAX] = { INFTY };
int d[MAX] = { INFTY };		//原点からの各頂点の距離
int p[MAX] = { NIL };		//親頂点

void dijkstra(int n) {

    d[0] = 0;
    colors[0] = WHITE;

    while (true) {

	int mincost = INFTY;
	int u;

	for (int i = 0; i < n; i++) {
	    //まだコストが確定しておらず、かつ現時点で仮コストが出ているもの
	    if (colors[i] != BLACK&&d[i] != INFTY) {

		//より小さいコストの原点からの距離があったら
		if (d[i] < mincost) {
		    mincost = d[i];
		    u = i;
		}
	    }
	}

	if (mincost == INFTY) {
	    break;
	}

	colors[u] = BLACK;

	//確定した頂点uからの近隣探索
	for (int i = 0; i < n; i++) {
	    
	    //まだ確定しておらずvから辺があれば
	    if (colors[i] != BLACK&&graph[u][i] != INFTY) {


		//現時点でiに行くコストより
		//頂点uを経由した方がコストが小さかったら
		if (d[u]+graph[u][i] < d[i]) {
		    d[i] = d[u] + graph[u][i];
		    p[i] = u;
		}

	    }

	}

    }
}

int main() {

    //cin.tie(0);
    //ios::sync_with_stdio(false);
    
    int n; scanf("%d", &n);
    int u; //頂点
    int k; //vからの辺の数
    int v; //uにつながる頂点v
    int c; //コスト

    //グラフ初期化
    for (int i = 0; i < n; i++) {
	for (int j = 0; j < n; j++) {
	    graph[i][j] = INFTY;
	}
    }
    
    //距離d初期化
    for(int i = 0; i < n; i++) {
	d[i] = INFTY;
    }

    //グラフ読み込み
    for (int i = 0; i < n; i++) {
	scanf("%d", &u);
	scanf("%d", &k);
	for (int j = 0; j < k; j++) {
	    scanf("%d", &v);
	    scanf("%d", &c);
	    graph[u][v] = c;
	}
    }


    //ダイクストラ法
    dijkstra(n);

    //表示
    for (int i = 0; i < n; i++) {
	printf("%d %d\n", i, d[i]);
    }

    return 0;

}




Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i * i <= x; i++) {
		while (x % i == 0) {
			res[i]++;
			x /= i;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
int n, m;
signed main() {
	cin >> n >> m;
	int ans = 1;
	for (auto p : factor(m)) {
		ans *= comb(p.second + n - 1, n - 1);
		ans %= moder;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>

std::vector<int> graph[200010];

int come[200010];
int flag=0;
int sum=0;

int tansaku(int x){
	int i;
	sum=sum+come[x];
//	printf("come[%d]=%d\n",x,come[x]);
	for(i=0;i<graph[x].size();i++){
		if(come[graph[x][i]]==-1){
			come[graph[x][i]]=(come[x]+1)%2;
			tansaku(graph[x][i]);
		}else{
			if(come[graph[x][i]]!=(come[x]+1)%2){
				flag=1;
			}
		}
	}
	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m;
	int a,b;

	//よく使う変数
	int i,j,k,l;
	//int flag=0;
	long int ans=0;
	int count=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for(i=0;i<100010;i++){
		come[i]=-1;
	}

//	printf("nは%dです\n", n);
//	printf("tag1 reading OK\n");
	//実際の処理
	
	come[1]=1;
	tansaku(1);

	if(flag==1){
		ans=(long)n*(n-1)/2-m;
	}else{
		ans=(long)sum*(n-sum)-m;
	}

//	printf("tag2 calculate OK\n");
	//出力
	
//	printf("flag=%d\n",flag);
	printf("%ld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

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

    int H, W, D;
    cin >> H >> W >> D;

    vector<int> x(H * W);
    vector<int> y(H * W);

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int A;
            cin >> A;
            A--;
            y[A] = i;
            x[A] = j;
        }
    }

    vector<int> a(H * W);

    for(int i = 0; i < H * W - D; i++) {
        a[i + D] = a[i] + abs(x[i] - x[i + D]) + abs(y[i] - y[i + D]);
    }

    int Q;
    cin >> Q;

    vector<int> ans(Q);

    for(int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        L--;
        R--;
        ans[i] = a[R] - a[L];
    }

    for(int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 2560
#include<cstdio>
#include<vector>
#include<cmath>

using namespace std;

long long bsearch(long long div, long long pw, long long lb, long long ub)
{
	long long val;
	long long next;

	if (ub - lb < 2)
	{
		return lb;
	}

	next = (lb + ub) / 2;

	val = (long long)pow((double)pw, next);

	if (!(div%val))
	{
		return bsearch(div, pw, next, ub);
	}

	else
	{
		return bsearch(div, pw, lb, next);
	}
}

int main()
{
	vector<long long> prime;

	long long n, p;
	long long i, j;
	long long pw;
	bool isprime;
	long long sol = 1;
	long long psol;
	long long cur;
	long long root;

	scanf("%lld %lld", &n, &p);

	if (n == 1)
	{
		printf("%lld\n", p);

		return 0;
	}

	root = pow((double)p, 1.0 / (double)n) + 1;

	for (i = root; i > 1; i--)
	{
		if (!(p % (long long)pow((double)i,n)))
		{
			break;
		}
	}

	printf("%lld\n", i);

	return 0;

	/*	
	prime.push_back(2);

	if (!(p%2))
	{
		psol = bsearch(p, 2, 1, (long long)((log10((double)p) / log10(2.0)) + 1));

		p /= (long long)pow(2.0, psol);

		sol *= (long long)pow(2.0, psol / n);
	}

	for (i = 3; (long long)pow(i, n) <= p; i += 2)
	{
		isprime = true;

		for (j = 0; j < prime.size() && prime[j] * prime[j] <= i; j++)
		{
			if (!(i%prime[j]))
			{
				isprime = false;

				break;
			}
		}

		if (isprime)
		{
			prime.push_back(i);

			if (!(p%i))
			{
				psol = bsearch(p, i, 1, (long long)((log10((double)p) / log10((double)i)) + 1));

				p /= (long long)pow((double)i, psol);

				sol *= (long long)pow((double)i, psol / n);
			}
		}		
	}

	/*
	for (i = 0; i < prime.size(); i++)
	{
		cur = (long long)pow(prime[i], n);

		if (p < cur)
		{
			break;
		}

		if (!(p%cur))
		{
			psol = bsearch(p, cur, 1, (long long)((log10((double)p) / log10(cur)) + 1));

			sol *= (long long)pow((double)prime[i], psol);

			p /= (long long)pow((double)cur, psol);
		}
	}

	printf("%lld\n", sol);

	return 0;
	*/
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int L;
int N;
int ord[114];
int res[114];
vector<pii> es[114];

void Add(int u, int v, int l) {
  MX(N, u+1);
  MX(N, v+1);
  es[u].eb(pii(v, l));
  res[v]++;
}

void Output() {
  int M = 0;
  queue<int> que;
  rep(v, N) {
    if (res[v] == 0) {
      que.push(v);
    }
  }

  int idx = 0;
  while (!que.empty()) {
    int v = que.front(); que.pop();
    ord[v] = idx++;
    for (auto &p : es[v]) {
      int u = p.X;
      res[u]--;
      if (res[u] == 0) {
        que.push(u);
      }
    }
    M += es[v].size();
  }
  assert(idx == N);

  cout << N << " " << M << endl;
  rep(v, N) {
    for (auto &p : es[v]) {
      int u = p.X;
      cout << ord[v]+1 << " " << ord[u]+1 << " " << p.Y << endl;
    }
  }
}

int main() {
  cin >> L;
  if (L <= 3) {
    rep(i, L) {
      Add(0, 1, i);
    }
    Output();
    return 0;
  }

  int w = 0;
  rep(i, 32) {
    if (L >> i & 1) MX(w, i+1);
  }
  int msbs = L >> (w-2);
  //cout << "w: " << w << endl;
  //cout << "msbs: " << msbs << endl;
  rep(i, msbs) {
    Add(0, 1, i);
  }

  int s = 0;
  int t = 1;
  int cur = msbs;
  rrep(i, w-2) {
    int v = i+2;
    if (L >> i & 1) {
      Add(v, s, cur+1);
      Add(v, s, 1);
      Add(v, t, 0);
      cur = cur*2 + 1;
    } else {
      Add(v, s, cur);
      Add(v, s, 0);
      cur = cur*2;
    }
    s = v;
  }
  assert(cur == L);
  Output();
}


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

int n,head=0,tail=0,q,l=100100;
struct pp{string name;int t;};
pp Q[100100];

void enqueue(pp x){
    Q[tail]=x;
    tail=(tail+1)%l;
}

pp dequeue(){
    pp x=Q[head];
    head=(head+1)%l;
    return x;
}

int main(){
    cin>>n>>q;int elaps=0;
    for(int i=0;i<n;i++) cin>>Q[i].name>>Q[i].t;
    head=0;tail=n;

    while(head!=tail){
        pp u=dequeue();
        if(u.t>q){
            u.t-=q;
            enqueue(u);
            elaps+=q;
        }
        else{
            elaps+=u.t;
            cout<<u.name<<" "<<elaps<<endl;
        }
    }
}



Measured memory_bytes: 7124
def lenOfLongIncSubArr(arr, n) : 
  
    # 'max' to store the length of longest 
    # increasing subarray 
    # 'len' to store the lengths of longest 
    # increasing subarray at diiferent  
    # instants of time 
    m = 1 
    l = 1 
       
    # traverse the array from the 2nd element 
    for i in range(1, n) : 
  
        # if current element if greater than previous 
        # element, then this element helps in building 
        # up the previous increasing subarray encountered 
        # so far 
        if (arr[i] <= arr[i-1]) : 
            l =l + 1 
        else : 
  
            # check if 'max' length is less than the length 
            # of the current increasing subarray. If true,  
            # then update 'max' 
            if (m < l)  : 
                m = l  
  
            # reset 'len' to 1 as from this element 
            # again the length of the new increasing 
            # subarray is being calculated     
            l = 1 
          
          
    # comparing the length of the last 
    # increasing subarray with 'max' 
    if (m < l) : 
        m = l 
       
    # required maximum length 
    return m 
n=int(input())
a=[int(x) for x in input().split(' ')]
print(lenOfLongIncSubArr(a,n)-1)

Measured memory_bytes: 14224
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D
 */
#include <iostream>
#include <algorithm>

using namespace std;

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

    int bot = 2000000000;
    int gain = -1000000000;
    for (int i = 0; i < n; i++) {
        int r;
        cin >> r; cin.ignore();
        gain = max(gain, r - bot);
        bot = min(bot, r);
    }
    cout << gain << endl;

    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 100500; //       e5
//const int SZ = 105;

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n, a, b;
    cin >> n >> a >> b;
    if(a > b){cout << 0 << endl; return 0;}
    if(n == 1){
        if(a == b){ cout << 1 << endl; return 0;}
        cout << 0 << endl;
        return 0;
    }
    long long ans = (b - a);
    ans *= n - 2;
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

/*
longest common subsequence
DPの復元
*/
func main() {
	s := readString()
	t := readString()
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	move := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, m+1)
		move[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
				move[i][j] = 0
			} else {
				if dp[i-1][j] > dp[i][j-1] {
					dp[i][j] = dp[i-1][j]
					move[i][j] = 1
				} else {
					dp[i][j] = dp[i][j-1]
					move[i][j] = 2
				}
			}
		}
	}

	i, j := n, m
	var ans string
	for i > 0 && j > 0 && len(ans) < dp[n][m] {
		if move[i][j] == 0 {
			i--
			j--
			ans = s[i:i+1] + ans
		} else if move[i][j] == 1 {
			i--
		} else {
			j--
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 155392
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 99999999;


int main(void)
{
	int n,m;
	int cost[101][101];
	int time[101][101];

	while( cin >> n >> m && n != 0 ){
		for( int i = 0;i < 101;i++ ){
			for( int j = 0;j < 101;j++ ){
				cost[i][j] = time[i][j] = INF;
			}
		}

		for( int i = 0;i < 101;i++ ){
			cost[i][i] = time[i][i] = 0;
		}

		for( int i = 0;i < n;i++ ){
			int a,b,c,d;

			cin >> a >> b >> c >> d;

			cost[a][b] = c;
			cost[b][a] = c;
			time[a][b] = d;
			time[b][a] = d;
		}

		for( int k = 1;k <= m;k++ ){
			for( int i = 1;i <= m;i++ ){
				if( cost[i][k] != INF ){
					for( int j = 1;j <= m;j++ ){
						cost[i][j] = min( cost[i][j], cost[i][k] + cost[k][j] );
					}
				}
				if( time[i][k] != INF ){
					for( int j = 1;j <= m;j++ ){
						time[i][j] = min( time[i][j], time[i][k] + time[k][j] );
					}
				}
			}
		}

		int k;

		cin >> k;

		for( int i = 0;i < k;i++ ){
			int p,q,r;

			cin >> p >> q >> r;

			if( r == 0 ) cout << cost[p][q];
			else cout << time[p][q];

			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
int a[3];
 
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(abs(c - a) + abs(c - b), min(abs(a - b) + abs(a - c), abs(a - b) + abs(b - c)));
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N, K;
		cin >> N >> K;
		vector<int> p( N );
		for( int i = 0; i < N; ++i ) { cin >> p[i]; }
		sort( p.begin(), p.end() );
		int ans = 0;
		for( int i = 0; i < K; ++i ) { ans += p[i]; }
		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3664