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

class UnionFind {
public:
    vector<int> par;  // 各ノードの親
    vector<int> rank;  // 各ノードの深さ
    int sz;  // 独立した集合の個数

    // コンストラクタ
    UnionFind(int n) {
        for (int i = 0; i < n; ++i) {
            par.push_back(i);
            rank.push_back(0);
        }
        sz = n;
    }

    // 木の根を求める
    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        // 深さが小さいものから大きい方の根へ辺を張る
        if (rank[x] < rank[y]) par[x] = y;
        else if (rank[x] > rank[y]) par[y] = x;
        else {
            par[y] = x;
            ++rank[x];
        }
        --sz;
    }

    // x と y が同じ木に属するかの判定
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    // 独立した集合の個数
    int size() {
        return sz;
    }
};

class edge {
public:
    int from, to;
    edge(int f, int t) {
        from = f;  to = t;
    }
};

int main() {
    int N, M;  cin >> N >> M;
    vector<edge> G;
    for (int i = 0; i < M; ++i) {
        int a, b;  cin >> a >> b;
        G.push_back(edge(a - 1, b - 1));
    }

    // 各辺に対して取り除く場合を考える
    int ans = 0;
    for (int i = 0; i < M; ++i) {
        UnionFind uf(N);
        for (int j = 0; j < M; ++j) {
            if (j != i) {
                edge e = G[j];
                uf.unite(e.from, e.to);
            }
        }
        bool connected = true;
        /*
        for (int j = 0; j < N - 1; ++j) {
            if (!is_same(i, i + 1)) {
                connected = false;
                cout << i << " " << j << " " << j + 1 << endl;
            }
        }
        */
        connected = uf.size() == 1;
        if (!connected) ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys


TEST_INPUT = [
    """
    5
    6 7 9 10 31
    """,
    """
    3
    28 27 24
    """
]
ANSWER = [
    "APPROVED",
    "DENIED"
]


class InputHandler:

    def __init__(self, text_lines="", is_test=False):
        self.data = list(text_lines.split("\n"))
        self.index = 0
        self.is_test = is_test

    def input(self):
        if self.is_test:
            self.index += 1
            return self.data[self.index].strip()
        else:
            return sys.stdin.readline().rstrip()


def solve(n, a_list):
    for a in a_list:
        if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
            return "DENIED"
    return "APPROVED"


def input_and_solve(ih):
    n = int(ih.input())
    a_list = list(map(int, ih.input().split()))
    res = solve(n, a_list)
    return res


def main():
    ih = InputHandler()
    res = input_and_solve(ih)
    print(res)


def test():
    for test_input, ans in zip(TEST_INPUT, ANSWER):
        ih = InputHandler(test_input, True)
        res = input_and_solve(ih)
        assert str(res) == str(ans)


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3064
class Dice:
    def __init__(self, eye1, eye2, eye3, eye4, eye5, eye6):
        self.eye1 = eye1
        self.eye2 = eye2
        self.eye3 = eye3
        self.eye4 = eye4
        self.eye5 = eye5
        self.eye6 = eye6
    
    def N(self):
        self.eye1, self.eye2, self.eye6, self.eye5 = self.eye2, self.eye6, self.eye5, self.eye1
    def S(self):
        self.eye2, self.eye6, self.eye5, self.eye1 = self.eye1, self.eye2, self.eye6, self.eye5
    def E(self):
        self.eye1, self.eye3, self.eye6, self.eye4 = self.eye4, self.eye1, self.eye3, self.eye6
    def W(self):
        self.eye4, self.eye1, self.eye3, self.eye6 = self.eye1, self.eye3, self.eye6, self.eye4
    
    def print_top(self):
        print(self.eye1)


eye1, eye2, eye3, eye4, eye5, eye6 = map(int, input().split())
commands = input()
dice1 = Dice(eye1, eye2, eye3, eye4, eye5, eye6)
for command in commands:
    if command == 'N':
        dice1.N()
    elif command == 'S':
        dice1.S()
    elif command == 'E':
        dice1.E()
    else:
        dice1.W()

dice1.print_top()


Measured memory_bytes: 5608
var n;
var x = {};

function main(){
	n = scan();
	rep(n, function(i){
		var s = scan('string');
		var p = scan();
		if(x.hasOwnProperty(s)){
			x[s] += p;
		}
		else{
			x[s] = p;
		}
	});
	var y = [];
	for(var i in x){
		if(x.hasOwnProperty(i)){
			y.push([i, x[i]]);
		}
	}
	y.sort(function(a, b){
		if(a[0].length != b[0].length){
			return a[0].length - b[0].length;
		}
		if(a[0] > b[0]){
			return 1;
		}
		else if(a[0] < b[0]){
			return -1;
		}
		else{
			return 0;
		}
	});
	rep(y.length, function(i){
		print(y[i].join(' '));
	});
}

function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/);
	main();
});

Measured memory_bytes: 18548
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	a := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&a[i])
	}

	for i := -1; i <= h; i++ {
		for j := -1; j <= w; j++ {
			if i == -1 || j == -1 || i == h || j == w {
				fmt.Print("#")
			} else {
				fmt.Print(string(a[i][j]))
			}
		}
		fmt.Println()
	}
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int d[100001],l=-1,r=-1;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='L' && s[i-1]=='R')l=i;
		if(i>r)r=-1;
		if(s[i]=='L')d[l-((i-l)%2)]++;
		if(s[i]=='R'){
			if(r==-1){
				int j=i;
				do{if(s[j]=='R' && s[j+1]=='L')r=j;j++;}while(r==-1);
			}
			d[r+((r-i)%2)]++;
		}
	}
	for(int i=0;i<s.size();i++)printf("%d ",d[i]);
}


Measured memory_bytes: 1024
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let a: usize = read!();
    let b: usize = read!();

    let mut ans = 0;
    for i in a..=b {
        let s = i.to_string();
        let t: String = s.chars().rev().collect();

        if s == t {
            ans += 1;
        }
    }

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


Measured memory_bytes: 2092
N,Y=map(int,input().split())

for x in range(N+1):
    for y in range(N-x+1):
        if x * 10000 + y * 5000 + (N-x-y) * 1000 == Y:
            print(x,y,N-x-y)
            exit()
print("-1 -1 -1")                


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>

using namespace std;
int main(){
  double a, b;
  cin >> a >> b;
  double xa, xb;
  bool exist = false;
  for(xb = 10*b; floor(xb*0.1) == b; xb++) {
    if(floor(xb*0.08) == a) {
      exist = true;
      break;
    }
  }
  if(exist) {
   cout << xb << endl;
  } else {
   cout << -1 << endl;
  }
   return 0;
} 


Measured memory_bytes: 3724
n=int(input())
ac=int(0)
wa=int(0)
tle=int(0)
re=int(0)

for i in range(n):
    s=input()
    if s=="AC":
        ac+=1
    if s=="WA":
        wa+=1
    if s=="TLE":
        tle+=1
    if s=="RE":
        re+=1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9228
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
long long N, K;
vector<long long> A;
vector<long long> F;

// x が条件を満たすかどうか
bool isOK(long long x) {
    long long s = K;
    rep(i, 0, N) {
        if(A[i] * F[i] > x) {
            s -= ((A[i] * F[i] - x) + F[i] - 1) / F[i];
        }
    }
    if(s >= 0) {
        return true;
    } else {
        return false;
    }
}

// 汎用的な二分探索のテンプレ
long long binary_search() {
    long long left =
        -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    long long right =
        INF; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は
             // a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while(right - left > 1) {
        long long mid = left + (right - left) / 2;

        if(isOK(mid))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
     */
    return right;
}
int main() {
    cin >> N >> K;
    A.assign(N, 0);
    F.assign(N, 0);
    rep(i, 0, N) { cin >> A[i]; }
    rep(i, 0, N) { cin >> F[i]; }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<long long>());
    // rep(i, 0, N) { cout << A[i] << " "; }
    // cout << endl;
    // rep(i, 0, N) { cout << F[i] << " "; }
    // cout << endl;
    cout << binary_search() << endl;
}

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

class PG{
    static void Main(string[] args){
        while(true){
            int[] nums=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if(nums[0]==0&&nums[1]==0){
                break;
            }
            for(int i=0;i<nums[0];i++){
                for(int j=0;j<nums[1];j++){
                    if(i==0||i==nums[0]-1||j==0||j==nums[1]-1){
                        Console.Write("#");
                    }else{
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            } 
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 20336
s = input()[::-1]
length = len(s)
a = [0] * length
d = [0] * length
ans = [0] * 2019
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

print(int(sum([ans[i] * (ans[i]-1) for i in range(2019)]) / 2) + ans[0])

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

int main() {
	int d,a, b, c;
	cin>>a>>b>>c;
	d = a + b + c;
	if (a == 5&&b==5&&c==7) {
		cout<<"YES"<<endl;
	}
	else if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
	}
	else if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e6+10;
int read(){int x;scanf("%lld",&x);return x;}
int n=read(),sum=0,a[maxn];
signed main() {
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	
	for(int i=1;i<=n;++i) {
		a[i]=read();
		if(a[i]<a[i-1]) sum+=a[i-1]-a[i],a[i]=a[i-1];
	}
	cout<<sum;
	return 0;
}

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

const long long INF = 1E18 + 10;

long long n, a;

bool check(long long u, int len) {
  if(u < len) return false;
  long long tp = u / len, tmp = 1;
  for (int i = 1; i <= len; i++) {
    if (i <= u % len) {
      if (INF / tmp < tp + 1) return true;
      tmp *= (tp + 1);
    } else {
      if (INF / tmp < tp) return true;
      tmp *= tp;
    }
  }
  return tmp >= n;
}

int main() {
  cin >> n >> a;
  long long ans = INF;
  for (int i = 1; i <= 44; i++) {
    long long l = 1, r = INF, md;
    for (int cs = 0; cs < 66; cs++) {
      md = (l + r) >> 1;
      if (check(md, i)) r = md;
      else l = md + 1;
    }
    ans = min(ans, md + a * (i - 1));
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int n,k;
	cin>>n>>k;
	
	int num=1;
	while(n>0){
		if(num+k>num*2) num*=2;
		else num+=k;
		n--;
	}
	
	cout<<num<<endl;
	return 0;
}

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

struct task {
    int idx;
    int next;
    int prev;
    std::string name;
    int time;
};

int main() {
    int n, q;
    int time = 0;
    int done = 0;
    task queue[100000];

    // input
    std::ios::sync_with_stdio(false);
    std::cin >> n >> q;
 
// make queue
    queue[0].prev = n-1;
    for (int i=0; i<n; i++) {
        queue[i].idx = i;
        if (i!=0) queue[i].prev = i-1;
        std::cin >> queue[i].name >> queue[i].time;
        if (i==n-1)
            queue[i].next = 0;
        else
            queue[i].next = i+1;
    }

int i = 0;
while (done < n) {
    if (queue[i].time > q) {
        time += q;
        queue[i].time -= q; 
    } else {
         done++;
         time += queue[i].time;
         queue[queue[i].prev].next = queue[i].next;
         queue[queue[i].next].prev = queue[i].prev;
         std::cout << queue[i].name << " " << time << std::endl;
    }
        i = queue[i].next;
    }
}



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

int main(){
    string s;cin>>s;
    if (s.size() < 26){
        set<char> used_alphabet;
        for (int i=0;i<s.size();i++){
            used_alphabet.insert(s[i]);
        }
        string alphabet = "abcdefghijklmnopqrstuvwxyz";
        for (int i=0;i<alphabet.size();i++){
            if (used_alphabet.find(alphabet[i]) == used_alphabet.end()){
                cout << s << alphabet[i] << endl;
                return 0;
            }
        }

    } else {
        if (s == "zyxwvutsrqponmlkjihgfedcba"){
            cout << -1 << endl;
        } else {
            int delimiter;
            for (int i=25;i>0;i--){
                if (s[i] > s[i-1]){
                    delimiter = i - 1;
                    break;
                }
            }
            string target = s.substr(delimiter, 26 - delimiter);
            char append_char;
            for (int i=target.size() - 1;i>=0;i--){
                if (target[i] > s[delimiter]){
                    append_char = target[i];
                    break;
                }

            }
            cout << s.substr(0, delimiter) << append_char << endl;

        }
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,K;
    cin >> N >> K;
    vector<int>p(N);
    rep(i,N)cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    rep(i,K)ans += p[i];
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 1e18;
    rep(i, n - k + 1) {
        ans = min(ans, h[k+i-1]-h[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int co=0;
  int si=s.size();
  if(si%2==1 && (s[si/2]=='(' || s[si/2]==')')) co++;
  for(int i=0;i<si/2;i++){
    int j=si-i-1;
    if(s[i]=='(' && s[j]==')');
    else if(s[i]==')' && s[j]=='(');
    else if(s[i]!=s[j]||s[i]==')'||s[i]=='(') co ++ ;
  }
  cout << co<<endl;
  
  return 0;
}

Measured memory_bytes: 1180
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print('Yes')
else:
    cnt = 0
    Hn = []
    flag = True
    for i in range(len(H)-1):
        Hn.append(H[i+1]-H[i])
    for h in Hn:
        if h < -1:
            flag = False
        elif h == -1:
            cnt += 1
            if cnt == 2:
                flag = False
        elif h == 0:
            continue
        else:
            cnt = 0
    if flag:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14396
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007

using namespace std;

class ARounding {
public:
	void solve(std::istream& in, std::ostream& out) {
		int x,a;
		in >> x >> a;
		if(x<a)
			out << "0\n";
		else
			out << "10\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ARounding solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

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

    long long mn = 1000;
    long long res = mn;

    vector<int> B;
    for (int i = 0; i < n; ++i) {
        if (B.empty() || B.back() != A[i]) {
            B.push_back(A[i]);
        }
    }

    n = B.size();
    long long x = mn;
    long long s = 0;
    for (int i = 0; i < n; ++i) {
        if ((i - 1 < 0 || B[i - 1] > B[i]) && (i + 1 >= n || B[i + 1] > B[i])) {
            auto cnt = x / B[i];
            x -= cnt * B[i];
            s += cnt;
        }
        if ((i - 1 < 0 || B[i - 1] < B[i]) && (i + 1 >= n || B[i + 1] < B[i])) {
            x += s * B[i];
            s = 0;
        }
        res = max(res, x);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int N;
    cin>>N;
    vector<double> ps(N);
    rep(i, N) cin>>ps[i];

    vector<vector<double>> dp(N + 1, vector<double>(N + 1));
    dp[0][0] = 1;
    rep(i, N) {
        dp[i + 1][0] = dp[i][0] * (1 - ps[i]);
    }
    int i, j;
    rep(i, N) {
        rep(j, N) {
            dp[i + 1][j + 1] = dp[i][j] * ps[i] + dp[i][j + 1] * (1 - ps[i]);
        }
    }
    double ans = 0;
    rep(i, N / 2 + 1) {
        ans += dp[N][N - i];
    }
    printf("%.15f", ans);
}

Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string[] e = Console.ReadLine().Split(' ');
            int ae = int.Parse(e[0]);
            int be = int.Parse(e[1]);
            string[] f = Console.ReadLine().Split(' ');
            int af = int.Parse(f[0]);
            int bf = int.Parse(f[1]);
            string[] g = Console.ReadLine().Split(' ');
            int ag = int.Parse(g[0]);
            int bg = int.Parse(g[1]);
            int[] s = { ae, be, af, bf, ag, bg };

            int OneCnt = 0;
            int TwoCnt = 0;
            int ThreeCnt = 0;
            int FourCnt = 0;

            for (int i = 0; i < 6; i++)
            {
                if (s[i] == 1)
                {
                    OneCnt++;
                }
                else if (s[i] == 2)
                {
                    TwoCnt++;
                }
                else if (s[i] == 3)
                {
                    ThreeCnt++;
                }
                else if (s[i] == 4)
                {
                    FourCnt++;
                }
            }

            string ans = "YES";
            if (OneCnt == 0 || TwoCnt == 0|| ThreeCnt == 0 || FourCnt == 0)
            {
                ans = "NO";
            }
            if (OneCnt == 3 || TwoCnt == 3 || ThreeCnt == 3 || FourCnt == 3)
            {
                ans = "NO";
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

#define MAX_N 500
#define MAX_W 10000
#define INF LLONG_MAX/4
typedef long long ll;

ll dp[MAX_N+1][MAX_W+1];

int main(){
    ll M,N,E;
    int C;
    cin >> M >> N;
    vector<ll> P(M);
    for(ll i = 0 ; i < M ; i++){
        cin >> P[i];
    }
    sort(P.begin(),P.end(),greater<ll>());
    fill(dp[0],dp[MAX_N+1],INF);
    dp[0][0] = 0;
    for(ll i = 0 ; i < N ; i++){
        cin >> C >> E;
        for(int j = 0 ; j < MAX_W+1 ; j++){
            dp[i+1][j] = min(dp[i][j],
                             dp[i][max(0,j-C)]+E);
        }
    }
    ll res = 0,sum = 0;
    for(int i = 0 ; i < M ; i++){
        sum += P[i];
        res = max(res,sum-dp[N][i+1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 40440
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

class IntervalTree { // find min, add to range
	using wgt = long long;

	static constexpr wgt no_val = (1LL<<60);

	struct node {
		wgt val, add;
		int l, r;
	};

	vector<node> T;

	void upd(int i) {
		node & n = T[i];
		n.val += n.add;
		if(n.l+1 < n.r) {
			T[2*i].add += n.add;
			T[2*i+1].add += n.add;
		}
		n.add = 0;
	}

public:
	IntervalTree() {}

	IntervalTree(int N) {
		int b = 1;
		while(b < N) b *= 2;
		T.reserve(2*b+1);
		T.resize(2, {no_val, 0, 0, b});
		for(int i = 1; ; i++) {
			if(i == (int)T.size() || T[i].l+1 == T[i].r) break;
			T.push_back({no_val, 0, T[i].l, (T[i].l+T[i].r)/2});
			T.push_back({no_val, 0, (T[i].l+T[i].r)/2, T[i].r});
		}
	}

	void add(int l, int r, wgt w_add, int i = 1) {
		node & n = T[i];
		if(n.l == l && n.r == r) {
			n.add += w_add;
			upd(i);
			return;
		}
		else if(n.add) upd(i);
		if(n.l >= r || l >= n.r) return;
		int c = (n.l + n.r) / 2;
		if(n.l+1 < n.r) {
			add(l, min(r, c), w_add, 2*i);
			add(max(l, c), r, w_add, 2*i+1);
			n.val = min(T[2*i].val, T[2*i+1].val);
		}
	}

	void put(int pos, wgt w, int i = 1) {
		node & n = T[i];
		if(n.l == pos && n.r == pos+1) {
			T[i].val = w;
			T[i].add = 0;
			return;
		}
		else if(n.add) upd(i);
		if(n.l > pos || pos >= n.r) return;
		put(pos, w, 2*i);
		put(pos, w, 2*i+1);
		n.val = min(T[2*i].val, T[2*i+1].val);
	}

	wgt get(int l, int r, int i = 1) { // max [l..r)
		node & n = T[i];
		if(n.add) upd(i);
		if(n.l >= r || l >= n.r) return no_val;
		if(n.l == l && n.r == r) return n.val;
		n.val = min(T[2*i].val, T[2*i+1].val);
		int c = (n.l + n.r) / 2;
		auto best_lft = get(l, min(r, c), 2*i);
		auto best_rt = get(max(l, c), r, 2*i+1);
		return min(best_lft, best_rt);
	}
};

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cat A, B;
	cin >> N >> A >> B;
	vector<int> P(N);
	for(int i = 0; i < N; i++) cin >> P[i];
	IntervalTree I(N+5);
	I.put(0, 0);
	for(int i = 0; i < N; i++) {
		cat cost = I.get(0, P[i]);
		I.put(P[i], cost);
		I.add(0, P[i], A);
		I.add(P[i]+1, N+3, B);
	}
	cout << I.get(0, N+3) << "\n";
	return 0;
}

// look at my code
// my code is amazing


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

#define PI 3.141592653589793

int main()
{
    long double a,b,x;
    cin >> a >> b >> x;

    long double h = x / (a * a), ans = 0;
    if(a * a * b / 2 <= x)
    {
        ans = (b - h) * 2 / a;
    }
    else
    {
        ans = b / (x * 2 / (b * a));
    }
    
    cout << fixed  << setprecision(15) << atanl(ans) * 180 / PI << endl;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
        public static void main(String[] args) throws IOException {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String is; 
                while((is = in.readLine()) != null){
                        int a = Integer.parseInt(is);
                        int c = 0;
                        for(int i = 1;i <= a/2; ++i){
                                if(isPrime(i) && isPrime(a+1-i)){
                                        ++c;
                                }   
                        }   
                        c *= 2;
                        if(a%2 != 0){ 
                                if(isPrime((a+1)/2)){
                                        ++c;
                                }   
                        }   
                        System.out.println(c);
                }   
        }

        static boolean isPrime(int n){ 
                if(n < 2){ 
                        return false;
                } else if(n == 2){ 
                        return true;
                }   
                if(n % 2 == 0){ 
                        return false;
                }   
                for(int i = 3; i*i <= n; i+=2){
                        if(n % i == 0){ 
                                return false;
                        }   
                }
                return true;
        }
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

void chmin(int &a, int b) {
  if (a > b) a = b;
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i) a[i] += a[i - 1];
  }
  int ans = 1e18;
  for (int i = 0; i < n - 1; i++) {
    chmin(ans, abs(a[n - 1] - a[i] * 2));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4720
#ITP1_10-A Distance
x1,y1,x2,y2 = input().split(" ")
x1=float(x1)
y1=float(y1)
x2=float(x2)
y2=float(y2)
print ( ((x1-x2)**2.0 + (y1-y2)**2.0 )**0.5)

Measured memory_bytes: 7460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll d[1<<21][21],n;
vector<ll> v[21];

ll dp(ll mask, ll ind) {
  
    if(mask==(1<<n) -1)
        return 1;

    if(d[mask][ind]!=inf)
        return d[mask][ind];

    d[mask][ind] = 0;
    for(auto i: v[ind]) {
        if(!(mask&(1<<i)))
            d[mask][ind] = (d[mask][ind] + dp(mask|(1<<i), ind+1))%M;
    }

    return d[mask][ind];
}

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   ll x;
   cin>>n;
   for(ll i=0; i<(1<<n); i++) {
        for(ll j=0; j<n; j++)
            d[i][j] = inf;
   }

   for(ll i=0; i<n; i++) {
    for(ll j=0; j<n; j++) {
        cin>>x;
        if(x)
            v[i].push_back(j);
    }
   }

   cout<<dp(0, 0)<<"\n";

    return 0;
}


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

int gcd(int x,int y){
    if(x%y==0){
        return y;
    }else{
        return(gcd(y,x%y));
    }
}
int GCM(vector<int> A){
    int l = A.front();
    int n = A.size(); 
    for(int i=1;i<n;i++){
        l = gcd(l,A[i]);
    }
    return l;
}

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> y(n);
    for(int i=0;i<n;i++){
        int p;
        cin >> p;
        y[i] = abs(p-x);
    }

    cout << GCM(y) << endl;
}

Measured memory_bytes: 1024
A = input()
B = input()

if len(A) > len(B):
  print("GREATER")
  exit(0)
elif len(A) < len(B):
  print("LESS")
  exit(0)

for i in range(len(A)):
  if A[i] > B[i]:
    print("GREATER")
    exit(0)
  elif A[i] < B[i]:
    print("LESS")
    exit(0)

print("EQUAL")

Measured memory_bytes: 3064
import itertools

n, m, q = map(int,input().split())
seq = list(range(n+m-1))
p = list(itertools.combinations(seq, n))

a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int,input().split())

res = 0
for i in range(len(p)):
    t = [0] * n
    pp = sorted(p[i])
    idx = 0
    for e in pp:
        t[idx] = 1 + e - idx
        idx += 1
    
    tmp = 0
    for j in range(q):
        if t[b[j]-1] - t[a[j]-1] == c[j]:
            tmp += d[j]
    
    res = max(res, tmp)

print(res)

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

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < M + 1; j++) {
            int black = j * N + i * M - i * j * 2;
            if (black == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	string ans = "NO";
	if(n%2==0){
		if(k<=(n/2)){
			ans = "YES";
		}
	}else{
		if(k<=(n/2)+1){
			ans = "YES";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define LL long long
#define INF 2000000000
#define maxn 1010
using namespace std;
int n,m;
int k[][2]={{-1,0},{1,0},{0,-1},{0,1}};//L,R,U,D
int border[maxn][maxn][4];//边界
int vis[maxn][maxn],qx[maxn*maxn],qy[maxn*maxn];
LL ans;
struct node{
	int a,b,c;
}f[maxn],g[maxn];
int X[maxn],Y[maxn],XN,YN;//值到脚标，离散化
int findX(int v){
	return lower_bound(X,X+XN,v)-X;//功能：查找非递减序列[first,last) 内第一个大于或等于某个元素的位置。
}
int findY(int v){
	return lower_bound(Y,Y+YN,v)-Y;
}
void bfs(int xx,int yy){
	int i,h,t,nx,ny,x,y;
	h=t=0;
	qx[t]=xx,qy[t]=yy,t++,vis[xx][yy]=1;
	while(h<t){
		x=qx[h],y=qy[h],h++;
		ans+=(LL)(X[x+1]-X[x])*(Y[y+1]-Y[y]);//根据此句编写The point (0,0) does not lie on any of the given segments.
		for(i=0;i<4;i++){//四个方向
			if(border[x][y][i])continue;
			nx=x+k[i][0],ny=y+k[i][1];
			if(nx==0||nx==XN-1||ny==0||ny==YN-1){//到达-INF,INF表示无线延伸
				ans=-1;
				return;
			}
			if(vis[nx][ny])continue;//该点已经访问过
			vis[nx][ny]=1,qx[t]=nx,qy[t]=ny,t++;
		}
	}
}
void init(){
	int i,x,y,r,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)scanf("%d%d%d",&f[i].a,&f[i].b,&f[i].c),X[XN++]=f[i].c;
	X[XN++]=-INF,X[XN++]=INF;//设定值的范围
	sort(X,X+XN);//自小到大排序
	XN=unique(X,X+XN)-X;//去重
	for(i=0;i<m;i++)scanf("%d%d%d",&g[i].a,&g[i].b,&g[i].c),Y[YN++]=g[i].a;
	Y[YN++]=-INF,Y[YN++]=INF;
	sort(Y,Y+YN);//自小到大排序
	YN=unique(Y,Y+YN)-Y;
	for(i=0;i<n;i++){
		x=findX(f[i].c);
		r=findY(f[i].b);
		if(Y[r]!=f[i].b)r--;//找不到的情况，需要--
		for(j=findY(f[i].a);j<r;j++)
			border[x-1][j][1]=border[x][j][0]=1;//边界设定:1表示,向右不能到达;0表示,向左不能到达
	}
	for(i=0;i<m;i++){
		y=findY(g[i].a);
		r=findX(g[i].c);
		if(X[r]!=g[i].c)r--;
		for(j=findX(g[i].b);j<r;j++)
			border[j][y-1][3]=border[j][y][2]=1;//边界设定:3表示,向下不能到达;2表示,向上不能到达
	}
}
int main(){
	init();
	bfs(findX(0)-1,findY(0)-1);//根据此句编写The point (0,0) does not lie on any of the given segments.
	if(ans==-1)printf("INF\n");
	else printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 29284
#include<stdio.h>
int main(){
  char s[10];
  int n,max,count;
  
  scanf("%s",&s);
  
  for(n=0;n<10;n++){
    if(s[n]=='A'||s[n]=='C'||s[n]=='G'||s[n]=='T'){
      count++;
     if(count>=max){
       max=count;
     }
    }
      else{
        count=0;
      }
    }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}

int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	string s;
	cin>>s;
	if(s[0] =='R' && s[1] =='R' && s[2] == 'R'){
		cout<<"3"<<endl;
	}else if(s[0] == 'R' && s[2] == 'R'){
		cout<<"1"<<endl;
	}else if( (s[0] =='R' && s[1] =='R') || (s[1] =='R' && s[2] == 'R') ){
		cout<<"2"<<endl;
	}else if(s[0]=='R' || s[1]=='R' || s[2] =='R' ){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
}

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

int main(){
  int N, A, B;
  string s;
  cin >> N >> A >> B >> s;
  int count_all = 0, count_b = 0;
  for (int i = 0; i < N; i++){
    if (s[i] == 'c'){
      cout << "No" << endl;
    }
    if (s[i] == 'b'){
      count_b++;
      count_all++;
      if(count_all <= A + B && count_b <= B) cout << "Yes" << endl;
      else{
      cout<< "No" << endl;
      count_all--;
      }
    }
    if (s[i] == 'a'){
      count_all++;
      if(count_all <= A + B) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3744
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   if c+f<F[v]:F[v]=c+f;heappush(H,(F[v],v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(n,E,*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6308
#include <iostream>
#include<algorithm>
int kaijou(int n){
    while(n>1){
        if(n%10!=0) return 0;
        n/=10;
    }
    return 1;
}

int wa(int n){
    int i=0;
    while(n>0){
        i+=n%10;
        n/=10;
    }
    return i;
}

using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    if(kaijou(n)){
        cout << 10<<endl;
    }else{
        cout<<wa(n)<<endl;
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int n,k,s;
	cin>>n>>k>>s;
	if (s==1000000000){
		for (int i=0;i<k;i++){
			cout<<1000000000<<' ';
		}
		for (int i=k;i<n;i++){
			cout<<1<<' ';
		}
	}
	else{
		for (int i=0;i<k;i++){
			cout<<s<<' ';
		}
		for (int i=k;i<n;i++){
			cout<<s+1<<' '; 
		} 
	}
	re 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

// 素因数を列挙
vector<pair<ll, ll>> enumeratePrimeFactors(ll n) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0) {
      continue;
    }
    ll ex = 0; // 指数
    // 割れるだけ割る
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.emplace_back(a, ex);
  }
  // nが一度も割られなかった場合
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;
  vector<pair<ll, ll>> primeFactors = enumeratePrimeFactors(p);
  ll res = 1;
  if (n == 1) {
    res = p;
  } else {
    for (auto pf : primeFactors) {
      res *= pow(pf.first, pf.second / n);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const int MAX_V = 200005;
vector<int> g[MAX_V];

int N, Q;
map<int, long> mp;

long point[MAX_V];

void dfs(int v, long cur_point) {
  if (point[v] != 0) {
    return;
  }
  long tmp = mp[v];
  point[v] = cur_point + tmp;

  for (auto next_v : g[v]) {
    dfs(next_v, cur_point + tmp);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
  }
  for (int i = 0; i < Q; i++) {
    int p;
    long x;
    cin >> p >> x;
    p--;
    mp[p] += x;
  }

  dfs(0, 0);
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << point[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 43008
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, K: int):
    if abs(B-A) > 10**18:
        print("Unfair")
    if K&1:
        print(B-A)
    else:
        print(A-B)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int d1[200005],d2[200005],tot=0,h[200005],n,x,y,siz[200005],col[200005],fa[200005],d3[200005],d4[200005];
long long ans=0;
struct Edge
{
    int x,next;
}e[400005];
char ch[200005];
inline void add_edge(int x,int y)
{
  e[++tot].x=y;
  e[tot].next=h[x],h[x]=tot;
}
void dfs1(int x,int father)
{
  int i;	
  siz[x]=col[x],fa[x]=father;
  d3[x]=col[x]?0:1e9;
  for(i=h[x];i;i=e[i].next)
  {
    if(e[i].x==father)
	  continue;
      dfs1(e[i].x,x);
    siz[x]+=siz[e[i].x];
    d1[x]=max(d1[x],d1[e[i].x]+1);
    if(siz[e[i].x])
    d3[x]=min(d3[x],d1[e[i].x]+1);
  }
}
void dfs2(int x,int father)
{
  if(father)
  d4[x]=d2[x]-1;
  int maxn=0,sec=0,i;
  for(i=h[x];i;i=e[i].next)
  {
    if(e[i].x==father)
	  continue;
    if(d1[e[i].x]+1>maxn)
      sec=maxn,maxn=d1[e[i].x]+1;
    else 
	  sec=max(sec,d1[e[i].x]+1);
  }
  for(i=h[x];i;i=e[i].next)
  {
    if(e[i].x==father)
	  continue;
    if(d1[e[i].x]+1==maxn)
      d2[e[i].x]=max(d2[x],sec)+1;
    else 
	  d2[e[i].x]=max(d2[x],maxn)+1;
    dfs2(e[i].x,x);
  }
}
int main()
{
  int i,j;	
  scanf("%d",&n);
  for(i=1;i<n;i++)
  {
    scanf("%d%d",&x,&y);
    add_edge(x,y);
    add_edge(y,x);
  }
  scanf("%s",ch+1);
  for(i=1;ch[i];i++)
    col[i]=ch[i]-'0';
  dfs1(1,0),dfs2(1,0);
  for(i=1;i<=n;i++)
  {
    int minv,maxv;
    minv=min(d3[i],siz[1]==siz[i]?(int)1e9:d2[i]);
    maxv=max(d1[i],d2[i])-1;
    for(j=h[i];j;j=e[j].next)
	{   	
      if(e[j].x==fa[i])
	    maxv=min(maxv,d1[i]+1);
      else 
	    maxv=min(maxv,d4[e[j].x]+1);
    }
    if(maxv>=minv)ans+=1LL*maxv-minv+1;
  }
  printf("%lld",ans+1);
  return 0;    
}

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


int main(){
  int a,b,c,d,e,n,m,count;
  cin >> a >>  b >> c >> d >> e;
  vector<int> v = {a,b,c,d,e};
  n = 9;
  for(int i=0; i < 5; i++){
    if(v.at(i) % 10 ==0){
      count++;
      continue;
    }
    if( v.at(i) % 10 < n)
      n = v.at(i) % 10;
  }
  if(count == 5)
    n = 10;
  m = a / 10 * 10 + b / 10 * 10 + c / 10 * 10 + d / 10 * 10 + e / 10 * 10 + (4 - count) * 10 + n ;
  cout << m << endl;
      }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  string s;cin>>s;
  map<char,int> m;
  rep(i,4){
    char c;
    c=s.at(i);
    m[c]++;
  }
  if(m.size()==2 && m[s.at(0)]==2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
/* ex3_4
    riverstone*/

#include <stdio.h>
 
int main(void){
    //Nをnumberとする。
    int number;
    int i=0;

    // number の入力を取得
    scanf("%d",&number);

    // iを総当たり
    // 割り切れるものがあればyes、なければNoを出力
    for(i=1;i<10;i++){
        //numberがiで割り切れてかつ商が9以下ならいい。
        if(number % i == 0 && number/i < 10){
            printf("Yes");
            return 0;
        } 
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=20;
int n,a[N];
ll dfs(int l, int r, int xl, int xr)
{
	if(l+1==r) return 0;
	ll ans=1ll<<60;
	for(int i=l+1;i<r;++i) ans=min(ans,dfs(l,i,xl,xl+xr)+dfs(i,r,xl+xr,xr)+1ll*a[i]*(xl+xr));
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, R;

  cin >> N >> R;

  R += 100 * max(0, 10 - N);

  cout << R << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,c = map(int,readline().split())
R = [0]*n
chk = []
pre_x = 0
for i in range(n):
  x,v = map(int,readline().split())
  chk.append((x,v))
  R[i] = R[i-1]-(x-pre_x)+v
  pre_x = x

L = [0]*(n+1)
nex_x = c
for i,p in enumerate(chk[::-1]):
  x,v = p
  L[n-1-i] = L[n-i]-(nex_x-x)+v
  nex_x = x
  
chk = [(0,0)]+chk
R = [0]+R
L = [0]+L

class segment_():
    def __init__(self,n,ide_ele,segfunc):
        self.ide_ele = ide_ele
        self.num = 1 << n.bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        self.segfunc = segfunc
        
    def update(self, k, r):
        k += self.num
        self.seg[k] = r
        while k:
            k >>= 1
            self.seg[k] = self.segfunc(self.seg[k*2], self.seg[k*2+1])

    def query(self, p, q):
        # qは含まない
        if q < p:
            return self.ide_ele
        p += self.num;
        q += self.num
        res = self.ide_ele
        while p < q:
            if p & 1 == 1:
                res = self.segfunc(res, self.seg[p])
                p += 1
            if q & 1 == 1:
                q -= 1
                res = self.segfunc(res, self.seg[q])
            p >>= 1;
            q >>= 1
        return res

SR = segment_(n+1,0,lambda a, b: max(a,b))
SL = segment_(n+1,0,lambda a, b: max(a,b))
for i in range(1,n+1):
  SR.update(i,R[i])
  SL.update(i,L[i])
  
ans = max(0,max(SR.query(0,n+1),SL.query(1,n+1)))
for i in range(1,n+1):
  cr = chk[i][0]
  cc = c-cr
  sr = SR.query(0,i)
  sl = SL.query(i+1,n+2)
  rr = R[i] + max(sl-cr,0)
  ll = L[i] + max(sr-cc,0)
  ans = max(ans, max(rr,ll))
  
print(ans)

Measured memory_bytes: 97264
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
//        long ans = x * (x - 1);

        BigInteger ans = new BigInteger(x+"");
        BigInteger tmp = ans.subtract(new BigInteger("1"));
        ans = ans.multiply(tmp);
        ans = ans.divide(new BigInteger("2"));
        System.out.println(ans);


    }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a;
    ll b;
    char c;
    ll d;
    cin >> a >> b >> c >> d;
    cout << a * b + (a * d)/100 << endl;

}


Measured memory_bytes: 3652
n = int(input())
enemys = list(map(int,input().split()))
people = list(map(int,input().split()))
count = 0
for i in range(n):
    if enemys[i] - people[i] < 0:
        count += enemys[i]
        people[i]-=enemys[i]
        if enemys[i+1] - people[i] < 0:
            count += enemys[i+1]
            enemys[i+1] = 0
        else:
            count += people[i]
            enemys[i+1] -= people[i]
    else:
        count += people[i]
    
print(count)


Measured memory_bytes: 18476
#include<stdio.h>
int main(){
  int A[1000][1000],B[1000][1000];
  long C[1000][1000];
  int n,m,l;
  int i,j,k;
  
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&A[i][j]);

  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&B[i][j]);

  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
	C[i][j]+=A[i][k]*B[k][j];
      }
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      printf("%ld",C[i][j]);
      if(j!=l-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;

int main(){
  ll X,Y;
  cin >> X >> Y;
  ll ans=0;
  while(X<=Y){
    X=X*2;
    ans++;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256