akhauriyash/Code-Regression huggingface dataset:
/**
* @author khokharnikunj8
**/
#include <bits/stdc++.h>

using namespace std;

//macros
#define ll long long
#define endl "\n"
#define pb push_back

//debug

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }


template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}







Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << endl
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
int f1(int a, int p) {
	if (p == 1)return a;
	if (p % 2)return f1(a, p - 1) * a % mod;
	else return f1(a * a % mod, p / 2) % mod;
}
int n, a[123456], ans = 1, k;
signed main() {
	cin >> n;
	for1(i, n) {
		cin >> a[i];
		if ((a[i] + 1) / 2 < i - k)
			ans = ans * (i - k++) % mod;
	}
	for1(i, n - k) { ans *= i; ans %= mod; }
	puts(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int a,b,c,d;
  while (cin >> a >> b >> c >> d){
    cout << min(a,b) + min(c,d) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <list>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <random>
#include <queue>
#include <fstream>
#include <iterator> // std::back_inserter
#include <chrono>
#include <string>

using namespace std;

int N, Q;
vector<pair<char, char>> spel;
vector<char> mp;

int check_over(int n)
{
    int now = n;

    for (unsigned int i = 0; i < spel.size(); i++)
    {
        if (mp[now] == spel[i].first)
        {
            if (spel[i].second == 'R')
                now += 1;
            else
                now -= 1;

            if (now == -1)
                break;
            if (now == N)
                break;
        }
    }

    return now;
}

int main(int argc, char *argv[])
{

    cin >> N >> Q;

    char a, b;

    for (int i = 0; i < N; i++)
    {
        cin >> a;
        mp.push_back(a);
    }

    for (int i = 0; i < Q; i++)
    {
        cin >> a >> b;
        spel.push_back(make_pair(a, b));
    }

    int c, d, d2 = 1;
    d = 1;

    int n = -1, m = N;

    while (n + 1 < m)
    {
        c = (n + m) / 2;
        d = check_over(c);
        if (d == -1)
            n = c;
        else 
            m = c;
    }

    c = m;

    int c2;

    n = -1;
    m = N;

    while (n + 1 < m)
    {
        c2 = (n + m) / 2;
        d = check_over(c2);
        if (d == N)
            m = (n + m) / 2;
        else
            n = (n + m) / 2;
    }
    c2 = m;

    int ans;

    ans = N - c - (N - c2);
    cout << ans;

    return 0;
}

Measured memory_bytes: 1020
n = int(input())
lst = [input() for _ in range(n)]

finA = 0
topB = 0
BtoA = 0
cnt = 0
for l in lst:
    cnt += l.count('AB')
    if l[0]=='B' and l[-1]=='A':
        BtoA += 1
    else:
        if l[0]=='B':
            topB += 1
        elif l[-1]=='A':
            finA += 1

if BtoA==0:
    cnt += min(finA, topB)
else:
    if finA==0 and topB==0:
        cnt += BtoA - 1
    else:
        cnt += BtoA + min(finA, topB)
print(cnt)

Measured memory_bytes: 3700
let solve ans w v =
  let rec duduwa ans j k = function
    | [] -> doit ans (j + 1, [(v.(j), k)])
    | (ch, cj) :: y' when ch >= v.(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) j cj y'
    | ys -> doit ans (j + 1, (v.(j), k) :: ys)
  and doit ans = function
    | (j, xs) when j = w -> List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs
    | (j, []) -> doit ans (j + 1, [(v.(j), j)])
    | (j, ((ch, _) :: _ as xs)) when ch = v.(j) -> doit ans (j + 1, xs)
    | (j, ((ch, _) :: _ as xs)) when ch < v.(j) -> doit ans (j + 1, (v.(j), j) :: xs)
    | (j, xs) -> duduwa ans j j xs in
  doit ans (0, [])

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read () = List.map int_of_string (split_on_char ' ' (read_line ()))

let () =
  match read () with
  | [h; w] ->
    let v0 = Array.make w 0 in
    let v1 = Array.make w 0 in
    let rec doit i ans =
      if i = h then ans
      else
        let rec duduwa j = function
          | [] -> Array.iteri (fun i e -> v0.(i) <- e) v1; doit (i + 1) (solve ans w v1)
          | x::xs ->
            v1.(j) <- 1 - x;
            if i <> 0 then v1.(j) <- if v1.(j) = 0 then 0 else v0.(j) + 1;
            duduwa (j + 1) xs in
        duduwa 0 (read ()) in
    Printf.printf "%d\n" (doit 0 0)
  | _ -> ()

Measured memory_bytes: 5100
m,d=map(int,input().split())

cnt=0
if d >=22:
    for i in range(22,d+1):        
        if int(str(i)[1])==1 or int(str(i)[1])==0:
            continue
        else:
            for j in range(1,m+1):
                if int(str(i)[1])*int(str(i)[0])==j:
                    
                    cnt+=1
    print(cnt)
else:
    print("0")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


int main () {
	int num, length;
	cin >> num >> length;

	vector<string> lst(num);
	for (int i = 0; i < num; i++) {
		cin >> lst.at(i);
	}

	sort(lst.begin(), lst.end());

	string concat = "";
	for (int i = 0; i < num; i++) {
		concat += lst.at(i);
	}

	cout << concat << endl;

	return 0;
}

Measured memory_bytes: 256
#1_10_C
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int,input().split()))
    m = sum(s) / len(s)
    a2 = 0
    for i in range(n):
        a2 += (s[i] - m)**2
    a =  math.sqrt(a2  / n)
    print(a)


Measured memory_bytes: 5700
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
/* Uncomment only if you are not using GNU compiler->
#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>
*/ 
using namespace std;

#define endl "\n"
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define re(i,a) for(int i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vi v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(a) int((a).size())
#define dbgv(c, v) cout << c << " = " << v << endl;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef vector< pii > vii;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;

void solve(){
	
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif 
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    
    int n,m;
    cin>>n>>m;
    in(h, n);

    vi adj[n];

    re(i, m){
        int a, b;
        cin>>a>>b;
        --a;
        --b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    int cnt = 0;

    re(i, n){
        bool good = 1;

        for(int v : adj[i]){
            if(h[v] >= h[i]){
                good = 0;
                break;
            }
        }

        if(good) cnt++;
    }

    cout << cnt;

    return 0;
}


Measured memory_bytes: 8760
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
int A[200010];
int sta[1000010],dep[1000010];
bool check(int mid)
{
	int head=0;
	sta[head]=0,dep[head]=0;
	for(int i=1;i<=n;i++)
	{
		if(A[i]>dep[head]){
			head++;
			dep[head]=A[i];
			sta[head]=0;
			sta[head-1]++;
		}
		else{
			while(dep[head]>=A[i])head--;
			int now=A[i]-1;
			while(head>=0&&dep[head]==now&&sta[head]>=mid)
			{
				now--;
				head--;
			}
			if(head<0)return false;
			if(dep[head]!=now){
				head++;
				sta[head]=1;
				dep[head]=now;
			}
			sta[++head]=0;
			dep[head]=A[i];
			sta[head-1]++;
		}
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&A[i]);
		if(A[i]<=A[i-1])flag=false;
	}
	if(flag){
		printf("1\n");
		return 0;
	}
	int l=1,r=n;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

long long a,b,c,cnt;
long long a1,b1,c1;
bool check(){
    return a%2||a%2||c%2;
}

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

    cin>>a>>b>>c;
    while(!check()){
        if(a%2==0&&a==b&&a==c){
            cnt = -1;
            break;
        }
        cnt++;
        a1 = (b+c)/2;
        b1 = (a+c)/2;
        c1 = (b+c)/2;
        a = a1;
        b = b1;
        c = c1;
    }
    cout<<cnt;

    return 0;
}
//1000000000


Measured memory_bytes: 256
<>;$x=$==-1,s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$=*=$&**(-$a%3)/ge,++$h{$x},$$x=$=for`factor`;$\+=$_>-2||$h{$_},$h{$_}=$h{$$_}=0for sort{$h{$b}-$h{$a}}keys%h;print

Measured memory_bytes: 71256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 5010;

int n, f[N][N], ans;
char s[N];

int main()
{
	scanf("%d%s", &n, s + 1);
	
	for (int i = n; i >= 1; --i)
	{
		for (int j = n; j > i; --j)
		{
			if (s[i] == s[j]) f[i][j] = min(f[i + 1][j + 1] + 1, j - i);
			ans = max(ans, f[i][j]);
		}
	}
	
	cout << ans;
	
	return 0;
}


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


int main() {

  int N, k;
  cin >> N >> k;
  vector<char> d(k);
  for (char &i : d)
    cin >> i;
  
  while(1){
    bool flag = 1;
    string s = to_string(N);
    for (int i=0; i<d.size(); i++){
      
      for (auto j : s){
        if (j == d.at(i)){
          flag = 0;
          break;
        }
        if (!flag)
          break;
      }

    }
    if (!flag)
      N++;
    else {
      cout << N;
      break;
    }
  }
    
  
  return 0;
}

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

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

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

  int H1, H0;
  H0 = 0;
  int c=0;
  int maxc=0;
  rep(i,n){
    cin >> H1;
    if(H1<=H0){
      c++;
      if(maxc < c)maxc = c;
    }else{
      c=0;
    }
    H0 = H1;
  }
  cout << maxc << endl;
  return 0;
}

Measured memory_bytes: 256
kx = input()
k = int(kx.split(' ')[0])
x = int(kx.split(' ')[1])

output_list = []

for i in range(1,k):
    output_list.append(x-(k-i))
output_list.append(x)
for i in range(1,k):
    output_list.append(x+i)
print(' '.join(map(str,output_list)))

Measured memory_bytes: 3064
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;
signed main() {
    int K; cin >> K;
    int rec[60], ans[60];
    int div = K / 50, md = K % 50;
    int n=50;
    for(int i=0;i<n;i++){
        rec[i]=div+(i<md);
    }
 
    for(int i=0;i<n;i++){
        int S = 0;
        for(int j=0;j<n;j++) {
            if(i != j) S += rec[j];
        }
        ans[i] = 50 * (rec[i] + 1) - S - 1;
    }

    cout << 50 << endl;
    rep(i,0,50) cout << (i ? " " : "") << ans[i];
    cout << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const int inf = 1 << 20;
const int limit = 1000001;
int dist[limit];

int num[limit];

int main(void) {
	int k;
	cin >> k;

	rep(i, limit) dist[i] = inf;

	rep(i, limit) {
		if (i < 9)
			num[i] = i;
		else
			num[i] = num[i / 10] + i % 10;
	}


	using state = tuple<int,int>;
	priority_queue<state,vector<state>,greater<state>> q;

	for (int i = 1; i <= 9; ++i) {
		dist[k * i] = 0;
		q.push(state(0,k * i));
	}

	while(!q.empty()){
		int val,cur;
		tie(val,cur)= q.top(); q.pop();

		if(dist[cur]<val) continue;

		rep(j, 10) {
			const int tmp = (cur + k * 10 * j);
			const int ncur = tmp / 10;
			const int nval = val + tmp % 10;
			if(chmin(dist[ncur],nval)){
				q.push(state(nval,ncur));
			}
		}
	}


	int ans = inf;
	rep(i,limit) chmin(ans,dist[i] + num[i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 26600
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, H, W): (usize, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (A, B): (Vec<i64>, Vec<i64>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let ans = (0..N).filter(|&i| A[i] >= H && B[i] >= W).count();

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <math.h>
//v.erase(unique(v.begin(),v.end()),v.end());

using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef  pair <ll, ll> pii;
 
const ll N = 200500;
const ll mod = 1e9 + 7;
const ld PI = acos(-1); 



int main() {


	ll n, m;
	cin >> n >> m;
	ll sum = 0;
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		sum += a;
	}

	if(sum > n) cout << -1 << endl;
	else cout << n - sum << endl;
	
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n; cin>>n;
    int a[n+1],b[n];
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll ans=0;
    rep(i,n)
    {
        if(a[i]<b[i])
        {
            if(a[i]+a[i+1]<b[i])
            {
                ans+=a[i]+a[i+1];
                a[i+1]=0;
            }else
            {
                ans+=b[i];
                a[i+1]-=(b[i]-a[i]);
            }
        }else
        {
            ans+=b[i];
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
N, start = [int(x) for x in input().split()]
# N < 10 ** 5
# start < 10 ** 9
# x < 10 ** 9
xs = [int(x) for x in input().split()]
xs.append(start)
xs.sort()
ds = sorted(list({(x1 - x0) for x0, x1 in zip(xs, xs[1:])}), reverse=True)

def gcd(a, b):
    while True:
        r = a % b
        if r == 0:
            return b
        a, b = b, r
        
a = ds[0]
for b in ds[1:]:
    a = gcd(a, b)
print(a)





Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	cin >> N;
	vint a(N);

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

	int tmp = a[0] ^ a[1];

	for (int i = 2; i < N; i++) {
		tmp ^= a[i];
	}

	yn(tmp == 0);

	return 0;
}

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

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap};

// Main
fn main(){
    input!{
        n: i32,
        x: [i32; if n==1{0}else{2}]
    }
    if n==1{
        println!("Hello World");
    }else{
        println!("{}", x[0]+x[1]);
    }
}



Measured memory_bytes: 4352
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 7;

fn main() {
    input! {
        mut s: chars,
    }

    s.reverse();
    let mut dp = vec![vec![0; 13]; s.len() + 1];
    let mut mul = 1;
    dp[0][0] = 1;
    for i in 1..s.len() + 1 {
        if s[i - 1] == '?' {
            for j in 0..13 {
                for k in 0..10 {
                    dp[i][j] += dp[i - 1][(13 + j - k * mul % 13) % 13];
                    dp[i][j] %= M;
                }
            }
        } else {
            let k = s[i - 1] as usize - b'0' as usize;
            for j in 0..13 {
                dp[i][j] += dp[i - 1][(13 + j - k * mul % 13) % 13];
                dp[i][j] %= M;
            }
        }
        mul *= 10;
        mul %= 13;
    }
    println!("{:?}", dp[s.len()][5]);
}


Measured memory_bytes: 18684
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int n;
        scanf("%d", &n);
        V a(n);
        SCAN(a);

        ll l[n+2] = {}, r[n+2] = {};
        REP(i, 1, n+1){
                l[i] = l[i-1] xor a[i-1];
                r[n-i+1] = r[n-i+2] xor a[n-i];
        }
        REP(i, 0, n) printf("%ld ", l[i] xor r[i+2]);
        return 0;
}

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

int main(){
  string S;
  cin>>S;
  for(int i=0;i<S.size()-1;i++)
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>


using namespace std;


long long int gcd(long long int a, long long int b) {

	long long int tmp;

	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r;

	r = a % b;

	while (r != 0) {

		a = b;
		b = r;
		r = a % b;

	}

	return b;
}



int main()
{

	string a;
	string b;


	string a2;

	
	cin >> a;
	cin >> b;
	a2 = a;
	while (true) {
		a = a.substr(a.size() - 1, 1) + a.substr(0, a.size() - 1);



		if (b == a) {
			cout << "Yes" << endl;
			break;
		}
		if (a2 == a) {
			cout << "No" << endl;
			break;

		}
	



	}

	


	return 0;


}



Measured memory_bytes: 256
N = int(input())
row1 = [int(x) for x in input().split()]
row2 = [int(y) for y in input().split()]
candy = row1[0] + sum(row2)
for i in range(2,N+1):
    sub_row1 = row1[0:i]
    sub_row2 = row2[0:i-1]
    con = sum(sub_row1) + sum(row2) - sum(sub_row2)
    # print(sub_row1, sub_row2,con,candy)
    if con > candy:
        candy = con
    # print(candy,con)

print(candy)



Measured memory_bytes: 3060
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var ans = 0;

    for (var i = 1; i <= N; i = i + 2) {
        var count = 0;
        for (var j = 1; j <= i; j++) {
            if (i % j === 0) { count++; }
        }
        if (count === 8) { ans++; }
    }
    console.log(ans);

});

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());

    int64_t ans = 0;
    rep(i, N-1) {
        ans += A[(i+1)/2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import scala.io.StdIn.readInt

object Main {
  def fib(a:Int, b:Int, c:Int, n:Int):Int = {
    n match {
      case 0 => a
      case n => fib(a+b, a, b, n-1)
    }
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, 0, n))
  }
}

Measured memory_bytes: 43648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
        int x = (int)Math.ceil((double)c / b);
        System.out.println(d * (x - 1) < a ? "Yes" : "No");
    }
}


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

using ll=long long;
const ll MOD=998244353LL;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<int> r(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
        if(s[i]=='0') r[i]=2;
        else if(s[i]=='1') r[i]=b[i]=1;
        else b[i]=2;
    }

    vector<ll> sumr(n+1);
    vector<ll> sumb(n+1);
    for(int i=0;i<n;i++){
        sumr[i+1]=sumr[i]+r[i];
        sumb[i+1]=sumb[i]+b[i];
    }
    vector<vector<ll>> dp(2*n+1,vector<ll>(2*n+1));
    dp[0][0]=1;
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            if(sumr[min(i+j+1,n)]>=i+1){
                dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            }
            if(sumb[min(i+j+1,n)]>=j+1){
                dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MOD;
            }
        }
    }
    
    cout<<dp[sumr[n]][sumb[n]]<<endl;
    return 0;
}

Measured memory_bytes: 125568
#include<stdio.h>

int main(void) {
   int a, b, i;
   char op;

   for(i = 1; i>0; i++){
   scanf("%d %c %d", &a, &op, &b);
   if(op == '+') printf("%d\n", a+b);
   else if(op == '-') printf("%d\n", a-b);
   else if(op == '*') printf("%d\n", a*b);
   else if(op == '/') printf("%d\n", a/b);
   else if(op =='?') break;
   }
   return 0;
}



Measured memory_bytes: 2756
#include <iostream>

using namespace std;

int main()
{
	int n1, n2, s;

	while (cin >> n1 >> n2) {
		int cnt = 0;
		for (s = n1 + n2; s > 0; s /= 10) {
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
x = list(map(int, input().split()))

MOD = 10 ** 9 + 7

class ModInv:
    def __init__(self, size, MOD):
        self.inv = [0] * (size + 1)
        self.inv[1] = 1
        for i in range(2, size + 1):
            self.inv[i] = (-(MOD // i) * self.inv[MOD%i]) % MOD

inv = ModInv(n, MOD)

#print(inv.inv)

b = 1
for i in range(1, n):
    b = (b * i) % MOD

ans = 0
temp = 0
for i in range(1, n):
    temp += inv.inv[i]
    ans += (x[i] - x[i-1]) * temp
    ans %= MOD

print((ans * b) % MOD)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define getcode(i,j) (((i)>>(j))&1)
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int>pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;

#define ls (t<<1)
#define rs ((t<<1)|1)
namespace sgt
{
	int mx[1100111],delta[1100111];
	void clear()
	{
		memset(mx,0,sizeof(mx));
		memset(delta,0,sizeof(delta));
	}
	void pushdown(int t)
	{
		mx[ls]+=delta[t];delta[ls]+=delta[t];
		mx[rs]+=delta[t];delta[rs]+=delta[t];
		delta[t]=0;
	}
	void add(int l,int r,int v,int tl,int tr,int t)
	{
//		if(t==1)printf("add %d %d v= %d\n",l,r,v);
		if(l<=tl&&tr<=r)
		{
			mx[t]+=v;delta[t]+=v;
			return;
		}
		pushdown(t);
		int mid=(tl+tr)>>1;
		if(l<=mid)add(l,r,v,tl,mid,ls);
		if(r>mid)add(l,r,v,mid+1,tr,rs);
		mx[t]=max(mx[ls],mx[rs]);
	}
	int query(int l,int r,int tl,int tr,int t)
	{
		if(l<=tl&&tr<=r)return mx[t];
		pushdown(t);
		int mid=(tl+tr)>>1,ret=-inf;
		if(l<=mid)ret=max(ret,query(l,r,tl,mid,ls));
		if(r>mid)ret=max(ret,query(l,r,mid+1,tr,rs));
		return ret;
	}
};

int w,h,n,ans;
pii p[300111];

vector<int>vs;
int getid(int x){return lower_bound(vs.begin(),vs.end(),x)-vs.begin();}

pii stk[300111],stk2[300111];
int tp,tp2;

void solve()
{
	sgt::clear();vs.clear();
	sort(p+1,p+n+1);
	
	for(int i=1;i<=n;i++)vs.pb(p[i].ff);
	vs.pb(0);vs.pb(-inf);
	sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
	int m=(int)vs.size()-1;
	
//	for(int i=1;i<=n;i++)printf("i= %d p= %d %d id= %d\n",i,p[i].ff,p[i].ss,getid(p[i].ff));
	tp=tp2=0;stk[++tp]=mp(0,h/2);stk2[++tp2]=mp(0,h/2+1);
	for(int i=1,nxt=1;i<=n;i=nxt)
	{
		for(;nxt<=n&&p[i].ff==p[nxt].ff;nxt++);
		int id=getid(p[i].ff);
		ans=max(ans,p[i].ff+h+sgt::query(1,id-1,1,m,1));
		int piv=0,piv2=0;
		for(int j=i;j<nxt;j++)
		{
			if(p[j].ss<=h/2)piv=j;
			else if(!piv2)piv2=j;
			else break;
		}
		
		sgt::add(id,id,-vs[id],1,m,1);
		if(piv)
		{
			sgt::add(getid(stk[tp].ff),id-1,-p[piv].ss,1,m,1);
			while(stk[tp].ss<p[piv].ss)
			{
				sgt::add(getid(stk[tp-1].ff),getid(stk[tp].ff)-1,stk[tp].ss-p[piv].ss,1,m,1);
				tp--;
			}
			stk[++tp]=p[piv];
		}
		if(piv2)
		{
			sgt::add(getid(stk2[tp2].ff),id-1,(p[piv2].ss-h),1,m,1);
			while(stk2[tp2].ss>p[piv2].ss)
			{
				sgt::add(getid(stk2[tp2-1].ff),getid(stk2[tp2].ff)-1,(p[piv2].ss-stk2[tp2].ss),1,m,1);
				tp2--;
			}
			stk2[++tp2]=p[piv2];
		}
	}
	ans=max(ans,w+h+sgt::query(1,m,1,m,1));
}
int main()
{
	scanf("%d%d%d",&w,&h,&n);
	int nn=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].ff,&p[i].ss);
		if(p[i].ff>0&&p[i].ff<w&&p[i].ss>0&&p[i].ss<h)p[++nn]=p[i];
	}
	n=nn;
	
	solve();
	
	swap(w,h);
	for(int i=1;i<=n;i++)swap(p[i].ff,p[i].ss);
	solve();
	
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 15728
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ar%=a;
  br%=b;
  ll ret=(ar+  ( (br-ar)%b*(moddiv(1,a,b)%b) +b )%b *a);
  return ret;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0)-1;
        ll ans1=garner2(val0,val1,0,1)-1;
        //ans0%=val0*val1;
        //ans1%=val0*val1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


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

Measured memory_bytes: 7076
# input
N = int(input())
S = [input() for _ in range(N)]

# process
T = []
for s in S:
    while '()' in s:
        s = s.replace('()', '')
    T.append(s)

l1 = []
l2 = []
for t in T:
    op = t.find('(')
    if op < 0:
        op = len(t)
    cl = len(t) - op
    
    if cl+op != 0:
        if cl <= op:
            l1.append((cl, op))
        else:
            l2.append((op, cl))

l1.sort()
l2.sort(reverse=True)

result = False
x = 0
if len(l1)+len(l2) == 0:
    result = True
elif len(l1)>0 and len(l2)>0 and l1[0][0]+l2[-1][0] == 0:
    for cl, op in l1:
        x -= cl
        if x < 0:
            break
        x += op
    
    if x >= 0:
        for op, cl in l2:
            x -= cl
            if x < 0:
                break
            x += op
            
        if x == 0:
            result = True

# output
print("Yes" if result else "No")


Measured memory_bytes: 95736
package main

import (
	"fmt"
	"math"
)

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

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

	a := make([]int, n+1)
	for i := 0; i <= n; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&b[i])

		l := min(a[i], b[i])
		cnt += l
		a[i] -= l
		b[i] -= l

		r := min(a[i+1], b[i])
		cnt += r
		a[i+1] -= r
		b[i] -= r
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1]<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  string A, B;
  cin >> A >> B;
  int X = stoi(A + B);
  if (X == floor(sqrt(X)) * floor(sqrt(X))) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	static long mod = (long)(1e9+7);
	public static void main(String[] args) { //Ball out 
		/*
		 * */
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int S = I.nextInt();
		long[] dp = new long[S+1];
		dp[0]=1;
		for (int sum = 1; sum<=S; sum++) {
			for (int prev = 3; prev<=S; prev++) {
				if (sum-prev>=0) dp[sum]+=dp[sum-prev];
				dp[sum]%=mod;
			}
		}
		O.pln(dp[S]);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25688
#include <iostream>
#include <vector>

using namespace std;


int main(void) {
    int n;
    cin >> n;

    vector<int> a;
    int accum_xor = 0;

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

        a.push_back(e);
        accum_xor ^= e;
    }
    
    for (int i = 0; i < n - 1; i++) {
        cout << (accum_xor ^ a[i]) << " ";
    }
    cout << (accum_xor ^ a[n - 1]) << endl;

    return 0;
}


Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> c(n),s(n),f(n);
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
  rep(i,n-1){//スタート地点がi 0-index
    int seek = i;
    int time = 0;
    while(seek<n-1){//シークバーがn-1を超えるまで
      time = max(time,s[seek]);
      while(time%f[seek]) time ++;
      time += c[seek];
      seek ++;
    }
    cout << time << endl;
  }
  cout << 0 << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int K[50],A[50][50];
  for(int i=1;i<=N;i++){
    cin >> K[i];
    for(int j=1;j<=K[i];j++){cin >> A[i][j];}
  }
  int ans=0;
  for(int i=1;i<=M;i++){
    int w=0;
    for(int j=1;j<=N;j++){
      bool q=false;
      for(int k=1;k<=K[j];k++){
        if(A[j][k]==i){q=true;}
      }
      if(q){w++;}
    }
    if(w==N){ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8

N, A, B, C = int(input()), input(), input(), input()
cnt = 0
for i in range(N):
    if A[i] == B[i] and A[i] == C[i]:
       pass
    elif (A[i] == B[i] and A[i] != C[i]) or (A[i] == C[i] and A[i] != B[i]) or (B[i] == C[i] and A[i] != B[i]):
        cnt += 1
    else:
        cnt += 2
print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 10000000
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int a;
	cin >> a;
	cout << 3 * a * a << endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8  as C
import Data.List

main = sol <$> get >>= print

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines <$> C.getContents

sol [[_,a,b],xs] = sum . fmap (min b . (*a)) $ zipWith (-) (tail xs) xs


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

namespace ConsoleApp2
{


    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] nString = Console.ReadLine().Split(' ');

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                int n = int.Parse(nString[i]);
                if (n == count + 1) count = n;
            }

            

            if(count!=0)Console.WriteLine(N-count);
            else Console.WriteLine(-1);
            Console.ReadLine();

        }

        private static int[] Read(string input)
        {
            string[] strings = input.Split(' ');
            int num = strings.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(strings[i]);
            }
            
            return ints;
        }


    }


}


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

int main(){
    string s;
    cin >> s;
    vector<bool> ex(26, false);
    for(int i=0; i<(int)s.length(); i++){
        ex[s[i]-'a']=true;
    }
    bool all=true;
    for(int i=0; i<26; i++){
        if(!ex[i]){
            all=false;
            cout << (char)(i+'a') << endl;
            break;
        }
    }
    if(all){
        cout << "None" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <sstream>
#include <iterator>
#include <iostream>
#include <vector>
 
 
using namespace std;
 
int main()  {
  int a, b, c;
  int i,j;
  int ans;
  ans = 0;
  i = 0;
  j = 0;
  // 空白文字で区切られた数字を 3 つ取得
  std::cin >> a >> b >> c;
  //std::vector<int> v(2);
  
  i = b;
  j = c;
  if(a>=c){
	ans = c+b;
  }
  else if(b>=c-a){
	ans = c+b;
  }
  else{
	ans = 2*b + a + 1;
  }
  printf("%d\n",ans);
  
}

Measured memory_bytes: 256