akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;

using namespace std;

int popcount(int n){
    int q1 = 0;
    while (n > 0){
        q1 += n % 2;
        n /= 2;
    }
    return q1;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    int popc = 0;
    for (char q: s){
        popc += (q == '1');
    }
    if (popc == 0){
        for (int q = 0; q < n; q++){
            cout << 1 << endl;
        }
    }else if (popc == 1){
        for (int q = 0; q < n; q++){
            if (q == n-1 && s[q] == '1') {
                cout << 0 << endl;
            }else if (q == n-1){
                cout << 2 << endl;
            }else if (s[q] == '1'){
                cout << 0 << endl;
            }else if (s.back() == '0'){
                cout << 1 << endl;
            }else{
                cout << 2 << endl;
            }
        }
    }else{
        int ost1 = 0, ost2 = 0;
        vector<int> osts1 = {1 % (popc-1)}, osts2 = {1 % (popc+1)};
        for (int q = 0; q < n; q++){
            if (s[n-q-1] == '1'){
                ost1 = (ost1+osts1.back()) % (popc-1);
                ost2 = (ost2+osts2.back()) % (popc+1);
            }
            osts1.push_back((osts1.back()*2) % (popc-1));
            osts2.push_back((osts2.back()*2) % (popc+1));
        }
        for (int q = 0; q < n; q++){
            int now = 0, q1 = 1;
            if (s[q] == '1'){
                now = ((ost1-osts1[n-q-1]) % (popc-1)+popc-1) % (popc-1);
            }else{
                now = (ost2+osts2[n-q-1]) % (popc+1);
            }
            while (now > 0){
                q1++, now = now % popcount(now);
            }
            cout << q1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6864
#include<bits/stdc++.h>
using namespace std;
char f() {
  string s;
  long k; cin >> s >> k;
  for (size_t i = 0; i < k; i++) {
    if (s[i] != '1') return s[i];
  }
  return '1';
}

int main() {
  cout << f() << endl;
}

Measured memory_bytes: 256
def c_tax_increase():
    A, B = [int(i) for i in input().split()]
    lower = max((25 * A + 2 - 1) // 2, 10 * B)
    upper = min(25 * (A + 1) // 2, 10 * (B + 1))
    return lower if lower < upper else -1

print(c_tax_increase())

Measured memory_bytes: 3060
#include <iostream>
int main(){
    int n, a, b, c, d;
    std::string s;
    std::cin >> n >> a >> b >> c >> d >> s;
    bool flag = true;
    for(int i = a-1; i < d-1; i++){
        if(s[i] == '#'){
            flag &= (s[i+1]=='.');
        }
    }
    if(d<c){
        int t = 0;
        int max = 0;
        for(int i = b-2; i < d+1; i++){
            if(s[i]=='.'){
                t++;
                max = std::max(max, t);
            }else{
                t = 0;
            }
        }
        flag &= (max >= 3);
    }
    if(flag){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 640
#include<stdio.h>

#define N 100

int main(void){
  int n,E[N][N];
  int u,v;
  int i,j,k;

  scanf(" %d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      E[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf(" %d",&u);
    scanf(" %d",&k);
    for(j = 0; j < k; j++){
      scanf(" %d",&v);
      E[u-1][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j)printf(" ");
      printf("%d",E[i][j]);
    }
    printf("\n");
  } 
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Union_Find_Tree{
	public:
	vi p,r,s;
	Union_Find_Tree(int n){
		p=r=vi(n);
		s=vi(n,1);
		for(int i=0;i<n;i++) p[i]=i;
	}
	int Par(int x){
		if(p[x]==x) return x;
		return p[x]=Par(p[x]);
	}
	int Size(int x){return s[Par(x)];}
	bool Unite(int x,int y){
		x=Par(x);
		y=Par(y);
		if(x==y) return 0;
		if(r[x]<r[y]){
			p[x]=y;
			s[y]+=s[x];
		}
		else{
			p[y]=x;
			s[x]+=s[y];
			if(r[x]==r[y]) r[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){return Par(x)==Par(y);}
};

ll n,m;
vl a,b,c;

int main(){
	cin>>n>>m;
	a=b=c=vl(m);
	for(int i=0;i<m;i++) cin>>a[i]>>b[i];
	c[m-1]=n*(n-1)/2;
	Union_Find_Tree uft(n);
	for(int i=m-1;i>0;i--){
		a[i]--;b[i]--;
		ll A=uft.Size(a[i]),B=uft.Size(b[i]);
		if(uft.Unite(a[i],b[i])) c[i-1]=c[i]-A*B;
		else c[i-1]=c[i];
	}
	for(auto i:c) cout<<i<<endl;
}

Measured memory_bytes: 4864
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    fl = defaultdict(lambda : 0)
    fr = defaultdict(lambda : 0)

    def dfs(x,hx):
        p = 0
        for y,c in v[x]:
            if hx < h[y]:
                continue
            fl[(x,y)] = p
            nh = h[y]+c
            if p < nh:
                p = nh
        p = 0
        for y,c in v[x][::-1]:
            if hx < h[y]:
                continue
            fr[(x,y)] = p
            nh = h[y]+c
            if p < nh:
                p = nh
        for y,c in v[x]:
            hy = h[y]
            if hx < hy:
                continue
            if ans[y]:continue
            nhx = max(fl[(x,y)],fr[(x,y)])
            ans[y] = nhy = max(h[y],nhx+c)
            h[x] = nhx
            dfs(y,nhy)
            h[x] = hx

    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b,c = LI()
        v[a].append((b,c))
        v[b].append((a,c))
    q = [0]
    q2 = []
    h = [-1]*n
    h[0] = 0
    while q:
        x = q.pop()
        for y,c in v[x]:
            if h[y] < 0:
                h[y] = 0
                q.append(y)
                q2.append((y,x,c))
    while q2:
        y,x,c = q2.pop()
        nh = h[y]+c
        if h[x] < nh:
            h[x] = nh

    ans = [0]*n
    ans[0] = h[0]
    dfs(0,h[0])

    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 27904
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){

    int N;
    cin >> N;

    vector<vector<int>> graph(N);
    rep(i, N - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);        
    }

    vector<int> c(N);
    rep(i, N)cin >> c[i];
    sort(all(c), greater<int>());

    int num = 0;
    vector<int> ans(N);
    vector<bool> used(N, false);

    function<void(int)> dfs = [&](int v){
        used[v] = true;
        ans[v] = c[num++];
        for(int i : graph[v]){
            if(!used[i])dfs(i);
        }
    };


    long long score = 0;
    rep(i, N - 1)score += c[i + 1];
    cout << score << endl;

    dfs(0);
    rep(i, N){
        cout << ans[i] << (i == N - 1 ? "\n" : " ");
    }

}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
	int N,K,X,Y,sum;
	scanf("%d %d %d %d", &N, &K, &X, &Y);
	if(N>K)
	{
	sum= K*X+(N-K)*Y;
	}
	else
	{
	sum= N*X;
	}
	printf("%d", sum);
	return 0;
}


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

    using namespace std;
     
    int main(){
    	int a, b;
    	scanf("%d %d", &a, &b);
    	if(a%3== 0 || b%3==0 || (a+b)%3 == 0){
    		printf("Possible");
    		return 0;
    	}
    	printf("Impossible");
    	return 0;
    }

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<pii, ll> ppiil;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define btoe(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

template<typename T>
void print(T out) {
    cout << out << '\n';
}

template<typename T1, typename T2>
void print(pair<T1, T2> out) {
    cout << out.first << ' ' << out.second << '\n';
}

template<typename T>
void print(vector<T> A) {
    rep(i, 0, A.size()) {
        cout << A[i];
        cout << (i == A.size()-1 ? '\n' : ' ');
    }
}

template<typename T>
void print(set<T> S) {
    vector<T> A(btoe(S));
    print(A);
}

ll sum(vector<ll> A) {
    ll res = 0;
    for (ll a: A) res += a;
    return res;
}

ll max(vector<ll> A) {
    ll res = -INF;
    for (ll a: A) chmax(res, a);
    return res;
}

ll min(vector<ll> A) {
    ll res = INF;
    for (ll a: A) chmin(res, a);
    return res;
}

ll sum(ll A[], int len) {
    ll res = 0;
    rep(i, 0, len) res += A[i];
    return res;
}

ll max(ll A[], int len) {
    ll res = -INF;
    rep(i, 0, len) chmax(res, A[i]);
    return res;
}

ll min(ll A[], int len) {
    ll res = INF;
    rep(i, 0, len) chmin(res, A[i]);
    return res;
}

ll toint(string s) {
    ll res = 0;
    for (char c : s) {
        res *= 10;
        res += (c - '0');
    }
    return res;
}

int toint(char c) {
    return c - '0';
}

ll grid1[87][87], grid2[87][87], grid[87][87];
bool dp[87][87][13007];
ll MAXV = 80 * 160;
int H, W;

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

    cin >> H >> W;
    rep(i, 0, H) rep(j, 0, W) cin >> grid1[i][j];
    rep(i, 0, H) rep(j, 0, W) cin >> grid2[i][j];
    rep(i, 0, H) {
        rep(j, 0, W) {
            grid[i+1][j+1] = abs(grid1[i][j]-grid2[i][j]);
        }
    }

    dp[1][1][grid[1][1]] = 1;
    rep(i, 1, H+1) {
        rep(j, 1, W+1) {
            int v = grid[i][j];
            rep(k, 0, MAXV+1) {
                dp[i][j][k] |= dp[i-1][j][abs(k-v)];
                if (k+v <= MAXV) {
                    dp[i][j][k] |= dp[i-1][j][k+v];
                }
                dp[i][j][k] |= dp[i][j-1][abs(k-v)];
                if (k+v <= MAXV) {
                    dp[i][j][k] |= dp[i][j-1][k+v];
                }
            }
        }
    }
    ll ans = INF;
    rep(k, 0, MAXV+1) {
        if (dp[H][W][k]) {
            chmin(ans, k);
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 91392
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b = sc.nextInt
    if (a <= b) {
      println(Seq.fill(b)(a).mkString(""))
    } else {
      println(Seq.fill(a)(b).mkString(""))
    }
  }
}


Measured memory_bytes: 25900
#include<stdio.h>

int main(){
  int X;
  scanf("%d",&X);
  int happy=0;
  if(X>=500){
    happy += (X / 500)*1000;
    X = X % 500;
  }
  if(X>0){
    happy += (X / 5)*5;
    X = X % 5;
  }
  printf("%d\n",happy);
  return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int cnt = 0;
                long l = in.nextLong();
                while (l % 2 == 0) {
                    cnt++;
                    l /= 2;
                }
                ans = Math.min(ans, cnt);
            }
            out.print(ans);
        }

    }
}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i_##END_=(b);i<=i_##END_;++i)
#define REP(i,a,b) for(int i=(a),i_##END_=(b);i>=i_##END_;--i)
#define M 1000005
#define N 10000005
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> Pa;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int n,X;
int main(){
	int a;
	scanf("%d%d",&n,&X);
	scanf("%d",&a);
	int d=abs(a-X);
	FOR(i,1,n-1){
		scanf("%d",&a);
		d=gcd(d,abs(a-X));
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var h = int.Parse(input[0]);
            var w = int.Parse(input[1]);
            Console.WriteLine(h * w / 2.0);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++)
	{
		if ((i % 2 && str[i] == 'R') || (!(i % 2) && str[i] == 'L'))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N)  cin >> A.at(i);

  vector<ll> bit_cnt(45,0);
  rep(i,N){
    rep(j,45){
      if(A.at(i)&(ll(1)<<j))  bit_cnt.at(j)++;
    }
  }
  debug_vec(bit_cnt);

  vector<ll> dp1(45,-1e18);
  vector<ll> dp2(45,-1e18);
  dp1.at(44)=0;
  for(int i=43;i>=0;i--){
    ll tmp=ll(1)<<i;
    if(K&tmp){
      chmax(dp1.at(i),dp1.at(i+1) + (N - bit_cnt.at(i))*tmp);
      chmax(dp2.at(i),dp1.at(i+1) + bit_cnt.at(i)*tmp);
    }
    else  chmax(dp1.at(i),dp1.at(i+1) + bit_cnt.at(i)*tmp);

    if(dp2.at(i+1)>=0){
      chmax(dp2.at(i),dp2.at(i+1) + bit_cnt.at(i)*tmp);
      chmax(dp2.at(i),dp2.at(i+1) + (N - bit_cnt.at(i))*tmp);
    }
  }
  debug_vec(dp1);
  debug_vec(dp2);
  cout << max(dp1.at(0),dp2.at(0)) << endl;

  return 0;
}

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

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#ifdef __DEBUG
#include "cpp-pyprint/pyprint.h"
#endif

void Main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
}

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


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
#"tel"は既に訪れている町
tel = set()
route = []
#"town"は今いる町
town = 1
route.append(town)
tel.add(town)
time_loop = 0
for i in range(k):
    town = a[town-1]
    if town in tel:
        time_loop += 1
        break
    tel.add(town)
    route.append(town)
    #テレポートした回数をカウント
    time_loop += 1

#"start"は"route"内のループの起点のとなる町のインデックス番号
start = route.index(town)
if time_loop != start:
    k = (k - start) % (time_loop - start)
    print(route[k+start])
else:
    print(town)



Measured memory_bytes: 32392
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m; cin>>n>>m;
    vector <tuple <int ,int, int>> data(m);
    vector <int> pre(n+10);
    for(int i=0;i<m;i++){
        int p,y; cin>>p>>y;
        data[i]=make_tuple(y,p,i);
    }
    sort(data.begin(),data.end());
    for(int i=0;i<m;i++){
        pre[get <1>(data[i])]++;
        data[i]=make_tuple(get <2>(data[i]), get <1>(data[i]), pre[get <1>(data[i])]);
    }
    sort(data.begin(),data.end());
    for(int i=0;i<m;i++){
        printf("%06d%06d\n",get <1>(data[i]),get <2>(data[i]));
    }
}

Measured memory_bytes: 3072
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<ll> a;
        forr(i,0,n)  {
            readint(kk); a.push_back(kk);
        }

        ll money = 1000, stocks = 0;
        forr(i,0,n-1) {
            if (a[i+1]>a[i]) {
                ll how_many = money/a[i];
                money -= how_many*a[i];
                stocks += how_many;
            }
            if (a[i+1]<a[i]) {
                money += stocks * a[i];
                stocks = 0;                
            }
        }

        cout << money + stocks * a.back() << endl;


    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3656
N = int(input())
TS = []
for i in range(N):
    X, L = map(int, input().split())
    TS.append((X + L, X - L))
TS.sort()

cur = -10**10
ans = 0
for i in range(N):
    if TS[i][1] >= cur:
        ans+=1
        cur = TS[i][0]
print(ans)

Measured memory_bytes: 16988
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    int count = 0;
    rep(i, n - 2) {
        if (p.at(i) < p.at(i + 1) && p.at(i + 1) < p.at(i + 2)) {
            count++;
        } else if (p.at(i + 2) < p.at(i + 1) && p.at(i + 1) < p.at(i)) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

const int maxn = 3e5;
int n, q;
struct data1
{
    int s, t, x;
};
struct data2
{
    int x, res, next, id;
};
data1 a[maxn];
data2 b[maxn];

void Enter()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].s >> a[i].t >> a[i].x;
        a[i].s -= a[i].x;
        a[i].t -= a[i].x + 1;
    }
    for (int i = 1; i <= q; i++)
    {
        cin >> b[i].x;
        b[i].res = -1;
        b[i].id = i;
    }
    b[0].x = INT_MIN; b[q + 1].x = INT_MAX;
    b[0].id = 0; b[q + 1].id = q + 1;
}

bool cmp1(data1 a, data1 b)
{
    if (a.x < b.x) return true;
    return false;
}

bool cmp2(data2 a, data2 b)
{
    if (a.x < b.x) return true;
    return false;
}

bool cmp3(data2 a, data2 b)
{
    if (a.id < b.id) return true;
    return false;
}

int Low_Bound(int x)
{
    int l = 1, r = q, m;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (b[m].x <= x && b[m + 1].x > x)
            return m;
        if (b[m].x <= x)
            l = m + 1;
        else
            r = m - 1;
    }
    return -1;
}

int Up_Bound(int x)
{
    int l = 1, r = q, m;
    while (l <= r)
    {
        m = (l + r) / 2;
        if (b[m].x >= x && b[m - 1].x < x)
            return m;
        if (b[m].x <= x)
            l = m + 1;
        else
            r = m - 1;
    }
    return -1;
}

void Solve()
{
    sort(a + 1, a + n + 1, cmp1);
    sort(b + 1, b + q + 1, cmp2);
    for (int i = 1; i <= n; i++)
    {
        int L = Up_Bound(a[i].s);
        int R = Low_Bound(a[i].t);
        if (L == -1) continue;
        while (L <= R)
        {
            if (b[L].res == -1)
            {
                b[L].next = R + 1;
                b[L].res = a[i].x;
                L++;
            }
            else
                L = b[L].next;
        }
    }
}

void Print()
{
    sort(b + 1, b + q + 1, cmp3);
    for (int i = 1; i <= q; i++)
        cout << b[i].res << endl;
}

int main()
{
    Enter();
    Solve();
    Print();
    return 0;
}


Measured memory_bytes: 10112
a, b, c, d, e, f = gets.split.map(&:to_i)
max_water = a * 100
max_sugar = 0
max_concentration = 0.0

(0..(f/(a*100))).each do |water_a|
  (0..(f/(b*100))).each do |water_b|
    next if water_a == 0 && water_b == 0
    water = (water_a * a + water_b * b) * 100
    sugar_limit = water / 100 * e
    (0..((f-water)/c)).each do |sugar_c|
      (0..((f-water)/d)).each do |sugar_d|
        sugar = sugar_c * c + sugar_d * d
        next if sugar > sugar_limit || sugar + water > f || sugar == 0 || water == 0
        concentration = sugar.to_f / (sugar+water)
        if concentration > max_concentration
          max_concentration = concentration
          max_water = water
          max_sugar = sugar
        end
      end
    end
  end
end

puts "#{max_water + max_sugar} #{max_sugar}"


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

int main(){
    int m, n, sum = 0;
    cin >> n >> m;
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());
    if(arr[m-1] >= (float)sum / (4 * m)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B <= A)cout << "delicious" << endl;
    else if (B <= A + X)cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
<?php
$input = fgets(STDIN);
list($bill_count, $total_amounts) = explode(" ", $input);

function checkNewYearsGift($bill_count, $total_amounts)
{
    for ($yc = 0; $yc <= $bill_count; $yc++) {
        for ($hc = 0; $hc + $yc <= $bill_count; $hc++) {
            $nc = $bill_count - $yc - $hc;
            if (10000 * $yc + 5000 * $hc + 1000 * $nc == $total_amounts) {
                return "$yc $hc $nc";
            }
        }
    }
    return "-1 -1 -1";
}

$result = checkNewYearsGift($bill_count, $total_amounts);
echo $result .PHP_EOL;

Measured memory_bytes: 4728
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Collections;

import java.util.Comparator;

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

		boolean f[] = new boolean[1000010];
		int[] s = new int[1000010];

		f[1] = true;

		for(int i = 1; i < 1000010; i *= 5){
			for(int j = 1; i * j < 1000010; j *= 3){
				for(int k = 1; i * j * k < 1000010; k *= 2){
					f[i * j* k] = true;
				}
			}
		}

		for(int i = 1; i < 1000010; i++) s[i] = s[i - 1] + (f[i]?1:0);

		while(in.hasNext()){
			int m = in.nextInt();
			if(m==0) return;
			int n = in.nextInt();
			System.out.println(s[n]-s[m-1]);
		}

	}
}

Measured memory_bytes: 31784
N = int(input())
r1 = int(input())
r2 = int(input())
R = [int(input()) for i in range(N-2)]

res = r2 - r1
min_r = min(r1, r2)

for r in R:
  res = max(res, r - min_r)
  min_r = min(min_r, r)

print(res)



Measured memory_bytes: 13592
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 200010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]
 
def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))
 
def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))
 
def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD
 
    return (num*(pow(den,MOD-2,MOD)))%MOD
 
def flush():
    return sys.stdout.flush()
 
'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n = int(input())
a = arrIN()
dp = [MAX]*(n)
dp[0] = 0
dp[1] = abs(a[1]-a[0])+dp[0]
for i in range(2,n):
    dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
print(dp[n-1])

Measured memory_bytes: 80620
import math
def main():
    t = [int(t)for t in input().split()]
    w,h,x,y = t[0],t[1],t[2],t[3]

    print(w*h/2, 1 if w/2==x and h/2 ==y else 0)

if __name__ == "__main__":
    main()

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  string N;
  int K;
  ll DP[110][5][2];

  void init() {
    cin >> N >> K;
  }

  ll rec(int d, int k, bool smaller) {
    if(DP[d][k][smaller] >= 0) return DP[d][k][smaller];
    if(d >= N.size()) {
      if(k==0) return DP[d][k][smaller] = 1;
      else return DP[d][k][smaller] = 0;
    }
    ll res = 0;
    if(smaller) {
      if(k > 0) REPC(i, 1, 9) res += rec(d+1, k-1, smaller);
      res += rec(d+1, k, smaller);
    } else if(N[d]-'0' == 0) {
      res += rec(d+1, k, smaller);
    } else {
      if(k > 0) {
        REP(i, 1, N[d]-'0') res += rec(d+1, k-1, true);
        res += rec(d+1, k-1, false);
      }
      res += rec(d+1, k, true);
    }
    return DP[d][k][smaller] = res;
  }

  void solve() {
    memset(DP, -1, sizeof DP);
    cout << rec(0, K, false) << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
<?php
/*
	AOJ 0164
	title:Ohajiki Game
	@kankichi573
*/

while(fscanf(STDIN,"%d ",$n) && $n)
  {
    $a=array();
    $x=fgets(STDIN);
    $a=explode(" ",$x);
    //fprintf(STDOUT,"%d:%d:%d:%d",$a[0],$a[1],$a[2],$a[3]);


    $yama=32;$turn=0;
    $yama -= 1;
    fprintf(STDOUT,"%d\n",$yama);
    while($yama >0)
      {
	//fprintf(STDOUT,"=%d[%d]\n",$a[$turn % $n],$turn % $n);
	if($a[$turn % $n] > $yama)
	  $tori=$yama;
	else
	  $tori=$a[$turn % $n];
	$yama -= $tori;
	if($yama==0)
	  break;
	fprintf(STDOUT,"%d\n",$yama);
	$tori= (($yama % 5)-1);
	if($tori < 0)
	  $tori += 5;
	$yama -= $tori;
	fprintf(STDOUT,"%d\n",$yama);
	$turn++;
      
	}
     fprintf(STDOUT,"%d\n",0);
  }
  return(0);
?>

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

typedef pair<int, int> pii;

int n, m;
char mat[30][30];
int op[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

inline bool valid(int i, int j) {
	return i >= 1 && j >= 1 && i <= n && j <= m && mat[i][j] == '.';
}

int solve(int sx, int sy, int ex, int ey) {
	queue<pii> q;
	q.emplace(sx, sy);

	int dist[21][21];
	memset(dist, 0x3f3f3f3f, sizeof dist);

	dist[sx][sy] = 0;

	while(q.size()) {
		int ux = q.front().first;
		int uy = q.front().second;
		q.pop();

		for (int k = 0; k < 4; k++) {
			int I = ux + op[k][0];
			int J = uy + op[k][1];

			if (valid(I, J) && dist[I][J] > dist[ux][uy] + 1) {
				dist[I][J] = dist[ux][uy] + 1;
				q.emplace(I, J);
			}

		}
	}



	return dist[ex][ey];
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf(" %c", &mat[i][j]);
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			for (int u = 1; u <= n; u++) {
				for (int v = 1; v <= m; v++) {
					if (mat[i][j] == '.' && mat[u][v] == '.')
						ans = max(ans, solve(i, j, u, v));
				}
			}
		}
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,K;
    cin>>N>>K;
    vl A(N);
    rep(i,N){
        cin>>A[i];
        A[i]--;
    }
    ll log=1;
    while((1LL<<log)<K) log++;
    vvl D(log,vl(N));
    rep(i,N){
        D[0][i]=A[i];
    }
    rep(i,log-1){
        rep(j,N){
            D[i+1][j]=D[i][D[i][j]];
        }
    }
    ll num=0;
    for(ll i=0;K>0;i++){
        if(K&1){
            num=D[i][num];
        }
        K=K>>1;
    }
    cout<<num+1<<endl;
}


Measured memory_bytes: 99976
#include<iostream>
#include<vector>
#include<stack>
using namespace std;

int main(){
    stack<int> land;//地形栈
    stack<pair<int, int> > area;//每个元素储存当前位置与当前位置的面积
    vector<int> res;//用于输出结果的向量
    char str[20005];
    cin>>str;
    char *p=str;
    for(int i=0; *p!='\0'; p++,i++){
        if(*p=='\\'){
            land.push(i);
        }else if(*p=='/'&&land.size()>0){
            int out=land.top();
            int nowArea = i-out;
            land.pop();
            while(area.size()>0&&(area.top().first)>out){
                nowArea+=area.top().second;
                area.pop();
            }
            area.push(make_pair(out, nowArea));
        }
    }
    int allArea = 0;
    int flag = area.size();
    int temp;
    for(int i = 0;i<flag;i++){
        temp = area.top().second;
        allArea+=temp;
        res.push_back(temp);
        area.pop();
    }
    cout<<allArea<<"\n"<<flag;
    for(int i=res.size()-1;i>=0;i--){
        cout<<' '<<res[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3180
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>


#include<iostream>
using namespace std;
int main()
{
	int a, c;
	int tmp;
	cin >> a;

	cin >> tmp;

	tmp -= 1;


	for (int i = 1; i < a; ++i) {
		cin >> c;

		if (tmp < c) {
			tmp = c - 1;
			continue;
		}

		if (tmp <= c) {
			tmp = c;
			continue;
		}


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


	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int r, D, x;
	cin >> r >> D >> x;

	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE] = {0};
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	int array[ARRAY_SIZE] = {0};

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}

	for(int k = 0;k < n; k++){
		if(k != n-1){
			printf("%d ",array[k]);
		}else{
			printf("%d\n",array[k]);
		}
	}

	int v = 0;
	int j = 0;
	for(int i = 1; i < n; i++){
		v = array[i];
		j = i-1;
		while(j >= 0 && array[j] > v){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = v;
		for(int k = 0;k < n; k++){
			if(k != n-1){
				printf("%d ",array[k]);
			}else{
				printf("%d\n",array[k]);
			}
		}
	}

}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,x;
  cin>>N>>A>>B;
  x=A*N;
  if(x<=B){
    cout<<x<<endl;
  }
  x=B;
  if(A*N>x){
    cout<<x<<endl;
  }
}
    

Measured memory_bytes: 256
fun main() = abc165c()

private data class Abcd(val a: Int, val b: Int, val c: Int, val d: Int)

@OptIn(ExperimentalStdlibApi::class)
fun abc165c() {
    data class Abcd(val a: Int, val b: Int, val c: Int, val d: Int)

    val (n, m, q) = readLine()!!.split(' ').map { it.toInt() }
    val abcdList = (1..q).map {
        readLine()!!.split(' ').map { it.toInt() }.let { Abcd(it[0] - 1, it[1] - 1, it[2], it[3]) }
    }

    var answer = 0

    fun dfs(list: List<Int>) {
        if (list.size < n) return ((list.lastOrNull() ?: 1)..m).forEach { dfs(list + it) }
        val filter = abcdList.filter { (a, b, c) -> list[b] - list[a] == c }
        answer = answer.coerceAtLeast(filter.sumBy { it.d })
    }

    dfs(listOf())

    println(answer)
}


Measured memory_bytes: 56156
#include <cstdio>
using namespace std;

int main()
{
	int n;
	scanf("%d",&n);

	int ar[]={1,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	printf("%d",ar[n]);
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	long long m=1e9+7;
    int n;
	int a[100000];
	scanf("%d",&n);
    for(int i=2;i<=n;i++){
    	int x=i;
        for(int j=2;j<=x;j++){
            while(x%j==0){
                a[j]++;
                x/=j;
            }
        }
    }
    long long res=1;
    for(int i=1;i<=n;i++){
        if(a[i]!=0){
        	res=(res*(a[i]+1))%m;
		}
    }
    printf("%lld",res);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
// #include <unordered_set>
// #include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

struct edge { int from, to, cost; };

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int V, E, r; cin >> V >> E >> r;
  vector<vector<edge> > points(V, vector<edge>());
  rep(i, E) {
    int s,t,d;
    cin >> s >> t >> d;
    points[s].push_back({s,t,d});
  }
  
  //ダイクストラ
  vector<int> dist(V, INF / 2);
  priority_queue<pii, vector<pii>, greater<pii> > que;
  que.push(mp(0, r));
  dist[r] = 0;
  
  while(!que.empty()) {
    pii p = que.top(); que.pop();
    int d = p.first;
    int v = p.second;
    if(dist[v] < d) continue;
    
    for(edge e : points[v]) {
      if(dist[e.from] + e.cost < dist[e.to]) {
        dist[e.to] = dist[e.from] + e.cost;
        que.push(mp(dist[e.to], e.to));
      }
    }
  }
  
  rep(i, V) {
    if(dist[i] == INF / 2) {
      fin("INF");
    } else {
      fin(dist[i]);
    }
  }
}


Measured memory_bytes: 15280
class Main{
    public static void main(String[] a){
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10 ; j++) {
				int calc = i * j;
				System.out.println(String.valueOf(i) + "x" + String.valueOf(j) + "=" + String.valueOf(calc));
			}
		}
    }
}

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

ll r, D, x;
int main() {
  cin >> r >> D >> x;

  rep(i, 10) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}


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

namespace Test01
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力1(N, K)
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = input[0];
            int K = input[1];
            //入力2(v)
            int[] v = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            long max = 0;  //答えの価値の最大値
            for(int i = 0; i <= Math.Min(N, K); i++)
            {
                for(int j = 0; j + i <= Math.Min(N, K); j++)
                {
                    List<int> bag = new List<int>();
                    long cur = 0;  //左からi個、右からj個とる時の価値
                    //左からi個、右からj個とる
                    for (int left = 0; left < i; left++) { bag.Add(v[left]); cur += v[left]; }
                    for (int right = N - 1; right > N - 1 - j; right--) { bag.Add(v[right]); cur += v[right]; }
                    bag = bag.OrderBy(x => x).ToList();
                    //残った操作回数でbag内の負の価値を捨てる
                    for (int k = 0; k + j + i < K && k < bag.Count; k++) if (bag[k] < 0) cur += Math.Abs(bag[k]);
                    max = Math.Max(max, cur);  //maxを更新
                }
            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 15444
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,dx=0,dy=0;
  string s,ans="";
  cin >> n >> s;
  for(int i=0;i<n;i++){
    if('A'<=s[i]&&s[i]<='M'){
      dy++;
    }else if('N'<=s[i]&&s[i]<='Z'){
      dy--;
    }else if('a'<=s[i]&&s[i]<='m'){
      dx++;
    }else{
      dx--;
    }
  }
  for(int i=0;i<n;i++){
    if('A'<=s[i]&&s[i]<='M'&&dy>0){
      ans+=s[i];
      dy--;
    }
    if('N'<=s[i]&&s[i]<='Z'&&dy<0){
      ans+=s[i];
      dy++;
    }
    if('a'<=s[i]&&s[i]<='m'&&dx>0){
      ans+=s[i];
      dx--;
    }
    if('n'<=s[i]&&s[i]<='z'&&dx<0){
      ans+=s[i];
      dx++;
    }
  }
  cout << ans.size()<<endl;
  cout <<ans << endl;
}



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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    v_int a(n);
    cin >> a;

    sort(a.begin(), a.end());
    int ans = 0;
    irep(i, k) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3596
#include <iostream>
using namespace std; 
int main()
{
    int m = 0;
    int f = 0;
    int r = 0;
    for(int i = 0; i < 100; i++){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        int s = m + f;
        if(m == -1 || f == -1){
            cout << "F" << endl;
        }else if(s >= 80){
            cout << "A" << endl;
        } else if(s >= 65){
            cout << "B" << endl;
        } else if(s >= 50){
            cout << "C" << endl;
        } else if(s >= 30){
            if(r >= 50){
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        } else {
            cout << "F" << endl;
        }
    }
    
	return 0;

}



Measured memory_bytes: 3072
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    R, G, B, N = map(int, input().split())

    ans = 0
    for r in range(N // R + 10):
        for g in range(N // G + 10):
            rest = N - R * r - G * g
            if rest < 0 or rest % B != 0:
                continue
            ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(void)
{
    int a;
    vector<int> v;
    for (int i = 0; i < 10; i++)
    {
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0] << "\n";
    cout << v[1] << "\n";
    cout << v[2] << "\n";
}



Measured memory_bytes: 3144
import collections

n = int(input())
ls = []
for i in range(n):
    s = input()
    ls.append(s)

c = collections.Counter(ls)

count = 0
if c.most_common()[0][1] >= 2:
    print("No")
else:
    for i in range(len(ls)-1):
        if ls[i][-1] == ls[i+1][0]:
            count += 1
    if count == len(ls)-1:
        print("Yes")
    else:
        print("No")
      

Measured memory_bytes: 3316