akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int n;
int t[16][17];	//stage , item
int dp[1<<16];

int main(){
	while(cin>>n,n!=0){
		for(int i=0;i<n;i++){
			for(int j=0;j<=n;j++) cin>>t[i][j];
		}
		for(int i=1;i<(1<<n);i++) dp[i]=1000000000;
		dp[0]=0;
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				int b=1<<j;
				if(i & b) continue;
				int cost=t[j][0];
				for(int k=0;k<n;k++){
					if(i & (1<<k)) cost=min(cost,t[j][k+1]);
				}
				dp[i+b]=min(dp[i+b],dp[i]+cost);
			}
		}
		cout<<dp[(1<<n)-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3332
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
int main() {
	double n, m, d;
	cin >> n >> m >> d;
	printf("%f\n", (n - d) / n / n * (d == 0 ? 1 : 2) * (m - 1));
	return 0;
}


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

#define ll long long int
#define pb push_back
#define MP make_pair
#define PLL pair<ll,ll>
#define fastio ios::sync_with_stdio(0);cin.tie(0);

ll arr[1000009];
int main()
{
  ll n;
  cin >> n;
  ll val = n%10;
  if(val==1 || val==0 || val==6 || val==8)
  cout << "pon"<<'\n';
  else if(val==3)
  cout <<"bon"<<'\n';
  else
  cout<<"hon";
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <cassert>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int N = 500 + 7;
const int M = 20;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * N * 1000;
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;


string s[N];
int col[N], row[N];
int n;
bool has = false;

int a[N][N];

int fullRow = 0, fullCol = 0;

bool colHas[N], rowHas[N];

void solve() {
    cin >> n;
    rep(i, 0, n) {
        cin >> s[i];
        rep(j, 0, n) {
            a[i][j] = (s[i][j] == '#');
            
            if (a[i][j]) {
                has |= a[i][j];
                row[i] ++;
                col[j] ++;
            
                if (col[j] == n) fullCol++;
                if (row[i] == n) fullRow ++;
                
                colHas[i] = 1;
                rowHas[j] = 1;
            }
        }
    }
    
    if (!has) {
        cout << -1 << '\n';
        return;
    }
    
    if (fullCol == n) {
        cout << 0 << '\n';
        return;
    }
    
    if (fullRow > 0) {
        cout << n - fullCol << '\n';
        return;
    }
    
    int ans = inf;
    
//    for(int i = 0; i < n; ++i) {
//        for(int j = 0; j < n; ++j) {
//            if (a[i][j]) {
//                            }
//        }
//    }
    
    rep(j, 0, n) if (rowHas[j]) {
        int tol = n - row[j];
        ans = min(ans, n + tol - fullCol);
    } else {
        rep(u, 0, n) {
            rep(v, 0, n) {
                
                int tol = n - row[j] + 1;
                if (a[j][j]) tol ++;
                if (a[u][j]) tol --;
                
                ans = min(ans, n + tol - fullCol);
                
            }
        }
    }
    
    
    
    cout << ans << '\n';
    
    
    
}


int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //t1=clock();
#endif
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
    }
    
#ifdef _LOCAL_
    cout<<"\n" << clock() / CLOCKS_PER_SEC<<endl;
#endif
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <sstream>
#include <set>
#include <queue>

using namespace std;

#define For(i,a,n)	for(int i = a;i < n;i++)
#define rep(i,n)	For(i,0,n)
#define clr(n)		memset(n,0,sizeof n)
#define all(n)		(n).begin(),(n).end()

const int INF = 1e9;
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
bool cheak(int x, int y, int mx, int my){
	return x >= 0 && y >= 0 && x < mx &&  y < my;
}

int main()
{
	int n;
	cin >> n;
	rep(_, n){
		int h, w;
		char d[51][51];
		cin >> h >> w;
		rep(y, h)rep(x, w){
			cin >> d[y][x];
		}

		bool f = false;
		set<char> vs[256];
		For(ct, 'A', 'Z' + 1){
			int rx = -1, ry = -1;
			int lx = 51, ly = 51;
			rep(y, h)rep(x, w){
				if (d[y][x] == ct){
					lx = min(lx, x), ly = min(ly, y);
					rx = max(rx, x), ry = max(ry, y);
				}
			}
			set<char> v;
			For(y, ly, ry + 1)For(x, lx, rx + 1){
				if (d[y][x] == '.'){
					f = true; goto End;
				}
				if (d[y][x] != ct){
					v.insert(d[y][x]);
				}
			}
			vs[ct] = v;
		}
		rep(i, 256){
			if (vs[i].size()){
				queue<pair<char,vector<bool>>> q;
				for (auto j : vs[i]){
					vector<bool> cf(256, 0);
					cf[i] = true;
					cf[j] = true;
					q.push(make_pair(j,cf));
				}
				while (q.size()){
					auto now = q.front(); q.pop();
					for (auto j : vs[now.first]){
						auto tf = now.second;
						if (tf[j]){
							f = true; goto End;
						}
						tf[j] = true;
						q.push(make_pair(j,tf));
					}
				}
			}
		}
	End:;

		if (f)cout << "SUSPICIOUS" << endl;
		else  cout << "SAFE" << endl;

	}
	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;
public class Main {
 
  public static int partition(int arr[], int low, int high) 
    { 
        int pivot = arr[high];  
        int i = (low-1); 
        for (int j=low; j<high; j++) 
        { 
            
            if (arr[j] <= pivot) 
            { 
                i++; 
                int temp = arr[i]; 
                arr[i] = arr[j]; 
                arr[j] = temp; 
            } 
        } 
               int temp = arr[i+1]; 
        arr[i+1] = arr[high]; 
        arr[high] = temp; 
  
        return i+1; 
    } 
  
 public static void sort(int arr[], int low, int high) 
    { 
        if (low < high) 
        { 
            /* pi is partitioning index, arr[pi] is  
              now at right place */
            int pi = partition(arr, low, high); 
  
            // Recursively sort elements before 
            // partition and after partition 
            sort(arr, low, pi-1); 
            sort(arr, pi+1, high); 
        } 
    } 
  
    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int [] arr=new int[3];
    
      arr[0]=sc.nextInt();
      arr[1]=sc.nextInt();
      arr[2]=sc.nextInt();
      
      sort(arr,0,2);
       String s=String.valueOf(arr[2]);
       s=s+String.valueOf(arr[1]);
       int sum=Integer.valueOf(s)+arr[0];
       System.out.println(sum);
      
    
    
    }
    
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int cnt = 0;
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n){
        if(i == n-1 && v[i] == i+1) cnt++;
        else if(v[i] == i+1){
            cnt++;
            swap(v[i],v[i+1]);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
using namespace std;
struct T{
    int parent,children,depth,right;
};
void maketree(T tree[]){
    int node,k,m,tmp;
    cin>>node>>k;
    for(int j=0;j<k;j++){
        cin>>m;
        if(j==0){
            tree[node].children=m;
        }
        else{
            tree[tmp].right=m;
        }
        tmp=m;
        tree[m].parent=node;
        tree[m].depth=tree[node].depth+1;
    }
}
void depth(int root,T tree[]){
    int l=tree[root].children;
   if(tree[l].children!=-1 && l!=-1){
        depth(l,tree);
    }
    if(l!=-1){
        tree[l].depth=tree[root].depth+1;
        while(tree[l].right!=-1){
            tree[tree[l].right].depth=tree[l].depth;
            l = tree[l].right;
        }
    }
}
int main(){
    T tree[100000];
    int n,root=0;
    cin>>n;
    for(int i=0;i<n;i++){
        tree[i].depth=0;
        tree[i].parent=-1;
        tree[i].children=-1;
        tree[i].right=-1;
    }
    for(int i=0;i<n;i++){
        maketree(tree);
    }
    while(tree[root].parent!=-1){
        root=tree[root].parent;
    }
    depth(root,tree);
    for(int i=0;i<n;i++){
        cout<<"node "<<i<<": parent = "<<tree[i].parent<<", depth = "<<tree[i].depth;
        if(tree[i].depth==0){
            cout<<", root, [";
        }
        else if(tree[i].children==-1){
            cout<<", leaf, [";
        }
        else{
            cout<<", internal node, [";
        }
        if(tree[i].children!=-1){
            cout<<tree[i].children;
        }
        int l=tree[i].children;
        while(tree[l].right!=-1 && tree[i].children!=-1){
            cout<<','<<" "<<tree[l].right;
            l=tree[l].right;
        }
        cout<<']'<<endl;
    }
    return 0;
}


Measured memory_bytes: 4664
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli X, A;
	cin >> X >> A;

	if (X >= A) {
		COUT(10);
	}
	else {
		COUT(0);
	}


	return 0;
}

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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,r,x,y,m,n;
    	cin>>n;
    	vi co(N,0);
    	x=n;
    	for(i=2;i<=sqrt(n);i++)
    	{
    		j=0;
    		while((x%i)==0)
    		{
    			co[i]++;
    			x=x/i;
    		}
    	}
    	ll ans=0;
    	if(x!=1)ans=1;
    	for(i=2;i<=sqrt(n);i++)
    	{
    		if(co[i]==0)continue;
    		for(j=1;j<=sqrt(n);j++)
    		{
    			if((j*(j+1))/2>co[i])break;
    			ans++;
    		}
    	}
    	cout<<ans;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N)
  cin >> H[i];
  int ans = 1;
  for (int i = 1; i < N; i++)
  {
    bool flag = true;
    for (int j = 0; j < i; j++)
    {
      if (H[j] > H[i])
      {
        flag = false;
      }
    }
    if (flag)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	int  a,b;
	int k;
	cin >> a>> b;
	if (a > 0) {
		cout << "Positive" << endl;
	}
	else {
		if (a == 0) {
			cout << "Zero" << endl;
		}
		else {
			if (b >= 0) {
				cout << "Zero" << endl;
			}
			else {
				k = b - a;
				if (k%2 == 0) {
					cout << "Negative" << endl;
				}
				else {
					cout << "Positive" << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;




void solve(){
    int n;
    string s;
    cin>>n>>s;
    if(n >= s.length())cout<<s;
    else{
        f(i,n)cout<<s[i];
        cout<<"...";
    }
}

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


Measured memory_bytes: 3632
#include <stdio.h>

int main () {
	int n;
	int a;
	int f = 0;

	scanf ("%d", &n);

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

	printf ("%d\n", f);
	return 0;
}



Measured memory_bytes: 128
module IO = struct

  (* @since 4.04.0 *)
  let split_on_char sep s =
    let open String in
    let r = ref [] in
    let j = ref (length s) in
    for i = length s - 1 downto 0 do
      if get s i = sep then begin
        r := sub s (i + 1) (!j - i - 1) :: !r;
        j := i
      end
    done;
    sub s 0 !j :: !r

  let read_ss () = read_line () |> split_on_char ' '

  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string

end

module SegmentTree = struct

  let default_val = ref 0

  let size = ref 0

  let make n init =
    default_val := init;
    let rec pow_of_2 i =
      if i > n then i
      else pow_of_2 (2 * i) in
    size := pow_of_2 1;
    Array.make (2 * (!size)) init

  let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

  let left i = 2*i + 1

  let right i = 2*i + 2

  let add s i x =
    let j = !size + i - 1 in
    s.(j) <- x + s.(j);
    let rec doit j =
      if j <= 0 then () else begin
        let p = parent j in
        s.(p) <- s.(left p) + s.(right p);
        doit p
      end in
    doit j

  let sum s a b =
    let rec doit k l r =
      if r < a || b < l then 0
      else if a <= l && r <= b then s.(k)
      else
        let m = (l + r) / 2 in
        doit (left k) l m + doit (right k) (m + 1) r in
    doit 0 0 (!size - 1)

end

module S = SegmentTree

let solve n q =
  let s = S.make n 0 in
  for _ = 0 to q - 1 do
    match IO.read_ns () with
    | c :: x :: y :: _ ->
      if c = 0 then S.add s x y
      else begin
        S.sum s x y |> print_int;
        print_newline ();
      end
    | _ -> assert false
  done

let () =
  match IO.read_ns () with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6436
N, M = list(map(int, input().split()))
X = [int(i) for i in input().split()]

if N >= M:
    print(0)
else:
    X.sort()
    if M == 2:
        print(X[1] - X[0])
    else:
        l = []
        for i in range(M-1):
            l.append(X[i+1] - X[i])
        l.sort()
        if N == 1:
            print(sum(l))
        else:
            print(sum(l[:-(N-1)]))




Measured memory_bytes: 13840
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<int>> vec(h, vector<int>(w));
    for(int i = 0; i < n; ++i){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            for(int i = 0; i < h; ++i){
                for(int j = 0; j < x; ++j){
                    vec.at(i).at(j) = 1;
                }
            }
        }
        if(a == 2){
            for(int i = 0; i < h; ++i){
                for(int j = x; j < w; ++j){
                    vec.at(i).at(j) = 1;
                }
            }
        }
        if(a == 3){
            for(int i = 0; i < y; ++i){
                for(int j = 0; j < w; ++j){
                    vec.at(i).at(j) = 1;
                }
            }
        }
        if(a == 4){
            for(int i = y; i < h; ++i){
                for(int j = 0; j < w; ++j){
                    vec.at(i).at(j) = 1;
                }
            }
        }
    }
    int sum = 0;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(vec.at(i).at(j) == 0){
                sum += 1;
            }
        }
    }
    cout << sum << nl;
}
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m[11];
    scanf("%d",&n);
    scanf("%s",&m);
getchar();
    if(n>=3200)
    {
        printf("%s\n",m);
    }
    else
    {
        printf("red\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,s,ten = 0,oth = 0;vector<int> other;cin >> n;
  while(cin>>s){
    if(s%10==0) ten += s;
    else{
      other.push_back(s);oth += s;
    }
  }
  sort(other.begin(),other.end());
  if(oth == 0) cout << 0 << endl;
  else if(oth%10 == 0) cout << ten+oth-other[0] << endl;
  else cout << ten+oth << endl;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
def alg(num)
  ans = ''
  bn = ''
  cn = 0
  num.to_s.split('').each do |n|
    if bn == ''
      bn = n
      cn = 1
      next
    end

    if n == bn
      cn += 1
    else
      ans << cn.to_s
      ans << bn
      bn = n
      cn = 1
    end
  end
  ans << cn.to_s
  ans << bn
  ans
end

while (n = gets.chomp.to_i) != 0
  num = gets.chomp
  n.times do
    num = alg(num)
  end
  puts num
end

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll inf = 1e18+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n; 
    ll h[n]; 
    rep(i,0,n) cin >> h[i]; 
    ll dp[100010];
    rep(i,0,100010) dp[i] = inf;
    dp[0] = 0;
    rep(i,0,n){
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import sys

#+++++

def reg(i):
	d1 = i // 10
	d2 = i % 10
	if d1 < 2 or d2 < 2:
		return -1
	else:
		return d1 * d2

def main():
	m , d = map(int, input().split())
	
	ret=0
	for i in range(1,d+1):
		aa= reg(i)
		if aa == -1:
			continue
		if aa <= m:
			ret += 1
	print(ret)
	
	
#+++++


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;
	
    return 0;
}

Measured memory_bytes: 256
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/
 
int main(){
	FIO
	
	int n,k,r,s,p;cin >> n >> k >> r >> s >> p;
	string t;cin >> t;
	int ans = 0;
	vector<char> moves;
	forn(i,k){
		if(t[i] == 'r'){
			ans+=p;
			moves.pb('p');
		}
		else if(t[i] =='p'){
			ans+=s;
			moves.pb('s');
		}
		else{
			ans+=r;
			moves.pb('r');
		}
	}
	for(int i = k ;i <t.size();i++){
		if(t[i] == 'r'){
			if(moves[i-k]!='p'){
				ans+=p;
				moves.pb('p');
			}
			else moves.pb('?');
		}
		else if(t[i] =='p'){
			if(moves[i-k]!='s'){
				ans+=s;
				moves.pb('s');
			}
			else moves.pb('?');
		}
		else{
			if(moves[i-k]!='r'){
				ans+=r;
				moves.pb('r');
			}
			else moves.pb('?');
		}
	}
	cout << ans;  
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double 
#define vpi vector<pair <int, int> >
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pair<ll, ll> >
#define pb push_back
#define mp make_pair
#define all(p) (p).begin(), (p).end()
#define fi first
#define se second
#define mem(a) memset(a, 0 , sizeof(a))
#define mod 1e9+7
#define inf 100000000007
#define N 100002
vi a(N);

int main(){
	ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL);
	int n, ma=0;
	cin >> n;
	
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	if(a[1] == 1){
		a[2] += a[1];
		a[1] = a[2] - a[1];
		a[2] -= a[1];
		ma++;
	}
	for(int i = 2; i < n; ++i) {
		if(a[i] == i) {
			ma++;
			if(a[i+1] != i) {
				a[i+1] += a[i];
				a[i] = a[i+1] - a[i];
				a[i+1] -= a[i];
			}
			else {
				a[i] += a[i-1];
				a[i-1] = a[i] - a[i-1];
				a[i] -= a[i-1];
			}
		}
	}
	if(a[n] == n) {
		ma++;
		a[n] += a[n-1];
		a[n-1] = a[n] - a[n-1];
		a[n] -= a[n-1];

	}

	cout << ma << "\n";
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    string s;
    cin >> s;

    ll su = 0;
    for(int i = 0; i < s.size(); ++i){
        su += s[i] - '0';
    }

    if (stoi(s)%su == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, W; cin >> N >> W;
    vector<ll> w(N), v(N);
    for (ll i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    ll ww = w[0];
    for (ll i = 0; i < N; i++) {
        w[i] = w[i] - ww;
    }

    vector<vector<ll>> dp(N+1, vector<ll> (3*N+1, 0));
    for (ll j = 0; j < N; j++) {
        for (ll k = N-1; k >= 0; k--) {
            for (ll i = 3*N; i >= 0; i--) {
                if(i + w[j] > 3*N) continue;
                dp[k+1][i+w[j]] = max(dp[k+1][i+w[j]], dp[k][i] + v[j]);
            }
        }
    }

    ll ans = 0;
    for (ll i = 0; i < 3*N+1; i++) {
        for (ll j = 0; j < N+1; j++) {
            if(i + j * ww > W) continue;
            ans = max(ans, dp[j][i]);
        }
    }

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

}

Measured memory_bytes: 3952
list_ = []

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

n = int(55555 / 5)

for i in range(1,n):
    cand = 1 + 5 * i
    if is_prime(cand):
        list_.append(cand)

k = int(input())

st = str()

for i in range(k):
    if i == 0:
        st  =  str(list_[i])
    else:
        st = st + ' ' + str(list_[i])

print(st)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int ord_descrescente(const void *a, const void *b){
    if (*(int*)a == *(int*)b)
        return 0;
    else if (*(int*)a > *(int*)b)
        return -1;
    else
        return 1;
}

int main(){
    int varetas, qtd, soma = 0;
    scanf("%d %d", &varetas, &qtd);
    int tamanhos[varetas];
    for (int i = 0; i < varetas; i++){
        scanf("%d", &tamanhos[i]);
    }
    qsort(tamanhos, varetas, sizeof(int), ord_descrescente);
    for (int i = 0; i < qtd; i++){
        soma += tamanhos[i];
    }
    printf("%d\n", soma);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

struct State {
  int prev;
  int now;
  int vel; // 到着時
  double e_time;
  
  bool operator < (const State &s) const {
    return e_time > s.e_time;
  }
  
  State() {}
  State(int p, int n, int v, double t) :
    prev(p), now(n), vel(v), e_time(t) {}
};

struct Edge {
  int to;
  int cost;
  int lim;
  
  Edge() {}
  Edge(int t, int c, int l) : to(t), cost(c), lim(l) {}
};

const double Inf = 1<<23;
int N, M;
vector<Edge> edges[30];
double G_time[31][30][31]; // u, v, vel -> e_time

double dijkstra(int s, int g) {
  
  fill(G_time[0][0], G_time[30][30], Inf);
  priority_queue<State> pq;
  
  pq.push(State(s, s, 0, 0.0));
  G_time[s][s][0] = 0.0;
  
  while(!pq.empty()) {
    const State st = pq.top(); pq.pop();
    
    if(G_time[st.prev][st.now][st.vel] < st.e_time) {
      continue;
    }
    
    if(st.now == g && st.vel == 1) {
      return st.e_time;
    }
    
    for(int i=0; i<edges[st.now].size(); i++) {
      const Edge &e = edges[st.now][i];
      
      if(e.to == st.prev) continue;
      
      for(int dvel = -1; dvel <= 1; dvel ++) {
	int nvel = st.vel + dvel;
	// 速度制限
	if(1 <= nvel && nvel <= e.lim) {
	  double ntime = st.e_time + (double)e.cost / nvel;
	  if(G_time[st.now][e.to][nvel] > ntime) {
	    G_time[st.now][e.to][nvel] = ntime;
	    pq.push(State(st.now, e.to, nvel, ntime));
	  }
	}
	
      }
    }
  }
  
  return -42;
}

int main() {
  int s, g;
  
  while(cin >> N >> M && (N|M)) {
    cin >> s >> g;
    s --, g --;
    
    for(int i=0; i<N; i++)
      edges[i].clear();
    
    for(int i=0; i<M; i++) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      x --, y --;
      edges[x].push_back(Edge(y, d, c));
      edges[y].push_back(Edge(x, d, c));
    }
    
    double ans = dijkstra(s, g);
    if((int)(-ans) == 42) {
      cout << "unreachable" << endl;
    } else {
      printf("%.5lf\n", ans);
    }
  }
  
  return 0;
}

Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#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++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  int H[N];
  rep(i,N) cin >> H[i];
  bool flag=true;
  rep(i,N-1) {
    if(H[N-i-2]-H[N-i-1]>=2) {
      flag=false;
      break;
    }
    else if(H[N-i-2]-H[N-i-1]==1) H[N-i-2]--;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int>> ba(M);
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        ba[i] = make_tuple(b, a);
    }

    sort(ba.begin(), ba.end());
    int ans = 0;
    int end = 0;
    for (tuple<int, int> x : ba) {
        if (end <= get<1>(x)) {
            ans++;
            end = get<0>(x);
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{   

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

    li n;
    cin>>n;

    li a[n],b[n],c[n];

    f(i,0,n-1)
    {
        cin>>a[i]>>b[i]>>c[i];
    }

    vector<vi> dp(n,vi(3,0));

    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    f(i,1,n-1)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];   
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))    ;
        
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long int n,k;
  cin>>n>>k;
  long long int a[n];
  map<int, int> m;
  for(int i=0;i<n;i++)
    cin>>a[i];
  long long int curInd = a[0], len=1;
  while(m[curInd]!=1) {
    m[curInd] = 1;
    curInd = a[curInd-1];
  }
  long long int temp = a[curInd-1];
  while(temp!=curInd) {
    temp=a[temp-1], len++;
  }
  if(curInd!=1) {
    long long int j=1;
    while(k && j!=curInd) {
      j = a[j-1], k--;
    }
    if(!k) {
      cout<<j;
      return 0;
    }
  }
  k%=len;
  while(k--) {
    curInd = a[curInd-1];
  }
  cout<<curInd;
}

Measured memory_bytes: 14264
H, W, h, w = map(int, input().split())
if H % h == 0 and W % w == 0:
    print('No')
    exit()
rem = H * W - (H - H % h) * (W - W % w)
x = (H // h * W // w) // rem + 1
a = [[x] * W for _ in range(H)]
for i in range(h-1, H, h):
    for j in range(w-1, W, w):
        a[i][j] = -(h * w - 1) * x - 1
print('Yes')
for row in a:
    print(*row)


Measured memory_bytes: 77260
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int cost[100][100];
bool is_freezing_plant[100];
int dp[100][101]; //dp[pos][life] := min_cost
int city_num,refreezing_limit,freezing_plant_num,
  road_num,capital_idx,hospital_idx;

class Node{
public:
  Node(int _l,int _p,int _c) : life(_l),pos(_p),cost_sum(_c){}
  int life;
  int pos;
  int cost_sum;
  bool operator<(const Node& n) const{
    return cost_sum < n.cost_sum;
  }
  bool operator>(const Node& n) const{
    return cost_sum > n.cost_sum;
  }
};

int main(){
  while(~scanf("%d %d %d %d %d %d",
	       &city_num,&refreezing_limit,&freezing_plant_num,
	       &road_num,&capital_idx,&hospital_idx)){
    if(city_num == 0) break;

    memset(cost,0x3f,sizeof(cost));
    memset(is_freezing_plant,false,sizeof(is_freezing_plant));

    for(int i=0;i<freezing_plant_num;i++){
      int city_idx;
      scanf("%d",&city_idx);
      is_freezing_plant[city_idx] = true;
    }
    is_freezing_plant[capital_idx] = true;
    is_freezing_plant[hospital_idx] = true;

    for(int i=0;i<road_num;i++){
      int from,to,c;
      scanf("%d %d %d",&from,&to,&c);
      cost[from][to] = c;
      cost[to][from] = c;
    }

    memset(dp,0x3f,sizeof(dp));
    dp[capital_idx][refreezing_limit] = 0;

    Node n(refreezing_limit,capital_idx,0);
    priority_queue<Node,vector<Node>,greater<Node> > que;
    que.push(n);
    
    while(!que.empty()){
      Node n = que.top();
      que.pop();
      int from = n.pos;
      int life = n.life;
      int cost_sum = n.cost_sum;

      for(int to=0;to<city_num;to++){
	if(from == to) continue;

	if(is_freezing_plant[from]){
	  for(int stay=refreezing_limit-life;stay>=0;stay--){
	    if(stay+life-cost[from][to] < 0) break;

	    int remaining_life = life-cost[from][to]+stay;
	    if(dp[to][remaining_life] > cost_sum+cost[from][to]+stay){
	      dp[to][remaining_life] = cost_sum+cost[from][to]+stay;
	      que.push(Node(remaining_life,to,cost_sum+cost[from][to]+stay));
	    }
	  }
	}
	else{
	  if(life <= 0) break;
	  if(life-cost[from][to] < 0) continue;
	  int remaining_life = life-cost[from][to];
	  if(dp[to][remaining_life] > cost_sum+cost[from][to]){
	    dp[to][remaining_life] = cost_sum + cost[from][to];
	    que.push(Node(remaining_life,to,cost_sum+cost[from][to]));
	  }
	}
      }
    }
    
    int res = INF;
    for(int i=0;i<=refreezing_limit;i++){
      res = min(res,dp[hospital_idx][i]);
    }
    
    if(res >= INF){
      printf("Help!\n");
    }
    else{
      printf("%d\n",res);
    }

  }
}

Measured memory_bytes: 1488
// Code for A - Payment
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

  int x = 1000 - N % 1000;

  if (x == 1000) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - N % 1000 << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>

#define all(a) (a).begin(),(a).end()
using namespace std;

bool check(vs &ngo, string s){
	for (string t : ngo) if (t == s) return 0;
	return 1;
}

int main(){
	ll a, b; cin >> a >> b;
	cout << a - b + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools


def is_integer(num):
    if isinstance(num, int):
        return True
    if isinstance(num, float):
        return num.is_integer()
    return False


n, d = map(int, input().split())
x = []
for _ in range(n):
    x.append(tuple(map(int, input().split())))

cnt = 0
for a, b in itertools.combinations(x, 2):
    if is_integer(sum([(ad - bd) ** 2 for ad, bd in zip(a, b)]) ** 0.5):
        cnt += 1

print(cnt)


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

const long long INF = INT_MAX;
struct SegmentTree {
private:
    long long n;
    vector<long long> node;

public:
    SegmentTree(vector<long long> v) {
        long long sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(long long i=0; i<sz; i++) node[i+n-1] = v[i];
        for(long long i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void update(long long x, long long val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    long long getmin(long long a, long long b, long long k=0, long long l=0, long long r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];

        long long vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        long long vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    long long N, Q;
    cin >> N >> Q;
    SegmentTree seg( vector<long long>(N, INF) );
    for(long long i = 0; i<Q; i++) {
        long long c, x, y;
        cin >> c >> x >> y;
        if(c == 0) seg.update(x, y);
        else cout << seg.getmin(x, y+1) << endl;
    }    
}


Measured memory_bytes: 5752
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let p_s = buf.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<Vec<_>>();

    let mut ans = 0usize;
    let mut min_p = p_s[0];
    for &p in p_s.iter() {
        if p <= min_p {
            min_p = p;
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn (1<<18)
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int dep[maxn+5];
int per[maxn+5];
ll sum[maxn+5];

int main()
{
    int H; scanf("%d",&H);
    int n=1<<(H-1),base=n-1;
    rep(i,1,base+n) dep[i]=dep[i/2]+1;
    rep(i,1,n) scanf("%d",&per[base+i]),per[base+i]+=base;
    ll ans=0;
    rep(now,1,base)
    {
        //int ls=now*2,rs=now*2+1;
        int N=1<<(H-dep[now]-1);
        int L=now<<(H-dep[now]),R=L+N;
        rep(x,L,L+N-1)
        {
            ll mul=1;
            int tmp=x;
            while(tmp>=now)
            {
                mul=mul*tmp%mod;
                tmp>>=1;
            }
            int y=per[x];
            while(y)
            {
                mul=mul*y%mod;
                sum[y]=(sum[y]+mul)%mod;
                //printf("?? %d, %d: %lld\n",x,y,mul);
                y>>=1;
            }
        }
        rep(x,R,R+N-1)
        {
            ll mul=1;
            int tmp=x;
            while(tmp>now)
            {
                mul=mul*tmp%mod;
                tmp>>=1;
            }
            int y=per[x];
            while(y>1)
            {
                //printf("-- %d, %d: %lld, %lld\n",x,y,mul,sum[y]*mul%mod);
                mul=mul*y%mod;
                ans=(ans+(sum[y/2]-sum[y]*(y/2)%mod+mod)*mul)%mod;
                y>>=1;
            }
        }
        rep(x,L,L+N-1)
        {
            int y=per[x];
            while(y)
            {
                sum[y]=0;
                y>>=1;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7408
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int S;
    int h,m,s;
    scanf("%d",&S);
    h = S /3600;
    m = (S - h*3600) /60;
    s = S - (h*3600 + m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int takahashi = (A-1)/D;
  int aoki = (C-1)/B;

  if(takahashi >= aoki) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
typedef long long int lli;
int main() {
  int n,x,t;
  scanf("%d %d %d", &n,&x,&t);
  int ans = 0;
  int time=0;
  while(ans<n){
    ans = ans + x;
    time = time + t;
    if(ans>=n){
        break;
    }
  }

  printf("%d", time);
  return 0;
}



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

int main() 
{
  	int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=0;i<n;i++)
    	cin >> a[i];
  	int start;
  	int dp[n];
  	for(int i=0;i<n;i++)
      dp[i]=INT_MAX;
  	dp[0]=0;
    for (int i = 1; i < n; i++) 
    {
      	start = i-k;
      	if(start<0)
          start=0;
      	for(int j=start;j<i;j++)
        {
        	dp[i] = min(dp[j] + abs(a[i] - a[j]),dp[i]);
        }
    }
  
    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
// AGC 013 A
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ll long long
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    REP(i,N){
        cin >> A[i];}
    int s = 0;
    int ans = 1;
    REP(i,N-1){
        if(s==0){
            if (A[i]<A[i+1]){
                s = 1;
            }else if (A[i]>A[i+1]){
                s = -1;}}
        if(s==1){
            if(A[i]>A[i+1]){
                ans++;
                s = 0;}}
        if(s==-1){
            if(A[i]<A[i+1]){
                ans++;
                s = 0;}}}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N, M=map(int,input().split())
A=list(map(int,input().split()))

for i in range(N):
  A[i]%=M
rui=[A[0]]*N
for i in range(1,N):
  rui[i]=(rui[i-1]+A[i])%M
rui.sort()
last=0
cnt=0
for i in range(1,N):
  if rui[i] != rui[i-1]:
    if i - last >=2:
      cnt+=(i-last)*(i-last-1)//2
    last=i
if N - last >= 2:
  cnt+=(N-last)*(N-last-1)//2
print(int(cnt)+rui.count(0))

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  double r;
  cin >> r;
  double p = 3.14159265;
  double ans = r*2*p;
  cout << ans << endl;
}

Measured memory_bytes: 3808
n,m = map(int,input().split())
p = [0]*m
s = [""]*m
for i in range(m):
  p[i],s[i] = input().split()
  
p = [int(j) for j in p]

u = [[0 for i in range(2)]for j in range(n)]

for k in range(0,m):
  if(s[k] == "WA" and u[p[k]-1][1] == 0):
    u[p[k]-1][0] += 1
  elif(s[k] == "AC"):
    u[p[k]-1][1] = 1

ans = 0
ac = 0
for i in range(n):
  if(u[i][1] == 1):
    ac += 1
    ans += u[i][0]
print(ac,ans)

Measured memory_bytes: 30624