akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define vi vector<int>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
typedef long long ll;
typedef short inth;
 
const int N = 1;
const int M = N + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 17;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int k;
    scanf("%d", &k);
    while (b <= a) {
        b <<= 1;
        --k;
    }
    while (c <= b) {
        c <<= 1;
        --k;
    }
    if (k >= 0)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}

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

using namespace std;
const int MAX = 500005;
const int MAX_V = 500005;

int sqrtN;
int N, M, A[MAX], result[MAX];

struct QueryNode{
    int s, e, n;
    QueryNode(): QueryNode(0, 0, -1){}
    QueryNode(int s1, int e1, int n1): s(s1), e(e1), n(n1){}
    bool operator <(const QueryNode &O)const{
        if(s/sqrtN != O.s/sqrtN) return (s/sqrtN < O.s/sqrtN);
        return (e < O.e);
    }
};

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


    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i];
    sqrtN = sqrt(N);

    QueryNode Q[MAX];
    for(int i = 0; i < M; ++i){
        int l, r;
        cin >> l >> r;
        Q[i] = QueryNode(l-1, r, i);
    }
    sort(Q, Q+M);


    int dcnt = 0, cnt[MAX_V+1] = {0};
    int s = Q[0].s, e = Q[0].e;
    for(int i = s; i < e; i++)
        if(cnt[A[i]]++ == 0) ++dcnt;
    result[Q[0].n] = dcnt;


    for(int i = 1; i < M; ++i){
        while(Q[i].s < s) if(cnt[A[--s]]++ == 0) ++dcnt;
        while(e < Q[i].e) if(cnt[A[e++]]++ == 0) ++dcnt;
        while(Q[i].s > s) if(--cnt[A[s++]] == 0) --dcnt;
        while(e > Q[i].e) if(--cnt[A[--e]] == 0) --dcnt;
        result[Q[i].n] = dcnt;
    }

    for(int i = 0; i < M; ++i)
        cout << result[i] << '\n';

}

Measured memory_bytes: 15512
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Pair {
    int f, s;
    Pair(int f, int s) {
        this.f = f; this.s = s;
    }

    public boolean equals(Object o) {
        if(!(o instanceof Pair)) return false;
        Pair p = (Pair)o;
        return p.f==this.f && p.s==this.s;
    }
}
class PairComparator implements Comparator<Pair> {
    public int compare(Pair l, Pair r) {
        if (l.f != r.f) return l.f - r.f;
        else if(l.s != r.s)  return l.s - r.s;
        else return 0;
    }
}

public class Main {

    private static int[][] cost;
    private static int start_pos;
    private static int node_n;
    private static int[] d, prev;
    private static void dijkstra() {
        d = new int[node_n]; Arrays.fill(d, Integer.MAX_VALUE); d[start_pos] = 0;
        prev = new int[node_n];

        PriorityQueue<Pair> Q = new PriorityQueue<>(new PairComparator());
        for(int i=0; i<node_n; i++) Q.add(new Pair(d[i], i));

        while(!Q.isEmpty()) {
            Pair u = Q.poll();
            for(int v=0; v<node_n; v++) {
                if(cost[u.s][v] == Integer.MAX_VALUE) continue;
                int alt = d[u.s] + cost[u.s][v];
                if(d[v] > alt) {
                    d[v] = alt;
                    prev[v] = u.s;
                    Q.add(new Pair(d[v],v));
                }
            }
        }
    }

    public static void main(String[] args) throws IOException {

//        Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        node_n = n; start_pos = 0;

        cost = new int[n][n];
        for(int[] c:cost) Arrays.fill(c, Integer.MAX_VALUE);
        for(int i=0; i<n; i++) {
            String[] in = br.readLine().split(" ", 0);
            int u = Integer.parseInt(in[0]), k = Integer.parseInt(in[1]);
            for(int j=0; j<k; j++) {
                int v = Integer.parseInt(in[2+2*j]), c = Integer.parseInt(in[2+2*j+1]);
                cost[u][v] = c;
            }
        }

        dijkstra();

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n; i++) {
            sb.append(i).append(" ").append(d[i]).append("\n");
        }
        bw.write(sb.toString());
        bw.flush();
    }
}


Measured memory_bytes: 552624
#include<stdio.h>
int main(){
  int n,d[100],num[101]={},i,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    num[d[i]]=1;
  }
  for(i=1;i<=100;i++){
    if(num[i])  cnt++;
  }
  printf("%d\n",cnt);
}


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

int main(void)
{
    int n;
    int a[3001];
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += (a[i]-1);
    }
    cout << sum;
    return 0;
}

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

int main() {

    int n, d, x;
    scanf("%d %d", &n, &d);

    int cnt = 0;
    int arr[n][d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            scanf("%d", &x);
            arr[i][j] = x;
        }
    }

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            int mysum = 0;
            for (int k = 0; k < d; k++) {
                //printf("%d %d ", arr[i][k], arr[j][k]);
                mysum += pow(arr[i][k] - arr[j][k], 2);
            }
            //printf("%d,%f %d", mysum, sqrt(mysum), (int) sqrt(mysum));
            //printf("\n");

            if (sqrt(mysum) == (int) sqrt(mysum)) {
                cnt++;
            }


        }
    }


    printf("%d", cnt);

    return 0;
}


Measured memory_bytes: 128
fun c78(args: Array<String>) {
    val (n, m) = args[0].split(" ").map { it.toInt() }
    val base = 1900 * m + 100 * (n - m)
    println(base * 1 shl m)
}

fun main(args: Array<String>) {
    c78(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 38212
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

//億マス計算類題だがかなり難。解説みても時間がかかった。

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(ALL(A));
  ll ok = INF;
  ll ng = -INF;
  while(ok - ng > 1){
    ll mid = (ok + ng) / 2LL;
  
    auto isok = [&]{ //mid以下の個数がK個以下ならtrue
      ll counter = 0LL;
      for(int i = 0; i < N; i++){
        ll AA = A.at(i);
        if(AA == 0){
          if(mid >= 0) counter += N;
        }
        else if(AA > 0){
          ll okk = -1;
          ll ngg = N;
          while(ngg - okk > 1){
            ll midd = (okk + ngg) / 2LL;
            if(A.at(i) * A.at(midd) <= mid) okk = midd;
            else ngg = midd;
          }
          counter += okk + 1;
        }
        else{
          ll okk = N;
          ll ngg = -1;
          while(okk - ngg > 1){
            ll midd = (okk + ngg) / 2LL;
            if(A.at(i) * A.at(midd) <= mid) okk = midd;
            else ngg = midd;
          }
          counter += N - okk;
        }
        if(A.at(i) * A.at(i) <= mid) counter--;
      }
      counter /= 2;
      return counter >= K;
    };
  
    if(isok()) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	int n, m, v, p; std::cin >> n >> m >> v >> p;
	std::vector<long long int> initial(n); for (auto& a : initial) std::cin >> a;
	std::sort(initial.begin(), initial.end());
	initial.erase(std::prev(initial.end(), p - 1), initial.end());
	if (p >= v) {
		int count = p;
		for (auto i = 0; i < initial.size() - 1; ++i) {
			if (initial[i] + m >= initial.back()) ++count;
		}
		std::cout << count << std::endl;
		return 0;
	}
	else {
		long long int vote = v - (p - 1);
		std::vector<long long int> sum(initial);
		for (auto i = 1; i < sum.size(); ++i) sum[i] += sum[i - 1];
		int count = p;
		for (auto i = 0; i < initial.size() - 1; ++i) if (initial[i] + m >= initial.back()) {
			long long int rest_vote = (vote - i - 1) * m;
			if (rest_vote <= 0) ++count;
			else if ((initial[i] + m) * (initial.size() - i - 1LL) - (sum.back() - sum[i]) >= rest_vote) ++count;
		}
		std::cout << count << std::endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,W;
    cin >> n >> W;
    vector<int> v(n),w(n);
    rep(i,n){
        cin >> v[i] >> w[i];
    }
    int dp[10005] = {};
    rep(i,n){
        for (int j = W; j>=0; j--)
        {
            if(j+w[i] <= W){
                dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
            }
        }
    }
    cout << dp[W] << endl;
    
}


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

int main(){
  string S;
  string X;
  int K, L;
  cin >> K >> S;
  L = S.size();
  if(L <= K){
    cout << S << endl;
  }
  else if(L > K){
  int a = K;
  cout << S.erase(a) << "..." << endl;
  }
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 998244353;

    constexpr unsigned long mx = 1000001;
    vector<vector<unsigned long>> fact(mx, {1});
    for(unsigned long i = 2; i < mx; ++i)for(unsigned long j = i; j < mx; j += i)fact[j].push_back(i);

    vector<unsigned long> coef(mx, 1);
    for(unsigned long i = 2; i < mx; ++i)coef[i] = coef[MOD % i] * (MOD - MOD / i) % MOD;

    vector<unsigned long> sieve(mx, 1);
    for(unsigned long i = 2; i < mx; ++i)if(sieve[i])for(unsigned long j = i; j < mx; j += i){
        sieve[j] = 0;
        (coef[j] *= MOD + 1 - i) %= MOD;
    }

    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);

    unsigned long ans{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        for(const auto& j : fact[i]){
            (ans += hoge[j] * i) %= MOD;
            (hoge[j] += coef[j] * i) %= MOD;
        }
    }

    ans %= MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 205824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    char a, b; cin >> a >> b;
    char ans;
    if (a == 'H' && b == 'H') ans = 'H';
    if (a == 'H' && b == 'D') ans = 'D';
    if (a == 'D' && b == 'H') ans = 'D';
    if (a == 'D' && b == 'D') ans = 'H';
    cout << ans << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const ll inf = 0x3f3f3f3f3f3f3f3f;
ll dist1[305][305], dist2[305][305];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, m, l; 
	read(n, m, l);

	rep(i, 1, n + 1) rep(j, 1, n + 1) dist1[i][j] = dist2[i][j] = inf;
	rep(i, 1, n + 1) dist1[i][i] = dist2[i][i] = 0;

	rep(i, 0, m) {
		int u, v, w; read(u, v, w);
		dist1[u][v] = dist1[v][u] = w;
	}

	rep(i, 1, n + 1) rep(j, 1, n + 1) rep(k, 1, n + 1)
		chmin(dist1[j][k], dist1[j][i] + dist1[i][k]);

	rep(i, 1, n + 1) rep(j, 1, n + 1) if (i != j && dist1[i][j] <= l) dist2[i][j] = 1;

	rep(i, 1, n + 1) rep(j, 1, n + 1) rep(k, 1, n + 1)
		chmin(dist2[j][k], dist2[j][i] + dist2[i][k]);

	int q; read(q);
	rep(i, 0, q) {
		int u, v; read(u, v);
		write(dist2[u][v] != inf ? dist2[u][v] - 1 : -1);
	}
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}
/**
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    return 0;
}
*/


Measured memory_bytes: 3640
import Control.Monad.State
import Control.Arrow
import Data.List

getInts = map read . words <$> getLine :: IO [Int]

main = do
    time <- readLn
    inputs <- map read <$> replicateM time getLine :: IO [Int]
    let sorted = sort inputs
    putStrLn . show $ foldr uniq [] >>> length $ sorted
    where 
        uniq x [] = [x]
        uniq x arr@(a:_) = if x == a then arr else x:arr


		

Measured memory_bytes: 1020
H,W=map(int,input().split())
L=[]
for i in range(H):
    tmp=list(input())
    L.append(tmp)


diffX=[1,1,1,0,0,-1,-1,-1]
diffY=[0,-1,1,1,-1,-1,0,1]
tmpL=[[0]*W]*H

for i in range(H):
    tmp=""
    for j in range(W):
        cnt=0
        if L[i][j]=='.':
            for p in range(0,8):
                if (i+diffY[p]<0 or i+diffY[p]>H-1):
                    cnt+=0
                elif (j+diffX[p]<0 or j+diffX[p]>W-1):
                    cnt+=0
                elif L[int(i+diffY[p])][int(j+diffX[p])]=='#':
                    cnt+=1
            tmpL[i][j]=cnt
        else:
            tmpL[i][j]='#'

        tmp=tmp+str(tmpL[i][j])
    print(tmp)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <utility>

using namespace std;

int main(){
    int n;
    cin >> n;
    map<pair<string,int>,int>m;

    for(int i = 0;i < n;i++){
        string s;
        int n;
        cin >> s >> n;
        m[make_pair(s,n*-1)] = i+1;
    }

    for(auto &i:m){
        cout << i.second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, q;
	while (cin >> n >> q) {
		if (n == 0 && q == 0)break;
		int wan=q;
		int a[50] = {};
		int j=0;
		while (true) {
			if (wan == 0) {
				wan = a[j]; a[j] = 0;
			}
			else {
				wan--; a[j]++;
			}
			if (a[j] == q) {
				cout << j << endl; break;
			}
			j=(j+1)%n;
		}
	}
	return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

    map<int, int> mp;

    for (int i = 0; i < n; ++i) {
        int a; cin >> a;

        mp[a]++;
    }

    int ans = 0;

    for (auto x : mp) {
        if (x.second % 2 != 0) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		int ans = 0, i = 0;
		while (i < n) {
			int j = i + 1;
			while (j < n && s[j] == s[i])j++;
			ans++;
			i = j;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;



int main()
{
    int n, m, t;
    cin >> n;
  	int ans = 0;
    // int lb, ub;
    int a[n];
    for (int i = 0; i< n; i++){
        cin >> a[i];
    }
    cin >> m;
    for (int i = 0; i< m; i++){
        cin >> t;
        auto ub = *upper_bound(a,a+n,t);
        auto lb = *lower_bound(a,a+n,t);
        if (ub != lb ) ans++;

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

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i< n; i++)


Measured memory_bytes: 3476
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
    ll ts=0;
    ll ss=0;
    rep(i,str.length()){
        if(str[i]=='S'){
            ss++;
        }else{
            if(ss) {
                ss--;
                sum+=2;
            }
        }
    }
    cout<<str.length()-sum<<endl;

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include<algorithm>
#include <string>
using namespace std;
int main(void){
   string str, moji, m;
   int q = 0;
   cin >> str;
   cin >> q;
   for(int i = 0; i < q; i++){
       int a = 0, b = 0;    
       cin >> moji >> a >> b;  
       if(moji == "print"){          
           cout << str.substr(a, b-a+1) <<endl;
       }  
       else if(moji == "reverse"){
               string str2 = str.substr(a, b-a+1);
               reverse(str2.begin(), str2.end());
               str = str.replace(a, b-a+1, str2);
       }
       else if(moji == "replace"){
           cin >> m;
           str = str.replace(a, b-a+1, m);
       }    
   }
   return 0;    }


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }

    }
    return 0;
}


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

int main() {

  long long INF = 1LL<<60;

  int N, K;
  cin >> N >> K;

  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  long long answer = INF;

  for (int i = 0; i < N - K + 1; i++) {
    // 右端
    long long right = x[i];
    // 左端
    long long left = x[i + K - 1];
    // 右から左
    answer = min(answer, abs(0 - right) + abs(right - left));
    // 左から右
    answer = min(answer, abs(0 - left) + abs(left - right));
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 768
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;cin >> K;
    cout << A[K-1] << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int main()
{
    int n,k,cnd=1;
    cin>>n>>k;
    while(n>=k){
        n/=k;
        cnd++;
    }
    cout<<cnd;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<math.h>
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define ll long long
using namespace std;
int l;
struct nod
{
    int to,val;
};
vector<nod>g[25];
int main()
{
    int n=0,m=-1;
    scanf("%d",&l);
    int x=l;
    while(x)
    {
        n++;
        if(x&1)m++;
        x>>=1;
    }
    m+=2*(n-1);
    for(int i=1;i<n;i++)
    {
        g[i].push_back((nod){i+1,0});
        g[i].push_back((nod){i+1,1<<(n-i-1)});
    }
    int sum=(1<<(n-1))-1;
    for(int i=n-2;i>=0;i--)
    {
        if((1<<i)&l)
        {
            g[1].push_back((nod){n-i,sum+1});
            sum+=(1<<i);
        }
    }
    printf("%d %d\n",n,m);
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<g[i].size();j++)
        {
            printf("%d %d %d\n",i,g[i][j].to,g[i][j].val);
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int minw,maxw;
pair<int,int> z[100000];

bool ok(int d)
{
	int smin = z[0].second;
	int smax = z[0].second;
	int lmin = z[n - 1].second;
	int lmax = z[n - 1].second;
	for(int i = n - 2; i >= 1; i--)
	{
		if(z[i].first <= minw + d)
		{
			break;
		}
		if(z[i].first >= maxw - d)
		{
			if(z[i].second < lmin)
			{
				lmin = z[i].second;
			}
			if(z[i].second > lmax)
			{
				lmax = z[i].second;
			}
			if(lmax - lmin > d)
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	int beg = n - 1;
	for(int i = 1; i < n - 1; i++)
	{
		if(z[i].first < maxw - d)
		{
			if(z[i].second < smin)
			{
				smin = z[i].second;
			}
			if(z[i].second > smax)
			{
				smax = z[i].second;
			}
			if(smax - smin > d)
			{
				return false;
			}
		}
		else
		{
			beg = i;
			break;
		}
	}
	int mmin = 22222;
	int mmax = -22222;
	int end = n - 1;
	for(int i = beg; i < n - 1; i++)
	{
		if(z[i].first > minw + d)
		{
			end = i;
			break;
		}
		if(z[i].second < mmin)
		{
			mmin = z[i].second;
		}
		if(z[i].second > mmax)
		{
			mmax = z[i].second;
		}
	}
	if(beg == end)
	{
		return true;
	}
	bool fir = true;
	if((abs(smin - mmin) > d || abs(smax - mmin) > d) || (abs(lmin - mmax) > d || abs(lmax - mmax) > d))
	{
		fir = false;
	}
	for(int i = beg; i < end; i++)
	{
		bool f1 = false;
		bool f2 = false;
		bool fs = false;
		bool fl = false;
		if(abs(z[i].second - mmin) <= d)
		{
			f1 = true;
		}
		if(abs(z[i].second - mmax) <= d)
		{
			f2 = true;
		}
		if(abs(z[i].second - smin) <= d && abs(z[i].second - smax) <= d)
		{
			fs = true;
		}
		if(abs(z[i].second - lmin) <= d && abs(z[i].second - lmax) <= d)
		{
			fl = true;
		}
		if(f1 && f2)
		{
			if(!fs && !fl)
			{
				return false;
			}
		}
		else if(!f1 && !f2)
		{
			return false;
		}
		else if(f1)
		{
			if(fir)
			{
				 if(!fs)
				 {
					 return false;
				 }
			}
			else
			{
				if(!fl)
				{
					return false;
				}
			}
		}
		else
		{
			if(fir)
			{
				if(!fl)
				{
					return false;
				}
			}
			else
			{
				if(!fs)
				{
					return false;
				}
			}
		}
	}
	return true;
}

int k1[100000];
int k2[100000];

int main()
{
	scanf("%d",&n);
	int max1 = -22222;
	int min1 = 22222;
	int max2 = -22222;
	int min2 = 22222;
	for(int i = 0; i < n; i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		int w1 = x + y;
		int w2 = x - y;
		if(w1 > max1)
		{
			max1 = w1;
		}
		if(w1 < min1)
		{
			min1 = w1;
		}
		if(w2 > max2)
		{
			max2 = w2;
		}
		if(w2 < min2)
		{
			min2 = w2;
		}
		k1[i] = w1;
		k2[i] = w2;
	}
	if(max1 - min1 > max2 - min2)
	{
		minw = min1;
		maxw = max1;
		for(int i = 0; i < n; i++)
		{
			z[i] = make_pair(k1[i],k2[i]);
		}
	}
	else
	{
		minw = min2;
		maxw = max2;
		for(int i = 0; i < n; i++)
		{
			z[i] = make_pair(k2[i],k1[i]);
		}
	}
	sort(z,z + n);
	int now = (1 << 20);
	int han = (1 << 19);
	for(int i = 0; i < 20; i++)
	{
		if(ok(now - han))
		{
			now -= han;
		}
		han /= 2;
	}
	printf("%d\n",now);
	return 0;
}

Measured memory_bytes: 2752
T=gets.to_i
T.times do
  h,w=gets.split.map &:to_i
  if h==w
    puts "1 0"
  elsif h%2==0||w%2==0
    puts "1 1"
  else
    g=h.gcd(w)
    h/=g
    w/=g
    puts "#{h*w/2+1} #{h*w/2}"
  end
end

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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


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

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 998244353;

vector <char> chars = {'R', 'G', 'B'};

int toInt(char c) { return find(chars.begin(), chars.end(), c) - chars.begin(); }

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    string s;
    cin >> s;

    ll ans = 1;

    VI cnt(3, 0);

    auto getKth = [&](int k) {
        VI sorted = cnt;
        sort(sorted.begin(), sorted.end(), greater <int> ());

        return sorted[k];
    };

    for (char c : s) {
        int x = toInt(c);

        int mulBy;
        if (cnt[x] == getKth(0)) {
            mulBy = 1;
        } else if (cnt[x] == getKth(1)) {
            mulBy = getKth(0) - getKth(1);
        } else if (cnt[x] == getKth(2)) {
            mulBy = getKth(1) - getKth(2);
        } else {
            assert(false);
        }

        ans = (ans * mulBy) % MOD;

        cnt[x]++;
    }

    FOR(i,1,n) {
        ans = (ans * i) % MOD;
    }

    cout << ans;

    return 0;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

ll NCR(ll n, ll r)
{
    if (r == 0) return 1;

    if (r > n/2) return NCR(n, n-r); // save some computation

    ll res = 1; 

    for(int k = 1; k <= r; ++k)
    {
        res *= n-k+1;
        res /= k;
    }

    return res;
}

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

	ll N, P; cin >> N >> P;
	ll c0 = 0;
	REP(i, N) {
		ll a; cin >> a;
		if (a % 2 == 0) c0++;
	}
	ll ans = 0;
	REP(i, c0 + 1) ans += NCR(c0, i);
	ll num;
	if (P == 0) num = 0;
	else num = 1;
	ll ans1 = 0;
	ll c1 = N - c0;
	while (num <= c1) {
		ans1 += NCR(c1, num);
		num += 2;
	}
	cout << ans * ans1 << endl;

	return 0;
}


Measured memory_bytes: 256
#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>;
const int MAX = 100;
const int INF = 1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	int N, M; cin >> N >> M;
	priority_queue<int> PQ;
	int sum = 0;
	rep(i,N) {
		int temp;
		cin >> temp;
		PQ.push(temp);
		sum += temp;
	}
	rep(i,M) {
		int temp = PQ.top(); PQ.pop();
		double tmp2 = (double)sum / (double)(4*M);
		if ( (double)temp < tmp2 ) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int Atoi(char c){
    return c-'a';
}

int main()
{ 
    string s,t;
    cin>>s>>t;
    //文字の存在判定
    int m[26];
    for(int i=0;i<26;i++){
        m[i]=-1;
    }
    for(int i=0;i<s.size();i++){
        if(m[Atoi(s[i])]==-1){m[Atoi(s[i])]=i;}
    }
    int flag=1;
    for(int i=0;i<t.size();i++){
        if(m[Atoi(t[i])]==-1){flag=0;}
    }
    if(flag==0){cout<<-1<<endl;return 0;}

    //文字列の情報変形
    int n=s.size();
    s=s+s;
    LL sn[n][26];
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            sn[i][j]=0;
        }
    }
    for(int i=0;i<26;i++){
        char x='a'+i;
        int cnt=0;
        for(int j=2*n-1;j>=0;j--){
            if(j<n){sn[j][i]=cnt;}
            if(x==s[j]){cnt=1;}
            else{cnt++;}
        }
    }
    LL ans=0;
    LL cnt=n-1;
    LL cntn=0;
    for(int i=0;i<t.size();i++){
        cntn=cnt+sn[cnt][Atoi(t[i])];
        ans=ans+sn[cnt][Atoi(t[i])];
        cnt=cntn%n;
        //cout<<cnt<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 21120
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX_N = 16;
typedef long long ll;

int n,a[MAX_N][MAX_N];
ll score[1<<MAX_N],dp[1<<MAX_N];

int main()
{
	scanf("%d",&n);
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			scanf("%d",&a[i][j]);
	for (int m=(1<<n)-1; m>0; m--)
		for (int i=0; i<n; i++)
			if (m&(1<<i))
				for (int j=i+1; j<n; j++)
					if (m&(1<<j))
						score[m]+=a[i][j];
	for (int m=1; m<(1<<n); m++)
		for (int s=m; s; s=(s-1)&m)
			dp[m]=max(dp[m],dp[m^s]+score[s]);
	printf("%lld\n",dp[(1<<n)-1]);
	return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  cout << (s < t ? "Yes" : "No") << endl;
  return 0;
}


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

struct Node{
    int x, y;
};

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

int main(){
    int w, h;
    while(cin >> w >> h, w != 0){
        for(int i=0;i<=h+1;++i){
            for(int j=0;j<=w+1;++j){
                if(i == 0 || j == 0 || i == h+1 || j == w+1)
                    room[i][j] = '#';
                else
                    room[i][j] = '.';
            }
        }
        int sx = 0, sy = 0;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                scanf(" %c",&room[i+1][j+1]);
                if(room[i+1][j+1] == '@'){
                    sx = j+1;
                    sy = i+1;
                }
            }
        }
        queue<Node> que;
        que.push((Node){sx, sy});
        while(!que.empty()){
            Node curr = que.front(); que.pop();
            for(int i=0;i<4;++i){
                int nx = curr.x + dx[i], ny = curr.y + dy[i];
                if(room[ny][nx] == '.'){
                    room[ny][nx] = '@';
                    que.push((Node){nx, ny});
                }
            }
        }
        int ans = 0;
        for(int i=1;i<=h;++i)
            for(int j=1;j<=w;++j)
                if(room[i][j] == '@')ans++;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
const int inf=1000000000;
int n,m,t,ans,f[200005],P[200005],Q[200005],B[200005];
struct O{int l,r,P,Q;}b[400005];
struct G{int l,r;}W[200005];
bool cmp(G a,G b){return a.l<b.l;}
void build(int u,int p,int q){
	if (p==q) {b[u].P=f[p]-P[p]; b[u].Q=f[p]-Q[p]; return;}
	b[u].l=++t; build(t,p,p+q>>1);
	b[u].r=++t; build(t,(p+q>>1)+1,q);
	b[u].P=min(b[b[u].l].P,b[b[u].r].P);
	b[u].Q=min(b[b[u].l].Q,b[b[u].r].Q);
}
int MP(int u,int p,int q,int l,int r){
	if (l<=p&&q<=r) return b[u].P;
	return min(l<=p+q>>1?MP(b[u].l,p,p+q>>1,l,r):inf,
		r>p+q>>1?MP(b[u].r,(p+q>>1)+1,q,l,r):inf);
}
int MQ(int u,int p,int q,int l,int r){
	if (l<=p&&q<=r) return b[u].Q;
	return min(l<=p+q>>1?MQ(b[u].l,p,p+q>>1,l,r):inf,
		r>p+q>>1?MQ(b[u].r,(p+q>>1)+1,q,l,r):inf);
}
void UP(int u,int p,int q,int x){
	if (p==q) {b[u].P=f[p]-P[p]; b[u].Q=f[p]-Q[p]; return;}
	if (x<=p+q>>1) UP(b[u].l,p,p+q>>1,x);
		else UP(b[u].r,(p+q>>1)+1,q,x);
	b[u].P=min(b[b[u].l].P,b[b[u].r].P);
	b[u].Q=min(b[b[u].l].Q,b[b[u].r].Q);	
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&t),B[i]=t,
		P[i]=P[i-1]+t,Q[i]=Q[i-1]+1-t;
	scanf("%d",&m);
	for (int i=1;i<=m;++i) scanf("%d%d",&W[i].l,&W[i].r);
	sort(W+1,W+m+1,cmp);
	for (int i=1;i<=n;++i) f[i]=inf;
	build(t=1,0,n);
	for (int i=1;i<=m;++i){
		int l=W[i].l,r=W[i].r;
		if (l<r) f[r]=min(f[r],MQ(1,0,n,l,r-1)+Q[r]);
		f[r]=min(f[r],MP(1,0,n,0,l-1)+P[l-1]+Q[r]-Q[l-1]);
		UP(1,0,n,r);
	}
	ans=n+100;
	for (int i=0;i<=n;++i) ans=min(ans,f[i]+P[n]-P[i]);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b)
    {
        if(c != b)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
    else
    {
        if(c == b || c == a)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
    return 0;
}



Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        mut k: usize,
        a: [u64; n],
    }

    k -= 1;
    for i in (k + 1)..n {
        if a[i] > a[i - k - 1] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 5640
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int N, A;
    cin >> N >> A;
    if (N<=A){
        cout << "Yes" << endl;
    }
    else if (N%500<=A){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * ( 10 - n ) << endl;
	}

	return 0;
}

Measured memory_bytes: 3536
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdio>

void kock(int n,std::complex<double> p1,std::complex<double> p2){
	if(!n){
		printf("%.8f %.8f\n",p1.real(),p1.imag());
		return ;
	}
	std::complex<double> s,t,u;
	s.real((2*p1.real()+p2.real())/3);
	s.imag((2*p1.imag()+p2.imag())/3);
	t.real((p1.real()+2*p2.real())/3);
	t.imag((p1.imag()+2*p2.imag())/3);
	u.real(cos(M_PI/3)*(t.real()-s.real())-sin(M_PI/3)*(t.imag()-s.imag())+s.real());
	u.imag(sin(M_PI/3)*(t.real()-s.real())+cos(M_PI/3)*(t.imag()-s.imag())+s.imag());
	kock(n-1,p1,s);
	kock(n-1,s,u);
	kock(n-1,u,t);
	kock(n-1,t,p2);

}

int main(void){
	int n;
	const std::complex<double> LEFT(0,0);
	const std::complex<double> RIGHT(100,0);
	std::cin>>n;
	kock(n,LEFT,RIGHT);
	printf("%.8f %.8f\n",RIGHT.real(),RIGHT.imag());
	return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int h,w;
char a[10][10];
bool ans=true;
signed main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            if(a[i][j]=='.')continue;
            if(i==0&&j==0){
                if(a[i+1][j]==a[i][j+1])ans=false;
            }
            else if(i==0&&j==w-1){
                if(a[i+1][j]=='.'||a[i][j-1]=='.')ans=false;
            }
            else if(i==h-1&&j==0){
                if(a[i-1][j]=='.'||a[i][j+1]=='.')ans=false;
            }
            else if(i==h-1&&j==w-1){
                if(a[i-1][j]==a[i][j-1])ans=false;
            }
            else if(i==0){
                if(a[i][j-1]=='.'||a[i][j+1]==a[i+1][j])ans=false;
            }
            else if(i==h-1){
                if(a[i-1][j]==a[i][j-1]||a[i][j+1]=='.')ans=false;
            }
            else if(j==0){
                if(a[i-1][j]=='.'||a[i][j+1]==a[i+1][j])ans=false;
            }
            else if(j==w-1){
                if(a[i][j-1]==a[i-1][j]||a[i+1][j]=='.')ans=false;
            }
            else{
                if(a[i+1][j]==a[i][j+1]||a[i-1][j]==a[i][j-1])ans=false;
            }
        }
    }
    if(ans)puts("Possible");
    else puts("Impossible");
    return 0;
}


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

int main() {
  char i=0, c, buf[8];
  bool f = true;
  while (cin.get(c)) {
    if (c==' ' || c==',' || c=='.') {
      if (i>=3 && i<=6) {
        buf[i] = '\0';
        if (!f) cout << ' ';
        cout << buf;
        f = false;
      }
      i=0;
    }
    else {
      if (i<6) buf[i++] = c;
      else i++;
    }
  }
  if (i>=3 && i<=6) {
    buf[i] = '\0';
    if (!f) cout << ' ';
    cout << buf;
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 1088
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[45][36][131][36][2];
lint out=0,mo=1000000007;
int main()
{
	int n,x,y,z;
	memset(dp,0,sizeof(dp));dp[0][1][0][0][0]=1;
	cin>>n>>x>>y>>z;
	rep(i,n) rep(j,(1<<x)) rep(k,(1<<y)) rep(l,(1<<z)) rep(m,2){
		if(dp[i][j][k][l][m]<1) continue;
		REP(o,1,11){
			int nj=1,nk=0,nl=0,nm=m;
			if(o<=z && (l&(1<<(z-o)))) nm=max(nm,1);
			if(o<=y && (k&(1<<(y-o)))) nl=1;
			if(o<=x && (j&(1<<(x-o)))) nk=1;
			rep(p,x){
				if((j&(1<<p)) && p+o<x) nj+=(1<<(p+o));
			}
			rep(p,y){
				if((k&(1<<p)) && p+o<y) nk+=(1<<(p+o));
			}
			rep(p,z){
				if((l&(1<<p)) && p+o<z) nl+=(1<<(p+o));
			}
			dp[i+1][nj][nk][nl][nm]+=dp[i][j][k][l][m];
			if(dp[i+1][nj][nk][nl][nm]>=mo) dp[i+1][nj][nk][nl][nm]-=mo;
		}
	}
	rep(i,(1<<x)) rep(j,(1<<y)) rep(k,(1<<z)){
		out+=dp[n][i][j][k][1];out%=mo;
	}
	cout<<out%mo<<endl;
}


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

int main() {
  int a, b, c, d;
  int inputNumber;
  cin >> inputNumber;

  d = inputNumber % 10;
  inputNumber /= 10;
  c = inputNumber % 10;
  inputNumber /= 10;
  b = inputNumber % 10;
  inputNumber /= 10;
  a = inputNumber;

  if (b != c || (a != b && c != d)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

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

int main()
{
  int b,a,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d)
  {
    cout << "Left" << endl;
  }
  else if(a+b<c+d)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
  }
}
  

Measured memory_bytes: 256
n = int(input())
s = input()

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    A = [A[i] if A[i] <= i else 0 for i in range(N)]
    return max(A)

ans = 0
for i in range(n):
    ans = max(ans, z_algo(s[i:]))
print(ans)

Measured memory_bytes: 54492
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)
    g = [set() for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

    dist = [-1] * (N+1)
    color = [-1]*(N+1)

    dist[1] = 0
    color[1] = 0

    def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

    dfs(1, 0)

    print(*color[1:], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 110612
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef complex<double> qua;
int main()
{
    int t;
    double x1,x2,x3,x4,y1,y2,y3,y4;
    for(scanf("%d",&t);t;--t)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        qua ans=qua(x2-x1,y2-y1)*qua(x4-x3,y3-y4);
        if(ans.imag()==0) printf("2\n");
        else if(ans.real()==0) printf("1\n");
        else printf("0\n");
    }
    return 0;
}



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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int main() {
    int n;

    scanf("%d", &n);

    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            if(i*j == n) {
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");

    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int32_t main() {

    int n, m; cin >> n >> m;
    vector<int> w(n+1), v(n+1);
    for(int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
    }

    int maxtotalval = 100000;
    vector<vector<int>> dp(n+1, vector<int>(maxtotalval+1, 1000000007));
    dp[0][0] = 0;
    
    for(int i = 1; i <= n; ++i) {
        int wi = w[i], vi = v[i];
        for(int j = 0; j < vi; ++j) {
            dp[i][j] = dp[i-1][j];
        }
        for(int j = vi; j <= maxtotalval; ++j) {
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-vi] + wi);
        }
    }

    int ans = -1;
    for(int i = maxtotalval; i >= 0; --i) {
        if(dp[n][i] > 0 && dp[n][i] <= m) {
            ans = i;
            break;
        }
    }

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


Measured memory_bytes: 80256
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[3];
        for(int i = 0 ; i < 3 ; i++){
            arr[i] = sc.nextInt();
        }
        for(int i = 0 ; i < 3 ; i++){
            for(int j = 0 ; j < 2 - i ; j++){
                if(arr[j+1] < arr[j]){
                    int temp = arr[j+1];
                    arr[j+1] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        
        System.out.print(arr[0]+" "+arr[1]+" "+arr[2]+"\n");
            
    }
}


Measured memory_bytes: 26272