akhauriyash/Code-Regression huggingface dataset:
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        int a,b;
        cin>>a>>b;
        cout<<a*b;
        



        cout<<'\n';
    return 0;
}

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ll get_max_rate(const multiset<ll>& s) {
	if (s.size() == 0) return (1LL << 60LL);
	auto iter = s.end();
	--iter;

	return *iter;
}

int solve() {
	ll X, N;
	cin >> X >> N;

	vector<ll> ps(N);
	for (ll i = 0; i < N; ++i) {
		cin >> ps[i];
	}
	sort(ps.begin(), ps.end());

	ll res = 1000, val;
	for (ll cand_x = 0; cand_x <= 101; ++cand_x) {
		bool found = false;
		for (ll i = 0; i < N; ++i) {
			if (cand_x == ps[i]) {
				found = true;
				break;
			}
		}
		if (!found && res > abs(cand_x - X)) {
			res = abs(cand_x - X);
			val = cand_x;
		}
	}

	cout << val << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 114514810893364364;

int main() {
  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    dump(x);
  }
  return 0;
}


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

int main() {
  int price = 700;
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == 'o') {
      price+= 100;
    }
  }
  cout << price << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,q = map(int,readline().split())

g = [[] for _ in range(n)] #隣接リスト
for i in range(n-1):
    a,b = map(int,readline().split())
    a,b = a-1,b-1
    g[a].append(b)
    g[b].append(a)

#親のノードに子を入れてくdfs
root = 0 #根
stack = [0]
parent = [0]*n
order = []
while stack:
    x = stack.pop()
    order.append(x)
    for i in g[x]:
        if i == parent[x]:
            continue
        parent[i] = x
        stack.append(i)

#ここで、何らかのクエリを消化する。
query = [0]*n
for i in range(q):
    p,x = map(int,readline().split())
    p -= 1
    query[p] += x

#全ての親についての累積和を取る。
#この時、親方向に逆流しないように注意。
for x in order: #親
    a = query[x]
    for y in g[x]: #子
        if y == parent[x]: #逆流防止弁(無向グラフにしているので双方向の道がある)
            continue
        query[y] += a #子にクエリを適応

#output
print(*query)

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

using namespace std;

int main(void)
{
	int n,L;cin>>n>>L;
	int a[n]; for(int i = 0; i < n; i++) cin>>a[i];
	
	bool flag = false;
	int left,right;
	for(int i = 0; i < n-1; i++){
		if(a[i]+a[i+1] >= L){
			//cout<<"i = "<<i<<", a[i] = "<<a[i]<<", L = "<<L<<endl;
			flag = true;
			left = i;
			right = i+1;
		}
	}
	if(flag == false){
		cout<<"Impossible"<<endl;
		return 0;
	}
	else{
		//cout<<"left = "<<left<<", right = "<<right<<endl;
		cout<<"Possible"<<endl;
		if(left >= 1){
			for(int i = 1; i <= left; i++){
				cout<<i<<endl;
			}
		}
		if(right < n-1){
			for(int i = n-1; i > right; i--){
				cout<<i<<endl;
			}
		}
		cout<<right<<endl;
	}
	return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

bool is_prime(int n) {
    for (int x = 2; x * x <= n; x++) {
        if (n % x == 0) return false;
    }
    return true;
}

int X;

int solve() {
    while (1) {
        if (is_prime(X)) return X;
        X++;
    }
}

int main() {
    cin >> X;
    cout << solve() << endl;
}

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

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split();
			int n = int.Parse(nk[0]);
			int k = int.Parse(nk[1]);
			var hList = from h in Console.ReadLine().Split()
						where int.Parse(h) >= k
						select h;

			Console.WriteLine(hList.Count());
		}
	}
}


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

using namespace std;

int findNum(vector<pair<int, long long> > comm, int num) {
    for(int i=0; i<comm.size(); i++)  {
      if(comm[i].first == num) {
	return i;
      }
    }
    return comm.size();
  }

int main() {
  int n;
  cin>>n;
  while(n != 0) {
    int m = n;
    vector<pair<int, long long> > comm;
    while(m--) {
      int num;
      long long price, unit;
      cin>>num>>price>>unit;
      int dataNum = findNum(comm, num);
      if(dataNum == comm.size()) {
        comm.push_back(make_pair(num, price*unit));
      }
      else {
        comm[dataNum].second += price*unit;
      }
    }

    bool flag = true;
    for(int i=0; i<comm.size(); i++) {
      if(comm[i].second >= 1000000) {
        cout<<comm[i].first<<endl;
        flag = false;
      }
    }
    if(flag == true) {
      cout<<"NA"<<endl;
    }
    cin>>n;
  }
}

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

using namespace std;

bool isPal(string s, int st, int en)
{
    for(int i = st; i <= en; i++){
        if(s[i] != s[en-i])return 0;
    }
    return 1;
}

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    if(isPal(s, 0, n-1) && isPal(s, 0, (n-1)/2-1) && isPal(s, (n+3)/2-1, n-1))
        cout << "Yes\n";
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	int x[100];
	cin >> n;
	rep(i, n)cin >> x[i];

	int ans = INF;
	rep(p, 101) {
		int s = 0;
		rep(i, n) s += (x[i]-p) * (x[i]-p);
		ans = min(ans, s);
	}
	cout << ans << endl;



	return 0;
}

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

int main() {
  ll Q,H,S,D;
  cin >> Q >> H >> S >> D;
  ll N;
  cin >> N;
  N *= 4;
  ll ans = 0;
  ll N2 = N % 8;
   N = N / 8;
  ans += N * min({8*Q,4*H,2*S,D});
   N2 = N2 / 4;
  ans += N2 * min({4*Q,2*H,S});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in) );

		int n = Integer.parseInt(br.readLine());

		Card[] nc = new Card[n];
		for (int i=0; i < n; i++) {
			String[] temp = br.readLine().split(" ");
			Card c = new Card(temp[0], Integer.parseInt(temp[1]), i);
			nc[i] = c;
//			nc[i].suit = temp[0];
//			nc[i].num = Integer.parseInt(temp[1]);
//			nc[i].pos = i;
		}

		quicksort(nc, 0, n-1);

		int counter;
		for (counter=0; counter < n-1; counter++) {
			if (nc[counter].num == nc[counter+1].num) {
				if (nc[counter].pos > nc[counter+1].pos) {
					System.out.println("Not stable");
					break;
				}
			}
		}
		if (counter == n-1) {
			System.out.println("Stable");
		}

		for(int i=0; i < n; i++) {
			System.out.println(nc[i]);
		}
	}

	static class Card {
		String suit;

		int num;

		int pos;

		Card(String suit, int num, int pos) {
			this.suit = suit;
			this.num = num;
			this.pos = pos;
		}

		@Override
		public String toString(){
			return suit + " " + num;
		}
	}

	static int partition(Card[] A, int p, int r) {
		int x = A[r].num;
		int i = p - 1;
		Card temp;
		for (int j=p; j < r; j++) {
			if (A[j].num <= x) {
				i++;
				temp = A[j];
				A[j] = A[i];
				A[i] = temp;
			}
		}
		temp = A[r];
		A[r] = A[i+1];
		A[i+1] = temp;
		return i+1;
	}

	static void quicksort(Card[] A, int p, int r) {
		if (p < r) {
			int q = partition(A, p, r);
			quicksort(A, p, q-1);
			quicksort(A, q+1, r);
		}
	}
}

Measured memory_bytes: 76316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
struct Union_Find{
  vi par;
  int N;
  Union_Find(int n):par(n){
    N=n;
    rep(i,0,N) par[i]=i;
  }
  int root(int X){
    if(par[X]==X) return X;
    return par[X]=root(par[X]);
  }
  void unite(int X,int Y){
    int rx=root(X),ry=root(Y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int X,int Y){
    return root(X)==root(Y);
  }
};
struct Edge{
  int a,b,cost;
  bool operator<(const Edge &o) const{
    return cost<o.cost;
  }
};
struct Gragh{
  int N;
  vector<Edge> E;
  vector<pii> A,B;
  Gragh(int n):A(n),B(n),E(n*2-2){
    N=n;
    rep(i,0,N){
      int X,Y; cin>>X>>Y;
      A[i]=mp(X,i);
      B[i]=mp(Y,i);
    }
  }
  void make(){
    sort(ALL(A));
    sort(ALL(B));
    int m=0;
    rep(i,1,N){
      E[m].a=A[i].second;
      E[m].b=A[i-1].second;
      E[m].cost=A[i].first-A[i-1].first;
      m++;
    }
    rep(i,1,N){
      E[m].a=B[i].second;
      E[m].b=B[i-1].second;
      E[m].cost=B[i].first-B[i-1].first;
      m++;
    }
  }
  int kruskal(){
    sort(ALL(E));
    int ret=0;
    Union_Find tree(N);
    rep(i,0,E.size()){
      if(!tree.same(E[i].a,E[i].b)){
        tree.unite(E[i].a,E[i].b);
        ret+=E[i].cost;
      }
    }
    return ret;
  }
};
signed main(){
  int N; cin>>N;
  Gragh G(N);
  G.make();
  cout<<G.kruskal()<<endl;
  }



Measured memory_bytes: 8832
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
R = 1000000007

def dfs(x,y):
    if x == n:
        return 1
    if dp[y] > -1:
        return dp[y]
    sum = 0
    for j in range(n):
        b = 1 << j
        if a[x][j] == 1 and (y&b) == 0:
            sum += dfs(x+1, y|b)
            if sum > R:
                sum -= R
    dp[y] = sum
    return sum

n = inn()
a = [ 0 for i in range(n) ]
for i in range(n):
    a[i] = inl()
dp = [-1] * (2**n)
print(dfs(0,0))


Measured memory_bytes: 64220
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
using namespace std;

int main()
{
	fast;
	string s; cin>>s; ll k; cin>>k;
	vector<string>ans; ll n = s.size();
	unordered_map<string,ll>mp;
	for(ll i = 0; i < n; i++)
	{
		for(ll len = 1; len <= k; len++)
		{
			string t = s.substr(i,len);
			if(!mp.count(t))
				ans.push_back(t);
			mp[t]++;
		}	
	}
	std::nth_element(ans.begin(),ans.begin()+k-1,ans.end());
	cout << ans[k-1] << endl;
	return 0;
}

Measured memory_bytes: 4732
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[100];
int main(){
	int N;
	scanf("%d",&N);
	int ans = 0; 
	for(int i = 1;i <= N;i++){
		scanf("%d",&a[i]);
		bool flag = true;
		for(int j = 1;j < i;j++){
			if(a[j] > a[i]){
				flag = false;
				break;
			}
		}
		ans += flag;
	} 
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 128
function Main(s) {
  var arr = s.split("\n");
  var dp = [1, 1, 2];
  for (var i = 3; i < 31; i++) {
    dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
  }
  for (var i = 0; i < s.length - 1; i++) {
    if(arr[i] == "0") break;
    console.log(Math.ceil(dp[arr[i]] / 3650));
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15424
var lines = [];

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
})

rl.on('line', function (x) {
    lines.push(x);
});

rl.on("close", function () {
    var N = Number(lines[0]);
    var dp = Array(Math.max(N, Math.pow(9, 5))).fill(0);
        
    dp[Math.pow(6, 6)] = 1;
    dp[Math.pow(9, 5)] = 1, dp[Math.pow(6, 5)] = 1;
    dp[Math.pow(9, 4)] = 1, dp[Math.pow(6, 4)] = 1;
    dp[Math.pow(9, 3)] = 1, dp[Math.pow(6, 3)] = 1;
    dp[Math.pow(9, 2)] = 1, dp[Math.pow(6, 2)] = 1;
    dp[Math.pow(9, 1)] = 1, dp[Math.pow(6, 1)] = 1;
    dp[1] = 1, dp[0] = 0;

    for (var index = 1; index <= N; index++) {
        var a = Infinity; var b = Infinity; var c = Infinity; var d = Infinity;
        var e = Infinity; var f = Infinity; var g = Infinity; var h = Infinity;
        var i = Infinity; var j = Infinity; var k = Infinity; var l = Infinity;

        if (0 <= index - Math.pow(6, 6)) a = dp[index - Math.pow(6, 6)] + dp[Math.pow(6, 6)];
        if (0 <= index - Math.pow(9, 5)) b = dp[index - Math.pow(9, 5)] + dp[Math.pow(9, 5)];
        if (0 <= index - Math.pow(6, 5)) c = dp[index - Math.pow(6, 5)] + dp[Math.pow(6, 5)];
        if (0 <= index - Math.pow(9, 4)) d = dp[index - Math.pow(9, 4)] + dp[Math.pow(9, 4)];
        if (0 <= index - Math.pow(6, 4)) e = dp[index - Math.pow(6, 4)] + dp[Math.pow(6, 4)];
        if (0 <= index - Math.pow(9, 3)) f = dp[index - Math.pow(9, 3)] + dp[Math.pow(9, 3)];
        if (0 <= index - Math.pow(6, 3)) g = dp[index - Math.pow(6, 3)] + dp[Math.pow(6, 3)];
        if (0 <= index - Math.pow(9, 2)) h = dp[index - Math.pow(9, 2)] + dp[Math.pow(9, 2)];
        if (0 <= index - Math.pow(6, 2)) i = dp[index - Math.pow(6, 2)] + dp[Math.pow(6, 2)];
        if (0 <= index - Math.pow(9, 1)) j = dp[index - Math.pow(9, 1)] + dp[Math.pow(9, 1)];
        if (0 <= index - Math.pow(6, 1)) k = dp[index - Math.pow(6, 1)] + dp[Math.pow(6, 1)];
        if (0 <= index - 1) l = dp[index - 1] + dp[1]

        dp[index] = Math.min(a, b, c, d, e, f, g, h, i, j, k, l);
    }

    console.log(dp[N]);
});

Measured memory_bytes: 29672
# -*- coding: utf-8 -*-
"""
Created on Wed Jun  3 14:11:35 2020

@author: NEC-PCuser
"""
def gcd(a, b):
    
    if (a % b == 0):
        return b
    return gcd(b, a % b)

def factorize(num):
    i = 2
    factorize_list = []
    num_tmp = num
    while i * i <= num_tmp:
        count = 0
        if num % i == 0:
            while num % i == 0:
                count += 1
                num //= i
            factorize_list.append([i, count])
        i += 1
    if num != 1:
        factorize_list.append([num, 1])
    return factorize_list 
                


if __name__ == "__main__":
    A, B =  map(int, input().split())
    big_num = max(A, B)
    short_num = min(A, B)
    gcd_num = gcd(big_num, short_num)
    print(len(factorize(gcd_num)) + 1)
            


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	int ans=0;
	while(cin>>s){
		string str1="",str2="";
		if(s.size()%2){		
			rep(i,s.size()/2)str1+=s[i];
			for(int i=s.size()-1;i>s.size()/2;i--)str2+=s[i];
		}else{
			rep(i,s.size()/2)str1+=s[i];
			for(int i=s.size()-1;i>=s.size()/2;i--)str2+=s[i];
		}
		if(str1==str2)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n, i, k, c, dp[222222];
	string s;
	vector<int> v;
	cin >> n >> k >> c >> s;
	dp[0] = 0;
	for (i = 1; i <= n; i++)
	{
		if(s[i-1]=='o'){
			if(i-c-1<0)
				dp[i] = 1;
			else
				dp[i] = dp[i - c - 1] + 1;
		}
		else
			dp[i] = dp[i - 1];
	}
	i = n;
	while(s[i-1]=='x')
		i--;
	while (k > 0)
	{
		int p = i;
		i--;
		while (s[i - 1] == 'x' && i > 1)
			i--;
		if(dp[i]<k)
			v.push_back(p);
		while((i+c>=p||s[i-1]=='x') && i > 1)
			i--;
		k--;
	}
	sort(v.begin(), v.end());
	for(auto &e:v)
		cout << e << endl;
}

Measured memory_bytes: 3448
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


ans = 0
t = 21
a = 0
for i in range(N):
    ans += B[A[i]-1]
    if i !=0:
        if A[i]-1 == A[i-1]-1+1:
            ans += C[t]
    t = A[i]-1
print(ans)

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    string str;
    cin >> str;

    REP(i, A + B + 1) {
        if (i == A) {
            if (str[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (str[i] < '0' || '9' < str[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(k,i,n) for(int i = (k); i < (int)(n); i++)
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) a/__gcd(a,b)*b
typedef long long ll;
typedef pair<int,int> Pii;


int main() {
    string s;ll k;cin>>s>>k;
    ll n=s.size();
    vector<ll> m(0,0),mm(0,0);
    if(n==1) {cout<<k/2; return 0;}
    rep(i,n-1){
        if(s[i]!=s[i+1]) break;
        else if(i==n-2){cout<<n*k/2;return 0;}
    }
    ll l=1;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            l++;
        }
        else{
            m.push_back(l);
            l=1;
        }
    }
    m.push_back(l);
    ll sum=0,ans=0;
    for(ll x:m){
        sum+=x/2;
    }
    s+=s;
    l=1;
    rep(i,n*2-1){
        if(s[i]==s[i+1]){
            l++;
        }
        else{
            mm.push_back(l);
            l=1;
        }
    }
    mm.push_back(l);
    for(ll x:mm){
        ans+=x/2;
    }
    cout<<sum+(ans-sum)*(k-1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
int read() {
    char ch = getchar();
    int x = 0, flag = 1;
    for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
    for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x * flag;
}
void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int Maxn = 100009;
struct edge {
	int to, nxt;
}g[Maxn << 1];
int n, m, dp[Maxn], head[Maxn], e;

void add(int u, int v) {
	g[++e] = (edge){v, head[u]}, head[u] = e;
}

void init() {
	clar(head, -1);
	n = read(), m = read();
	rep (i, 1, m) {
		int u = read(), v = read();
		add(u, v);
	}
}

int dfs(int u) {
	if (dp[u]) return dp[u];
	int res = 0;
	for (int i = head[u]; ~i; i = g[i].nxt) {
		int v = g[i].to;
		res = max(dfs(v) + 1, res);
	}
	return dp[u] = res;
}

void solve() {
	rep (i, 1, n) dp[i] = dfs(i);

	int ans = 0;
	rep (i, 1, n) ans = max(dp[i], ans);	
	cout << ans << endl;
}

int main() {
//	freopen("G.in", "r", stdin);
//	freopen("G.out", "w", stdout);

	init();
	solve();

#ifdef Qrsikno
    debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
    return 0;
}



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

int main() {
	while(true){
	int sum,r;
	cin >> sum;
	if(sum==0)
		break;
	for(int i=0;i<9;i++){
	cin >> r;
	sum-=r;
	}
	cout << sum <<endl;
	}
	return 0;
}

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

int main(void){
    int n, m, a, sum=0, c=0;
    cin >> n >> m;
    vector<int> count(1001);
    for(int i=0; i<n; i++){
        cin >> a;
        count[a]++;
        sum += a;
    }
    for(int i=1001; i>=((sum%(4*m)==0)?sum/(4*m):sum/(4*m)+1); i--){
        if(count[i] == 1) c++;
        if(c == m){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int x=sc.nextInt();
            if(n==0&&x==0) break;
            int ans=0;
            for(int i=1;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    for(int k=j+1;k<=n;k++){
                        if(i+j+k==x) ans++;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 26500
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

n, x = map(int,input().split())
li = list(map(int,input().split()))
d = [abs(x-li[0])]
 
for i in range(n-1):
    d.append(abs(li[i]-li[i+1]))

print(gcd(*d))

Measured memory_bytes: 16280
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{
    int n;
    cin >> n;
    cout << (n+999)/1000 * 1000 - n << endl;   
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N,Z,W;
    cin >> N >> Z >> W;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    if(N==1) cout << abs(W-a[N-1]) << endl;
    else cout << max(abs(W-a[N-1]),abs(a[N-2]-a[N-1])) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 36
#define TRUE 1
#define FALSE 0

typedef struct {
    char suit;
    int value;
} Card;

int eq_cards(Card a, Card b){
    if(a.value == b.value && a.suit == b.suit) return TRUE;
    else return FALSE;
}

void swap(Card *a, Card *b){
    Card temp;
    temp = *a;
    *a = *b;
    *b = temp;
    return;
}

Card* selectionsort(int n, Card *r){
    int i,j,minj;
    Card *res;
    res = (Card *)malloc(N * sizeof(Card));
    for(i=0;i<n;i++) res[i] = r[i];

    for(i=0;i<n;i++){
        minj = i;
        for(j=i;j<n;j++){
            if(res[j].value<res[minj].value) minj = j;
        }
        swap(&res[i], &res[minj]);
    }
    return res;
}

Card* bubblesort(int n, Card *r){
    int flag = 1;
    int i;
    Card *res;
    res = (Card *)malloc(N * sizeof(Card));
    for(i=0;i<n;i++) res[i] = r[i];

    while(flag){
        flag = 0;
        for(i=n-1;i>0;i--){
            if(res[i].value<res[i-1].value){
                swap(&res[i], &res[i-1]);
                flag = 1;
            }
        }
    }
    return res;
}

void print_array(Card *cs, int n){
    int i;
    for(i=0;i<n-1;i++) printf("%c%d ", cs[i].suit, cs[i].value);
    printf("%c%d\n", cs[n-1].suit, cs[n-1].value);

}

int is_stable(Card *b, Card *a, int n){
    int i, j, k, l;
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            for(k=0;k<n;k++)
                for(l=k+1;l<n;l++)
                    if(b[i].value == b[j].value && eq_cards(b[i], a[l]) && eq_cards(b[j], a[k])) return FALSE;
    return TRUE;
}

int main(){
    int n;
    Card r[N];
    int i, j;
    Card *b_res, *s_res;

    scanf("%d", &n);
    for(i=0;i<n;i++) scanf(" %c%d", &r[i].suit, &r[i].value);

    b_res = bubblesort(n, r);
    s_res = selectionsort(n, r);
    
    print_array(b_res, n);
    if(is_stable(r, b_res, n)==TRUE) printf("Stable\n");
    else printf("Un stable\n");
    print_array(s_res, n);
    if(is_stable(r, s_res, n)==TRUE) printf("Stable\n");
    else printf("Not stable\n");
    
    free(b_res);
    free(s_res);
    return 0;
}

Measured memory_bytes: 608
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
               cnt+=1
               temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
        N = int(input())

        fac = factorization(N)

        arr = []

        for i in range(len(fac)):
                for j in range(fac[i][1]):
                        temp = fac[i][0]**(j+1)
                        arr.append(temp)

        arr.sort()

        count = 0

        for i in range(len(arr)):
                if N==1:
                        break
                else:
                        if N%arr[i]==0:
                                N = N/arr[i]
                                count += 1

        return count

if __name__=="__main__":
        ans = main()
        print(ans)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep (i, n) cin >> a[i];
  double bunbo = 0;
  rep (i, n) {
    bunbo += 1.0 / a[i];
  }
  Sp(1.0 / bunbo);
}


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


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


factors = factorization(N - 1)
tmp = 1
for prime, power in factors:
    tmp *= power + 1

ans = tmp - 1


divisors = make_divisors(N)
divisors.remove(1)
for d in divisors:
    n = N
    while n % d == 0:
        n //= d
    if n % d == 1:
        ans += 1

if N == 2:
    ans = 1
print(ans)


Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)


//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int tb[1500][1500];
int am[1500][1500];

int main() {
	
	int h, w; cin >> h >> w;

	LL ans = 0;
	for (int i = 0; i < h; i++) {

		for (int j = 0; j < w; j++) {
			int buf; cin >> buf;
			
			if (buf == 1) {
				tb[i][j] = 0;
			}
			else {
				tb[i][j] = 1;
				ans = 1;
			}
			
		}
		
	}

	for (int i = 0; i < h; i++)am[i][0] = tb[i][0];
	for (int j = 0; j < w; j++)am[0][j] = tb[0][j];


	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (tb[i][j] == 0) {
				am[i][j] = 0;
			}
			else {
				am[i][j] = min(am[i - 1][j - 1], min(am[i - 1][j], am[i][j - 1])) + 1;
			}

			ans = max(ans, (LL)am[i][j] * am[i][j]);
		}
	}

	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 19540
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)

C = [-1]*n
def is_bipartite(v, color):
  C[v] = color
  for nv in G[v]:
    if C[nv] != -1 and color == C[nv]:
      return False
    if C[nv] == -1:
      if not is_bipartite(nv, color ^ 1):
        return False
  return True

if is_bipartite(0, 0):
  b = C.count(0)
  w = n - b
  ans = b*w - m
else:
  ans = n*(n-1)//2 - m
print(ans)

Measured memory_bytes: 31132
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	double a, b;
	cin >> a >> b;
	cout << b * 2 - a << endl;
	return 0;
}

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

int main() {
    string s,x;
    cin >> s >> x;
    int n = s.size();
    int m = x.size();
    int mx = 1001;
    for (int i = 0; i < n - m + 1; i++){
        string temp;
        int cnt = 0;
        for (int j = i; j < i + m; j++){
            temp += s[j];
        }
        for (int j = 0; j < m; j++){
            if (temp[j] == x[j])
                cnt++;
        }
        mx = min(mx,m - cnt);
    }
    cout << mx << endl;
    return 0;
}

//

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

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

  int n; cin >> n;
  vector<P> v(n);
  vector<P> junban(n);
  REP(i, n) {
    cin >> v[i].first >> v[i].second;
    junban[i] = {v[i].first, i};
  }
  sort(ALL(v));
  sort(ALL(junban));

  dsu uf(n);
  set<P> st;
  REP(i, n) {
    vector<P> use;
    for(auto &e: st) {
      if(e.first < v[i].second) {
        use.emplace_back(e);
      } else {
        break;
      }
    }

    for(auto &e: use) {
      uf.merge(i, e.second);
    }

    if(use.empty()) {
      st.insert({v[i].second, i});
    }
  }

  map<int, int> cnt;
  REP(i, n) {
    //cout << uf.leader(i) << endl;
    cnt[uf.leader(i)]++;
  }

  vi ans(n);
  REP(i, n) {
    ans[junban[i].second] = cnt[uf.leader(i)];
  }

  REP(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 12764
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int gcd(int q,int r){
	if(!r)return q;
	return gcd(r,q%r);
}

int c(int p,int q,int a,int n,int m){
	//cout<<p<<" "<<q<<" "<<a<<" "<<n<<" "<<m<<endl;
	if(p<0||q<0)return 0;
	if(!a)return 0;
	if(!p)return 1;
	if(p>1&&n==1)return 0;
	int res=0;
	for(int r=max(q/p,m);r<=min(q*n/p,a);r++){
		int u=p*r-q,d=q*r;
		res+=c(u/gcd(u,d),d/gcd(u,d),a/r,n-1,r);
	}
	return res;
}

int p,q,a,n;

int main(){
	while(cin>>p>>q>>a>>n&&p)cout<<c(p,q,a,n,1)<<endl;
}

Measured memory_bytes: 864
using System;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;
            
            string[] str = Console.ReadLine().Split(' ');
            b = int.Parse(str[0]);
            c = int.Parse(str[1]);

            if (b == c)
            {
                Console.WriteLine(b + c);
            }
            else if (b>c)
            {
                Console.WriteLine(b + b - 1);
            }
            else
            {
                Console.WriteLine(c + c - 1);
            }
        }
    }
}


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

int N, x, ans = 0;
int main(){
    cin >> N;
    REP(i,N){
        cin >> x;
        while(x % 2 == 0){
            x /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
}

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


long long bt[200005], a[200005];
int n;
int h[200005];


void inp()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) cin >> a[i];
}

void upd(int h, long long v)
{
    for (int i = h; i <= n; i+= i&-i)
    bt[i] = max(bt[i], v);
}

long long gett(int h)
{
    long long tmp = 0;
    for (int i = h; i > 0; i -= i&-i)
    tmp = max(tmp,bt[i]);
    return tmp;
}


void proc()
{
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        long long tmp = gett(h[i]);
        tmp = tmp + a[i];
        ans = max(ans,tmp);
        upd(h[i],tmp);
    }
    cout << ans;
}


int main()
{
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 4096
package main

import (
	"fmt"
)

func main(){
	for {
		var deck string
		var h, times int
		fmt.Scan(&deck)
		if deck == "-" {
			break
		}
		fmt.Scan(&h)
		for i:=0; i<h; i++{
			fmt.Scan(&times)
			deck = deck[times:] + deck[:times]
		}
		fmt.Println(deck)
	}
}


Measured memory_bytes: 1112
#include <stdio.h>

int main(){
	
	int num;
	long long sum = 0;
	scanf("%d", &num);
	for(int i=1;i<=num;i++){
	
	if(!(i%3 == 0 || i%5 == 0)){
		sum = sum + i;
			
	}
}	
	
	printf("%lld", sum);
	
	
	
	return 0;
}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
string s; int n,ans;
int main()
{
	cin>>s; n=s.size();
	for(int i=0;i<n/2;i++)
		ans+=(s[i]!=s[n-i-1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, x; cin >> n >> x;
    vector<lint> a(n); repeat(i, n) cin >> a[i];
    
    lint ans = 0;
    repeat(i, n-1) {
        lint dif = a[i] + a[i+1] - x;
        if (dif > 0) {
            ans += dif;
            if (a[i+1] >= dif) {
                a[i+1] -= dif;
            }
            else {
                a[i] = x;
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

using namespace std;

int main(){
	int n,t; scanf("%d%d",&n,&t);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int cnt=0,mn=a[0],h=0;
	rep(i,n){
		mn=min(mn,a[i]);
		if(h<a[i]-mn){
			h=a[i]-mn;
			cnt=1;
		}
		else if(h==a[i]-mn){
			cnt++;
		}
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=1000000+5;
const int MOD=1000000007;
template<class T> inline void read(T &x){
	x=0; 
	T f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	x*=f;
}
map<string,ll> ma;
ll n;
int main(){
	string s;
	read(n);
	for(int i=1;i<=n;i++){
		cin>>s;
		ma[s]++;
	}
	cout<<"AC x "<<ma["AC"]<<endl;
	cout<<"WA x "<<ma["WA"]<<endl;
	cout<<"TLE x "<<ma["TLE"]<<endl;
	cout<<"RE x "<<ma["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int N,count = 0;
        N = Integer.parseInt(scan.next());
        count = N;
        int H[] = new int[N];
        for(int i = 0;i < N;i++){
            H[i] = Integer.parseInt(scan.next());
        }

        for(int i = 1;i < N;i++){
            for(int j = 0;j < i;j++){
                if(H[i] < H[j]){
                    count--;
                    break;
                }
            }
        }
        System.out.println(count);
            
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

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

    int N, K, L;
    cin >> N >> K >> L;
    UnionFind road(N), railway(N);
    for(int i = 0; i < K; ++i){
        int x, y;
        cin >> x >> y;
        --x, --y;
        road.unite(x, y);
    }
    vector<int> x(L), y(L);
    for(int i = 0; i < L; ++i){
        cin >> x[i] >> y[i];
        --x[i], --y[i];
        railway.unite(x[i], y[i]);
    }
    map<P, int> mp;
    for(int i = 0; i < N; ++i){
        ++mp[P(road.find(i), railway.find(i))];
    }
    for(int i = 0; i < N; ++i){
        cout << mp[P(road.find(i), railway.find(i))];
        cout << ((i == N - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 18444