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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    string s; cin >> s;

    map<char, ll> mp;

    for(char c : s){
        mp[c]++;
    }

    if(mp.size()!=2){
        p_no();
        return 0;
    }

    for(auto pa : mp){
        if(pa.second!=2){
            p_no();
            return 0;
        }
    }
    p_yes();
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0){
				break;
			}
			int [][] dp = new int[y+2][x+2];
			int [][] data = new int[y+2][x+2];
			for(int i=1; i< y+1; i++){
				for(int j=1; j < x + 1; j++){
					data[i][j] = sc.nextInt();
				}
			}
			//set a first value
			for(int i=1; i < x+1; i++){
				dp[1][i] = 1;
			}

			//calc a dp
			for(int i=1; i <= y-1; i++){
				for(int j=1; j <= x; j++){
					int posSta = data[i][j];
					if(posSta == 1){
						continue;
					}
					else if(posSta == 2){
						dp[i+2][j] += dp[i][j];
					}
					else{
						//left buttom
						if(data[i+1][j-1] != 2){
							dp[i+1][j-1] += dp[i][j];
						}
						//buttom
						dp[i+1][j] += dp[i][j];

						//right buttom
						if(data[i+1][j+1] != 2){
							dp[i+1][j+1] += dp[i][j];
						}
					}
				}
			}

			//print
			int sum = 0;
			for(int i=y; i <= y + 1; i++){
				for(int j=1; j <= x; j++){
					if(data[i][j] == 1)
						continue;
					sum += dp[i][j];
				}
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define SORT(v) (sort(v.begin(),v.end()))
using ll = long long;
using namespace std;

void solve();

int main() {

	solve();
	return 0;

}

void solve() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) { cin >> a[i]; }
	deque<ll> deq;
	REP(i, n) {
		i % 2 ? deq.push_back(a[i]) : deq.push_front(a[i]);
	}
	REP(i, n) {
		if (n % 2 == 1) {
			cout << deq.front() << " ";
			deq.pop_front();
		}
		else {
			cout << deq.back() << " ";
			deq.pop_back();
		}
	}
	cout << endl;
}

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

int main() {
    int n;
	cin >> n;
    
    string s[n];
    int manag[55][26];
    for (int i = 0; i < 55; i++){
        for (int j = 0; j < 26; j++){
            manag[i][j] = 0;
        }
    }

    int mins[26];
    for (int i = 0; i < 26; i++){
        mins[i] = 100;
    }

    string b;
    for (int i = 0; i < n; ++i){
		cin >> b;
        for (int j = 0; j < b.size(); j++){
            manag[i][b[j] - 'a']++;
        }
    }
    
    for (int i = 0; i < 26; i++){
        for (int j = 0; j < n; j++){
            mins[i] = min(mins[i], manag[j][i]);
        }
    }

    string moji;
    for (int i = 0; i < 26; i++){
        for (int j = 0; j < mins[i]; j++){
            if(mins[i]>0){
                moji += 'a' + i;
            }
        }
    }
    if(!moji.empty()){
        cout << moji << endl;
    }else{
        cout << "" << endl;
    }
}

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

using namespace std;
typedef long long ll;

int main()
{
   int x ,n;
   cin >> x >> n;
   vector<int> v(n);
   for(int i=0;i<n;i++){
       cin >> v[i];
   }
    if(n ==0){
        cout << x <<endl;
    }else{
        
        bool a =true;
         for(int i =0;i<n;i++){
           if(x == v[i]){
               a= false;
               
            } 
        }
        if(a){cout << x <<endl;} 
        else{
             int k =1;bool is1 = true,is2 =true;
   while(true){
       for(int i =0;i<n;i++){
           if(x-k == v[i]){
               is1 =false;
               
            } 
        }
       if(is1){ cout << x-k << endl; break;}
       else{
          for(int i =0;i<n;i++){
           if(x+k == v[i]){
               is2 =false;
            
            } 
        }
        if(is2){
            cout << x+k << endl; break;
        } 
       }
       if(!is1&& !is2){
           k++; is1 =true;is2=true;
       }

   }
    }
   
        }  
       
       
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s;
int ans;
int main(void){
    int n; cin>>n;
    map<string,int> M;
    for(int i=0;i<n;i++){
        cin>>s;
        if(M[s]==0){
            M[s]++;
            ans++;
        }
    }
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 19184
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  const u64 a = scan<u64>();
  const u64 b = scan<u64>();
  std::vector<u64> x(n);
  for (auto &e : x) {
    std::cin >> e;
  }
  u64 ans = 0;
  for (const usize i : rep(1, n)) {
    ans += std::min(a * (x[i] - x[i - 1]), b);
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
n, m = map(int, input().split())
L = [1]*n
R = [1] + [0]*~-n
for _ in range(m):
  x, y = map(int, input().split())
  x -= 1;y -= 1
  if R[x]:R[y] = 1
  L[x] -= 1;L[y] += 1
  R[x] *= (L[x] > 0)
print(sum(R))

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

C2 = [0] * N
C5 = [0] * N

for i in range(N):
    a = str(input())
    dot_idx = -1
    for j in range(len(a)):
        if a[j] == '.':
            dot_idx = j
            break
    # .がないので末尾につける
    if dot_idx == -1:
        a += ".000000000"
    # .の場所に応じて後ろにつける
    else:
        while len(a) < 10+dot_idx:
            a += "0"
    tmps = ""
    for j in range(len(a)):
        if a[j] == '.':continue
        tmps += a[j]
    
    b = int(tmps)

    # 素因数2の個数
    tmp = b
    while tmp > 0 and tmp % 2 == 0:
        tmp //= 2
        C2[i] += 1
    while tmp > 0 and tmp % 5 == 0:
        tmp //= 5
        C5[i] += 1

Cc = [[0] * 19 for _ in range(19)]

for i in range(N):
    Cc[min(18, C2[i])][min(18, C5[i])]+=1

ans = 0
for i in range(N):
    if C2[i] >= 9 and C5[i] >= 9:
        ans -= 1
    l2 = max(0, 18 - C2[i])
    l5 = max(0, 18 - C5[i])
    for j in range(l2, 19):
        for k in range(l5, 19):
            ans += Cc[j][k]

print(ans//2)

Measured memory_bytes: 79108
def main():
    S = input()
    N = len(S)
    INF = N + 1
    T = input()
    # S で i 番目の何番目の後で文字 c が出てくるかを計算
    next_loc = [[INF for _ in range(N)] for _ in range(26)]
    for i, s in enumerate(S):
        c = ord(s) - ord('a')
        next_loc[c][i - 1] = 1
    for c in range(26):
        n = INF
        for i in range(N - 1, -(N + 1), -1):
            n = min(next_loc[c][i], n + 1)
            next_loc[c][i] = n
    # 答えを計算
    ans = 0
    index = -1
    for t in T:
        c = ord(t) - ord('a')
        i = next_loc[c][index]
        if i == INF:
            print(-1)
            return
        ans += i
        index = (index + i) % N
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 108336
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ll N,M;
	cin>>N>>M;
	vector< vector<char> > grid(N,vector<char>(M));
	for(ll i=0;i<N;i++)
	{
		for(ll j=0;j<M;j++)
		{
			cin>>grid[i][j];
		}
	}
	vector< vector<ll> > dp (N,vector<ll>(M,0));
	dp[0][0]=1;
	for(ll i=1;i<M;i++)
	{
		if(grid[0][i]=='.')
		{
			dp[0][i]=dp[0][i-1];
		}
	}
	for(ll i=1;i<N;i++)
	{
		if(grid[i][0]=='.')
		{
			dp[i][0]=dp[i-1][0];
		}
	}
	for(ll i=1 ;i<N;i++)
	{
		for(ll j=1;j<M;j++)
		{
			if(grid[i][j]=='.')
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[N-1][M-1]%mod;
}

Measured memory_bytes: 12104
#  AtCoder Beginners Contest 141 - B
# -*- encoding: UTF-8 -*-
slist = list(input())

result = "Yes"

while len(slist) > 0 :
  s1 = slist.pop(0)
  if s1 == "L" :
    result = "No"
    break
  if len(slist) > 0:
    s2 = slist.pop(0)
    if s2 == "R":
      result = "No"
      break

print(result)


Measured memory_bytes: 2940
import sys


def calc_cell(x, y):
	return '.' if (x + y) % 2 else '#'


def print_chessboard(height, width):
	for y in range(height):
		l = []
		for x in range(width):
			l.append(calc_cell(x, y))
		print ''.join(l)

if __name__ == '__main__':
	while True:
		h, w = map(int, sys.stdin.readline().split())
		print_chessboard(h, w)

		if not h or not w:
			break

		print

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

int main() {
  int N ;
  cin >> N ;
  N>=1;
  N<=100;
  string x; 
  int a,b,c,d;
  a=0;
  b=0;
  c=0;
  d=0;
  for(int i=0;i < N;i++){
    cin >> x;
    if(x=="P" && a==0){
     a=1;
    }
    else if (x=="P" && a==1){
      continue;
    }
    else if(x=="W" && b==0){
     b=1;
    }
    else if (x=="W" && b==1){
      continue;
    }
    else if(x=="G" && c==0){
     c=1;
    }
    else if (x=="G" && c==1){
      continue;
    }
    else if(x=="Y" && d==0){
     d=1;
    }
    else if (x=="Y" && d==1){
      continue;
    }
  }
  if(a+b+c+d == 3){
    cout << "Three" << endl;
  }
  else if (a+b+c+d == 4){
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  int q;
  cin>>q;
  string str;
  rep(i,q){
    int t;
    cin>>t;
    if(t==1) swap(str,s);
    else {
      int f;char c;
      cin>>f>>c;
      if(f==1) str+=c;
      else s+=c;
    }
  }
  reverse(all(str));
  str+=s;
  cout<<str<<endl;
}

Measured memory_bytes: 1128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

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

  double L; cin >> L;
  cout << (L/3)*(L/3)*(L/3) << endl;
  return 0;
}


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

int main(){
    string a = "aiueo";
    char c; cin >> c;
    for(int i = 0; i < 5; i++)
    {
        if(c==a[i]){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

int ans = 0;
REP(i,N){
    int cnt = 0;
    for(char c = 'a'; c <= 'z'; c++){ 
        bool left = false, right = false;

        for(int j = 0; j < i; j++){ 
            if(S[j] == c) left = true;
        }
        
        for(int j = i; j < N; j++){ 
            if(S[j] == c) right = true;
        }
        
        if(left&&right)cnt++;

}

ans = max(ans, cnt);
}

print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc135_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<ll> a(N + 1);
  rep(i, N + 1) { cin >> a[i]; }
  vector<ll> b(N);
  rep(i, N) { cin >> b[i]; }

  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());

  ll ans = 0;
  rep(i, N) {
    ll _a = a[i];
    ll _b = b[i];
    ans += min(_a, _b);
    a[i] = max(_a - _b, (ll)0);
    b[i] = max(_b - _a, (ll)0);
    if (b[i] != 0) {
      ll _a = a[i + 1];
      ll _b = b[i];
      ans += min(_a, _b);
      a[i + 1] = max(_a - _b, (ll)0);
      b[i] = max(_b - _a, (ll)0);
    }
  }

  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  for(int i=0; i<N; i++)cin >> A.at(i);
  
  vector<int>B(N);
  for(int i=0; i<N; i++)B.at(i)=A.at(i);
  
  sort(B.begin(), B.end());
  int Bmax1 = B.at(N-1);
  int Bmax2 = B.at(N-2);
  
  for(int i=0; i<N; i++){
    if(A.at(i)==Bmax1)cout << Bmax2 << endl;
    else cout << Bmax1 << endl;
  }
  
}

Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String str = sc.next();
    	sc.close();
    	int max = 0;
    	int tmp = 0;
    	for(int i = 0; i < str.length(); i++){
    		char c = str.charAt(i);
    		if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
    			tmp++;
    		}else{
    			tmp = 0;
    		}
    		if(max < tmp) max = tmp;
    	}
    	System.out.println(max);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

ll lpower(ll b, ll p){
    if(b  < 2){
        return b;
    }

    if(p == 0){
        return 1;
    }

    if(p == 1){
        return b;
    }

    ll x = lpower(b, p/2);
    x *= x;
    if(p % 2){
        x *= b;
    }

    return x;
}

inline ll rsum(ll r, ll n){
    return r * (lpower(r, n) - 1) / (r - 1);
}

string alphabet = "abcdefghijklmnopqrstuvwxyz";


void Main(){
    ll N;
    cin >> N;

    ll length, left;
    rep(i, 12){
        ll r_sum = rsum(26, i);
        if(r_sum >= N){
            length = i;
            left = N - rsum(26, i-1);
            break;
        }
    }

    // cout << "length=" <<length <<endl;

    vector<ll> diff;
    for(ll j=length-1;j>=0;j--){
        ll base = lpower(26, j);
        if(base < left){
            ll num = (left-1) / base;
            left = left - base * num;
            diff.emplace_back(num);
        }else{
            ll num = 0;
            diff.emplace_back(num);
        }
    }

    string ans = "";
    for(ll i=diff.size()-1;i>=0;i--){
        ans = alphabet[diff[i]] + ans;
    }

    // cout << diff <<endl;

    
    cout << ans <<endl;


}

int main(){
    Main();
}

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

using namespace std;

int main() {
  string S;
  bool ans = true;
  
  cin >> S;
  
  int len = S.length();
  
  if (len % 2 == 1) {
    ans = false;
  } else {
    for (int i = 0; i < len - 1; i += 2) {
      if (S[i] != 'h' || S[i + 1] != 'i') {
        ans = false;
        break;
      }
    }
  }
  
  cout << (ans ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#B
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse= True)
M = 0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if (i != j) and (i != k) and (j != k):
                if (L[i] != L[j]) and (L[i] != L[k]) and (L[j] != L[k]):
                    if ((L[i]+L[j]) > L[k]) and ((L[j]+L[k]) > L[i]) and ((L[i]+L[k]) > L[j]) :
                        M += 1 
                        #print(L[i],L[j],L[k],M)       
# 出力
print(M)

Measured memory_bytes: 9044
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] = - a[i]
q = []
for i in range(n):
    heapq.heappush(q, a[i])

for i in range(m):
    tmp = heapq.heappop(q)
    tmp = -tmp
    tmp = tmp // 2
    tmp = -tmp
    heapq.heappush(q, tmp)
print(-sum(q))

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

typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;
    
    ll cnt1=0, cnt2=0;
    ll ans=0;
    if(K%2==0){
        for(ll i=1; i<=N; i++){
            if(i%K==0){
                cnt1++;
            }
            else if((i%K==K/2)){
                cnt2++;
            }
        }
        ans = cnt1*cnt1*cnt1 + cnt2*cnt2*cnt2;
    }
    else {
        for(ll i=1; i<=N; i++){
            if(i%K==0){
                cnt1++;
            }
        }
        ans = cnt1*cnt1*cnt1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
struct sushi{
	long t;
	long d;
};
bool comp(const sushi& l,const sushi& r){
	return l.d>r.d;
}
int main(){
	int n,k;
	cin >> n >> k;
	vector<sushi> x(n);
	for(int i=0;i<n;i++) cin >> x[i].t >> x[i].d;
	
	sort(x.begin(),x.end(),comp);
	stack<int> s;
	int type[n+1]={};
	long taste=0,typenum=0;
	for(int i=0;i<k;i++){
		type[x[i].t]++;
		if(type[x[i].t]==1) typenum++;
		else s.push(x[i].d);
		taste+=x[i].d;
	}
	long ans=taste+typenum*typenum;
	for(int i=k;i<n;i++){
		if(s.empty()) break;
		type[x[i].t]++;
		if(type[x[i].t]==1) {
			typenum++;
			taste-=s.top();s.pop();
			taste+=x[i].d;
			ans=max(ans,taste+typenum*typenum);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2304
import itertools
N = int(input())
P = input().split()
Q = input().split()
num = ""
for i in range(1, N+1):
  num += str(i)
a = 0
b = 0
count = 0
for i in list(itertools.permutations(num)):
  count += 1
  if "".join(list(i)) == "".join(P):
    a = count
  if "".join(list(i)) == "".join(Q):
    b = count

print(abs(a-b))

Measured memory_bytes: 8052
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
ans = 0
for i in range(1,N+1):
	if i > 0 and i < 10:
		ans += 1
	elif i >= 100 and i < 1000:
		ans += 1
	elif i >= 10000 and i < 100000:
		ans += 1
print(ans)

Measured memory_bytes: 4208
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int s,w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}



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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  int n;

  while (cin >> n, n != 0){
    int mini = INF, maxi = 0;
    rep(i, n){
      int point[5];
      int sum = 0;
      rep(j, 5) point[i] = in(), sum += point[i];
      mini = min(mini, sum);
      maxi = max(maxi, sum);
    }
    cout << maxi << " " << mini << "\n";
  }

  return (0);
}

Measured memory_bytes: 3236
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int x[4]={1,-1,0,0};
int y[4]={0,0,1,-1};
int a[200][200],n,m,ans;
int cn,nn,mm,v[200][200],q[1000000][2];
char c;

void doit(int p,int qq)
{
	int t=0,w=0;
	q[0][0]=p;
	q[0][1]=qq;
	for (t=w=0;t<=w;t++)
	{
		for (int r=0;r<=3;r++)
		{
			int xx=q[t][0]+x[r];
			int yy=q[t][1]+y[r];
			if (a[xx][yy]==a[q[t][0]][q[t][1]] && v[xx][yy]==0)
			if (xx>0 && xx<=n && yy>0 && yy<=m)
			{
				w++;
				q[w][0]=xx;
				q[w][1]=yy;
				v[xx][yy]=1;
			}
		}
	}
}

int main(void)
{
	while(1)
	{
		memset(a,0,sizeof(a));
		memset(v,0,sizeof(v));
		ans=0;
		scanf("%d%d",&n,&m);
		if (n==0 && m==0)
		{
			break;
		}
		for (int i=1;i<=n;i++)
		{
			scanf("%c",&c);
			for (int j=1;j<=m;j++)
			{
				scanf("%c",&c);
				if (c=='#')
				a[i][j]=1;
				else
				if (c=='@')
				a[i][j]=2;
				else
				a[i][j]=3;
			}
		}
		for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		{
			if (v[i][j]==0)
			{
				ans++;
				doit(i,j);
			}
		}		
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
 
int main(void){
    for(int a, b, c; cin >> a >> b >> c;){
        int s = a + b, cnt = 0;

        rep(i, 10){
            if(i + 1 == a || i + 1 == b || i + 1 == c) continue;
            if(20 < s + i + 1) break;
            cnt ++;
        }
        string res = 0.5 <= cnt / 7. ? "YES":"NO";

        cout << res << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a*b > c*d){
    printf("%d\n",a*b);
  }else{
    printf("%d\n",c*d);
  }
  return 0;
}



Measured memory_bytes: 128
h, w = $stdin.readline.chomp.split.map(&:to_i)
dp = Array.new(h) { Array.new(w) }
q = []
h.times do |i|
  a = $stdin.readline.chomp.chars
  w.times do |j|
    if a[j] == "#"
      q << [i, j]
      dp[i][j] = 0
    end
  end
end

d = [[0, -1], [0, 1], [-1, 0], [1, 0]]
while !q.empty?
  x, y = q.pop
  d.each do |dx, dy|
    nx = x + dx
    ny = y + dy
    next if nx < 0 || nx >= h || ny < 0 || ny >= w
    next if !dp[nx][ny].nil?

    dp[nx][ny] = dp[x][y] + 1
    q.unshift([nx, ny])
  end
end
puts dp.flatten.max

Measured memory_bytes: 92456
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		//3っつの整数を昇順に並び替える
		Scanner sc=new Scanner(System.in);
		int[] num_ary=new int[3];
		for(int i=0;i<3;i++){
			num_ary[i]=sc.nextInt();
		}
		Arrays.sort(num_ary);
		System.out.println(num_ary[0]+" "+num_ary[1]+" "+num_ary[2]);
	}

}



Measured memory_bytes: 26436
#include<stdio.h>

void countingSort(int,int);
int A[2000001];
int B[2000001];
int main()
{
  int n,i,k;

  scanf("%d",&n);

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

  k=A[0];
  
  for(i=1; i<n; i++){
    if(k<A[i]) {
      k=A[i];
    }
  }
  countingSort(n,k);
  
  for(i=1; i<n; i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);

  return 0;
}

void countingSort(int n,int k){
  int i,j;
  int C[200000];
  
  for(i=0; i<=k; i++){
    C[i] = 0;
  }
  
  for(j=0; j<n; j++){
    C[A[j]]++;
  }
  
  for(i=1; i<=k; i++){
      C[i] += C[i-1];
  }
  
  for(j=n-1; j>=0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}


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

using namespace std;

int n;
double data[100005];

main()
{
  int up = 0;
  int ter;
  int min = (-1) & 0x7fffffff;
  int down;

  cin >> n;
  for ( int i = 0; i < n; i++) {
    cin >> data[i];
    data[i] *= 2;

    if ( up < data[i] ){
      up = data[i];
    }
  }

  ter = up / 2;
  sort(data, data + n);

  for ( int i = 0; i < n; i++) {
    if ( abs(data[i] - ter) < min) {
      min = abs(data[i] - ter);
      down = data[i];
    }
  }

  printf("%d %d\n", up / 2, down / 2);

  return (0);
}


Measured memory_bytes: 1024
// Aizu Vol-2 0286: Computation of Salary
// 2017.8.20 bal4u@uu
// 2017.11.5 retry

#include <stdio.h>

#define MAX 10000
#define MAX2 500000

typedef struct { int n, nxt, end; } WAK;
typedef struct { int nxt, t, e; } LNK;

WAK wak[MAX+5];
LNK lnk[MAX2+5]; int used;
int b[MAX+5];

char buf[100002], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

char tmp[13], *q;
void pr(int n)
{
	if (!n) { *p++ = '0', *p++ = ' '; return; }
	q = tmp; while (n) {
		*++q = '0' + (n % 10);
		n /= 10;
	}
	while (*q) *p++ = *q--;
	*p++ = ' ';
}

int main()
{
	int N, M, L, i, j, k, ans;
	WAK *w;

	fgets(p=buf, 20, stdin), N = getint(), p++, M = getint();
	while (fgets(p=buf, 30, stdin) && *p != '0') {
		w = wak + getint(), p++, lnk[used].t = getint(), p++, lnk[used].e = getint();
		if (w->n == 0) w->nxt = used;
		else lnk[w->end].nxt = used;
		w->end = used++, w->n++;
	}
	fgets(p=buf, 10, stdin), L = getint();
	while (L--) {
		fgets(p=buf, 100000, stdin);
		for (i = 1; i <= M; i++) b[i] = getint(), p++;
		for (p = buf, w = wak+1, i = N; i--; w++) {
			if (w->n == 0) { *p++ = '0', *p++ = ' '; continue; }
			for (ans = 0, k = w->nxt, j = w->n; j > 0; j--, k = lnk[k].nxt)
				ans += lnk[k].e * b[lnk[k].t];
			pr(ans);
		}
		*--p = 0, puts(buf);
	}
	return 0;
}

Measured memory_bytes: 2392
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve(s, MAX):
    if s < 3:
        return 0
    elif s < 6:
        return 1
    a = 1
    b = 1
    c = 1
    num = 6
    while num <= s:
        tmp = a
        a = b
        b = c
        c += tmp
        c %= MAX
        num += 1
    return c


MAX=10**9+7
s = int(input())
res = solve(s, MAX)

print(res)



Measured memory_bytes: 9180
package main 

import (
	"fmt"
)

func main () {
	var n, x, m, an ,lo, ko int
	s :=[]int{}
	ta := 0
	a :=0
	fmt.Scan(&n, &x)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&m)
		s = append(s, m)
	}
	for {
		x = x - s[a]
		a += 1
		an +=1
		if a == len(s) {
			break
		}
	}
	for x :=0 ; x < len(s) ; x++{
		ko = s[ta]
		ta +=1
		if lo == 0{
			lo = ko
		} else if ko < lo{
			lo = ko
		}
	}

	for {
		x = x -lo
		an +=1
		if x == 0{
			break
		}  else if x < 0 {
			an -=1
			break
		}
	}

	fmt.Println(an)
}

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

using namespace std;

int main(){
  int n; cin >> n;
  map < pair < int, int >, int> mp;
  for(int i = 0; i < n; i++){
    double x; cin >> x;
    long long tmp = llround(x * 1e9);
    int cnt2 = 0, cnt5 = 0;
    while(tmp % 2 == 0){
      cnt2++;
      tmp /= 2;
    }
    while(tmp % 5 == 0){
      cnt5++;
      tmp /= 5;
    }
    mp[{cnt2, cnt5}]++;
  }
  long long ans = 0;
  for(auto x : mp){
    for(auto y : mp){
      if(x.first.first + y.first.first >= 18 and x.first.second + y.first.second >= 18) {
        if(x < y)
          ans += (long long)(x.second * 1ll * y.second);
        else if(x == y){
          ans += (long long)(x.second) * 1ll * (x.second - 1) / 2;
        }
      }
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3756
N=int(input())
ue=[0]*(N+1)
shita=[0]*(N+1)
for i,a in enumerate(list(map(int,input().split()))):
    ue[i]=ue[i-1]+a

for i,a in enumerate(list(map(int,input().split()))):
    shita[i]=shita[i-1]+a
ans=0
for i in range(N):
    ans=max(ans,ue[i]+shita[N-1]-shita[i-1])
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int n,k;
    int i,j,l,m,point;
    double result = 0.0;
    scanf("%d %d", &n, &k);
    
    for(i = 1; i <= n; i++){
        j = 0;
        point = i;
        while(point < k){
            point *= 2;
            j++;
        }
        
        m = 1;
        for(l = 1; l <= j; l++){
            m *= 2;
        }
        result += ((double)1 / m);
    }
    result /= n;
    
    printf("%.10f\n", result);
    
    return 0;
}

Measured memory_bytes: 128
my $N = <STDIN>;
my ($D, $X) = split(/ /, <STDIN>);
my $t = $X;
foreach my $i (0..$N-1) {
        my $fac = <STDIN>;
        my @tmp;
        my $j = 1;
        while ($D >= $j) {
                $t++;
                $j += $fac;
        }
}
print $t;

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

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

  int n; cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n - 1; ++i) {
    cin >> b[i];
  }

  int sum_a = 0;
  sum_a += b[0];
  for (int i = 1; i < n - 1; ++i) {
    sum_a += min(b[i - 1], b[i]);
  }
  sum_a += b[n - 2];
  cout << sum_a << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = Array.new(1)
count = 1

n.times do
  a << gets.chomp.to_i
end
idx = a[1]
 
while idx != 2 && count <= n
  idx = a[idx]
  count += 1
end

if count > n
  puts "-1"
  exit 
end

puts count

Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const int MAX=1e5+1;
const ll INF=1e9;

int main()
{
    string s;
    cin>>s;
    string map={"ACGT"};
    int ans=0;
    int lans=0;
    bool flag;
    rep(i,s.size())
    {
        flag=false;
        rep(j,4)
        {
            if(s[i]==map[j])flag=true;
        }
        if(flag)
        {
            ans++;
        }
        else
        {
            lans=max(lans,ans);
            ans=0;
        }
        lans=max(lans,ans);
        
    }
    cout<<lans;

}

Measured memory_bytes: 256
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	if(b<a) a--;
	cout<<a;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
mod=998244353
n=ii()
arr=limii()

if arr[0]!=0:
    print(0)
    exit()

if n==1 and arr[0]==0:
    print(1)
    exit()


chk=True

p=Counter(arr)

if p[0]!=1:
    print(0)
    exit()

tmp=0
for i in range(1,max(list(p))+1):
    if p[i]>0:
        pass
    else:
        print(0)
        exit()

ans=1

#掛け算の場合
# (a*b)%mod と同等
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

#割り算の場合
# (a//b)%mod と同等
def div(a,b):
    return a*pow(b, mod-2, mod)

#累乗の場合
#a**n %p と同等
def p_f(a,n,pp):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %pp
        if bi[i]=="1":
            res=(res*a) %pp
    return res

for i in range(max(p.keys())):
    
    ans=(ans*pow(p[i], p[i+1], mod)) %mod
    
print(ans%mod)

Measured memory_bytes: 20416
program main
implicit None
integer(8)::n,x,s,i
integer(8),allocatable::a(:)

	read *,n,x
	allocate(a(n))
	read *,a
	call hsort(a,n)
	
	s = 0
	do i = 1,n
		s = s + a(i)
		if(s > x)then
			exit
		endif
	enddo
	
	if((x-s) >= 0) i = i-1
	if((x-s)/=0) i = i-1
	
	if(i < 0) i = 0
	
	print 101,i
	
101 format(i0)
end program main

subroutine makeheap(a,n)
Implicit None
	integer(8)::n,i,c1,c2,p,t,m
	integer(8)::a(n)
	
	do i = n/2,1,-1
		p = i; c1 = i * 2
		do while (c1 <= n)
			c2 = c1 + 1
			if(c2 <= n .and. a(c2) > a(c1)) c1 = c2
			if(a(p) < a(c1))then
				t = a(p)
				a(p) = a(c1)
				a(c1) = t
				p = c1
				c1 = p*2
				else
					exit
			endif
		enddo
	enddo
	
end subroutine makeheap

subroutine hsort(a,n)
Implicit None
	integer(8)::n,t,i,p,c1,c2,j
	integer(8)::a(n)
	
	call makeheap(a,n)
	
	do i = n,2,-1
		t = a(i)
		a(i) = a(1)
		a(1) = t
		
		p = 1
		do
			c1 = p*2
			if (c1 >= i) exit
			
			c2 = c1 +1
			if(c2 < i .and. a(c2) > a(c1))then
					c1 = c2
			endif
			
			if(a(c1) >a(p))then
				t = a(p)
				a(p) = a(c1)
				a(c1) = t
				p = c1
				else
					exit
			endif
		enddo
	enddo
end subroutine hsort

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

int main() {
 int n; cin >> n;
 vector<int> p(n);
 int cnt=1;
 rep(i,n) cin >> p[i];
 int min_element=p[0];
 rep1(i,n){
  if(p[i]<min_element){
    cnt++; 
    min_element=p[i];
  }
}
 cout << cnt << endl;

}


Measured memory_bytes: 1024
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    double ans = 0.0;
    vector<double> v;
    int n = read();
    rep(i, 1, n) {
        int t = read();
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    ans = (v[0] + v[1]) / 2.0;
    for (int i = 2; i < v.size(); ++i) {
        ans = (ans + v[i]) / 2.0;
    }
    printf("%.5f\n", ans);

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    tree = [[] for  _ in range(N)]
    abs = []
    for _ in range(N-1):
        a, b = read_ints()
        a -= 1
        b -= 1
        abs.append((a, b))
        tree[a].append(b)
    Q = [(0, -1)]
    colors = {}
    color_count = 0
    while Q:
        node, color = Q.pop()
        c = 1
        for child in tree[node]:
            if color == c:
                c += 1
            colors[(node, child)] = c
            Q.append((child, c))
            color_count = max(color_count, c)
            c += 1
    print(color_count)
    for ab in abs:
        print(colors[ab])


if __name__ == '__main__':
    solve()


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

using namespace std;

const int DZIESTYS  = 1e5;

int howMany[DZIESTYS + 1];
int tabMax = 0;

void update(int i)
{
	howMany[i]++;
	if (howMany[i] > tabMax)
		tabMax = howMany[i];
}

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

	for (int i = 0; i < n; ++i)
	{
		int a;
		scanf("%d", &a);

		update(a);
		update(a + 1);
		if (a > 0)
			update(a - 1);
	}

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

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


void fibonacci(int n){
  vector<int> fib;

  fib.push_back(1);
  fib.push_back(1);

  if(n < 2){
    cout << "1" << endl;
  }else if(n == 2){
    fib.push_back(fib.at(0) + fib.at(1));
    cout << fib.back() << endl;
  }else{
    for(int i = 2;i < n+1;i++){
      fib.push_back(fib.at(i - 2) + fib.at(i - 1));
    }
      cout << fib.back() << endl;
  }

}

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

  return 0;
}



Measured memory_bytes: 3152
#include<stdio.h>

int main(){
    int x[5], h;
    for(int i=0; i<sizeof(x)/sizeof(int);i++){
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < sizeof(x) / sizeof(int); i++) {
        if(x[i]==0) h = i + 1;
    }
    printf("%d\n", h);
}

Measured memory_bytes: 1664
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
num = c
count = 0
for i in range(n):
  a = list(map(int, input().split()))
  for j in range(m):
    num += a[j]*b[j]
  if num > 0:
    count += 1
    num = c
  else:
    num = c
print(count)

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

using namespace std;

using ll = long long;
const ll MOD = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

ll S;


ll modpow(ll x, ll n) {
  x = x%MOD;
  if(n==0) return 1;  //再帰の終了条件

  else if(n%2==1) {
    return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
  }
  else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll h_num (ll a, ll b) {
    ll f1 = a + b - 1;
    return (((fac[f1] * ifac[a]) % MOD) * ifac[b - 1]) % MOD;
}

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

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

    fac[0] = 1;
    ifac[0] = 1;

    for(ll i = 0; i<1000000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*modpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll n = S / 3;
    ll ex = S % 3;

    ll sum = 0;

    while (n >= 1){ // とりあえず2組以上
        // ex個のボールが誰の所有物か求める(誰でもいい)
        ll num = h_num(ex, n);
        // 足しこむ
        sum += num;
        sum %= MOD;
        --n;
        ex += 3;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 18688
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

int A, B;
int V, W;
int T;

void read_input()
{
    cin >> A >> V >> B >> W >> T;
}

void solve()
{
    if(V <= W)
    {
        cout << "NO\n";
        return;
    }
    int dist = abs(A - B), delta = V - W;
    if(dist <= T * 1LL * delta)
        cout << "YES\n";
    else cout << "NO\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;

int dp[N][3],n,arr[N][3];

int knapsack(int i, int c)
{
    //cout<< i<<" ";
    bool flag = 0;
    if (i==n) return 0;
    int &ret = dp[i][c];
    if(ret!=-1)
    {
        return ret;
    }

    int op1, op2;
    //cout<<"Passed\n";

    op1 = knapsack(i+1, (c+1)%3)+arr[i][(c+1)%3];
    op2 = knapsack(i+1, (c+2)%3)+arr[i][(c+2)%3];



    return ret=max(op1,op2);
}


int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    cout<<max(knapsack(0,0),max(knapsack(0,1),knapsack(0,2)));
}


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

namespace algorithm
{
	class Program
	{
		public static void Main()
		{
			int[] nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			int k = nm[1]-1;
			List<long> q = new List<long>();
			for (int i = 0; i < nm[0]; i++)
			{
				q.Add(long.Parse(Console.ReadLine()));
			}
			q.Sort();
			long min = q[k] - q[0];
			for (int i = 0; i < q.Count - k; i++)
			{
				min = Math.Min(min, q[i + k]-q[i]);
			} 
			Console.WriteLine(min);



		}





	}

}




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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int k, A, B;
    cin >> k;
    cin >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3620
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
res=sum(B)

for i in range(n-1):
	if A[i+1]-A[i]==1:
		res += C[A[i]-1]
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	string t;
	cin >> t;

	for (int i = 0; i < t.size(); ++i) {
		if (t[i] == '?') { t[i] = 'D'; }
	}
	cout << t << endl;

	return 0;
}


Measured memory_bytes: 3752