akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;



int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int,int>> in(n);
	for(int i = 0; i < n; ++i)
		scanf("%d%d", &in[i].first, &in[i].second);
	ll answer = 0;
	for(int rep = 0; rep < 2; ++rep) {
		ll maybe = 0;
		set<pair<int,int>> lewe, prawe;
		for(int i = 0; i < n; ++i) {
			lewe.insert({in[i].second, i});
			prawe.insert({-in[i].first, i});
		}
		int cur = 0;
		for(int xx = 0; xx <= n; ++xx) {
			if(xx % 2 == 0) {
				if(xx == n) {
					maybe += abs(cur);
					debug() << imie(cur) imie(maybe);
					continue;
				}
				auto it = lewe.begin();
				int id = it -> second;
				if(cur < in[id].first) {
					maybe += in[id].first - cur;
					cur = in[id].first;
				}
				if(cur > in[id].second) {
					maybe += cur - in[id].second;
					cur = in[id].second;
				}
				//~ maybe += max(0, cur - it -> first);
				//~ if(it -> first < cur)
					//~ cur = it -> first;
				//~ int id = it -> second;
				prawe.erase({-in[id].first, id});
				lewe.erase({in[id].second, id});
			}
			else {
				if(xx == n) {
					//~ maybe += max(0, -cur);
					maybe += abs(cur);
					debug() << imie(cur) imie(maybe);
					continue;
				}
				auto it = prawe.begin();
				int id = it -> second;
				if(cur < in[id].first) {
					maybe += in[id].first - cur;
					cur = in[id].first;
				}
				if(cur > in[id].second) {
					maybe += cur - in[id].second;
					cur = in[id].second;
				}
				prawe.erase({-in[id].first, id});
				lewe.erase({in[id].second, id});
			}
			debug() << imie(cur) imie(maybe);
		}
		debug();
		answer = max(answer, maybe);
		for(pair<int,int> & p : in) {
			swap(p.first, p.second);
			p.first *= -1;
			p.second *= -1;
		}
	}
	printf("%lld\n", answer);
}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for(int i = 2; i < N; ++i) {
        if (S[i-2] == 'A' && S[i-1] == 'B' && S[i] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var xi = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var n = nk[0];
            var k = nk[1];
            var answer = Math.Abs(xi[n - 1] - xi[0]) * 2;
            for (var i = 0; i < n - k + 1; i++)
            {
                var left = Math.Abs(xi[i]) + Math.Abs(xi[i + k - 1] - xi[i]);
                var right = Math.Abs(xi[i + k - 1]) + Math.Abs(xi[i + k - 1] - xi[i]);
                answer = Math.Min(answer, Math.Min(left, right));
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 22752
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for (int i = 0; i < 3; i++){
      if (s.charAt(i) == '1'){ans += 1;}
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35504
#include <stdio.h>

int main()
{
   int R;
   scanf("%d",&R);
   if(R>=2800){
       printf("AGC");
   }
   if(2800>R){
       if(R>=1200){
           printf("ARC");
       }
   }

   if(R<1200){
       printf("ABC");
   }
   

  return 0;
} 

Measured memory_bytes: 128
k = int(input())

List = [i for i in range(1, 10)]
latest_added = List.copy()
newly_add = []

count = 9
for _ in range(10000000):
    for i in latest_added:
        mod10 = i % 10
        if mod10 != 0:
            newly_add.append(i * 10 + mod10 - 1)
            count += 1

        newly_add.append(i * 10 + mod10)
        count += 1

        if mod10 != 9:
            newly_add.append(i * 10 + mod10 + 1)
            count += 1


    List += newly_add
    latest_added = newly_add.copy()
    newly_add = []

    if count >= k:
        break

print(List[k - 1])

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

int main() {
    int N;
    //int d[110];
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; ++i) cin >> d.at(i);
    // for (int i = 0; i < N; ++i) cin >> d[i];

    vector<int> num(110);
    for (int i = 0; i < N; i++) {
        num.at(d.at(i)) ++;
    }

    int res = 0;
    for (int i = 0; i < num.size(); i++) {
        if (num.at(i)) res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int m,f,r,sum;
    while ((m = sc.nextInt()) != -1 | (f = sc.nextInt()) != -1 | (r = sc.nextInt()) != -1){
      sum = m + f;
      if(m == -1 || f == -1){
        System.out.println("F");
      }else if(sum >= 80){
        System.out.println("A");
      }else if(sum >= 65){
        System.out.println("B");
      }else if(sum >= 50){
        System.out.println("C");
      }else if(sum >= 30){
        if(r >= 50){
          System.out.println("C");
        }else{
          System.out.println("D");
        }
      }else{
        System.out.println("F");
      }
    }
  }
}



Measured memory_bytes: 26308
nkq = input()
nkq = nkq.split()
n = int(nkq[0])
k = int(nkq[1])
q = int(nkq[2])
a = [0 for i in range(q)]
for i in range(q):
    a[i] = int(input())

charanger = [k-q for i in range(n)]

for i in range(q):
    charanger[a[i]-1]+=1

for i in range(n):
    if charanger[i] <= 0:print("No")
    else:print("Yes")


Measured memory_bytes: 11780
#頂点を見た時に，枝分かれの本数に応じてansを更新
#permutationのリストを先に作っておく

import sys
input = sys.stdin.readline

mod=10**9+7


N,K=map(int,input().split())
ab=[list(map(int, input().split())) for _ in range(N - 1)]
adj=[[] for _ in range(N)]

for a,b in ab:
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
    
#順列(K-2)Piを先に
P=[1]
for i in range(N):
    P.append((P[-1]*(K-2-i))%mod)
    

q=[(0,-1,0)]#node,parent,depth

ans=1
while q!=[]:
    v,p,d=q.pop()
    #深さ0or1で塗ることができる色数は異なる
    l=len(adj[v])
    if d==0:
        ans*=(K-1)
    ans*=(P[l-1])
    ans%=mod
    for i in range(l):
        next_v=adj[v][i]
        #葉は追加しない
        if next_v!=p and len(adj[next_v])!=1:
            q.append((next_v,v,d+1))
if N==1:
    ans=1
print((ans*K)%mod)

Measured memory_bytes: 75740
import fractions
from functools import reduce
 
 
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                if n[j] % t == 0 and (n[j] / t) % 2 == 1:
                        n[j] = int(n[j]/t)
                else: return 0
        return int(t//2)
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
n=sorted(set(n),reverse = True)
 
bs = n[0]//2
 
if len(n) > 1:
        
        c = chk(n[-1])
        
        if  c != 0:
                v = lcm_o()*c
                
                if v > M:
                        print(0) 
                else:
                        v = M//v
                        if v%2==1: v+=1
                        print(int(v//2))
        
        else: print(0)
elif len(n)==1:
        v = M//bs
        if v%2==1: v+=1
        print(int(v//2))

Measured memory_bytes: 16284
N = int(input())
s = list(map(int, input().split()))
count = 0
for i in range(N - 2):
  if s[i+1] != max(s[i], s[i+1], s[i+2]):
    if s[i+1] != min(s[i], s[i+1], s[i+2]):
      count += 1
      
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main(){
  int a,b,c=0;
  scanf("%d%d",&a,&b);
  for(int i=b;i;i/=10)c++;
  for(int i=0;i<c;i++)a*=10;
  a+=b;
  puts(sqrt(a)-(int)sqrt(a)?"No":"Yes");
  return 0;
}

Measured memory_bytes: 128
n = int(input())

xyh = [[int(i) for i in input().split()] for j in range(n)]

xyh.sort(key=lambda x: -x[2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                tmp = H - abs(xyh[k][0] - i ) - abs(xyh[k][1] - j )
                if tmp <= 0 and k == n-1:
                    print(cx,cy,H)
                    exit()
                elif tmp <= 0:
                    continue
                else:
                    break
                
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

#print(cx,cy,H)
            

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N;
char S[200001] = {};
ll white[200001] = {}, black[200001] = {};
ll ans = 300000;

int main() {
	cin >> N;
	cin >> S;
	for (int i = 1; i <= N; i++) {
		if (S[i - 1] == '.') {
			white[i] = white[i - 1] + 1;
		}
		else {
			white[i] = white[i - 1];
		}
		if (S[i - 1] == '#') {
			black[i] = black[i - 1] + 1;
		}
		else {
			black[i] = black[i - 1];
		}
	}
	ans = white[N];
	for (int i = 1; i <= N; i++) {
		ans = min(ans, black[i] + white[N] - white[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  string s;
  cin >> s;
  
  int ok = 0;
  for (int i = 0; i < s.size(); i++){
    for (int j = i; j < s.size(); j++){
      if ("keyence" == s.substr(0, i) + s.substr(j))
        ok = 1;
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
    
    
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool check(char ch){
	if(ch=='A'||ch=='G'||ch=='C'||ch=='T')return true;
	else return false;
}

int main(){
	string s,ans="",alt="";
	cin>>s;
	rep(i,s.size()){
		if(check(s[i]))alt+=s[i];
		else{
			if(ans.size()<alt.size())ans=alt;
			alt="";
		}
		if(i==s.size()-1){
			if(ans.size()<alt.size())ans=alt;
		}
	}
	cout<<ans.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>H>>W;
    vector<string> grid(H);
    rep(i,H) cin>>grid[i];
    mat ans(H,vec(W,0));
    rep(i,H) {
        rep(j,W){
            if(grid[i][j] == '#'){
                ans[i][j] = -1;
                for(int p = max(0, i-1); p <= min(H-1,i+1LL); ++p){
                    for(int q = max(0, j-1); q <= min(W-1,j+1LL); ++q){
                        if(grid[p][q] == '.') ++ans[p][q];
                    }
                }
            }
        }
    }
    rep(i,H){
        rep(j,W){
            if(grid[i][j] == '#') cout<<'#';
            else cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    fill((T*)array, (T*)(array + N), val);
}struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) { 
        for (int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        par[rx] = ry; 
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main() {
    int n, q, c, x, y; cin >> n >> q;
    UnionFind tree(n);
    rep(i, q) {
        cin >> c >> x >> y;
        if (c == 0) tree.unite(x, y);
        else if (tree.same(x, y)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int N = S.size();
  bool flag = false;
  for(int i = 0; i < N; i++) {
    string temp = S;
    string sbstr = S.substr(i);
    temp.erase(i);
    temp = sbstr + temp;
    if(temp == T) {
      flag = true;
      break;
    }
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

count = 0
total = 0
xor = 0
r = 0
for l in range(N): #左側を動かす
    while r < N and total + A[r] == xor ^ A[r]:
        total += A[r]
        xor ^= A[r]
        r += 1
    count += r - l
    total -= A[l]
    xor ^= A[l]

print (count)


Measured memory_bytes: 24840
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N, A, B;

int main(){
	scanf("%d %d %d", &N, &A, &B);
	printf("%d %d\n", min(A, B), max(0, (A + B) - N));
	return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
n, m = map(int, input().split())
a = list(map(int, input().split()))
add = defaultdict(int)
for i in a:
    add[i] += 1
for i in range(m):
    b, c = map(int, input().split())
    add[c] += b

output = 0
cnt = 0
print()
for i, v in sorted(add.items(), reverse=True):
    if cnt+v >= n:
        output += i*(n-cnt)
        break
    else:
        output += i*v
        cnt += v
print(output)


Measured memory_bytes: 40992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int a,b; cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

struct dsu{
    vector <int> p;
    void resize(int n){
        p.resize(n + 1);
        for(int i = 1 ; i <= n ; i++){
            p[i] = i;
        }
    }
    int find(int x){
        if(p[x] == x) return x;
        return p[x] = find(p[x]);
    }
    void merge(int x, int y){
        x = find(x);
        y = find(y);
        p[x] = y;
    }
};

int n, k, l;
dsu a, b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k >> l;
    a.resize(n);
    b.resize(n);
    for(int i = 0 ; i < k ; i++){
        int x, y;
        cin >> x >> y;
        a.merge(x, y);
    }
    for(int i = 0 ; i < l ; i++){
        int x, y;
        cin >> x >> y;
        b.merge(x, y);
    }
    map <pair <int, int>, int> cnt;
    for(int i = 1 ; i <= n ; i++){
        cnt[make_pair(a.find(i), b.find(i))]++;
    }
    for(int i = 1 ; i <= n ; i++){
        cout << cnt[make_pair(a.find(i), b.find(i))] << " ";
    }
    cout << endl;
}


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

int main(){
    int n, a, b, c, x;
    cin >> n;
	while(n){
		n--;
        cin >> a >> b >> c;
		if(a < b){ x = a, a = b, b = x; }
		if(a < c){ x = a, a = c, c = x; }
		if(a * a == b * b + c * c){ cout << "YES" << endl; }
		else{ cout << "NO" << endl; }
	};
    return 0;
}


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

using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

int N;
vi a, b;
vvi minMax;
vvb aReachable;

int64_t solve();
bool allReachable();
bool allAble(int);
bool eachAble(int, int);
bool end();

int main()
{
	printf("%lld\n", solve());

	return 0;
}

int64_t solve()
{
	scanf("%d", &N);
	a.resize(N);
	minMax.resize(N);
	aReachable.resize(N);
	for (int i{}; i < N; i++)
	{
		scanf("%d", &a[i]);
		minMax[i].resize(a[i] + 1, 1 << 30);
		aReachable[i].resize(a[i] + 1);
		aReachable[i].back() = true;
	}

	b.resize(N);
	for (auto& e: b)
		scanf("%d", &e);
	for (int i{}; i < N; i++)
		if (b[i] > a[i])
			return -1;
	
	for (int i{}; i < N; i++)
	{
		minMax[i][b[i]] = 0;
		for (int div{b[i] + 1}; div <= a[i]; div++)
			for (int j{b[i]}; j < div; j++)
				if (minMax[i][j] < div)
					for (int k{j}; k <= a[i]; k += div)
						minMax[i][k] = std::min(minMax[i][k], div);
	}

	int64_t ans{};
	int prev{*std::max_element(a.begin(), a.end()) + 1};
	while (prev > 1 && !end())
	{
		int ng{}, ok{prev};
		while (ok - ng > 1)
		{
			int mid{(ok + ng) >> 1};
			if (allAble(mid)) ok = mid;
			else ng = mid;
		}
		ans += 1ll << ok;
		for (int i{}; i < N; i++)
			for (int j{a[i]}; j >= b[i]; j--)
				if (aReachable[i][j])
					aReachable[i][j % ok] = true;
		if (prev == ok) return -1;
		prev = ok;
	}
	if (end()) return ans;
	else return -1;
}

bool allReachable()
{
	for (int i{}; i < N; i++)
		if (!aReachable[i][b[i]])
			return false;
	return true;
}

bool allAble(int max)
{
	for (int i{}; i < N; i++)
		if (!eachAble(i, max))
			return false;
	return true;
}

bool eachAble(int index, int max)
{
	for (int i{b[index]}; i <= a[index]; i++)
		if (aReachable[index][i] && minMax[index][i] <= max)
			return true;
	return false;
}

bool end()
{
	for (int i{}; i < N; i++)
		if (!aReachable[i][b[i]])
			return false;
	return true;
}

Measured memory_bytes: 256
// Sequence
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    int N;
    ll count1 = 0, count2 = 0;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    ll su = 0;
    for (int i = 0; i < N; i++) {
        su += A[i];
        if (i % 2 == 1) {
            if (su < 1) {
                count1 += -1 * su + 1;
                su = 1;
            }
        } else {
            if (su > -1) {
                count1 += su + 1;
                su = -1;
            }
        }
    }

    su = 0;
    for (int i = 0; i < N; i++) {
        su += A[i];
        if (i % 2 == 0) {
            if (su < 1) {
                count2 += -1 * su + 1;
                su = 1;
            }
        } else {
            if (su > -1) {
                count2 += su + 1;
                su = -1;
            }
        }
    }

    cout << min(count1, count2) << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	int [][] map;
	int ans;
	String [][] boards;
	boolean isused [];

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			String inputline = sc.nextLine();
			if(inputline.equals("END")) break;
			boards = new String[2][10];
			boards[0] = inputline.split(" ");
			for(int i = 0; i < 10; i++){
				StringBuilder sb = new StringBuilder(boards[0][i]);
				sb.reverse();
				boards[1][i] = sb.toString();
			}
			map = new int[10][5];
			for(int i = 0; i < 10; i++){
				Arrays.fill(map[i], -1);
			}
			isused = new boolean[10];
			ans = 0;
			dfs(0);
			System.out.println(ans/ 8);
		}
	}

	private void dfs(int deep){
		if(deep == 10){
			ans++;
			return ;
		}
		
		for(int i= 0 ; i < 10; i++){
			if(! isused[i]){
				for(int dir = 0; dir < 2; dir++){
					boolean isarrange = true;
					for(int j = 0; j < 5 ; j++){
						map[deep][j] = boards[dir][i].charAt(j) - '0';
						if(deep < 5){
							int movey = j + 5, movex = 5 - deep - 1;
							if(map[movey][movex] != -1 && map[deep][j] + map[movey][movex] != 1){
								isarrange = false;
							}
						}
						else{
							int movey = deep - 5, movex = 5 - j - 1;
							if(map[movey][movex] != -1 && map[deep][j] + map[movex][movey] != 1){
								isarrange = false;
							}
						}
					}
					isused[i] = true;
					if(isarrange){
						dfs(deep + 1);
					}
					isused[i] = false;
					for(int j = 0; j < 5 ; j++){
						map[deep][j] = -1;
					}
					if(boards[0][i].equals(boards[1][i])){
						break;
					}
				}
				
			}
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int cnt = 0;
        int min = Integer.MAX_VALUE;
        long ans = 0;
        for(int i = 0; i<N; i++) {
            a[i] = sc.nextInt();
            if(a[i]<0) {
                cnt++;
                a[i] = -1*a[i];
            }
            ans += a[i];
            min = Math.min(a[i], min);
        }

        if(cnt%2==0) {
            System.out.println(ans);
        }else {
            System.out.println(ans-min-min);
        }

    }
}

Measured memory_bytes: 52652
import java.util.*;

class Main{
	public static void main (String[] args) {
    	Scanner sc=new Scanner(System.in);
    	int N=sc.nextInt();
    	int num=0;
    	for(int i=1;i<=9;i++){
    	    if(N<=(i*100+i*10+i)){
    	        num=i*100+i*10+i;
    	        break;
    	    }     
    	}
    	System.out.println(num);
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

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

using namespace std;

typedef long long ll;

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

  int x, y, ans = 0;
  cin >> x >> y;
  
  if ( x == 1 && y == 1 ) {
    cout << 1000000 << endl;
  } else {
    if (x == 1) {
      ans += 300000;
    }
    if ( x == 2 ) {
      ans += 200000;
    }
    if ( x == 3 ) {
      ans += 100000;
    }
    if (y == 1) {
      ans += 300000;
    }
    if ( y == 2 ) {
      ans += 200000;
    }
    if ( y == 3 ) {
      ans += 100000;
    }
    cout << ans << endl;
  }

  return 0;
}


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

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

	int arr[100000];
	int mx = 0, mn = 100000;
	for (int i = 0; i < N; ++i) {
		cin >> arr[i];
		mx = max(mx, arr[i]);
		mn = min(mn, arr[i]);
	}

	if (mn == mx) {
		if (mx == N - 1 || mx * 2 <= N) cout << "Yes";
		else cout << "No";
	}
	else if (mn + 1 == mx) {
		int x = 0, y = 0;
		for (int i = 0; i < N; ++i)
			arr[i] == mn ? ++x : ++y;

		if (x > mn) cout << "No";
		else if (mn - x + 1 <= y / 2) cout << "Yes";
		else cout << "No";
	}
	else cout << "No";

	return 0;
}


Measured memory_bytes: 640
n = input()
a = map(int,raw_input().split())


print " ".join(map(str,a))
for i in xrange(1,len(a)):
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v :
    a[j+1] = a[j]
    j = j - 1
  a[j+1] = v

  print " ".join(map(str,a))

Measured memory_bytes: 6468
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

A, B = MAP()
a = divisor(A)
b = divisor(B)
a = set(a)
b = set(b)
kouyaku = a & b

ans = 1
for y in kouyaku:
    if is_prime(y):
        ans += 1
print(ans)
    


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

using namespace std;

int main(int argc, char *argv[])
{
	int k, x;
	cin >> k >> x;
	int l = max(x - (k - 1), -1000000);
	int r = min(x + (k - 1), 1000000);
	for (int i = l; i <= r; i++) cout << i << ' ';
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int N;
char s[maxn];
void solve(){
	int ans =0;
	int l = 1,r = N;
	while(l<r){
		while(l<=N && s[l] == 'R') l++;
		while(r>=1 && s[r] == 'W') r--;
		if(l<r) ans++;
		l++,r--;
	}
	cout<<ans<<'\n';
}
int main(){
	// debug;
	ios;

	cin>>N;
	cin>>(s+1);
	solve();
	
	return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  int N,M;
  int T[105]={};
  int P,X;
  int sum = 0;
  int out = 0;
  cin >> N;
  for (int i=1; i <= N; i++) {
    cin >> T[i];
    sum += T[i];
  }
  cin >> M;
  for (int i=1; i <= M; i++) {
    cin >> P >> X;
    out = sum - T[P] + X;
    cout << out << endl;
  }

  return 0;
}


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

int main() {
  long A,B;
  cin >> A>>B;
  long c=__gcd(A,B); 
  long N=c;
  bool a=true;
  int ans=1;
  while(a){
    a=false;
    for (int i = 2; i <= (int)sqrt(c); i++) {
        if(c%i==0){
          a=true;
        }
      }
    if(a){
    for (int i = 2; i <= (int)sqrt(c); i++) {
      if(c%i==0){
        c/=i;
        ans++;
      }
      while(c%i==0){
        c/=i;
      }
    }
    }
    else{
      if(c!=1){
        ans++;
      }
    }
  }
      
    
    cout <<ans<< endl;
  
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let big_int = 998244353;

    // 'R', 'G', 'B', 'RG', 'GB' , BR
    let mut count = vec![0; 6];

    let mut ans = 1i64;
    for i in 1..n as i64 + 1 {
        ans *= i;
        ans %= big_int;
    }
    for ch in s {
        match ch {
            'R' if count[4] > 0 => {
                ans *= count[4];
                count[4] -= 1;
            }
            'R' if count[1] > 0 => {
                ans *= count[1];
                count[3] += 1;
                count[1] -= 1;
            }
            'R' if count[2] > 0 => {
                ans *= count[2];
                count[5] += 1;
                count[2] -= 1;
            }
            'R' => count[0] += 1,

            'G' if count[5] > 0 => {
                ans *= count[5];
                count[5] -= 1;
            }
            'G' if count[0] > 0 => {
                ans *= count[0];
                count[3] += 1;
                count[0] -= 1;
            }
            'G' if count[2] > 0 => {
                ans *= count[2];
                count[4] += 1;
                count[2] -= 1;
            }
            'G' => count[1] += 1,

            'B' if count[3] > 0 => {
                ans *= count[3];
                count[3] -= 1;
            }
            'B' if count[0] > 0 => {
                ans *= count[0];
                count[5] += 1;
                count[0] -= 1;
            }
            'B' if count[1] > 0 => {
                ans *= count[1];
                count[4] += 1;
                count[1] -= 1;
            }
            'B' => count[2] += 1,
            _ => unreachable!(),
        }
        ans %= big_int;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

string to_string(string s) {
	return '"' + 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...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
	int n;
	cin >> n;
	vector<int> P(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> P[i];
	}
	int cnt = 0;
	for (int i = 2; i < n; ++i) {
		vector<int> v = {P[i - 1], P[i], P[i + 1]};
		sort(v.begin(), v.end());
		if (P[i] == v[1]) {
			++cnt;
		}
	}
	cout << cnt << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	return 0;
}

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

#define int long long
#define pb push_back
#define DBGB if (true)

template<typename A, typename B> ostream& operator<<(ostream& out, const pair<A, B>& p) { return out << "(" << p.first << ", " << p.second << ")"; }
//template<typename Ch, typename Tr, typename C> basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& out, const C& xs) { out << "["; for (const auto& x: xs) out << x << ", "; out << "]"; }

const int MOD = 1e9+7;

int n;
string s;

signed main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>n>>s;
	int totcnt=1,open=0;
	for (int i=0; i<2*n; ++i) {
		int flipthis=0;
		if(s[i]=='B') flipthis=1;
		else assert(s[i]=='W');
		if(open%2==flipthis) {  // cannot open here
    		if (open==0) totcnt=0;
    		else {
				totcnt=(totcnt*open)%MOD;
				--open;
			}
    	}
    	else  /*need to open here*/ ++open;
	}
	if(open>0) totcnt=0;
	for(int i=1;i<=n;i++) totcnt=(totcnt*i)%MOD;
	cout<<totcnt%MOD<<endl;
	return 0;
}

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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    long long a[n][m];
    long long b[m][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            long long t=0;
            for(int k=0;k<m;k++){
                t+=a[i][k]*b[k][j];
            }
            if(j!=l-1)printf("%lld ",t);
            else printf("%lld\n",t);
        }
    }
}


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

int main() {
  ll n,x; cin >>n >>x;
  vector<ll> a(n);
  rep(i,n) cin >>a.at(i);
  ll ans = 0;
  if (a.at(0)+a.at(1) > x){
    ll buf = 0;
    buf = min(a.at(0)+a.at(1)-x, a.at(1));
    ans += buf; a.at(1) -= buf;
    if (a.at(0) > x){
      buf = a.at(0) - x;
      ans += buf; a.at(0) -= buf;
    }
  }
  rep(i,n-1){
    ll buf = 0;
    if (a.at(i)+a.at(i+1) <= x) continue;
    buf = (a.at(i)+a.at(i+1))-x;
    ans += buf; a.at(i+1) -= buf;
  }
  cout <<ans <<endl;
}


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


def solve(N: int, x):
    x = list(set(x))
    xs = [_[0] for _ in x]
    ys = [_[1] for _ in x]
    sum_n = [x_+y_ for x_, y_ in zip(xs, ys)]
    sum_m = [x_-y_ for (x_,y_) in zip(xs, ys)]

    a = max(max(sum_n)- min(sum_n), max(sum_m)-min(sum_m))
    print(a)
    

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    x = [()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = (int(next(tokens)),int(next(tokens)))
    solve(N, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 57688
a = []
b = []
c = []
calc = 0

n, m = map(int, input().split())
i = 0
j = 0

while i < n:
    a.append(list(map(int, input().split())))
    i += 1

while j < m:
    b.append(int(input()))
    j += 1

i = 0
j = 0
while i < n:
    calc = 0
    j = 0
    while j < m:
        calc += a[i][j] * b[j]
        j += 1 
    c.append(calc)
    i += 1

i = 0
while i in range(len(c)):
    print(c[i])
    i += 1


Measured memory_bytes: 6024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		string str;
		cin >> str;
		for(int j=0;j<str.size();j++)
		{
			for(int k=1;k<str.size();k++)
			{
				int id=j;
				string tmp;
				while(id<str.size())
				{
					tmp+=str[id];
					if(s==tmp)
					{
						ans++;
						goto end;
					}
					id+=k;
				}
			}
		}
		end:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1212
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char dn[1300000], * di = dn;
int keta1 = 1, keta2;
char C1[10] = { '1', '0', '0', '0', '0', '0' };
char C2[10] = { '0', '0', '0', '0', '0', '0' };

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


	int N, M;
	scanf("%d %d", &N, &M);

	if (N % 2) {
		int n = N - 1;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}

		rep1(i, M) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}
	else {
		int n = N;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}
		rep1(i, (M + 1) / 2) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
		C2[0]--;
		int tmp = 0;
		while (C2[tmp] < '0') {
			C2[tmp++] += 10;
			C2[tmp]--;
			if (C2[keta2 - 1] == '0') keta2--;
		}
		for (int i = (M + 1) / 2 + 1; i <= M; i++) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (C1[keta1] != '0') keta1++;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2620
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[5000];
    ll n,ans=0;
    scanf("%lld%s",&n,s);
    ll r[n],g[n],b[n];
    r[n-1]=0; g[n-1]=0; b[n-1]=0;
    rrep(i,n-2,0){
        if(s[i+1]=='R') r[i]=r[i+1]+1;
        else r[i]=r[i+1];

        if(s[i+1]=='G') g[i]=g[i+1]+1;
        else g[i]=g[i+1];

        if(s[i+1]=='B') b[i]=b[i+1]+1;
        else b[i]=b[i+1];
    }

    rep(i,0,n-2){
        rep(j,i+1,n-1){
            if(s[i]==s[j]) continue;
            if(s[i]!='B' && s[j]!='B' ){
                ans+=b[j];
                if(2*j-i<n && s[2*j-i]=='B') ans--;
            }
            if(s[i]!='R' && s[j]!='R' ){
                ans+=r[j];
                if(2*j-i<n && s[2*j-i]=='R') ans--;
            }
            if(s[i]!='G' && s[j]!='G' ){
                ans+=g[j];
                if(2*j-i<n && s[2*j-i]=='G') ans--;
            }
        }
    }

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1808
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	string N, M;
	ll sum=0;
	cin >> N >> M;
	if (N == "H")sum += 1;
	if (M == "H")sum += 1;
	if (sum % 2 == 0)cout << "H"<<endl;
	else cout << "D"<<endl;

	return 0;
}

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

if N == 1:
    print(1)
else:
    L = [0] * (N + 1)
    L[0] = 2
    L[1] = 1
    for i in range(2, N + 1):
        L[i] = L[i - 1] + L[i - 2]
    print(L[N])


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

// types - only for stuff used a lot 
using ll = long long;
using ld = long double;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; cin >> n;
	int x[n],y[n];
	int dx[n],dy[n];
	f(i,0,n) {
		cin>>x[i]>>y[i];
		string s; cin >> s;
		dx[i]=dy[i]=0;
		if (s == "U")
			dy[i]=1;
		if (s == "D")
			dy[i]=-1;
		if (s == "L")
			dx[i]=-1;
		if (s == "R")
			dx[i]=1;

	}
	auto eval = [&](ld t) {
		ld x_min = loo, x_max = -loo, y_min = loo, y_max = -loo;		
		f(i,0,n) {
			ri(x_min,x[i]+dx[i]*t);
			re(x_max,x[i]+dx[i]*t);
			ri(y_min,y[i]+dy[i]*t);
			re(y_max,y[i]+dy[i]*t);
		}
		return (x_max-x_min)*(y_max-y_min);
	};
	ld lo = 0, hi = 1e10;
	f(_,0,300) {
		ld mid1 = lo+(hi-lo)/3;
		ld mid2 = hi-(hi-lo)/3; 
		ld a = eval(mid1), b = eval(mid2);
		if (a<b) hi=mid2;
		else lo=mid1;
	}
	
	printf("%.30Lf\n",eval(lo));

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}



Measured memory_bytes: 1920