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

int main(int argc, char const *argv[])
{
	int n,q;
	cin>>n>>q;
	vector<pair<pair<long long,int>,long long>> v;
	long long s,t,x;
	for (int i = 0; i < n; ++i)
	{
		cin>>s>>t>>x;
		v.emplace_back(make_pair(make_pair(s-x,-1),x));
		v.emplace_back(make_pair(make_pair(t-x,0),x));
	}
	long long d;
	for (int i = 0; i < q; ++i)
	{
		cin>>d;
		v.emplace_back(make_pair(make_pair(d,1),i));
	}
	sort(v.begin(), v.end());
	multiset<long long> memo={};
	for (auto i = v.begin(); i != v.end(); ++i)
	{
		auto p=*i;
		if (p.first.second==-1)
		{
			memo.insert(p.second);
		}
		else if (p.first.second==0)
		{
			memo.erase(memo.lower_bound(p.second));
		}
		else
		{
			if (memo.size()>0)
			{
				cout<<*memo.begin()<<endl;
			}
			else
			{
				cout<<"-1\n";
			}
		}
	}
	return 0;
}


Measured memory_bytes: 26728
N = int(input())
Ls = list(map(int, input().split()))

Ls.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            A, B, C = Ls[i], Ls[j], Ls[k]
            if A == B or B == C or C == A:
                continue
            if A + B > C:
                ans += 1

print(ans)


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

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


int main() {
	
	int n;
	cin >> n;
	
	vector<vector<int>> a(n, vector<int>(3));
	rep(i, n){
		rep(j, 3){
			cin >> a[i][j];
		}
	}
	
	vector<vector<ll>> dp(n+1, vector<ll>(3));
	
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(j==k) continue;
				chmax(dp[i+1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	ll ans = 0;
	rep(i, 3) chmax(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}

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

long gcd(long x, long y){
  if(y==0) return x;
  return gcd(y, x%y);
}

int main(){
  int N;
  long A, g=0;
  cin >> N;
  cin >> A;
  g = A;
  for(int i=1; i<N; i++){
    cin >> A;
    g = gcd(A, g);
  }
  int count=0;
  while(g>1){
    g /= 2;
    count++;
  }
  cout << count << endl;
  return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) (ll)arr.size()

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
/*ll f[200001];
ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }*/


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i < n; ++i) {
		int x;
		cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; ++i)
		cout << a[i] << "\n";
	return 0;
}


Measured memory_bytes: 3992
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        int N = readInt();
        int X = readInt();
        int T = readInt();

        pw.println((N + X - 1) / X * T);
        pw.close();
    }
}


Measured memory_bytes: 32608
import collections
n,ais,cc = int(raw_input()), map(int, raw_input().split()), collections.Counter()
for ai in ais:
	if ai % 4 == 0: cc[0] += 1
	elif ai % 2 == 0: cc[1] += 1
	else: cc[2] += 1

p,h = 0, [[2,1,0],[1],[0]] 
while(n):
	for u in h[p] + [-1]:
		if u == -1: 
			p =-1
			break
		if cc[u] > 0:
			p = u
			cc[u] -=1
			n -=1
			break
	if p == -1: break

print 'Yes' if n == 0 else 'No'

Measured memory_bytes: 89616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    ll a, b, v, w, t;

    cin >> b >> w >> a >> v >> t;

    int flag = 0;
    if(a < b && a-v*t >= b-w*t){
        flag = 1;
    }
    if(a > b && a+v*t <= b+w*t){
        flag = 1;
    }

    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
from operator import itemgetter
n = int(input())
l= [list(map(int,input().split())) for i in range(n)]
l.sort(key = itemgetter(1))
#print(l)
ima = 0
gou = 0
for i, j in l:
    ima += i
    if ima > j:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 87640
#include<cstdio>
#include<cmath>

int main(void){
double a,b,C;
long double S,c,h;
scanf("%lf%lf%lf",&a,&b,&C);
C=C*3.1415926535897932384/180;
S=a*b*sin(C)*0.50;
c=sqrt(a*a+b*b-2*a*b*cos(C));
h=2*S/a;
printf("%Lf\n%Lf\n%Lf\n",S,a+b+c,h);
return 0;
}

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

#define int long long
const int INF = LLONG_MAX/10;
const char dc[] = "RULD";

int SX, SY, TX, TY;

void Move(int dir)
{
	printf("%c", dc[dir]);
}

void Move(int dir, int count)
{
	for (int i = 0; i < count; i++) Move(dir);
}

signed main()
{
	cin >> SX >> SY >> TX >> TY;
	int dx = TX - SX, dy = TY - SY;
	Move(3);
	Move(0, dx + 1);
	Move(1, dy + 1);
	Move(2);
	Move(3, dy);
	Move(2, dx);
	Move(1, dy);
	Move(0, dx);
	Move(1);
	Move(2, dx + 1);
	Move(3, dy + 1);
	Move(0);
	puts("");
	return 0;
}

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

int lth,vis[30];
char s[30];

int main()
{
    scanf("%s",s+1),lth=strlen(s+1);
    for(int i=1;i<=lth;i++)vis[s[i]-'a']=i;
    if(lth<26)
    {
        for(int i=0;i<26;i++)if(!vis[i])
            return printf("%s%c",s+1,'a'+i),0;
    }
    else for(int i=26;i;i--)
        for(int j=s[i]-'a'+1;j<26;j++)if(vis[j]>i)
        {
            s[i]='a'+j,s[i+1]=0;
            return printf("%s",s+1),0;
        }
    return puts("-1"),0;
}

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

int main(){
    std::vector<int> v;
    int num_1,num_2,num_3;
    std::cin>>num_1>>num_2>>num_3;
    v.push_back(num_1);
    v.push_back(num_2);
    v.push_back(num_3);
    std::sort(v.begin(),v.end());
    
    for(int i=0;i<3;i++){
        std::cout<<v[i];
        if(i<2) std::cout<<" ";
    }
    std::cout<<std::endl;
    
    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)



int main()
{
   long double a,b,h,m;
   cin>>a>>b>>h>>m;
   h=h*30 + m*.5;
   m=m*6;

   long double dif=abs(m-h);//*30;
   long double pp= (pi*dif)/180;
  // long double qq=sin(pp);
   //cout<<qq<<endl;

   long double ans= a*a + b*b - 2*a*b*(cos(pp));
   ans= sqrt(ans);

   cout<< setprecision(10)<<fixed<<ans<<endl;



}




Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch DuplexPrinting | diff DuplexPrinting.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address DuplexPrinting.cpp && ./a.out

/*
 
 3/1/2020
 
 8:30-
 
 */

int N;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  cout<<((N+1)/2)<<endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n, m;
    cin >> n >> m;
    ll mx = 1,mn = n;

    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        mx = max(mx, a);
        mn = min(mn, b);
    }
    ll z = 0;
    cout << max(z, ((mn - mx) + 1)) << endl;
    return 0;
}


Measured memory_bytes: 3652
#ifndef LOCAL
#define NDEBUG 1
#endif
#include<bits/stdc++.h>

struct IndexedValue{
	int value, index;
	bool operator<(IndexedValue other) const{return value<other.value;}
};

template IndexedValue const& std::max<IndexedValue>(IndexedValue const&,IndexedValue const&);

struct RMQ{
	using T=IndexedValue;
	auto static constexpr f=(T const&(*)(T const&,T const&))std::max<T>;

	std::vector<std::vector<T>> d;
	RMQ():d(){}
	RMQ(std::vector<T> x):d(){
		assign(std::move(x));
	}
	void assign(std::vector<T> x){
		d.assign(1,std::move(x));
		for(int step=1;step<(int)d.back().size();step<<=1){
			std::vector<T> const& a=d.back();
			std::vector<T> b(begin(a),end(a)-step);
			std::transform(begin(b),end(b),begin(a)+step,begin(b),f);
			d.push_back(std::move(b));
		}
	}
	T get(int l,int r)const{
		assert(l<r);
		int layer=std::__lg(r-l);
		return f(d[layer][l],d[layer][r-(1<<layer)]);
	}

};

RMQ maximum;
std::vector<std::vector<int64_t>> cost; //[right][left]=sum(maximum value of each ticket)

void process(int left, int right){ // updates the (cost) array.
	if(left==right) return;
	auto temp=maximum.get(left, right);
	auto value=temp.value; auto index=temp.index;
	
	cost[index+1][left]+=value; cost[right+1][left]-=value;
	cost[index+1][index+1]-=value; cost[right+1][index+1]+=value;
	// will be accumulated (to suffix) later

	process(left, index); process(index+1, right);
}

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int height, width; std::cin>>height>>width;
	std::vector<int> gap(height-1);for(auto & item: gap) std::cin>>item;
	std::vector<std::vector<int>> value(height);
	for(auto & row: value){
		row.resize(width);
		for(auto & item: row) std::cin>>item;
	}

	cost.resize(height+2);
	for(int i=0;i<cost.size();++i) cost[i].resize(i+1);

	for(int col=0;col<width;++col) {
		std::vector<IndexedValue> data(height);
		for(int row=0;row<height;++row) data[row]={value[row][col], row};
		maximum.assign(std::move(data));

		process(0, height);
	}

	for(auto & row: cost)
		for(int index=0;index+1<(int)row.size();++index) 
			row[index+1]+=row[index];
	for(int row=0;row+1<=height;++row) 
		for(int col=0;col<(int)cost[row].size();++col)
			cost[row+1][col]+=cost[row][col];

	int64_t result=0;
	for(int right=0;right<=height;++right){
		int64_t totalWalk=0;
		for(int left=right-1;left>=0;--left, totalWalk+=left>=0 ? gap[left] : 0)
			result=std::max(result,cost[right][left]-totalWalk);
	}
	std::cout<<result<<'\n';
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b;
int main() {
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 3612
package main

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

var (
	f, s int
	tmp  int
	m    = make(map[int]int)
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	for sc.Scan() {
		tmp, _ := strconv.Atoi(sc.Text())
		m[tmp]++

		if m[tmp] >= 2 {
			if tmp > f {
				s = f
				f = tmp
				m[tmp] -= 2
			} else if tmp > s {
				s = tmp
				m[tmp] -= 2
			}
		}
	}
	fmt.Println(f * s)
}


Measured memory_bytes: 7424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
using namespace std;

typedef long long ll;
const ll maxn=1e5+10;
ll n,q,a[maxn],ans[maxn];
vector<ll> vec;
map<ll,ll> mp;

int main(){
	scanf("%lld%lld",&n,&q);
	vec.push_back(n);
	for(ll i=1;i<=q;++i){
		scanf("%lld",&a[i]);
		while(!vec.empty()&&a[i]<=vec.back())
			vec.pop_back();
		vec.push_back(a[i]);
	}
	mp[vec.back()]=1;
	while(true){
		ll now=mp.rbegin()->first,cnt=mp.rbegin()->second;
		vector<ll>::iterator p=lower_bound(vec.begin(),vec.end(),now);
		if(p==vec.begin())
			break;
		ll k=*(p-1);
		if(now/k*k==now)
			mp[k]+=now/k*cnt;
		else{
			mp[k]+=now/k*cnt;
			mp[now%k]+=cnt;
		}
		mp.erase(mp.find(now));
	}
	{
		map<ll,ll>::reverse_iterator p=mp.rbegin();
		for(ll i=n,sum=0;i;--i){
			if(p!=mp.rend()&&p->first==i)
				sum+=p->second,++p;
			ans[i]=sum;
		}
	}
	for(ll i=1;i<=n;++i)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 10228
#include<cstdio>
typedef long long LL;
inline void Min(int &x,int y){if(x>y)x=y;}
const int N=2003;

int n,x;
int mn[N],a[N<<1];
LL ans=1e18+233,sum;

int main() {
	scanf("%d %d",&n,&x);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		a[i+n]=a[i];
		mn[i]=0x3f3f3f3f;
	}
	for(int k=0;k<n;k++) {
		sum=1ll*k*x;
		for(int i=1;i<=n;i++) {
			Min(mn[i],a[i+k]);
			sum+=mn[i];
		}
		if(sum<ans) ans=sum;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1704
#include <atcoder/segtree>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

using S = int;
S op(S a, S b) { return max(a, b); }

S e() { return 0; }

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  atcoder::segtree<S, op, e> segtree(300001);

  int answer = 0;
  rep(i, N) {
    int A;
    cin >> A;
    int Amin = max(0, A - K);
    int Amax = min(300000, A + K);
    int Blen = segtree.prod(Amin, Amax + 1) + 1;
    answer = max(answer, Blen);
    segtree.set(A, Blen);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 8492
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main() {
    IO;
    int a;
    cin >> a;
    cout << a + pow(a, 3) + pow(a, 2);
    return 0;
}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

std::vector<int> enum_div(int n)//nの約数を列挙
{
    std::vector<int> ret;
    for(int i=1 ; i*i<=n ; ++i)
    {
        if(n%i == 0)
        {
            ret.push_back(i);
            if(i!=1 && i*i!=n)
            {
                ret.push_back(n/i);
            }
        }
    }
    ret.push_back(n);
    sort(ret.begin(),ret.end(),greater<int>());
    return ret;
}

int main() {
    int a,b,k;
    cin>>a>>b>>k;
    int n;
    n=__gcd(a,b);

    vector<int>q= enum_div(n);

     cout<<q[k-1]<<endl;

}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, k; cin >> n >> k;
	ll min_sum[200005];
	ll max_sum[200005];
	ll now = 0;
	// i個選んだときの和の最小値
	for(ll i=1;i<=n+1;i++){
		now += i-1;
		min_sum[i] = now;
	}
	// i個選んだときの和の最大値
	for(ll i=n+1;i>=1;i--){
		max_sum[i] = now;
		now -= n-i+1;
	}
	ll ans = 0;
	for(ll i=k;i<=n+1;i++){
		ans += (max_sum[i]-min_sum[i]+1)%MOD;
	}
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double a[10000];
    scanf("%d", &n);
    double sum = 0;
    for (int i = 0; i < n;i++)
    {
        scanf("%lf", &a[i]);
        a[i] = 1 / a[i];
        sum += a[i];
    }
    sum = 1 / sum;
    printf("%.7lf", sum);
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int a,b,d=0,r=0;
	double f=0.0;
	
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	printf("%d %d %f\n",d,r,f);
	
	return 0;
}


Measured memory_bytes: 2128
import sys
input = sys.stdin.readline

_s = input()[:-1]
_k = int(input())


def chker(S, K):
    s3 = [item for item in S * 3]
    for i in range(1, len(s3)):
        if s3[i - 1] == s3[i]:
            s3[i] = 1

    s3 = [0 if item != 1 else item for item in s3]

    ls = len(S)
    cnt_0 = sum(s3[:ls])
    cnt_1 = sum(s3[ls:2 * ls])
    cnt_2 = sum(s3[2 * ls:3 * ls])

    print(cnt_0 + cnt_1 * (K // 2) + cnt_2 * ((K - 1) // 2))


chker(_s, _k)


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int na = 0, nb = 0;
	for (int i = 0; i < s.length(); i++) {
		switch (s[i]) {
		case 'a':
			if (na + nb < a + b) {
				na++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
			break;
		case 'b':
			if (na + nb < a + b && nb < b) {
				nb++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
			break;
		case 'c':
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}

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



int main(){

    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<m;j++){
            int a;
            cin>>a;
            sum+=a*b[j];
        }
        if(sum+c>0)
            ans++;
    }
    cout<<ans;


return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

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

	ll k, n;cin >> n >> k;
	ll ans = 0;
	for(ll i = k;i <= n+1;i++){
		ll a = i * (i - 1) / 2;
		ll b = i * (n + (n - i + 1)) / 2;
		//cout << "i: " << i << "a b: " << a << " " << b << endl;
		ans += b - a + 1;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int x, y;
    x = 800*n;
    y = n / 15;
    y *= 200;
    cout << x - y << endl;
    return 0;
}


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

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

int main() {
    int n,k;cin>>n>>k;
    int d[k];
    rep(i,k)cin>>d[i];
    
    while(true){
    int tmp = n;
    int tmp2 = 0;
    while(tmp>0){
    rep(i,k){
        if(tmp%10==d[i]){
            tmp2=1;
            break;
        }
    }
    tmp/=10;
    }
    if(tmp2==0){
        cout<<n<<endl;
        return 0;
    }
    else ++n;
    }
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  int m, n, ans=0,sum=0;
  cin >> n >> m;
  vector<int> a(n);
  REP(i, n)
  {
    cin >> a.at(i);
    sum += a.at(i);
  }
  REP(i, n)
  {
    if ((double)a.at(i) >= (double)sum / (4 * m))
      ans++;
  }
  if (ans >= m)
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
  return 0;
}


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

using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int n,x;
  cin>>n>>x;
  long long int f=0;
  long long int a[101];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  long long int sum=0;
  int j=0;
  while(sum<x && j<n){
    f++;
    sum+=a[j];
    j++;
  }
  if(sum-x==0){
  cout<<f<<endl;
  }else{
    cout<<f-1<<endl;
  }
}

Measured memory_bytes: 256
//abc134_c.cpp
//Sat Jul 20 20:59:17 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	priority_queue<int> pq; //大きい順
	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
		pq.push(temp);
		a[i] = temp;
	}

	int top = pq.top();
	pq.pop();
	int second = pq.top();

	for (int i=0;i<n;i++){
		if (top==a[i]){
			cout << second << endl;
		}else{
			cout << top << endl;
		}

	}
}

Measured memory_bytes: 3316
#include "bits/stdc++.h"
//#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
	int n, m;
	cin >> n >> m;
	int v[n], w[n];
	rep(i, n)cin >> v[i] >> w[i];

	int va[n + 1][m + 1] = {};

	for(int i = n - 1; i >= 0; i--){
		rep(j, m + 1){
			if(j < w[i])
				va[i][j] = va[i + 1][j];
			else
				va[i][j] = max(va[i + 1][j], va[i + 1][j - w[i]] + v[i]);
		}
	}

	cout << va[0][m] << endl;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    fori(n) cin>>a[i];
    sort(a.begin(),a.end());
    int ans=0;
    fori(k) ans+=a[i];
    cout<<ans<<endl;
}

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

int main(){
    int D,G;
    cin>>D>>G;
    vector<int> p(D),c(D);
    for(int i=0;i<D;i++) cin>>p[i]>>c[i];

    int ans=1e9;
    for(int mask=0;mask<(1<<D); mask++){
        int s=0,num=0,rest_max=-1;
        for(int i=0;i<D;i++){
            if(mask>>i&1){
                s+= 100*(i+1)*p[i]+c[i];
                num += p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<G){
            int s1 = 100*(rest_max+1);
            int need = (G-s + s1-1)/s1;
            if(need>=p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
        }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0583

template<typename T>
vector< T > divisor(T n) {
  vector< T > ret;
  for(T i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

template<typename T>
T gcd(T a, T b){
    if (b==0) return a;
    else return  gcd(b,a%b);
}




int main(){
    int n;
    int a,b,c;
    cin >> n;
    vector<int> ret;
    if (n==2){
        cin >> b >> c;
        int a = gcd<int>(b,c);
        ret = divisor<int>(a);
    }else if (n==3){
        cin >> a >> b >> c;
        int k = gcd<int>(a,gcd<int>(b,c));
        ret = divisor<int>(k);
    }
    for(const int &p :ret){
        printf("%d\n",p);
    }
    
}


Measured memory_bytes: 3268
H=int(input())

#print(H)

COUNT = 0
for i in range(10000000000):
    temp = pow(2,i)
    if temp == H:
        COUNT = i
        break
    elif temp > H:
        COUNT = i-1
        break

#print(COUNT)

SUM = 0
for j in range(COUNT+1):
    SUM += pow(2,j)

print(SUM)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli data[200200];
lli ans[200200];

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	lli first=0;
	vector<lli> ans;

	for(lli i=n-1;i>=0;i--){
		if(data[i+1]%2!= a[i]%2){
			first = max(first,i+1);
			for(lli j=1;j*j<=(i+1);j++){
				if((i+1)%j==0){
					if((i+1)/j!=j)data[(i+1)/j]++;
					data[j]++;
				}
			}
			ans.push_back(i+1);
		}
	}

	if(DEBUG){
	REP(i,0,n+1){
		cout<<"i="<<i<<" data="<<data[i]<<endl;
	}
	}

	cout<<ans.size()<<endl;
	REP(i,0,ans.size())cout<<ans[i]<<" ";
	cout<<endl;

	return 0;
}

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

const int N = 2e6 + 5;
typedef long long LL;

LL mod = 1e9 + 7, ans;
string s;
int k, n;
LL fac[N], inv[N];

LL ksm(LL a, LL b) {
	LL res = 1;
	while(b) {
		if(b&1) res = res*a%mod;
		b /= 2;
		a = a*a%mod;
	}
	return res;
}

LL comb(int a, int b) {
	return fac[a]*inv[a - b]%mod*inv[b]%mod;
}

int main() {
	cin>>k>>s;
	n = s.size();
	fac[0] = inv[0] = 1ll;
	for(LL i = 1; i <= n + k; i++) {
		fac[i] = fac[i - 1]*i%mod;
		inv[i] = ksm(fac[i], mod - 2);
	}
	for(LL i = n; i <= n + k; i++) 
		ans = (ans + comb(i - 1, n - 1)*ksm(25, i - n)%mod*ksm(26, n + k - i)%mod)%mod;
	cout<<ans<<endl;

}

Measured memory_bytes: 35552
N, M = map(int, input().split())
*P, = map(int, input().split())
*p, = range(N)
def root(x):
    if x == p[x]:
        return x
    y = p[x] = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
    else:
        p[px] = py
    return 1

for i in range(M):
    x, y = map(int, input().split())
    x -= 1; y -= 1
    unite(x, y)

pp = [set() for i in range(N)]
qq = [set() for i in range(N)]
for i in range(N):
    r = root(i)
    pp[r].add(i)
    qq[r].add(P[i]-1)

ans = 0
for i in range(N):
    ans += len(pp[i] & qq[i])
print(ans)

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

int main(){
  int64_t N;
  cin >> N;
  string S;
  cin >> S;
  int64_t ans=0;
  for(int i=1;i<N;i++){
    if(S.at(i-1)!=S.at(i)){
      ans++;
    }
  }
  ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
"use strict";

function main(input) {
  var N = splitNum(input).slice(0, 4);
  N.sort();
  var res = JSON.stringify(N) === JSON.stringify([1, 4, 7, 9]);
  console.log(res ? 'YES' : 'NO');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
const int MAXN = 1e5 + 5;

int main()
{
	zapp;
	ll x;
	cin >> x;
	ll fc = lcm(x, 360);
	cout << fc / x;

	return 0;
}



Measured memory_bytes: 3644
var
	N, K, i, j, x, y, b, nx, ny: integer;
    c: string;
	cnt: array[1..1001, 1..1001] of integer;
begin
	read(N, K);
    for i := 1 to N do begin
    	read(x, y, c);
        if c = ' W' then y := y + k;
        if x div K mod 2 = y div K mod 2 then
        	b := 1
        else
        	b := -1;
        if b = 1 then cnt[1, 1] := cnt[1, 1] + 1;
        nx := x mod K + 2;
        ny := y mod K + 2;
        cnt[nx, 1] := cnt[nx, 1] - b;
        cnt[1, ny] := cnt[1, ny] - b;
        cnt[nx, ny] := cnt[nx, ny] + b * 2;
    end;
    for i := 1 to K + 1 do for j := 1 to K do
    	cnt[i, j + 1] := cnt[i, j + 1] + cnt[i, j];
    for j := 1 to K + 1 do for i := 1 to K do
    	cnt[i + 1, j] := cnt[i + 1, j] + cnt[i, j];
    for i := 1 to K do for j := 1 to K do begin
    	if b < cnt[i, j] then b := cnt[i, j];
    	if b < N - cnt[i, j] then b := N - cnt[i, j];
    end;
    writeln(b);
end.

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int k, a, b;
  cin >> k >> a >> b;
  bool can=false;
  int d = k;
  while(d <= b){
    if(d >= a && d <= b) can = true;
    d += k;
  }
  if(can)
    cout << "OK\n";
  else
    cout << "NG\n";
  return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAXN 100100
int n, m, cnt, a[MAXN];
int main()
{
	scanf("%d",&n);
	n = n%10;
	if(n == 3) printf("bon\n");
	else if(n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
	else printf("hon\n");
	
	return 0;
}

Measured memory_bytes: 3692
from itertools import product


def main():
    op = ['+', '-']
    numbers = list(map(int, list(input())))
    for now_op in product(op, repeat=3):
        now = numbers[0]
        for i in range(3):
            if now_op[i] == '+':
                now += numbers[i + 1]
            else:
                now -= numbers[i + 1]
        if now == 7:
            answer = ""
            for i in range(3):
                answer += str(numbers[i]) + now_op[i]
            answer += str(numbers[3]) + "=7"
            print(answer)
            break


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a, b;
  char s[100];
  while(cin >> a >> b){
    a += b;
    sprintf(s, "%d", a);
    cout << strlen(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int solve(int N){
  int count = 0;
  while(true){
    if(N & 1){
      break;
    }
    count += 1;
    N /= 2;
  }
  return count;
}
int main(){
  int n,t;
  int m=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> t;
    m += solve(t);
  }
  cout << m;
}

Measured memory_bytes: 256
(let ((n (read))
      (a (read))
      (b (read))
      (c (read))
      (d (read))
      (s (read-line)))
  (princ (cond ((and (< c d) (not (eq nil (search "##" (subseq s a d))))) "No")
               ((and (> c d) (or (not (eq nil (search "##" (subseq s a c)))) (equal nil (search "..." (subseq s (- b 2) (1+ d)))))) "No")
               (T "Yes"))))


Measured memory_bytes: 8424
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    string s;
    cin >> s;
    int N = s.length();
    int R[N+1] = {};
    int L[N+1] = {};
    int r=0;
    R[0] = 0;
    L[N] = 0;
    for(int i=0;i<N;i++){
        if(s[i] == '<') r++;
        else r=0;
        R[i+1] = r;
    }
    int l=0;
    for(int i=N-1;0<=i;i--){
        if(s[i] == '>') l++;
        else l=0;
        L[i] = l;
    }
    long long sum = 0;
    for(int i=0;i<=N;i++){
        sum += max(R[i],L[i]);
    }
    cout << sum << endl;

    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, R;
	cin >> N >> R;
	if (N >= 10) {
		cout << R << endl;
	} else {
		cout << R+100*(10-N) << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	int n, ans;
	int [][] data;
	int [] vx ={0,1,0,-1};
	int [] vy ={1,0,-1,0};

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			n = 12;
			data = new int[n][n];
			for(int i = 0; i < n; i++){
				String s = sc.next();
				for(int j = 0; j < n; j++){
					data[i][j] = s.charAt(j) - '0';
				}
			}
			ans = 0;
			for(int i = 0; i <  n; i++){
				for(int j = 0; j < n; j++){
					if(data[i][j] == 1){
						ans++;
						dfs(j,i);
					}
				}
			}
			System.out.println(ans);
		}
		
	}

	private void dfs(int x, int y) {
		data[y][x] = 0;
		for(int i = 0; i < 4; i++){
			int yy = y + vy[i];
			int xx = x + vx[i];
			if(! isOK(xx,yy))continue;
			if(data[yy][xx] == 1){
				dfs(xx,yy);
			}
		}
	}

	private boolean isOK(int xx, int yy) {
		if(0 <= xx && xx < n && 0<= yy && yy < n){
			return true;
		}
		return false;
	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % 13, n/2);
    if(n % 2 == 1) res = res * x % 13;
    return res;
}

ll dp[100010][15] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    dp[0][0] = 1;
    ll val[100010];
    rep(i,0,100001) val[i] = power(10, i);
    reverse(S.begin(), S.end());
    rep(i,0,N){
        rep(j,0,13){
            if(S[i] == '?'){
                rep(k,0,10){
                    ll amari = k * val[i] % 13;
                    dp[i+1][(j+amari) % 13] += dp[i][j] % MOD;
                    dp[i+1][(j+amari) % 13] %= MOD;
                }
            }else{
                ll v = S[i] - '0';
                ll amari = v * val[i] % 13;
                dp[i+1][(j+amari) % 13] += dp[i][j] % MOD;
                dp[i+1][(j+amari) % 13] %= MOD;
            }

        }
    }
    print(dp[N][5]);
    
}

Measured memory_bytes: 13008
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  for(int num=0; num<1000; num++){
    int k=num, i=N-1;
    for(int j=2; j>-1; j--){
      for(i; i>-1; i--){
        if(k%10==S.at(i)-'0'){
          if(j==0) ans++;
          i--;
          k/=10;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string s;cin>>s;
    int res=0;
    int q;cin>>q;
    int t,f;string c,front;
    rep(i,q){
        cin>>t;
        if(t==1){
            res++;
            continue;
        }
        cin>>f>>c;
        if(res%2==f%2)s+=c;
        else front=c+front;
    }
    s=front+s;
    if(res%2)reverse(all(s));
    cout<<s<<endl;
}

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int for_a, for_b, for_ab;
    if(a<2*c) for_a = a; else for_a = 2*c;
    if(b<2*c) for_b = b; else for_b = 2*c;
    if(a+b<2*c) for_ab = a+b; else for_ab = 2*c;

    int tmp = min(x, y), result = 0;
    result += tmp*for_ab; x -= tmp; y -= tmp;
    result += x*for_a; result += y*for_b;

    cout << result << endl; return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int dp[31] = {0};
    int n;

    dp[0] = 1;
    rep(i, 31){
        if(i >= 1) dp[i] += dp[i - 1];
        if(i >= 2) dp[i] += dp[i - 2];
        if(i >= 3) dp[i] += dp[i - 3];
    }
    int input;
    while(cin >> input, input){
        cout << dp[input] / 365 / 10 + 1  << endl;
    }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
int n;
cin>>n;
vector<int>bosses(n+1);
for(int i=1;i<=n;i++)
bosses[i]=0;
int tt;
for(int i=0;i<n-1;i++)
{
	cin>>tt;
	bosses[tt]++;
}
for(int i=1;i<=n;i++)
{
	cout<<bosses[i]<<"\n";
}
}

Measured memory_bytes: 4048
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
using namespace std;
int main()
{
    int N,K,i;
    string S;
    cin >> N >> S >> K;
    for(i = 0;i < N;i++){
        if(S[i] != S[K - 1]){
            S[i] = '*';
        }
    }
    cout << S << endl;
}

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

using namespace std;

bool comp(char i, char j) {
  return i > j;
}

int main(int argc, char* argv[]) {
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), comp);

  if (lexicographical_compare(s.begin(), s.end(), t.begin(), t.end()))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
def lcs(s1, s2):
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)

def solve():
    N = int(input())
    for _ in range(N):
        x = input()
        y = input()
        print(lcs(x, y))

if __name__ == '__main__':
    solve()


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<pair<int, int>> a(n);
  range(i, 0, n) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair(x - y, x + y);
  }
  sort(a.begin(), a.end());
  vector<pair<int, int>> b;
  for(auto x : a) {
    while(!b.empty() && b.back().second >= x.second) b.pop_back();
    if(b.empty() || b.back().first < x.first) b.push_back(x);
  }
  swap(a, b);
  n = a.size();
  vector<int> dp(n + 1);
  int to = 0;
  range(i, 1, n + 1) {
    while(a[to].second <= a[i - 1].first) to++;
    dp[i] = dp[to] + 1;
  }
  cout << *max_element(dp.begin(), dp.end());
  return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  LL n, m;
  cin >> n >> m;
  priority_queue<LL> a;

  repl(i, n) {
    LL val;
    cin >> val;
    a.push(val);
  }

  repl(i, m) {
    LL tmp = a.top() / 2;
    a.pop();
    a.push(tmp);
  }

  LL sum = 0;
  while(!a.empty()) {
    sum += a.top();
    a.pop();
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <string.h>
#include <numeric>

using namespace std;

///////////////////////////////////////////
//const long long int INF = 1000000000000000000LL;
const long long int INF = 1000000;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(    v[0])>()) //降順でVをソート
///////////////////////////////////////////


ll box[200001]={0};
ll box2[200001]={0};
ll key = 1;
void wri(string s){
    ll si = s.size();
    rep(i,si){
        if(box[i]==0){
            char kk = s[i];
            rep(j,si){
                if(box[j]==0){
                    if(s[j]==kk){
                        box[j]=key;
                    }
                }
            }
            key++;
        }
    }
}
void wri2(string s){
    ll si = s.size();
    rep(i,si){
        if(box2[i]==0){
            char kk = s[i];
            rep(j,si){
                if(box2[j]==0){
                    if(s[j]==kk){
                        box2[j]=key;
                    }
                }
            }
            key++;
        }
    }
}

int main(){
    string s,t;
    cin>>s>>t;
    wri(s);
    key=1;
    wri2(t);
    bool asn=true;
    rep(i,t.size()){
        if(box[i]!=box2[i]){
            asn=false;
            break;
        }
    }
    if(asn){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3908