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

using namespace std;

int solve(const vector<int>& L, int i, int j)
{
    const auto ab = L[i] + L[j];
    const auto len = L.size();
    int left = 0, right = len - 1;
    int count = 0;
    for (;;) {
        const auto index = (left + right + 1) / 2;
        // printf("count=%d, left=%d, right=%d, index = %d\n", count, left, right, index);
        if (L[index] < ab) {
            left = index;
        }
        else {
            right = index;
        }
        if (index == (left + right + 1) / 2) {
            break;
        }
    }

    // printf("left=%d, right=%d\n", left, right);

    return left - j;
}

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

    vector<int> L;
    L.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }

    sort(L.begin(), L.end());
    // for (int i = 0; i < N; ++i) {
    //     cout << L[i] << endl;
    // }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            const auto a = L[i];
            const auto b = L[j];
            const auto ab = a + b;
            ans += solve(L, i, j);
            // printf("a=%d, b=%d, ab=%d, ans=%d\n", a, b, ab, ans);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef struct {
  int x;
  int y;
} PT;
int main()
{
  PT pt[4];
  cin >> pt[0].x >> pt[0].y >> pt[1].x >> pt[1].y;
  int x_diff = pt[1].x - pt[0].x;
  int y_diff = pt[1].y - pt[0].y;

  pt[2].x = pt[1].x - y_diff;
  pt[2].y = pt[1].y + x_diff;

  pt[3].x = pt[2].x - x_diff;
  pt[3].y = pt[2].y - y_diff;

  cout << pt[2].x << " " << pt[2].y << " " << pt[3].x << " " << pt[3].y << endl;
  return 0;
}


Measured memory_bytes: 3604
x = int(input())
for i in range(-1000, 1000):
    i5 = i ** 5
    j5 = i5 - x
    if j5 < 0:
        j = (-j5) ** (1/5)
        j *= -1
    else:
        j = j5 ** (1/5)
    j = int(j)
    for cand in range(j - 10, j + 10):
        if i5 - cand ** 5 == x:
            print(i, cand)
            exit(0)
    

Measured memory_bytes: 66948
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[210];
    int even=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]%2==0) even++;
    }
    int ans=0;
    while(even==n)
    {
        ans++;
        for(int i=1; i<=n; i++)
        {
            a[i]/=2;
            if(a[i]%2) even--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int x, y, z;
  cin >> x >> y >> z;
  
  x -= z;
  int ans = x/(y+z);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

a,b,c,d,e = multi_int_input()

if a == 0:
    print(1)
elif b == 0:
    print(2)
elif c == 0:
    print(3)
elif d == 0:
    print(4)
elif e == 0:
    print(5)

Measured memory_bytes: 9552
K, N = map(int, input().split())
distances = list(map(int,input().split()))

var = distances[0]
for i in range(N):
    distances[i] -= var
distances.append(K-distances[-1])

for i in range(N-1, 0,-1):
    distances[i] -= distances[i-1]

print(sum(sorted(distances)[:-1]))


Measured memory_bytes: 25840
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i,n,*A,*B,C[10001];
  scanf("%d",&n);
  A=(int*)malloc(sizeof(int)*n);
  B=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  // CountingSort(A, B, k)
  for (i=0;i<=10000;i++)
    C[i]=0;

  /* C[i] ??? i ???????????°????¨?????????? */
  for (i=0;i<n;i++)
    C[A[i]]++;

  /* C[i] ??? i ??\????????°???????????°????¨??????????*/
  for(i=0;i<=10000;i++)
    C[i]=C[i]+C[i-1];
  
  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
  for(i=0;i<n;i++){
    printf("%d",B[i]);
	   if(i<n-1)
	     printf(" ");
	   }
      printf("\n");
    return 0;
  }

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

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

constexpr int INF=1e9;

int main()
{
	for(int n;cin>>n && n;){
		vector<map<string,int>> ss(n);
		rep(i,n){
			int k; cin>>k;
			rep(j,k){
				string name; int value; cin>>name>>value;
				ss[i][name]=value;
			}
		}
		int q; cin>>q;
		vs ns(q);
		rep(i,q) cin>>ns[i];
		int m; cin>>m;
		vvi d(n+1,vi(n+1,INF));
		rep(i,n+1) d[i][i]=0;
		rep(i,m){
			int u,v,w; cin>>u>>v>>w;
			(u+=n)%=n+1; (v+=n)%=n+1;
			d[u][v]=d[v][u]=w;
		}
		
		rep(k,n+1) rep(i,n+1) rep(j,n+1)
			d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		
		vvi dp(1<<n+1,vi(n+1,INF));
		rep(i,n) dp[1<<i][i]=d[n][i];
		rep(i,1<<n+1) rep(j,n+1) if(i>>j&1) rep(k,n+1) if(!(i>>k&1))
			dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+d[j][k]);
		
		tuple<int,int> res(INF,INF);
		rep(i,1<<n){
			vi ps(q,INF);
			rep(j,n) if(i>>j&1)
				rep(k,q) if(ss[j].count(ns[k]))
					ps[k]=min(ps[k],ss[j][ns[k]]);
			if(count(all(ps),INF)) continue;
			res=min(res,make_tuple(accumulate(all(ps),0),dp[i|1<<n][n]));
		}
		
		if(res==make_tuple(INF,INF))
			cout<<"impossible"<<endl;
		else
			cout<<get<0>(res)<<' '<<get<1>(res)<<endl;
	}
}

Measured memory_bytes: 1428
k = gets.to_i

q = [1, 2, 3, 4, 5, 6, 7, 8, 9]
(k-1).times do
  x = q.shift
  m = x % 10
  if m != 0
    q.push 10 * x + m - 1
  end
  q.push 10 * x + m
  if m != 9
    q.push 10 * x + m + 1
  end
end

p q.shift

Measured memory_bytes: 16632
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    sc.nextLine()
    val houses = sc.nextLine.split(" ").map(_.toInt).sorted
    println((houses.slice(1, houses.length) zip houses.slice(0, houses.length - 1)).map(item => item._1 - item._2).sum)
  }
}


Measured memory_bytes: 27208
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A,B;
    cin>>A>>B;
    cout<<max(max(A+B,A-B),A*B)<<endl ;
    return 0;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

//Greatest Common Divisor
long long GCD(long long a, long long b) {
    return ((b == 0) ? a : GCD(b, a % b));
}

int main() {
	int N; cin >> N;
	V<ll> A(N); REP(i,N) cin >> A[i];
	ll ans = A[0];
	for(int i = 0; i < N; ++i) ans = GCD(ans,A[i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println(a<=c && c<=b ? "Yes" : "No");
  }
}


Measured memory_bytes: 35664
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,x,y = readInts()

d = defaultdict(int)

for i in range(1,n+1):
	for j in range(1,n+1):
		d[min(abs(i-j),abs(i-x)+1+abs(y-j),abs(i-y)+1+abs(j-x))]+=1

for i in range(1,n):
	print(d[i]//2)

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n)cin>>a[i];
    vl sub;
    rep(i,n){
        ll sum = 0;
        for(int j=i;j<n;j++){
            sum += a[j];
            sub.push_back(sum);
        }
    }
    //debug(sub);

    ll ma = 0;
    int m = sub.size();
    rep(i,m)chmax(ma,sub[i]);

    ll res = 0;
    for(ll bit = 63;bit >= 0;bit--){
        ll cnt = 0;
        ll num = 1LL << bit;
        vl n_sub;
        rep(i,m)if(sub[i] & num){
            cnt++;
            n_sub.push_back(sub[i]);
        }
        if(cnt >= k){
            res += num;
            sub = n_sub;
            m = sub.size();
        }
    }
    out(res);
}


Measured memory_bytes: 8920
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func init() {
	// read one word/char/int separated by space(s).
	//sc.Split(bufio.ScanWords)

	// read one line.
	sc.Buffer(make([]byte, 202400), 404800)
	sc.Split(bufio.ScanLines)
}

func main() {
	S := nextStr()
	o := str{chrs: []byte(S), memo: make([][4]int64, len(S)+20)}
	if len(S) == 1 {
		fmt.Println(1)
		return
	}
	one := o.solve(0, 0)
	two := o.solve(0, 1)
	if one > two {
		fmt.Println(one)
		return
	}
	fmt.Println(two)
}

type str struct {
	chrs []byte
	memo [][4]int64
}

// prev
// 1: 前の文字列と、その前の文字列が異なる
// 2: 前の文字列と、その前の文字列が一致
// 3: 前の文字列が2文字

func (s *str) solve(prev, idx int) int64 {
	if idx == len(s.chrs)-1 {
		if prev == 2 || prev == 3 {
			return 1
		}
		if s.chrs[idx] == s.chrs[idx-1] {
			return 0
		}
		return 1
	}
	if s.memo[idx][prev] != 0 {
		return s.memo[idx][prev]
	}
	var ans int64
	switch prev {
	case 1:
		if s.chrs[idx] == s.chrs[idx-1] {
			ans = s.solve(2, idx+1)
		} else {
			ans = s.solve(1, idx+1) + 1
		}
	case 2:
		ans = s.solve(3, idx+1) + 1
	case 3:
		ans = s.solve(1, idx+1) + 1
	default:
		ans = s.solve(1, idx+1) + 1
	}
	s.memo[idx][prev] = ans
	return ans
}


Measured memory_bytes: 59904
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> A >> B;
  if(B==100)B++;
  HpOut(B*pow(100,A));
}

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

using namespace std;

typedef pair<int, int> Pii;

string s;
int n;
vector<Pii> edges;

void make_tree(){
    s[n-1] = '1';
    vector<int> one_indexes;
    for(int i=0;i<n;i++) if(s[i] == '1') one_indexes.push_back(i);
    for(int i=0;i<n-1;i++){
        // この内側ループを二分探索にする
        int j = *upper_bound(one_indexes.begin(), one_indexes.end(), i);
        if(i < j && j <= n) edges.emplace_back(i+1, j+1);
    }
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    n = s.length();

    bool flag = (s[0] == '1') && (s[n-1] == '0');
    for(int i=1;i<n/2&&flag;i++){
        if(s[i] != s[n-2-i]) flag = false;
    }
    bool all_zero = true;
    for(int i=1;i<n-1&&all_zero;i++){
        if(s[i] == '1') all_zero = false;
    }
    flag &= !all_zero;

    if(flag){
        make_tree();
        for(Pii e: edges) cout << e.first << " " << e.second << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 2500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

struct food{
  string fn;
  int g;
  int s;
};
int f[10],an[10],m;
food fd[10],sf;
int ans(int n,int s){
  if(n==-1){
    for(int i = m - 1 ; i >= 0 ; i --)
      cout << fd[an[i]].fn << endl; 
      return 1;
  }
 for (int i=m-1;i>=0;i--) {
        if (f[i]==0 && fd[i].s>=s-fd[i].g) {
            f[i]=1; an[n]=i;
            if (ans(n-1,s-fd[i].g)==1) return 1; 
            f[i]=0;
        }
  }
  return 0;
}

int main(void){
  int i,j,s;
  while(cin >> m){
    if (m==0)break;
    for(i = 0 , s = 0 ; i < m ; i ++){
      f[i] = 0 ; 
      cin >> fd[i].fn >> fd[i].g >> fd[i].s;
      s+=fd[i].g;
    }
    for(i = 1 ; i < m ; i ++){
      for(j = 0  ; j < m - i ; j ++){
	if(fd[j].g>fd[j+1].g){
	  sf=fd[j];
	  fd[j] = fd[j+1];
	  fd[j+1] = sf;
	}
      }
    }
    ans(m-1,s);
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
//////////////////////////////////////////////////////////////////////



int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  string s;cin>>s;
  cout<<s[0]<<s.length()-2<<s[s.length()-1]<<nl;
  
  return 0;
}


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

int main(void){
    long long N, H;
    cin >> N >> H;
    vector<vector<long long>> ab(2, vector<long long>(N));
    
    for(int i = 0; i < N; i++){
        long long a, b;
        cin >> a >> b;
        ab[0][i] = a; ab[1][i] = b;
    }
    
    sort(ab[0].begin(), ab[0].end());
    sort(ab[1].begin(), ab[1].end());
    
    long long count = 0;
    for(int i = 0; i < N; i++){
        if(ab[0][N-1] < ab[1][N-i-1])
            H -= ab[1][N-i-1];
        else
            break;
        count++;
        if(H <= 0)
            break;
    }
    
    if(H <= 0)
        cout << count;
    else
        cout << count + (H + (ab[0][N-1] - 1)) / ab[0][N-1];
    
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    double a , b , h , m ;
    cin >> a >> b >> h >> m;
    double d ;
    d = abs(30 * h + 0.5 * m - 6 * m) ;
    if(d > 180.0){
        d = 360.0 - d ;
    }

    double ans ;
    if(d == 180.0){
        cout << a + b << endl;
    }else if(d == 0){
        cout << abs(a - b) << endl;
    }else{
    //cout << d << endl;
    //cout << 2*a*b*cos(d) << endl;
    //cout << pow(a*a + b*b ,0.5) << endl;
    double j ;
    j =  a*a + b*b - 2*a*b*cos(M_PI*d/180.0) ;
    ans = pow(j, 0.5);
    cout << fixed << setprecision(21)<<ans<< endl;
    //4.56425719433005567605
    }
    return 0 ;
}

 


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string s;
    cin >> s;

    bool c = false; bool f = false;

    Rep (i, s.size()) {
        if (s[i] == 'C') c = true;
        if (c) {
            if (s[i] == 'F') {
                f = true;
                break;
            }
        }
    }

    if (c && f) cout << "Yes\n";
    else cout << "No\n";
}

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

#define maxN 100005
#define oo 1000000007
#define fto(i, a, b) for (int i = a; i <= b; ++i)
#define fdto(i, a, b) for (int i = a; i >= b; --i)
#define sci(x) scanf("%d", &x)
#define scii(x, y) scanf("%d %d", &x, &y)
#define pri(a) printf("%d ", a)
#define pril(a) printf("%d\n", a)
#define pril2(a, b) printf("%d %d\n", a, b)
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define iii pair<int, ii>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define bug(a) cout << #a << "=" << a << ";" << endl
#define bug2(a, b) cout << #a << "=" << a << ";  " << #b << "=" << b << ";" << endl
#define sz(a) (int)a.size()

using namespace std;

struct point {
    int x, y;
};

pair<int, int> x[maxN], y[maxN];
int par[maxN], ans, n;
point p[maxN];
vector<pair<int, pair<int, int> > > canh;

void initSet(int n) {
    fto(i, 1, n) par[i] = i;
}

int findSet(int u) {
    return (par[u] == u) ? u : par[u] = findSet(par[u]);
}

void unionSet(int u, int v) {
    par[findSet(u)] = findSet(v);
}

int main() {
    sci(n);
    fto(i, 1, n) {
        scii(p[i].x, p[i].y);
        x[i].ff = p[i].x; x[i].ss = i;
        y[i].ff = p[i].y; y[i].ss = i;
    }

    sort(x+1, x+n+1);
    sort(y+1, y+n+1);

    fto(i, 1, n-1) {
        int u = x[i].ss, v = x[i+1].ss;
        int w = min(abs(p[u].x-p[v].x), abs(p[u].y-p[v].y));
        canh.pb(mp(w, mp(u, v)));

        u = y[i].ss, v = y[i+1].ss;
        w = min(abs(p[u].x-p[v].x), abs(p[u].y-p[v].y));
        canh.pb(mp(w, mp(u, v)));
    }

    sort(canh.begin(), canh.end());
    initSet(n);
    fto(i, 0, (int)canh.size()-1) {
        int w = canh[i].ff, u = canh[i].ss.ff, v = canh[i].ss.ss;
        if (findSet(u) != findSet(v)) {
            unionSet(u, v);
            ans += w;
        }
    }
    pril(ans);

    return 0;
}


Measured memory_bytes: 7284
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

template<typename T = int>
struct min_of {
    constexpr T operator ()(T& lhs, T& rhs) const { return min<T>(lhs, rhs); }
};
template<typename T = int>
struct max_of {
    constexpr T operator ()(T& lhs, T& rhs) const { return max<T>(lhs, rhs); }
};
template<typename T, class F, const T& I>
struct SegmentTree {
    const F op = F();
    int n; vector<T> dat;
    void init(int n_) { n = 1; while (n < n_) n *= 2; dat.assign(n * 2, I); }
    void build(const vector<T>& v) {
        int n_ = v.size(); init(n_);
        for (int i = 0; i < n_; ++i) dat[n + i] = v[i];
        for (int i = n - 1; i; --i) dat[i] = op(dat[i << 1], dat[(i << 1) + 1]);
    }
    void update(int k, T v) { dat[k += n] = v; while (k >>= 1) dat[k] = op(dat[k << 1], dat[(k << 1) + 1]); }
    T query(int a, int b) {
        T vl = I, vr = I;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1) vl = op(vl, dat[l++]); if (r & 1) vr = op(dat[--r], vr); }
        return op(vl, vr);
    }
    template<class C> int find(int a, int b, C& check) { return find(a, b, check, 1, 0, n); }
private:
    template<class C> int find(int a, int b, C& check, int k, int l, int r) {
        if (!check(dat[k]) || r <= a || b <= l) return -1; if (k >= n) return k - n;
        int m = (l + r) >> 1; int vl = find(a, b, check, (k << 1) | 0, l, m);
        if (~vl) return vl; return find(a, b, check, (k << 1) | 1, m, r);
    }
};
extern constexpr int identity_min = 1e9;
extern constexpr int identity_max = -1;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    SegmentTree<int, min_of<int>, identity_min> stmin;
    SegmentTree<int, max_of<int>, identity_max> stmax;
    stmin.build(P);
    stmax.build(P);

    int cnt = 0;
    for (int i = 0; i < N - K; ++i) {
        int m = stmin.query(i + 1, i + K);
        int M = stmax.query(i + 1, i + K);

        if (M < P[K + i] && m > P[i]) {

        }
        else {
            cnt++;
        }
    }

    vector<int> is(N, 1);
    rep(i, 1, N) {
        if (P[i] > P[i - 1]) is[i] = is[i - 1] + 1;
    }
    int t = -1;
    rep(i, N) {
        if (is[i] >= K) {
            if (t != -1 && i - t >= K) {
                cnt--;
            }
            t = i;
        }
    }

    write(1 + cnt);
}

Measured memory_bytes: 5888
cards = gets.to_i
array = gets.split(" ").map{|k|k.to_i}
 
cards_sum1 = 0
cards_sum2 = 0
array.each do |num|
    cards_sum2 += num
end

if array.length == 2
    ans = (array[0] - array[1]).abs
else
    ans = Float::INFINITY
    for i in 0..array.length-2 do
        cards_sum1 += array[i]
        a = (cards_sum2 - (cards_sum1 * 2)).abs
        if ans > a
            ans = a
        end
    end
end
 
puts ans

Measured memory_bytes: 15236
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cassert>
#include<climits>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 50*50
#define MAX_V 50*50

using namespace std;

//

struct edge{
  int to,cap,rev;
  edge(int to=IINF,int cap=IINF,int rev=IINF):to(to),cap(cap),rev(rev){}
};
 
vector<edge> G[MAX_V];
bool used[MAX_V];
 
void add_edge(int from,int to,int cap){
  G[from].push_back(edge(to,cap,G[to].size()));
  G[to].push_back(edge(from,0,(int)G[from].size()-1));
}
 
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,IINF);
    if(f == 0)return flow;
    flow += f;
  }
}

//

int counter[4];// H W C M
int csum[4];
int N[3]; // Nw Nc Nm
int limit[3][MAX];
int input_buf[3][MAX][MAX];
int Grave[3][2];
int V;

inline bool first_input(){
  bool fin = true;
  rep(i,4){
    cin >> counter[i];
    if(i == 0)csum[i] = counter[i];
    else      csum[i] = 2*counter[i] + csum[i-1];
    if( counter[i] >= 0 )fin = false;
  }
  rep(i,3){
    cin >> N[i];
    if( counter[i] >= 0 )fin = false;
  }
  return !fin;
}

int main(){
  while(first_input()){
    rep(i,3){
      rep(j,counter[i+1]){
	cin >> limit[i][j];
	rep(k,limit[i][j]){
	  cin >> input_buf[i][j][k];
	  input_buf[i][j][k]--;
	}
      }
    }

    int source = csum[3],sink = source+1;
    Grave[0][0] = sink+1       , Grave[0][1] = Grave[0][0]+1;
    Grave[1][0] = Grave[0][1]+1, Grave[1][1] = Grave[1][0]+1;
    Grave[2][0] = Grave[1][1]+1, Grave[2][1] = Grave[2][0]+1;

    V = Grave[2][1]+1;
    rep(i,V)G[i].clear();

    //1テ、ツコツコテ」ツ?ョテ、ツコツコテ」ツ?ッ1テ・ツ崢榲」ツ?セテ」ツ?ァテ」ツ?療」ツ?凝」ツ?、テ」ツ?凝」ツ?暗」ツ?ェテ」ツ??」ツつ暗」ツ??」ツ?ォテ」ツ?凖」ツつ凝」ツ?ョテ・ツソツ佚」ツつ古」ツ?ヲテ」ツ??( テ・ツ青古」ツ?佚、ツコツコテ」ツつ津、ツスツ陛・ツコツヲテ」ツつづ、ツスツソテァツ板ィテ」ツ?療」ツ?ヲテ」ツ??」ツ?淌」ツ?淌」ツつ仝A )
    rep(i,3)rep(j,counter[i+1])add_edge(csum[i]+j,csum[i]+j+counter[i+1],1);

    rep(i,counter[0])add_edge(source,i,1);
    rep(i,counter[3])add_edge(csum[2]+i+counter[3],sink,1);
    rep(i,3){
      rep(j,counter[i+1]){
	rep(k,limit[i][j]){
	  add_edge(input_buf[i][j][k]+((i-1)>=0?csum[i-1]:0)+((i)?counter[i]:0),csum[i]+j,1);
	}
      }
    }

    rep(k,2){
      int coef = ((k==0)?0:counter[k]);
      rep(i,counter[k])add_edge(((k-1)>=0?csum[k-1]:0)+i+coef,Grave[k][0],1);
      add_edge(Grave[k][0],Grave[k][1],N[k]);
      rep(i,counter[k+2])add_edge(Grave[k][1],csum[k+1]+i,1);
    }

    rep(i,counter[2])add_edge(csum[1]+i+counter[2],Grave[2][0],1);
    add_edge(Grave[2][0],sink,N[2]);

    int tmp;
    cout << (tmp=max_flow(source,sink)) << endl;
    assert(0 <= tmp && tmp <= counter[0] );

  }
  return 0;
}

Measured memory_bytes: 9908
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int year, month, day;
    char c1, c2;
    cin >> year >> c1 >> month >> c2 >> day;
    if (month <= 4) {
        cout << "Heisei" << endl;
    } else
    {
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[105][100005];
long long val[105];
long long weig[105];
int main()
{
  int n,W;
  cin>>n>>W;
  for(int i=0;i<n;i++){
    cin>>weig[i]>>val[i];
  }
  for(int i=0;i<=W;i++){
    dp[0][i]=0;
  }
  for(int i=0;i<n;i++){
    for(int w=0;w<=W;w++){
      if(weig[i]<=w){
	dp[i+1][w]=max(dp[i][w-weig[i]]+val[i],dp[i][w]);
      }else{
	dp[i+1][w]=dp[i][w];
      }
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}


Measured memory_bytes: 80128
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int s[105];
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]),sum+=s[i];
	if(sum%10!=0)
	{
		printf("%d\n",sum);
		return 0;
	}
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++)
		if(s[i]%10!=0)
		{
			sum-=s[i];
			break;
		}
	if(sum%10==0) printf("0\n");
	else printf("%d\n",sum);
}

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

template<typename T>
struct Segtree {
    int n;
    T e; // default value
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input) {
        initialize(n_input, f_input, e_input);
    }

    void initialize(int n_input, Func f_input, T e_input) {
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) { n<<=1; }
        dat.resize(2*n-1, e);
    }
    
    void set(int k, T a) {
        k += n-1;
        dat[k] = a;
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    void update(int k, T a) {
        k += n-1;
        dat[k] = f(dat[k], a);
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k) {
        return dat[k+n-1];
    }
    // [a, b)
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // [a, b)
    T _query(int a, int b, int k, int l, int r) {
        if(r<=a || b<= l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = _query(a, b, 2*k+1, l, (l+r)/2);
        T vr = _query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};
/** Usage:
Segtree<int> seg(n, [](int a, int b) {return max(a,b);}, 0); // init
REP(i, n+1) st.update(i, i)
st.query(a, b)
*/

const int MX=300005;
int main() {
    int n, k;
    cin >> n >> k;
    Segtree<int> seg(MX, [](int a, int b) {return max(a,b);}, 0); // init
    for ( int i=0; i<n; i++ ) {
        int a;
        cin >> a;
        int l=max(0, a-k);
        int r=min(MX,a+k+1);
        int x=seg.query(l,r);
        seg.update(a, x+1);
    }
    cout << seg.query(0, MX) << '\n';
    return 0;
}

Measured memory_bytes: 7492
#include <cstdio>
#include <algorithm>
#include <functional>

int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  int h[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", h + i);
  }
  std::sort(h, h + n);
  const int lim = n - k;
  int ans = 1e9;
  for (int i = 0; i <= lim; ++i)
  {
    if (ans > h[i + k - 1] - h[i]) ans = h[i + k - 1] - h[i];
  }
  printf("%d\n", ans);
  return 0;
}

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

int N;
int A;
int counter=0;

int main()
{
    cin>>N;

    for (int i=0; i<N; i++)
    {
        cin>>A;

        if (A%2==1)
        {
            counter++;
        }
    }

    if (counter%2==0)
    {
        cout<<"YES"<<endl;
    }

    else
    {
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3636
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: i32 = itr.next().unwrap().parse().unwrap();
    let x: i32 = itr.next().unwrap().parse::<i32>().unwrap() - 1;
    let y: i32 = itr.next().unwrap().parse::<i32>().unwrap() - 1;

    let mut ans: Vec<i32> = vec![0; 2020];
    for i in 0..n {
        for j in i + 1..n {
            let dist = std::cmp::min(j - i, (i - x).abs() + 1 + (j - y).abs());
            ans[dist as usize] += 1;
        }
    }
    let mut out = Vec::new();
    for i in 1..n {
        writeln!(out, "{}", ans[i as usize]).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 4352
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
acum1=[0]
for i in range(n): #累積和ai,bjを求める
 acum1.append(acum1[-1]+arr1[i])
acum2=[0]
for i in range(m):
 acum2.append(acum2[-1]+arr2[i])
ans=0
j=m
for i in range(n+1):
 if acum1[i]>k: #ai>Kであれば、どのようにjを選んでもai+bj<=Kとなることはないので探索を終了する
   break
 while acum2[j]>k-acum1[i] and j>0: #各iについて、bj<=K-aiを満たす最大のjを求める
   j-=1
 ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47596
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n;
void solve()
{
    cin>>n;ll ar[n];
    for(int i=0;i<n;i++)    cin>>ar[i];
    ans+=ar[0];
    for(int i=1;i<n;i++)
    {
        if(ar[i]>ar[i-1])
            ans+=ar[i]-ar[i-1];
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

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

int main () {
  int n; cin >> n;
  cout << "Christmas";
  if (n < 25) cout << " Eve" << endl;
    if (n < 24) cout << " Eve" << endl;
      if (n < 23) cout << " Eve" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int P,Q,R;
    cin >> P >> Q >> R;
    cout << P + Q + R - max(P, max(Q, R)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void) {
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	printf("%d\n", a + b + c - max(a, max(b, c)));

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;


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

		int hit, blow;
		int a[] = new int[4];
		int b[] = new int[4];

		while(sc.hasNext()){
			hit = blow = 0;

			for(int i = 0; i < 4; i++){
				a[i] = sc.nextInt();
			}
			for(int i = 0; i < 4; i++){
				b[i] = sc.nextInt();
			}

			for(int i = 0; i < 4; i++){
				if(a[i] == b[i]) hit++;
				else{
					for(int j = 0; j < 4; j++){
						if(a[i] == b[j]) blow++;
					}
				}
			}

			System.out.println(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 12000
#import "stdio.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        int a;
        scanf("%d", &a);
        for(int i = a; i<=999; i++) {
            if (i%111==0) {
                printf("%d\n", i);
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i < n + 1; ++i) {
        double x = (1.0 * m * i - k) / (2 * i - n);
        if (x >= 0.0 and x <= 1.0 * m and ceil(x) == floor(x)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i=0; i<=s.length(); i++){
        for(int j=i; j<=s.length(); j++){
            string t = s;
            t.erase(t.begin()+i, t.begin()+j);
            if(t == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(20)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};
void solve(){
	int ans=1;
	for(int i=0;i<5;i++){
		int x;
		cin>>x;
		if(x==0) ans=i+1;
	}
	cout<<ans<<endl;
		
	
	
	
	
	
	
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


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

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,cnt=0;
  long long int size=1,before=-1;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  for(int i=n-1;i>=0;i--){
    if(before==a[i]){
      cnt++;
      size*=a[i];
      before=-1;
    }else{
      before=a[i];
    }
    if(cnt==2){
      break;
    }
  }
  if(cnt==2) cout << size<<endl;
  else cout << 0<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int a, b;
  cin >> a >> b;
  int ans;
  for (int i = 1; i <= 1100; i++){
    int c = i * 8;
    int d = i * 10;
    c /= 100;
    d /= 100;
    if (c == a && d == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long a = long.Parse(input[1]);
    long b = long.Parse(input[2]);

    if(n == 1)
    {
      if(a == b) Console.WriteLine(1);
      else Console.WriteLine(0);
    }
    else
    {
      if(a>b) Console.WriteLine(0);
      else Console.WriteLine((b-a)*(n-2)+1);
    }

	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
//#include <iomanip>
using namespace std;
int main() {

	int a, b, c;
	cin >> a >> b >> c;
	if (a != b && b != c && a != c) {
		cout << "3" << endl;
		goto end;
	}
	if (a == b && b == c) {
		cout << "1" << endl;
	}
	else {
		cout << "2" << endl;
	}

	end:

	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
ans = "Yes"
start = [-1]*27
goal = [-1]*27
for i in range(len(S)):
    s,t = ord(S[i])-96,ord(T[i])-96
    if start[s]!=-1 or goal[t]!=-1:
        if start[s]!=t or goal[t]!=s:
            ans = "No"
    else:
        start[s] = t
        goal[t] = s
print(ans)

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, ans = 2;
int main() {
	cin >> n;
	REP(i, n) ans = ans * 2 + 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())

a = [[0] * (N + 1) for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    a[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        a[i][j] += a[i][j-1]
for i in range(1, N+1):
    for j in range(1, N+1):
        a[i][j] += a[i-1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(a[q][q] - a[p-1][q] - a[q][p-1] + a[p-1][p-1])


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

int main(){
    int h,w,ans=-1,l[4]={0,0,1,-1},m[4]={1,-1,0,0};
    cin >> h >> w ;
    vector<vector<char>> maze(h,vector<char> (w));
    queue<pair<int,int>> que;
    rep(i,h)rep(j,w){
        cin >> maze[i][j];
        if(maze[i][j]=='#') que.push(make_pair(i,j));
    }
    while(!que.empty()){
        queue<pair<int,int>> que1;
        while(!que.empty()){
            pair<int,int> d = que.front();
            int x,y;
            tie(x,y)=d;
            que.pop();
            rep(i,4){
                if(x+l[i]<0||h<=x+l[i]) continue;
                if(y+m[i]<0||w<=y+m[i]) continue;
                if(maze[x+l[i]][y+m[i]]=='#') continue;
                que1.push(make_pair(x+l[i],y+m[i]));
                maze[x+l[i]][y+m[i]]='#';
            }
        }
        ans++;
    que = que1;
    }
    cout << ans << endl;
}

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

void solve()
{
    long long int N, W, i, j;
    cin>>N>>W;
    vector<long int> v(N+1), w(N+1);
    for(i=1;i<=N;i++) {
        cin>>w[i]>>v[i]; 
    }
    vector<vector<long long int>> dp(N+1, vector<long long int>(W+1, 0));
    for(i=1;i<=N;i++)
    {
        dp[i][w[i]] = v[i];
    }
    for(i=1;i<=N;i++) {
        for(j=1;j<=W;j++) {
            if(w[i] > j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max({dp[i][j], dp[i-1][j], v[i] + dp[i-1][j-w[i]]});
        }
    }
    cout<<dp[N][W];
}

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

Measured memory_bytes: 83152
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define MOD 1000000007
#define EPS 1e-7


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


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    string s; cin>>s;
    sort(all(s));
    cout<<(s[0]!=s.back()?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_077_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 C1     PIC X(3).
    01 C2     PIC X(3).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT C1.
    ACCEPT C2.

    IF C1(1:1) = C2(3:1)
       AND C1(2:1) = C2(2:1) AND C1(3:1) = C2(1:1) THEN
       DISPLAY "YES"
    ELSE
       DISPLAY "NO"
    END-IF.

    STOP RUN.


Measured memory_bytes: 384