akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    string s;
    cin>>s;
    int flag=0;
    char c=s[0];
    for(int i=1;i<4;i++){
        if(s[i]==c) flag=1;
        c=s[i];
    }
    if(flag) cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vl a(n + 1);
    vl b(m + 1);
    ll x ;
    REP(i, n) {
        cin >> x;
        a[i + 1] = a[i] + x;
    }
    REP(i, m) {
        cin >> x;
        b[i + 1] = b[i] + x;
    }

    int ans = 0;
    REP(i, n + 1) {
        ll r = k - a[i];
        if (r < 0) break;
        auto itr = lower_bound(ALL(b), r);
        if (itr == b.end()) chmax(ans, i + (int)m);
        else {
            if (*itr == r) chmax(ans, (int)distance(b.begin(), itr) + i);
            else chmax(ans, max(0, (int)distance(b.begin(), itr) - 1) + i);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 6300
package main

import (
	"fmt"
	"sort"
)

func main() {

	var N, L int
	fmt.Scanf("%d %d", &N, &L)

	S := make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S[i])
	}

	sort.Sort(sort.StringSlice(S))
	for i := 0; i < N; i++ {
		fmt.Printf("%s", S[i])
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 1880
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 3010;
ll dp[N][N];

int main() {
    int n;
    cin >> n;
    VL a(n);
    REP(i,n) a[i] = in();
    REP(i,n){
        if (n % 2) dp[i][i] = a[i];
        else dp[i][i] = -a[i];
    }
    FORR(t,n-2,0){
        int len = n - t;
        REP(i,n-len+1){
            int j = i + len - 1;
            if (t % 2 == 0){
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j]);
            }else{
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j]);
            }
        }
    }

    cout << dp[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 70016
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll A[MAX_N];
    ll S[MAX_N][2];
    ll answer;
    
    cin >> N;
    rep(i, N) cin >> A[i];

    S[0][0] = 0;
    S[0][1] = - INF;
    
    rep(i, N - 1){
        S[i + 1][0] = max(S[i][0] + A[i], S[i][1] - A[i]);
        S[i + 1][1] = max(S[i][0] - A[i], S[i][1] + A[i]);
    }

    S[N][0] = max(S[N - 1][0] + A[N - 1], S[N - 1][1] - A[N - 1]);

    cout << S[N][0] << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

ll N,K,L=1,R;
ll A[200200];

ll canCut(ll length){
    // cout<<"length: "<<length<<endl;
    ll ans=0;
    rep(i,N){
        ans+=(A[i]+length-1)/length-1;
    }
    // cout<<"ans: "<<ans<<endl;
    return ans;
}

int main(){
    cin>>N>>K;
    rep(i,N){
        cin>>A[i];
        R=max(R,A[i]);
    }
    ll mid;
    do{
        mid=(L+R)/2;
        if(canCut(mid)>K){
            L=mid;
        } else {
            R=mid;
        }
    }while(L+1<R);
    if(canCut(L)<=K)out(L);
    else out(R);
}

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

namespace AtCoder
{
    class Abc142D
    {
        public static void Main()
        {
            var ab = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            var a = ab[0];
            var b = ab[1];

            var c = Gcd(a, b);

            var primeFactors = new List<long>();

            if (c % 2 == 0)
            {
                primeFactors.Add(2);
                while (c % 2 == 0)
                    c /= 2;
            }

            for (long i = 3; i * i <= c; i += 2)
            {
                if (c % i != 0)
                    continue;
                primeFactors.Add(i);
                while (c % i == 0)
                    c /= i;
            }

            if (c != 1)
                primeFactors.Add(c);

            Console.WriteLine(primeFactors.Count + 1);
        }

        public static long Gcd(long a, long b)
        {
            if (a > b)
            {
                var c = a;
                a = b;
                b = c;
            }

            while (a > 0)
            {
                var r = b % a;
                b = a;
                a = r;
            }
            return b;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	if (a > b)cout << "Alice" << endl;
	else if (a < b)cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
}


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

s = input()
s = list(s)

str1 = ''
str2 = ''

half = n/2 - 1

if n%2 == 0:
    for i in range(n):
        if i <= half:
            str1 += s[i]
        else:
            str2 += s[i] 
    if str1 == str2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        
        int counter = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (counter + 1 == num) {
                counter++;
            }
        }
        
        if (counter == 0) {
            System.out.println(-1);
            return;
        }
        
        System.out.println(n - counter);
    }
}


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

const char Col[2][2] = { { 'R','Y' },{ 'G','B' } };
int H, W, d;

char get_col(int x, int y) {
	int i = (x / d) % 2;
	int j = (y / d) % 2;
	return Col[j][i];
}

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

	cin >> H >> W >> d;
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			int x = i + j;
			int y = i - j + H;
			char c = get_col(x, y);
			cout << c;
			if (i == W - 1)
				cout << '\n';
		}
	}
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	int a=0,b=0,c=0,d=0;
	while(n--){
		string s;
		cin>>s;
		if(s[0]=='A') a++;
		if(s[0]=='W') b++;
		if(s[0]=='T') c++;
		if(s[0]=='R') d++;
	}
	cout<<"AC x "<<a<<'\n';
	cout<<"WA x "<<b<<'\n';
	cout<<"TLE x "<<c<<'\n';
	cout<<"RE x "<<d<<'\n';
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];    
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(ALL(a));    
    sort(ALL(b));
    sort(ALL(c));

    vector<ll> d(n);
    rep(i, n){
        d[i] = (ll)(c.size() - (upper_bound(ALL(c), b[i]) - c.begin()));
    }

    for(int i=n-2; i>=0; i--) d[i] += d[i+1];

    ll ans = 0;
    rep(i, n){
        int t = upper_bound(ALL(b), a[i]) - b.begin();
        if(t<n) ans += (ll)d[t];
    }
    cout << ans << endl;
    
  	return 0;
}


Measured memory_bytes: 5360
N = int(input())
edge = 0
for i in range(N-1):
    u,v = map(int,input().split())
    if u > v:
        a = u
        u = v
        v = a
    edge += u*(N-v+1)

vertice = 0    
for i in range(1,N+1):
    vertice += i*(N-i+1)
    
print(vertice-edge)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	ll a, b;
	cin >> a >> b;
	int cnt = 0;
	for(; a <= b; a *= 2, cnt++);
	cout << cnt << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  vector<tuple<int,int> > vec;
  while(true)
  {
    int a,b;
    cin>>a>>b;
    if((a==0) && (b==0)) break;
    vec.emplace_back(a,b);
  }


  for (int i = 0; i < vec.size(); i++)
  {
    int H,W;
    H = get<0>(vec[i]);
    W = get<1>(vec[i]);

    for (int h = 0; h < H; h++)
    {
      for (int w = 0; w < W; w++)
      {
        cout<<"#";
      }
      cout<<endl;
    }
      cout<<endl;
    
  }

  return;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



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

int x, a, b;

int main() {
	cin >> x >> a >> b;
	if(b - a > x) {
		puts("dangerous");
	} else if(b - a <= x && b - a > 0) {
		puts("safe");
	} else if(b - a <= 0 && b - a <= x) {
		puts("delicious");
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect
from math import factorial


def main():
    K = int(input())
    #N, M, K = map(int, input().split())

    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(A[K-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int r=Integer.parseInt(scan.next());
    		int g=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		
    		System.out.print((r*100+g*10+b)%4==0?"YES":"NO");
    		
    	
  
    				
 
     
    }
    }

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

int main(){

    string s;
    cin >> s;

    int size = s.size();
    int ans = 0;
    char temp = s.at(0);
    for (int i=1; i<size; i++){
        if (temp == s.at(i)){
            ans++;

            if (s.at(i) == '0') s.at(i) = '1';
            else s.at(i) = '0'; 
        }
        temp = s.at(i);
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

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

int main(){
    int n; cin>>n;
    int k[101]={};
    int m=0;
    FOR(i,0,n){
        int a; cin>>a;
        k[a]++;
        m=max(m,a);
    }
    bool flag=true;
    FOR(i,1,101){
        if(i==(m+1)/2){
            if(k[i]>1+m%2) flag=false;
        }else if((m+1)/2<i && i<=m){
            if(k[i]<2) flag=false;
        }else{
            if(k[i]!=0) flag=false;
        }
    }
    Pos(flag);
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int a[n+1];
    REP(i,n+1){
        cin >> a[i];
    }
    ll count = 0;
    REP(i,n){
        int b;
        cin >> b;
        int num = min(b,a[i]);
        count += min(b,a[i]);
        b -= num;
        if(b>0){
            int num = min(b,a[i+1]);
            count += num;
            a[i+1] -= num;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 640
N, P = map(int, input().split())
O = sum([int(a) % 2 for a in input().split()])
E = N - O
fa = [1]
for i in range(1, 51):
    fa.append(fa[-1] * i)
ans = 0
for i in range(P, O+1, 2):
    ans += fa[O] // (fa[i] * fa[O-i])

print(ans * 2**E)

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

#define N 100005
ll n;
vector<ll>v[N];
ll dp[N];
ll dfs(ll id,ll par){
    vector<ll>res;
    for(auto x:v[id]){
        if(x==par)continue;
        res.pb(dfs(x,id));
    }
    sort(res.begin(),res.end());
    ll sum=0;
    ll vs=res.size();
    rep(i,0,vs-1){
        if(i==0)sum+=res[i];
        else sum+=max(1,res[i]);
    }
    dp[id]=sum;
    return dp[id];
}

int main(){fastio
    cin>>n;
    if(n==2){
        cout<<1<<endl;return 0;
    }
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    ll mx=0;
    rep(i,0,n-1){
        if(v[i].size()>v[mx].size())mx=i;
    }
    ll i=mx;
    ll ans=dfs(i,-1);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 15744
#include <stdio.h>
#include <math.h>

void insert(int code);
void find(int code);

/*
A:1
C:2
G:3
T:4
 */

char dictionary[390626];
int dictLen = 0;

main(){

  int i,j,n,code;
  char command[7], op;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command);
    j=0; code=0;
    while(j<=8){
      scanf("%c",&op);
      if(op=='\n') break;
      switch(op){
      case 'A':
	code+=1*pow(4,j);
	break;
      case 'C':
	code+=2*pow(4,j);
	break;
      case 'G':
	code+=3*pow(4,j);
	break;
      case 'T':
	code+=4*pow(4,j);
	break;
      default:
	j--;
      }
      j++;
    }
    if(command[0] == 'i'){ // insert
      insert(code);
    }else if(command[0] == 'f'){ // find
      find(code);
    }
  }

  return 0;

}

void insert(int code){
  dictionary[code] = 1;
}

void find(int code){
  if(dictionary[code] == 1) printf("yes\n");
  else printf("no\n");
}

Measured memory_bytes: 488
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

type Num struct {
	Num int
}

type Nums []Num

func (n Nums) Len() int {
	return len(n)
}

func (n Nums) Swap(i, j int) {
	n[i], n[j] = n[j], n[i]
}

func (n Nums) Less(i, j int) bool {
	return n[i].Num < n[j].Num
}

func main() {
	s := IOInitialize()
	n := Int(s)
	nums := scanNums(s, n)
	sort.Sort(nums)
	max := nums[n-1].Num
	min := nums[0].Num
	minDistance := abs((max - min) - min)
	for i := 0; i < n-1; i++ {
		num := nums[i].Num
		distance := abs((max - num) - num)
		if minDistance > distance {
			min = num
			minDistance = distance
		}
	}
	fmt.Println(fmt.Sprintf("%d %d", max, min))
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func scanNums(s *bufio.Scanner, len int) (nums Nums) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, Num{Num: num})
	}
	return
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	return s.Text()
}


Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;


int main() {
   int h, w;
    cin >> h >> w;
    int count = 0;
    for (int i = 0; i < h; i++) {
        string str;
        cin >> str;
        for (int j = 0; j < w; j++) {
            count += str[j] == '#';
        }
    }
    cout << (count==h+w-1 ? "Possible" : "Impossible");
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vi as(n);
	 trav(x, as) cin >> x;
	int odd = 0, even = 0;
	trav(x, as) (x%2 ? odd : even)++;
	int tot = 1;
	rep(_,0,n) tot *= 3;
	int bad = 1;
	rep(_,0,even) bad *= 2;
	cout << tot - bad << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n):
        a = l[i]
        for j in range(i):
            b = l[j]
            c = a+b
            k = bisect.bisect_left(l,c)-i-1
            ans += k
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

void display(int A[], int N) {
  int i;
  for(i = 0; i < N; i++) {
    if(i > 0) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
}

void insert_sort(int A[], int N) {
  int i, j, tmp;
  for(i = 1; i < N; i++) {
    tmp = A[i];
    j = i;
    while(j > 0 && A[j-1] > tmp) {
      A[j] = A[j-1];
      j--;
    }
    A[j] = tmp;
    display(A, N);
  }
}


int main(){
  int N, A[100];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  display(A, N);
  insert_sort(A, N);

  return 0;


}



Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double sum = 0;
	double a[1000];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum =sum+( 1 / a[i]);
	}
	cout << 1 / sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a;
    cin>>a;
    if(a[2]==a[3] and a[4]==a[5])
    	cout<<"Yes\n";
    else
    	cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	char c;
	cin >> c;
	if ('A' <= c && c <= 'Z') cout << "A" << endl;
	else cout << "a" << endl;
	return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
   int w,h,x,y,r;
   scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
   if(0<=x-r && 0<=y-r && x+r<=w && y+r<=h)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];
int X[202020],Y[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		X[i]=30000*(i+1);
		Y[i]=30000*(N+1-i);
	}
	FOR(i,N) {
		cin>>A[i], A[i]--;
		X[A[i]]+=i;
		Y[A[i]]+=i;
	}
	
	FOR(i,N) _P("%d%c",X[i],(i==N-1)?'\n':' ');
	FOR(i,N) _P("%d%c",Y[i],(i==N-1)?'\n':' ');
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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

N, M = MAP()
a = [INT() for _ in range(M)]
b = [0] * (N+2)  # こわれているところに１たてる
for i in a:
	b[i] = 1

dp = [0]*(N+2)
dp[0] = 1
if b[1] == 1:
	dp[1] = 0
else:
	dp[1] = 1

# print(dp)
for i in range(2, N+1):
	if b[i] == 1:  # こわれてる
		dp[i] = 0
	else:
		dp[i] = (dp[i-1] + dp[i-2])%MOD
# print(dp)
print(dp[N])



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


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

    string si;
    set<string> s;
    rep(i, N) {
        cin >> si;
        s.insert(si);
    }

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

    return 0;
}



Measured memory_bytes: 19256
from itertools import combinations
 
n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
 
fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x)
 
while all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)


Measured memory_bytes: 3064
#![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>();
    // "AC", "WA", "TLE", "RE"
    let mut count = vec![0; 4];

    for i in 0..n {
        let s = read::<String>();
        if s == "AC" {
            count[0] += 1;
        } else if s == "WA" {
            count[1] += 1;
        } else if s == "TLE" {
            count[2] += 1;
        } else {
            count[3] += 1;
        }
    }
    println!("AC x {}", count[0]);
    println!("WA x {}", count[1]);
    println!("TLE x {}", count[2]);
    println!("RE x {}", count[3]);
    // count.insert("WA", 0);
    // count.insert("TLE", 0);
    // count.insert("RE", 0);
}

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: 2136
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#include <string>
using namespace std;

int main(){
    string s; cin >> s;
    int n = s.length();
    long long int ans = 0;
    int bn = 0;
    int c=0;
    for(int i=0;i<n;i++){
        if(s[i] == 'B') bn++;
    }
    for(int i=0;i<n;i++){
        if(s[i] == 'B'){
            ans = ans + (n - bn + c - i);  
            c++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
#define pii pair<int,int>
#define mp make_pair
const int M=2e5+10; 
LL tmp;
pii s[M],d[M];
pii gt(LL x){
	int p=0,q=0; tmp=x;
	while (tmp%2==0) tmp>>=1,p++;
	while (tmp%5==0) tmp/=5,q++;
	return mp(p,q);
}
int c[30][30][30][30];
int n,ct;
LL z[M],mu[M]; 
double a[M];
int main(){
	cin.tie(0);
	cin>>n; LL ans=0;
	int ct=0;
	F(i,1,n){
		cin>>a[i];
		z[i]=llround(a[i] * 1e9);;
		mu[i]=1e9;
		LL ddd=__gcd(z[i],mu[i]);
		z[i]/=ddd; mu[i]/=ddd;
//		cout<<z[i]<<" "<<mu[i]<<"\n";
		ct++;
		s[ct]=gt(z[i]); d[ct]=gt(mu[i]);
//		cout<<tmp<<"  ??\n";
		if (tmp>1){
			ct--;
		}
		else{
			F(j,0,s[ct].first){
				F(k,0,s[ct].second){
					ans+=c[j][k][d[ct].first][d[ct].second];
				}
			}
			F(l,0,s[ct].first){
				F(ll,0,s[ct].second){
					c[d[ct].first][d[ct].second][l][ll]++; 
				}
			}
//			cout<<s[ct].first<<" "<<s[ct].second<<"   gg\n";
		}
//		cout<<ans<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 11772
<?php
fscanf(STDIN, "%d %d", $h, $w);
$b = str_repeat('#', $w + 2);
$x[] = $b;
while ($h--) {
	$s = trim(fgets(STDIN));
	$x[] = "#$s#";
}
$x[] = $b;
echo implode("\n", $x);

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

int main(){
	int count = 0;
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N){
	cin >> A[i];
	if(A[i] % 2 == 0) count++;
	}

	cout << pow(3,N) - pow(2,count) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(void){
  unsigned int N, a, b;
 
  cin >> N;
  vector<pair<int,int>> AB;
  for(int i=0; i<N; i++){
    cin >> a >> b;
    AB.emplace_back(b,a);
  }
  
  sort(AB.begin(),AB.end());
  
  int cTime = 0;
  bool flag = true;
  for(int it=0; it<N; it++){
    //cout << cTime << "," << AB[it].first << "," << AB[it].second << endl;
    cTime += AB[it].second;
    if(cTime > AB[it].first){
      flag = false;
      break;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 2420
H, W, N = map(int, input().split())
posObss = [{H} for y in range(W)]
for _ in range(N):
    X, Y = map(int, input().split())
    posObss[Y - 1].add(X - 1)

ans = H
xNow = 0
for y in range(W):
    xLim = min([x for x in posObss[y] if x > xNow])
    ans = min(ans, xLim)

    if y == W - 1: break
    xNow += 1
    while xNow in posObss[y + 1]:
        xNow += 1
    if xNow >= xLim: break

print(ans)


Measured memory_bytes: 57516
import sys
import math
from collections import deque
from collections import Counter

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    H, W, N = NMI()
    grid = {}
    for i in range(N):
        a, b = NMI()
        for t in range(-2, 1):
            for k in range(-2, 1):
                if a + t < 1 or b + k < 1:
                    continue
                if a + t >= H - 1 or b + k >= W - 1:
                    continue
                point = (a+t) * 10**10 + b+k
                grid[point] = grid.get(point, 0) + 1
    c = Counter(grid.values())
    for i in range(10):
        if i == 0:
            print((H-2)*(W-2) - sum(c.values()))
        else:
            print(c.get(i, 0))


if __name__ == "__main__":
    main()

Measured memory_bytes: 104320
// Create time: 2019-09-21  19:59:16
#include <bits/stdc++.h>
#define rint register int
using namespace std;

#define N 200005

int n, K, a[N];

int mx[N << 2], mi[N << 2];

void Build(int l, int r, int pos) {
    if (l == r) {
        mx[pos] = a[l];
        mi[pos] = a[l];
        return ;
    } rint mid = (l + r) >> 1;
    Build(l, mid, pos << 1);
    Build(mid + 1, r, pos << 1 | 1);
    mx[pos] = max(mx[pos << 1], mx[pos << 1 | 1]);
    mi[pos] = min(mi[pos << 1], mi[pos << 1 | 1]);
}

int Queryx(int l, int r, int L, int R, int pos) {
    if (L <= l && r <= R) return mx[pos];
    int mid = (l + r) >> 1, res = -1;
    if (L <= mid) res = Queryx(l, mid, L, R, pos << 1);
    if (mid < R) res = max(res, Queryx(mid + 1, r, L, R, pos << 1 | 1));
    return res;
}

int Queryi(int l, int r, int L, int R, int pos) {
    if (L <= l && r <= R) return mi[pos];
    int mid = (l + r) >> 1, res = n + 2;
    if (L <= mid) res = Queryi(l, mid, L, R, pos << 1);
    if (mid < R) res = min(res, Queryi(mid + 1, r, L, R, pos << 1 | 1));
    return res;
}

int f[N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    int k;
    cin >> n >> k;
    for (rint i = 1; i <= n; ++i)
        scanf("%d", a + i);
    for (rint i = 1; i <= n; ++i) {
        if (a[i - 1] < a[i]) f[i] = f[i - 1] + 1;
        else f[i] = 1;
    } Build(1, n, 1);
    int check = 0;
    for (rint i = k + 1; i <= n; ++i)
        check += f[i] >= k;
    int ans = 0;
    if (check) ++ans;
    if ((f[k] == k && !check) || (f[k] < k)) ++ans;
    for (rint i = 2; i + k - 2 < n; ++i) {
        int Mx = Queryx(1, n, i, i + k - 2, 1);
        int Mi = Queryi(1, n, i, i + k - 2, 1);
        if (f[i + k - 1] >= k) continue;
        if (a[i - 1] < Mi && Mx < a[i + k - 1]) continue;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7168
s = str(input())

ans = 0

def kaibun(tex):
  n = len(tex)
  before = tex[0:int((n-1)/2)]
  after = tex[int((n+3)/2-1):]
  if before == before[::-1] and after == after[::-1]:
    return 1
  else:
    return 0

ans += kaibun(s)

if ans == 1 and s == s[::-1]:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
typedef long long ll;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int N = 2e5 + 5;
const int inf = 2e9;
int n, a[N], lc[N], rc[N];
ll ans;
void solve(int l, int r) {
	if (l == r) {
		ans += a[l];
		return;
	}
	
	int mid = l + r >> 1;
	
	lc[mid + 1] = rc[mid] = inf;
	for (int i = mid; i >= l; --i) lc[i] = std :: min(lc[i + 1], a[i]);
	for (int i = mid + 1; i <= r; ++i) rc[i] = std :: min(rc[i - 1], a[i]);
	
	int tl = mid, tr = mid + 1;
	while (tl >= l || tr <= r) 
		if (tl < l || (tr <= r && rc[tr] > lc[tl])) ans += (ll)rc[tr++] * (mid - tl);
		else ans += (ll)lc[tl--] * (tr - mid - 1);
	
	solve(l, mid), solve(mid + 1, r);
	return;
}
int main() {
	n = Get();
	for (int i = 1; i <= n; ++i) a[i] = Get();
	
	solve(1, n);
	printf("%lld\n", ans);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long n, k;

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> n >> k;
    cout << min(n % k, k - n % k) << '\n';
}


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

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	int aristas;
	int nodos;

	cin >> nodos >> aristas;
	
	vector <int> alturas(nodos);
	vector <vector <int> > graph(nodos);

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

	int u, v;

	for (int i = 0; i < aristas ; ++i)
	{
		cin >> u >> v;
		
		u--;
		v--;

		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	bool can = true;
	int ans = 0;
	int n;

	for (int i = 0; i < nodos; ++i)
	{
		can = true;

		for (int j = 0; j < graph[i].size(); ++j)
		{
			n = graph[i][j];
			if(alturas[n] >= alturas[i]){
				can = false;
				break;
			}
		}
		
		if(can)
			ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 8736
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}






int main() {
	int a,b,k;
	cin >>a>>b>>k;
	int i = 0;
	int j = 100;
	while (1) {
		if (a%j == 0 && b%j == 0) {
			i++;
			if (i == k) {
				cout << j << endl;
				return 0;
			}
		}
		j--;
	}




	


	return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("avx,avx2,fma,sse,sse2")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll= long long;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0)cout<<(b-a)/2<<endl;
    else cout<<min((a-1)+((b-a)+1)/2,(n-b)+(n-(a+(n-b))+1)/2)<<endl;

}


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

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, p1, p2, x;
            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            p1 = n * a;
            p2 = b;
            if (p1 <= p2)
                x = p1;
            else 
                x = p2;

            Console.WriteLine(x);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int A,i;
    string X;

    cin >> X;

    if(X == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}

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

void solve() {
    ld x, curr = 100;
    cin >> x;
    ll ans = 0;
    while(curr < x) {
        curr += floor(curr / 100);
        ans++;
    }
    cout << ans;
}   

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3700
#pragma GCC optmize ("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define spIO ios::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
typedef long double ld;
string s, front, back;
int q, rev = 0;
int main()
{
	spIO;
	cin >> s >> q;
	int ti, fi;
	char ci;
	while (q--)
	{
		cin >> ti;
		if (ti == 1)
			rev++;
		else
		{
			cin >> fi >> ci;
			if (fi == 2)
				fi = 0;
			if ((rev & 1) ^ fi)
				front += ci;
			else
				back += ci;
		}
	}
	if ((rev & 1) == 0)
	{
		reverse(front.begin(), front.end());
		cout << front << s << back;
	}
	else
	{
		reverse(back.begin(), back.end());
		reverse(s.begin(), s.end());
		cout << back << s << front;
	}
}

Measured memory_bytes: 1040
#include <iostream>
#include <cstdio>
#include <fstream>
using namespace std;

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int q;
  cin >> q;

  double x, y, k;
  double ax, ay, bx, by;
  double hx, hy;
  double ansx, ansy;
  for(int i=0; i<q; i++){
    cin >> x >> y;
    ax = x-x1; ay = y-y1;
    bx = x2-x1; by = y2-y1;
    k = (ax*bx + ay*by)/(bx*bx + by*by);
    hx = bx*k+x1+0; hy = by*k+y1+0;
    ansx = hx + (hx-x); ansy = hy + (hy-y);
    printf("%.10lf %.10lf\n", ansx, ansy);
  }

  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    bool flag1 = false, flag2 = false;

    rep(i,s.length()){
        if(flag1 == false){
            if(s[i] == 'C'){
                flag1 = true;
            }
        }
        if(flag1 == true && flag2 == false){
            if(s[i] == 'F'){
                flag2 = true;
            }
        }
    }
    if(flag2 == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define rev(v) 	v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << endl;
}

int main() {
	int white = 0;
	vvb maze;
	vb tmp;
	int H, W;
	vvb is_done;
	deque<pair<int, pair<int, int>>> que;
	cin >> H >> W;
	rep(W + 2)tmp.push_back(false);
	rep(H + 2)is_done.push_back(tmp);
	maze.push_back(tmp);
	rep(H) {
		tmp.clear();
		tmp.push_back(false);
		makes(s);
		for (char x : s) {
			if (x == '#')tmp.push_back(false);
			else tmp.push_back(true);
		}
		tmp.push_back(false);
		maze.push_back(tmp);
	}
	tmp.clear();
	rep(W + 2)tmp.push_back(false);
	maze.push_back(tmp);

	for (vb i : maze)
		for (bool j : i)
			if (j) ++white;

	is_done[1][1] = true;
	que.push_back({ 1,{1,1} });
	while (!que.empty()) {
		/*for (vb i : is_done) {
			for (bool j : i) {
				if (j)cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << endl;
		*/
		int trun = que.front().first + 1;
		int x = que.front().second.first;
		int y = que.front().second.second;
		if ((x == H && y == W - 1) || (x == H - 1 && y == W)) {
			say(white - trun);
			re;
		}
		if (maze[x + 1][y] && !is_done[x + 1][y]) {
			que.push_back({ trun,{x + 1,y} });
			is_done[x + 1][y] = true;
		}
		if (maze[x][y + 1] && !is_done[x][y + 1]) {
			que.push_back({ trun,{x,y + 1} });
			is_done[x][y + 1] = true;
		}
		if (maze[x - 1][y] && !is_done[x - 1][y]) {
			que.push_back({ trun,{x - 1,y} });
			is_done[x - 1][y] = true;
		}
		if (maze[x][y - 1] && !is_done[x][y - 1]) {
			que.push_back({ trun,{x,y - 1} });
			is_done[x][y - 1] = true;
		}
		que.pop_front();
	}
	say(-1);
}
/*
	幅優先探索で最短路を求めて、全体の白のマスの個数から引く。
*/

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

int main(){
  int N; cin >> N;
  long long md = 1e9+7;
  vector<long long> one(63,0), zero(63,0);
  long long score = 0;
  for (int i=0; i<N; i++){
    long long A; cin >> A;
    for (int i=0; i<63; i++){
      if(A&1){
        one[i]++;
      } else {
        zero[i]++;
      }
      A >>= 1;
    }
  }
  long long hoge = 1;
  for (int i=0; i<63; i++){
    score += (one[i]*zero[i]%md)*hoge;
    score %= md;
    hoge *= 2;
    hoge %= md;
  }
  cout << score << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	string s,t;
	cin>>s>>t;
	int n=s.size();
	bool ok=true;
	for(int i=0;i<n;i++){
		if(s[i]!=t[i])ok=false;
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628