akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long double
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a;
    cin>>a;
    ll b;
    cin>>b;
    long long v=a*b;
    cout<<v;
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int32_t r, g, b;
	cin >> r >> g >> b;

	int32_t num = r * 100 + g * 10 + b;

	cout << (num % 4 == 0 ? "YES" : "NO") << endl;

	return 0;
}


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

int main() {
    int count = 0;
    string s,t;
    cin >> s >> t;
    for (int i = 0; i < 3; i++){
        if(s.at(i) == t.at(i)){
            count ++;
        }
    }
    cout << count << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(ll& a : A){
        cin >> a;
    }

    ll ans = 0;
    ll max = A[0];
    for(int i = 0; i < N; i++){
        ll d = max - A[i];
        if(d > 0) ans += d;
        if(max < A[i]) max = A[i];
    }

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

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

using namespace std;

#define fastio ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;

bool checkVowel(char c)
{
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
		return true;
	if(c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y')
		return true;
	return false;
}

char capital(char c)
{
	if(97 - int(c) > 0)
		return char(int(c) + 32);
	return c;
}

int main()
{
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout); 
	#endif	
	
	fastio;

	double d, t, s;
	cin >> d >> t >> s;

	if(d <= s * t)
		cout << "Yes";
	else
		cout << "No";

	return 0;

}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ED(x) ((int)x.size()-1)
#define _for(i,a,b) for(int i=(a);i<=(b);++i)
#define _rep(i,a,b) for(int i=(a);i>=(b);--i)
#define changxv ios::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int maxn=2e5+3;
const int INF=0x3f3f3f3f;

int w[maxn],xr[maxn];
ll s[maxn];

int main(){changxv
	int n;cin>>n;
	_for(i,1,n){
		cin>>w[i];
		s[i]=s[i-1]+w[i];
		xr[i]=xr[i-1]^w[i];
	}
	ll ans=0;
	for(int l=1,r=1;r<=n;++r){
		while(s[r]-s[l-1]!=(xr[r]^xr[l-1]))++l;
		ans+=r-l+1;
	}
	cout<<ans<<'\n';
return 0; }

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

int main(){
  int a,b,c;
  cin >> a >> b >>c;
  int x = a-b, y = c-x;
  if (y <= 0){
    cout << 0 << endl;
  }
  else{
	cout << y << endl;
  }

}



Measured memory_bytes: 256
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a

def reduce_gcd(x,y,z):
    return reduce(euclid,(x,y,z))

def main():
    from functools import reduce
    K=int(input())
    ans=0
    for a in range(1,K+1):
        for b in range(1,K+1):
            for c in range(1,K+1):
                ans+=reduce_gcd(a,b,c)
    print(ans)

main()

Measured memory_bytes: 73732
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n + 1, 1);
    vector<bool> red(n + 1, false);
    red[1] = true;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        v[x]--;
        v[y]++;
        if (red[x]) {
            red[y] = true;
            if (v[x] == 0)
                red[x] = false;
        }
    }
    int ans = accumulate(red.begin(), red.end(), 0LL);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    while(true){
    		
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		
		if(op.equals("?")){break;}
		if(op.equals("+")){System.out.println(a+b);}
		if(op.equals("-")){System.out.println(a-b);}
		if(op.equals("*")){System.out.println(a*b);}
		if(op.equals("/")){System.out.println(a/b);}
	}
    }
}


Measured memory_bytes: 26468
def waru(n):
  return int(n/2)

number = int(input())
line2 = input().split()
cnt = 0
cnt2 = 0
cnt3  =0
while cnt2 ==0:
  cnt = 0
  for i in range(len(line2)):
    line2[i] = int(line2[i])
    if int(line2[i])%2 ==0:
      cnt +=1
  if cnt == len(line2):
    line2 = list(map(waru,line2))
    
    cnt3 +=1
  else:
    cnt2 +=1
print(cnt3)



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int max = 0;
        int currentStreak = 0;
        int prev = Integer.MIN_VALUE;
        for(int i=0; i<n; i++) {
            int h = in.nextInt();
            if(h<=prev) {
                currentStreak++;
            }
            else {
                max = Math.max(max, currentStreak);
                currentStreak = 0;
            }
            prev = h;
        }
        max = Math.max(max, currentStreak);
        System.out.println(max);
    }
}


Measured memory_bytes: 50468
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int 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))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int r,g,b,n;
  cin >> r >> b >> g >> n;

  int ans = 0;
  REP(i,n+1){
    REP(j,n+1){
      int tmp = i*r + j*b;
      if(n-tmp < 0) continue;
      if((n-tmp)%g == 0) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;
#define MAX_N (100010)
int N;
ll A[MAX_N];

typedef pair<ll, int> P;

P B[MAX_N];

int main()
{


    scanf("%d", &N);
    for ( int i = 0; i < N; i++ ) {
	scanf("%lld", &A[i]);
	B[i].first = A[i];
	B[i].second = i;
    }
    
    sort( B, B+N );

    ll count = 0;
    for ( int i = 0; i < N; i++ ) {
	count += abs(i - B[i].second) % 2;
    }

    printf("%lld\n", (count >> 1 ));

    return 0;
}


Measured memory_bytes: 2560
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [H, A] = input[0].split(' ').map(x => parseInt(x))

  let count = 0
  let hp = H
  while (hp > 0) {
    hp -= A
    count++
  }

  console.log(count)
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29520
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Atcoder.Abc
{
    //https://atcoder.jp/contests/abc177/tasks/abc177_a
    public class Abc177_A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            WriteLine(a[0] > a[1] * a[2] ? "No" : "Yes");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17852
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
  int H,N;
  cin>>H>>N;
  vector <int> v1(N);
  int sum=0;
  for(int i=0 ; i<N ; i++){
    cin>>v1.at(i);
    sum+=v1.at(i);
  }if(H<=sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}




Measured memory_bytes: 640
from collections import deque

n = int(input())
preroots = []
for i in range(n-1):    
    preroots.append(list(map(int,input().split())))

roots = [[] for i in range(n+1)]

for i in range(n-1):
    roots[preroots[i][0]].append([preroots[i][1],preroots[i][2]])
    roots[preroots[i][1]].append([preroots[i][0],preroots[i][2]])



QK = list(map(int,input().split()))
dist  = [-1 for i in range(n+1)]
dist[QK[1]] = 0
query = []
for i in range(QK[0]):
    query.append(list(map(int,input().split())))

q = deque()
q.append(QK[1])

while(len(q)):
    curr = q.popleft()
    for i in roots[curr]:
        if dist[i[0]] != -1:continue
        dist[i[0]] = dist[curr] + i[1]
        q.append(i[0])
        
for i in query:
    print(dist[i[0]] + dist[i[1]])

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

void solve(long long H, long long W){
	long long res = H * W;

	for(int k = 0; k < 2; ++k) {
		for(long long i = 1; i < H; ++i) {
			long long a = (H - i) / 2, b = (H - i) - a;
			if(H - i > 1) {
				res = min(res, (max(b, i) - min(a, i)) * W);
			}
			//cerr << i << "," << res << endl;

			a = W / 2 * (H - i);
			b = W * (H - i) - a;
			long long c = i * W;
			res = min(res, max(b, c) - min(a, c));
			//cerr << res << endl;
		}
		swap(H,W);
	}

	cout << res << endl;
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&H);
	scanf("%lld",&W);
	solve(H, W);
	return 0;
}



Measured memory_bytes: 256
#82B two anagrams
s=list(input())
t=list(input())
length=len(s)
len2=len(t)
for j in range(length):
    for i in range(0,length-j-1):
        if s[i]>s[i+1]:
            temp=s[i+1]
            s[i+1]=s[i]
            s[i]=temp
for j in range(len2):
    for i in range(0,len2-j-1):
        if t[i]<t[i+1]:
            temp=t[i+1]
            t[i+1]=t[i]
            t[i]=temp     
sd="".join(s)
td="".join(t)
# print(sd,td)

if sd<td:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
    int n,i,x,Count=0;
    cin>>n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int j=0; j<n; j++)
    {
        if((j+1)%2==1)
        {
            if(a[j]%2==1)
            {
                Count++;
            }
        }
    }
    cout<<Count<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    
    auto f = [&](int n){
        int p=0;
        while(n){
            p+=n%10;
            n/=10;
        }
        return p;
    };
    
    int sum = 0;
    for(int i=1;i<=n;i++){
        int ret = f(i);
        if(a<=ret&&ret<=b)sum+=i;
    }
    cout<<sum<<endl;
}


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

int main(void){
    int a, b, c;
    
    cin>>a>>b>>c;
    
    int d=a%b;
    
    int sum=d;
    
    bool bb=false;
    if(d==c){
        bb=true;
    }else{
        for(int i=0; i<100; i++){
            sum+=d;
            if(sum>=b){
                sum=sum%b;
            }
            
            if(sum==c){
                bb=true;
                break;
            }
        }
    }
    
    if(bb){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,k
    integer(int64), allocatable:: a(:)
    integer(int64):: i

    read*, n,k
    allocate(a(n))
    read*, a(:)

    do i=k+1,n
        if (a(i) > a(i-k)) then
            print'(a)', 'Yes'
        else
            print'(a)', 'No'
        end if
    end do
end program main

Measured memory_bytes: 4656
import numpy as np
def getLine():
    return list(map(int, input().split()))
a = np.zeros((3,3))
r = np.full((3,3),False)
for i in range(3):
    a[i] = getLine()
n = int(input())
for i in range(n):
    b = int(input())
    r[np.where(a == b)] = bool(b in a)
for i in range(3):
    if (r[i][0] and r[i][1] and r[i][2]) or (r[0][i] and r[1][i] and r[2][i]):
        print('Yes')
        break
else:
    if (r[0][0] and r[1][1] and r[2][2]) or (r[0][2] and r[1][1] and r[2][0]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 12492
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, ans;
  cin >> A >> B;
  ans=A+B;
  if (ans<10) {
    cout << ans << endl;
  }
  else {
    cout << "error" << endl;
  }
}


Measured memory_bytes: 3628
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef array<int,3> A;
// gcd
LL gcd(LL a, LL b) {
	while(b){
		auto t=a%b;
		a=b;
		b=t;
	}
	return a;
}
const LL M=998244353;
LL C[201][201];
LL ps[201];
LL f(int i){
	if(i<3){
		return 0;
	}
	return (ps[i]-C[i][0]-C[i][1]-C[i][2]+3*M)%M;
}
P in[201];
int main() {
	for(int i=0;i<201;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=C[i-1][j-1]+C[i-1][j];
			C[i][j]%=M;
		}
	}
	ps[0]=1;
	for(int i=1;i<201;i++){
		ps[i]=ps[i-1]*2%M;
	}
	
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		in[i]=P(a,b);
	}
	map<A,vector<int> > ls;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			int x=in[j].first-in[i].first;
			int y=in[j].second-in[i].second;
			int g=gcd(x,y);
			x/=g;
			y/=g;
			if(x<0){
				x=-x;
				y=-y;
			}
			int v=in[i].first*y-in[i].second*x;
			A k={{x,y,v}};
			ls[k].push_back(i);
			ls[k].push_back(j);
		}
	}
	LL ret=f(N);
	for(auto t:ls){
		auto& v=t.second;
		sort(v.begin(),v.end());
		auto s=unique(v.begin(),v.end())-v.begin();
		ret+=M-f(s);
		ret%=M;
	}
	printf("%lld\n",ret);




	return 0;
}



Measured memory_bytes: 2688
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 10000;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 4 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	if (X >= 10000) {
		if (X >= 100000) {
			memcpy(di, f.C + X / 10000 * 4 + 2, 2);
			memcpy(di + 2, f.C + X % 10000 * 4, 4);
			di += 6;
		}
		else {
			memcpy(di, f.C + X / 10000 * 4 + 3, 1);
			memcpy(di + 1, f.C + X % 10000 * 4, 4);
			di += 5;
		}
	}
	else {
		if (X >= 1000) memcpy(di, f.C + X * 4, 4), di += 4;
		else if (X >= 100) memcpy(di, f.C + X * 4 + 1, 3), di += 3;
		else if (X >= 10) memcpy(di, f.C + X * 4 + 2, 2), di += 2;
		else memcpy(di, f.C + X * 4 + 3, 1), di += 1;
	}
	*di++ = '\n';
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 14908
#include <stdio.h>

int main(void)
{
	int x[10000], i;

	for (i = 0; i < 10000; i++){
		scanf("%d", &x[i]);
		if (x[i] == 0){
			break;
		}
	}

	for (i = 0; i < 10000; i++){
		if (x[i] != 0){
			printf("Case %d: %d\n", i + 1, x[i]);
		}
		else{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 636
h, w = map(int, input().split())

img = []
for i in range(h):
   img.append(input())

for i in range(w+2):
   print('#', end='')
print()

for i in range(h):
   print('#', end='')
   print(img[i], end='')
   print('#')

for i in range(w+2):
   print('#', end='')
print()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main(){
  char s[11];
  int ans = 0;
  int tmp = 0;

  scanf("%s", s);

  for(int cnt = 0; cnt < strlen(s); cnt++){
    if(s[cnt] == 'A' || s[cnt] == 'C' || s[cnt] == 'G' || s[cnt] == 'T'){
      ans++;      
      //      printf("%c", s[cnt]);
    }else{
      if(ans > 0){
	tmp = ans;
	ans = 0;
      }
    }
  }

  if(tmp >= ans){
    printf("%d", tmp);
  }else if(tmp < ans){
    printf("%d", ans);
  }
  printf("\n");


}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String[] args) throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());
        String s = reader.readLine();
        String[] inp = s.split(" ");

        int[] arr = new int[n-1];

        for (int i = 0; i < inp.length; i++) {
            arr[i]=Integer.parseInt(inp[i]);
        }

        int[] countarr = new int[n];

        for (int i = 0; i < arr.length; i++) {
            //System.out.print(i+" ");
            int val = arr[i]-1  ;
            //System.out.println(val);
            countarr[val]++;
        }

        for (int i = 0; i <countarr.length ; i++) {
            System.out.println(countarr[i]);
        }

    }
}


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


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

    // all the code goes here
    int n;cin>>n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin>>a[i];
    
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);

    for(int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }

    cout<<dp[n-1]<<"\n";

    return 0;
}

Measured memory_bytes: 1024
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
a=1
if n>2:
 a*=n-2
if m>2:
 a*=m-2
if n==2 or m==2:
  a=0
print(a)

Measured memory_bytes: 38480
from collections import deque
K=int(input())
res = 0
deq = deque(['1','2','3','4','5','6','7','8','9'])
for i in range(K):
    now = deq.popleft()
    if i==K-1:
       res = int(now)
       break

    if now[-1] != '0':
        tmp = str(int(now[-1])-1)
        deq.append(now+tmp)
    tmp = now + now[-1]
    deq.append(tmp)
    if now[-1] != '9':
        tmp = str(int(now[-1])+1)
        deq.append(now+tmp)

print(res)

Measured memory_bytes: 17012
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define int long long int

signed main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<int> a;
	std::vector<int> b;
	std::vector<int> c;
	
	for (int j=0; j<n; j++)
	{
		int aj,bj,cj;
		std::cin>>aj>>bj>>cj;
		a.push_back(aj);
		b.push_back(bj);
		c.push_back(cj);
	}
	std::vector<int> dpa;
	std::vector<int> dpb;
	std::vector<int> dpc;
	
	dpa.push_back(a[0]);
	dpb.push_back(b[0]);
	dpc.push_back(c[0]);
	for (int j=1; j<n; j++)
	{
		dpa.push_back(a[j]+std::max(dpb[j-1],dpc[j-1]));
		dpb.push_back(b[j]+std::max(dpa[j-1],dpc[j-1]));
		dpc.push_back(c[j]+std::max(dpa[j-1],dpb[j-1]));
	}
	std::cout<<std::max(std::max(dpa[n-1],dpb[n-1]),dpc[n-1]);
	return 0;
}

Measured memory_bytes: 5728
A, B, H, M = map(int, input().split())

import math

H_angle =(M * math.pi) / 30
M_angle = (60 * H + M) * math.pi / 360

H_x, H_y = (A * math.cos(H_angle), A * math.sin(H_angle))
M_x, M_y = (B * math.cos(M_angle), B * math.sin(M_angle))

d = math.sqrt((H_x - M_x) ** 2 + (H_y - M_y) ** 2)
print(d)

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

int main(void)
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    ll r=0, g=0, b=0;
    for(int i=0;i<N;i++){
        if(S[i] == 'R') r++;
        if(S[i] == 'G') g++;
        if(S[i] == 'B') b++;
    }
    ll total = r*g*b;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int k = j + j - i;
            if(k >= N ) continue;
            if(S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]) total--;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char m[55][55];
bool used[55][55];
int w,h;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
char c,c_;
bool f;

int solve(int x,int y){
  int ret = 1;
  used[x][y] = false;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(m[nx][ny] == c){
      f = true;
    }
    if(m[nx][ny] == c_){
      ret -= 10000;
    }
    if(m[nx][ny] == '.' && used[nx][ny]){
      ret += solve(nx,ny);
    }
  }
  return ret;
}

int main(void){
  while(1){
    scanf("%d%d",&w,&h);
    if(!w && !h) break;
    memset(m,0,sizeof(m));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	scanf(" %c",&m[i][j]);
      }
    }
    for(int k = 0; k < 2; k++){
      int ans = 0;
      memset(used,true,sizeof(used));
      c_ = (k)?'B':'W';
      c = (!k)?'B':'W';
      for(int i = 1; i <= h; i++){
	for(int j = 1; j <= w; j++){
	  if(m[i][j] == '.' && used[i][j]){
	    f = false;
	    int ret = max(0,solve(i,j));
	    if(f){
	      //printf("%d:%d %d\n",i,j,ret);
	      ans += ret;
	    }
	  }
	}
      }
      printf("%d%c",ans,(k)?'\n':' ');
    }
  }
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, L;
vector <int> a, b;

ll get_sum(vector <ll> &s, int l, int r){
    if(r < l || l < 0 || r >= n) return 0;
    return s[r] - (l == 0 ? 0 : s[l - 1]);
}
ll calc(){
    vector <ll> sum_a(n), sum_b(n);
    sum_a[0] = a[0];
    sum_b[0] = b[0];
    for(int i = 1 ; i < n ; i++){
        sum_a[i] = sum_a[i - 1] + a[i];
        sum_b[i] = sum_b[i - 1] + b[i];
    }
    ll ret = 0;
    for(int i = 0 ; i < n ; i++){
        int len = min(i + 1, n - i - 1);
        if(i + 1 < n){
            ret = max(ret, 2 * (get_sum(sum_a, i - len + 1, i) + get_sum(sum_b, i + 1, i + len)) - min(a[i], b[i + 1]));
        }
        len = min(i, n - i - 1);
        ret = max(ret, 2 * (get_sum(sum_a, i - len, i - 1) + get_sum(sum_b, i + 1, i + len)) + max(a[i], b[i]));
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> L >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    b.resize(n);
    for(int i = 0 ; i < n ; i++){
        b[i] = L - a[i];
    }
    ll ans = calc();
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    swap(a, b);
    ans = max(ans, calc());
    cout << ans << endl;
}


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

typedef long long int ll;

int main()
{
    ll n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool ans = true;

    if(c < d){
        bool f = false;
        for(ll i = a - 1;i <= d - 2;i++){
            if(s[i] == s[i + 1] && s[i] == '#'){
                ans = false;
            }
        }
    }
    else{
        bool f = false;
        for(ll i = b - 1;i <= d - 1;i++){
            if(s[i - 1] == s[i] && s[i] == s[i + 1] && s[i] == '.'){
                f = true;
                break;
            }
        }
        if(f){
            for(ll i = a - 1;i <= c - 2;i++){
                if(s[i] == s[i + 1] && s[i] == '#'){
                    ans = false;
                }
            }
        }
        else{
            ans = false;
        }
    }

    if(ans){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 640
N,S,j;
long d[3001];
main(A)
{
	scanf("%d%d",&N,&S);
	for(;~scanf("%d",&A);N--)
	{
		d[0]++;
		for(j=S-A;j>=0;d[j--+A]%=998244353)d[j+A]+=d[j]*(j+A<S?:N);
	}
	printf("%d",d[S]);
}

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

int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    cin>>arr[i];
    int dp[n];
    for(int i=0; i<n; i++)
    dp[i]=0;
    if(n==1)
    cout<<arr[0];
    else
    if(n==2)
    {
        int x=abs(arr[1]-arr[0]);
        
        cout<<x;
    }
    else
    {
    dp[0]=0;
    int x=abs(arr[1]-arr[0]);
        
       
    dp[1]=x;
    for(int i=2; i<n; i++)
    {
   
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
   
    cout<<dp[n-1];
    }
	// your code goes here
	return 0;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[200005];
void solve(){
    cin>>n;
    rep(i,2,n+1){
        int x;
        cin>>x;
        a[x]++;
    }
    rep(i,1,n+1) cout<<a[i]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4356
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int A[200000];
queue<int> que[200001];

ll op_num[200000]; // the num of op's when A[i] is the front
ll next_front[200000];

int exist[200001];
ll ans[200000];

int main(){
    int N;
    ll K;
    
    cin >> N >> K;
    
    
    ll turns = N*K;
    
    for(int i=0; i<N; i++){
        cin >> A[i];
        que[A[i]].push(i);
    }
    
    
    
    for(int i=0; i<N; i++){
        que[A[i]].pop();
        que[A[i]].push(i);

        int last=que[A[i]].front();
        next_front[i]=(last+1)%N;

        if(last==i){
            op_num[i] = N+1;
        }else if(i < last){
            op_num[i] = last-i+1;
        }else if(last < i){
            op_num[i] = N+last-i+1;
        }
    }

    ll one_cycle=op_num[0];
    for(int temp=next_front[0]; temp!=0; temp=next_front[temp]){
        one_cycle+=op_num[temp];
    }

    turns%=one_cycle;



    int temp=0;
    while(turns>=op_num[temp]){
        turns-=op_num[temp];
        temp = next_front[temp];
    }
    
    

    for(int i=0; i<200001; i++){
        exist[i]=-1;
    }
    int idx=0;
    for(int i=0; i<turns; i++){
        int x=A[(i+temp)%N];

        if(exist[x]==-1){
            exist[x]=idx;
            ans[idx]=x;
            idx++;
        }else{
            while(1){
                idx--;
                exist[ans[idx]]=-1;
                if(ans[idx]==x){
                    break;
                }
            }

        }
        
        
    }

    for(int i=0; i<idx; i++){
        cout<<ans[i];
        if(i!=idx-1){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, k;
	cin >> a >> b >> k;
	
	vector<int> ok;
	FOR(i, 1, 101) {
		if (a % i == 0 and b % i == 0) ok.push_back(i);
	}
	
	reverse(ALL(ok));
	
	cout << ok[k - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	if ((A <= C && C <= B) || (A >= C && B <= C)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
ar=[gets.to_i]
ar.push gets.to_i
ar.push gets.to_i
ar.push gets.to_i
ar.push gets.to_i
k = gets.to_i

ar.minmax().each_cons(2){|e|
    if e[1] - e[0] <= k then
        puts "Yay!";
      else
        puts ":(";
      end
}


Measured memory_bytes: 1788
#include "iostream"
#include "math.h"


int main()
{
	double n, ave = 0, sum = 0, dev = 0, score[1000];
	while (true) {
		std::cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			std::cin >> score[i];
			sum += score[i];
		}
		ave = sum / n;
		for (int i = 0; i < n; i++)
			dev += pow(score[i] - ave, 2);
		dev /= n;
		dev = sqrt(dev);
		std::cout << std::fixed << dev << std::endl;
		ave = 0;
		sum = 0;
		dev = 0;
	}
    return 0;
}

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

using namespace std;

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

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  LL N;
  cin >> N;
  string a = "abcdefghijklmnopqrstuvwxyz";
  string ans = "";
  while(N > 0) {
    N--;
    ans += a[N % 26];
    N /= 26;
  }
  for (int i = ans.size() - 1; i >= 0; i--) {
    cout << ans[i];
  }

  return 0;
}


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

using namespace std;

int n,q,k,a,b,c,x,y;
typedef struct{int to;int cost;}edge;
edge e;

long long depth[100000];
vector<edge>g[100000];

void dfs(int current_v,int parent,long long cost){
    depth[current_v]=cost;
    for(auto x:g[current_v])if(x.to!=parent)dfs(x.to,current_v,cost+x.cost);//(木の子孫は全て未訪問)
    return;
}

int main(){
    cin>>n;
    for(int i=1;i<n;i++){cin>>a>>b>>c;g[a-1].push_back(edge{b-1,c});g[b-1].push_back(edge{a-1,c});}
    cin>>q>>k;
    dfs(--k,-1,0LL);
    for(int i=0;i<q;i++){
        cin>>x>>y;
        cout<<depth[x-1]+depth[y-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12800
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cstring>
#include <queue>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? n==1 ? x: b_pow(x,n>>1)*b_pow(x,(n>>1)+(n&1)) : 1;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

//long longÉ«ðÂ¯Ä

int N,K;
double T,U,V,L;
vector<int> D;


int main(){
	cin >> N >> K >> T >> U >> V >> L;
	rep(i,N){
		int t; cin >> t;
		D.push_back(t);
	}
	D.push_back(L);
	double R = 0;
	int C = 0;
	double time = 0;
	int cur = 0;
	for(int i = 0 ; i < N+1 ; i++){
		double Di = (D[i]-cur);
		while(Di > EPS){
			double use = min(Di / V , R);
			time += use;
			R -= use;
			Di -= use * V;
			if(R < EPS && C) C -= 1  , R = T;
			else{
				time += (Di / U);
				break;
			}
		}
		if(C==K) R=T , C-=1;
		C += 1;
		cur = D[i];
	}
	printf("%.7f\n",time);
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
#define BIG(c) (c)-0x20
#define SMALL(c) (c)+0x20
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      DOUBLECHANGE(18);
      int N, K;
      cin >> N >> K;
      double ans = 0;
      for(int i = 0;i < N;i++){
          int win_count = 0;
          for(int point = i+1;point < K;win_count++){
              point *= 2;
          }
          ans += 1.0/pow(2,win_count);
      }
      cout << ans/N << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1e6 + 10;
int n;
int p[N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i + 1 < n; ++i) {
		ans += min(p[i - 1], p[i + 1]) < p[i] && p[i] < max(p[i - 1], p[i + 1]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
def main():
    n=int(input())
    a=list(map(int, input().split()))
    m,s=1000,0
    for i in range(n-1):
        if a[i] > a[i+1]:
            m += s*a[i]
            s = 0
        elif a[i] < a[i+1]:
            b = m//a[i]
            m -= b*a[i]
            s += b
    m += s*a[-1]
    print(m)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
n,k = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    now = A[i] + A[i-1]
    if now >k:
        ans += min(A[i],now-k)
        A[i] -= min(A[i],now-k)
        now = A[i] + A[i-1]
        if now >k:
            ans += min(A[i-1],now-k)
            A[i-1] -= min(A[i-1],now-k)

print(ans)

Measured memory_bytes: 14068
import sys
input = sys.stdin.readline

n = int(input())
a_list = list(map(int, input().split()))
a_half = sum(a_list) / 2

for i in range(n):
  a_half -= a_list[i]
  if a_half <= 0:
    #print(a_half, a_half+a_list[i])
    row_answer = a_half
    high_answer = a_half+a_list[i]
    break

print(int(min(-1 * row_answer, high_answer) * 2))

Measured memory_bytes: 26392
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Mame = Tuple!(long, "point", long, "number");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    if (s == "Sunny")
        writeln("Cloudy");
    if (s == "Cloudy")
        writeln("Rainy");
    if (s == "Rainy")
        writeln("Sunny");
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	 static char[][] S;
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        S = new char[H][W];
        
        
        for(int i=0;i<H;i++){
        	String s=sc.next();
        	S[i] = s.toCharArray();
        }
        
        int max=0;
        for(int i=0;i<H*W;i++) {
        	max=Math.max(max, kaisi(i,H,W));
        }
//        max=Math.max(max, kaisi(0,H,W));
//        max=Math.max(max, kaisi(W-1,H,W));
//        max=Math.max(max, kaisi((H-1)*W,H,W));
//        max=Math.max(max, kaisi((H-1)*W+W-1,H,W));
                               
        System.out.println(max);        	
                		
    }
    
    public static int kaisi(int k,int H,int W) {
        int max = 0;
        
        boolean[][] visited = new boolean[H][W];
        LinkedList<Integer> queue = new LinkedList<Integer>();
        
        int kh=k/W;
        int kw=k%W;
        if(S[kh][kw]=='#')return -1;
        visited[kh][kw]=true;
        queue.add(k);
        queue.add(0);
        while(!queue.isEmpty()) {
        	int now = queue.poll();
        	int d = queue.poll();
        	max=Math.max(max, d);
        	int nowh=now/W;
        	int noww=now%W;
        	if(kensa(nowh,noww+1,H,W,visited)==1) {
        		queue.add(nowh*W+noww+1);
        		queue.add(d+1);
        		visited[nowh][noww+1]=true;
        	}
        	if(kensa(nowh,noww-1,H,W,visited)==1) {
        		queue.add(nowh*W+noww-1);
        		queue.add(d+1);
        		visited[nowh][noww-1]=true;
        	}
        	if(kensa(nowh+1,noww,H,W,visited)==1) {
        		queue.add((nowh+1)*W+noww);
        		queue.add(d+1);
        		visited[nowh+1][noww]=true;
        	}
        	if(kensa(nowh-1,noww,H,W,visited)==1) {
        		queue.add((nowh-1)*W+noww);
        		queue.add(d+1);
        		visited[nowh-1][noww]=true;
        	}
        }
        return max;
    }
    
    public static int kensa(int nowh,int noww,int H,int W,boolean[][] v) {
    	if(nowh<0||nowh>=H||noww<0||noww>=W) {
    		return -1;
    	}
    	if(v[nowh][noww]==true||S[nowh][noww]=='#') {
    		return -1;
    	}
    	
    	return 1;
    }
    
}

Measured memory_bytes: 34088
n,k=map(int,input().split())
l=list(map(int,input().split()))
from itertools import accumulate
def update(a):
    ret=[0]*len(a)
    for i,x in enumerate(a):
        ret[max(i-x,0)]+=1
        r=min(n-1,i+x)
        if r==n-1:continue
        ret[r+1]-=1
    return list(accumulate(ret))
for i in range(min(50,k)):
    l=update(l)
print(*l)

Measured memory_bytes: 183152
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <sstream>
#include <string>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

template<class T, class U>
T lexical_cast(const U& from) {
  stringstream ss;
  ss << from;
  T to;
  ss >> to;
  return to;
}

pair<int, int> parse(const string &s) {
  // DEBUG(s);
  int st = 0;
  st += lexical_cast<int>(s.substr(0, 2)) * 60;
  st += lexical_cast<int>(s.substr(3, 2));

  int en = 0;
  en += lexical_cast<int>(s.substr(6, 2)) * 60;
  en += lexical_cast<int>(s.substr(9, 2));
  return make_pair(st, en);
}

int main() {
  int K; cin >> K;
  vector<pair<int, int>> A;
  for(int i = 0; i < K; ++i) {
    string s; cin >> s;
    A.push_back(parse(s));
  }
  int N; cin >> N;
  vector<vector<pair<int, int>>> B(N);
  for(int i = 0; i < N; ++i) {
    int k; cin >> k;
    for(int j = 0; j < k; ++j) {
      string s; cin >> s;
      B[i].push_back(parse(s));
    }
  }
  int M; cin >> M;
  vector<vector<pair<int, int>>> C(M);
  for(int i = 0; i < M; ++i) {
    int k; cin >> k;
    for(int j = 0; j < k; ++j) {
      string s; cin >> s;
      C[i].push_back(parse(s));
    }
  }
  int ans = 0;
  for(int i = 0; i < K; ++i) {
    int t = 0;
    for(int j = 0; j < N; ++j) {
      bool ok = false;
      for(auto item : B[j]) {
        if(item.first <= A[i].first && A[i].second <= item.second) ok = true;
      }
      if(ok) ++t;
    }
    int s = 0;
    for(int j = 0; j < M; ++j) {
      bool ok = false;
      for(auto item : C[j]) {
        if(item.first <= A[i].first && A[i].second <= item.second) ok = true;
      }
      if(ok) ++s;
    }
    ans += min(t, s);
  }
  cout << ans << endl;
}

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

ans = H * W
for i in range(1, H):
    maxt = W * i
    tmp1 = (H - i) * (W // 2)
    tmp2 = (H - i) * (W - (W // 2))
    ans = min(ans, (max(maxt, tmp1, tmp2) - min(maxt, tmp1, tmp2)))

    tmp3 = W * ((H - i) // 2)
    tmp4 = W * (((H - i) - ((H - i) // 2)))
    ans = min(ans, (max(maxt, tmp3, tmp4) - min(maxt, tmp3, tmp4)))

for i in range(1, W):
    maxt = H * i
    tmp1 = H * ((W - i) // 2)
    tmp2 = H * ((W - i) - ((W - i) // 2))
    ans = min(ans, (max(maxt, tmp1, tmp2) - min(maxt, tmp1, tmp2)))
    tmp3 = (W - i) * (H // 2)
    tmp4 = (W - i) * (H - (H // 2))
    ans = min(ans, (max(maxt, tmp3, tmp4) - min(maxt, tmp3, tmp4)))



print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
    int A[100], N;
    int i, j, temp;
    int count = 0;

    scanf("%d", &N);
    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    for (i = 0; i < N; i++) {
        for ( j = N-1; j > i; j--) {
            if (A[j] < A[j-1]) {
            temp = A[j];
            A[j] = A[j-1];
            A[j-1] = temp;
            count++;}
        }
    }

    for (i = 0; i < N; i++) {
       if ( i != 0 )
       printf(" ");
       
       printf("%d", A[i]);

    }
    printf("\n%d\n", count);

    return 0;
}


Measured memory_bytes: 1988