akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
  int N,temp=1;
  cin >> N;
  vector<int>vec(N);
  REP(i,N)cin >> vec.at(i);
  FOR(i,1,N){
    temp=vec.at(temp-1);
    if(temp==2){
      cout << i << endl;
      break;
    }
    if(i==N-1)cout << -1 << endl;
  }
}


Measured memory_bytes: 640
while True:
    m, f, r = map(int, input().split())
    t = m+f
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif t >= 80:
        print("A")
    elif 65 <= t and t < 80:
        print("B")
    elif 50 <= t and t < 65:
        print("C")
    elif 30 <= t and t < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")
    elif t < 30:
        print("F")
    else:
        raise Exception


Measured memory_bytes: 5592
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll k, s,count=0;
	cin >> k >> s;
	for (ll i = 0; i <=k ; i++) {
		for (ll j = 0; j <=k ; j++) {
			if (0<=s - (i + j)&&s-(i+j) <= k) {
				count++;
			}
		}
	}
	cout << count << endl;
}



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

using i64 = long long;

constexpr i64 mod = 1000000007;

i64 pow(i64 a, i64 b) {
  i64 r = 1;
  while (b != 0) {
    if (b % 2 != 0) {
      r = r * a % mod;
    }
    a = a * a % mod;
    b /= 2;
  }
  return r;
}

int main() {
  i64 n, k;
  std::cin >> n >> k;
  std::vector<i64> a(k + 1);
  for (int i = 1; i <= k; i += 1) {
    a[i] = pow(k / i, n);
  }
  
  for (int i = k; i >= 1; i -= 1) {
    for (int j = i * 2; j <= k; j += i) {
      a[i] = (a[i] - a[j] + mod) % mod;
    }
  }
  
  i64 ans = 0;
  for (int i = 1; i <= k; i += 1) {
    ans = (ans + a[i] * i % mod) % mod;
  }
  
  std::cout << ans << "\n";
}


Measured memory_bytes: 4052
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int ans[maxn],d[maxn*2],fa[maxn*2],h[maxn*2],now[maxn*2],go[maxn*6],nxt[maxn*6],sta[maxn*6];
bool bz[maxn*6],czy;
int i,j,k,l,r,s,t,n,m,tot,top,rot1,rot2; /*int read(){
    int x=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') f=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9'){

    }
}*/
void add(int x,int y) {
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x,int y) {
	int t=h[x];
	while (t) {
		if (go[t]!=y) {
			dfs(go[t],x);
			d[x]^=1;
		}
		t=nxt[t];
	}
	d[x]^=1;
}
void travel(int x) {
	int t=now[x];
	while (t=now[x]) {
		now[x]=nxt[t];
		if (!bz[(t+1)/2]) {
			bz[(t+1)/2]=1; //now[x]=nxt[t];
			travel(go[t]);
		}
	}
	sta[++top]=x;
}
int main() {
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&fa[i]);
		if (fa[i]==-1) {
			fa[i]=0;
			rot1=i;
		} else {
			add(fa[i],i);
			add(i,fa[i]);
		}
	}
	fo(i,n+1,2*n) {
		scanf("%d",&fa[i]);
		if (fa[i]==-1) {
			fa[i]=0;
			rot2=i;
		} else {
			add(fa[i]+n,i);
			add(i,fa[i]+n);
		}
	}
	dfs(rot1,0);
	dfs(rot2,0);
	czy=1;
	fo(i,1,n) if (d[i]^d[i+n]) {
		czy=0;
		break;
	}
	if (!czy) {
		printf("IMPOSSIBLE\n");
		return 0;
	}
	printf("POSSIBLE\n");
	s=0;
	add(s,rot1);
	add(rot1,s);
	add(s,rot2);
	add(rot2,s);
	fo(i,1,n) if (d[i]) {
		add(i,i+n);
		add(i+n,i);
	}
	fo(i,s,2*n) now[i]=h[i];
	travel(s);
	fo(i,1,n) if (d[i]) ans[i]=-1;
	fo(i,1,top-1) if (sta[i]>0&&sta[i]<=n&&sta[i+1]==sta[i]+n) ans[sta[i]]=1;
	fo(i,1,n) printf("%d ",ans[i]);
}

Measured memory_bytes: 20352
#include <algorithm>
#include <iostream>
#include <vector>

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

#define INF 1000000000

using namespace std;

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

    if (A + B >= C)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

vector<int> hs;
int n;

int main() {
    cin >> n;
    hs.resize(n, 0);
    for (int i = 0; i < n; i++) cin >> hs[i];
    if (n == 1) {
        cout << hs[0] << endl;
        return 0;
    }
    if (n == 2) {
        cout << max(hs[0], hs[1]) << endl;
        return 0;
    }
    vector<int> minPos;
    for (int i = 1; i < n - 1; i++) {
        if (hs[i] <= hs[i + 1] && hs[i] <= hs[i - 1]) minPos.push_back(i);
    }
    if (minPos.size() == 0) {
        cout << (*max_element(hs.begin(), hs.end())) << endl;
        return 0;
    }
    int ans = 0;
    ans += (*max_element(hs.begin(), hs.begin() + 1 + minPos[0]));
    ans += (*max_element(hs.begin() + minPos[minPos.size() - 1], hs.end()));
    for (int i = 1; i < minPos.size(); i++) {
        ans += (*max_element(hs.begin() + minPos[i - 1], hs.begin() + minPos[i] + 1));
        ans -= hs[minPos[i - 1]];
    }
    ans -= hs[minPos[minPos.size() - 1]];
    cout << ans << endl;
}

Measured memory_bytes: 256
//c.......

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(c>=b || d<=a) printf("0");
    else if(a<c && b>c) {
        if(b>=d) printf("%d",d-c);
        else printf("%d",b-c);
    }
    else if(a>=c && b>c){
        if(b>=d) printf("%d",d-a);
        else printf("%d",b-a);
    }
    return 0;
}


Measured memory_bytes: 128
"""brute force
import itertools


n = int(input())
jobs = [list(map(int, input().split())) for _ in range(n)]

for pattern in itertools.permutations([i for i in range(n)]):
    t = 0
    flag = True
    for i in pattern:
        t += jobs[i][0]
        if t > jobs[i][1]:
            flag = False
    if flag:
        print("Yes")
        exit()
print("No")
"""
import heapq

n = int(input())
jobs = [list(map(int, input().split()[::-1])) for _ in range(n)]

heapq.heapify(jobs)
t = 0
for i in range(len(jobs)):
    deadline, job_t = heapq.heappop(jobs)
    t += job_t
    if t > deadline:
        print("No")
        exit()
print("Yes")

    











Measured memory_bytes: 51712
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int x;
  cin>>x;
  int five=0;
  int fiveh=0;
    if(x>=500){
      int hoge=x/500;
      fiveh+=hoge;
      x-=hoge*500;
    }
    
    if(x>=5){
      int hoge=x/5;
      five+=hoge;
      x-=hoge*5;
    }
  long long int ans=five*5 + fiveh*1000;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
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();

        int min = Math.min(a+b, b+c);
        min = Math.min(min, a+c);

        System.out.println(min);
    }
}

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

int main(){
  string s;
  cin>>s;
  bool ans=0;
  if(s=="hi") ans=1; 
  if(s=="hihi") ans=1; 
  if(s=="hihihi") ans=1; 
  if(s=="hihihihi") ans=1; 
  if(s=="hihihihihi") ans=1; 
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    a, b = map(int, input().split())
    ans = 0
    for m in range(1, a + 1):
        for d in range(1, b + 1 if m == a else 32):
            ans += (m == d)
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  string a, b;
  cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	M := nextInt(sc)
	m := make(map[int][]int, N)
	for i := 0; i < M; i++ {
		from := nextInt(sc)
		to := nextInt(sc)
		m[from] = append(m[from], to)
	}
	// fmt.Println("N", N, "M", M, "m", m)
	if m[1] != nil {
		v := m[1]
		for i := 0; i < len(v); i++ {
			if w := m[v[i]]; w != nil {
				for j := 0; j < len(w); j++ {
					if w[j] == N {
						fmt.Println("POSSIBLE")
						return
					}
				}
			}
		}
	}
	fmt.Println("IMPOSSIBLE")
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ll ct = 0;

    
    if(k>=0){
        ans += min(a, k);
        k -= a;
   }
    if(k>=0){
        k -= b;

    }
    if(k>=0){
        ans -= min(k, c);
    }
    cout << ans;
}


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] g = { 2, 3, 5, 10, 12, 15 };
        int[] a = { 380, 550, 850, 1520, 1870, 2244 };
        int[] dp = new int[51];
        Arrays.fill(dp, 10000);
        dp[0] = 0;
        for (int i = 0; i < dp.length - 1; i++) {
            for (int j = 0; j < g.length; j++) {
                if (i + g[j] > dp.length - 1) continue;
                dp[i + g[j]] = Math.min(dp[i + g[j]], dp[i] + a[j]);
            }
        }
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            System.out.println(dp[n / 100]);
        }
        sc.close();
    }
}


Measured memory_bytes: 26060
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    a_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    b = 10**18

    if 0 in a_list:
        print(0)
        return

    a = 1
    for _a in a_list:
        a *= _a
        if a > b:
            print(-1)
            return

    print(a)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
1000000000 1000000000"""
        output = """1000000000000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
101 9901 999999000001"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0"""
        output = """0"""
        self.assertIO(input, output)


Measured memory_bytes: 86692
#include <iostream>
#include <string>
#include <vector>
#include <utility> 
#include <tuple>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;


int main() {
int a,b,c,d;
cin>>a>>b>>c>>d;
int s=a+b+c+d;
cin>>a>>b>>c>>d;
int t=a+b+c+d;

if(s>t) cout<<s<<endl;
else cout<<t<<endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;


#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
//#pragma GCC optimize("Ofast")

const int mod = 1e9 + 7;

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, a[SIZE];
vector<int> v;
string s;


void solve()
{
    cin >> n;

    int k = n / 1000;

    if(n % 1000 != 0) k++;

    k *= 1000;
    cout << k - n;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    filein; fileout;

//    cin >> T;

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




    return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[] b = new int[n];
			for(int i=0;i<n;i++) b[i] = sc.nextInt();
			char[] a = sc.next().toCharArray();
			
			int j = 0;
			for(int i=0;i<a.length;i++){
				int p = 0;
				if(97<=(int)a[i] && (int)a[i]<=122) p = (int)a[i]-96;
				else p = (int)a[i]-38;
				p -= b[j];
				if(p<=0) p+=52;
				if(1<=p && p<=26) System.out.print((char)(p+96));
				else System.out.print((char)(p+38));
				j++;
				if(j==n) j=0;
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 24352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s[n];
  int t[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  string a;
  cin >> a;
  long long ans = 0;
  bool seen = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == a) {
      seen = 1;
      continue;
    }
    if (seen) {
      ans += t[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().rstrip().split())

m = [list(map(int, input().rstrip().split())) for _ in range(10)]

def dfs(i, v):
    if i == 1:
        return v
        
    min_v = int(1e9)
    for j in range(10):
        if f[j] == False:
            f[j] = True
            min_v = min(min_v, v + dfs(j, m[i][j]))
            f[j] = False
            
    return min_v
    
min_vs = [-1] * 10
for i in range(10):
    f = [False] * 10
    f[i] = True
    min_vs[i] = dfs(i, 0)
min_vs += [0]
    
v = 0
for _ in range(H):
    v += sum(list(map(lambda x: min_vs[int(x)], input().rstrip().split()))) 
print(v)

Measured memory_bytes: 51292
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int a[150],i,j,n;
void output()
{
	for(j=1;j<=n;j++)
	{
		printf("%d",a[j]);
		if(j!=n)
			printf(" ");
	}
}
void sort()
{
	int v;
	for(i=2;i<=n;i++)
	{
		v=a[i];
		j=i-1;
		while(j>=1 && a[j]>v)
		{
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		output();
		printf("\n");
	}
	return;
}
int main()
{
	scanf("%d",&n);
	//我喜欢从1开始计数，就把a[0]给废掉了
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		printf("%d",a[i]);
		if(i!=n)
			printf(" ");
	}
	printf("\n");
	sort();
	return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    string ans="";
    while(n!=0){
        int r=n%2;
        if(r<0) r+=2;
        ans+=char(r+'0');
        n=(n-r)/(-2);
    }
    
    reverse(all(ans));
    if(ans=="") ans="0";
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
var i : longint;
    n,ans:int64;

begin
  read(n);
  ans := 0;
  for i := 1 to 999999 do begin
    if n mod i = 0 then
      if n div i - 1 > i then ans := ans + n div i - 1
  end;
  writeln(ans);
end.

Measured memory_bytes: 256
W,H,x,y,r = map(int,input().split())


x2 = x+r
y2 = y+r
x1 = x-r
y1 = y-r

if W >= x2 and H >=y2 and x1 >=0 and y1 >=0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,X,b[100010],c[100010],d[100010],p[100010];
long long suml[100010],sumr[100010];
bool cmp(int x,int y)
{
	return 1ll*(X-b[x])*d[x]-1ll*b[y]*c[y]>1ll*(X-b[y])*d[y]-1ll*b[x]*c[x];
}
bool check(long long x)
{
	if(x/X>=n)return 1;
	long long w=0xc0c0c0c0c0c0c0c0ll,s;
	int pp=x/X,xx=x%X;
	for(int i=1;i<=n;++i)
	{
		s=xx>=b[p[i]]?1ll*(xx-b[p[i]])*d[p[i]]:1ll*(xx-b[p[i]])*c[p[i]];
		if(i<=pp)s+=sumr[pp+2]+suml[pp+1]-1ll*(X-b[p[i]])*d[p[i]];
		else s+=suml[pp]+sumr[pp+1]+1ll*b[p[i]]*c[p[i]];
		w=max(w,s);
	}
//	printf("%lld %d\n",x,w);
	return w>=0;
}
int main()
{
	scanf("%d %d",&n,&X);
	for(int i=1;i<=n;++i)
		scanf("%d %d %d",&b[i],&c[i],&d[i]),p[i]=i;
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=n;++i)suml[i]=suml[i-1]+1ll*(X-b[p[i]])*d[p[i]];
	for(int i=n;i;--i)sumr[i]=sumr[i+1]-1ll*b[p[i]]*c[p[i]]; 
	long long l=0,r=10000000010ll,mid,ans;
	while(l<=r)
	{
		mid=l+r>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>
#include <math.h>


using namespace std;
typedef long long ll;

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


int main() {
	int n;
	cin >> n;
	int y = 0;
	while (y < n) {
		y += 1000;
	}

	int ans;
	ans = y - n;
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int main(){
	int N, A, B, uds = 0, cnt = 0;
	cin >> N;
	cin >> A;
	for (int i = 1;i < N;i++) {
		cin >> B;
		if (A < B) {
			if (uds == 0) {
				cnt++;uds = 1;
			}
			if (uds == -1) {
				uds = 0;
			}
		}
		if (A > B) {
			if (uds == 0) {
				cnt++;uds = -1;
			}
			else if (uds == 1) {
				uds = 0;
			}
		}
		swap(A, B);
	}
	if (uds == 0)cnt++;
	cout << cnt << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<long long> sum(N + 1, 0);
    for (int i = 1; i <= N; i++) sum[i] = sum[i - 1] + a[i - 1];

    long long ans = (1LL<<32);
    for (int i = 1; i < N; i++) {
        long long x = sum[i];
        long long y = sum[N] - x;
        ans = min(ans, abs(x - y));
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    H, N, P, M, K = map(int, readline().split())
    A = [0]*H
    for i in range(M):
        a, b = map(int, readline().split())
        A[a-1] = b

    S = [[0]*N for i in range(K+1)]
    S[0][P-1] = 1
    T = [[0]*N for i in range(K+1)]
    for i in range(H-1, -1, -1):
        b = A[i]
        for j in range(K+1):
            T[j][:] = S[j][:]
        if b > 0:
            for Si in S:
                Si[b-1], Si[b] = Si[b], Si[b-1]
        else:
            for k in range(K):
                v = (K-k) / (H-M-k)
                for j in range(1, N-1):
                    S[k+1][j] += (T[k][j-1] + T[k][j] * (N-3) + T[k][j+1]) / (N-1) * v
                S[k+1][0] += (T[k][0] * (N-2) + T[k][1]) / (N-1) * v
                S[k+1][N-1] += (T[k][N-1] * (N-2) + T[k][N-2]) / (N-1) * v
    write("%.016f\n" % max(S[K]))
solve()


Measured memory_bytes: 6060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int solve(vi &a, int n)
{
	int dp[n + 1] ={0}; 

	dp[0] = 0;
	dp[1] = 0;
	int op1, op2;
	for(int i=2; i<=n; ++i)
	{
		op1 = op2 = inf;
		op1 = abs(a[i] - a[i - 1]) + dp[i - 1];

		if(i > 2)
		op2 = abs(a[i] - a[i - 2]) + dp[i - 2];

		dp[i] = min(op1, op2);
	}
	return dp[n];
}
int32_t main()
{
	FIO;
	int n; cin >> n;

	vi a(n + 1);
	for(int i=1; i<=n; ++i)
		cin >> a[i];

	cout << solve(a, n) << '\n';
	return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
			++a[i];
	}
	bool v=1;
	for(int i=1;i<n;i++)
		if(a[i]<a[i-1])v=0;
	if(v)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
class Tree:
    class Node:
        def __init__(self, n, left, right):
            self.left = left
            self.right = right
            self.n = n
            if left is not None:
                lt = {t + n for t in left.totals}
            else:
                lt = set()
            if right is not None:
                rt = right.totals
            else:
                rt = set()

            self.totals = lt | rt | {n}

        def find(self, total):
            return total in self.totals

        def __str__(self):
            cs = []
            if self.left is not None:
                cs.append(str(self.left))
            if self.right is not None:
                cs.append(str(self.right))

            return "{} -> ({})".format(self.n, ",".join(cs))


    def __init__(self, ns):
        self.top = self.build_nodes(sorted(ns))

    def has_subset(self, total):
        return self.top.find(total)

    def build_nodes(self, ns):
        if len(ns) == 0:
            return None

        left = self.build_nodes(ns[:-1])
        right = self.build_nodes(ns[:-1])
        node = self.Node(ns[-1], left, right)

        return node


def run_tree():
    _ = int(input())  # flake8: noqa
    ns = [int(i) for i in input().split()]

    tree = Tree(ns)
    _ = int(input())  # flake8: noqa

    for q in (int(j) for j in input().split()):
        if tree.has_subset(q):
            print("yes")
        else:
            print("no")



if __name__ == '__main__':
    run_tree()



Measured memory_bytes: 609240
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
int main(){
    int n;
    scanf("%d",&n);
    int ans=0;
    int a[100005];
    map<int,int> loc;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        loc[a[i]]=i;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(loc[a[i]]%2!=i%2){
            ans++;
        }
    }
    printf("%d\n",ans/2);
}

Measured memory_bytes: 5376
s = input()
k = int(input())
if k <= len(s) :
         for i in range(k):
                  if s[i] != "1":
                           print(s[i])
                           exit()
         print("1")
         exit()
for i in range(len(s)):
         if s[i] != "1":
                  print(s[i])
                  exit()
                  


Measured memory_bytes: 3060
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ll pre[N],pr[N];
void solve()
{
   ll n,x,m;
   cin>>n>>x>>m;
   pre[1]=x;
   ll sum=x;
   for(int i=2;i<=min(n,100001LL);i++)
   {
      pre[i]=(pre[i-1]*pre[i-1])%m;
      sum+=pre[i];

   }
   if(n<=100001)
   {
      ll ans=0;
      for(int i=1;i<=n;i++)
        ans+=pre[i];
      cout<<ans;
      return;
   }
   ll cnt=100001;
   for(int i=100000;i>=1;i--)
   {
       if(pre[i]==pre[100001])
       {
         cnt=i;
         break;
       }
   }
   ll op=100001-cnt;
   for(int i=cnt+1;i<=100001;i++)
    pr[i-cnt]=pre[i]+pr[i-1-cnt];
   ll ans=sum;
   ll rem=n-100001;
   ans+=(rem/op)*pr[op];
   ans+=pr[rem%op];
   cout<<ans;



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

Measured memory_bytes: 4788
package main

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

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

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

//u.p が存在しないとき、その接点はroot
//u.l が存在しないとき、その接点はleaf
//u.r が存在しないとき、その接点は最も右の子
type Node struct {
	p int
	l int //左の子
	r int //右の兄弟
}

// 再帰的に深さを求める
//rec(root, 0)から始める
func rec(u, p int) {
	if u == NIL {
		return
	}
	D[u] = p
	if T[u].r != NIL {
		rec(T[u].r, p+1) // 右の兄弟に同じ深さを設定
	}
	if T[u].l != NIL {
		rec(T[u].l, p+1) // 最も左の子に自分の深さ+1を設定
	}
}

//兄弟の番号を求める
func getSibling(u int) int {
	rt := NIL
	if T[u].p != NIL {
		if T[T[u].p].l != u && T[T[u].p].l != NIL {
			rt = T[T[u].p].l
		} else if T[T[u].p].r != u && T[T[u].p].r != NIL {
			rt = T[T[u].p].r
		}
	}
	return rt
}

//高さを求める
func setHeight(u int) int {
	h1 := 0
	h2 := 0
	if T[u].l != NIL {
		h1 = setHeight(T[u].l) + 1
	}
	if T[u].r != NIL {
		h2 = setHeight(T[u].r) + 1
	}
	H[u] = max(h1, h2)
	return max(h1, h2)

}

func max(a int, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func PrintNode(u int) {
	degree := 0
	if T[u].l != NIL {
		degree++
	}
	if T[u].r != NIL {
		degree++
	}
	fmt.Printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p, getSibling(u), degree, D[u], H[u])

	if T[u].p == NIL {
		fmt.Printf("root\n")
	} else if T[u].l == NIL && T[u].r == NIL {
		fmt.Printf("leaf\n")
	} else {
		fmt.Printf("internal node\n")
	}
}

const MAX_NODES_NUM = 200000
const NIL = -1

var T [MAX_NODES_NUM]Node
var D [MAX_NODES_NUM]int
var H [MAX_NODES_NUM]int

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	//初期化
	for i := 0; i < n; i++ {
		T[i].p, T[i].l, T[i].r = NIL, NIL, NIL
	}

	//parentの設定
	for i := 0; i < n; i++ {
		id, lc, rc := nextInt(), nextInt(), nextInt()
		if lc != NIL && T[lc].p == NIL {
			T[lc].p = id
		}
		if rc != NIL && T[rc].p == NIL {
			T[rc].p = id
		}
		T[id].l = lc
		T[id].r = rc

	}

	root := NIL
	for i := 0; i < n; i++ {
		if T[i].p == NIL {
			root = i
			break
		}
	}

	//深さを再起的に求める
	rec(root, 0)
	setHeight(root)

	for i := 0; i < n; i++ {
		PrintNode(i)
	}

}



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

int main() {
  int A, B; cin >> A >> B;
  for (int i = 1; i < 2000; i++) {
    if (i * 8 / 100 != A) continue;
    if (i * 10 / 100 != B) continue;
    cout << i << endl;
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	static int H;
	static int W;
	static char[][] in;
	static long[][] memo;
	static int UNCAL = -1;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter p = new PrintWriter(System.out);
		H = sc.nextInt();
		W = sc.nextInt();
		in = new char[H][W];
		for(int i = 0 ; i<H ;i++) {
			char[] x = sc.next().toCharArray();
			in[i] = x;
		}
		memo = new long[H][W+1];
		for(long[]a:memo)
			Arrays.fill(a,-1);
		System.out.println(dp(0,0));
		}
	public static long dp(int i , int j) {
		if(i==H-1 && j==W-1)
			return 1;
		if(i>=H || j>=W || in[i][j]=='#')
			return 0;
		if(memo[i][j]!=UNCAL)
			return memo[i][j];
		long right = dp(i+1,j);
		long down = dp(i,j+1);
		memo[i][j] = (right+down)%(1000000000+7);
		return memo[i][j];
	}
		
	}
	


Measured memory_bytes: 49600
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<string>s(2);
  for(int i=0;i<2;i++){
    cin>>s[i];
  }
  int64_t ans=0;
  bool pre=true;//trueなら縦1型
  for(int i=0;i<N;i++){
      if(s[0][i]==s[1][i]){
        if(i==0){ans=3;}
        else if(pre){ans*=2;}
        else{ans*=1;}
        pre=true;
      }
      else{
        if(i==0){ans=6;}
        else if(pre){ans*=2;}
        else{ans*=3;}
        pre=false;i++;
      }
      ans%=mod;
  }
  cout<<ans<<endl;
  return 0;  
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a) '\n'


int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	if (n == 1) { cout << "Yes"; return 0; }
	rep2(i,1, n -1) {
		if (h[i] > h[i - 1]) --h[i];
	}
	rep(i, n - 1) {
		if (h[i] > h[i + 1]) {
			cout << "No"; return 0;
		}
	}
	cout << "Yes";
}
	

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
    int n, k, x, y, sum=0;
    scanf("%d%d%d%d", &n, &k, &x, &y);
    if(n<=k)     sum=n*x;
    else
    {
        sum=k*x;
        sum+=(n-k)*y;
    }
    printf("%d\n", sum);

    return 0;
}


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

int main() {
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
	} else if (H % 2 == 0 || W % 2 == 0) {
		cout << H * W / 2 << endl;
	} else {
		cout << (H * W + 1) / 2 << endl;
	}
	return 0;
}


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

C,t = [], []

for i in range(N):
    CT = list(map(int,input().split()))
    C.append(CT[0])
    t.append(CT[1])

C_min = 10000
for i,t_i in enumerate(t):
    if t_i <= T and C_min >= C[i]:
        C_min = C[i]
        
if C_min == 10000:
    print('TLE')
else:
    print(C_min)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
    int r, c;
    cin >> r >> c;
    int btm[c+1];
    for(int i = 0; i < c+1; ++i) {
        btm[i] = 0;
    }
    for(int i = 0, s = 0; i < r; ++i, s = 0) {
        for(int j = 0, v; j < c; ++j) {
            cin >> v;
            cout << v << " ";
            s += v;
            btm[j] += v;
        }
        cout << s << endl;
        btm[c] += s;
    }
    for(int i = 0; i < c; ++i) {
        cout << btm[i] << " ";
    }
    cout << btm[c] << endl;
    return 0;
}


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

int main() {

    while(true) {

        int n;

        cin >> n;

        if(n==0) break;

        int a[n];

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

        sort(a, a+n);

        priority_queue<int> q;

        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                q.push(a[i] - a[j]);
            }
        }

        cout << -q.top() << endl;

    }

    return 0;
}

Measured memory_bytes: 6068
#!/usr/bin/env python3
# coding=utf-8

import sys

n = int(sys.stdin.readline().strip())
a = [list(map(int, l.strip().split(" "))) for l in sys.stdin.readlines()]

tmp = [[0 for _ in range(n)] for _ in range(2)]
for i in range(2):
    for j in range(n):
        if i == j == 0:
            tmp[i][j] = a[i][j]
        elif i == 0:
            tmp[i][j] = a[i][j] + tmp[i][j - 1]
        elif j == 0:
            tmp[i][j] = a[i][j] + tmp[i - 1][j]
        else:
            tmp[i][j] = a[i][j] + max(tmp[i - 1][j], tmp[i][j - 1])
print(tmp[1][n-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
int b[N];
int n;
map<pl, int> dp;
int go(ll x, ll y){
	if(abs(x-y)<=1) return -1;
	return 1;
	if(x<=1 and y <=1 ) return -1;	
	int lose = 1;
	ll i = 1;
	int &ans = dp[{x,y}];
	if(ans!=0) return ans; 
	while(2*i<=x){
		int res = go(x-2*i, y+i);
		if(res==-1){
			return ans = 1;
		}
		i++;
	}
	i = 1;
	while(2*i<=y){
		int res = go(y-2*i, x+i);
		if(res==-1){
			return ans = 1;
		}
		i++;
	}
	return ans = -1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,k,j;
	ll x , y;
	cin >> x >> y;
	int win = go(x, y);
	if(win==1) cout << "Alice\n";
	else cout << "Brown\n";
	
	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int m){
	int i, u, v;
	fo(i, m){
		cin>>u>>v; 
		u++, v++;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 7552
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }
const double PI = 3.14159265359;

double get_h(double x, double t, double theta_d) {
    double theta_r = PI*theta_d / 180;
    double h = t * tan(theta_r);
    return h;
}

double get_y(double x, double a, double b, double theta_d) {
    double h = get_h(x, a, theta_d);
    double t = x / (a*a) - h / 2.0;
    if (t >= 0)
        return h + t;
    return -1;
}

double get_y2(double x, double a, double b, double theta_d) {
    double theta_r = PI*theta_d / 180;
    double t = sqrt(2 * x / (a * tan(theta_r)));
    return t * tan(theta_r);
}

bool in_cond(double x, double a, double b, double theta_d) {
    double y = get_y(x, a, b, theta_d);
    if (y < 0) {
        y = get_y2(x, a, b, theta_d);
    }
    if (y <= b) return true;
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a, b, x;
    cin >> a >> b >> x;
    double L = 0.0, R = 89.9999999;
    rep(i, 100000) {
        double M = (L + R) / 2;
        if (in_cond(x, a, b, M) == true) {
            L = M;
        }
        else {
            R = M;
        }

    }
    printf("%20.15f\n", L);
    return 0;
}

Measured memory_bytes: 256
import numpy as np

X = int(input())

dp = np.zeros(X + 1)

if X >= 105:
    dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = 1
elif X >= 104:
    dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = 1
elif X >= 103:
    dp[100] = dp[101] = dp[102] = dp[103] = 1
elif X >= 102:
    dp[100] = dp[101] = dp[102] = 1
elif X >= 101:
    dp[100] = dp[101] = 1
elif X >= 100:
    dp[100] = 1


for i in range(106, X+1):
    if dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]:
        dp[i] = 1

print(int(dp[X]))

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

int main(void){

    int n;
    string s;
    cin >> n;
    cin >> s;
    bool precircle;
    bool ck=true;
    if(s[0]=='O') precircle=true;
    if(s[0]=='X') precircle=false;
    int c = 0;
    for(int i=1;i<n;i++){
        if((s[i]=='O' and precircle==false and ck) or (s[i]=='X' and precircle==true and ck)){
          c++;
          ck = false;
        } else{
            ck = true;
        }
        if(s[i]=='O') precircle=true;
        if(s[i]=='X') precircle=false;
    }
    cout << c << endl;
}



Measured memory_bytes: 3356
#include <cstdio>
using namespace std;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n][m];
    int v[m];

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

    for(int i = 0; i < m; ++i) scanf("%d", &v[i]);

    for(int i = 0; i < n; ++i){
        int val = 0;
        for(int j = 0; j < m; ++j) val += a[i][j] * v[j];
        printf("%d\n", val);
    }
    
    return 0;
}

Measured memory_bytes: 1068
#include<bits/stdc++.h>
using namespace std;
int a[400005];
int main()
{
	int n,ans=0,cnt=0,fa,ne;
	cin>>n>>fa;
	for(int i=1;i<n;i++)
	{
		cin>>ne;
		if(fa>=ne)cnt++;
		else cnt=0;
		if(cnt>ans)ans=cnt;
		fa=ne;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std; 
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int pp=0;int as=sqrt(i);
		for(int a=1;a<as;a++)
		{
			for(int b=1;b<as;b++)
			{
				double ji=(-1*(a+b)+sqrt(1.0*(a+b)*(a+b)-4.0*(a*a+b*b+a*b-i)))/2;
				double jii=(-1*(a+b)-sqrt(1.0*(a+b)*(a+b)-4.0*(a*a+b*b+a*b-i)))/2;
					 if(ji-(int)ji==0&&ji>0||jii-(int)jii==0&&jii>0)
					{
						pp++;
						//break;
					}	
			}
		}
		cout<<pp<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        int[] a = new int[4];
        for (int i = 0 ; i < c.length ; i++) {
            if (c[i] == 'N') {
                a[0]++;
            } else if (c[i] == 'W') {
                a[1]++;
            } else if (c[i] == 'S') {
                a[2]++;
            } else {
                a[3]++;
            }
        }

        if (a[0] == 0 && a[2] != 0) {
            System.out.println("No");
            return;
        }
        if (a[1] == 0 && a[3] != 0) {
            System.out.println("No");
            return;
        }
        if (a[2] == 0 && a[0] != 0) {
            System.out.println("No");
            return;
        }
        if (a[3] == 0 && a[1] != 0) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }

}

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

int main(void){
	int n,m;
	while(cin>>n>>m && (n||m)){
		int t[n],s[m];
		for(int i=0;i<n;i++) cin>>t[i];
		for(int i=0;i<m;i++) cin>>s[i];

		int ti = 0, si = 0, count = 1;
		for(;;count++){
			ti += s[si++];
			if(ti >= n-1) break;
			ti += t[ti];
			if(ti >= n-1) break;
		}

		cout<<count<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main() {
    int K, X,i,n;
    cin >> K >> X;
    for (i = K-1; i >0; i--) {
        cout << X - i<<" ";
    }
    cout << X <<" ";
    for (i = 1; i <= K - 1; i++) {
        cout << X + i<<" ";
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::{stdin, stdout, Read, Write};

fn main() {
    let mut buf = [b'\n'; 8];
    let stdin = stdin();
    let mut handle = stdin.lock();
    handle.read(&mut buf).unwrap();
    if (buf[0] == buf[6]) && (buf[1] == buf[5]) && (buf[2] == buf[4]) {
        stdout().write_all(b"YES").unwrap();
    } else {
        stdout().write_all(b"NO").unwrap();
    };
}


Measured memory_bytes: 2080
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

while True:
    M,F,R = map(int,input().split())
    if M == -1 and F == -1 and R == -1:
        break
    if M == -1 or F == -1:
        print("F")
    elif M+F >= 80:
        print("A")
    elif M+F >= 65:
        print("B")
    elif M+F >= 50:
        print("C")
    elif M+F >= 30:
        if R >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
 
int main(){
  ll N;
  cin >> N;
 
  int M = 1;
  ll sum = 0;
  ll p = 26;
  while(true){
    if(sum + 1 <= N && N <= sum + p){
      break;
    }
    M++;
    sum += p;
    p *= 26;
  }
  p /= 26;
  N--;
  N -= sum;

  vector<int> ret;
  rep(i,M){
    ll tmp = N/p;
    ret.push_back(tmp);
    N -= p * tmp;
    p /= 26;
  }
 
  string ans = "";
  rep(i,ret.size()){
    ans += (char)('a' + ret[i]);
  }
 
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#define SENTINEL 1000000000
int count=0;

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

int main(){
  int i,S[500000],n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const ll mod = 7 * 17 * (1 << 23) + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	ll ans = 0, x = 0;
	for(int i = 0; i+1 < s.size(); i++) {
		if(s[i]=='A')x++;
		else if(s[i]=='B'&&s[i+1]=='C') {
			ans += x;
			s[i+1]='A';
			i++;
		} else
			x= 0;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int N,K,arr[101000],minnum=1,ans=0;
int main(){
    scanf("%d %d",&N,&K);
    for(int i=1;i<=N;i++) scanf("%d",&arr[i]);
    sort(arr+1,arr+N);
    for(int i=1;i<N;i++){
        if(arr[i]==arr[i+1]) minnum++;
        else break;
    }
    if((N-minnum)%(K-1)!=0) ans=1;
    ans+=(N-minnum)/(K-1);
    printf("%d",ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  double H,W,N;
  cin >> H;
  cin >> W;
  cin >> N;
  
  double m = max(H,W);
  
  
  double answer = ceil(N/m);
  
  cout << answer <<endl;
  
}

Measured memory_bytes: 256