akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

enum FACE{TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};
class Dice {
public:
	Dice() {
		id[TOP] = 0; id[BOTTOM] = 1; id[FRONT] = 2;
		id[BACK] = 3; id[LEFT] = 4; id[RIGHT] = 5;
	}
	Dice(int top,int bottom, int front, int back, int left, int right) {
		id[TOP] = top; id[BOTTOM] = bottom; id[FRONT] = front;
		id[BACK] = back; id[LEFT] = left; id[RIGHT] = right;
	}
	int& operator[] (FACE f) { return id[f]; }
	void rotX(int c) {
		for(int i = 0; i < c; ++i) {
			int top = id[BACK], front = id[TOP], bottom = id[FRONT], back = id[BOTTOM];
			id[TOP] = top; id[FRONT] = front;
			id[BOTTOM] = bottom; id[BACK] = back;
		}
	}
	void rotY(int c) {
		for(int i = 0; i < c; ++i) {
			int top = id[LEFT], right = id[TOP], bottom = id[RIGHT], left = id[BOTTOM];
			id[TOP] = top; id[RIGHT] = right;
			id[BOTTOM] = bottom; id[LEFT] = left;
		}
	}
	void rotZ(int c) {
		for(int i = 0; i < c; ++i) {
			int front = id[RIGHT], left = id[FRONT], back = id[LEFT], right = id[BACK];
			id[FRONT] = front; id[LEFT] = left;
			id[BACK] = back; id[RIGHT] = right;
		}
	}
	vector<vector<int> > all() {
		vector<vector<int> > vs;
		for(int i = 0; i < 4; ++i) {
			for(int j = 0; j < 4; ++j) {
				vector<int> v(6);
				v[TOP] = id[TOP]; v[BOTTOM] = id[BOTTOM];
				v[FRONT] = id[FRONT]; v[BACK] = id[BACK];
				v[RIGHT] = id[RIGHT]; v[LEFT] = id[LEFT];
				vs.pb(v);
				rotZ(1);
			}
			rotX(1);
		}
		for(int i = 0; i < 4; ++i) {
			for(int j = 0; j < 4; ++j) {
				vector<int> v(6);
				v[TOP] = id[TOP]; v[BOTTOM] = id[BOTTOM];
				v[FRONT] = id[FRONT]; v[BACK] = id[BACK];
				v[RIGHT] = id[RIGHT]; v[LEFT] = id[LEFT];
				vs.pb(v);
				rotZ(1);
			}
			rotY(1);
		}
		return vs;
	}
private:
	int id[6];
};

bool solve(Dice d1, Dice d2) {
	vector<vector<int> > a = d1.all();
	bool d = false;
	REP(i,a.size()) {
		if(d2[TOP]==a[i][TOP]&&d2[FRONT]==a[i][FRONT]&&d2[RIGHT]==a[i][RIGHT]&&d2[BOTTOM]==a[i][BOTTOM]&&d2[BACK]==a[i][BACK]&&d2[LEFT]==a[i][LEFT]) d = true;
	}
	return d;
}

int main() {
	int n;
	cin>>n;
	vector<Dice> d(n);
	REP(i,n) {
		int top,right,front,back,left,bottom;
		cin>>top>>right>>front>>back>>left>>bottom;
		d[i][TOP]=top;
		d[i][RIGHT]=right;
		d[i][FRONT]=front;
		d[i][BACK]=back;
		d[i][LEFT]=left;
		d[i][BOTTOM]=bottom;
	}
	bool f = false;
	REP(i,n) {
		REP(j,n) {
			if(i==j) continue;
			f = f|solve(d[i],d[j]);
		}
	}
	if(f) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3160
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int cnt[28][52] = { };
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n;
	cin >> n;
	lp(i,1,n)
	{
		string s;
		cin >> s;
		for (auto u : s)
			cnt[u - 'a'][i]++;
	}
	lp(i,0,25)
	{
		int z = 100;
		lp(j,1,n)
			z = min(z, cnt[i][j]);
		lp(k,1,z)
			cout << (char) (i + 'a');
	}
	return 0;
}

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

int n, m, a[100005];
int main()
{
	int i, t1, t2;
	cin >> n >>m;
	while (m--) {
		scanf ("%d %d", &t1, &t2);
		a[t1]++;
		a[t2]++;
	}
	for (i = 1; i <= n; i++) {
		if (a[i] % 2) break;
	}
	if (i > n) cout << "YES";
	else cout << "NO";
    return 0;
}


Measured memory_bytes: 640
module Weighted_UF
    
    integer, allocatable, dimension(:) :: par, rank, diff_weight

    contains
    
    subroutine init(N)
        integer :: N
        allocate(par(N), rank(N), diff_weight(N))
        do i = 1, N
            par(i) = i
            rank(i) = 0
            diff_weight(i) = 0
        end do
    end subroutine

    recursive function root(x) result (res)
        integer :: x, res
        if (par(x) == x)then 
            res = x
        else
            res = root(par(x))
            diff_weight(x) = diff_weight(x) + diff_weight(par(x))
            par(x) = res
        end if
    end function

    function weight(x) result (res)
        integer :: x, res, r
        res = diff_weight(x)
        r = root(x)
    end function

    function same(x, y) result (res)
        integer :: x, y
        logical :: res
        res = (root(x) == root(y))
    end function
    
    subroutine unite(x, y, w)
        integer :: x, y, w
        w = w + weight(x) - weight(y)
        x = root(x); y = root(y)
        if (x /= y) then
            if(rank(x) < rank(y)) then
                x = xor(x, y); y = xor(y, x); x = xor(x, y) !swap
                w = -w
            end if
            if(rank(x) == rank(y)) then
                rank(x) = rank(x) + 1
            end if
            par(y) = x
            diff_weight(y) = w
        end if
    end subroutine

    function diff(x, y) result (res)
        integer :: x, y, res
        res = weight(y) - weight(x)
    end function
    
    subroutine print_UF(N)
        integer :: N
        print"(a)", parents
        do i = 1, N
            print*, "Number :", i , " " , par(i)
        end do
    end subroutine
end module Weighted_UF

program main
    use Weighted_UF

    integer N, M, l, r, d
    read*,N, M

    call init(N)

    do i = 1, M
        read*, l, r, d
        if (same(l, r)) then
            if (diff(l, r) /= d) then
                print"(a)", "No"
                stop
            end if
        else
            call unite(l, r, d)
        end if
        
    end do

    print"(a)", "Yes"
end

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

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

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> 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(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll ansA = max(a - k, 0LL);
  k -= a - ansA;
  ll ansB = b - k;
  ansB = max(ansB, 0LL);
  cout << ansA << " " << ansB << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)  ary[i] = Integer.parseInt(line1[i]);
        int[] ary1 = ary.clone();
        Arrays.sort(ary1);
        int count = 0;
        for(int i = 0; i < ary.length; i++) if(ary[i] != ary1[i])   count++;
        if(count == 2 || count == 0)  System.out.println("YES");
        else    System.out.println("NO");
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    int ans = 1e9;
    for(int p = 1; p <= 100; p++){
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum += (x[i]-p)*(x[i]-p);
        }
        if(ans > sum) ans = sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  if (K % 2 != 0) {
    ll res = 0;
    rep1(i, N) {
      if (i % K == 0) res++;
    }
    cout << res * res * res << endl;
    return 0;
  } else {
    ll res1 = 0, res2 = 0;
    rep1(i, N) {
      if (i % K == 0) res1++;
    }
    rep1(i, N) {
      if (i % K == K / 2) res2++;
    }
    cout << res1 * res1 * res1 + res2 * res2 * res2 << endl;
  }
  return 0;
}


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

#define INPUT_FROM_FILE (0)

const int Num_doom = 4;
const int Num_floor = 3;
const int Num_room = 10;

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif // INPUT_FROM_FILE
	std::vector<std::vector<std::vector<char> > > doom_info;
	int n = 0;
	int b = 0;
	int f = 0;
	int r = 0;
	int v = 0;

	doom_info.resize(Num_doom + 1);
	for(unsigned i = 0; i < doom_info.size(); i++){
		doom_info[i].resize(Num_floor + 1);
		for(unsigned j = 0; j < doom_info[i].size(); j++){
			doom_info[i][j].resize(Num_room + 1, 0);
		}
	}

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif // INPUT_FROM_FILE

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> b >> f >> r >> v;
#else
		std::cin >> b >> f >> r >> v;
#endif // INPUT_FROM_FILE
		doom_info[b][f][r] += v;
	}

	for(unsigned i = 1; i < doom_info.size(); i++){
		for(unsigned j = 1; j < doom_info[i].size(); j++){
			for(unsigned int k = 1; k < doom_info[i][j].size(); k++){
				std::cout << " ";
				std::cout << (int)doom_info[i][j][k];
			}
			std::cout << std::endl;
		}
		if(i < doom_info.size() - 1){
			for(unsigned int j = 0; j < 20; j++){
				std::cout << "#";
			}
			std::cout << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);

		int k=sc.nextInt();		//英小文字からなる文字列
		String s=sc.next();
		int n=s.length();
		String komos=s.toLowerCase ();	//小文字に

		if(n>=1&&n<=100) {
			if(k>=1&&k<=100) {
				if(n<=k) {
					System.out.println(komos);
				}else {
					System.out.println(komos.substring(0,k)+"...");
				}
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 27072
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();

let [N, M] = reader.readInts();

enum RequestType {
    LEFT = 0,
    RIGHT = 1
}

interface IRequest {
    city: number;
    requestType: RequestType;
}

interface RequestLeft extends IRequest {
    requestType: RequestType.LEFT;
}

interface RequestRight extends IRequest {
    requestType: RequestType.RIGHT;
    left: RequestLeft;
}

type Request = RequestLeft|RequestRight;
let requests: Request[] = [];

for(let i=0; i<M; i++) {
    let [a, b] = reader.readInts() as [number, number];
    let left: RequestLeft = {city: a-1, requestType: RequestType.LEFT};
    requests.push(left);
    let right: RequestRight = {city: b-1, requestType: RequestType.RIGHT, left: left};
    requests.push(right);
}

function compareRequests(city1: IRequest, city2: IRequest): number {
    if (city1.city != city2.city)
        return city1.city-city2.city;
    return city2.requestType-city1.requestType;
}

requests.sort(compareRequests);

let isDisconnected: boolean[] = new Array(N).fill(false);
let stack: RequestLeft[] = [];
let answer: number = 0;

for(let request of requests) {
    if (request.requestType == RequestType.LEFT) {
        stack.push(request);
    } else if (!isDisconnected[request.left.city]) {
        while (stack.length > 0) {
            isDisconnected[stack.pop().city] = true;
        }
        answer += 1;
    }
}

console.log(answer);


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

int main() {
  int a,b,c;
  cin >> a;
  b=a;
  a/=10;
  b%=1000;
  a%=111;c=b%111;
  if(a==0||c==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

using namespace std;

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

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

int main() { 
    string s;
    int w;
    cin >> s >> w;
    rep(i, s.size()) if(i % w == 0) cout << s[i];
    cout << endl;
    
    return 0; 
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
ab = sorted(ab, key=lambda x:(x[1],x[0]))

f = ab[0][1]
ans = 0
for a,b in ab:
  if a >= f:
    ans += 1
    f = b
    
print(ans+1)    

Measured memory_bytes: 36288
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
const double PI = acos(-1);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

/*C++になってるか確認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int N, M, X; cin>>N>>M>>X;
    int C[N], A[N][M];
    for(int i=0; i<N; i++){
        cin>>C[i];
        for(int j=0; j<M; j++){
            cin>>A[i][j];
        }
    }

    int check[M];
    int ans=INF, cost;
    for(int bit=0; bit < (1<<N); bit++){
        cost=0;
        for(int i=0; i<M; i++){
            check[i]=0;
        }
        for(int i=0; i<N; i++){
            if(bit & (1<<i)){
                cost+=C[i];
                for(int j=0; j<M; j++){
                    check[j]+=A[i][j];
                }
            }
        }
        for(int j=0; j<M; j++){
            if(check[j]<X){
                goto endloop;
            }
        }
        if(cost!=0){
            ans=min(ans, cost);
        }
        endloop:;

    }
    if(ans==INF){
        ans=-1;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	string N;
	cin >> N;

	string N_rev = N;
	reverse(N_rev.begin(), N_rev.end());

	if (N_rev == N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}





Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1000000005
#define mod 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrep*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrep*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrep*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrep*/
#define each(a,b) for(auto& (a): (b)) /*よくわからん*/
#define all(v) (v).begin(),(v).end() /*全選択*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大値*/
#define cmn(x,y) x=min(x,y) /*最小値*/
#define rev(v) reverse((v).begin(),(v).end()); /*逆順*/
#define so(v) sort((v).begin(), (v).end()); /*ソート*/
#define yn {puts("Yes");}else{puts("No");} /*はい・いいえ*/
#define fi first
#define se second
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vs = vector<string>; 

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout<<"bust"<<endl;
    }
    else {
        cout<<"win"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 100
#define maxv 100000

using namespace std;

pii v[maxn+5];///fi=greutate se=valoare
ll d[maxv+5];///d[i]=greutate minima pt a avea valoare i in rucsac
bool viz[maxv+5];

void umax (ll &a, ll b) { a=max(a,b); }
void umin (ll &a, ll b) { a=min(a,b); }

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, w; cin >> n >> w;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i].fi >> v[i].se;
  fill(all(d), infl); d[0] = 0; viz[0] = 1;
  ll ans = 0;
  for (i = 1; i <= n; i++) {
    for (j = maxv; j-v[i].se >= 0; j--)
      if (viz[j-v[i].se] && d[j-v[i].se]+1LL*v[i].fi <= 1LL*w) {
        viz[j] = 1;
        umin(d[j], d[j-v[i].se]+1LL*v[i].fi);
        umax(ans, j);
      }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,K,ans,r;

string s,f;
int main() {
	cin >> s;
	ans = 0;
	f = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != f[0]) {
			f = s[i];
			ans++;
		}
	}
	cout << ans<<endl;

	return 0;

}


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

using namespace std;

void Main()
{
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	cout << ((a1 + a2 + a3 >= 22) ? "bust" : "win") << endl;
}

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

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

int main(void)
{
    long long ans[100][21];
    int n;
    int add[100];
    int i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%d", &add[i]);
    }
    
    memset(ans, 0, sizeof(ans));
    
    ans[0][add[0]] = 1;
    
    for (i = 1; i < n; i++){
        for (j = 0; j < 21; j++){
            if (ans[i - 1][j] != 0){
                if (j + add[i] <= 20){
                    ans[i][j + add[i]] += ans[i - 1][j];
                }
                if (j - add[i] >= 0){
                    ans[i][j - add[i]] += ans[i - 1][j];
                }
            }
        }
    }
    
    printf("%lld\n", ans[n - 2][add[n - 1]]);
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (a % b)
        return gcd(b, a % b);
    else
        return b;
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n + 1);
    for (int i = 0; i <= n; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        d[i] = x[i + 1] - x[i];
    }
    int ans = d[0];
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, d[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
N, M = map(int, input().split())

def primefactorize(n):
    fct = []  # return [[p1, power1], [p2, power2], ...]
    p, power = 2, 0
    while p * p <= n:
        while n % p == 0:
            n = n // p
            power += 1
        if power > 0:
            fct.append([p, power])
        if p == 2:
            p += 1
        else:
            p += 2
        power = 0
    if n > 1:
        fct.append([n, 1])
    return fct

def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

if M != 1:
    fct = primefactorize(M)
    factors = []
    for div in divisorize(fct):
        factors.append(num(div))
else:
    factors = [1]
factors.sort()
k = M//N
L = [x for x in factors if x <= k]
print(max(L))

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    int n,m;
    int a[10000];
    cin >> n >> m;
    for (int i=0;i<m;i++) {
      cin >> a[i];
    }
    for (int i=0;i<m;i++) {
        n -= a[i];
    }
    if (n < 0) {
        n = -1;
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define SIZE 262144
typedef long long ll;
#define INF 1000000000000000000LL
class segtree
{
public:
	ll seg[SIZE * 2];
	void init()
	{
		fill(seg, seg + SIZE * 2, INF);
	}
	void update(int a, ll b)
	{
		a += SIZE;
		seg[a] = min(seg[a], b);
		for (;;)
		{
			a /= 2;
			if (a == 0)break;
			seg[a] = min(seg[a * 2], seg[a * 2 + 1]);
		}
	}
	ll get(int beg, int end, int node, int lb, int ub)
	{
		if (ub < beg || end < lb)return INF;
		if (beg <= lb&&ub <= end)return seg[node];
		return min(get(beg, end, node * 2, lb, (lb + ub) / 2), get(beg, end, node * 2 + 1, (lb + ub) / 2 + 1, ub));
	}
};
segtree tree1,tree2;
int main()
{
	int num;
	ll len, gen;
	scanf("%d%lld%lld", &num, &len, &gen);
	vector<ll>vec;
	vec.push_back(0);
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		vec.push_back(z);
	}
	vec.push_back(len);
	tree1.init();
	tree2.init();
	tree1.update(0, vec[1] - 3 * vec[1]);
	tree2.update(0, vec[1] - vec[1]);
	for (int i = 1; i < vec.size() - 1; i++)
	{
		int low = lower_bound(vec.begin(), vec.end(), vec[i] - gen / 2) - vec.begin() - 1;
		ll mini = min(tree1.get(0, low - 1, 1, 0, SIZE - 1) + vec[i] * 3, tree2.get(low, i - 1, 1, 0, SIZE - 1) + vec[i] + gen) + vec[i + 1] - vec[i];
		tree1.update(i, mini - vec[i + 1] * 3);
		tree2.update(i, mini - vec[i + 1]);
	}
	printf("%lld\n", tree2.get(vec.size() - 2, vec.size() - 2, 1, 0, SIZE - 1) + len);
}

Measured memory_bytes: 9460
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	ll X;cin >> X;
	bool ok = false;
	vector<ll> a(120);
	for (ll i = 0;i <= 120;i++) {
		a[i] = i*i*i*i*i;
	}
	//for (int i = 0;i < 120; i++)cout << a[i] << endl;
	for (ll i = 0;i<120;i++) {
		for (ll j = i;j<120;j++) {
			if (a[j]+a[i]==X) {
				cout << j << " " << -i << endl;
				ok = true;
				break;
			}
			if (a[j]-a[i]==X) {
				cout << j << " " << i << endl;
				ok = true;
				break;
			}
		}
		if (ok) break;
	}
}


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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
  int64_t N;
  cin >> N;
  
  map<int64_t, int> p;
  p =prime_factor(N);

  int64_t cnt=0;
  for(auto p : prime_factor(N)) {
    int cnt2=0;
    while(p.second--){
        cnt2++;
    }
    cnt+=floor((-1+sqrt(1+8*cnt2))/2);
  }
  cout <<cnt<< endl;
}

// 2 2 2 2 2 2 2 2 2 2 2 
// 1   2     3       4
// 1 2 3 4 5 6 7 8 9 10
// 1からnまでの和　sum=1/2*n*(n+1)
// 

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>

typedef struct student
{
    int studentNumber;
    int studentRow;
} student;

int cmp(const void *n1, const void *n2)
{
    student x = *(student *)n1;
    student y = *(student *)n2;
    return x.studentRow - y.studentRow;
}

int main(void)
{
    int inputN;
    student *inputA;

    scanf("%d", &inputN);
    inputA = (student *) malloc(sizeof(student) * inputN);
    for (int index = 0; index < inputN; index++)
    {
        scanf("%d", &inputA[index].studentRow);
        inputA[index].studentNumber = index + 1;
    }

    qsort(inputA, inputN, sizeof(student), cmp);

    for (int index = 0; index < inputN; index++)
    {
        printf("%d", inputA[index].studentNumber);
        if (index != inputN - 1)
        {
            printf(" ");
        }
    }

    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int n, W; cin >> n >> W;
    vector<long long> dp(W+1);
 
    for (int i=0; i<n; i++){
        long long w,v;
        cin >> w >> v;
        for (int j=W-w; j >= 0; j--){
            dp[w+j] = max(dp[w+j], dp[j] + v);
        }
    }
    long long ans = 0;
    for (int i=0; i<=W; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
    int a,b;
    cin >> a >> b;
    int n=b-a;
    int ans=0;
    for(int i=1;i<=n;++i) {
        ans+=i;
    }
    cout << ans-b << endl;
}



Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())


def main():
    ABCD = list(input())
    for ops in range(2**3):
        t = int(ABCD[0])
        ans = ABCD[0]
        for i in range(3):
            if (ops>>i)&1:
                t += int(ABCD[i+1])
                ans += '+'+ABCD[i+1]
            else:
                t -= int(ABCD[i+1])
                ans += '-'+ABCD[i+1]
        if t == 7:
            ans += '=7'
            print(ans)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 81528
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll unsigned long long
//#define mod 1000000007
#define NCONS 200001

using namespace std;


int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N, M; cin >> N >> M; --N; --M;
	cout << N * M;

	return 0;
}

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

int main(){
    int N;
    int ans =0;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L.at(i);
    }
    for(int a=0; a<N-2; a++){
        for(int b=a+1; b<N-1; b++){
            for(int c=b+1; c<N; c++){
                if(L.at(a)!=L.at(b) && L.at(b)!=L.at(c) && L.at(c)!=L.at(a)
                && L.at(a)+L.at(b)>L.at(c) && L.at(b)+L.at(c)>L.at(a) && L.at(c)+L.at(a)>L.at(b)){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define endl '\n'
#define N 3003

typedef long long ll;

int n, a[N];
ll dp[N][N][3];

//0->taro, 1->jiro
ll dif(int l, int r, int p){
  if(l+r==n) return 0;
  if(dp[l][r][p]!=-1) return dp[l][r][p];
  if(p) return dp[l][r][p]=min((ll) dif(l+1, r, p^1)-a[1+l], (ll) dif(l, r+1, p^1)-a[n-r]);
  return dp[l][r][p]=max((ll) dif(l+1, r, p^1)+a[1+l], (ll) dif(l, r+1, p^1)+a[n-r]);
}

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

  cin >> n;
  for(int i=1; i<=n; i++) cin >> a[i];

  for(int i=0; i<=n+1; i++){
    for(int j=0; j<=n+1; j++){
      for(int k=0; k<=2; k++){
        dp[i][j][k]=-1;
      }
    }
  }

  cout << dif(0, 0, 0) << endl;
}


Measured memory_bytes: 211712
N = int(input())
K = int(input())

res = 0
if K == 1:
    for i in range(1,10):
        for j in range(len(str(N))):
            if i*10**j <= N:
                res += 1
if K == 2:
    for i1 in range(1,10):
        for i2 in range(1,10):
            for j1 in range(len(str(N))-1):
                for j2 in range(len(str(N))-1-j1):
                    if i1*10**(j1+j2+1)+i2*10**j2 <= N:
                        res += 1

if K == 3:
    for j1 in range(len(str(N))-2-1):
        for j2 in range(len(str(N))-2-1-j1):
            for j3 in range(len(str(N))-2-1-j1-j2):
                res += 1
    res = res * (9**3)
    
    for j1 in range(len(str(N))-2):
        for j2 in range(len(str(N))-2-j1):
            j3 = len(str(N))-2-j1-j2-1
            for i1 in range(1,10):
                for i2 in range(1,10):
                    for i3 in range(9,0,-1):
                        if i1*10**(j1+j2+j3+2)+i2*10**(j2+j3+1)+i3*10**+j3 <= N:
                            res += i3
                            break

print(res)


Measured memory_bytes: 44040
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, A, B):
    C = [[abs(a-b) for a, b in zip(ar, br)] for ar, br in zip(A, B)]

    memo = [[set() for _ in range(W)] for __ in range(H)]
    memo[0][0].add(C[0][0])
    for i in range(H):
        for j in range(W):
            c = C[i][j]
            s = memo[i][j]
            if i > 0:
                for d in memo[i-1][j]:
                    s.add(abs(d + c))
                    s.add(abs(d - c))
            if j > 0:
                for d in memo[i][j-1]:
                    s.add(abs(d + c))
                    s.add(abs(d - c))

    return min(map(abs, memo[H-1][W-1]))




def main():
    H, W = read_int_n()
    A = [read_int_n() for _ in range(H)]
    B = [read_int_n() for _ in range(H)]
    print(slv(H, W, A, B))


if __name__ == '__main__':
    main()


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int result = -1;
  for (int i = 1; i < 1500; ++i) {
    if (floor(i * 0.08) == a && floor(i * 0.10) == b) {
      result = i;
      break;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
N = int(input())
S = []
for i in range(N):
    l, r = map(int, input().split())
    S.append((l, r))

if all(l <= 0 <= r for l, r in S):
    print(0)
    exit(0)

P = sorted(r for l, r in S)
Q = sorted(l for l, r in S)
L = R = 0
ans = 0
for i in range(N):
    if not i < N-1-i:
        break
    L += P[i]
    R += Q[N-1-i]
    ans = max(ans, abs(R - L)*2)
    if i+1 < N-1-i:
        ans = max(ans, abs(R - L - P[i+1])*2)
    if i < N-1-i-1:
        ans = max(ans, abs(R + Q[N-1-i-1] - L)*2)
print(ans)

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


int main() {
  int X;
  cin >> X;
    
  int answer = 1;
  
  for (int i = 2; i < X; i++){
    int a = i;
    bool b = false;
    while (a <= X/i) {
      a *= i;
      b = true;
    }
    if ((b) && (answer < a)) {
      answer = a;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int b, a;
		int ans = Integer.MAX_VALUE;
		int sum;
		for(int i = 1;i <= n/2; ++i){
			a = i;
			b = n-a;
			sum = 0;
			while(a > 0 || b > 0){
				sum += a%10 + b%10;
				a/=10; b/=10;
			}

			ans = Math.min(ans, sum);
		}

		System.out.print(ans);

	}

}


//end


Measured memory_bytes: 21972
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	X := make(map[string]int, n)
	for i := 0; i < n; i++ {
		var x string
		fmt.Scan(&x)
		X[x] += 1
	}

	dictList := make(DictList, 0)
	for k, v := range X {
		dict := Dict{k, v}
		dictList = append(dictList, dict)
	}
	sort.Sort(dictList)

	max := 0
	for _, v := range X {
		if max < v {
			max = v
		}
	}
	for _, dict := range dictList {
		if dict.count == max {
			fmt.Println(dict.key)
		}
	}
}

type DictList []Dict

type Dict struct {
	key   string
	count int
}

func (l DictList) Len() int {
	return len(l)
}

func (l DictList) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l DictList) Less(i, j int) bool {
	return l[i].key < l[j].key
}


Measured memory_bytes: 40704
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	long long n,a[5];
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	cout << (n - 1) / min({a[0],a[1],a[2],a[3],a[4]}) + 5 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int ,int> pairs;
int main()
{
    ll n,weight,value,a=0,b=0,re,r,blue;
  string s;
  char c;
  cin>>a>>b;

 r=b*10;
 for(int i=r;i<r+10;i++)
 {
     re=i*.08;
     if(re==a)
     {
         cout<<i<<endl;
         return 0;
     }
 }
 cout<<-1<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int h[1000000];
int main(void)
{
   int n;
    int answer,i,j,max;
    max=0;
    long long int  num=0;
answer=0;
    scanf("%d",&n);

    for(i=1; i<n; i++)
    {
        num+=i;
    }


printf("%lld",num);

   
    
    return 0;
}

Measured memory_bytes: 128
#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,x;cin >> a >> b >> x;
  if(a>x)cout << "NO";//多すぎ
  else if(a+b<x)cout << "NO";//少なすぎ
  else cout << "YES";
}

Measured memory_bytes: 256
require 'set'
loop do
    bl = false
    n = gets.to_i
    break if n == 0
    d = Array.new(n).map{Array.new(31,false)}
    n.times do |i|
        _, *dt = gets.split.map(&:to_i)
        dt.each do |dd|
            d[i][dd] = true
        end
    end
    m = Array.new(n).map{Array.new(31).map{Set.new}}
    m.each_with_index do |mm,i|
        mm[0].add(i)
    end
    1.upto(30) do |i|
        m.each do |mm|
            mm[i] = mm[i-1]
        end
        s = Set.new
        temp = Set.new
        d.each_with_index do |dd,j|
            if dd[i]
                s.add(j)
                temp = temp + m[j][i-1]
            end
        end
        s.each do |si|
            m[si][i] = temp
        end
        n.times do |k|
            if m[k][i].size == n
                puts i
                bl = true
                break
            end
        end
        break if bl
    end
    puts "-1" if !bl
end

Measured memory_bytes: 10836
#!/usr/bin/env python3
import sys
import itertools
import math


def solve(N: int, x: "List[int]", y: "List[int]"):
    seq = range(N)
    comb = math.factorial(N)
    all_distance = 0.0
    for road_map in itertools.permutations(seq):
        for n in range(N - 1):
            n1 = road_map[n]
            n2 = road_map[n+1]
            all_distance += math.sqrt(pow(x[n1] - x[n2],
                                          2) + pow(y[n1] - y[n2], 2))
    print(all_distance / comb)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)


if __name__ == '__main__':
    main()


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

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


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

using namespace std;

// 3^ 14
// 3 no 13

string ans;

void solve(int cnt, int dig, int w, string s) {

    if(w == 0) {
        ans = s;
    }

    if(cnt >= 12) {
        return;
    }

    solve(cnt + 1, dig * 3, w, s + "0");
    solve(cnt + 1, dig * 3, w - dig, s + "+");
    solve(cnt + 1, dig * 3, w + dig, s + "-");

    return;
}

int main() {

    int w;
    int enable_p;

    cin >> w;

    solve(0, 1, w, "");

    reverse(ans.begin(), ans.end());

    enable_p = 0;
    for(int i = 0; i < ans.size(); ++i) {
        if(ans[i] == '0') {
            ++enable_p;
        } else {
            break;
        }
    }

    for(int i = enable_p; i < ans.size(); ++i) {
        cout << ans[i];
    }
    cout << endl;

    //cout << ans << endl;

}

Measured memory_bytes: 3196
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string s1 = Console.ReadLine();
        string s2 = Console.ReadLine();
        if(s1 == s2){
            sb.Append("0\n");
        }
        else{
            List<int> stacki = new List<int>();
            List<int> stacko = new List<int>();
            {
                char c = s2[N-1];
                int p = N-1;
                bool b = true;
                for(int i=N-1;i>=-1;i--){
                    if(i == -1 || s2[i] != c){
                        stacko.Add(i+1);
                        p = Math.Min(p,i+1);
                        while(p >= 0 && s1[p] != c){
                            p--;
                        }
                        if(p == -1){
                            b = false;
                            break;
                        }
                        stacki.Add(p);
                        if(i != -1){
                            c = s2[i];
                        }
                    }
                }
                if(!b){
                    sb.Append("-1\n");
                    return;
                }
            }
            int max = 0;
            int d = 0;
            int spi = stacki.Count-1;
            int spo = stacko.Count-1;
            for(int i=0;i<N;i++){
                if(spi >= 0 && i == stacki[spi]){
                    spi--;
                    d++;
                }
                while(spo >= 0 && i == stacko[spo] + d - 1){
                    spo--;
                    d--;
                }
                max = Math.Max(max,d);
            }
            sb.Append(max+1+"\n");
        }
    }
}

Measured memory_bytes: 30176
//メモリ数確認したか?
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
    int m,n;
	const int MAX_N=500,MAX_M=10000;
	int p[MAX_M];
	int c[MAX_N],e[MAX_N];
	scanf("%d%d",&m,&n);
	for(int i=0;i<m;i++)scanf("%d",&p[i]);
	sort(p,p+m);
	reverse(p,p+m);
	for(int i=0;i<n;i++)scanf("%d%d",&c[i],&e[i]);

	int dp[MAX_M+1];
	for(int i=0;i<=MAX_M;i++)dp[i]=214700000;
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=m;j>=0;j--){
			dp[j]=min(dp[j],dp[max(j-c[i],0)]+e[i]);
		}
	}
	int ans=0;
	int sum=0;
	for(int i=0;i<=m;i++){
		ans=max(ans,sum-dp[i]);
		if(i<m)sum+=p[i];
	}
	printf("%d\n",ans);
    return 0;
}
//メモリ数確認したか?

Measured memory_bytes: 1288
n = int(input())
p_t = 0
p_h = 0

for i in range(n):
  t,h = str(input()).split()
  if t > h:
    p_t += 3
  elif t < h:
    p_h += 3
  else:
    p_t += 1
    p_h += 1

print (str(p_t) + " " + str(p_h))


Measured memory_bytes: 5592
# ABC065B - Trained?
n = int(input())
lst = list(map(int, [input().rstrip() for _ in range(n)]))
button = lst[0]
count = 0
for _ in range(n):
    count += 1
    if button == 2:
        break
    button = lst[button - 1]
else:
    count = -1
print(count)

Measured memory_bytes: 13356
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

struct point {
  int x, y;

  point(): x(0), y(0) {}

  point(int _x, int _y): x(_x), y(_y) {}

  void read() {
    assert(scanf("%d%d", &x, &y) == 2);
  }

  point operator + (const point &p) const {
    return point(x + p.x, y + p.y);
  }

  point operator - (const point &p) const {
    return point(x - p.x, y - p.y);
  }

  long long operator ^ (const point &p) const {
    return (long long) x * p.y - (long long) y * p.x;
  }

  long long operator * (const point &p) const {
    return (long long) x * p.x + (long long) y * p.y;
  }

  long long slen() const {
    return *this * *this;
  }

  point ort() const {
    return point(-y, x);
  }
};

bool operator < (const point &a, const point &b) {
  long long cp = (a ^ b);
  if (cp) {
    return cp > 0;
  }
  return a.slen() < b.slen();
}

ld getAngle(const point &a, const point &b) {
  return abs(atan2(a ^ b, a * b));
}

const int maxn = 105;
int n;
point ps[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    ps[i].read();
  }
  return true;
}

point ps0[maxn];
ld ans[maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    ps0[i] = ps[i];
    ans[i] = 0;
  }
  for (int i = 1; i < n; i++) {
    if (ps[i].x < ps[0].x || (ps[i].x == ps[0].x && ps[i].y < ps[0].y)) {
      swap(ps[i], ps[0]);
    }
  }
  for (int i = 1; i < n; i++) {
    ps[i] = ps[i] - ps[0];
  }
  sort(ps + 1, ps + n);
  for (int i = 1; i < n; i++) {
    ps[i] = ps[i] + ps[0];
  }
  int m = 1;
  for (int i = 1; i < n; i++) {
    while (m >= 2 && ((ps[m - 1] - ps[m - 2]) ^ (ps[i] - ps[m - 1])) <= 0) {
      m--;
    }
    ps[m] = ps[i];
    m++;
  }
  for (int i = 0; i < m; i++) {
    point a = ps[(i + m - 1) % m], b = ps[i], c = ps[(i + 1) % m];
    point v = (a - b).ort();
    point u = (b - c).ort();
    ld alpha = getAngle(v, u);
    for (int j = 0; j < n; j++) {
      if (ps0[j].x == ps[i].x && ps0[j].y == ps[i].y) {
        ans[j] = alpha / (2 * pi);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%.12f\n", (double) ans[i]);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int check(int a){
    return (a%10)*(a/10);
}
int main(){
    int m,d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1;i<=m;i++){
        for(int j = 1;j<=d;j++){
            if(check(j)==i && (j%10)>=2 && (j/10)>=2) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256