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

struct Point{
  int64 x1, y1, z1;
  int64 x2, y2, z2;
  Point(){}
  Point(int64 x1, int64 y1, int64 z1, int64 x2, int64 y2, int64 z2):
    x1(x1), y1(y1), z1(z1), x2(x2), y2(y2), z2(z2){};
};


int main(){
  int64 N, K;
  cin >> N >> K;
  vector< int64 > X, Y, Z;
  static int nums[101][101][101];
  vector< Point > p(N);
  for(int i = 0; i < N; i++){
    int x1, y1, z1, x2, y2, z2;
    cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
    p[i] = Point( x1, y1, z1, x2, y2, z2);

    X.push_back(x1), X.push_back(x2);
    Y.push_back(y1), Y.push_back(y2);
    Z.push_back(z1), Z.push_back(z2);
  }

  sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end());
  sort(Y.begin(), Y.end()); Y.erase(unique(Y.begin(), Y.end()), Y.end());
  sort(Z.begin(), Z.end()); Z.erase(unique(Z.begin(), Z.end()), Z.end());
                                
  for(int i = 0; i < N; i++){
    int x1 = lower_bound(X.begin(), X.end(), p[i].x1) - X.begin();
    int y1 = lower_bound(Y.begin(), Y.end(), p[i].y1) - Y.begin();
    int z1 = lower_bound(Z.begin(), Z.end(), p[i].z1) - Z.begin();
    int x2 = lower_bound(X.begin(), X.end(), p[i].x2) - X.begin();
    int y2 = lower_bound(Y.begin(), Y.end(), p[i].y2) - Y.begin();
    int z2 = lower_bound(Z.begin(), Z.end(), p[i].z2) - Z.begin();

    for(int i = x1; i < x2; i++){
      for(int j = y1; j < y2; j++){
        for(int k = z1; k < z2; k++){
          nums[i][j][k]++;
        }
      }
    }
  }


  int64 ret = 0;
  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 101; j++){
      for(int k = 0; k < 101; k++){
        if(nums[i][j][k] >= K){
          ret += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (Z[k + 1] - Z[k]);
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 4952
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char f[1010][1010];
int d[1010][1010];
P pos[20];
int H,W,N;
int bfs(int n)
{
	for(int i=0;i<1010;i++)
	{
		for(int j=0;j<1010;j++)
		{
			d[i][j]=INF;
		}
	}
	queue<P> q;
	P s;
	s.fi=pos[n].fi;
	s.sec=pos[n].sec;
	d[s.fi][s.sec]=0;
	q.push(s);
	while(!q.empty())
	{
		P t;
		t=q.front();
		q.pop();
		for(int i=0;i<4;i++)
		{
			int nx=t.fi+dx[i],ny=t.sec+dy[i];
			if(nx<0||nx>=H||ny<0||ny>=W)continue;
			if(d[nx][ny]!=INF||f[nx][ny]=='X')continue;
			d[nx][ny]=d[t.fi][t.sec]+1;
			if(nx==pos[n+1].fi&&ny==pos[n+1].sec)return d[nx][ny];
			q.push(P(nx,ny));
		}
	}
}
int main()
{
	cin >> H >> W >> N;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin >> f[i][j];
			if(f[i][j]=='S')pos[0]=P(i,j);
			else if(f[i][j]!='.'&&f[i][j]!='X')pos[f[i][j]-'0']=P(i,j);
		}
	}
	int ans=0;
	for(int i=0;i<N;i++)
	{
		ans+=bfs(i);
		//cout << bfs(i) << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6188
num=[[[0 for a in range(10)]for a in range(3)]for a in range(4)]

n = int(input())

for a in range(n):
    b,f,r,v = [int(x) for x in input ().split()]
    num[b-1][f-1][r-1] += v

for i in range(4):
    for f in num[i]:
        print(""," ".join([str(x) for x in f]))
    
    if i != 3:
        print("#"*20)


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

int main()
{
    int a,b;
    cin >> a >> b;
    int ans = (a-1)*(b-1);
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
	string s[3];
	string ans;
	cin>>s[0]>>s[1]>>s[2];
	for(int i=0;i<3;i++)
	{
		ans+=s[i][0];
	}
	for(int i=0;i<3;i++)
	{
		ans[i] = toupper(ans[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
program minimize
  implicit none 
  integer(8) :: n, k, ans
  read *, n, k
  if (mod(n-1,k-1) == 0) then
    ans = (n-1)/(k-1)
  else
    ans = (n-1)/(k-1)+1
  end if
  print '(i0)', ans
  stop
end program minimize

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());
	for(int i = 0; i < n; ++i) {
		cout << a[i].second  ;
		if(i != n - 1)
			cout << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    
    for (int i=0; i<N; i++) {
        if (S.at(i)!=S.at(K-1)) S.at(i)='*';
    }

    cout << S << endl;
    
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int h1, m1; cin >> h1 >> m1;
	int h2, m2; cin >> h2 >> m2;
	int k; cin >> k;

	int a = 60 * h1 + m1;
	int b = 60 * h2 + m2;

	cout << (b - a - k) << endl;

	return 0;
}


Measured memory_bytes: 3656
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ta = readln.split.to!(double[]);
    auto T = ta[0];
    auto A = ta[1];
    auto HS = readln.split.to!(double[]);

    double min_t = double.max;
    int idx;
    foreach (int i, h; HS) {
        auto t = abs(A - (T - h * 0.006));
        if (t < min_t) {
            min_t = t;
            idx = i;
        }
    }
    writeln(idx + 1);
}

Measured memory_bytes: 380
N, X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
d = [0] * (N + 1)
for i in range(1, N + 1):
    d[i] = d[i - 1] + L[i - 1]
print(sum([1 for e in d if e <= X]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll          long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<ll int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const ll s = 1e7+2;
ll a[s];
int main() {

    ISO();
   online_judge();
    ll int n;
    cin >> n;
    ll ans = 0;
    
    for(ll int i=1;i<=n;++i)
    {
        for(int j = i;j<=n;j += i)
        {
            a[j]++;
        }
    }
    for (ll int i = 1; i <= n; ++i)
    {
       
        ans += (i*a[i]);
    }
    cout << ans << "\n";
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 81776
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int H,W,K;
	String[]A;
	void solve(){
		Scanner sc=new Scanner(System.in);
		int count=1;
		H=sc.nextInt();
		W=sc.nextInt();
		K=sc.nextInt(); //=魔法の移動回数=開けられる部屋の個数
		A=new String[H];
		for(int i=0;i<H;i++){
			A[i]=sc.next();
		}
		int fx=-1;
		int fy=-1;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(A[i].charAt(j)=='S'){
					fx=j;
					fy=i;
				}
			}
		}
		Queue<Integer> nowq=new LinkedList<Integer>();
		nowq.add(encode(fy,fx));
		
		int[] vy=new int[]{1,0,-1,0};
		int[] vx=new int[]{0,1,0,-1};
		
		boolean[][] check=new boolean[H][W];
		
		//最初のKで到達できるところ
			Queue<Integer> endq=new LinkedList<Integer>();
			
			for(int i=0;i<K;i++){
				Queue<Integer> nextq=new LinkedList<Integer>();
				while(!nowq.isEmpty()){
					int now=nowq.poll();
					int y=now/1000;
					int x=now%1000;
					for(int j=0;j<4;j++){
						int ny=y+vy[j];
						int nx=x+vx[j];
					
						if(!ok(ny,nx))continue;
					
						if(check[ny][nx])continue;
					
						if(A[ny].charAt(nx)=='.' && (ny==0 || ny==H-1 || nx==0 || nx==W-1)){
							System.out.println(count);
							return;
						}
						else if(A[ny].charAt(nx)=='#' && !check[y][x]){
							endq.add(encode(y,x));
							check[y][x]=true;
						}
						else if(A[ny].charAt(nx)=='.'){
							nextq.add(encode(ny,nx));
							check[ny][nx]=true;
							endq.add(encode(ny,nx));
						}
					}
				}
				nowq=nextq;
			}
			int n=endq.size();
			
			int Min=999999999;
			for(int i=0;i<n;i++){
				int now=endq.poll();
				int y=now/1000;
				int x=now%1000;
				y=Math.min(y, H-1-y);
				x=Math.min(x, W-1-x);
				if(Min>Math.min(x, y))Min=Math.min(x, y);
			}
			if(Min%K==0)System.out.println(Min/K+1);
			else System.out.println(Min/K+2);
	}
	int encode(int y,int x){
		return y*1000+x;
	}
	boolean ok(int y,int x){
		return y>=0 && x>=0 && y<H && x<W;
	}
}

Measured memory_bytes: 43648
#include <bits/stdc++.h>
using namespace std;
//#define MOD 100000007
long long N;
long long M;
int k;
using Graph = vector<vector<int>>;
vector<int> color(100000,0);
vector<bool> used(100000,false);
//vector<bool> ans(100000,false);

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};
int ans = 0;

int solve(int a,int b)
{
    int ans = 0;
    for(int i=0;i<a;i++)
    {
        for(int j=i+1;j<a;j++)
        {
            for(int k=j+1;k<a;k++)
            {
                if(i+j+k+3 == b)
                {
                    ans++;
                }
            }
        }
    }
    return ans;
}
int main()
{
    cin >> N ;
    //cin >> M;
    
    //Graph data(1000);
    
    int ans = 0;
    for(int i= 0;2*i<N;i++)
    {
        int count = 0;
        int x = 2*i+1;
        for(int j= 0;2*j-1<2*i;j++)
        {
            if(x%(2*j+1) == 0) //2*j <= 2*i
            {
                count++;
            }
        }
        
        if(count == 8)
        {
            ans++;
        }
    }
   
    
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
// Problem : C - Tax Increase
// Contest : AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,n) for (ll i = 0; i < n; i++)
#define REPR(i,n) for(ll i = n-1; i >= 0; i--)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define FORR(i,a,b) for(ll i = a-1; i>= b; i--)
#define ff first
#define ss second
#define MAXN (ll)1000002
#define MODN (ll)1000000007
#define mp make_pair
#define pb push_back
#define LN(x) (ll)x.length()
#define SZ(x) (ll)x.size()
#define bg(x) (x.begin())
#define rbg(x) (x.rbegin())
#define ENDL cout<<endl
ll n,t=1,tmp;
ll arr[MAXN];
int main() {
	ll a,b;
	cin>>a>>b;
    FOR(i,1,1251) {
		if((i*8)/100 == a && (i*10)/100 == b) {
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {}
};

int n, m;
vector<vector<edge>> g;

bool check(int a, int b) {
    // front:now,back:from
    queue<pair<int, int>> bfs;
    bfs.push({a, -1});
    while (!bfs.empty()) {
        auto p = bfs.front();
        bfs.pop();
        for (auto e : g[p.first]) {
            if (e.to == p.second) continue;
            if (e.to == a) return true;
            if (e.to != b) {
                bfs.push({e.to, p.first});
            }
        }
    }
    return false;
}

int main() {
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool has_six = false;
    vector<int> intersection;
    for (int i = 0; i < n; i++) {
        int s = g[i].size();
        if (s % 2 == 0) {
            if (s / 2 >= 3) {
                has_six = true;
            } else {
                if (s / 2 == 2) {
                    intersection.push_back(i);
                }
            }
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    if (has_six) {
        cout << "Yes" << endl;
        return 0;
    }
    string ans;
    int det = intersection.size();
    if (det > 2) {
        ans = "Yes";
    } else if (det == 2) {
        ans = (check(intersection[0], intersection[1]) ? "Yes" : "No");
    } else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
const int N = 6e5 + 7;

int n, a[N], k, tree[4 * N];

#define m (l + r) / 2
#define lson 2 * node
#define rson 2 * node + 1

void update(int pos, int v, int l, int r, int node) {
    if (l == r) {
        tree[node] = v;
        return;
    }
    if (pos <= m) update(pos, v, l, m, lson);
    else update(pos, v, m + 1, r, rson);
    tree[node] = max(tree[lson], tree[rson]);
}

int query(int ql, int qr, int l, int r, int node) {
    if (ql <= l && qr >= r) {
        return tree[node];
    }
    int ans = 0;
    if (ql <= m) ans = max(ans, query(ql, qr, l, m, lson));
    if (qr > m) ans = max(ans, query(ql, qr, m + 1, r, rson));
    return ans;
}



int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int res = query(max(a[i] - k, 0), a[i] + k, 0, N, 1) + 1;
        ans = max(ans, res);
        update(a[i], res, 0, N, 1);
    }
    cout << ans << endl;



    
}

Measured memory_bytes: 9004
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, T;
    cin >> A >> B >> T;
    cout << (T / A) * B << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
	//i=m -> n

int main(){
  LL d,t,s;
  cin >> d >> t >> s;
  
  if(s*t >= d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


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


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


void solve() {
	vector<pair<int, int>> s;
	pair<int, int>buf;
	int n; cin >> n;
	rep(i, n) {
		cin >> buf.first;
		buf.second = i + 1;
		s.push_back(buf);
	}
	sort(s.begin(), s.end());
	rep(i, n) {
		if (i != 0) cout << " ";
		cout << s[i].second;
	}
	cout << endl;
}

int main() {


	solve();


	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

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

    if (A > B)
    {
        int c = A;
        A = B;
        B = c;
    }

    if ((B - A) % 2 == 0)
    {
        OP(B - (B - A) / 2)
    }
    else
    {
        OP("IMPOSSIBLE")
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double P,E,T;

double dfs(int k,double L,double R){
  double H=(R+L)/2,PP=H>=T ?1-P:P;
  if(k==0||(T<R-E||L+E<T)||(abs(L-T)<=E&&abs(R-T)<=E))return abs(H-T)<=E;
  return PP*dfs(k-1,H,R)+(1-PP)*dfs(k-1,L,H);
}

int main(){
  double K,R,L;
  cin>>K>>R>>L>>P>>E>>T;
  printf("%.10f\n",dfs(K,L,R));
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#include <chrono>
#define fr first
#define sc second
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll md = 1000000007;
vl fac(2,1), ifac(2,1);

ll ad(ll a, ll b) {
    return (a%md + b%md + md) % md;
}

ll ml(ll a, ll b) {
    return ( (a%md) * (b%md) ) % md;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(int n, int r) {
    if(n < r || r < 0) return 0;
    return ml(fac[n], ml(ifac[r], ifac[n-r]));
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cachefact(1e6);
    int h, w, n, i, j;
    cin >> h >> w >> n;
    h--, w--;
    ll ans = C(h+w, h);
    vector<pair<ll,ll>> a(n);
    for(i = 0; i < n; ++i) {
    	cin >> a[i].fr >> a[i].sc;
    	a[i].fr--;
    	a[i].sc--;
    }
    sort(a.begin(), a.end());
    vl dp(n);
    for(i = 0; i < n; ++i) {
    	dp[i] = C(a[i].fr + a[i].sc, a[i].fr);
    	for(j = 0; j < i; ++j) {
    		if(a[j].fr <= a[i].fr && a[j].sc <= a[i].sc) {
    			dp[i] = ad(dp[i], - ml(dp[j], C(a[i].fr + a[i].sc - a[j].fr - a[j].sc, a[i].fr - a[j].fr)));
    		}
    	}
    }
    for(i = 0; i < n; ++i) {
    	ans = ad(ans, - ml(dp[i], C(h + w - a[i].fr - a[i].sc, h - a[i].fr)));
    }
    cout << ans << "\n";
    return 0;
}





/*
	{a,b,c,d}
    =
    a b c d ab ac ad bc bd cd abc abd acd bcd abcd
    a ab ac ad abc abd acd abcd = dp[1]
    b bc bd bcd = dp[2]
    c cd = dp[3]
    d = dp[4]
    b: ab
    c: ac bc abc
    d:
    ad bd cd abd acd bcd abcd
    ad abd acd abcd
    bd bcd
    cd
    dp[0][i] = C(a[i].fr + a[i].sc, a[i].fr) - 
    dp[1][i] = dp[1][i-1] + dp[0][i] * C(h+w-a[i].fr-a[i].sc, h-a[i].fr)
    b, ab
    c, ac, bc, abc
 */

Measured memory_bytes: 23368
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e4+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
int main(){
  IOS();
  int n;
  cin>>n;
  REP(i,n) cin>>d[i];
  ll ans = 0;
  REP(i,n){
    int tmp = d[i];
    while( tmp%2 == 0 ) ans++,tmp/=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
#include <cmath>
#include <limits>
#include <queue>
using namespace std;


int main()
{
	long long N;

	cin >> N;

	bool able = true;

	bool danger = false; //!< ���O�ɉ��������������
	long long prev = 0;
	for (long iN = 0; iN < N; iN++) {
		long long val;

		cin >> val;

		if (prev - val >= 2) {
			able = false;
			break;
		}
		else if (prev - val == 1) {
			if (danger == true) {
				able = false;
				break;
			}
			else {
				danger = true;
			}
		}
		else if (prev < val) {
			danger = false;
		}

		prev = val;
	}

	if (able == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


//int main()
//{
//	long long A, B, C;
//
//	cin >> A >> B >> C;
//
//	long long lastA = A - B;
//
//	if (C <= lastA) {
//		cout << 0 << endl;
//	}
//	else {
//		cout << C - lastA << endl;
//	}
//
//	return 0;
//}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n, total = 0;
	scanf("%d", &n);
	for(int i = 1; i<n; i++){
		if(n%i==0) total+=(n/i)-1;
		else total+=n/i;
	}
	printf("%d", total);
	return 0;
}

Measured memory_bytes: 1736
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static void add(Map<Integer, Integer> m , int k , int v) {
		if(m.containsKey(k)) {
			int newV = m.get(k) + v;
			m.put(k, newV);
		}else {
			m.put(k, v);			
		}
	}
	static long solve(int mem[] , int K) {
		long cnt = 0;
		int N = mem.length;
		for(int k = 1 ; k <= N ; ++k) {
			long S = mem[k - 1];
			if(S == k) {
				++cnt;
			}
		}
		int M[] = new int[N];
		for(int i = 0 ; i < N ; ++i) {
			M[i] = mem[i] - (i % K) + K;
			M[i] = M[i] % K;
		}
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 1 ; i < Math.min(N, K) ; ++i) {
			int mi = M[i];
			add(map, mi, 1);
		}
		for(int j = 0 ; j < N ; ++j) {
			int mj = M[j];
			int L = j + 1;
			int R = Math.min(K + j, N);
			if(map.containsKey(mj)) {
				cnt += map.get(mj);				
			}
			if(L < N) {
				add(map, M[L], -1);
			}
			if(R < N ) {
				add(map, M[R], 1);				
			}
		}
		return cnt;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i) {
			A[i] = sc.nextInt() % K;			
		}
		int mem[] = new int[N];
		mem[0] = A[0] % K;
		for(int i = 1 ; i < N ; ++i) {
			mem[i] = (mem[i - 1] + A[i]) % K; 
		}
		System.out.println(solve(mem, K));
	}
}


Measured memory_bytes: 104392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int a,b;cin>>a>>b;
    if(a>b) cout<<"a > b"<<endl;
    else if(a<b) cout<<"a < b"<<endl;
    else cout<<"a == b"<<endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
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() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> cost(10, vector<int>(10,0));
	rep(i, 10){
        rep(j, 10){
            cin >> cost[i][j];
        }
	}
	for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
	}
	int ans = 0;
	rep(i,h){
        rep(j,w){
            int a;
            cin >> a;
            if(abs(a) == 1) continue;
            ans += cost[a][1];
        }
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
def keta_sum(x):
    m = 0
    while x:
        m += x%10
        x //= 10
    return(m)
res = 0
for i in range(N+1):
    if A <= keta_sum(i) <= B:
        res += i
print(res)

Measured memory_bytes: 3060
#include <cstdlib>
#include <iostream>

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

  int n, y;
  std::cin >> n >> y;
  int a = 0, b = 0, c = 0;

  for (a = n; a >= 0; a--) {
    if (10000 * a > y) {
      continue;
    }
    for (b = n - a; b >= 0; b--) {
      if (10000 * a + 5000 * b > y) {
        continue;
      }
      for (c = n - a - b; c >= 0; c--) {
        if (a + b + c != n) {
          continue;
        }
        if (10000 * a + 5000 * b + 1000 * c == y) {
          std::cout << a << ' ' << b << ' ' << c << std::endl;
          return EXIT_SUCCESS;
        }
      }
    }
  }

  std::cout << -1 << ' ' << -1 << ' ' << -1 << std::endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  int n; cin >> n;
  vector<long long> a(n);
  long long total = 0LL;
  for (auto &x : a) cin >> x, total += x;
  long long lft = 0LL;
  long long ans = numeric_limits<long long>::max();
  for (int i = 0; i < n; ++i) {
    lft += a[i]; 
    if (lft == total - lft) ans = 0;
    ans = min(ans, abs(total - lft - lft));
  }
  cout << ans << endl;

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 1792
#include <set>
#include <string>
#include <vector>
#include <iostream>
using namespace std;

class Point
{
public:
  int x, y;
  Point(int xx = -1, int yy = -1)
    :x(xx), y(yy) {}
};

class Rect
{
public:
  char sign;
  Point lu, rd;
  Rect(char s, Point a, Point b)
    :sign(s), lu(a), rd(b) {}
};

int main()
{
  int N;
  cin >> N;
  while (N--) {
    int H, W;
    cin >> H >> W;

    vector<string> s(H);
    for (int i = 0; i < H; ++i)
      cin >> s[i];

    set<char> alpha;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
	if (s[i][j] != '.')
	  alpha.insert(s[i][j]);
      }
    }

    
    vector<Rect> rec;
    for (set<char>::iterator it = alpha.begin(); it != alpha.end(); ++it) {
      Point lu, rd;
      // y
      for (int y = 0; y < H; ++y) {
	for (int x = 0; x < W; ++x) {
	  if (s[y][x] == (*it)) {
	    if (lu.y == -1)
	      lu.y = y;
	    rd.y = y;
	  }
	}
      }

      // x
      for (int x = 0; x < W; ++x) {
	for (int y = 0; y < H; ++y) {
	  if (s[y][x] == (*it)) {
	    if (lu.x == -1)
	      lu.x = x;
	    rd.x = x;
	  }
	}
      }

      rec.push_back(Rect(*it, lu, rd));
    }

    for ( ; ; ) {
      bool op = false;

      for (int i = 0; i < rec.size(); ++i) {
	bool ok = true, found = false;
	for (int y = rec[i].lu.y; y <= rec[i].rd.y && ok; ++y) {
	  for (int x = rec[i].lu.x; x <= rec[i].rd.x; ++x) {
	    if (s[y][x] == rec[i].sign)
	      found = true;
	    if (s[y][x] != rec[i].sign && s[y][x] != '$') {
	      ok = false;
	      break;
	    }
	  }
	}

	if (ok && found) {
	  op = true;
	  for (int y = rec[i].lu.y; y <= rec[i].rd.y; ++y) {
	    for (int x = rec[i].lu.x; x <= rec[i].rd.x; ++x)
	      s[y][x] = '$';
	  }
	}
      }

      if (!op)
	break;
    }
    
    bool safe = true;
    for (int i = 0; i < H && safe; ++i) {
      if (s[i].find_first_not_of("$.", 0) != string::npos)
	safe = false;
    }

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

  }
  return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        if(x[i]<= k/2) ans += 2*x[i];
        else ans += 2*(k-x[i]);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
# include <functional>
# include <cmath>
# include <iomanip>
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
	}
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				break;
			}
			if (a[i] < b[i]) {
				cout << "LESS" << endl;
				break;
			}
			if (i == a.size() - 1) {
				cout << "EQUAL" << endl;
			}
		}

	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    set<string> st;
    REP(i, N) {
        string s;
        cin >> s;
        st.emplace(s);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 19236
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		int top    = sc.nextInt();
		int front  = sc.nextInt();
		int left   = sc.nextInt();
		int right  = sc.nextInt();
		int back   = sc.nextInt();
		int bottom = sc.nextInt();
		
		final String input = sc.next();
		for(char c : input.toCharArray()){
			if(c == 'S'){
				int tmp = bottom;
				bottom = front;
				front = top;
				top = back;
				back = tmp;
			}else if(c == 'N'){
				int tmp = bottom;
				bottom = back;
				back = top;
				top = front;
				front = tmp;
			} else if(c == 'W'){
				int tmp = bottom;
				bottom = right;
				right = top;
				top = left;
				left = tmp;
			} else if(c == 'E'){
				int tmp = bottom;
				bottom = left;
				left = top;
				top = right;
				right = tmp;
			}
		}
		
		System.out.println(top);
	}
}

Measured memory_bytes: 17288
//Optimise
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fast()                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

#define f first
#define s second
#define pb push_back
#define mp make_pair

const long long mod = 100000000;
const long long High = 1e16;

int main()
{
    fast();
  	ld x,t;
  	cin >> t >> x;
  	cout << setprecision(9) << fixed << t/x;
    return 0;
}


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

// ダイクストラ
// 負の重みの辺を含むグラフには適用できない
int N, M;
const int INF = 1000000000;
vector<int> p;
vector<vector<pair<int, int>>> G;  // first : 頂点, second : 有向辺の重み

void dijkstra(int r) {
  // first : スタート地点からのコスト, second : 頂点
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> PQ;
  vector<int> color(N);
  vector<int> d(N, INF);
  color.at(r) = 1;
  d.at(r) = 0;
  PQ.push(make_pair(0, r));

  while (!PQ.empty()) {
    // 最短経路木に追加する候補からコスト最小の頂点 u を取り出す
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color.at(u) = 2;  // 最短経路木に追加

    if (d.at(u) < f.first) continue;

    // u に隣接する頂点を候補に追加
    for (auto cand : G.at(u)) {
      int v = cand.first;
      if (color.at(v) == 2) continue;
      if (d.at(u) + cand.second < d.at(v)) {
        d.at(v) = d.at(u) + cand.second;
        PQ.push(make_pair(d.at(v), v));
        color.at(v) = 1;
        p.at(v) = u + 1;
      }
    }
  }
}

int main() {
  cin >> N >> M;
  G.resize(N);
  p = vector<int>(N, -1);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G.at(a).push_back(make_pair(b, 1));
    G.at(b).push_back(make_pair(a, 1));
  }
  dijkstra(0);
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) {
    cout << p.at(i) << endl;
  }
}

Measured memory_bytes: 14032
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    vvi dp(s.length()+1,vi(5));
    dp[0][0]=1;
    rep(i,s.length()){
        rep(j,4){
            if(s[i]=='?'){
                dp[i+1][j]=(dp[i+1][j]+dp[i][j]*3%mod)%mod;
                dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
            }
            else dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
        }
        if(s[i]=='A')dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod;
        if(s[i]=='B')dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mod;
        if(s[i]=='C')dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mod;
    }
    cout<<dp[s.length()][3]<<endl;
}

Measured memory_bytes: 7376
#include <stdio.h>

int main (void){

        int a, b;

        scanf("%d %d", &a, &b);

        if(-1000 <= a && a <= 1000 && -1000 <= b && b <= 1000){

                if(a < b) printf("a < b\n");
                if(a > b) printf("a > b\n");
                if(a == b) printf("a == b\n");
        }

        return 0;
}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
int main(void){
    long long T1,T2,A1,A2,B1,B2,a,c,ans;
    cin>>T1>>T2>>A1>>A2>>B1>>B2;
    if((A1-B1)*T1+(A2-B2)*T2==0){
        cout<<"infinity"<<endl;
        return 0;
    }
    if((A1-B1)*T1+(A2-B2)*T2<0){
        c=A1;A1=B1;B1=c;
        c=A2;A2=B2;B2=c;
    }
    if(A1>B1){
        cout<<0<<endl;
        return 0;
    }
    a=(A1-B1)*T1+(A2-B2)*T2;
    if((B1*T1-A1*T1)%a==0){
        ans=((B1*T1-A1*T1-1)/a+1)*2;
    }else{
        ans=((B1*T1-A1*T1)/a+1)*2-1;
    }
    if(ans<0){
        ans=0;
    }
    cout<<ans<<endl;
}


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

class Program {
    static void Main(string[] args) {
        string s = cin.next();

        char lastWard = s.First();
        int count = 0;

        for (int i = 1; i < s.Length; i++) {
            if (lastWard != s[i]) count++;
            lastWard = s[i];
        }

        Console.WriteLine(count);
    }
}


public class cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public static int ni() {
        return int.Parse(next());
    }

    public static long nextLong() {
        return long.Parse(next());
    }

    public static double nextDouble() {
        return double.Parse(next());
    }

}


Measured memory_bytes: 3544
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = 0;
		for(int i =0;i < s.length(); i++) {
			if(s.charAt(i) == '1') {
				n++;
			}else {
				
			}
		}
		System.out.println(n);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool ispali(string s)
{
    ll i,j,k,l=s.length();
    i=0;
    j=l-1;
    while(i<l/2)
    {
        if(s[i]!=s[j])
        return false;
        i++;
        j--;
    }
    return true;
}
int main()
{
    ll t,i,j,k,l,m,n,o,p,q,r,s,a[300002],map[300001]={0};
    cin>>n;
    s=0;
    for(i=0;i<n;i++)
    {
        cin>>j;
        a[i]=j;
        map[j]++;
    }
    for(i=0;i<=n;i++)
    {
          k=map[i];
          s+=(k*(k-1))/2;
    }
    for(i=0;i<n;i++)
    {
        k=map[a[i]];
        p=k-1;
        o=s-(k*(k-1))/2;
        o=o+(p*(p-1))/2;
        cout<<o<<endl;
    }
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(b>1 && a>b || a==1 && a<b) cout<<"Alice"<<endl;
  else if(a>1 &&a<b || b==1 && a>b) cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
  return 0;
}


Measured memory_bytes: 256
// D - Swap and Flip
#include <bits/stdc++.h>

using namespace std;

#define	INF	1000000000

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	vector<vector<int> > dp(1 << n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) dp[1 << i][i] = i;
	for (int k = 0; k < (1 << n); k++)
		for (int l = 0; l < n; l++) {
			if ((k & (1 << l)) == 0) continue;
			int p = k ^ (1 << l);
			int c = __builtin_popcount(p);
			int x = abs(l - c) % 2 == 0 ? a[l] : b[l];
			int d = __builtin_popcount((~k) & ((1 << l) - 1));
          for (int i = 0; i < n; i++) {
            if ((p & (1 << i)) == 0) continue;
            int y = abs(i - c + 1) % 2 == 0 ? a[i] : b[i];
            if (y <= x) dp[k][l] = min(dp[k][l], dp[p][i] + d);
          }
		}
	int ans = INF;
	for (int i = 0; i < n; i++) ans = min(ans, dp[(1 << n) - 1][i]);

	cout << (ans < INF ? ans : -1) << endl;

	return 0;
}


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

int main(){
    char egara;
    int n,suuji;
    int a[4][14];

    for(int i=0;i<4;i++){
        for(int j=0;j<14;j++){
            a[i][j] = 0;
        }
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>egara>>suuji;
        if(egara=='S') a[0][suuji]=1;
        if(egara=='H') a[1][suuji]=1;
        if(egara=='C') a[2][suuji]=1;
        if(egara=='D') a[3][suuji]=1;
    }
    for(int i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(a[i][j]) continue;
            if(i==0) egara='S';
            if(i==1) egara='H';
            if(i==2) egara='C';
            if(i==3) egara='D';
            cout<<egara<<' '<<j<<'\n';
        }
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
map<int,int>mp;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,L,N,M,K,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(dist,int,N,0);
  rep(i,0,K){
    cin >> A;
    rep(j,0,A){
      cin >> B;
      dist[B-1]++;
    }
  }
  rep(i,0,N)if(dist[i]==0)sum++;
  Out(sum);
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>

#include <algorithm>

using std::max;
using std::min;
using std::sort;

char s[10], t[10];

int main(void) {
  scanf("%s%s", s, t);
  printf("%d\n", (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]));
  return 0;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

    int D, N;
    cin >> D >> N;
    vector<int> T(D);
    FOR(i, 0, D) {
        cin >> T[i];
    }

    vector<tuple<int, int, int>> C;
    FOR(i, 0, N) {
        int a, b, c;
        cin >> a >> b >> c;
        C.emplace_back(make_tuple(a, b, c));
    }

    vector<vector<LL>> dp(D, vector<LL>(101, -1));
    FOE(t, C) {
        int a, b, c;
        tie(a, b, c) = t;
        if (a <= T[0] and T[0] <= b) {
            dp[0][c] = 0;
        }
    }


    FOR(i, 0, D - 1) {
        FOR(j, 0, dp[0].size()) {
            if (dp[i][j] == -1) {
                continue;
            }

            FOE(t, C) {
                int a, b, c;
                tie(a, b, c) = t;

                if (a <= T[i + 1] and T[i + 1] <= b) {
                    dp[i + 1][c] = max(dp[i + 1][c], dp[i][j] + abs(j - c));
                }
            }
        }
    }

    LL ans = 0;
    FOR(j, 0, dp[0].size()) {
        ans = max(ans, dp[D - 1][j]);
    }

    print(ans);

	return 0;
}


Measured memory_bytes: 3344
from collections import deque
n,m=map(int,input().split())
path=[[] for i in range(n*3+3)]
seen=[0]*(3*n)
for i in range(m):
  u,v=map(int,input().split())
  path[3*(u-1)].append(3*(v-1)+1)
  path[3*(u-1)+1].append(3*(v-1)+2)
  path[3*(u-1)+2].append(3*(v-1))
s,t=map(int,input().split())
s-=1
t-=1
q=deque()
q.append(s*3)
seen[s*3]=1
while q:
  x=q.popleft()
  if x%3==0 and x//3==t:
    print(seen[x]//3)
    exit()
  for i in path[x]:
    if seen[i]==0:
      seen[i]=seen[x]+1
      q.append(i)
print(-1)

Measured memory_bytes: 82980