akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int a[M];
 main()

{

    int n,l;
    scanf("%lld%lld",&n,&l);
    vector<int>ses;
    f(i,1,n)
    {
        scanf("%lld",&a[i]);
    }
    int flag=0;
    for(int i=1;i<n;i++)
    {
        int sum=a[i]+a[i+1];
        if(sum>=l)
        {
            flag=i;
        }
    }
    if(flag==0)
    {
        printf("Impossible\n");
        return 0;
    }
    printf("Possible\n");
    for(int i=1;i<flag;i++)
    {
        printf("%lld\n",i);
    }
    for(int i=n-1;i>flag;i--)
    {
        printf("%lld\n",i);
    }
    printf("%lld\n",flag);
    return 0;

}





































Measured memory_bytes: 4600
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


template<typename T>
class BIT{
    public:
        vector<T> x_list;
        ll n;

        BIT(ll n=1, T fill_value=0): n(n){
            x_list.resize(n+1);
            fill(x_list.begin(), x_list.end(), fill_value);
        }

        void add(ll idx, T v){
            for(ll x=idx; x<= n;x += (x & -x)){
                x_list[x] += v;
            }
        }

        ll get_sum(ll idx){
            T v = 0;
            for(ll x=idx;x>0;x-=(x & -x)){
                v += x_list[x];
            }
            return v;
        }
};

void Main(){
    ll N, Q, c, l, r;
    cin >> N >> Q;
    vector<ll> as(N);
    vector<vector<ll>> pos(N);
    vector<vector<pll>> qs(N);
    vector<ll> cs(N, -1);
    // vector<pll> qs_org(Q);
    vector<ll> ans(Q);
    rep(i, N){
        cin >> c;
        -- c;
        as[i] = c;
        l = cs[c];
        if(l != -1){
             // (s, t)
            pos[l].emplace_back(i);
        }
        cs[c] = i;
    }

    rep(i, Q){
        cin >> l >> r;
        -- l;
        -- r;
        qs[l].emplace_back(r, i);
        // qs_org[i] = make_pair(r, l);
    }

    // sort(qs.begin(), qs.end());

    // ll now_r = qs[0].first;

    BIT<ll> bitree(N, 0);

    for(ll i=N-1;i>=0;--i){
        for(auto p:pos[i]){
            bitree.add(p+1, 1);
        }
        for(auto q:qs[i]){
            ans[q.second] = q.first - i + 1 - bitree.get_sum(q.first+1);
        }
    }
    rep(i, Q){
        cout << ans[i] <<endl;
    }

}

int main(){
    Main();
}

Measured memory_bytes: 70772
#include<stdio.h>
int main() {
  unsigned long s = 100000;
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i ++) {
    s += s / 20;
    if (s % 1000 != 0) s = (s / 1000 + 1) * 1000;
  }
  printf("%lu\n", s);
  return 0;
}

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

int main() {
  char forecast[3];
  char real[3];
  int count;
  
  cin >> forecast >> real;
  
  for(int i=0; i<3; i++) {
    if(forecast[i] == real[i]) {
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){


string Sd,T;
cin>>Sd>>T;
vector<string> Slist;
rep(i,Sd.size()-T.size()+1){
    string s=Sd.substr(i,T.size());
    rep(j,T.size()){
        if(s[j]=='?'){
            s[j]=T[j];
        }

    }
    if(s==T){
        string S=Sd;
        rep(j,T.size())S[i+j]=T[j];
        rep(j,S.size()){
            if(S[j]=='?')S[j]='a';
        }
        Slist.push_back(S);

    }
}

if(Slist.size()==0){
cout<<"UNRESTORABLE"<<endl;
}
else{
    sort(all(Slist));
    cout<<Slist[0]<<endl;
}


return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
long long X[200000], Y[200000];
int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &X[i]);
		Y[i] = X[i];
	}
	sort(Y, Y + N);
	long long an1 = Y[N / 2], an2 = Y[N / 2 - 1];
	//printf("%lld %lld\n", an1, an2);
	for (int i = 0; i < N; i++) {
		if (X[i] < an1) {
			printf("%lld\n", an1);
		}
		else {
			printf("%lld\n", an2);
		}
	}
	return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){

	int n, k, x, y;
	int res = 0;
	cin >> n >> k >> x >> y;

	int l = 0;
	if (n > k){
		l = n - k;
		res = (k*x) + (l*y);
	}
	else res = n*x;
	
	cout << res;

	return 0;
}

Measured memory_bytes: 256
def solve():
    import sys
    input = sys.stdin.readline

    numChar = 26
    #numChar = 5
    ordA = ord('a')

    N = int(input())
    Ss = input()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        datas = [[0]*(numPow2+1) for _ in range(numChar)]
        return datas, numPow2
    def addValue(no, iA, A):
        data = datas[no]
        iB = iA + 1
        while iB <= numPow2:
            data[iB] += A
            iB += iB & -iB
    def getSum(no, iA):
        data = datas[no]
        iB = iA + 1
        ans = 0
        while iB > 0:
            ans += data[iB]
            iB -= iB & -iB
        return ans
    def getRangeSum(no, iFr, iTo):
        return getSum(no, iTo) - getSum(no, iFr-1)


    datas, numPow2 = makeBIT(N)

    for i in range(N):
        no = nos[i]
        addValue(no, i, 1)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            no1 = nos[pos]
            no2 = ord(v2)-ordA
            addValue(no1, pos, -1)
            addValue(no2, pos, 1)
            nos[pos] = no2
        else:
            L, R = int(v1)-1, int(v2)-1
            ans = 0
            for no in range(numChar):
                if getRangeSum(no, L, R):
                    ans += 1
            anss.append(ans)

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 152436
# coding: utf-8

lines = $stdin.read

array = lines.split("\n")

n = array[0].to_i
x = array[1].split(" ")
y = array[2].split(" ")

# p = 1
d = 0
for i in 0..(n-1)
  d += (x[i].to_f - y[i].to_f).abs
end

printf "%f\n",d

# p = 2
d = 0
for i in 0..(n-1)
  d += (x[i].to_f - y[i].to_f).abs ** 2
end

printf "%f\n", Math.sqrt(d)

# p = 3
d = 0
for i in 0..(n-1)
  d += (x[i].to_f - y[i].to_f).abs ** 3
end
printf "%f\n", d**(1/3.0)

# p = ???
d = []
for i in 0..(n-1)
  d.push (x[i].to_f - y[i].to_f).abs
end
printf "%f\n", d.max

Measured memory_bytes: 8860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N, C;
    cin >> N >> C;
    vector<ll> s(N), t(N), c(N);
    ll MAX = pow(10, 5) + 100;
    vector<ll> time(MAX, 0);
    map<pll, bool> ma;
    rep(i, N) {
        cin >> s[i] >> t[i] >> c[i];
        if (ma[{s[i], c[i]}]) {
            time[s[i] + 1]++;
        } else {
            time[s[i]]++;
        }
        if (ma[{t[i], c[i]}]) {
            time[t[i]]--;
        } else {
            time[t[i] + 1]--;
        }
        ma[{s[i], c[i]}] = true;
        ma[{t[i], c[i]}] = true;
    }

    rep(i, MAX - 1) { time[i + 1] += time[i]; }

    ll ans = *max_element(all(time));

    cout << ans << endl;
}

Measured memory_bytes: 18788
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let (n, a, b) = get!(i32, i32, i32);
    println!("{}", cmp::min(a * n, b));
}

Measured memory_bytes: 2084
x = int(input())             # ５００円の枚数
y = int(input())             # 1００円の枚数
z = int(input())             # 50円の枚数
payment = int(input())

count = 0
for k in range(x + 1):
    for j in range(y + 1):
        for i in range(z + 1):
            ans = i * 50 + j * 100 + k * 500
            if ans == payment:
                count += 1

print(count)                

Measured memory_bytes: 3060
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,k,c,ans=0,f=0;
    cin>>n>>m>>k;
    vll a,b;
    for(ll i=0;i<n;i++)
    {
        cin>>c;
        a.pb(c);
    }
    for(ll i=0;i<m;i++)
    {
        cin>>c;
        b.pb(c);
    }
    for(ll i=1;i<n;i++)
    {
        a[i]=a[i-1]+a[i];
    }
    for(ll i=1;i<m;i++)
    {
        b[i]=b[i-1]+b[i];
    }
    for(ll i=0;i<m;i++)
    {
        if(b[i]<=k)
        {
            f=1;
            ans=i+1;
        }
        else
        {
            break;
        }
    }
    for(ll i=0;i<n;i++)
    {
        if(a[i]>k)
            break;
        if(upper_bound(all(b),k-a[i])!=b.end())
        {
            ll p=upper_bound(all(b),k-a[i])-b.begin();
            ans=max(ans,i+p+1);
            //cout<<i+p+1<< "\n";
        }
        else
        {
            ans=max(ans,i+m+1);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7892
// Reference: editorial and official answer (youtube)
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); i++)

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1), b(n+1);
  rep(i,0,n) cin >> a[i+1]; //iの倍数番目の箱の偶奇を表す

  for(int i=n; i>=1; i--){//大きい方から見ていく
    int sum=0;
    for(int j=i+i; j<=n; j+=i){//iの倍数に関するループ
      sum ^= b[j];
    }
    b[i]=sum^a[i];//偶奇の辻褄を合わせる。sumが0でa[i]が1ならボールを入れて1にする。
  }
  vector<int> ans;
  for(int i=1; i<=n; i++){
    if(b[i]) ans.push_back(i);
  }
  cout<<ans.size()<<endl;
  rep(i, 0, ans.size()){
    cout << ans[i] << " ";
  }
  
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    char a,b,c;
    a = s.at(0);
    if ( s.at(1) == a ){
        if( s.at(2) == a ){
            cout << "No" << endl;
            return 0;
        }else if( s.at(2) != s.at(3)){
            cout << "No" << endl;
            return 0;
        }else {
            cout << "Yes" << endl;
            return 0;
        }
    }else if( s.at(2) == a ){
        if ( s.at(3) == s.at(1) ){
            cout << "Yes" << endl;
            return 0;
        }else {
            cout << "No" << endl;
            return 0;
        }
    }else {
        b = s.at(1);
    }
    //
    if( s.at(2) == b ){
        if( s.at(3) == b ){
            cout << "No" << endl;
            return 0;
        }else{
         cout << "Yes" << endl;       
         return 0; 
        }
    }else {
        c = s.at(2);
        cout << "No" << endl;
        return 0;
    }
    //
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
int main(void) 
{
	int a, b, C;
	double S, L, h;
	scanf("%d %d %d", &a, &b, &C);
	S = 0.5 * a * b * sin(C * PI / 180);
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * PI / 180));
	h = b * sin(C * PI / 180);
	printf("%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);
	return 0;
}


Measured memory_bytes: 2140
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt()

	as := makeRange(0, a)
	bs := makeRange(0, b)
	cs := makeRange(0, c)

	count := 0
	for _, a := range as {
		for _, b := range bs {
			for _, c := range cs {
				if a*500+b*100+c*50 == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func nextInt() int {
	i, err := strconv.Atoi(nextWord())
	pnc(err)
	return i
}

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1780
#ABC097B
hoge=input()
no=0

if(hoge[0]=="A"):
    hoge=hoge.replace("A","a",1)
else:
    no=1
    
if not(hoge[1].islower() and hoge[-1].islower()):
    no=1

if(hoge.count("C")==1):
    hoge=hoge.replace("C","c",1)
else:
    no=1
    
if(hoge.islower() and no==0):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on
 
main {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  int odd = count_if(all(a), [](auto &x) { return x % 2 == 1; });
  int even = count_if(all(a), [](auto &x) { return x % 2 == 0; });
  int by4 = count_if(all(a), [](auto &x) { return x % 4 == 0; });
  cout << (by4 >= odd || (by4 + 1 == odd && by4 == even) ? "Yes" : "No") << endl;
}

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

int dp[200005];
int p[200005];
int a[200005];
int n;
int ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		p[a[i]]=i;
		dp[i]=1;
	}
	
	for(int i=1;i<=n;i++){
		if(p[a[i]-1]<i)dp[i]=dp[p[a[i]-1]]+1,ans=max(ans,dp[i]);
	}
	
	printf("%d",n-ans);
}
		
		

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
const ll INF = 1000000007;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int gcd(ll a,ll b){return __gcd(a,b);}

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
		int k;cin>>k;
		string s;cin>>s;
		int len=s.length();
		if(len<=k)cout<<s;
		else {
			for(int i=0;i<k;i++)cout<<s[i];
			cout<<"...";
			}
	}
	//cout<< "Done in " <<fixed<<setprecision(15)<<(double)clock()/7.33e8<<"sec"<< endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int n,k,mx,sum,a[105];
int main(){
    cin>>n>>k;
    rep(i,1,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a+1,a+1+n);
    for(int i=n;i>n-k;i--){
        if(4*a[i]*k<sum){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;





int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int p,q,r;
  cin >> p >> q >> r;
  cout << min(p+q,min(q+r,r+p));

}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
ans = 0
s = A[0]
x = A[0]
r = 1
for l in range(N-1):
    while r < N and s+A[r] == x^A[r]:
        s += A[r]
        x ^= A[r]
        ans += r-l
        r += 1
    if l == r:
        r += 1
    else:
        s -= A[l]
        x ^= A[l]
print(ans+N)

Measured memory_bytes: 23560
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

int main(void)
{
	int A, B, Q;
	std::cin >> A >> B >> Q;

  std::set<long long> shrines;
  std::set<long long> temples;
  for(int i = 0; i < A; i++)
  {
    long long a;
    std::cin >> a;
    shrines.insert(a);
  }
  shrines.insert(-50000000000);
  shrines.insert(50000000000);
  for (int i = 0; i < B; i++)
  {
    long long a;
    std::cin >> a;
    temples.insert(a);
  }
  temples.insert(-50000000000);
  temples.insert(50000000000);

  std::vector<long long> questions;
  for(int i = 0; i < Q; i++)
  {
    long long a;
    std::cin >> a;
    questions.push_back(a);
  }

  for(const auto& q: questions)
  {
    auto itSE = shrines.lower_bound(q);
    auto itSW = std::prev(itSE);
    auto itTE = temples.lower_bound(q);
    auto itTW = std::prev(itTE);
    // assert は省略
    long long locSE = *itSE - q;
    long long locSW = *itSW - q;
    long long locTE = *itTE - q;
    long long locTW = *itTW - q;

    long long shortest = 50000000000;
    shortest = std::min(shortest, std::max(locSE, locTE));
    shortest = std::min(shortest, std::max(-locSW, -locTW));
    shortest = std::min(shortest, locSE - locTW - locTW);
    shortest = std::min(shortest, locSE + locSE - locTW);
    shortest = std::min(shortest, -locSW - locSW + locTE);
    shortest = std::min(shortest, -locSW + locTE + locTE);
    std::cout << shortest << "\n";
  }
}


Measured memory_bytes: 11640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int a,b,h;
	cin >> a >> b >> h;
	cout << (a+b)*(h/2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int num[18][18] = {};
int isStop[18][18] = {};

int main(){
  int k,s; cin >> k >> s;
  int ans = 0;
  for(int i = 0; i<=k; i++){
    for(int j = 0; j<=k; j++){
      int z = s - i - j;
      if(z  <= k && z >= 0) ans++;
    } 
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		
		if(a+b < c+d) System.out.println("Right");
		else if(a+b > c+d) System.out.println("Left");
		else System.out.println("Balanced");
	}

}


Measured memory_bytes: 22608
import fractions
a, b, c, d = map(int, input().split())
cr = b // c - (a - 1) // c
dr = b // d - (a - 1) // d

cdr = b // ((c * d) // fractions.gcd(c, d)) - (a - 1) // ((c * d) // fractions.gcd(c, d))
print(b - a + 1 - cr - dr + cdr)

Measured memory_bytes: 5984
#include <stdio.h>
int main(void) {
    long int a, b, max, max2;
    scanf("%ld %ld", &a, &b);
    
    max = a+b>=a-b ? a+b : a-b;
    max2 = max>a*b ? max : a*b;
    
    printf("%ld", max2);
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int sum = 0;
    int[] x = new int[n];
    for(int i = 0; i<n; i++) {
      x[i] = sc.nextInt();
    }
    for(int i = 0; i<n; i++) {
      if(x[i] < k -x[i]) {
        sum += 2 * x[i];
      }else {
        sum += 2 * (k - x[i]);
      }
    }
    System.out.println(sum);
  }
}


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

int main(){
	int N,W;
	int v[101],w[101];
	cin>>N>>W;
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	int DP[N+1][W+1];
	for(int j=0;j<=W;j++)
		DP[0][j]=0;

	for(int i=1;i<=N;i++)
		for(int j=0;j<=W;j++)
			if(j<w[i-1])
				DP[i][j]=DP[i-1][j];
			else{
				if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1])
					DP[i][j]=DP[i-1][j];
				else
					DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
			}
		cout<<DP[N][W]<<endl;

		return 0;
}

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
const int MAX = 510000;
const ll MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//a^n%mod
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  COMinit();
  ll n,a,b,k;
  cin >> n >> a >> b >> k;
  ll ans=0;
  rep(i,n+1){
    ll y=i;
    if(y*a>k)continue;
    if((k-(y*a))%b!=0)continue;
    ans=(ans+COM(n,y)*COM(n,(k-y*a)/b))%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12160
import Data.Char

solve :: String -> Int -> Int -> String
solve (s:sx) pos counter
  | pos == counter = (toLower s):sx
  | otherwise = s : solve sx pos (counter + 1)

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  s <- getLine :: IO String
  putStrLn $ solve s k 1

Measured memory_bytes: 508
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

// Mod int
// const int MOD = 1000000007;
struct mint{
    ll x;
    mint():x(0){}
    mint(ll x):x((x%MOD+MOD)%MOD){}
    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;}
    bool operator==(const mint& a)const{ return x == a.x;}
    friend ostream& operator<<(ostream& os, const mint& mi)  
    {  
        os << mi.x;  
        return os;  
    }
};

void mainmain(){
	ll n,m;
	cin>>n>>m;
	mint a;
	ll x;
	cin>>x;
	mint aa;
	rep(i,n-1){
		ll t;
		cin>>t;
		aa += mint(t-x)*mint(i+1);
		a += aa;
		x = t;
	}
	// cout<<a<<endl;
	mint ans;
	cin>>x;
	mint b;
	rep(i,m-1){
		ll t;
		cin>>t;
		b += mint(i+1)*mint(t-x);
		ans += a*b;
		// cout<<ans<<endl;
		x = t;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector< pair<int,int> > data(N);
	for (int i = 0; i < N; ++i) {
		cin >> data[i].second >> data[i].first;
	}
	sort(data.begin(),data.end());
	int now = 0;
	bool dead = false;
	for (int i = 0; i < N && !dead; ++i) {
		now += data[i].second;
		if (now > data[i].first) {
			dead = true;
		}
	}
	if (dead) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}



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

int main() {
  	string s;
	cin >> s;
	bool check1 = false;
	bool check2 = false;
	bool check3 = false;
	int n = s.size();
	int count_C = 0;
    int count_large = 0;
  
	if (s.at(0) == 'A') {
		check1 = true;
	}
  
  
	for (int i = 2; i < n - 1; i++) {
		if (s.at(i) == 'C') {
			count_C++;
		}
	}
	if (count_C == 1) {
		check2 = true;
	}
  
  
	for (int i = 0; i < n; i++) {
		if (s.at(i) >= 'A' &&  s.at(i) <= 'Z'){
        count_large ++;
        }
	}
    if(count_large == 2){
        check3 = true;
    }
  
	if (check1 && check2 && check3) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

}








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

int main(){
  int nn;
  cin>>nn;
  for(int n=1;n<=nn;n++){
    int ans=0;
    int mx = sqrt(n/6);
    for(int x=1;x<=mx;x++){
      int my= sqrt(n/3 - x*x) ;
      for(int y=x;y<=my;y++){
        int mz= sqrt(n-5*x*x);
        for(int z=y;z<=mz;z++){
          if (x*x+y*y+z*z+x*y+y*z+z*x==n){
            if (x==y && y==z){
              ans=ans+1;
            }else if(x==y || y==z){
              ans=ans+3;
            }else{
              ans=ans+6;
            }     
          }
        }
      }
    }
    cout<<  ans<< endl;
  }
  
  
  
}



Measured memory_bytes: 3500
#include "bits/stdc++.h"
using namespace std;

const int INF = 1e9+5;

void print(std::vector<auto> V){
	for(auto v:V)
		cout<<v<<" ";
	cout<<endl;
}

int min_cost(std::vector<int> h, int k){
	// cout<<"hey"<<endl;
	int n = h.size();
	std::vector<int> v(n, INF);
	v[0] = 0;
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<=i+k; ++j){
			if(j<n){
				v[j] = min(v[j], v[i]+abs(h[j]-h[i]));
			}
		}
		// cout<<"iter: "<<i<<" ";
		// print(v);

	}
	return v[n-1];
}

int main(){
	int n, k;
	cin>>n;
	cin>>k;
	vector<int>h(n);
	for(int& x: h){
		cin>> x;
	}
	// print(h);

	int ans = min_cost(h, k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// const ll MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;

void solve()
{
   string s;
   cin>>s;
   int sum=0;
   fr(i,s.length())
   {
       sum+=s[i]-'0';
   }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#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 ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

    string s; cin >> s;
    ll k; cin >> k;

    int ans = 1;
  	int length = (int)min((ll)s.length(), k);
    REP(i, length){
	if(s[i] != '1'){
	  ans = s[i] - '0';
	  break;
	}
    }

    SCOUT(ans) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

input()
d = deque()
for l in sys.stdin:
	s = l.split()
	if s[0] == 'insert':
		d.appendleft(s[1])
	elif s[0] == 'deleteFirst':
		d.popleft()
	elif s[0] == 'deleteLast':
		d.pop()
	elif s[0] == 'delete':
		try: d.remove(s[1])
		except: pass
print(*d)


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




int main(){
    long double a,b,c;
    cin>>a>>b>>c;
    if(c*c+a*a+b*b>a*b+a*b+a*c+a*c+b*c+b*c&&c-a-b>0){
        cout<<"Yes"<<endl;    
    }
    else{
        cout<<"No"<<endl;
    } 
            
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	    ll n,i,j,k,l=0;
	    cin>>n;
	    REP(i,1,n){
	    	REP(j,1,n){
	    		REP(k,1,n){
	    			l+=gcd(i,gcd(j,k));
	    		}
	    	}
	    }
	    cout<<l;
	
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll  long long int
#define N 100000
#define M 1000000007
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Sawlani
  *
  */
vector <ll> cal(40,0);
ll pre()
{
    cal[0]=1;
     f(i,1,39)
    {
       cal[i]=pow(2,i);
         
    }
}
ll near(ll num)
{
   ll k=lb(cal.begin(),cal.end(),num)-cal.begin();
   return k;
}
int main()
{
    pre();
    ll n,k;
    cin >>  n >> k;
    double ans=0.0;
    f(i,1,n)
    {
        ll j;
        if(k%i==0)
        j=near(k/i);
        else
        j=near(k/i+1);
     //  cout << j << endl;
      ans=ans+((1.0/(double)n)*(1.0/(double)pow(2,j)));
    }
    cout << fixed << setprecision(13) ;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<60;
template<class T> void chmin(T &a,T b){a=min(a,b);}
template<class T> void chmax(T &a,T b){a=max(a,b);}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;cin>>s;
	string t="";
	int c=0;
	int q;cin>>q;
	while(q--){
		int ti;cin>>ti;
		if(ti==1){
			c++;
		}else{
			int f;char cc;cin>>f>>cc;
			if(f==1){
				if(c%2==0){
					t.push_back(cc);
				}else{
					s.push_back(cc);
				}
			}else{
				if(c%2==0){
					s.push_back(cc);
				}else{
					t.push_back(cc);
				}
			}
		}
	}
	if(c%2==0){
		reverse(all(t));
		cout<<t<<s<<endl;
	}else{
		reverse(all(s));
		cout<<s<<t<<endl;
	}
}


Measured memory_bytes: 980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main(void) {
  int N;
  int T1, T2, P1, P2;
  int cnt[100]={0};
  int R = 0;
  int j = 0;
  while(cin >> N) {
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0 ; i < N*(N-1)/2 ; i++) {
      cin >> T1 >> T2 >> P1 >> P2;
      if(P1 > P2) cnt[T1] += 3; 
      else if(P1 < P2) cnt[T2] += 3;
      else if(P1 == P2) { cnt[T1]++; cnt[T2]++; }	
    }
    /*for(int i = 1 ; i <= N ; i++) {
      cout << cnt[i] << ' ';
    }
    cout << endl;*/
    for(int i = 1 ; i <= N ; i++) {
      for(int j = 1 ; j <= N ; j++) {
	  if(cnt[i] < cnt[j]) R++;
      }
      cout << R+1 << endl;
      R = 0;
    }
    //cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
const int N = 1e5 + 5;
map<int, int> nm, need;
int main()
{
    int n; cin >> n;
    FOR(i, n + 1, 1)
    {
        if(n >=100 * i && n <= 105 * i)
        {
            cout << 1;
            return 0;
        }
    }
    cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    char b,res;
    cin >> b;
    if(b == 'A'){
        res = 'T';
    }
    if(b == 'T'){
        res = 'A';
    }
    if(b == 'C'){
        res = 'G';
    }
    if(b == 'G'){
        res = 'C';
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	int C = (A + K - 1) / K * K;
	puts([&] {
		return C <= B;
		
	}() ? "OK": "NG");
	return 0;
}


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



int main(){
  int N,L; cin>>N>>L;
  vector<P>taste(N);
  for(int i=0;i<N;i++){
    taste.at(i).second=L+i;
    taste.at(i).first=abs(L+i);
  }
  sort(taste.begin(),taste.end());
  
  int res=0;
  
  for(int i=1;i<N;i++)
    res+=taste.at(i).second;
  cout<<res;
}
  

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

bool is_odd(int x){
    if((x-1)%2 == 0){
        return true;
    }else{
        return false;
    }

}

using namespace std;
int main(){
    int N;
    while(cin >> N){
        int counter = 0;
        double solve = 0;
        for(int i = 1; i <=N; i++){
            if(is_odd(i)){
                counter++;
            }
        }
        solve = (double)counter / N;
        cout << solve << endl;
    }


}

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

int main(){
    int a, b;
    cin >> a >> b;
    
    string s_a;
    for(int i=0; i<b; i++){
        s_a += to_string(a);
    }
    string s_b;
    for(int i=0; i<a; i++){
        s_b += to_string(b);
    }


    if(s_a>=s_b){
        cout << s_b << endl;
    }
    else{
        cout << s_a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

signed main(){
  int n;
  cin>>n;
  vector<int> X(n);
  cin>>X;
  int L;
  cin>>L;
  
  vector<vector<int> > can(n,vector<int>(20,0));

  for(int i=0;i<n;i++){
    can[i][0] = upper_bound(X.begin(),X.end(),X[i]+L) - X.begin() - 1;
  }
  
  for(int j=0;j<19;j++)
    for(int i=0;i<n;i++){
      int l = can[i][j];
      can[i][j+1] = can[l][j];
    }
  
  int Q;
  cin>>Q;

  function<int(int,int)> calc=[&](int a,int b){
    int idx = lower_bound(can[a].begin(),can[a].end(),b) - can[a].begin()-1;
    int day = 1<<idx;
    if(idx == -1) return 1LL;
    if(idx == 0) return day + 1;
    return day + calc(can[a][idx],b);
  };

  while(Q--){
    int a,b;
    cin>>a>>b; a--,b--;
    if(a > b) swap(a,b);
    int ans = calc(a,b);
    cout<<ans<<endl;
  }
  
  return 0;
}


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


int A, L;

string to_str(int n) {
  ostringstream os;
  os << n;
  return os.str();
}

int calc(int a) {
  string s = to_str(a);
  
  sort(s.begin(), s.end(), greater<char>());
  
  while(s.size() < L) s += '0';
  
  int ret = atoi(s.c_str());
  reverse(s.begin(), s.end());
  
  ret -= atoi(s.c_str());
  
  return ret;
}

int main()
{
  int flag[1000005];
  
  while(cin >> A >> L, A || L) {
    
    int j = 1;
    fill_n(flag, 1000005, -1);
    flag[A] = 0; A = calc(A);
    
    while(!~flag[A]) {
      flag[A] = j; A = calc(A); 
      j++;
    }
    
    cout << flag[A] << " " << A << " " << j - flag[A] << endl;

  }

  return 0;
}

Measured memory_bytes: 7108
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    string S; int K; cin >> S >> K;
    map<string,int>m;
    rep(i,S.size()){
        for(int j=1;j<=min((int)S.size()-i,(int)5);j++){
            m[S.substr(i,j)]++;
        }
    }
    vector<string> SS;
    for(auto p:m){
        SS.push_back(p.first);
        if(SS.size()>=5)break;
    }
    cout << SS[K-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] arr = in.next().toCharArray();
        char[] brr = in.next().toCharArray();

        TreeSet<Integer>[] idx = new TreeSet[26];
        for (int i = 0; i < 26; ++i)
            idx[i] = new TreeSet<>();

        for (int i = 0; i < arr.length; ++i) {
            idx[arr[i] - 'a'].add(i + 1);
        }

        int cur = -1;

        long ans = 0;
        for (int i = 0; i < brr.length; ++i) {
            if (idx[brr[i] -'a'].size() == 0) {
                System.out.println(-1);
                return ;
            }
            
            Integer ceilingInteger = idx[brr[i] - 'a'].higher(cur);
            if (ceilingInteger == null) ceilingInteger = idx[brr[i] - 'a'].first();
            if (cur >= ceilingInteger) {
                ceilingInteger = idx[brr[i] - 'a'].first();
                ans += arr.length;
            }

            cur = ceilingInteger;
        }

        ans += cur;
        System.out.println(ans);
    }
}


class Kattio extends PrintWriter {
    public Kattio(InputStream i) {
	super(new BufferedOutputStream(System.out));
	r = new BufferedReader(new InputStreamReader(i));
    }
    public Kattio(InputStream i, OutputStream o) {
	super(new BufferedOutputStream(o));
	r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasMoreTokens() {
	return peekToken() != null;
    }

    public int getInt() {
	return Integer.parseInt(nextToken());
    }

    public double getDouble() { 
	return Double.parseDouble(nextToken());
    }

    public long getLong() {
	return Long.parseLong(nextToken());
    }

    public String getWord() {
	return nextToken();
    }



    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
	if (token == null) 
	    try {
		while (st == null || !st.hasMoreTokens()) {
		    line = r.readLine();
		    if (line == null) return null;
		    st = new StringTokenizer(line);
		}
		token = st.nextToken();
	    } catch (IOException e) { }
	return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }

    public int nextInt() {
        return Integer.parseInt(getWord());
    }

}

Measured memory_bytes: 34648
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C, D, E, F, G, H, I;
    cin >> A >> B >> C >> D >> E >> F >> G >> H >> I;
    if (A - D == B - E &&
    B - E == C - F &&
    D - G == E - H &&
    E - H == F - I &&
    A - B == D - E &&
    D - E == G - H &&
    B - C == E - F &&
    E - F == H - I) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val N = StdIn.readLine()
    val ans = "CODEFESTIVAL2016"
    var counter = 0
    for ((ch, i) <- N.toCharArray.zipWithIndex) {
      if (ch != ans.charAt(i)) {
        counter += 1
      }
    }
    println(counter)
  }

}


Measured memory_bytes: 21712