akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> out(n);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin >> a >> b;
        a--,b--;
        out[a]++;
        out[b]++;
        uf.merge(a,b);
    }
    for (int i = 0; i < k; ++i) {
        int c,d;
        cin >> c >> d;
        c--,d--;
        if(uf.issame(c,d)){
            out[c]++;
            out[d]++;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << uf.size(i)-1-out[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#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 reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll p = (a1 - b1) * t1;
    ll q = (a2 - b2) * t2;
    if (p > 0) {
        p *= -1;
        q *= -1;
    }
    if ((p + q) < 0) {
        cout << 0 << endl;
    }
    else if ((p + q) == 0) {
        cout << "infinity" << endl;
    }
    else {
        ll s = (-1 * p) / (p + q);
        ll t = (-1 * p) % (p + q);
        if (t == 0) {
            cout << (s * 2) << endl;
        }
        else {
            cout << (s * 2 + 1) << endl;
        }
    }
    return 0;
}


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

int main() {
	double n;
	cin >> n;
	double ans =  2 * n * 3.141592;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3776
def main():
    s = input()
    q = int(input())

    reverse = False
    pre = ""
    post = ""
    for _ in range(q):
        line_ls = input().split()
        # 長さが1ならTi=1
        if len(line_ls) == 1:
            reverse = not reverse
            continue

        fi = line_ls[1]
        ci = line_ls[2]
        if fi == "1":
            if not reverse:
                pre += ci
            else:
                post += ci
        else:
            if not reverse:
                post += ci
            else:
                pre += ci

    if reverse:
        s = s[::-1]
        post = post[::-1]
        print(post + s + pre)
    else:
        pre = pre[::-1]
        print(pre + s + post)


main()


Measured memory_bytes: 4340
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int g[1010][1010];

int main(){
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  rep(i,h){
    rep(j,w){
      if((i<b&&j<a)||(b<=i&&a<=j)) g[i][j]=1;
    }
  }
  rep(i,h){
    rep(j,w){
      cout << g[i][j];
    }cout << endl;
  }
}

Measured memory_bytes: 5120
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<isize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    let mut map: HashMap<isize, usize> = HashMap::new();
    for i in 0..n {
        *map.entry(i as isize - a[i]).or_insert(0) += 1;
    }

    let mut count: usize = 0;
    for i in 0..n {
        if let Some(c) = map.get(&(i as isize + a[i])) {
            count += *c;
        }
    }
    return count.to_string();
}


Measured memory_bytes: 11712
from itertools import permutations
from math import sqrt
def dist(x1,y1,x2,y2):
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
n = int(input().strip())
pl=[]
for i in range(n):
    pl.append(i)
l=[]
for i in range(n):
    x,y=map(int,input().strip().split())
    l.append([x,y])
d=[]
for i in permutations(pl):
    x=list(i)
    s=0
    for i in range(n-1):
        s+=dist(l[x[i]][0],l[x[i]][1],l[x[i+1]][0],l[x[i+1]][1])
    d.append(s)
avg=0.0
for i in range(len(d)):
    avg+=d[i]
print(avg/len(d))



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

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

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

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

int intr(pair<int, int> a, pair<int, int> b)
{
    int l = max(a.fi, b.fi), r = min(a.se, b.se);
    if(r < l)
        return 0;
    return r-l;
}

int main()
{
    int n; cin >> n;
    pair<int, int> dat[n];
    pair<int, int> mn = {2e9, -1}, mx = {-2e9, -1};
    int mLen = 0;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> dat[i].fi >> dat[i].se; dat[i].se++;
        mn = min(mn, {dat[i].se, i});
        mx = max(mx, {dat[i].fi, i});
        mLen = max(mLen, dat[i].se-dat[i].fi);
    }
    int mL = mx.se, mR = mn.se;
    ans = mLen + intr(dat[mL], dat[mR]);
    vector<pair<int, int> > vc;
    for(int i = 0; i < n; i++)
    {
        vc.push_back({dat[i].se-dat[mL].fi, dat[mR].se-dat[i].fi});
    }
    sort(vc.begin(), vc.end());
    vector<int> pr(vc.size());
    int mmn = 2e9;
    for(int i = 0; i < vc.size(); i++)
    {
        mmn = min(mmn, vc[i].se);
        pr[i] = mmn;
    }
    for(int i = vc.size()-2; i >= 0; i--)
    {
        ans = max(ans, pr[i] + vc[i+1].fi);
    }
    cout << ans << '\n';
}






































/// shche ne vmerla Ykraina


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

using namespace std;

vector<int> h;
vector<int> dp;
int cost(int i, int j) {
	return abs(h[i] - h[j]);
}
int main() {
	int n;
	cin>>n;
	h.resize(n);
	for(int i=0; i<n; i++) {
		cin>>h[i];
	}
	dp.resize(n);
	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);
	for(int i=2; i<n; i++) {
		dp[i] = min(dp[i-1] + cost(i,i-1), dp[i-2] + cost(i,i-2));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

constexpr ll mod = 998244353;

int n, x[200100], d[200100];
pii s[200100];
ll dp[200100];


constexpr int sz = 1 << 18, defv = -2e9;
int stree[sz * 2];
void Init() {
	for (int i = 0; i < sz * 2; i++)
		stree[i] = defv;
}
int f(int a, int b) {
	return max(a, b);
}
int query(int l, int r, int low = 0, int upp = sz, int x = 0) {
	if (r <= low || upp <= l)
		return defv;
	if (l <= low && upp <= r)
		return stree[x];
	int cen = (low + upp) / 2;
	int lv = query(l, r, low, cen, x * 2 + 1);
	int rv = query(l, r, cen, upp, x * 2 + 2);
	return f(lv, rv);
}
void upd(int x, int v) {
	x += sz - 1;
	stree[x] = v;
	while (x != 0) {
		x = (x - 1) / 2;
		stree[x] = f(stree[x * 2 + 1], stree[x * 2 + 2]);
	}
}

int g(int v) {
	return lower_bound(x, x + n, v) - x;
}

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

	for (int i = 0; i < n; i++)
		s[i] = pii(x[i], d[i]);
	sort(s, s + n);
	for (int i = 0; i < n; i++)
		tie(x[i], d[i]) = s[i];

	x[n] = 2e9 + 100, dp[n] = 1;
	for (int i = n - 1; 0 <= i; i--) {
		int area = max(query(i, g(x[i] + d[i])), x[i] + d[i]);
		dp[i] = (dp[i + 1] + dp[g(area)]) % mod;
		upd(i, area);
	}
	printf("%lld\n", dp[0]);
}

Measured memory_bytes: 8448
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n;
    cin>>n;
    vector<ll>a(n),b(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }    
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    ll x,y,val,val1,ans=-inf;
    for(int i=0;i<pow(2,n);i++)
    {
        x=0;
        y=0;
        for(int j=0;j<n;j++)
        {
            val=1<<j;
            if(val&i)
            {
                x+=a[j];
                y+=b[j];    
            }
        }
        val=x-y;
        ans=max(ans,val);
    }
    cout<<ans<<endl;
}


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

long ans(void);

long MARCH[5];
int main(void){
	int N;
	for(int i=0;i<5;i++){
		MARCH[i] = 0;
	}
	std::cin>>N;
	for(int i=0;i<N;i++){
		std::string name;		
		std::cin>>name;
		if(*name.begin() == 'M'){
			MARCH[0] += 1;
		}
		if(*name.begin() == 'A'){
			MARCH[1] += 1;
		}
		if(*name.begin() == 'R'){
			MARCH[2] += 1;
		}
		if(*name.begin() == 'C'){
			MARCH[3] += 1;
		}
		if(*name.begin() == 'H'){
			MARCH[4] += 1;
		}
	}

	std::cout<<ans()<<std::endl;

//	for(int i=0;i<5;i++){
//		std::cout<<MARCH[i]<<std::endl;
//	}

	return 0;
}

long ans(void){
	long ans =    MARCH[0]*MARCH[1]*MARCH[2] + MARCH[0]*MARCH[1]*MARCH[3] + MARCH[0]*MARCH[1]*MARCH[4] 
				+ MARCH[0]*MARCH[2]*MARCH[3] + MARCH[0]*MARCH[2]*MARCH[4] + MARCH[0]*MARCH[3]*MARCH[4] 
				+ MARCH[1]*MARCH[2]*MARCH[3] + MARCH[1]*MARCH[2]*MARCH[4] + MARCH[1]*MARCH[3]*MARCH[4]
				+ MARCH[2]*MARCH[3]*MARCH[4];
	return ans;
}


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

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int n=gi();
boolean flg=false;
        for (int i=0; i<=25; i++ ) {
        	for (int j=0; j<15;j++) {
        		if(i*4+j*7==n) {
        			flg=true;
        			break;
        		}
        	}
        }
        //System.out.println("No");
        

	    if (flg) {
	    	System.out.print("Yes");
	    }else {
	    	System.out.print("No");
	    }



	}
	
	public static int s(int n) {
		String S=String.valueOf(n);
		int c=0;
		for (int i=0; i<S.length();i++) {
			int k=Integer.parseInt(S.substring(i, i+1));
			c+=k;
		}
		return c;
	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    ll N, K, X, Y;
    cin >> N >> K >> X >> Y;
    cout << min(N*X, K*X) + Y*max(0LL, N - K) << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
} 
void solve()
{
    int x, n;
    cin >> x >> n;
    int a[n];
    map<int, int> mp;
    for (int i = 0; i < n;i++){
        cin >> a[i];
        mp[a[i]] = 1;
    }
    int g = x;
    while(mp[x]==1){
        x++;
    }
    int ans = x;
    x = g;
    
    while(mp[x]==1){
        x--;
    }
    if(abs(x-g)<=abs(ans-g)){
        ans = x;
    }
    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;



int main() {
  string a; cin >> a;
  for (int i = 0; i < a.size(); ++i) for (int j = i + 1; j < a.size(); ++j) if (a[i] == a[j]) { cout << "no" << endl; return 0;}
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int count=1,ans=1;
  char c;
  string S;
  cin>>S;
  vector<int> V;
  c=S[0];
  for(int i=1;i<S.size();i++){
    if(c!=S[i] || count==2){
      ans++;
      count=1;
      c=S[i];
    }else{
      if(i==S.size()-1) break;
      i++;
      count=2;
      ans++;
    }
    //cout<<ans<<" "<<count<<endl;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1336
def main():
    flag = True
    S = input()
    if len(S) < 2 or S[-1] != 'i': flag = False
    if flag:
        for enum, i in enumerate(S):
            if enum % 2 == 0:
                if i != 'h':
                    flag = False
                    break
            else:
                if i != 'i':
                    flag = False
                    break
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

const int N = 310;

double f[N][N][N];
int n, a[N], cnt[5];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]), cnt[a[i]]++;
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= n; ++j) {
			for(int k = 0; k <= n; ++k) {
				if(i + j + k > n) continue;
				if(!i && !j && !k) continue;
				if(i > cnt[3]) continue;
				if(j > cnt[3] + cnt[2]) continue;
				if(k > cnt[3] + cnt[2] + cnt[1]) continue;
				double p1 = 1.0 * i / n, p2 = 1.0 * j / n, p3 = 1.0 * k / n;
				double p4 = 1.0 * (i + j + k) / n;
				f[i][j][k] = (double)(1+(i?f[i-1][j+1][k]:0)*p1+(j?f[i][j-1][k+1]:0)*p2+(k?f[i][j][k-1]:0)*p3)/p4;
//				printf("%.2lf %.2lf\n",1+(i?f[i-1][j+1][k]:0)*p1+(j?f[i][j-1][k+1]:0)*p2+(k?f[i][j][k-1]:0)*p3, p4);
			}
		}
	}
/*	for(int i = 0; i <= cnt[1]; ++i) {
		for(int j = 0; j <= cnt[2]; ++j) {
			for(int k = 0; k <= cnt[3]; ++k) printf("%.2lf ", f[i][j][k]);
		}
	}*/
	printf("%.10lf\n", f[cnt[3]][cnt[2]][cnt[1]]);
}

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


//閉路があることの判定
//dfs(再帰)による実装

bool dfs(int ex, int node, vector<vector<int> > adjlist, vector<bool>& used, vector<bool> &u){

    for(int i = 0; i < adjlist[node].size(); i++){
        //cout << node << " " << adjlist[node][i] << endl;
        //cout << u[0] << u[1] << u[2] << u[3] <<  endl;
        
        if(used[adjlist[node][i]] == true) return true;
        else if(u[adjlist[node][i]] == true) continue;
        else if(adjlist[node][i] == ex) continue;
        else if(used[adjlist[node][i]] == false){
            used[adjlist[node][i]] = true;
            u[adjlist[node][i]] = true;            
            bool flag = dfs(node, adjlist[node][i], adjlist, used, u);
            if(flag) return true;
            used[adjlist[node][i]] = false;
        }
    }
    return false;
}

int main(){

    int V, E; cin >> V >> E;                          // V:= 頂点の数    E:= 辺の数
    vector<vector<int> > adjlist(V);                  //first := 行先　second := コスト

    //入力
    for(int i = 0; i < E; i++){
        int a, b; cin >> a >> b;                      // a ←→ b に コスト c の辺がある
        adjlist[a].push_back(b);
    }

    vector<bool> used(V, false);
    vector<bool> u(V, false);
    int node = 0;
    bool flag = false;
    for(int i = 0; i < V; i++){
        if(u[i] == true) continue;
        else{
            used[i] = true;
            u[i] = true;
            flag = dfs(-1, i, adjlist, used, u);
            used[i] = false;
            if(flag) break;
        }
    }

    if(flag) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int c = max(a + b, a - b);
  c = max(c, a * b);
  cout << c;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ld a,b;cin>>a>>b;
    a*=b;
    ll x=a;
    cout<<x<<endl;
}

Measured memory_bytes: 3716
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c;
  int G[200][200];

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      G[i][j] = 0;
    }
  }
  for(int i = 0 ; i < n ; i++){
    cin >> a >> b;
    a--;
    for(int i = 0 ; i < b ; i++){
      cin >> c;
      c--;
      G[a][c] = 1;
    }
  }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      if(j == 0)cout << G[i][j];
      else cout <<" "<< G[i][j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  string S;

  rep(i, 3) {
    cin >> S;

    if (i == 0) {
      cout << S[0];
      continue;
    }
    if (i == 1) {
      cout << S[1];
      continue;
    }
    if (i == 2) {
      cout << S[2];
      continue;
    }
  }
  ENDL;
  return 0;
}

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

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

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")

#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")

int main (void){
  char c;
  cin >> c;
  if(c>='A' && 'Z'>=c) cout << "A"<< endl;
  else if(c>='a' && 'z'>=c) cout << "a"<< endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


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

	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	vector<vector<int>> graph(n, vector<int>());
	rep(i, n - 1) {
		graph[i].pb(i + 1);
		graph[i + 1].pb(i);
	}
	graph[x].pb(y);
	graph[y].pb(x);
	vector<int> ans(n - 1);
	rep(i, n) {
		queue<P> que;
		vector<bool> vis(n);
		que.push(P(i, 0)); vis[i] = true;
		while (!que.empty()) {
			P p = que.front(); que.pop();
			int px = p.first; int py = p.second;
			for (int j : graph[px]) {
				if (!vis[j]) {
					vis[j] = true;
					ans[py]++;
					que.push(P(j, py + 1));
				}
			}
		}
	}
	rep(i, n - 1) cout << ans[i] / 2 << endl;
}

Measured memory_bytes: 512
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
int n,k=38;
vector<int> v[2333];
bool hs[2333];

void out()
{
	putsii(n,k);
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<v[i].size();j++)puti(v[i][j]);
		puts("");
	}
}
void solve(int it,int cur)
{
	int st=v[it].size()-1;
	v[it].PB(cur);
	if(cur<=k)
	{
		for(int i=2;i<=k;i++)
		{
			v[i+(cur-1)*(k-1)].PB(cur);
		}
		return;
	}
	memset(hs,0,sizeof(hs));
	for(int i=0;i<v[it].size();i++)hs[v[it][i]]=1;
	int cnt=k-1;
	for(int i=k+1;i<=n;i++)
	{
//		if(v[i].size()>=it)continue;
		int pos=(i-2)%(k-1);
		int block=(i-k-1)/(k-1);
		if((st+(it-2)*block)%(k-1)==pos)
		{
			bool ok=1;
			for(int j=0;j<v[i].size();j++)
			{
				ok&=!hs[v[i][j]];
			}
			if(ok)
			{
				v[i].PB(cur);
				cnt--;
				for(int j=0;j<v[i].size();j++)hs[v[i][j]]=1;
				if(cnt==0)return;
			}
		}
	}
	out();
	assert(false);
}
int main()
{
	n=k*(k-1)+1;
	int it=1;
	for(int i=1;i<=n;i++)
	{
		solve(it,i);
		if(v[it].size()==k)it++;
//		out();
	}
	out();
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

#define MAX_N 100000
#define MAX_Q 100000

int N;
char marked[MAX_N];
int parent[MAX_N];

int Q;
char qtype[MAX_Q];
int qindex[MAX_Q];

int par[MAX_N];

void uf_init() {
  int i;
  for (i = 0; i < N; i++) par[i] = i;
}

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

void uf_unite(int x, int y) {
  int rx = uf_find(x), ry = uf_find(y);
  if (rx != ry) par[ry] = rx;
}

int main() {
  int i;
  for (;;) {
    scanf("%d %d", &N, &Q);
    if (N == 0 && Q == 0) break;

    for (i = 1; i < N; i++) {
      int n; scanf("%d", &n);
      parent[i] = n-1;
    }

    memset(marked, 0, sizeof(marked));
    marked[0] = 1;
    
    int qnum = 0;
    for (i = 0; i < Q; i++) {
      int n; char t[2]; scanf("%s %d", t, &n);
      if (!(t[0] == 'M' && marked[n-1] == 1)) {
        if (t[0] == 'M') marked[n-1] = 1;
        qtype[qnum] = t[0];
        qindex[qnum] = n-1;
        qnum++;
      } 
    }
    Q = qnum;

    uf_init();
    for (i = 0; i < N; i++) {
      if (marked[i] == 0) uf_unite(parent[i], i);
    }

    long long ans = 0;
    for (i = Q - 1; i >= 0; i--) {
      if (qtype[i] == 'M') {
        uf_unite(parent[qindex[i]], qindex[i]);
      } else {
        ans += uf_find(qindex[i]) + 1;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn=100;

struct Node
{
	string s;
}a[maxn+5];

bool cmp(const Node &x,const Node &y)
{
	if(x.s.size()<y.s.size()) return 1;
	if(x.s<y.s) return 1;
	return 0;
}

int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=1; i<=n; i++)
		cin>>a[i].s;
	sort(a+1,a+n+1,cmp);
	for(int i=1; i<=n; i++)
		cout<<a[i].s;
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a[100003];

int main()
{
    int n;
    scanf("%d",&n);
    while (n--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
    return 0;
}

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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

int n,m,r;
int a[202][202];
int b[10];
int u,v,value;

int main()
{
    cin>>n>>m>>r;
    F(i,1,r) cin>>b[i];
    F(i,1,n)F(j,1,n) a[i][j]=0x3f3f3f3f;
    F(i,1,m)
    {
        cin>>u>>v>>value;
        a[u][v]=a[v][u]=value;
    } 
    F(k,1,n)F(i,1,n)F(j,1,n) a[i][j]=min(a[i][k]+a[k][j],a[i][j]);
    //F(i,1,n)F(j,1,n) printf("%d%c",a[i][j],j==n?'\n':' ' );
    int num=1,ans=1e9;
    F(i,2,r) num*=i;
    while(num--)
    {
        int ret=0;
        F(i,1,r-1) ret+=a[b[i]][b[i+1]];
        ans=min(ans,ret);
        next_permutation(b+1,b+1+r);
    }
    cout<<ans;
    return 0;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       s.find(x) != s.end()

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
    //    ll a, b, d;
    string s, s1, s2;

    cin1(x);
    cot1(x+(x*x)+(x*x*x));

    return 0;
}



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

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

int main()
{
  int X;
  cin >> X;
  
  cout << 360 / gcd(X, 360) << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define irep(i,a)for(int i=1;i<=a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
char t[1000][1000];
int dp[1000][1000];

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

void dfs(int y,int x){
	//cout<<y<<" "<<x<<endl;

	rep(i,4){
		int ny=y+dy[i];
		int nx=x+dx[i];
		if(ny>=1&&nx>=1&&nx<=w&&ny<=h&&t[y][x]=='.'){

			if(dp[ny][nx]>dp[y][x]+1||dp[ny][nx]==0){
				dp[ny][nx]=dp[y][x]+1;
				dfs(ny,nx);
			
			}
		}
	}

}
int main(){
cin>>h>>w;
int cnt=0;
for(int i=1;i<=h;i++){
	for(int j=1;j<=w;j++){
	cin>>t[i][j];
		if(t[i][j]=='.')cnt++;
	}
}

dp[1][1]=1;


dfs(1,1);
if(dp[h][w]==0)cout<<-1<<endl;
else cout<<cnt-dp[h][w]<<endl;

	return 0;
}

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

using namespace std;

long gcd(long a, long b) {
  if (b == 0) return a;
  if (b > a) {
    long c = a;
    a = b;
    b = c;
  }
  return gcd(b, a%b);
}

int main() {
  long A,B,C,D;
  cin>>A>>B>>C>>D;

  long exp = B - A + 1;
  long c = (B/C) - ((A-1)/C);
  long d = (B/D) - ((A-1)/D);

  long l = gcd(D,C);
  long m = D*C/l;
  long e = (B/m) - ((A-1)/m);

  cout << exp - c - d + e << endl;


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int main() {
	int n;
	scanf("%d",&n);
	int l=0;
	for(int i=1;i<=n;i++){
		l+=i;
		if(l>=n){
			printf("%d",i);
			break;
		}
	}
	return 0;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int n;
str s;

int type[4010];
vi pos[3];
ll ans = 0;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n>>s;
    for(int i = 0; i < n; i++)
    {
    	if(s[i] == 'R') pos[0].PB(i);
    	else if(s[i] == 'G') pos[1].PB(i);
    	else pos[2].PB(i);
	}
	for(int i = 0; i < n; i++)
	{
		if(s[i] == 'R') type[i] = 0;
		else if(s[i] == 'G') type[i] = 1;
		else type[i] = 2; 
	}
	for(int i = 0; i < n; i++) for(int k = i + 2; k < n; k++)
	{
		if(type[i] == type[k]) continue; 
		int type_j = 3 - type[i] - type[k];
		int low_pos = lower_bound(all(pos[type_j]), i) - begin(pos[type_j]);
		int high_pos = lower_bound(all(pos[type_j]), k) - begin(pos[type_j]);
		if(high_pos)
		{
			ans += high_pos - low_pos;
			if((k - i) % 2 == 0 && type[(k + i) / 2] == type_j) ans--;
		}
	}
	cout<<ans<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 3668
n=int(input())
ans="Yes"
dic={}
w=input()
last=w[-1]
dic[w]=dic.get(w,0)+1
for i in range(n-1):
    w=input()
    if dic.get(w,0)==1 or w[0]!=last:
        ans="No"
        break
    dic[w]=dic.get(w,0)+1
    last=w[-1]

print(ans)


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

int main() {
    int k, n; cin >> k >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long m = 0;
    for (int i = 1; i < n; i++) {
        m  = max(a[i] - a[i-1], m);
    }
    m = max(a[0] + k - a[n-1], m);
    cout << k - m << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
string s;
void add(ll &a, ll b) {
	a += b;
	if (a >= INF)a -= INF;
}
ll dp[210000][5];//dp[i+1][3]:=i文字目まで考えた時にABCとの
//照合においてCまでは照合させたようなもの
int main() {
	cin >> s;
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j < 5; ++j) {
			if (s[i] != '?')add(dp[i + 1][j], dp[i][j]);
			else add(dp[i + 1][j], dp[i][j] * 3 % INF);
		}
		if (s[i] == 'A' || s[i] == '?')add(dp[i + 1][1], dp[i][0]);
		if (s[i] == 'B' || s[i] == '?')add(dp[i + 1][2], dp[i][1]);
		if (s[i] == 'C' || s[i] == '?')add(dp[i + 1][3], dp[i][2]);
	}
	cout << dp[s.size()][3] << endl;
	return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin>>x;
	ll ans=100;
	for(int i=1;;++i){
		ans+=(ans/100);
		if(ans>=x) {
			cout<<i;
			break;
		}
	}
	return 0;
} 

Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n, h, w;

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

    int res = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (a >= h && b >= w) {
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
K = I()

ans = 1
for i in range(N):
    if ans < K:
        ans *= 2
    else:
        ans += K
print(ans)

Measured memory_bytes: 12484
class MyStack():
    def __init__(self):
        self.stack = []
    def push(self, item):
        self.stack.append(item)
    def pop(self):
        if len(self.stack) == 0:
            return None
        result = self.stack[-1]
        del self.stack[-1]
        return result

s = list(input().split())
n = len(s)

mystack = MyStack()
for i in range(n):
    if s[i] == "+" or s[i] == "-" or s[i] == "*":
        x = mystack.pop()
        y = mystack.pop()
        if s[i] == "+":
            r = y + x
        elif s[i] == "-":
            r = y - x
        elif s[i] == "*":
            r = y * x
        mystack.push(r)
        if (i + 1) == n:
            print(mystack.pop())
    else:
        mystack.push(int(s[i]))



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

using namespace std;

int main(){

    string s;
    cin >> s;
    
    for(int i=0;i<s.size();i++){
        int f = 0;

        if(s.substr(i,7) == "dreamer" && s.substr(i+5,5) != "erase"){
            i += 6;
            f = 1;            
        }
        if(s.substr(i,6) == "eraser" && f == 0){
            i += 5;
            f = 1;
        }
        if(s.substr(i,5) == "erase" && f == 0){
            i += 4;
            f = 1;
        }
        if(s.substr(i,5) == "dream" && f == 0){
            i += 4;
            f = 1;
        }
        if(f == 0){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
	if cur == N:
 		return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
	ret0 = dfs(cur + 1, a, b, c)
	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
	return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3188
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

using pipii  = pair<int, pii>;
using vpipii = vector<pipii>;

void solve() {
  int n, m, a;
  while (
    cin >> n >> m >> a, n) {
    vpipii v;
    while (m--) {
      int h, p, q;
      cin >> h >> p >> q;
      v.pb(mp(h, mp(p, q)));
    }
    sort(rall(v));
    for (pipii p : v) {
      a = a == p.se.fi ? p.se.se : a == p.se.se ? p.se.fi : a;
    }
    cout << a << endl;
  }
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, M, ans;
    ll A;
    priority_queue<ll> Values;
    scanf("%lld %lld", &N, &M);
    REP(int, i, 0, N){
        scanf("%lld", &A);
        Values.push(A);
    }
    REP(int, i, 0, M){
        ll Waribiki = Values.top();
        Values.pop();
        Values.push(Waribiki/2);
    }
    ans = 0;
    for ( int i = 0; i < N; i++ ){
        ans += Values.top();
        Values.pop();
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>

int main(){
	int m,f,r;
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1)
			break;
		else if(m==-1 || f==-1)
			printf("F\n");	
		else if(m+f>=80)
			printf("A\n");
		else if(80>m+f && m+f>=65)
			printf("B\n");
		else if(65>m+f && m+f>=50)
			printf("C\n");
		else if(50>m+f && m+f>=30)
			if(r>=50)
				printf("C\n");
			else
				printf("D\n");
		else if(30>m+f)
			printf("F\n");
	}
	return 0;
}

Measured memory_bytes: 584
/*input
6 6
#####.
#.#.##
####.#
.#..#.
#.##..
#.#...
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
int dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
char a[55][55];
string s[55];
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y,w;
	cin>>h>>w;
	for(int i=0;i<w+2;++i) s[0]+='.',s[h+1]+='.';
	for(int i=1;i<=h;++i){
		cin>>s[i];
		s[i]='.'+s[i]+'.';
	}
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j){
			if(s[i][j]=='#') {
				a[i][j]='#';
				continue;
			}
			int sum=0;
			for(int k=0;k<8;++k){
				if(s[i+dy[k]][j+dx[k]]=='#') ++sum;
			}
			a[i][j]='0' + sum;
		}
	for(int i=1;i<=h;++i,cout<<'\n')
		for(int j=1;j<=w;++j)
			cout<<a[i][j];
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

int main()
{
    string s[2];

    while(cin >> s[0] >> s[1])
    {
        if(s[0] == "0") break;
        int h = 0, b = 0;

        REP(4)if(s[0][i] == s[1][i]) h++;

        REP(4)rep(j,4)
        {
            if(i == j ) continue;
            if(s[0][i] == s[1][j]) b++;
        }
        cout << h << " " << b << endl;

    }
    return 0;
}

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

using namespace std;

const int mod = 1e9+7;

int main(){
    int n;
    string a,b;
    cin >> n >> a >> b;
    int ans,i=0;
    if(a[0]==b[0]){
        ans=3;
        i=1;
    }
    else{
        ans=6;
        i=2;
    }
    while(i<n){
        if(a[i]==b[i]){
            if(a[i-1]==b[i-1]){
                ans*=2;
                ans%=mod;
            }
            i++;
        }
        else{
            if(a[i-1]==b[i-1]){
                ans*=2;
                ans%=mod;
            }
            else{
                ans=(1LL*ans*3)%mod;
            }
            i+=2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256