akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ll a, b;
	cin >> a >> b;
	for(ll x=0; x<500000; ++x){
		ll r1 = (x*8)/100;
		ll r2 = (x*10)/100;
		if(r1==a and r2==b){
			cout << x << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define pu(n) cout << n; 
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
int a,b,i;
string h;
char f;
int main(void){
	cin >> a >> h >> b;
	f=h[b-1];
	rep(i,0,a){
		if(h[i]==f){
			pu(h[i]);}
		else{
			cout << "*" ;}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    cin>>n;
    ll div[n+10] = {0};

    for(i=1;i<=n;i++){
        for(j=i;j<=n;j+=i){
            div[j]++;
        }
    }
    ll ans = 0;
    for(i=1;i<=n;i++){
        ans+= (i*div[i]);
    }
    cout<<ans<<NL;

    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 81772
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <cmath>
#include <bitset>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>

using namespace std;

#define ef emplace_front
#define eb emplace_back
#define mp make_pair
#define MOD 1000000007

typedef long double f80;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef unordered_set<int> usi;
typedef set<int> si;

ll gcd(ll a, ll b){
	if (a<b) return gcd(b,a);
	if (!b)return a;
	return gcd(b,a%b);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	ll a,b;
	cin>>a>>b;
	cout<<a/gcd(a,b)*b;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	//0400 start
	
	class C{
		int w,h;

		public C(int w, int h) {
			this.w = w;
			this.h = h;
		}

		@Override
		public String toString() {
			return "C [w=" + w + ", h=" + h + "]";
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((n|w|h) == 0) break;
			ArrayList<C> list = new ArrayList<Main.C>();
			list.add(new C(w, h));
			for(int i = 0; i < n; i++){
				//System.out.println(list.toString());
				int p = sc.nextInt() - 1;
				int s = sc.nextInt();
				C now = list.get(p);
				list.remove(p);
				s = s % (now.w + now.h);
				int j = 0;
				for(j = 0 ; j < 5; j++){
					int ninus = j % 2 == 0 ? now.w : now.h;
					if(s - ninus < 0){
						break;
					}
					s = s - ninus;
				}
				if(j % 2 == 0){
					C next1 = new C(s, now.h);
					C next2 = new C(now.w - s, now.h);
					if(next1.h * next1.w < next2.h * next2.w){
						list.add(next1); list.add(next2);
					}
					else{
						list.add(next2); list.add(next1);
					}
				}
				else{
					C next1 = new C(now.w, s);
					C next2 = new C(now.w, now.h - s);
					if(next1.h * next1.w < next2.h * next2.w){
						list.add(next1); list.add(next2);
					}
					else{
						list.add(next2); list.add(next1);
					}
				}
			}
			ArrayList<Integer> res = new ArrayList<Integer>();
			for(int i = 0; i < list.size(); i++){
				res.add(list.get(i).h * list.get(i).w);
			}
			Collections.sort(res);
			System.out.print(res.get(0));
			for(int i = 1; i < res.size(); i++){
				System.out.print(" " + res.get(i));
			}
			System.out.println();
		}
	}


	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

#define int long long

int n, m, c;
int l[100010];

signed main(){
    cin >> n >> m >> c;

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

    int c, w;

    priority_queue<pair<int, int> > que;

    for(int i = 0;i < n;i++){
        cin >> c >> w;
        c--;
        que.push(make_pair(w, c));
    }

    int ans = 0;

    while(!que.empty() && m > 0){
        if(l[que.top().second] > 0){
            l[que.top().second]--;
            m--;
            ans += que.top().first;
        }
        que.pop();
    }

    cout << ans << endl;

    return 0;
}




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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

#define int ll


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

  int N;
  cin>>N;

  //K個の集合を結ぶのに必要な線の数
  //1->0
  //2->1
  //3->3
  //4->6
  //5->10
  //K*(K-1)/2=N
  //K^2-K-2N=0
  //1+\sqrt{1+8N}/2
  bool ok=false;
  int a=0;
  for(;a*a<=1+8*N;a++){
    if(a*a==1+8*N){
      ok=true;
      break;
    }
  }
  if(!ok){
    cout<<"No"<<endl;
    return 0;
  }
  if((a+1)%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  int K=(a+1)/2;
  vector<vector<int>>S(K);
  int now=1;
  for(int i=0;i<K;i++){
    int sz=S[i].size();
    for(int j=0;i+j<(2*N)/K;j++){
      S[i].push_back(now);
      S[i+j+1].push_back(now);
      now++;
    }
  }
  if(now-1>N){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  cout<<K<<endl;
  for(int i=0;i<K;i++){
    cout<<S[i].size()<<" ";
    for(auto it:S[i])cout<<it<<" ";
    cout<<endl;
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 5048
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var N, K int
	fmt.Fscan(reader, &N, &K)

	S := make([][]int, K)
	for i := 0; i < K; i++ {
		var l, r int
		fmt.Fscan(reader, &l, &r)
		temp := []int{l, r}
		S[i] = temp
	}
	dp := make([]int, N)
	mod := 998244353
	dp[0] = 1
	wa := make([]int, N+1)
	for n := 0; n < N; n++ {
		for i := range S {
			l := S[i][0]
			r := min(S[i][1], n)
			if l <= r && n >= l && n >= r {
				dp[n] += wa[n-l+1] - wa[n-r]
				dp[n] %= mod
			}
		}
		wa[n+1] = wa[n] + dp[n]
	}
	ans := dp[N-1] % mod
	fmt.Println(ans)
}
func max(a ...int) int {
	max := a[0]
	for _, i := range a {
		if i > max {
			max = i
		}
	}
	return max
}
func min(a ...int) int {
	min := a[0]
	for _, i := range a {
		if i < min {
			min = i
		}
	}
	return min
}


Measured memory_bytes: 5100
#include<iostream>
using namespace std;
int main(){
  int a,b,i;
  cin>>b;
  for(i=0;i<2;i++){
    cin>>a;
    if(a!=b){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    set<int> st;
    for (int i = 0; i < N; ++i)
    {
        int tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    if (st.size() == N)
        cout << "YES\n";
    else
        cout << "NO\n";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vector<vi> a(n, vi(m));
	rep(i,0,n) rep(j,0,m) {
		cin >> a[i][j];
		a[i][j]--;
	}

	int ret = n;
	vector<bool> v(m, true);
	rep(iter,0,m) {
		vi cnt(m);
		rep(i,0,n) {
			rep(j,0,m) {
				if(!v[a[i][j]]) continue;
				cnt[a[i][j]]++;
				break;
			}
		}
		int g = 0;
		rep(i,0,m) {
			if(cnt[i] > cnt[g]) {
				g = i;
			}
		}
		ret = min(ret, cnt[g]);
		v[g] = false;
	}
	cout << ret << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll A, B;
    cin >> A >> B;

    ll ans = -1;
    REPi(x,1,10000){
        ll a = floor(x * 0.08);
        ll b = floor(x * 0.1);
        if(a == A && b == B){
            ans = x;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int H = in.nextInt();
        int W = in.nextInt();

        while (H != 0 && W != 0) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < H; i++) {
                if (i % 2 == 0) {
                    for (int j = 0; j < W; j++) {
                        if (j % 2 == 0) {
                            sb.append("#");
                        } else {
                            sb.append(".");
                        }
                    }
                } else {
                    for (int j = 0; j < W; j++) {
                        if (j % 2 == 0) {
                            sb.append(".");
                        } else {
                            sb.append("#");
                        }
                    }
                }
                sb.append("\n");
            }
            System.out.println(sb.toString());

            H = in.nextInt();
            W = in.nextInt();
        }

        System.exit(0);
    }
}



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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 3e5 + 5;

int w, h, n, ans;
int x[maxn], y[maxn], col[maxn], row[maxn];
vector<int> vec[maxn];
set<pii, greater<pii> > s;

int main(){
	scanf("%d%d%d", &w, &h, &n);
	FOR(i, 0, n){
		scanf("%d%d", x + i, y + i);
		--x[i]; --y[i];
		++col[y[i]];
		++row[x[i]];
		vec[x[i]].PB(y[i]);
	}
	
	FOR(i, 0, h)
		s.insert(MP(col[i], i));
	
	FOR(i, 0, w){
		FOR(it, 0, vec[i].size()){
			int j = vec[i][it];
			ans = max(ans, row[i] + col[j] - 1);
			s.erase(MP(col[j], j));
		}
		if(s.size()){
			set<pii>::iterator it = s.begin();
			ans = max(ans, row[i] + it -> fst);
		}
		FOR(it, 0, vec[i].size()){
			int j = vec[i][it];
			s.insert(MP(col[j], j));
		}
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 38924
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
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;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

ll dp[51][2600][51];
vl x;
ll N, A, ans;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> A;
	x.pb(0);
	ll sum = 0;
	FOR(i, 1, N + 1) {
		x.pb(0); cin >> x[i];
		sum += x[i];
	}
	dp[0][0][0] = 1;
	ll ans = 0;
	FOR(i, 1, N + 1) {
		F0R(j, sum + 1) {
			F0R(k, i + 1) {
				dp[i][j][k] = dp[i - 1][j][k];
				if (x[i] <= j && k > 0) dp[i][j][k] += dp[i - 1][j - x[i]][k - 1];
				if (i == N && k != 0 && j == k * A) ans += dp[i][j][k];
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 51968
// abc088_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3) {
    rep(j, 3) { cin >> c[i][j]; }
  }
  bool flag = true;
  int left = c[0][0] - c[0][1], right = c[0][1] - c[0][2];
  for (int i = 1; i < 3; ++i) {
    if (left != c[i][0] - c[i][1] || right != c[i][1] - c[i][2]) {
      flag = false;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

#define loop(i,n) for(int i=1;i<=n;i++)
int dp[2][5002];
int a[5002];
int b[5002];

int main(){
  int A,B;
  cin>>A>>B;
  loop(i,A)cin>>a[i];
  loop(j,B)cin>>b[j];
  int m=0;
  loop(j,B){
    int c=0;
    loop(i,A){
      if(a[i]==b[j+c])c++;
    }
    m=max(m,c);
  }
  cout<<m<<endl;
  return 0;
}

int _main(){
  int A,B;
  cin>>A>>B;
  loop(i,A)cin>>a[i];
  loop(j,B)cin>>b[j];
  int m=0;
  loop(i,A)loop(j,B){
    dp[i&1][j]=dp[i&1^1][j];
    if(a[i]==b[j]){
      dp[i&1][j]=dp[i&1^1][j-1]+1;
    }
    m=max(m,dp[i&1][j]);
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 3120
import math
from datetime import date

def main():
		
	line = input().split()
	a = [int(x) for x in line]
	a.sort()

	if a[0] == 5 and a[1] == 5 and a[2] == 7:
		print("YES")
	else:
		print("NO")
	
main()


Measured memory_bytes: 9412
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long M;
        static string[] A;
        static string[] B;
        static void Main(string[] args)
        {
            //N = long.Parse(Console.ReadLine());
            //var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var S = Console.ReadLine();
            var left  = 0;
            var right = S.Length-1;
            var possible = true;
            var ans = 0;
            while (left <= right)
            {
                if (S[left] == S[right])
                {
                    left++;
                    right--;
                }else if (S[left] == 'x')
                {
                    ans++;
                    left++;
                }
                else if (S[right] == 'x')
                {
                    ans++;
                    right--;
                }
                else
                {
                    possible = false;
                    break;
                }
            }

            Console.WriteLine(possible ?ans:-1 );
            //Console.WriteLine("Yes");
        }
       
    }


}


Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    const int MOD = 1000000007;
    long long dp[110][5][5][5]={};
    dp[0][0][0][0]=1;
for(int z=0;z<=n;z++){
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<5;k++){
               for(int l=1;l<5;l++){
                    if (i == 1 && j == 2 && l == 3) continue;
                    if (i == 1 && k == 2 && l == 3) continue;
                    if (j == 1 && k == 2 && l == 3) continue;
                    if (j == 2 && k == 1 && l == 3) continue;
                    if (j == 1 && k == 3 && l == 2) continue;
                    dp[z+1][j][k][l]+=dp[z][i][j][k];
                    dp[z+1][j][k][l]%=MOD;
                } 
            }
        }
    }
}
    long long ans=0;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<5;k++){
                ans+=dp[n][i][j][k];
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}

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

/*-------------------------------TEMPLATE ------ START-------------------*/
//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pii pair<int,int>
#define vii vector<int>
#define ll long long
#define int long long
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define allr(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define mp make_pair

#define mod 1000000007
#define eps 1e-9

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

int fact(int k){
    if(k == 1 || k == 2)
        return k;
    int a=1,b=1;
    while(a<=k){
        b = ((b%mod) * (a%mod))%mod;
        a++;
    }
    return b;
}
/* String to int */
uint64_t toint(const string &s){
    istringstream src(s);
    uint64_t v;
    src>>v;
    return v;
}

/*Int to string */
string tostring(uint64_t v){
    ostringstream src;
    src<<v;
    return src.str();
}


/*-------------------------------TEMPLATE ------ END-------------------*/
//SOLUTION
const int N = 2e5+5;
int n;

void solve(){
   char c;
   rep(i,1,4){
       cin>>c;
       if(c=='+') n++;
       else n--;
   }
   cout<<n;
}

int32_t main()
{
    fast;//openin;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[100007];
int dp[100007];
int main(){
  int n;
  cin >> n;
  memset(dp,0,sizeof(dp));
  for(int i=0;i<n;i++) cin >> A[i];
  dp[0]=0;
  dp[1]=abs(A[1]-A[0]);
  for(int i=2;i<n;i++){
    dp[i] = min(abs(A[i]-A[i-1])+dp[i-1], abs(A[i]-A[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
sticks_length = gets.chomp.to_i
sticks = gets.chomp.split.map(&:to_i)

sticks_asc = sticks.sort_by{ |stick| stick }

result = 0

(sticks_length - 1).downto(2) do |i|
  (i - 1).downto(1) do |j|

    # 2辺が固定されたのであと1本の必要な長さがわかる
    min_length = sticks_asc[i] - sticks_asc[j]
    # 短すぎる枝の数
    small_stick_num = sticks_asc.bsearch_index {|stick| min_length < stick }
    result += [j - small_stick_num, 0].max
  end
end

puts result

Measured memory_bytes: 3960
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int dp[5005][5005]; //the min. cost of getting [a][b]

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, ma, mb;
	cin >> n >> ma >> mb;
	rep(i, 5005) rep(j, 5005) dp[i][j] = 1e9;
	dp[0][0] = 0;
	vi a(n), b(n), c(n);
	int sumA = 0, sumB = 0;
	rep(i, n) cin >> a[i] >> b[i] >> c[i], sumA += a[i], sumB += b[i];
	rep(i, n){
		for(int j = sumA - a[i]; j >= 0; j--){
			for(int k = sumB - b[i]; k >= 0; k--){
				dp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
			}
		}
	}
	int ans = 1e9;
	repn(i, 1, sumA + 1) repn(j, 1, sumB + 1){
		int i1 = i, j1 = j;
		int g = gcd(i, j);
		i1 /= g, j1 /= g;
		if(i1 == ma && j1 == mb) ans = min(ans, dp[i][j]);
	}
	if(ans == 1e9) ans = -1;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(){
  int N, A;
  cin >> N >> A;
  
  if(A == 0) {
    if(N % 500 != 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else if(A != 0) {
    int rem = N % 500;
    if(rem > A) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] ar = new int[n];
			int[] abs = new int[n-k+1];
			for (int i = 0; i < n; i++) {
				ar[i] = sc.nextInt();
			}
			Arrays.sort(ar);
			for (int i = 0; i < n-k+1; i++) {
				abs[i] = ar[k-1+i] - ar[i];
			}
			int min = abs[0];
			for (int i = 0; i < n-k+1; i++) {
				if (abs[i] < min) {
					min = abs[i];
				}
			}
			System.out.println(min);
			sc.close();
		}
}

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

int a[200020], b[200020];
long sa[200020], sb[200020];
int main()
{
    int n, m, k; cin>>n>>m>>k;
    for(int i=0; i<n; ++i) cin>>a[i];
    for(int i=0; i<m; ++i) cin>>b[i];

    for(int i=0; i<n; ++i) sa[i+1]=sa[i]+a[i];
    for(int i=0; i<m; ++i) sb[i+1]=sb[i]+b[i];

    int res=0;
    for(int i=0; i<=n; ++i) {
        int x=k-sa[i];
        if (x<0) break;
        int j=upper_bound(sb, sb+m+1, x)-sb;
        res=max(res, i+j-1);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 8208
s = str(input())
n = len(s)
a = 0
for i in range(0,n):
    if (i % 2)== 1:
        if s[i] == 'R':
            a = 1

    else:
        if s[i] == 'L':
            a = 1


if a == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll H,N;
    cin>>H>>N;
    vector<ll> A(N),B(N);
    rep(i,N) cin>>A.at(i)>>B.at(i);
    
    ll dp[20005];
    rep(i,20005) dp[i]=INF;
    dp[0]=0;
    rep(i,H){
        rep(j,N){
            dp[i+A.at(j)]=min(dp[i]+B.at(j),dp[i+A.at(j)]);
        }
    }
    ll ans=INF;
    for(ll i=H;i<20005;i++){
        ans=min(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int digit(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  if(n % digit(n)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Read_ freopen("input.inp", "r", stdin)
#define Write_ freopen("output.out", "w", stdout);
using namespace std;
typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define N  52
int a,b,c,d;
ll res,s;
ll mx(ll a, ll b){
    if (a>b) return (ll)a;
    return (ll)b;
}
int main(){
    _io; 
   cin>>a>>b>>c>>d;
    cout<<mx(mx((ll)a*c,(ll)b*d),mx((ll)a*d,(ll)b*c));
}





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

int main()
{
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  
  if(A == 0){
  	cout << 1 << endl;
  }else if(B == 0){
  	cout << 2 << endl;
  }else if(C == 0){
  	cout << 3 << endl;
  }else if(D == 0){
  	cout << 4 << endl;
  }else if(E == 0){
  	cout << 5 << endl;
  }



  
}


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

using namespace std;
#define int long long

signed main(){
    int N,Y;
    cin >> N >> Y;
    
    int x,y,z;
    for(x=0;x<=N;x++){
        for(y=0;y<=N;y++){
            z=N-x-y;
            if(x+y+z==N && x*10000+y*5000+z*1000==Y && z>=0){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
s=list(input())
l=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in l:
    if i not in s:
        print(i)
        exit()
print("None")  

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

int main(){
  char A;
  cin >> A;
  if(A=='A'){
    cout << 'T' << endl;
  }
  else if(A=='T'){
    cout << 'A' << endl;
  }
  else if(A=='C'){
    cout << 'G' << endl;
  }
  else{
    cout << 'C' << endl;
  }
}
  

Measured memory_bytes: 3536
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    double face = 1 / (double) N;
    double ans = 0;
    for (int i = 1; i <= N; ++i) {
        int count = 0;
        for (int j = 0, c = i; c < K; ++j) {
            c *= 2;
            ++count;
        }
        ans += face * pow(0.5, count);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
from math import ceil
H,N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
# 1回iを使ってから、のこりをjで仕留める、を全探索でよい気がする
# だめだった

# dp[i] : HPをi減らすために必要なmin魔力
dp = [1e9] * (10010)
dp[0] = 0
for i in range(1,H+1):
  for a in A:
    ap, mp = a
    down = max(0, i - ap)
    dp[i] = min(dp[i], dp[down] + mp)
      
print(min(dp[H:]))

Measured memory_bytes: 45292
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  long long a, b;
  cin >> a >> b;

  if (a == 1 && b == 1)
  {
    cout << 1 << endl;
    exit(0);
  }
  else if (a == 1 || b == 1)
  {
    if(a == 1)
    {
      cout << b - 2 << endl;
    }
    else
    {
      cout << a - 2 << endl;
    }
    exit(0);
  }
  else if (a == 2 || b == 2)
  {
    cout << 0 << endl;
    exit(0);
  }
  else if (a == 3 && b == 3)
  {
    cout << 2 << endl;
    exit(0);
  }
  else
  {
    cout << (a * b) - (2 * a + 2 * b - 4) << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int kaibun(int A, int B ) {
    int cou = 0;
    for (int i = A; i <= B; i++) {
        int k = i;
        if (k / 10000 == k % 10) {
            k /= 10;
            k %= 1000;
            if (k / 100 == k % 10) {
                cou++;
            }
        }
    }
    return cou;
}

int main() {
    int A, B;
    cin >> A >> B;
    int ans = kaibun(A,B);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a,b,i,n;
while(1){
scanf("%d%d",&a,&b);
if(a==0&&b==0)break;
for(i=1;i<=a;i++){
for(n=1;n<=b;n++){
if(n%2==1){
if(i%2==1)printf("#");
else printf(".");
}
else{
if(i%2==1)printf(".");
else printf("#");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N;
	cin >> N;
	int h, m = 0;
	int ans = 0;
	for(int i = 0; i < N; i ++){
		cin >> h;
		if(m <= h){
			ans ++;
			m = h;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    print('2018'+IS()[4:])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int hills[10];
	int i, j;
	int temp;

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

	for(i=0; i < 9; i++){
		for(j=0; j < 9-i; j++){
			if(hills[j] < hills[j+1]) {
				temp = hills[j];
				hills[j] = hills[j+1];
				hills[j+1] = temp;
			}
		}
	}
	for(i=0; i < 3; i++){
		printf("%d\n", hills[i]);
	}

	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const ll INF = LLONG_MAX;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;
#define PI acosl(-1)
#define MAX_N 100 + 2

void exec(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && c <= b ? "Yes" : "No") << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 8;

int N, M;
int D[8][8];
int V[8];
int ans;

void dfs(int num){
	bool def = true;
	for(int i = 0; i < N; i++){
		if(V[i] == 0) def = false;
	}
	if(def == true) ans++;
	for(int i = 0; i < N; i++){
		if(D[num][i] == 1 && V[i] == 0){
			V[i] = 1;
			dfs(i);
			V[i] = 0;
		}
	}
}

void solve(){
	ans = 0;
	V[0] = 1;
	dfs(0);
	printf("%d\n", ans);
}

int main(){
	scanf("%d %d", &N, &M);
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			D[i][j] = 0;
		}
	}
	int a, b;
	for(int i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		a--; b--;
		D[a][b] = 1;
		D[b][a] = 1;
	}
	solve();
	return 0;
}


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

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

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


int main() {
	fastio;

	ll N;
	cin >> N;
	
	ll ans = 1;
	rep(i, N) {
		ll T;
		cin >> T;
		ans = ans / gcd(ans, T) * T;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();
    let ans = if n % 2 == 0 { n } else { 2 * n };
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
S = [input() for _ in range(N)]

from collections import Counter

counter = Counter(S)
ans = []
c = counter.most_common(1)[0][1]
for word, cnt in counter.most_common():
    if cnt == c:
        ans.append(word)

for w in sorted(ans):
    print(w)

Measured memory_bytes: 45068
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,L,R) for(auto i=R-1;i>=L;i--)
#define show(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

vi dp(1e5,1e9),arr(1e5);

int main() 
{
	int test;
//	cin>>test;
//	while(test--)
	{
	    int n,k;
	    cin>>n>>k;
	    F(i,0,n)
	        cin>>arr[i];
        dp[0]=0;
        dp[1]=abs(arr[1]-arr[0]);
        F(i,2,n)
        {
            for(int j=i-1;j>=i-k && j>=0;j--)
            {
                dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
            }
        }
	    
	    cout<<dp[n-1]<<"\n";
	    
	}

}




Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<cmath>
using namespace std;
char c[310];
int n;
int main()
{
    int b = 0,sum=0;
    ios::sync_with_stdio(false);//65 90  97 122
    cin.tie(0);  cout.tie(0);
    cin >> n;
    cin >> c;
    for (int i = 0; i < n; i++)
    {
        if (c[i] == 'A') { b = 1; }
        else if (b == 1 && c[i] == 'B') {
            b = 2;
            ;
        }
        else if (b == 2 && c[i] == 'C') { sum++; b = 0; }
        else b = 0;
    }
    cout << sum << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    for(int i=0; i<(int) S.size(); i++){
        int tmp = S[i]-'A';
        tmp+=N;
        tmp%=26;
        cout << char(tmp+'A');
    }
    cout << endl;
}

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

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int T = NextInt();
        int X = NextInt();
        double ans = (T+0.0)/(X+0.0);

        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<stdlib.h>
/*
int main()
{
  int *A;
  int i,n,key;

  scanf("%d",&n);
  A = malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  printf("node 1: key = %d, left key = %d, right key = %d, \n",A[0],A[1],A[2]);
  for(i=1;i<n;i++)
    {
      printf("node %d: key = %d, parent key = %d,",i+1,A[i],A[(i-1)/2]);
      if(i*2+1<n)
	{
	  printf(" left key = %d,",A[i*2+1]);
	}
      if((i+1)*2<n)
	{
	  printf(" right key = %d,",A[(i+1)*2]);
	}
      printf(" \n");
    }
  free(A);
  return 0;
}
*/

#define H 250
int main()
{
  int youso,i,haire[H];
  scanf("%d",&youso);
  for(i=1;i<=youso;i++)
    {
      scanf("%d",&haire[i]);
    }
  printf("node 1: key = %d, left key = %d, right key = %d, \n",haire[1],haire[2],haire[3]);
  for(i=2;i<=youso;i++)
    {
      printf("node %d: key = %d, parent key = %d,",i,haire[i],haire[i/2]);
      if((i*2)<=youso)
	{
	  printf(" left key = %d,",haire[i*2]);
	}
      if((i*2+1)<=youso)
	{
	  printf(" right key = %d,",haire[i*2+1]);
	}
      printf(" \n");
    }
  return 0;
}




Measured memory_bytes: 2040
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int Q, x[1000], y[1000], ret;
int main() {
	scanf("%*d%*d%d%d%d", &Q, x, y);
	for(int i = 1; i < Q; i++) {
		scanf("%d%d", x + i, y + i);
		int dx = x[i] - x[i - 1], dy = y[i] - y[i - 1];
		ret += (dx > 0) == (dy > 0) ? max(abs(dx), abs(dy)) : abs(dx) + abs(dy);
	}
	printf("%d\n", ret);
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , k;
    cin >> n >> k;
    double res = 0;
    range(i,1,n){
        if(i >= k){
            res += 1.0 / n;
        }else{
            double cur = 1.0 / n;
            int num = i;
            while(num < k){
                num <<= 1;
                cur *= 0.5;
            }
            res += cur;
        }
    }

    cout << fixed << setprecision(12) << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 200000
int a[maxn*2+5],b[maxn+5],ans[maxn*2+5],n,k;
inline int lowbit(int x){
	return x&(-x);
}
void add(int x){
	while(x<=n)b[x]++,x+=lowbit(x);
}
int sum(int x){
	int ans=0;
	while(x)ans+=b[x],x-=lowbit(x);
	return ans;
}
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i),a[i]++;
	int ans1=n-k+1,mx=0,x;bool fl=0;
	for(int i=1;i<=k;i++)add(a[i]),ans[i]=sum(a[i]),ans[i+k]=sum(a[i+k]),mx=(a[i]>a[i-1]?mx+1:1);
	if(mx>=k)fl=1;
	for(int i=k+1;i<=n;i++){
		add(a[i]);x=sum(a[i]);ans[i+k]=sum(a[i+k]);
		mx=(a[i]>a[i-1]?mx+1:1);
		if(mx>=k){
			if(fl)ans1--;
			else fl=1;
		}
		else if(ans[i-k]==sum(a[i-k])&&ans[i]+k==x)ans1--;
		ans[i]=x;
	}
	printf("%d",ans1);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<int> k(M);
    std::vector<std::vector<int>> s(M);
    for (int i = 0; i < M; i++) {
        std::cin >> k[i];
        s[i].resize(k[i]);
        for (int j = 0; j < k[i]; j++)
            std::cin >> s[i][j];
    }

    std::vector<int> p(M);
    for (int i = 0; i < M; i++)
        std::cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < 1 << N; bit++) {
        bool ok = true;
        for (int i = 0; i < M; i++) {
            int res = 0;
            for (int j = 0; j < k[i]; j++)
                res += bit >> s[i][j] - 1 & 1;
            if (res % 2 != p[i])
                ok = false;
        }
        if (ok)
            ans++;
    }
    std::cout << ans << "\n";
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
n=int(input())
hoge=list(map(int,input().split()))

if(n%2):
  for i in range(n):
    if(i%2==0):
      print(hoge[-(i+1)],end=" ")
  for i in range(n):
    if(i%2==1):
      print(hoge[i],end=" ")
else:
  for i in range(n):
    if(i%2==1):
      print(hoge[-i],end=" ")
  for i in range(n):
    if(i%2==0):
      print(hoge[i],end=" ")

Measured memory_bytes: 26180
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,H;

int a[100005];
int b[100005];

int maxSwingPower;
int throwPower[100005];

signed main(){
    cin>>N>>H;
    for(int i=0;i<N;++i){
        cin>>a[i]>>b[i];
        maxSwingPower=max(a[i],maxSwingPower);
    }
    sort(b,b+N);
    for(int i=1;i<=N;++i){
        throwPower[i]=throwPower[i-1] + b[N-i];
    }
    int it=upper_bound(b,b+N,maxSwingPower)-b;
    int throwCount=N-it;
    int h=H-throwPower[throwCount];
    int swingCount=(h+maxSwingPower-1)/maxSwingPower;
    if(h<0){
        for(int i=0;i<=N;++i){
            if(H<=throwPower[i]){
                cout<<i<<endl;
                exit(0);
            }
        }
    }
    else cout<<swingCount+throwCount<<endl;

    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int in(){ int a; scanf("%d",&a); return a; }
int main(){
	int n,S;
	while(n=in(),S=in(),(n||S)){
		int w[101]={};
		int ans = 0;
		for(int i = 0 ; i < n ; i++) w[in()]++;
		
		for(int i = 0 ; i <= 100 ; i++){
			for(int j = i ; j <= 100 ; j++){
				if(i+j>S){
					if(i==j) ans+=w[i]*(w[i]-1)/2;
					else ans += w[i]*w[j];
				}
			}
		}
		printf("%d%c",ans,10);
	}
}

Measured memory_bytes: 876