akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;

#include <iostream>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = 1; i <= n; ++i)
using namespace std;

constexpr int MX = 100000, mod = 1000000007;
struct Fact {
  int d[MX+1];
  constexpr Fact(): d() {
    d[0] = 1;
    long long x = 1;
    rrep(i,MX) {
      x = (x*i)%mod;
      d[i] = x;
    }
  }
};
constexpr Fact F = Fact();

int main() {
  int n;
  scanf("%d", &n);
  cout << F.d[n] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>   
using namespace std;   
int main()
{  
    int a,b,c,d,t;
	cin>>a>>b>>c>>d;
	if(a<b&&c<d&&a>=0&&b<=100&&c>=0&&d<=100)
	{
	if(a<c)
		{
			if(b<d)	 t=b-c;
			else  t=d-c;
		}
	else
		{
			if(b<d) t=b-a;
			else  t=d-a;
		}
	}
	if(t<0)  t=0;
	cout<<t<<endl;
    return 0;  
}  

Measured memory_bytes: 256
n= gets.strip.to_i

arr=[]
(1..n).each do |i|
	arr << gets.strip
end

if arr.uniq.size!=arr.size
	puts 'No'
	exit
end

s=arr[0][0]
arr.each do |a|
	if s!=a[0] 
		puts 'No'
		exit
	end
	s=a[a.size-1]
end

puts 'Yes'



Measured memory_bytes: 1788
#include <iostream>
#include <complex>
#include <map>

using namespace std;

typedef complex<int> P;

int main() {
	P dirs[5] = {
		P(0, 0),
		P(0, -1),
		P(1, 0),
		P(0, 1),
		P(-1, 0)
	};
	map<char, int> trans;
	trans['.'] = 0;
	trans['^'] = 1;
	trans['>'] = 2;
	trans['v'] = 3;
	trans['<'] = 4;

	int W, H;
	int m[100][100];
	while (cin >> H >> W, H || W) {
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x)
				m[y][x] = trans[str[x]];
		}

		P p = P(0, 0);
		for (int i = 0; i < W*H; ++i)
			p += dirs[m[p.imag()][p.real()]];

		if (m[p.imag()][p.real()]) cout << "LOOP" << endl;
		else cout << p.real() << " " << p.imag() << endl;
	}
}

Measured memory_bytes: 1252
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        int[] d = new int[N];
        int sum = 1;

        for(int i=0; i<N; i++){
            d[i] = sc.nextInt();
            if(i>0){
                for(int j=0; j<i; j++){
                    if(d[i]==d[j]){
                        break;
                    }
                    if(j==i-1){
                        sum += 1;
                    }
                }
            }
        }
        System.out.println(sum);
    } 
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double[] p = new double[n];
        for(int i = 0; i < n; i++){
            p[i] = scanner.nextDouble();
        }
        double[] dp = new double[n+1];
        dp[0] = 1;
        double pre = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= n; j++){
                double t = dp[j];
                if(j == 0){
                    dp[j] *= (1 - p[i-1]);
                }else{
                    dp[j] = p[i-1] * pre + (1 - p[i-1]) * dp[j];
                }
                pre = t;
            }
        }
        double ans = 0;
        for(int i = n / 2 + 1; i <= n; i++){
            ans += dp[i];
        }
        System.out.println(ans);
    }
}


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

#define long long long int

using namespace std;

// @author: pashka

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

    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        a[i].first--;
        a[i].second--;
    }

    int res = 0;
    {
        vector<pair<int, int>> l(n);
        l[0] = a[0];
        for (int i = 1; i < n; i++) {
            l[i].first = max(l[i - 1].first, a[i].first);
            l[i].second = min(l[i - 1].second, a[i].second);
        }
        vector<pair<int, int>> r(n);
        r[n - 1] = a[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            r[i].first = max(r[i + 1].first, a[i].first);
            r[i].second = min(r[i + 1].second, a[i].second);
        }
        for (int i = 0; i < n; i++) {
            int s = a[i].second - a[i].first + 1;
            pair<int, int> q = {0, 1000000000};
            if (i > 0) {
                q.first = max(q.first, l[i - 1].first);
                q.second = min(q.second, l[i - 1].second);
            }
            if (i < n - 1) {
                q.first = max(q.first, r[i + 1].first);
                q.second = min(q.second, r[i + 1].second);
            }
            if (q.second >= q.first) {
                s += q.second - q.first + 1;
            }
//            cerr << i << " " << q.first << " " << q.second << " " << s << "\n";
            res = max(res, s);
        }
    }
//    cerr << res << "\n";

    for (int i = 0; i < n; i++) a[i].second = -a[i].second;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) a[i].second = -a[i].second;

    vector<pair<int, int>> s;
    for (int i = 0; i < n; i++) {
        while (!s.empty() && s.back().second >= a[i].second) {
            s.pop_back();
        }
        s.push_back(a[i]);
    };

    a = s;
    n = a.size();

    if (n > 1) {
        vector<pair<int, int>> l(n);
        l[0] = a[0];
        for (int i = 1; i < n; i++) {
            l[i].first = max(l[i - 1].first, a[i].first);
            l[i].second = min(l[i - 1].second, a[i].second);
        }
        vector<pair<int, int>> r(n);
        r[n - 1] = a[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            r[i].first = max(r[i + 1].first, a[i].first);
            r[i].second = min(r[i + 1].second, a[i].second);
        }
        for (int i = 0; i < n - 1; i++) {
            int s = 0;
            s += max(l[i].second - l[i].first + 1, 0);
            s += max(r[i + 1].second - r[i + 1].first + 1, 0);
            res = max(res, s);
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 3424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		String ans = "Yes";
		if (A + B < C) {
			ans = "No";
		}

		System.out.println(ans);
		reader.close();
	}
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	if (N < 1000)
	{
		cout << "ABC" << endl;
	}
	else
	{
		cout << "ABD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
        _n: usize,
        s: chars,
    }
    let mut called_time = Vec::new();
    for i in 1..s.len() {
        let mut m1 = (b'a'..b'z')
                    .map(|c| c as char)
                    .filter(|c| c.is_alphabetic())
                    .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        m1.insert('z', 0);
        let mut m2 = (b'a'..b'z')
                    .map(|c| c as char)
                    .filter(|c| c.is_alphabetic())
                    .map(|c| (c, 0)).collect::<HashMap<_, _>>();
        m2.insert('z', 0);
        let mut v = (b'a'..b'z').map(|c| c as char).collect::<Vec<_>>();
        v.push('z');
        for j in 0..i {
            if let Some(x) = m1.get_mut(&s[j]) {
                *x += 1;
            }
        }
        for j in i..s.len() {
            if let Some(x) = m2.get_mut(&s[j]) {
                *x += 1;
            }
        }
        let mut time = 0;
        for j in 0..v.len() {
            if m2[&v[j]] != 0 && m1[&v[j]] != 0 {
                time+=1;
            }
        }
        called_time.push(time);
    }
    if let Some(x) = called_time.iter().max() {
        println!("{}", x);
    }
}

Measured memory_bytes: 4352
from math import factorial
import sys
sys.setrecursionlimit(100000)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]

N, K = [int(i) for i in input().split()]
R = N - K
for i in range(K):
    if K <= i or R < i:
        print(0)
    else:
        print(cmb(R + 1, i + 1) * cmb(K - 1, i) % (10 ** 9 + 7))


Measured memory_bytes: 181108
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n;
int a[210000];
int d[25][210000];

ll nishin[25];

int main()
{
	cin >> n;

	nishin[0] = 1;
	for (int i = 1; i < 25; i++) {
		nishin[i] = nishin[i - 1] * 2;
	}

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 25; i++) {
		d[0][i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		int k = a[i];
		for(int j=24;j>=0;j--){
			if (k >= nishin[j]) {
				d[j][i] = d[j][i-1] + 1;
				k -= nishin[j];
			}
			else {
				d[j][i] = d[j][i - 1];
			}
		}
	}

	/*
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cout << d[j][i];
		}
		cout << endl;
	}
	*/
	
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int mx = 1;
		

		for (int j = 24; j >= 0; j--) {
			if (d[j][i] != 0) {
				//cout << "d_ji-1:"<<d[j][i] - 1 << endl;
				
				/*
				for (int i = 0; i <= n; i++) {
					cout << *(d[j] + i);
				}
				cout << endl;
				*/

				int l = d[j][i] - 1;
				//cout << d[j][i] - 1 << endl;
				int k = lower_bound(d[j], d[j] + n+1, l) - d[j]+1;

				mx = max(k, mx);
				//cout << j<<" "<<k << " " << mx << endl;
			}
		}
		cnt += i - mx+1;
		//cout << "cnt:"<<cnt << endl;
		//cout << endl;

	}


	cout << cnt << endl;

	return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


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

	int n, ans =0;
	cin >>n;
	vector<vector<pii>> dt(n);
	rep(i, n){
		int a;
		cin >>a;
		rep(j, a){
			int x, y;
			cin >>x >>y;
			dt[i].push_back(pii(x-1, y));
		}
	}

	rep(i, 1<<n){
		int ok=1;
		VI ht(n, 9);
		rep(j, n) if(i>>j &1){
			rep(k, sz(dt[j])){
				int c=dt[j][k].first;
				if(ht[c] == 9 || ht[c] == dt[j][k].second){
					ht[c] = dt[j][k].second;
					
				}else{ok = 0;}
			}
		}
		rep(j, n){
			if((i>>j &1) && ht[j]==0) ok=0;
			if(!(i>>j &1) && ht[j]==1) ok=0;
		}
		if(ok) ans = max(ans, __builtin_popcount(i));
		//dbg(i, ok, __builtin_popcount(i));
	}
	cout <<ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

long long dfs(long long l, long long m){
	if(l % m){
		return l / m * 2 * m + dfs(m, l % m);
	}else{
		return l / m * 2 * m - m;
	}
}

int main(){
	long long n, x;
	cin >> n >> x;

	cout << dfs(n - x, x) + n << endl;
}


Measured memory_bytes: 384
N,Z,W =  map(int,input().split(" "))        # Z は要らん子
 
a = list(map(int,input().split(" ")))
 
if N == 1:
	ans = abs(a[-1]-W)
else:
	ans = max(abs(a[-1]-a[-2]),abs(a[-1]-W))
 
 
print(ans)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Text;

namespace mondai0002
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            int a = 0;
            int b = 0;
            int sum = 0;

            while (true)
            {
                input = Console.ReadLine();

                if (input == null || input.Equals(""))
                {
                    break;
                }

                a = int.Parse(input.Split(' ')[0]);
                b = int.Parse(input.Split(' ')[1]);
                sum = a + b;
                Console.WriteLine(sum.ToString().Length);
            }

        }
    }
}

Measured memory_bytes: 5636
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	int card[4][13] = { 0 };
	char pattern;
	int number, n, i=0, j;
	scanf("%d", &n);
	for (i = 0; i < n;i++) {
		scanf(" %c %d", &pattern, &number);
		if (pattern == 'S')
			card[0][number - 1] = 1;
		else if (pattern == 'H')
			card[1][number - 1] = 1;
		else if (pattern == 'C')
			card[2][number - 1] = 1;
		else
			card[3][number - 1] = 1;
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			if (card[i][j] != 1) {
				if (i == 0)
					printf("S %d\n", j+1);
				else if (i == 1)
					printf("H %d\n", j+1);
				else if (i == 2)
					printf("C %d\n", j+1);
				else
					printf("D %d\n", j+1);
			}
		}
	}
}


Measured memory_bytes: 2040
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a,b,k;
  cin >> a >> b >> k;

  if(a>=k) cout << a-k SP b << endl;
  else if(a+b>=k) cout << 0 SP b - (k-a) << endl;
  else cout << 0 SP 0 << endl;
 
  return 0;
}

Measured memory_bytes: 256
n,k=list(map(int,input().split()))
r,s,p=list(map(int,input().split()))
t=input()
vic=""
ans=0
for i in t:
    if i=="r":
        vic+="p"
    if i=="p":
        vic+="s"
    if i=="s":
        vic+="r"
#print(vic[:k])
for i in vic[:k]:
    if i=="r":
        ans+=r
    elif i=="p":
        ans+=p
    elif i=="s":
        ans+=s
#print(vic)
#print(ans)
for i in range(k,n):
    #print(i,":",vic[i])
    if vic[i]==vic[i-k]:
        #print("lose")
        if not i==n-1:
            vic=vic[:i]+'n'+vic[i+1:]
    else:
        #print("win")
        if vic[i]=="r":
            ans+=r
        elif vic[i]=="p":
            ans+=p
        elif vic[i]=="s":
            ans+=s
        else:
            pass
            #print("wrong input")

    #print()

print(ans)

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, max_w;
  cin >> n >> max_w;
  vector<map<string, int> > items;
  items.pb({{"dummy", 0}});
  for (int i = 0 ; i < n ; i++) {
    int v_tmp, w_tmp;
    cin >> v_tmp >> w_tmp;
    map<string, int> mp;
    mp["value"] = v_tmp;
    mp["weight"] = w_tmp;
    items.pb(mp);
  }

  vvi max_value(n+1, vi(max_w+1, 0));
  for (int item_num = 1 ; item_num <= n ; item_num++) {
    for (int w_left = 1 ; w_left <= max_w ; w_left++) {
      max_value[item_num][w_left] = max_value[item_num-1][w_left];
      if (w_left >= items[item_num]["weight"]) {
        max_value[item_num][w_left] = max(max_value[item_num][w_left], 
          items[item_num]["value"] + max_value[item_num][w_left - items[item_num]["weight"]]);
      }
    }
  }

  printf("%d\n", max_value[n][max_w]);

  return 0;
}

Measured memory_bytes: 6844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<int>input(string s) {
	vector<int>ret;
	int k = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ' ') {
			ret.push_back(min(k, 10));
			k = 0;
		}
		else {
			k *= 10;
			if (s[i] == '1')k += 1;
			else if (s[i] == '2')k += 2;
			else if (s[i] == '3')k += 3;
			else if (s[i] == '4')k += 4;
			else if (s[i] == '5')k += 5;
			else if (s[i] == '6')k += 6;
			else if (s[i] == '7')k += 7;
			else if (s[i] == '8')k += 8;
			else if (s[i] == '9')k += 9;
			else if (s[i] == '0')k += 0;
		}
	}
	ret.push_back(min(k, 10));
	return ret;
}
int main() {
	string s;
	while (getline(cin, s)) {
		if (s == "0")return 0;
		vector<int>v = input(s);
		int cnt1 = 0;
		int cnt = 0;
		for (int i = 0; i < v.size(); i++) {
			if (v[i] == 1)cnt1++;
			else cnt += v[i];
		}
		int ans = 0;
		cnt += cnt1;
		if (cnt <= 21)ans = cnt;
		for (int i = 0; i < cnt1; i++) {
			cnt += 10;
			if (cnt <= 21)ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	for (int i=0;i+1<(int)s.size();i++){
		if (s[i]=='A'&&s[i+1]=='C') {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

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

const int N = 3005;
ld ans[N][N];
ld prob[N];

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> prob[i];
    ans[0][1] = prob[0], ans[0][0] = (1 - prob[0]);
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j <= i + 1; j++)
        {
            ans[i][j] = ans[i - 1][j] * (1 - prob[i]);
            if(j)
                ans[i][j] += ans[i - 1][j - 1] * (prob[i]);
        }
    }
    ld sol = 0;
    for(int i = (n + 1) / 2; i <= n; i++)
        sol += ans[n - 1][i];
    cout << fixed << setprecision(12) << sol;
    return 0;
}


Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define N 100010
using namespace std;
long long dam[N],n,i,sum1=0,sum2=0;
vector<long long> mount;
int main(){
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>dam[i];
		sum1+=dam[i];
		if(i%2==1)
		{
			sum2+=dam[i];
		}
	}
	mount.push_back(sum1-sum2*2);
	for(i=0;i<n-1;i++)
	{
		mount.push_back(dam[i]*2-mount.back());
	}
	for(i=0;i<n;i++)
	{
		cout<<mount[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3060
import sys
input = sys.stdin.buffer.readline

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)

print(ans)

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

int main(){
	int h, w;
	
	cin >> h >> w;
	vector< vector<char> > c(h,vector<char>(w));
	for(int i=0; i<h; i++){
	string s;
		for(int j=0; j<w; j++){
			char temp;
			cin >> temp;
			s += temp;
			
		}
		cout << s << endl << s << endl;
	}

 }


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

int main(void){
  long long a,b,c,K;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&K);

  long long ans;
  if(K%2 != 0) ans = b-a;
  else ans = a-b;

  if(llabs(ans) <= 1e18)
    printf("%lld\n",ans);
  else
    printf("Unfair\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[N];
int b;
int main() {
    ios::sync_with_stdio(false);
    cin>>b>>a+1;
    int n=strlen(a+1);
    for(int i=1;i<=n;i++){
        int x='Z'-a[i];
        if(x<b){
            cout<<(char)('A'+(b-x-1));
        }else cout<<(char)(a[i]+b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int num[10000];
	int i;
	int input;
	while(1) {
		scanf("%d",&input);
		if(input==-1)break;
		i=0;
		while(input) {
			num[i]=input%4;
			input/=4;
			i++;
			if(i>=10000)return 1;
		}
		if(i==0)puts("0");
		else {
			for(i--;i>=0;i--)printf("%d",num[i]);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int t;
int n,k;
int x[100001];
int dist[100001];
int main(void){
	scanf("%d",&t);
	for(int kkk=0;kkk<t;kkk++){
		scanf("%d %d",&n,&k);
		for(int i=0;i<n;i++){
			scanf("%d",&x[i]);
		}
		for(int i=0;i<n-1;i++){
			dist[i]=x[i+1]-x[i];
		}
		sort(dist,dist+n-1);
		int res=0;
		for(int i=0;i<n-k;i++){
			res+=dist[i];
		}
		printf("%d\n",res);
	}
	return 0;
}

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

ll n;
std::vector<ll> ara[100010];
ll dp[100010][4];

ll fnc(ll idx,ll last){
  if(idx == n) return 0;
  if(dp[idx][last] != -1) return dp[idx][last];

  ll res1 = - (1<<25);
  ll res2 = - (1<<25);
  ll res3 = - (1<<25);

  if(last == 0){
    res1 = max(res1,ara[idx][0] + fnc(idx+1,1));
    res2 = max(res2,ara[idx][1] + fnc(idx+1,2));
    res3 = max(res3,ara[idx][2] + fnc(idx+1,3));
  }else if(last == 1){
    res2 = max(res2,ara[idx][1] + fnc(idx+1,2));
    res3 = max(res3,ara[idx][2] + fnc(idx+1,3));
  }else if(last == 2){
    res1 = max(res1,ara[idx][0] + fnc(idx+1,1));
    res3 = max(res3,ara[idx][2] + fnc(idx+1,3));
  }else if(last == 3){
    res1 = max(res1,ara[idx][0] + fnc(idx+1,1));
    res2 = max(res2,ara[idx][1] + fnc(idx+1,2));
  }
  dp[idx][last] = max(res1, max(res2,res3));
  return dp[idx][last];
}

int main(int argc, char const *argv[]) {
  memset(dp,-1,sizeof(dp));
  cin >> n;
  for(int i = 0;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    ara[i].push_back(a);
    ara[i].push_back(b);
    ara[i].push_back(c);
  }

  cout << fnc(0,0) << endl;
  return 0;
}


Measured memory_bytes: 16640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder  = new StringBuilder();
		int i=1;
		while(true){
			int data = Integer.parseInt(reader.readLine());
			if(data==0)
				break;
			builder.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(data)).append("\n");
		}
		System.out.print(builder);
		}
}

Measured memory_bytes: 30476
import math

S = int(input())

ss = int(math.sqrt(S)) + 1
if ss >= int(1E9):
    ss = int(1E9)

x1 = 1
y2 = abs(S-ss**2)
x2 = ss
y1 = ss

print(' '.join([str(a) for a in [0, 0, x1, y1, x2, y2]]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int dp[maxn];
int a[maxn];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for (int i = 3; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 1024
n = int(input())
P = tuple(map(str, input().split()))
Q = tuple(map(str, input().split()))

l = []
for i in range(1, n+1):
	l.append(str(i))
	
import itertools
count = 0
for x in itertools.permutations(l):
	if x == P:
		p = count
	if x == Q:
		q = count
	count += 1
	
print(abs(p-q))

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[100001],B[100001];
	vpll C;
	ll ans=0;
	scan(N);
	rep(i,N){
		scan(A[i]);scan(B[i]);
		C.push_back(mp(A[i]+B[i],i));
	}
	sort(C.rbegin(),C.rend());
	rep(i,N){
		if(i%2==0) ans+=A[C[i].second];
		else ans-=B[C[i].second];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 3444
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    int a, b;
    cin >> a >> b;
    int x = a*b;
    if (x % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;

    return 0;
}



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

using namespace std;
long long abc(int n){
    long long a = n;
    a *= n+1;
    a>>=1;
    return a;
}
long long arr[10000001];
long long arr2[10000001];
int main()
{
   long long  n,m,k;
   int count = 0;
   cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        arr[i] += arr[i-1];
    }
    for(int i = 1; i <= m; i++){
        cin >> arr2[i];
        arr2[i] += arr2[i-1];
    }
    int p2 = m;
    int ans = 0;
    for (int p1 = 0; p1 <= n; p1++){
        while(arr[p1]+arr2[p2] > k && p2 > 0) p2--;
        if(arr[p1]+arr2[p2] <= k){
            ans = max(ans,p1+p2);
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int N = (int) 1e5;
vector<int> graph[N];

int dfs(int u, int par) {
	int sum = 0;
	for (auto v : graph[u]) if (v != par) {
		int x = dfs(v, u);
		if (x == 2) return 2;
		sum += x;
	}
	if (sum > 1) return 2;
	if (sum == 1) return 0;
	return 1;
}

int main() {
	int n; cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v; --u; --v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	cout << (dfs(0, -1) != 0 ? "First" : "Second") << endl;
	return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 
 
// Debug //
 
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
// Constants //
 
 
/*** Template Ends ***/
ll cache[1005][1005];
char a[1005][1005];
ll n,m;
bool isvalid(ll i,ll j)
{
  return (i>=1 && i<=n && j>=1 && j<=m && a[i][j]=='.');
}

ll paths(ll x, ll y)
{
  if(x==1 && y==1)
    return 1;
  if(cache[x][y]!=-1)
    return cache[x][y];
  cache[x][y]=0;
  if(isvalid(x-1,y))
  {
    cache[x][y] += paths(x-1,y);
    cache[x][y]%=hell;
  }
  if(isvalid(x,y-1))
  {
    cache[x][y]+= paths(x,y-1);
    cache[x][y]%=hell;
  }
  return cache[x][y];
}
void solve()
{
  cin>>n>>m;
  ll i,j;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      cin>>a[i][j];
      cache[i][j]=-1;
    }
  }
  cout<<paths(n,m);         
}
 
int main(){ 
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
 
  return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxval = 1'000'00;

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; ll wmax;
    cin >> n >> wmax;
    ll w[n+1], v[n+1];
    for (int i = 1; i <= n; ++i)
        cin >> w[i] >> v[i];
    ll dp[n+1][maxval+1];
    for (ll val = 1; val <= maxval; ++val)
        dp[0][val] = LLONG_MAX - 2'000'000'000;
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (ll val = 0; val < v[i]; ++val)
            dp[i][val] = dp[i-1][val];
        for (ll val = v[i]; val <= maxval; ++val)
            dp[i][val] = min(dp[i-1][val], dp[i-1][val-v[i]] + w[i]);
    }
    ll ans = 0;
    for (ll val = 0; val <= maxval; ++val)
        if (dp[n][val] <= wmax)
            ans = max (ans, val);
    cout << ans;
    return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define MAX int(2*10e5)
#define ll long long int
using namespace std;

int main(){
	vector<ll> sieve(MAX+1,true);
	int n; cin>>n;
	vector<ll> arr(n+1,0); vector<ll> freq(MAX+1,0);
	for(int i=1;i<=n;i++){ cin>>arr[i]; freq[arr[i]]+=1; }
	
	sort(arr.begin(),arr.end());
	ll end = arr[n-1];
	for(int i=1;i<=n;i++){
  		int curr = arr[i];
    	if(sieve[curr]==false){freq[curr]=0; continue;}
    	
      	for(ll j=2; j*curr<=MAX; j++){ sieve[curr*j]=false; }
      	if(freq[curr]>1) sieve[curr]=false;
      	freq[curr]=0;
    }
  ll count=0;
  for(int i=1;i<=n;i++){if(sieve[arr[i]]==true)count++;}
  cout<<count<<endl;
}


Measured memory_bytes: 35972
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
using namespace std;

int main() {
	int ans1 = 0, ans2 = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] - '0' != i % 2) ans1++;
		if (s[i] - '0' != (i + 1) % 2) ans2++;
	}
	cout << min(ans1, ans2) << endl;
  	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{

   int a;
   int b;
   int c;
   int d;
	//1 <= a;
	//b <= 100;


   scanf("%d %d", &a, &b);
   
   c =a*b;
	d =2*(a+b);
   
   
   printf("%d %d\n" , c,d);
   
   return 0;
   }


Measured memory_bytes: 2576
#include <stdio.h>

int main(){
    char s[10];
    int i, cnt = 0, max = 0;

    scanf("%s", &s);

    i = 0;
    while(s[i] != '\0'){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt++;
            if(cnt > max)
                max = cnt;
        }
        else{
            cnt = 0;
        }
        i++;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define MAX3(a, b, c) MAX(MAX(a, b), c)
#define MIN3(a, b, c) MIN(MIN(a, b), c)
#define SORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_a - *(t *)_b; } _f; }))
#define RSORT(t, a, n) qsort(a, n, sizeof(t), ({ int _f (const void *_a, const void *_b) { return *(t *)_b - *(t *)_a; } _f; }))
#define SUM(a, n) ({ ll _s = 0; REP(_i, n) _s += a[_i]; _s; })
#define PROD(a, n) ({ ll _p = 1; REP(_i, n) _p *= a[_i]; _p; })
#define CNT(x, a, n) ({ ll _c = 0; REP(_i, n) if (a[_i] == x) _c++; _c; })
#define MAXM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MAX(_m, a[_i]); _m; })
#define MINM(t, a, n) ({ t _m = a[0]; REP(_i, n) _m = MIN(_m, a[_i]); _m; })
#define INF 1073709056
#define LLINF 4611686016279904256LL
typedef long long ll;

int main() {
    int n;
    scanf("%d", &n);
    char s[100];
    scanf("%s", s);
    int len = strlen(s);
    int l = 0, ml = 0, r = 0, mr = 0;
    REP(i, len) {
        if (s[i] == ')') l++; else l--;
        ml = MAX(ml, l);
    }
    RREP(i, len) {
        if (s[i] == '(') r++; else r--;
        mr = MAX(mr, r);
    }
    REP(i, ml) putchar('(');
    printf(s);
    REP(i, mr) putchar(')'); 
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 11;
    for (ll i=1; i<=sqrt(n); i++){
        if(n%i==0){
            ll ot = n/i;
            ll cnt = 0;
            while(ot>0){
                ot /= 10;
                cnt++;
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, A, B= map(int, input().split())

# 1以上N以下の整数のリスト
target_list = range(1, N+1)
# print(target_list)

# nについて各桁の総和のリストを返す
def sum_each_digit(n):
    return sum(list(map(int,str(n))))

digit_sum_list = list(map(sum_each_digit,target_list))
# print(digit_sum_list)

# A以上B以下はTrue、それ以外はFalse
def A_more_B_less(x, a, b):
    return (a <= x and x <= b) if True else False

bool_list = list(map(lambda x: A_more_B_less(x, A, B), digit_sum_list))
# print(bool_list)

# 総和を求める
combined = [x * y for (x, y) in zip(target_list, bool_list)]
# print(combined)

ans = sum(combined)
print(ans)


Measured memory_bytes: 3572
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    char c;
    cin >> c;
    if (c >= 'a' and c <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif


    return 0;
}

Measured memory_bytes: 3568
da = list(map(int,input().split()))
k = []
while sum(da) != 0:
	for i in range(da[0]):
		k.append(int(input()))
	for i in range(da[0]):
		k[da[0] - 1 -i] = k[da[0] - 1 -i] - k[da[0]-2 -i]


	pp = k[da[1]:da[2]+1]
	qq = min(pp)

	for i in range(len(pp)):
		if pp[i] == qq:
			jj = i

	print(da[1]+jj)

	da = list(map(int,input().split()))
	k = []


Measured memory_bytes: 5612
#include<cstdio>

int main(){
	int dice1[6], dice2[6], tmp[6];
	int pt[5][6] = {	{5,1,3,4,6,2}, 
				 	{0,0,0,0,0,0},
					{4,2,1,6,5,3},
					{2,6,3,4,1,5},
					{3,2,6,1,5,4}};
	int t[24] = {0,0,0,2,0,0,0,2,0,0,0,4,0,0,0,4,0,0,0,2,0,0,0,0};
	for(int i = 0; i < 6; i++){
		scanf("%d", &dice1[i]);
     }
	for(int i = 0; i < 6; i++){
		scanf("%d", &dice2[i]);
	}
	int x;
	for(int i = 0; i < 24 ; i++){
		int c = 0;
		while(!(dice1[c] - dice2[c])){
			c++;
			if(c == 6){
				printf("Yes\n");
				return 0;
			}
		}
		for(int j = 0; j < 6; j++){
			tmp[j] = dice1[j];
		}
		for(int j = 0; j < 6; j++){
			x = pt[t[i]][j];
			dice1[j] = tmp[x - 1];
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
char s[100001],s1[100001];
int main(){
    cin>>s>>s1;
	if(strlen(s)!=strlen(s1)) puts("NO");
    else{
    	reverse(s1,s1+strlen(s1));
    	if(!strncmp(s,s1,strlen(s))) puts("YES");
    	else puts("NO");
	}
}

Measured memory_bytes: 256
N = int(input())

L = list(map(int, input().split()))

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,N):
        while (k<N and L[i] + L[j] > L[k]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)



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

int main()
{
    ll n, h, w;
    cin >> n >> h >> w;
    ll ans = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if(a >= h && b >= w) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> fl(N);
  for(int i=0;i<N;i++){
    cin >> fl.at(i);
  }
  int ans=fl.at(0);
  if(N==1){
    cout << ans << endl;
    return 0;
  }
  for(int i=1;i<N;i++){
    if(fl.at(i-1)<fl.at(i)){
      ans+=fl.at(i)-fl.at(i-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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>
#include<cassert>
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)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	lint n;cin>>n;
	lint out=n-1;
	REP(i,1,1001001){
		if(n%i>0) continue;
		out=min(out,i+n/i-2);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
   int a,b;
   scanf("%d %d",&a,&b);
   if(a < b)
   {
      printf("a < b\n",a,b);
   }
   if(a > b)
   {
      printf("a > b\n");
   }
   if(a == b)
   {
      printf("a == b\n",a,b);
   }
   return 0;
}

Measured memory_bytes: 580
#%%
n, k = map(int, input().split())
reach = [[] for _ in range(n)]
mod = 10**9 + 7
for i in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    reach[a].append(b)
    reach[b].append(a)

def kai(i, j, mod):
    tmp = 1
    for x in range(i, i-j, -1):
        tmp *= x
        tmp %= mod
    return tmp

def dfs(st, n, k, reach, mod):
    check = [0] * n
    stack = [st]
    ans = k
    check[st] = 1
    while len(stack) > 0:
        tmp = stack.pop(-1)
        tmp_list = reach[tmp]
        alredy = 1
        yet = 0
        for i in tmp_list:
            if check[i] != 1:
                stack.append(i)
                check[i] = 1
                yet += 1
            else:
                alredy += 1
        t = kai(k-alredy, yet, mod)
        ans *= t
        ans %= mod
    return ans

ans = dfs(0, n, k, reach, mod)
print(ans)

Measured memory_bytes: 23632
/* 
 * Project: AtCoder Beginners Contest 160 B - Golden Coins
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/15
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#pragma GCC optimize("Ofast")
#include <cstdio>
using namespace std;

void solve(int x) {

    int div_500 = 0;
    int div_5 = 0;

    div_500 = x / 500;
    div_5 = (x - 500 * div_500)/5;

    printf("%d\n",div_500 * 1000 + div_5 * 5);

}

int main() {

    int x;

    scanf("%d",&x);

    solve(x);

}

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

int main( )
{
	int n, y, m, d, total;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> y>> m >> d;
		total = 0;
		//1年1月1日から誕生年の前年までの日数
		for (int j = 1; j < y; j++){
			if(j % 3 == 0)
				total += 20 * 10;
			else
				total += 20 * 5 + 19 * 5;
		}
		//誕生年までの日数
		if(y % 3 == 0){
			total += (m - 1) * 20 + d;
		}
		else{
			for(int j = 1; j < m; j++){
				if(j % 2 == 0)
					total += 19;
				else 
					total += 20;
			}
			total += d;
		}
		cout << 196471 - total << endl;
			
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(',');

            var aaa = string.Join(" ", str);

            Console.WriteLine(aaa);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <iostream>
using namespace std;

double l, h, mx = 0;

int main()
{
  cin >> l;
  for (h = 0; h < l; h += 0.0001)
  {
    mx = max(mx, (h * h * h - 2 * l * h * h + l * l * h) / 4);
  }
  cout << fixed << setprecision(15) << mx << endl;
  return 0;
}

Measured memory_bytes: 256