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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int n;
    cin>>n;
    vll v(n);
    forn(i,n){
        cin>>v[i];
    }

    ll curr=1000;

    int i=0;

    while(i<n){
        int temp=v[i],temp1=v[i];
        while(i<n && v[i]>=temp){
            temp=v[i];
            i++;
        }
        if(i==n){
            if(v[n-1]<=temp1)
                break;
        }
        ll pro=curr/temp1;

        curr -= (pro*temp1);
        curr += (pro * temp);
    }
    cout<< curr << endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);


int n,k;
vec a;

bool check(int mid){
  int kiru=0;
  rep(i,n){
    kiru+=a[i]/mid;
    if(a[i]%mid==0) kiru--;
  }
  if(kiru>k){
    return false;
  }
  else{
    return true;
  }
}


void solve4ts()
{
  
  
  cin>>n>>k;
  a.resize(n);
  int ma=0;
  rep(i,n){
    cin>>a[i];
    chmax(ma,a[i]);
  }
  if(k==0){
    cout<<ma<<endl;
    return;
  }


  int ng = 0, ok = INF;
  while (abs(ng-ok)>1) {
    int mid = ng+(ok-ng)/2;
    (check(mid)?ok:ng) = mid;
  }

  cout<<ok<<endl;
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/

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

int main(){
    int k,x;
    cin>>k>>x;

    int _min,_max;
    _min=max(-10000000,x-k+1);
    _max=min(10000000,x+k-1);
    for(int i=_min;i<=_max;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int swap;
	scanf("%d", &swap);
	char kata[10000];
	scanf("%s", kata);
	for(int i = 0; i < strlen(kata); i++){
		kata[i] += swap;
		if(kata[i] > 'Z'){
			kata[i] -= 26;
		}
	}
	for(int i = 0; i < strlen(kata); i++){
		printf("%c", kata[i]);
	}
	
	return 0;
}

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

void compress(vector<ll> s, vector<ll> &v) {
    for (int i = 0; i < s.size(); i++) {
        int cnt = 1;
        while (i + 1 < s.size() && s[i] == s[i + 1]) {
            cnt++;
            i++;
        }
        v.push_back(cnt);
    }
}

int main() {
    int n;
    cin >> n;
    vector<ll> s(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        ll a;
        cin >> a;
        s[i] = s[i - 1] + a;
    }
    sort(s.begin(), s.end());
    vector<ll> v;
    compress(s, v);
    ll ans = 0;
    for (int i = 0; i < v.size(); i++) {
        ans += v[i] * (v[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5492
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		sc.close();
		System.out.println((int)((T / A) + 0.5) * B);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int w,h,n;
int x,y,a;
int s[102][102];
int main(){
	void get1();
	void get0(int x,int y,int a);
	int getans();

	scanf("%d %d %d",&w,&h,&n);
	get1();

	for(int i=1;i<=n;i++){
		scanf("%d %d %d",&x,&y,&a);
		get0(x,y,a);
	}
	printf("%d",getans());
}

void get1(){
	for(int i=1;i<=w;i++){
		for(int j=1;j<=h;j++){
			s[i][j]=1;
		}
	}
}

int getans(){
	int ans=0;
	for(int i=1;i<=w;i++){
		for(int j=1;j<=h;j++){
			if(s[i][j]==1)
				ans++;
		}
	}
	return ans;
}

void get0(int x,int y,int a){
	if(a==1){
		for(int i=1;i<=x;i++){
			for(int j=1;j<=h;j++){
				s[i][j]=0;
			}
		}
	
	}
	else if(a==2){
		for(int i=x+1;i<=w;i++){
			for(int j=1;j<=h;j++){
				s[i][j]=0;
			}
		}
	}
	else if(a==3){
		for(int i=1;i<=w;i++){
			for(int j=1;j<=y;j++){
				s[i][j]=0;
			}
		}

	}

	else if(a==4){
		for(int i=1;i<=w;i++){
			for(int j=y+1;j<=h;j++){
				s[i][j]=0;
			}
		}

	}
}

Measured memory_bytes: 256
A,B,C,K = map(int,input().split())

score = 0

if A<K:
    K -= A
    score += A
else:
    score += K
    print(score)
    exit()

if B<K:
    K -= B
else:
    print(score)
    exit()

score -= min(K,C)
print(score)

Measured memory_bytes: 9184
def main():
    n,m = tuple([int(t)for t in input().split()])

    a = [tuple([int(t)for t in input().split()])for _ in [0]*m]

    t = max(a,key=lambda x:x[0])[0]
    s = min(a,key=lambda x:x[1])[1]
    ans = s-t+1
    if ans<0:
        print(0)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 17388
a, b, c, x, y = map(int, input().split())
if (a + b) / 2 < c:
  print(a * x + b * y)
else:
  min_xy = min(x, y)
  ans = c * min_xy * 2
  if x > y:
    if a / 2 > c :
      ans += c * (x - y) * 2
    else:
      ans += a * (x - y)
  elif x < y:
    if b / 2 > c :
      ans += c * (y - x) * 2
    else:
      ans += b * (y - x)
  print(ans)

Measured memory_bytes: 61908
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int difference = b - a;
		int heightB = 0;
		for (int i = 1; i <= difference; i++) {
			heightB += i;
		}
		System.out.println(heightB - b);
		
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n; cin>>n;
    long long sum=0;
    long long a[n]; rep(i,n) {cin>>a[i];sum+=a[i];}
    if(sum/(n*(n+1)/2)*(n*(n+1)/2)!=sum){
        cout<<"NO"<<endl;
        return 0;
    }
    sum/=(n*(n+1)/2);
    long long sabun[n];
    rep(i,n){
        sabun[i]=a[i+1]-a[i];
    }
    sabun[n-1]=a[0]-a[n-1];
    long long cnt=0;
    rep(i,n){
        sabun[i]-=sum;
        if(sabun[i]%n==0&&sabun[i]<0){
            cnt-=sabun[i]/n;
        }
    }
    if(sum==cnt) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int a, z;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
    for (int i = (int)s.size()-1; i >= 0; i--) {
        if (s[i] == 'Z') {
            z = i;
            break;
        }
    }
    cout << z-a+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const vector<ll> four={0,1,0,-1,0};
using tuplis=pair<ll,pair<ll,ll>>;
template<class T>using pq=priority_queue<T,vector<T>,greater<T>>;
template<class T>inline constexpr bool update_min(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}




#define int long long
signed main(){
    int x,y;
    cin>>x>>y;
    int ans=1;
    while((x*=2)<=y)ans++;
    cout<<ans<<endl;
}





Measured memory_bytes: 256
using System;
using System.Collections;

namespace test
{
    class test
    {
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();

            for(int i = 0; i <= 4; i++)
            {
                al.Add(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine().ToString());

            int a = int.Parse(al[0].ToString());
            int b = int.Parse(al[4].ToString());
            bool flg = true;
            if (b - a > k)
            {
                flg = false;
            }
            string str = string.Empty;
            if (flg)
            {
                str = "Yay!";
            }
            else
            {
                str = ":(";
            }
            Console.WriteLine(str);
        }
    }
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    string S;
    cin >> S;

    int na = 0, nb = 0;
    rep(i, N) {
        bool ok = false;
        if (S[i] == 'a' && na + nb < A + B) {
            ok = true;
            na++;
        } else if (S[i] == 'b' && na + nb < A + B && nb < B) {
            ok = true;
            nb++;
        }
        if (ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

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

A = [(a, i) for i, a in enumerate(A)]
A.sort(reverse = True)

dp = [[0]*(N+1) for _ in range(N+1)]

ans = 0

for l in range(N):
    for r in range(N):
        if l+r == N:
            ans = max(ans, dp[l][r])
            break
        else:
            a, i = A[l+r]
            dp[l+1][r] = max(dp[l+r][r], dp[l][r] + a*abs(l-i))
            dp[l][r+1] = max(dp[l][r+1], dp[l][r] + a*abs((N-1-r)-i))

print(ans)

Measured memory_bytes: 100652
#include <stdio.h>


int main(void)
{
	int a,b;

   scanf("%d %d", &a,&b);
   
 if(a<b){
	 printf("a < b\n");
} else if(a>b) {
     printf("a > b\n");
} else {
	 printf("a == b\n");
}
   return 0;

}

Measured memory_bytes: 580
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        a: f64,
        b: f64,
        c: f64,
        d: f64,
    }

    let x = c / b;
    let y = a / d;

    if x.ceil() <= y.ceil() {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2696
package main

import "fmt"

func main() {
  var a, b, n int
  fmt.Scanf("%d %d %d", &n, &a, &b)
  if (a - b) % 2 == 0 {
    fmt.Println(abs(a - b) / 2)
  } else {
    p, q := n - a, n - b
    m := min(a - 1, b - 1, p, q)
    fmt.Println(m + 1 + (abs(a - b) - 1) / 2)
  }
}

func abs(m int) int {
  if m > 0 {return m}
  return -m
}

func min(a ...int) int {
  m := a[0]
  for _, v := range a {
    if v < m {
      m = v
    }
  }
  return m
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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


	int N;
	cin >> N;
	int odd = 0, even = 0;
	rep(i, N) {
		int j;
		cin >> j;
		if (j % 2 == 0)even++;
		else odd++;
	}

	even += odd / 2;
	odd %= 2;
	even = min(int(1), even);
	int ans = odd + even;
	if (ans == 1)cout << "YES" << endl;
	else cout << "NO" << endl;




	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){

  int i,j,k;
  int num,key;
  int *A;
  
  scanf("%d",&num);
  A=malloc(sizeof(int)*num);

  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<num-1;i++){
    printf("%d ",A[i]);
  }
  
    printf("%d\n",A[num-1]);
  
  for(i=1;i<num;i++){
    key=A[i];
    j=i-1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j]; 
      j--;
      A[j+1] = key;
    }
    for(k=0;k<num-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d\n",A[num-1]);
  }
  free(A);
  
  return 0;
}

Measured memory_bytes: 600
#include  <iostream>

using namespace std;

int main()
{
	int n, m;
	int t[100000] = { 0 }, p[100], x[100];

	cin >> n;
	for (int i = 0; i < n; i++)  cin >> t[i];
	cin >> m;
	for (int i = 0; i < m; i++)  cin >> p[i] >> x[i];
	
	int sum = 0;
	for (int i = 0; i < n; i++)  sum += t[i];  

	int ksum = sum;
	for (int i = 0; i < m; i++) {
		int k = t[p[i] - 1] - x[i];
		if (k > 0) {
			sum -= k;
		}
		else {
			sum += -k;
		}
		cout << sum << endl;
		sum = ksum;
	}	
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (N, M, V, P) = readInputLine().split(" ").map { it.toLong() }
    val AArr = readInputLine().split(" ").map { it.toLong() }.sortedDescending().toLongArray()

    var ans = 0
    var diffNum = 0L
    var overCnt = 0L

    for (i in LongRange(0L, N - 1L)) {
        if (AArr[i.toInt()] + M < AArr[(P - 1L).toInt()]) {
            break
        }
        if (i > P && (P - 1L) * M + (N - i) * M + (AArr[i.toInt()] + M - AArr[(P - 1L).toInt()]) * overCnt + diffNum < M * V) {
            break
        }

        if (i >= P - 1L) {
            diffNum += AArr[(P - 1L).toInt()] - AArr[i.toInt()]
            overCnt++
        }

        ans++
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 56364
#include<stdio.h>

 
int main(){
 
  int n,i;
  char s[101];
  int cnt=0;

    scanf("%d",&n);
    scanf("%s",s);
  for(i=0;i<n;i++){
    if(s[i]=='R')cnt++; }

  if(cnt>n/2) printf("Yes");
  else	printf("No");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int A[MAX],n;
int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++) L[i]=A[left+i];
	for(int i=0;i<n2;i++) R[i]=A[mid+i];
	L[n1]=R[n2]=SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]) A[k]=L[i++];
		else A[k]=R[j++];
	}
}

void mergesort(int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergesort(left,mid);
		mergesort(mid,right);
		merge(left,mid,right);
	}
}

int main(){
	int i;
	cnt=0;
	
	cin>>n;
	for(i=0;i<n;i++) cin>>A[i];
	
	mergesort(0,n);
	
	for(i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	
	cout<<cnt<<endl;
	
	return 0;
}



Measured memory_bytes: 6912
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt64(scanner)
	if n < 2 {
		fmt.Println(0)
		return
	}
	if n%2 == 1 {
		fmt.Println(0)
		return
	}

	var ans int64
	for i := 1; i <= 25; i++ {
		ans += int64(n / (int64(math.Pow(5, float64(i))) * 2))
	}
	fmt.Println(ans)

	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int n; 
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> s;
  vector<int>ord(n+1,-1);
  int c=1,l = 0; 
  {
    int v = 1;
    while(ord[v] == -1){
      ord[v] = s.size();
      s.push_back(v);
      v=a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];//ループしない部分
  }
  if(k < l) cout << s[k] << endl;//ループしないところでk回使い切る
  else{
    k-=l;//ループしない部分を引く
    k%=c;//最終的にループし始めからK%cの位置
    cout << s[l+k] << endl;//ループし始めの位置＋移動
  }
  return 0;
}

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

struct Node{
  int parent,left,right;
};

Node T[100005];
int n,D[1000005];



void setDepth(int u, int p){
  D[u]=p;
  if(T[u].right!=-1){
    setDepth(T[u].right,p);
  }
  if(T[u].left!=-1){
    setDepth(T[u].left,p+1);
  }
}

int main(){
  int i=0,j=0,k=0,c=0,l=0,r=0,Tc=0;
  int id=0;
  cin>>n;
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=-1;
  }
  for(i=0;i<n;i++){
    cin>>id>>k;
    for(j=0;j<k;j++){
      cin>>c;
      if(j==0)T[id].left=c;
      else T[l].right=c;
      l=c;
      T[c].parent=id;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1){
      r=i;
    }
  }
  setDepth(r,0);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,D[i]);
    if(T[i].parent==-1)cout<<"root, ";
    else if(T[i].left==-1)cout<<"leaf, ";
    else cout<<"internal node, ";
    cout<<"[";
    for(j=0,Tc=T[i].left;Tc!=-1;j++,Tc=T[Tc].right){
      //while(1){
      if(j)cout<<", ";
      cout<<Tc;
	//if(T[i].left==-1||T[i].left==T[T[i].left].right)break;
    }
    cout<<"]"<<endl;
    /*while(1){
      if(T[i].left==-1)break;
      
    }*/
  }
  return 0;
}



Measured memory_bytes: 7900
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,h; cin >> n >> h;
  vi a(n), b(n);
  int amax = 0;
  rep(i, n){
    cin >> a[i] >> b[i];
    chmax(amax,a[i]);
  }

  sort(all(b),greater<int>());
  int ans = 0;
  rep(i, n){
    if(b[i] > amax){
      h -= b[i];
      ans++;
      if(h <= 0) break;
    }
  }
  if(h > 0){
    if(h%amax == 0) ans += h/amax;
    else ans += h/amax + 1;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
//using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(X , Y);
  if(X == 1 && Y == 1) out(1000000);
  else{
    int cur = max(0 , 4 - X) + max(0 , 4 - Y);
    out(cur * 100000);
  }

}

Measured memory_bytes: 256
a,b,h,m = map(int, input().split())
import math
a_x = a * math.cos(math.radians(30*h + 0.5*m))
a_y = a * math.sin(math.radians(30*h + 0.5*m))
b_x = b * math.cos(math.radians(6*m))
b_y = b * math.sin(math.radians(6*m))

ans = math.sqrt(abs(a_x - b_x)**2 + abs(a_y - b_y)**2)
print(ans)


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

typedef long long ll;
typedef long double ld;

ll niz[1000005];
ll dp[1000005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
    }
    dp[2] = abs(niz[2] - niz[1]);
    for(int i=3; i<=n; i++){
        dp[i] = min(dp[i-1] + abs(niz[i]-niz[i-1]), dp[i-2] + abs(niz[i]-niz[i-2]));
    }
    cout << dp[n];
    return 0;
}


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

int main(){
	
	string s; cin>>s;
	s.erase(unique(s.begin(),s.end()),s.end());
	if(s.size()!=4) cout << "Bad" << endl;
	else cout << "Good" << endl;
	
}

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

int main(){
  while(true){ 
    int M,T,P,R;
    cin >> M >> T >> P >> R;
    if(M==0 && T==0 && P==0 && R==0) break;
    int S[T][P];
    memset(S,0,sizeof(S));
    pair<pair<int, int>,int> pa[T];
    rep(i,T){
      pa[i]=make_pair(make_pair(0,0),i+1);
    }
    rep(i,R){
      int m,t,p,j;
      cin >> m >> t >> p >> j;
      if(j==0){
	pa[t-1].first = make_pair(pa[t-1].first.first+1,pa[t-1].first.second-m-S[t-1][p-1]*20);
      }else{
	S[t-1][p-1]++;
      }
    }
    sort(pa,pa+T);
    reverse(pa,pa+T);
    rep(i,T){
      cout << pa[i].second;
      if(i!=T-1){
	if(pa[i].first.first==pa[i+1].first.first && pa[i].first.second==pa[i+1].first.second) cout << "=";
	else {
	  cout << ",";
	  //cout << "i = " << i << " : " <<  pa[i].first.second << "  i+1 = " << i+1 << " : " << pa[i+1].first.second << endl;
	}
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
H, W = map(int,input().split())
A = [input() for _ in range(H)]

result = []
for a in A:
  result.append('#' + a +'#')
waku = '#' * (W+2)
result.insert(0,waku)
result.insert(len(A)+1,waku)
for r in result:
  print(r)

"""
お前の目は節穴か？
"""

Measured memory_bytes: 3060
/*******************************************
* AUTHOR : Adnan Masroor :-)
* NICK : adnanlari
* COLLEGE : NIT Durgapur
********************************************/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll MOD=1000000007,BMOD=100000000700000;

bool check(string s)
{
	int n=s.length();
	for(int i=0;s[i]!=0;i++)
	{
		if(s[i]!=s[n-i-1])
			return false;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	/*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif*/
	//the main code starts here
    
	string s;
	cin>>s;
	int l=s.length();
	if(check(s) && check(s.substr(0,l/2)) && check(s.substr(l/2+1)))
		cout<<"Yes\n";
	else
		cout<<"No\n";


	return 0;
}

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

vector<int> a;

ll max_val = 1e16;

int main() {
  int n;
  cin >> n;
  a.resize(n+1);
  rep(i, n+1) {
    cin >> a[i];
  }

  // 追加できる葉の数を保持する
  vector<ll> b(n+2, 0);
  b[0] = 1;
  rep(i, n+1) {
    // 0以下の場合は作れない
    // ただし最後は0でもOK
    if(i == n) {
      if(b[i] - a[i] < 0) {
        cout << -1 << endl;
        return 0;
      }
    }
    else if(b[i] - a[i] <= 0) {
      cout << -1 << endl;
      return 0;
    }
    b[i+1] = min(max_val, (b[i] - a[i]) * 2);
    // printf("%d: %lld, %lld\n", i+1, max_val, b[i+1]);
  }

  ll vs = 0;
  ll pvs = 0;
  for(int i = n; i>=0; i--) {
    ll max_dvs = min(a[i] + pvs, b[i]);
    pvs = max_dvs;
    vs += max_dvs;
  }
  cout << vs << endl;
  return 0;
}


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
int a,b,c,t=0; 
int main()
{
	cin>>a>>b>>c;
	t=a*100+b*10+c;
	if(t%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

int main() {
    int a[3];
    int K;

    cin >> a[0] >> a[1] >> a[2];
    cin >> K;

    sort(a, a + 3, greater<int>());

    int ans;

    ans = a[1] + a[2] + a[0] * pow(2, K);

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

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

using namespace std;

typedef vector<char> vc;
typedef vector<vc> vvc;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<char, pii> mcpii;
typedef pair<pair<string, string>, int> ppssi;
typedef vector<ppssi> vppssi;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second
#define read freopen("..\\in.txt", "r", stdin)
#define write freopen("..\\out.txt", "w", stdout)

const int dir_x[]{0, 0, -1, 1}, dir_y[]{-1, 1, 0, 0};

const int INF = 1e9 + 5;

int main() {
    //read;
    int T = 1;
    //cin >> T;
    vector<ll> lunlun;
    queue<ll> q;
    for (int i = 1; i <= 9; ++i) q.push(i), lunlun.eb(i);
    while (1) {
        if (lunlun.size() > (100005)) break;
        ll v = q.front();
        q.pop();
        int x = v % 10;
        if (x >= 1 && x <= 8) {
            ll a = v * 10 + (x - 1);
            ll b = v * 10 + x;
            ll c = v * 10 + (x + 1);
            q.push(a);
            q.push(b);
            q.push(c);
            lunlun.eb(a);
            lunlun.eb(b);
            lunlun.eb(c);
        } else if (x == 0) {
            ll a = v * 10 + x;
            ll b = v * 10 + (x + 1);
            q.push(a);
            q.push(b);
            lunlun.eb(a);
            lunlun.eb(b);
        } else if (x == 9) {
            ll a = v * 10 + x - 1;
            ll b = v * 10 + x;
            q.push(a);
            q.push(b);
            lunlun.eb(a);
            lunlun.eb(b);
        }
    }
    for (int tc = 1; tc <= T; ++tc) {
        ll k;
        cin >> k;
        cout << lunlun[k - 1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1620
#include<stdio.h>
#define MAX 200000

int main(){
  int i,n=0,r[MAX];
  int maxvalue=-2000000000;
  //int minivalue;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&r[i]);
  }

  int minivalue=r[0];

  for(i=1;i<n;i++){
    if(maxvalue<r[i]-minivalue){
      maxvalue=r[i]-minivalue;
    }
    //else maxvalue=maxvalue;

    if(minivalue>r[i]){
       minivalue=r[i];
       // minivalue=minivalue;
    }
    // else minivalue=r[i];
  }

  printf("%d\n",maxvalue);

  return 0;
}
    



Measured memory_bytes: 2508
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
#include <stack>
#include <math.h>
using namespace std;
typedef long long int ll;

int cost[500*500];
bool used[500*500];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> p(n*n);
	for(int i=0;i<n*n;i++){
		cin >> p[i]; p[i]--;
		cost[i]=min({i%n,n-1-i%n,n-1-i/n,i/n});
	}
	int res=0;
	for(int i=0;i<n*n;i++){
		res+=cost[p[i]];
		used[p[i]]=1;
		queue<int> q;
		q.push(p[i]);
		while(q.size()){
			int p=q.front(); q.pop();
			int c=cost[p];
			if(!used[p])c++;
			if(p%n){
				if(cost[p-1]>c){
					cost[p-1]=c;
					q.push(p-1);
				}
			}
			if(p%n!=n-1){
				if(cost[p+1]>c){
					cost[p+1]=c;
					q.push(p+1);
				}
			}
			if(p/n){
				if(cost[p-n]>c){
					cost[p-n]=c;
					q.push(p-n);
				}
			}
			if(p/n!=n-1){
				if(cost[p+n]>c){
					cost[p+n]=c;
					q.push(p+n);
				}
			}
		}
	}
	printf("%d\n",res);
}


Measured memory_bytes: 5580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    unordered_map<string,int>happened;
    string s;
    cin>>s;

    happened[s]=1;
    char cur=s[s.size()-1];
    int wrong=0;

    for(int i=0;i<n-1;i++)
    {
        cin>>s;
        if(s[0]!=cur)
        {
            wrong=1;
        }
        else
        if(happened.find(s)!=happened.end())
        {
            wrong=1;
        }
        happened[s]=1;
        cur=s[s.size()-1];
    }
    if(wrong==1)
    cout<<"No\n";
    else
    cout<<"Yes\n";



return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let ans = if a.contains(&1) {
        let mut count = 1;
        let mut count_destory_blocks = 0;
        for a_i in a {
            if a_i == count {
                count += 1;
            } else {
                count_destory_blocks += 1;
            }
        }
        count_destory_blocks
    } else {
        -1
    };

    println!("{}", ans);
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e5 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

int dp[N];

int a[111];

int main () {
	boost;
	int n, k;
	cin >> n >> k;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> a[i];
	}
	dp[0] = 0;
	for (int i = 1 ; i <= k ; ++ i) {
		for (int j = 0 ; j < n ; ++ j) {
			if (i - a[j] >= 0 && !dp[i - a[j]])
				dp[i] = 1;
		}
	}
	cout << (dp[k] ? "First" : "Second");
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace ABC132B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var ans = 0;

            for (var i = 1; i <= n - 2; i++)
            {
                var tmp = new int[] { p[i - 1], p[i], p[i + 1] };
                if (tmp.OrderBy(x => x).ElementAt(1) == p[i])
                    ans += 1;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
open Printf
open Scanf

let id x = x

let h, w = scanf "%d %d" (fun h w -> h, w)
let vs = Array.init (h * w) (fun i -> scanf " %d" id)

let nth n =
  let y = n / w in
  let x = n mod w in
  let x' = if y mod 2 = 0 then x else w - 1 - x in
  y * w + x'

let decode n =
  let y = n / w in
  let x = n mod w in
  (y + 1, x + 1)

let () =
  let out = ref [] in
  let moving = ref false in
  for n = 0 to h * w - 1 do
    let i = nth n in
    if !moving then begin
      out := (i, n) :: !out;
      if vs.(i) mod 2 = 1 then moving := false
    end else begin
      if vs.(i) mod 2 = 1 then moving := true
    end
  done;
  out := List.rev !out;
  printf "%d\n" (List.length !out);
  List.iter (fun (v, n) ->
    let y0, x0 = decode (nth (n - 1)) in
    let y1, x1 = decode v in
    printf "%d %d %d %d\n" y0 x0 y1 x1
  ) !out;


Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
MM = input().split()
A = int(MM[0])
B = int(MM[1])
C = int(MM[2])
K = int(input())
S = [A,B,C]
S.sort()

S[-1] = S[-1] * 2 ** K

total =0
for i in S:
  total += i
print(total)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
long long n;
int ans;

void dfs(int a,int b,int c,long long x){
    if(x > n){
        return;
    }
    if(a && b && c){
        ans++;
    }
    dfs(1,b,c,x*10+3);
    dfs(a,1,c,x*10+5);
    dfs(a,b,1,x*10+7);
}

int main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;
long long ans;
long long D,G,p,c;
vector<long long>vec_p;
vector<long long>vec_c;
long long solve(vector<long long>tmp_p, vector<long long>tmp_c) {
  long retans;
  long num,s,si,restmax, need;
  retans = INF;
  for(int mask=0; mask < (1 << D); mask++) {
    num = 0;
    s = 0;
    si = 0;
    restmax = 0;
    need = 0;
    for(int i = 0; i < D; i++) {
      if((mask >> i) & 1) {
        s += (i + 1) * 100 * tmp_p[i] + tmp_c[i];
        num += tmp_p[i];
      } else {
        restmax = i;
      }
    }
    if(s < G) {
      si = (restmax + 1) * 100;
      need = (G - s + si - 1) / si;
      if(need >= tmp_p[restmax]) {
        continue;
      }
      num += need;
    }
    retans = min(retans, num);
  }
  return retans;
}

int main(int arg, char* argv[]) {
  scanf("%d %d ", &D, &G);
  for(int i = 0; i < D; i++) {
    p = c = 0;
    scanf("%d %d", &p, &c);
    vec_p.push_back(p);
    vec_c.push_back(c);
  }
  ans = solve(vec_p, vec_c);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
int main() {
  char b;
  cin >> b;
  char ans;
  string s = "ACGT", t = "TGCA";
  rep(i, 4) if(b == s[i]) ans = t[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();
	int n; cin >> n;
	cout << fixed << setprecision(6);
	if (n & 1)
		cout << (n / 2 + 1) / (double)n << endl;
	else
		cout << 0.5000000 << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            if (B / A > C)
                Console.WriteLine(C.ToString());
            else
                Console.WriteLine((B / A).ToString());

            //Console.ReadKey();
        }

    }
}


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

// それぞれマイナス方向で頑張るか、プラス方向で頑張るかの2^3=8通りのパターンを固定して考えてやるとソートが可能になり、
// 順番にいい方から選べそう

long long solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y, std::vector<long long> z){
    long long res = 0;
    for (int s = 0; s < 8; s++) {
        vector<vector<long long>> values;
        values.push_back(x);
        values.push_back(y);
        values.push_back(z);
        for (int i = 0; i < 3; i++) {
            if (s & 1 << i) {
                for (int j = 0; j < N; j++)
                    values[i][j] *= -1;
            }
        }

        vector<long long> sums;
        for (int i = 0; i < N; i++) {
            sums.push_back(values[0][i] + values[1][i] + values[2][i]);
        }
        sort(sums.begin(), sums.end());
        reverse(sums.begin(), sums.end());
        long long firstM = 0;
        for (int i = 0; i < M; i++)
            firstM += sums[i];
        res = max(res, firstM);
    }
    return res;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> z(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&z[i]);
    }
    cout << solve(N, M, std::move(x), std::move(y), std::move(z)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
struct Z{
  // v[i] には s と s[i..-1] の最長共通接頭辞長が入る
  void solve(vector<int>& v, string& s){
    int l = s.size(), i = 1, j = 0, k;
    v.resize(l);
    if(l < 1) return;
    v[0] = l;
    while (i < l) {
      while (i+j < l && s[j] == s[i+j]) ++j;
      v[i] = j;
      if(!j){
        ++i;
        continue;
      }
      k = 1;
      while (i+k < l && k+v[k] < j) v[i+k] = v[k], ++k;
      i += k; j -= k;
    }
  }
} z;
string s;
V<int> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  z.solve(v, s);
  int ans = 0;
  FOR(i, 1, sz(s)/2) if(i<=v[i]) maxs(ans, i);
  cout << ans*2 << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
X = [0] * 26
for _ in range(H):
    for a in input():
        X[ord(a)-97] += 1

Y = [0] * 2 # 1, 2
for x in X:
    if x%4 == 1:
        Y[0] += 1
    elif x%4 == 2:
        Y[1] += 1
    elif x%4 == 3:
        Y[0] += 1
        Y[1] += 1

if Y[0] <= (H%2) * (W%2) and Y[1] <= (H%2) * (W//2) + (W%2) * (H//2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>

using namespace std;

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int n;
int s[100];
 int count_d;

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

  cin>>n;
  if(n == 0){
      printf("%d\n",0);
  }

  for(int i = 0; n != 0; i++){
      s[i] = ((n % 2) + 2) % 2;
      n = (n - s[i]) / -2;
      count_d++;
  }


  rrep(i, count_d){
      cout<<s[i];
  }
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, x;
    scanf("%d %d", &n, &x);
    int d = 0;
    int count = 1;
    for(int i = 0; i < n; i++){
        int l;
        scanf("%d", &l);
        d = d + l;
        if(d <= x) count++;
    }
    printf("%d\n", count);
}

Measured memory_bytes: 128
<?php

fscanf(STDIN, '%d %d', $n, $m);

for ($i = 0; $i < $n; $i++) {
    $a[] = explode(' ', trim(fgets(STDIN)));
}

for ($i = 0; $i < $m; $i++) {
    $b[] = trim(fgets(STDIN));
}

for ($i = 0; $i < $n; $i++) {
    $c[$i] = 0;
    for ($j = 0; $j < $m; $j++) {
        $c[$i] += $b[$j] * $a[$i][$j];
    }
    echo $c[$i], PHP_EOL;
}

Measured memory_bytes: 8396
(ns Atcoder.ABC083-B)
(require '[clojure.string :as str])
(def input (map read-string (str/split (read-line) #" ")))  ;inputの値を代入 N A B

(def N (nth input 0))
(def A (nth input 1))
(def B (nth input 2))

(defn sumDigits [x]                                         ;整数値xの各桁の和
  (reduce + (map (fn [z] (- (int z) (int \0))) (seq (str x))))
  )

(def ans
  (reduce + (filter (fn [x]
                      (def sum (sumDigits x))
                      (and (>= sum A) (<= sum B)))
                    (range 1 (+ N 1))
                    )
          )
  )

(println ans)

Measured memory_bytes: 85068