akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 3000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
ll arr[N], n, mem[N][N][2];
ll solve(int i, int j, bool state) {
	if (i > j)return 0;
	ll& ret = mem[i][j][state];
	if (~ret)return ret;
	if (state) {
		ret = solve(i + 1, j, !state) + arr[i];;
		ret = max(ret, solve(i, j - 1, !state) + arr[j]);
	}
	else {
		ret = solve(i + 1, j, !state) + -arr[i];;
		ret = min(ret, solve(i, j - 1, !state) + -arr[j]);
	}

	return ret;
}
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	clr(mem, -1);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cout << solve(0, n - 1, 1);
}


Measured memory_bytes: 144964
import java.util.Scanner;

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

	void solve(Scanner sc) {
		int N = sc.nextInt();
		String[] s = sc.next().split("");

		int R = 0;
		int B = 0;

		for (int i = 0; i < N; i++) {
			if (s[i].equals("R")) {
				R++;
			} else {
				B++;
			}
		}

		if (R > B) {
			System.out.println("Yes");

		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		char[] str = scan.next().toCharArray();

		String result = "No";
		if (str[2] == str[3] && str[4] == str[5]) {
			result = "Yes";
		}

		System.out.println(result);
	}
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

struct Trie {
	bool f;
	Trie *par;
	Trie *next[2];
	Trie() { f = 0, par = (Trie*)0, fill(next, next+2, (Trie*)0); }
};

Trie *ins(string t, Trie *r) {
	for (int i = 0; i < t.size(); ++i) {
		int c = t[i]-'0';
		if (!r->next[c]) r->next[c] = new Trie;
		r->next[c]->par = r;
		r = r->next[c];
		r->f = 1;
	}
	return r;
}

int N;
ll L;
string s[100010];
Trie *p[100010];

ll get_grundy(ll dep)
{
	ll c = 1;
	while (dep % 2 == 0) {
		dep /= 2;
		c *= 2;
	}
	return c;
}

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

	Trie *r = new Trie();

	rep(i, N) {
		cin >> s[i];
		p[i] = ins(s[i], r);
	}

	ll xo = 0;
	rep(i, N) {
		Trie *cur = p[i];
		int id = s[i].size()-1;

		while (true) {
			cur = cur->par;
			int c = s[i][id]-'0';
			if (!cur->next[c^1] || cur->next[c^1]->f == 0) {
				if (!cur->next[c^1]) {
					cur->next[c^1] = new Trie();
					cur->next[c^1]->f = 1;
				}
				xo ^= get_grundy(L-id);
				//cout<<get_grundy(L-id)<<endl;
			}

			if (cur == r) {
				break;
			}		
			--id;
		}
	}

	puts(xo != 0 ? "Alice" : "Bob");
	
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int x, y;
  cin >> x >> y;

  for (int i = 0; i <= x; i++) {
    if (i * 2 + (x-i) * 4 == y) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");

  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long int w,h;
long long int ans=1e18;
int main()
{
	cin>>h>>w;
	for(long long int i=1;i<=w;++i){
		long long int s1=i*h,s2,s3;
		long long int remain=w-i;
		if(h%2==0||remain%2==0){
			s2=h*remain/2;
			s3=s2;
		}
		else{
			if(remain<h){
				s2=remain*(h-1)/2;
				s3=remain*(h+1)/2;
			}
			else{
				s2=h*(remain-1)/2;
				s3=h*(remain+1)/2;
			}
		}
		ans=min(ans,max(max(abs(s2-s1),abs(s2-s3)),abs(s3-s1)));
	}
	for(long long int i=1;i<=h;++i){
		long long int s1=i*w,s2,s3;
		long long int remain=h-i;
		if(w%2==0||remain%2==0){
			s2=w*remain/2;
			s3=s2;
		}
		else{
			if(remain<w){
				s2=remain*(w-1)/2;
				s3=remain*(w+1)/2;
			}
			else{
				s2=w*(remain-1)/2;
				s3=w*(remain+1)/2;
			}
		}
		ans=min(ans,max(max(abs(s2-s1),abs(s2-s3)),abs(s3-s1)));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k;
	long long mod=1e9+7;
	cin>>n>>k;
	long long a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	long long s1[n+1]={0},s2[n+1]={0};
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i]<a[j])
			{
				s1[j]++;
				if(i<j)
				{
					s2[j]++;
				}
			}
		} 
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=(((k%mod)*((k+1)%mod)/2%mod)*s1[i]%mod-s2[i]*k%mod+ans)%mod;
		if(ans<0)
		{
			ans+=mod;
		}	
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int main() {
	int a,b;
	int c,d;
	scanf("%d%d", &a, &b);
	scanf("%d%d", &c, &d);
	if (a!=c) cout <<1<<endl;
	else cout <<0<<endl;
	return 0;
}

Measured memory_bytes: 256
a, v = map(int,input().split())
b, w = map(int,input().split())
T = int(input())

if a<b:
    A = a + v * T
    B = b + w * T
    if A>= B:
        print("YES")
    else:
        print("NO")
else:
    A = a - v*T
    B = b - w * T
    if A <= B:
        print("YES")
    else:
        print("NO")



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

int main(){
	int s[3];
	cin >> s[0] >> s[1] >> s[2];
	sort(s, s + 3);
	cout << s[2] * 10 + s[1] + s[0] << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    // ( x1, y1 ) = ( 0, 0 ) に移動したときの ( x2, y2 ) を求める
    int vx2 = x2 - x1,
        vy2 = y2 - y1;
    
    int x4 = 0 - vy2 + x1,
        y4 = vx2 + y1;
    
    cout << x4 + vx2 << " " << y4 + vy2 << " " << x4 << " " << y4 << endl;
    return 0;
}

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

#define EPS (1e-10)
typedef complex<double> Po;

double cross(Po x,Po y){return x.real()*y.imag() - x.imag()*y.real();}

double area(Po a,Po b,Po c){return abs(cross(b-a,c-a)/2);}

bool inter(Po a,Po b,Po c,Po x){
  if(abs( area(a,b,c) ) < EPS)return false;
  if( area(a,b,x) + area(b,c,x) + area(c,a,x) > area(a,b,c) + EPS)return false;
  else return true;
}

int main(void){
  int i,j,k,l;
  int n;
  int ans;
  bool use[100];
  Po p[100];

  while(1){
    scanf(" %d ",&n);
    if(!n)break;

    for(i=0;i<n;i++){
      scanf(" %lf,%lf ",&p[i].real(),&p[i].imag());
      use[i] = false;
    }

    ans = 0;
    for(i=0;i<n-3;i++){
      for(j=i+1;j<n-2;j++){
	for(k=j+1;k<n-1;k++){
	  for(l=k+1;l<n;l++){
	    if(!use[l]){
	      if(inter(p[i],p[j],p[k],p[l])){
		ans++;
		use[l] = true;
		//cout << i << " " << j << " " << k << " " << l << endl;
		//cout << p[l].real() << " " << p[l].imag() << endl;
	      }
	    }
	    if(!use[k]){
	      if(inter(p[i],p[j],p[l],p[k])){
		ans++;
		use[k] = true;
		//cout << i << " " << j << " " << k << " " << l << endl;
		//cout << p[k].real() << " " << p[k].imag() << endl;
	      }
	    }
	    if(!use[j]){
	      if(inter(p[i],p[l],p[k],p[j])){
		ans++;
		use[j] = true;
		//cout << i << " " << j << " " << k << " " << l << endl;
		//cout << p[j].real() << " " << p[j].imag() << endl;
	      }
	    }
	    if(!use[i]){
	      if(inter(p[l],p[j],p[k],p[i])){
		ans++;
		use[i] = true;
		//cout << i << " " << j << " " << k << " " << l << endl;
		//cout << p[i].real() << " " << p[i].imag() << endl;
	      }
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>

using namespace std;

void solve(){
    int a, b;
    cin >> a >> b;
    if(a != 1 && b != 1){
        cout << 1;
    } else if (a != 2 && b != 2){
        cout << 2;
    } else if (a != 3 && b != 3){
        cout << 3;
    }
    cout << endl;
    
}

int main() {
    solve();
    return 0;
}

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


def solve(N: int, a: "List[int]"):
    if 1 not in a:
        print(-1)
        return
    ans = 0
    nxt = 1
    for i in range(N):
        if a[i] == nxt:
            nxt += 1
        else:
            ans += 1
    print(ans)
    return


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 25984
//Optimisation Flags
#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC optimize("Ofast")

#include   <bits/stdc++.h>
//#include   <ext/pb_ds/assoc_container.hpp>
//#include   <ext/pb_ds/tree_policy.hpp>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    itn              unsigned long long int
#define    db               long double
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    rall(v)          v.rbegin(),v.rend()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(a)            (int)a.size()
#define    erase(vec,val)   vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end()); //deleting specific value element in vector
#define    PI               (db)3.141592653589793238462643383279502884197169399375105820974944
#define    inf              (int)1000000000
#define    mod              (int)1000000007
#define    mem(a,b)          memset(a,b,sizeof(a));
#define    w(x)              int T;cin>>T;while(T -- > 0)
#define    ff                first
#define    ss                second
#define    pqueue            priority_queue< int >
#define    pdqueue           priority_queue< int,vll ,greater< int > >

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

clock_t time_p = clock();

void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void solveTC(){

        int n;
        cin>>n;

string str;
set< string >s;
        rep(i,0,n)
        {
            cin>>str;
            s.insert(str);
        }

        cout<<(int)(s.size())<<endl;

}

int32_t main()
{

    FAST

  //  w(x){

        solveTC();

   // }

    time();

    return 0;

}

Measured memory_bytes: 19372
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	ll n;
	cin>>n;
	vector<ll>a(n);
	for(ll&x:a)cin>>x;
	sort(all(a),greater<int>());
    if(n==2){cout<<a[0];return 0;}
    else if(n==3){cout<<a[0]+a[1]<<endl;return 0;}
    ll ans = a[0];
    ll m = n-2;
    for(int i=1;i<n;i++)
    {
		if(m == 1){ans+=a[i];m--;}
		else if(m >= 2){ans+=2*a[i];m-=2;}
		if(!m)break;
		
	}
	cout<<ans;
}


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

import itertools
from heapq import heappop, heapify

N,*A = map(int,read().split())

n90 = sum(x == 90 for x in A)
if n90 - (N-n90) != 4:
    print(-1)
    exit()

x = 0
temp = list(itertools.accumulate(1 if x == 90 else -1 for x in A))
slide = temp.index(min(temp)) + 1
A = A[slide:] + A[:slide]

def F(left_node, right_node, R, depth):
    step = 1<<depth
    # L：左に曲がるインデックス集合
    # R：右に曲がるインデックスのヒープ
    if not R:
        n1,n2,n3,n4 = [i for i,x in enumerate(left_node) if x is not None]
        X = [None] * N
        Y = [None] * N
        X[n1] = step; Y[n1] = 0
        X[n2] = step; Y[n2] = step
        X[n3] = 0; Y[n3] = step
        X[n4] = 0; Y[n4] = 0
        return X,Y
    r = heappop(R); l = left_node[r]
    # l番：90度、r番：270度 を消し飛ばす
    ll = left_node[l]; rr = right_node[r]
    left_node[rr] = ll; right_node[ll] = rr
    left_node[l] = None; left_node[r] = None
    right_node[l] = None; right_node[r] = None
    X,Y = F(left_node,right_node,R,depth+1)
    # 90,270を追加する
    
    dx = X[rr] - X[ll]; dy = Y[rr] - Y[ll]
    if dx > 0:
        Y[rr] += step
        X[l] = X[rr] - step; Y[l] = Y[ll]
        X[r] = X[l]; Y[r] = Y[rr]
    elif dx < 0:
        Y[rr] -= step
        X[l] = X[rr] + step; Y[l] = Y[ll]
        X[r] = X[l]; Y[r] = Y[rr]
    elif dy > 0:
        X[rr] -= step
        X[l] = X[ll]; Y[l] = Y[rr] - step
        X[r] = X[rr]; Y[r] = Y[l]
    elif dy < 0:
        X[rr] += step
        X[l] = X[ll]; Y[l] = Y[rr] + step
        X[r] = X[rr]; Y[r] = Y[l]
    return X,Y

R = [i for i,x in enumerate(A) if x == 270]
heapify(R)

X,Y = F(list(range(-1,N-1)),list(range(1,N))+[0],R,0)

# 最初にずらしていた分
X = X[N-slide:] + X[:N-slide] 
Y = Y[N-slide:] + Y[:N-slide] 

# 最後に座圧して完成
x_to_i = {x:i for i,x in enumerate(sorted(set(X)))}
y_to_i = {y:i for i,y in enumerate(sorted(set(Y)))}
X = [x_to_i[x] for x in X]
Y = [y_to_i[y] for y in Y]

print('\n'.join('{} {}'.format(x,y) for x,y in zip(X,Y)))

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	double l,t;
	cin>>l;
	t=l/3;
	cout<<setprecision(10)<<t*t*t<<endl;
	return 0;
}

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

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


Measured memory_bytes: 3920
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def backtrack(n, ml, mh, tmp=[]):
    if n == 0:
        yield tmp
        return

    for i in range(ml, mh + 1):
        yield from backtrack(n - 1, i, mh, tmp + [i])


def main():
    def count(ca):
        return sum(d for a, b, c, d in abcd if ca[b - 1] - ca[a - 1] == c)
    N, M, Q = inpl()
    abcd = [inpl() for _ in range(Q)]
    print(max(count(c) for c in backtrack(N, 1, M)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 94212
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] D = nextIntArray(sc,N);
		int M = sc.nextInt();
		int[] T = nextIntArray(sc,M);
		
		sc.close();

		Arrays.sort(D);
		Arrays.sort(T);
		
		for(int i=0,j=0;i<M;i++) {
			while(T[i] > D[j]) {
				j++;
			}
			
			if(T[i] == D[j]) {
				j++;
				continue;
			}else {
				out.println("NO");
				return;
			}
		}
		out.println("YES");
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 94644
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int n , d1 , x;

int main(){
    scanf("%d%d%d",&n,&d1,&x);
    db ans = 0.;
    db p = d1;
    db s = d1 , di = d1;
    for(int i=1;i<=n;++i){
        ans += p;
        db q = 1. / (i + 1);
        p -= q * s;
        p += (1 - q) * 2 * x;
        s += di += 2 * x;
        p += 1. / (i + 1) * s;
    }
    p = d1 + x * (n + n - 1);
    s = p , di = p;
    for(int i=1;i<=n;++i){
        ans += p;
        db q = 1. / (i + 1);
        p -= q * s;
        p -= (1 - q) * 2 * x;
        s += di -= 2 * x;
        p += 1. / (i + 1) * s;
    }
    printf("%.12f\n",(double)ans / 2);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(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 << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  int a,b,c,k;

  cin >> a >> b >> c >> k;

  if(k % 2 == 0)cout << a - b << endl;
  else cout << b - a << endl;

  return 0;
}


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

using namespace std;

#define MAX 100000

int N, M;
int par[MAX], rank[MAX];
typedef pair<double,double> P;
void init(){
  for(int i = 0 ; i < N ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);

  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;

    if(rank[x] == rank[y]){
      rank[x]++;
    }
  }
}

bool same(int x,int y){
  return find(x) == find(y);
}

struct edge{
  int u,v;
  double cost;
};

bool comp(const edge &e1,const edge &e2){
  return e1.cost > e2.cost;
}

edge es[MAX];

double kruskal(){
  init(); sort(es , es + M, comp);
  double res = 0;
  for(int i = 0 ; i < M ; i++){
    edge e = es[i];
    if(!same(e.u , e.v)){
      unite(e.u , e.v);
      res += e.cost;
    }
  }
  return res;
}

double dist(P p1, P p2){
  return sqrt(pow(p1.first-p2.first,2)+pow(p1.second-p2.second,2));
}

int main(){
  int a,b;
  P p[MAX];

  scanf("%d %d" ,&N ,&M);
  for(int i = 0 ; i < N ; i++){
    scanf("%lf%lf",&p[i].first, &p[i].second);
  }
  double total = 0;
  for(int i = 0 ; i < M ; i++){
    scanf("%d %d" ,&a ,&b);  
    a--, b--;
    double d = dist(p[a], p[b]);
    es[i].u = a; es[i].v = b; es[i].cost = d;
    total += d;
  }
  printf("%.5f\n",total-kruskal());

  return 0;
}

Measured memory_bytes: 3356
#include<stdio.h>
int main()
{
  int a,b,i;
  scanf("%d%d",&a,&b);
  int x,y;
  if(a>=b)
  {
    y=a;
    x=b;
  }
  else
  {
    y=b;
    x=a;
  }
  for(i=0;i<y;i++)
  {
    printf("%d",x);
  }
  	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
int x,y,z,p;
scanf("%d",&p);
  x=p/3600;
  y=(p-3600*x)/60;
  z=p-3600*x-60*y;
printf("%d:%d:%d\n",x,y,z);




 return 0;
}

Measured memory_bytes: 2728
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    map<ll, ll> c;
    REP(i, N)
    {
        ++c[i - A[i]];
    }
    ll ans = 0;
    REP(i, N)
    {
        --c[i - A[i]];
        ans += c[i + A[i]];
    }
    OUT(ans);
}

Measured memory_bytes: 27364
def sumNum(num, sums):
    if num == 0:
        return sums
    sums += num % 10
    num = num // 10
    return sumNum(num, sums)

A, B = [int(i) for i in input().rstrip().split(' ')]
cnt = 0
for i in range(A, B+1):
    arr = [i for i in list(str(i))]
    if not arr[0] == arr[-1]:
        continue
    
    asc = ''.join(arr)
    desc = ''.join(list(reversed(arr)))
    if asc == desc:
        cnt += 1

print(cnt)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N;
vector <int> G[100005];
vector <int> D[100005];

bool color[100005];
long long curDist = 0;

void dfs(int v, int p = -1) {
    color[v] = curDist % 2;
    for(int i = 0; i < G[v].size(); i++) if(G[v][i] != p) {
        curDist += D[v][i];
        dfs(G[v][i], v);
        curDist -= D[v][i];
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        int a, b, d;
        cin >> a >> b >> d;
        G[a].push_back(b); D[a].push_back(d);
        G[b].push_back(a); D[b].push_back(d);
    }
    dfs(1);
    for(int i = 1; i <= N; i++)
        cout << color[i] << "\n";
}


Measured memory_bytes: 14208
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt_a = Counter(a)
q = int(input())
s = sum(a)
for i in range(q):
    b, c = map(int, input().split())
    s += (c - b)*cnt_a[b]
    print(s)
    cnt_a[b], cnt_a[c] = 0, cnt_a[c] + cnt_a[b]

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

int main()
{
    string s1="",s2="";
    int i,j,n,m;

    cin>>n>>m;

    for(i=0; i<n; i++)
        s1+=m+'0';

    for(i=0; i<m; i++)
        s2+=n+'0';

    if(s2>s1)
        cout<<s1<<endl;
    else
        cout<<s2<<endl;

}


Measured memory_bytes: 256
#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 < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int dp[101][4][4][4];
const int MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    // init
    dp[0][3][3][3] = 1;
    for(int i=0; i<N; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                for(int l=0; l<4; l++){
                    if(dp[i][j][k][l] == 0) continue;
                    for(int a=0; a<4; a++){
                        if(a==2 && j==1 && k==0) continue;
                        if(a==1 && j==2 && k==0) continue;
                        if(a==2 && j==0 && k==1) continue;
                        if(a==2 && j==1 && l==0) continue;
                        if(a==2 && k==1 && l==0) continue;
                        dp[i+1][a][j][k] += dp[i][j][k][l];
                        dp[i+1][a][j][k] %= MOD;
                    }
                }
            }
        }
    }
    int ans = 0;
    rep(i, 4){
        rep(j, 4) {
            rep(k, 4){
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1005;
int a[N];
int main (){
	int n,m;scanf ("%d%d",&n,&m);
	int t1=m,t2=1;
	for (int i=1;i<=m;i++) scanf ("%d",&a[i]);
	int cnt=0;
	for (int i=1;i<=m;i++)
		if (a[i]&1) {
			cnt++;
			if (cnt==1) t1=i;
			if (cnt==2) t2=i;
			if (cnt>2){
				puts("Impossible");
				return 0;
			}
		}
	swap(a[m],a[t1]);
	swap(a[1],a[t2]);
	if (m==1&&a[1]==1) {puts("1\n1\n1");return 0;}
    for (int i=1;i<=m;i++) printf("%d ",a[i]);
    if (m==1) {printf("\n2\n%d 1\n",a[1]-1);return 0;}
    printf ("\n%d\n%d ",a[m]>1?m:m-1,a[1]+1);
    for (int i=2;i<m;i++) printf("%d ",a[i]);
    if (a[m]>1) printf("%d\n",a[m]-1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib> //abs(int)
using namespace std;
int main(void){
  int a;
  cin >> a;
  if(a < 1200){
    cout << "ABC";
  } else if(a >= 2800){
    cout << "AGC";
  } else {
    cout << "ARC";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 1e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int N,M;
vector<vector<int>> G;
double dp[660];

int main(){
    cin >> N >> M;
    G.resize(N);
    rep(i,M){
        int s,t; cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
    }
    for(int u = N-2; u >= 0; u--){
        for(int v : G[u]){
            dp[u] += (dp[v]+1)/G[u].size();
        }
    }

    double ans = 1000.0;

    rep(u,N){
        double now = 0.0;
        int erase;
        if(G[u].size() == 1) continue;
        for(int v : G[u]){
            if(now < dp[v]){
                now = dp[v];
                erase = v;
            }
        }
        vector<double> dp2(660);
        for(int k = N-2; k >= 0; k--){
            for(int v : G[k]){
                if(k == u){
                    if(v != erase) dp2[k] += (dp2[v]+1)/(G[k].size()-1);
                }
                else dp2[k] += (dp2[v]+1)/G[k].size();
            }
        }
        ans = min(ans,dp2[0]);
    }
    cout << fixed << setprecision(7) << ans << endl;
    
}
   


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10000
#define STRLEN 20

int main(void){
    int n,q, w, e, r;
    q=w=e=r=0 ;
    char a[5];
    scanf("%d", &n);
    for(int i=0; i < n; i++){
        scanf("%s", a);
        if(strcmp(a,"AC") == 0) q++;
        else if(strcmp(a,"WA") == 0) w++;
        else if(strcmp(a,"TLE") == 0) e++;
        else r++;
    }

    printf("AC x %d\n", q);
    printf("WA x %d\n", w);
    printf("TLE x %d\n", e);
    printf("RE x %d\n", r);

    return 0;


}


Measured memory_bytes: 1728
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pll;

const int MAX_X = 1000000000;

int64 myabs(int64 x){
    if(x < 0)    return -x;
    return x;
}

int64 find_B(int64 C){
    if(C < 0)    return -1;
    double dB = pow(C+0.0,.2);
    for (int i = -100; i < 100; ++i){
        int64 B = int64(dB) + i;
        if( B < 0)    continue;
        int64 B5 = B*B*B*B*B;
        if(B != 0 && B5/B/B/B/B/B != 1)   continue;
        if(B5 == C)    return B;
    }
    return -1;
}
pll solve(int X){
    for (int64 A = 0;; ++A){
        int64 A5 = A*A*A*A*A;
        if(A != 0 && A5/A/A/A/A/A != 1)   break;
        int64 B;
        if((B = find_B(X-A5)) != -1)    return pll(B,-A);
        if((B = find_B(X+A5)) != -1)    return pll(B,A);
    }
    assert(false);
    return pll(-1,-1);
}

int main(){
    int X;    scanf("%d",&X);
    pll ans = solve(X);
    printf("%lld %lld\n",ans.first, ans.second);




}


Measured memory_bytes: 2612
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int main(void){

	int n,a,b,c,d,e;
	for(;;){
	cin >> n;
	if(n==0) break;

	vector<int>p;
	rep(i,n){
	cin >> a >> b >> c >> d >> e;
	p.push_back(a+b+c+d+e);
	}

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

	cout << p[n-1] << ' ' << p[0] << endl;

	p.clear();

	}

    return 0;

   }

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) {
    cin >> h[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < i; j++) {
      if (h[i] < h[j]) {
      ok = false;
      break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,x;
bool up;
int a[100010];

signed main(){
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
    }
    int cnt=0;
    rep(i,0,n){
        cnt++;
        while(i+1<n&&a[i]==a[i+1])i++;
        if(i==n-1)break;
        if(a[i]<a[i+1]){
            while(i+1<n&&a[i]<=a[i+1])i++;
        }else{
            while(i+1<n&&a[i]>=a[i+1])i++;
        }
    }
    cout<<cnt<<endl;
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1024
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    ll ttwo = 0, tfive = 0;
                    ll k = 1e9;
                    while(k%2 == 0){
                        k /= 2;
                        ++ttwo;
                    }
                    while(k%5 == 0){
                        k /= 5;
                        ++tfive;
                    }
                    map<pair<ll, ll>, int> store;
                    ll ans = 0;
                    for(int i = 0; i < n; i++){
                        double number;
                        cin>>number;
                        ll num = llround(number*1e9);
                        ll two = 0, five = 0;
                        while(num%2 == 0){
                            num /= 2;
                            ++two;
                        }
                        while(num%5 == 0){
                            num /= 5;
                            ++five;
                        }
                        two -= ttwo;
                        five -= tfive;
                        for(auto itr : store){
                            pair<ll, ll> p = itr.first;
                            if(p.first+two >= 0 && p.second+five >= 0)
                                ans += itr.second;
                        }
                        store[{two, five}]++;
                    }
                    cout<<ans;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define UL unsigned long long


int main(void)
{
    IOS
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> zero;
    vector<int> one;
    if (s[0] == '0') {
        one.emplace_back(0);
    }

    int cnt = 1;
    char c = s[0];
    for(auto i = 1; i < n; i++)
    {
        if (c == s[i]) {
            cnt++;
            //cerr << cnt;
        }
        if (c != s[i]) { 
            if (c == '0') {
                zero.emplace_back(cnt);
            } else {
                one.emplace_back(cnt);
            }
            c = s[i];
            cnt = 1;
        }
        if (i == n-1) { 
            if (c == '0') {
                zero.emplace_back(cnt);
            } else {
                one.emplace_back(cnt);
            }
        }
    }
    one.emplace_back(0);
    
    /*
    cerr << "zero: ";
    for(int i = 0; i < zero.size() ; i++) {
        cerr << zero[i] << " ";
    }
    cerr << "one: ";
    for(int i = 0; i < one.size() ; i++) {
        cerr << one[i] << " ";
    }
    */
    
    int m = zero.size();
    if (m < k) {
        cout << n << endl; 
        return 0;
    }

    int ans = 0;
    for(auto i = 0; i <= m-k; i++)
    {
        int count = 0;
        for (auto j = 0; j < k ; j++){
            count += one[i+j] + zero[i+j];
        }
        //cerr << "count: " << count << endl;
        //if (i != m-k) count += one[i+k];
        count += one[i+k];
        //cerr << "count2: " << count << endl;
        if (ans < count)  ans = count; 
    }
    

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


Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	N++;
	cout << N / 2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 2000
#define LL long long
#define INF 1000000000000000000
int n;
LL a[MAXN+5],x;
LL minn[MAXN+5];
LL ans;
int main()
{
	ans=INF;
	scanf("%d%lld",&n,&x);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	memset(minn,0x3f,sizeof(minn));
	for(LL st=0;st<n;st++)
	{
		LL sum=0;
		for(LL j=0;j<=n-1;j++)
		{
			minn[j]=min(minn[j],a[(j-st+n)%n]);
			sum+=minn[j];
		}
		ans=min(ans,sum+st*x);
	}
	printf("%lld",ans);
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
      cin >> A[i];
    }
    // Kまでの数がないといけない.  逆に残りKコマで砕ければいい.
    int value = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] == value + 1) {
        value ++;
      }
    }
    if (value == 0) {
      cout << -1 << endl;
      return 0;
    }
    cout << N - value << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    getchar();
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        if(s[i]+n>90) printf("%c",s[i]+n-90+'A'-1);
        else printf("%c",s[i]+n);
    }


    return 0;
}


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

typedef pair<int, int> P;
const int INF = 1000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int H, W;
char field[50][50];
int dist[50][50];

int sx, sy;
int gx, gy;


int bfs(){
    queue<P> que;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            dist[i][j] = INF;
        }
    }
    dist[sx][sy] = 0;

    que.push(P(sx, sy));
    while(que.size()){
        P p = que.front();
        que.pop();

        for(int i=0; i<4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == '.' && dist[nx][ny] == INF){
                dist[nx][ny] = dist[p.first][p.second] + 1;
                if(nx == gx && ny == gy) return dist[nx][ny] + 1;

                que.push(P(nx, ny));
            }
        }
    }
    return dist[gx][gy] + 1;
}

int main(){
    cin >> H >> W;
    sx = 0, sy = 0;
    gx = H - 1, gy = W - 1;
    int res = H * W;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> field[i][j];
            if(field[i][j] == '#') res--;
        }
    }

    res -= bfs();
    if(dist[gx][gy] == INF) res = -1;
    cout << res << endl;
    return 0;
}


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

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = max(a*c,b*d);
  ans = max(ans,max(a*d,b*c));
  if( ( a <= 0 && b >= 0) || ( c <= 0 && d >= 0 ) ){
    ans = max(ans,0LL);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long;
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   long long int n;
   cin>>n;
   long long int ans=0;
   if(n%2==0)
   {
       long long int h=0;
       while(n%2==0)
        {
            h++;
            n=n/2;
        }
      for(int j=1;j<50;j++)
      {
          if((j*(j+1))/2>h)
           {
               ans+=j-1;
               break;
           }
      }
   }
       for(long long int i=3;i*i<=n;i+=2)
       {
           long long  int h=0;
           while(n%i==0)
           {
               h++;
               n=n/i;
           }
          for(int j=1;j<50;j++)
         {
          if((j*(j+1))/2>h)
           {
               ans+=j-1;
               break;
           }
         }   
       }
       if(n!=1)
        ans++;
        cout<<ans<<"\n";
  
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int n,q,a,b,c,i,x[100010];
string s;
int main(){
  for(cin>>n>>q>>s,i=1;i<n;++i){
    x[i+1]=x[i];
    if(s[i-1]=='A'&&s[i]=='C')x[i+1]++;
  }
  for(i=0;i<q;++i){
    int a,b;cin>>a>>b;
    int ans=x[b]-x[a];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1408
#include <stdio.h>
int
digits(int num) {
  int ret = 0;
  while (1) {
    num /= 10;
    ret += 1;
    if(num == 0) {
      break;
    }
  }
  return ret;
}
int
base_num(int digits) {
  int ret = 1;
  while(--digits) {
    ret = ret*10+1;
  }
  return ret;
}

int
main(void)
{
  int input;
  scanf("%d", &input);
  int ketasu = digits(input);
  int baseNum = base_num(ketasu);
  int ans = baseNum;
  while(input > ans) {
    ans += baseNum;
  }
  printf("%d\n", ans);
  return 0;
}


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

using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::endl;
using std::ios_base;
using std::unordered_map;
using std::cerr;
using std::string;
using std::to_string;
using std::max;
using std::min;

const long long INF = 1e9;
long long MOD = 1e9 + 7;

vector<long long> up, down; // long long !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
vector<vector<long long>> g;
vector<long long> p;
vector<vector<long long>> pref, suff;
vector<unordered_map<int, int>> ind;

void init(long long s) {
    up.resize(s);
    down.resize(s);
    g.resize(s);
    p.resize(s);
    pref.resize(s);
    suff.resize(s);
    ind.resize(s);
}

void fill_down(long long u, long long pr = -1) {
    down[u] = 1;
    p[u] = pr;
    vector<long long> a;
    int id = 0;
    for (int i = 0; i < (int)g[u].size(); i++) {
        long long v = g[u][i];
        if (v == pr) continue;
        fill_down(v, u);
        a.push_back(down[v] + 1);
        down[u] *= down[v] + 1;
        down[u] %= MOD;
        ind[u][v] = id++;
    }
    pref[u].resize(a.size() + 1);
    suff[u].resize(a.size() + 1);
    pref[u][0] = 1;
    for (int i = 1; i <= (int)a.size(); i++) {
        pref[u][i] = pref[u][i - 1] * a[i - 1];
        pref[u][i] %= MOD;
    }
    suff[u][a.size()] = 1;
    for (int i = a.size() - 1; i > -1; i--) {
        suff[u][i] = suff[u][i + 1] * a[i];
        suff[u][i] %= MOD;
    }
}

void fill_up(long long u, long long pr = -1) {
    up[u] = 1;
    if (pr != -1) {
        up[u] *= up[pr];
        up[u] %= MOD;
        up[u] *= pref[pr][ind[pr][u]];
        up[u] %= MOD;
        up[u] *= suff[pr][ind[pr][u] + 1];
        up[u] %= MOD;
        up[u]++;
        up[u] %= MOD;
        // cerr << u + 1 << ' ' << suff[pr].size() << ' ' << ind[pr][u] + 1 << endl;
    }
    for (long long v : g[u]) {
        if (v == pr) continue;
        fill_up(v, u);
    }
}

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

    long long n;
    cin >> n >> MOD;
    init(n);
    for (long long i = 0; i < n - 1; i++) {
        long long a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    fill_down(0);
    fill_up(0);

    for (long long i = 0; i < n; i++) {
        /*
        long long ans = 1;
        for (long long to : g[i]) {
            if (to == p[i]) {
                ans *= up[to] + 1;
            } else {
                ans *= down[to] + 1;
            }
            ans %= MOD;
        }
        cout << ans << endl;
        cout << down[i] << ' ' << up[i] << endl;
        */
        cout << (down[i] * up[i]) % MOD << endl;
        // cerr << down[i] << ' ' << up[i] << endl;
    }

    return 0;
}



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

unordered_map<int, int> h;

int fib(int n);

int fib(int n) {
    if (h.count(n) != 0) {
        return h[n];
    }

    int ret;
    if (n == 0) {
        ret = 1;
    }
    else if (n == 1) {
        ret = 1;
    }
    else {
        ret = fib(n-1) + fib(n-2);
    }
    h[n] = ret;
    return ret;
}

int main () {
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define P_B push_back
#define E_B emplace_back
#define fi first
#define se second

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


int main(){
  string S;
  ll N, n, ans = 0;

  cin >> N;

  vector<int> A(N), B(N);

  rep(i, N){
    cin >> A[i] >> B[i];
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  if(N%2 == 1){
    n = (N-1)/2;
    ans = B[n] - A[n] + 1;
  }else{
    n = N/2;
    ans = (B[n] + B[n-1]) - (A[n] + A[n-1]) + 1;
  }

  cout << ans << endl;


  return 0;
}


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

int main()
{ 
  string a, b ;
  cin >> a >> b ;
  string str = a + b ;
  int calcu = stoi(str) ;
  
  for(int i = 1 ; i <= 1000 ; i++)
  {
    if(i * i == calcu)
    {
      cout << "Yes" << endl ;
      break; 
    }
    else if(i * i > calcu)
    {
      cout << "No" << endl ;
      break ;
    }
  }
}


Measured memory_bytes: 256