akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main() {
	long int s, c, a;
	cin >> s >> c;
	if (s >= c / 2){
		cout << c / 2 << endl;
	}else{
		cout << ((c / 2) - s) / 2 + s << endl;
	}
	return 0;
	
}

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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

int n, k;
string str;
vector<int> v;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  cin >> n >> k;
  cin >> str;
  int prev = -1;
  for (int i = 1; i < n; ++i) {
    if (str[i] != str[i - 1]) {
      v.push_back(i - prev - 1);
      prev = i - 1;
    }
  }
  v.push_back(n - 1 - prev);
  if (v.size() < 3) {
    int sum = 0;
    for (auto x: v) sum += x;
    cout << sum - 1 << endl;
  }
  else {
    int mx = 0, curidx;
    for (int i = 1; i < (int)v.size() - 1; ++i) {
      int cur = v[i] + v[i - 1] + v[i + 1];
      if (cur > mx) {
        curidx = i;
        mx = cur;
      }
    }
    int sz = v.size();
    int l = curidx, r = curidx;
    int sum = v[curidx];
    while (k--) {
      if (r == sz - 1 && l == 0) break;
      if (r == sz - 1) {
        sum += v[--l];
        if (l) sum += v[--l];
      }
      else if (l == 0) {
        sum += v[++r];
        if (r < sz - 1) sum += v[++r];
      }
      else {
        sum += v[++r];
        sum += v[--l];
      }
    }
    int ans = sum - 1;
    for (int i = 0; i < (int)v.size(); ++i) {
      if (i >= l && i <= r) continue;
      ans += v[i] - 1;
    }
    cout << ans << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  int ans = 0;
  for (int i = 1; i < N; ++i)
    if (A[i] > A[i - 1])
      ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>
 
// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int  tr['T'+1];
char f[33554432];
 
int main()
{
    int n, k, c;
 
    tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
    n = in();
    while (n--) {
        if (gc() == 'i') {
            k = 7; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            f[k] = 1;
        } else {
            k = 5; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            if (f[k]) pc('y'), pc('e'), pc('s');
            else      pc('n'), pc('o');
            pc('\n');
        }
    }
    return 0;
}


Measured memory_bytes: 2952
#include<iostream>
 #define ll long long 
using namespace std;
int main()
{
 
	ll t;
	ll i,j=100,n,m=100;
     cin>>n;
      ll cnt=0;
     while(m<=n)
     {
     	m=m*1.01;
     	//cout<<m<<endl;
     	 
     	cnt++;
     	if(m>=n)
     	{
     		cout<<cnt<<endl;
     		return 0;
		 }
     	
     	
     	
	 }
	 
	 cout<<cnt<<endl;
	 
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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

typedef long long ll;

void result() {
    string s;
    cin >> s;
    cout << (s == "Sunny"? "Cloudy" : (s == "Cloudy" ? "Rainy": "Sunny")) << endl;
}

int main() {	
    std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
    result();
}

Measured memory_bytes: 256
import math

n, k = [int(x) for x in input().split()]
result = 0
if n >= k:
    result += (n - k + 1) / n
    result += sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, k)) / n
else:
    result = sum(1 / 2 ** math.ceil(math.log(k / i, 2)) for i in range(1, n + 1)) / n

print('%.12f' % result)

Measured memory_bytes: 3060
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
import time

import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from numba import jit


def main():
    N = int(input())
    ans=0
    for i in range(1,N+1):
        if N%i==0:
            ans+=N//i -1
        else:
            ans+=N//i
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 91756
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int usi[213456];
string uiop[213456];
signed main() {
	int n, m, k = 0, a = 1, sum = 0, ans = 0; string s, t; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> m; usi[h] = m;
		k += m;
	}
	k /= n;
	for (int h = 0; h < n; h++) {
		sum += (usi[h] - k - 1) * (usi[h] - k - 1);
	}
	for(int h = 0; h < n; h++) {
		ans += (usi[h] - k) * (usi[h] - k);
	}
	cout << min(sum,ans) << endl;
}

Measured memory_bytes: 1920
import Control.Monad
import Data.List
import qualified Data.Map as Map
import Data.Maybe

main = do
  n <- readLn :: IO Int
  ts <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
  let
    tree = makePLR ts
    root = rootId tree
    pre   = preorder root tree
    ino = inorder root tree
    post  = postorder root tree
  putStrLn "Preorder"
  putStr " "
  putStrLn . unwords $ map show pre
  putStrLn "Inorder"
  putStr " "
  putStrLn . unwords $ map show ino
  putStrLn "Postorder"
  putStr " "
  putStrLn . unwords $ map show post

preorder :: Int -> [(Int, Int, Int)] -> [Int]
preorder _ [] = []
preorder p tree = p:l ++ r
  where
    targetTree = filter (\(pid, _, _) -> pid == p) tree
    (_, lid, rid) = head targetTree
    l = if lid == -1 then [] else preorder lid tree
    r = if rid == -1 then [] else preorder rid tree

inorder :: Int -> [(Int, Int, Int)] -> [Int]
inorder _ [] = []
inorder p tree = l ++ [p] ++ r
  where
    targetTree = filter (\(pid, _, _) -> pid == p) tree
    (_, lid, rid) = head targetTree
    l = if lid == -1 then [] else inorder lid tree
    r = if rid == -1 then [] else inorder rid tree


postorder :: Int -> [(Int, Int, Int)] -> [Int]
postorder _ [] = []
postorder p tree = l ++ r ++ [p]
  where
    targetTree = filter (\(pid, _, _) -> pid == p) tree
    (_, lid, rid) = head targetTree
    l = if lid == -1 then [] else postorder lid tree
    r = if rid == -1 then [] else postorder rid tree


rootId :: [(Int, Int, Int)] -> Int
rootId tree = id
  where
    parents = clean $ makeParents tree
    depths = map (measureDepth parents) [0..(length tree - 1)]
    Just id = elemIndex 0 depths

clean = sort . filter (\(id, _) -> id /= -1)

makePLR :: [[Int]] -> [(Int, Int, Int)]
makePLR [] = []
makePLR (t:ts) = (id, l, r):(makePLR ts)
  where (id:l:r:_) = t

makeParents :: [(Int, Int, Int)] -> [(Int, Int)]
makeParents [] = []
makeParents (t:ts) = (l, p):(r, p):makeParents ts
  where (p, l, r) = t

measureDepth :: [(Int, Int)] -> Int -> Int
measureDepth parents id = if (length target) == 0 then 0 else (1 + measureDepth parents (snd $ head target))
  where
    target = filter (\(tid, _) -> tid == id) parents



Measured memory_bytes: 4128
using System;
using System.Linq;
public class Program
{
    public static void Main()
    {
        var N = decimal.Parse(Console.ReadLine());
        var res = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();

        decimal cnt = 0;
        foreach (var p in res)
        {
            var tmp = p;
            while (true)
            {
                if (tmp % 2 == 0)
                {
                    cnt++;
                    tmp = tmp / 2;
                }
                else
                {
                    break;
                }
            }

        }

        Console.WriteLine(cnt.ToString());
    }
}

Measured memory_bytes: 14688
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	int ant=1;
	scanf("%d%d",&n,&m);
	while(n--)
	{
		if(ant*2<=ant+m)
			ant=ant*2;
			else
				ant+=m;
	}
	printf("%d\n",ant);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define rint register int
#define Maxn 100
#define inf 1<<30
#define cmin(x,y) (x>y)&&(x=y)
#define cmax(x,y) (x<y)&&(x=y)
using namespace std;
inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void write(int v){if(v<0){putchar('-');v=-v;}if(v>9)write(v/10);putchar(v%10+'0');}
int main()
{
	//freopen("xxx.in", "r", stdin);
    //freopen("xxx.out", "w", stdout);
	int x=read();
	if(x==0) cout<<1;
	if(x==1) cout<<0;
	return 0;
}
/*
 * ┌───┐   ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐
 * │Esc│   │ F1│ F2│ F3│ F4│ │ F5│ F6│ F7│ F8│ │ F9│F10│F11│F12│ │P/S│S L│P/B│  ┌┐    ┌┐    ┌┐
 * └───┘   └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘  └┘    └┘    └┘
 * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐
 * │~ `│! 1│@ 2│# 3│$ 4│% 5│^ 6│& 7│* 8│( 9│) 0│_ -│+ =│ BacSp │ │Ins│Hom│PUp│ │Num│ / │ * │ - │
 * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤
 * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │{ [│} ]│ | \ │ │Del│End│PDn│ │ 7 │ 8 │ 9 │   │
 * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ └───┴───┴───┘ ├───┼───┼───┤ + │
 * │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │: ;│" '│ Enter  │               │ 4 │ 5 │ 6 │   │
 * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤     ┌───┐     ├───┼───┼───┼───┤
 * │ Shift  │ Z │ X │ C │ V │ B │ N │ M │< ,│> .│? /│  Shift   │     │ ↑ │     │ 1 │ 2 │ 3 │   │
 * ├─────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ E││
 * │ Ctrl│ Win│ Alt│         Space         │ Alt│ Win│Menu│Ctrl│ │ ← │ ↓ │ → │ │   0   │ . │←─┘│
 * └─────┴────┴────┴───────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘
 */


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
  }
  int _max = -1;
  for (auto it : m) {
    _max = max(_max, it.second);
  }
  for (auto it : m) {
    if (it.second == _max) {
      cout << it.first << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 23808
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1e5+5;
typedef long long ll;
ll dp[N];
int w[105],v[105];
int main(){
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    int n,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++){
        for(int j=N-1;j>=v[i];j--){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    for(int i=N-1;i>=0;i--)if(dp[i]<=W){
        printf("%d",i);
        return 0;
    }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int dp[2][5001];
int main(){
  int n,m,a[5001],b[5000];
  scanf("%d %d",&n,&m);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  for(int i=1;i<=m;i++) scanf("%d",&b[i]);
  int ans = 0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      dp[1][j] = dp[0][j];
      if(a[i] == b[j]) dp[1][j] = dp[0][j-1]+1;
      if(i == n) ans = max(ans,dp[1][j]);
    }
    for(int j=1;j<=m;j++){
      dp[0][j] = dp[1][j];
    }
  }
  printf("%d\n",ans);
  return (0);
}

Measured memory_bytes: 3300
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m;
int i,j,k;
int main(){
	scanf("%lld%lld",&n,&m);
	puts(n-m>=-1&&n-m<=1?"Brown":"Alice");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i = 0,j = 0,ans = 0;
	char s[100000] = "\0";
	
	scanf("%s",s);
	
	while(s[i] != '\0'){
		if(s[i] != s[i + 1])
			ans++;
		i++;
	}
	
	printf("%d\n",ans - 1);
	
	return 0;
}

Measured memory_bytes: 256
import sys
import heapq
from math import ceil


def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        heapq.heapreplace(A, ceil(A[0] / 2))

    ans = -sum(A)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.S<b.S)
    return true;
    return false;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 764
using System;

class Program {
  static void Main() {
    var s = Console.ReadLine();
    for (int i = 0; i < s.Length - 1; i++) {
      if (s[i] == 'A' && s[i + 1] == 'C') {
        Console.WriteLine("Yes");
        return;
      }
    }
    Console.WriteLine("No");
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int N=100002;
int n,i,a[N],col,m;
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
	int x=0,fl=1;char ch=gc();
	for (;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;
	for (;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);
	return x*fl;
}
inline void wri(int a){if(a<0)a=-a,putchar('-');if(a>=10)wri(a/10);putchar(a%10|48);}
inline void wln(int a){wri(a);puts("");}
int main(){
	n=rd();
	for (i=1;i<=n;i++) a[i]=rd();
	sort(a+1,a+n+1);
	if (a[1]==a[n]) return puts(a[1]<=n/2 || a[1]==n-1?"Yes":"No"),0;
	if (a[n]-a[1]>1) return puts("No"),0;
	col=a[n];
	for (i=1;a[i]==a[1];i++);
	m=i-1;
	puts(m+1<=col && col<=(n-m)/2+m?"Yes":"No");
}

Measured memory_bytes: 768
#include <iostream>
int countsum(int n){
  int sum = 0;
  while(n>0){
    sum = sum + n%10;
    n = n/10;
  }
  return sum;
}

int main (){
  int a=0, b=0;
  int N=0;

  std::cin >> N >> a >> b;
  int total = 0;

  for(int i=1; i<=N; ++i){
    int sum = countsum(i);
    if (sum >= a && sum <= b){
      total += i;
    }
  }

  std::cout << total << std::endl;

}


Measured memory_bytes: 256
while True:
    w,d = [int(i) for i in input().split()]
    if w == 0:
        break
    h = [int(i) for i in input().split()]
    h_ = [int(i) for i in input().split()]
    h = sorted(h)
    h_ = sorted(h_)
    hdic = {}
    h_dic = {}

    for i in h:
        if i in hdic.keys():
            hdic[i]+= 1
        else:
            hdic[i] = 1
    
    for i in h_:
        if i in h_dic.keys():
            h_dic[i]+= 1
        else:
            h_dic[i] = 1
    ans  = sum(h)+ sum(h_)
    for num in hdic.keys():
        if num in h_dic.keys():
            ans -= num*min(hdic[num],h_dic[num])
    print(ans)



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
#define B 550
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
ll t[100005];
struct que{
  ll o,a,b;
};
struct z{
  ll x;
  bool operator <(z&q){
       if(t[x]!=t[q.x])return -t[x]<-t[q.x];
       else return x<q.x;
  }
};
int n,c;
bool v[100005];
int main(void){
    scanf("%d%d",&n,&c);
    for(int i=0;i<c;i+=B){
        set<int>o;
        vector<que>m;
        for(int k=0;k<n;k++)v[k]=false;
        for(int j=i;j<i+B&&j<c;j++){
            int x;
            scanf("%d",&x);
            if(x==0){
                ll a,b;
                scanf("%lld%lld",&a,&b);
                a--;
                v[a]=true;
                m.push_back(que{0,a,b});
            }else{
                int a;
                scanf("%d",&a);
                m.push_back(que{1,a,0});
            }
        }
        vector<z>p;
        vector<P>q;
        for(int k=0;k<n;k++){
            if(!v[k])q.push_back(P(-t[k],k));
            else p.push_back(z{k});
        }
        sort(q.begin(),q.end());
        for(int j=0;j<m.size();j++){
            ll r=m[j].o,a=m[j].a,b=m[j].b;
            if(r==0)t[a]+=b;
            else{
                sort(p.begin(),p.end());
                a--;
                bool e=false;
                for(int k=0;k<p.size();k++){
                    int h=lower_bound(q.begin(),q.end(),P(-t[p[k].x],p[k].x))-q.begin();
                    if(a<h)break;
                    else if(a==h){
                        printf("%lld %lld\n",p[k].x+1,t[p[k].x]);
                        e=true;
                        break;
                    }else a--;
                }
                if(!e){
                    printf("%lld %lld\n",q[a].S+1,-q[a].F);
                }
            }
        }
    }
}


Measured memory_bytes: 7532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front
#define MP make_pair
typedef long long int ll;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int main(){
  ll x, a, b;
  cin >> x >> a >> b;
 
  if(b - a <= 0){
    cout << "delicious" << endl;
  }else if(b - a <= x){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
const int inf = 999999;
 
int func(int n)
{
  int r = inf, w;
 
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 17; j++){
      for(int k = 0; k <= 10; k++){
    w = i*200+j*300+k*500;
    if(n == w){
      r = min(r, (i/5)*1520 + (i%5)*380 + 1870*(j/4) + (j%4)*550 + 2244*(k/3) + (k%3)*850);
    } else if(n < w){
      break;
    }
      }
    }
  }
 
  return r;
}
 
int main()
{
  int n;
 
  while(cin >> n && n){
    cout << func(n) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1164
from heapq import heappush, heappop
X = []
N = int(input())
dic = {}
for i in range(N):
  a, b = map(int, input().split())
  heappush(X,(-(a+b),a,b))
count = 0
T = 0
A = 0
while X:
  m, a, b = heappop(X)
  if count%2==0:
    T += a
  else:
    A += b
  count += 1

print(T-A)

Measured memory_bytes: 68312
import sys
input = sys.stdin.readline
ins = lambda: input().strip()
inn = lambda: int(input())
inl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

n, a, b = inl()

def comb(n, k):
	p, q = 1, 1
	for i in range(1, k+1):
		p = p * (n-i+1) % mod
		q = q * i % mod
	return p * pow(q, mod-2, mod) % mod

sum_comb = pow(2, n, mod) - 1
sum_comb -= comb(n, a)
sum_comb -= comb(n, b)

print(sum_comb % mod)


Measured memory_bytes: 3188
#include<stdio.h>

int main(void){
    int i,j,h,w,start,next;

    while(1){
        scanf("%d %d",&h,&w);
        if(h == 0 && w == 0)
            break;
        start = 1;
        for(i = 0;i < h;i++){
            next = start;
            for(j = 0;j < w;j++){
                if(next == 1)
                    printf("#");
                else
                    printf(".");
                next *= -1;
            }
            printf("\n");
            start *= -1;
        }
        printf("\n");
    }
    return 0;
}

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

int main() {
    int const MOD = 1e9 + 7;
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    ll ans = 3;
    rep(i, n) {
        bool prev = s1[i - 1] == s2[i - 1];
        if (s1[i] == s2[i]) {
            if (i > 0 && prev) ans = ans * 2 % MOD;
        } else
            ans = ans * (prev ? 2 : 3) % MOD, i++;
    }

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


Measured memory_bytes: 3540
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#define LL long long
#define mod 1000000007
#define hmod 300007
using namespace std;

LL n;
int info[300007],Prev[1000000],val[1000000],cnt_e;
LL key[2][1000000];

int Insert(LL u,LL v,int cst)
{
	int k = (u % hmod + v % hmod) % hmod;
	if(cst==-1)
	{
		for(int i=info[k];i;i=Prev[i])
			if(key[0][i] == u && key[1][i] == v)
				return val[i];
		return -1;
	}
	else Prev[++cnt_e] = info[k] , info[k] = cnt_e , val[cnt_e] = cst , key[0][cnt_e] = u , key[1][cnt_e] = v;
}

int dfs(LL u,LL v)
{
    if(v<0) return 0;
    if(v==0) return 1;
    LL tmp;
    if((tmp=Insert(u,v,-1))!=-1) return tmp;
    tmp = ((dfs(u >> 1 ,v >> 1) + dfs((u-1) >> 1 , (v-1) >> 1)) % mod + dfs(u>>1 , (v-2)>>1)) % mod;
    Insert(u,v,tmp);
    return tmp;
}

int main()
{
	scanf("%lld",&n);
	printf("%d",dfs(n,n));
}


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

int main()
{
  string O, E;
  cin >> O >> E;
  rep(i, O.size() + E.size())
  {
    if (i % 2 == 0)
      cout << O[i / 2];
    else
      cout << E[i / 2];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  if(s[n-1] == 's') cout << s << "es" << endk;
  else cout << s << "s" << endk;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

int main(int argc, char *argv[])
{
	int n;

	cin >> n;
	bool f=false;
	for (int i=1; i<10;i++)
	{
		if ((n%i)==0 && (n/i)<10)  f=true;
	}

	cout << (f ? "Yes" : "No") << endl;
	return 0;
}



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

int main() {
     
    int n, k; cin >> n >> k;
    const int p = 200010;
    vector<int> num(p,0);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        num[a]++;
    }
    sort(num.begin(), num.end(), greater<int>());

    int ans = 0;
    for (int i = k; i < p; i++) {
        if (num[i] == 0) break;
        ans += num[i];
    }
 
    cout << ans << endl;
    return 0;
}

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

int checkrock(int p,int q,string s){
    int flag=0,pastf=0;
    int inArow=0;
    int maxinArow=0;

    
        for (int i = p-1; i < q; i++){
            pastf=flag;
            
            if(s[i]=='.'){
                
                flag=0;
                inArow=0;

            }else{
                flag=1;
                if(pastf==0)inArow=1;
            }

            if(pastf==1 && flag==1)inArow++;

            maxinArow = max(maxinArow,inArow);
        }

    return maxinArow;
}

int checkjimen(int p,int q,string s){
    int flag=0,pastf=0;
    int inArow=0;
    int maxinArow=0;

    
        for (int i = p-2; i <= q; i++){
            pastf=flag;
            
            if(s[i]=='#'){
                
                flag=0;
                inArow=0;

            }else{
                flag=1;
                if(pastf==0)inArow=1;
            }

            if(pastf==1 && flag==1)inArow++;

            maxinArow = max(maxinArow,inArow);
        }

    return maxinArow;
}

int main(){
    int n,a,b,c,d;
    int flag=0,pastf=0;
    int inArow=0;
    int maxinArow=0;
    string s;
    //int ans1=1,ans2=1,ans3=1;
    int ansall=1;

    cin >>n>>a>>b>>c>>d;
    cin >>s;


    if(d<c){
        if(checkjimen(b,d,s) <= 2)ansall=0;
        if(checkrock(a,c,s) >= 2)ansall=0;

        //if(s[d]=='#' || s[d-2]=='#')ansall=0;
    }else{

        if(checkrock(a,c,s) > 1)ansall=0;
        if(checkrock(b,d,s) > 1)ansall=0;

    }
    
    if(ansall==1)cout << "Yes" <<endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 772
n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
d = []
d.append(0)
for i in range(n):
    d.append(d[i] + l[i])

for i in range(len(d)):
    if d[i] <= x:
        ans += 1

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(m, d);
    ll res = 0;
    REPS(i, m)REPS(j, d){
        int a = (j - j % 10) / 10, b = j % 10;
        if(a < 2 or b < 2) continue;
        if(a * b == i) res++;
    }
    print(res);
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int arr[1000][2];
int cache[100005];
int dp(int loc){
  if(loc>=100001) return 0;
  int & ret = cache[loc];
  if(ret!=0) return ret;
  for(int i=0;i<N;i++){
    if(arr[i][0]>loc) {
      ret = max(ret,arr[i][1]-arr[i][0]+1+dp(arr[i][1]));
    }
  }
  return ret;
}
int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>arr[i][0]>>arr[i][1];
  }
  cout<<dp(0);
}


Measured memory_bytes: 640
from collections import deque

n=int(input())
a = [int(i) for i in input().split()]
a.sort()
a=deque(a)
a.appendleft(0)
a.append(a[-1])
#print(n,a)

def gcd(x,y):
  if x < y:
    x,y = y,x
  if y==0:
    return x
  else:
    x=x%y
    return gcd(x,y)
#print(gcd(9,3))

left=deque([0 for i in range(n)])
left[0]=gcd(a[0],a[1])
for i in range(1,n):
  left[i]=gcd(left[i-1],a[i+1])
#print(left)

right=deque([0 for i in range(n)])
right[-1]=gcd(a[-1],a[-2])
for i in range(-2,-1-n,-1):
  right[i]=gcd(right[i+1],a[i-1])
#print(right)

ans=right[1]
for i in range(n-2):
  val=gcd(left[i],right[i+2])
  if ans < val:
    ans=val
if ans < left[-2]:
  ans=left[-2]
  
print(ans)

Measured memory_bytes: 14436
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;



int main(){
    int N;
    cin >> N;
    int unko = N%2;

    vector<ll> down;
    vector<ll> up;
    for(int i = 1; i <= N; i++){
        ll a;
        cin >> a;
        if(i%2 == unko){
            down.insert(down.begin(),a);
        }else{
            up.push_back(a);
        }
    }

    down.insert(down.end(), up.begin(), up.end());

    string result = "";
    for(int i = 0 ; i < N; i ++){
        result += to_string(down[i]);
        if(i != N-1){
            result += " ";
        }
    }

    printf("%s",result.c_str());

    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;

int main()
{
	int n;
	cin >> n;
	cout << 48 - n << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
int h, w;
vector<string> maze;
vector<vector<int>> dp;

int f(int i, int j) {
    return 23 * i + j;
}

signed main() {
    cin >> h >> w;
    string s;
    for (int i = 0; i < h; ++i) {
        cin >> s;
        maze.push_back(s);
    }
    if((h==1 && w==2)|| (w==1 && h==2)){
        cout<<1;
        return 0;
    }
    dp = vector<vector<int>>(23 * 23, vector<int>(23 * 23, INT_MAX));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (maze[i][j] == '.') {
                if (i < h - 1 && maze[i + 1][j] == '.')dp[f(i, j)][f(i + 1, j)] = 1, dp[f(i + 1, j)][f(i, j)] = 1;
                if (j < w - 1 && maze[i][j + 1] == '.')dp[f(i, j)][f(i, j + 1)] = 1, dp[f(i, j + 1)][f(i, j)] = 1;
            }
        }
    }
    int maxi = 0;
    h = w = 23;
    for (int k = 0; k < h * w; k++) {
        for (int i = 0; i < h * w; i++) {
            for (int j = 0; j < h * w; j++) {
                if (dp[i][k] + dp[k][j] < dp[i][j] && dp[i][k] != INT_MAX && dp[k][j] != INT_MAX) {
                    dp[i][j] = dp[i][k] + dp[k][j];
                }
            }
        }
    }
    for (int i = 0; i < 23*23; ++i) {
        for (int j = 0; j < 23*23; ++j) {
            if (dp[i][j] != INT_MAX)maxi = max(maxi, dp[i][j]);
        }
    }
    cout << maxi << endl;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  int count = 0 ;
  
  rep(i,n){
    if(s.at(i)=='+'){
      count++ ;
    }
    else{
      count-- ;
    }
  }
  cout << count <<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101

int main(){
int n,i,j,k,key;
int A[MAX];

scanf("%d",&n);

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

for( i = 0 ; i < n ; i++ ){
key = A[i];

j = i - 1;

while( j >= 0 && key < A[j]){
A[j+1] = A[j];
j--;
}
A[j+1] = key;

for( k = 0 ; k < n - 1 ; k++ ) printf("%d ",A[k]);
	printf("%d\n",A[k]);
}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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 long long INF=1LL<<60;
//set<int>::iterator it;



int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int k,i,ans=0,n;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++){
//		cout<<a[a[i]-1]<<" "<<a[i]<<" "<<i+1<<endl;
		if(a[a[i]-1]==i+1)ans++;
	}
	ans/=2;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL cmCI(LL l, LL r, LL m, LL a) { assert(m > 0); return max(0LL, fl(r - a, m) - fl(l - a, m)); }
LL cmCD(LL l, LL r, LL m, LL a) { return cmCI(l    , r - 1, m, a); }
LL cmII(LL l, LL r, LL m, LL a) { return cmCI(l - 1, r    , m, a); }
LL cmID(LL l, LL r, LL m, LL a) { return cmCI(l - 1, r - 1, m, a); }


LL l, r;

int main() {
	cin >> l >> r;
	
	if(cmII(l, r, 2019, 0) > 0) { cout << 0 << endl; } else {
		LL mi = l * r;
		incII(i, l, r) {
		incID(j, l, i) {
			setmin(mi, i * j % 2019);
		}
		}
		cout << mi << endl;
	}
	
	return 0;
}


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

dict = {}
A_set = set(A)
for a in A_set:
    dict[a] = []
for i in range(N):
    dict[A[i]].append(i)

trans = {}
for a_list in dict.values():
    for i in range(len(a_list)):
        trans[a_list[i - 1]] = a_list[i]

k = 1
pos = 0
print_ans = 0
div_flag = 0
while True:
    new_pos = trans[pos]
    if new_pos <= pos:
        if k + 1 <= K:
            k += 1
            if new_pos + 1 < N:
                pos = new_pos + 1
            else:
                if div_flag == 0:
                    pos = 0
                    K = K % k
                    k = 1
                    div_flag = 1
                else:
                    print('')
                    break
        else:
            print_ans = 1
            break
    else:
        if new_pos + 1 < N:
            pos = new_pos + 1
        else:
            if div_flag == 0:
                pos = 0
                K = K % k
                k = 1
                div_flag = 1
            else:
                print('')
                break

if print_ans:
    ans = []
    i = pos
    while i < N:
        if trans[i] <= i:
            ans.append(A[i])
            i += 1
        else:
            i = trans[i] + 1
    print(' '.join(map(str, ans)))


Measured memory_bytes: 124236
#include <iostream>

using namespace std;

int main(){
  string s;
  int N=0,a[26],i;
  for (i=0;i<26;i++) {
    a[i]=0;
  }

  getline(cin ,s);
  while (s!="") {
    N=s[0] - '0';
    if (N>48 && N<75) {
      a[N-49]+=1;
    } else if (N>16 && N<43) {
      a[N-17]+=1;
    }
    s.erase(s.begin());
    if (s=="") getline(cin ,s);
  }

  char c='a';
  for (i=0;i<26;i++) {
    cout << c << " : " << a[i] << endl;
    c+=1;
  }
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long a[N];
  long long x,y=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    y+=a[i];
  }
  x=a[0];
  y-=a[0];
  long long ans=abs(x-y);
  
  for(int i=1;i<N-1;i++){
    x+=a[i];
    y-=a[i];
    ans=min(ans,abs(x-y));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    w, h, x, y = rli()
    s = w*h/2
    if x*2 == w and y*2 == h:
        print(s, 1)
    else:
        print(s, 0)





if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
a, b, c, x, y = map(int, input().split())
ans = a * x + b * y
for i in range(0, 2 * max(x, y) + 2, 2):
    pay = max(0, (x - i / 2)) * a + max(0, (y - i / 2)) * b + c * i
    ans = min(ans, pay)
print(int(ans))


Measured memory_bytes: 9152
import Data.Bool
import Data.List
main = do
    [w,h,_] <- map read . words <$> getLine
    xyas <- tuplify . map read . words <$> getContents
    print $ sum [solve x y xyas | y <- [1..h], x <- [1..w]]

solve _ _ [] = 1
solve u v ((x,y,1):as) = bool (solve u v as) 0 $ u <= x
solve u v ((x,y,2):as) = bool (solve u v as) 0 $ x < u
solve u v ((x,y,3):as) = bool (solve u v as) 0 $ v <= y
solve u v ((x,y,4):as) = bool (solve u v as) 0 $ y < v

tuplify [] = []
tuplify (x:y:z:xs) = (x,y,z):tuplify xs


Measured memory_bytes: 1020
#include <iostream>
#include<stdio.h>
using namespace std;

int main(){
	int n;

	cin >> n;
	int* a = new int[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
		
	}
	for(int x = 0;x < n;x++){
		cout << a[x] <<  flush;
		if(x != n - 1)
			cout << " " << flush;
	}
	cout << endl;
	for(int i = 1;i < n;i++){
		int v = a[i];
		int j = i - 1;
		while(j >= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[j+1] = v;

		for(int x = 0;x < n;x++){
			cout << a[x] << flush;
			if(x != n - 1)
				cout << " " << flush;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
def main():
    n, threshould = [int(x) for x in input().split()]
    count = 0
    for _ in range(n):
        x, y = [int(x) for x in input().split()]
        if (x ** 2 + y ** 2) <= threshould ** 2:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    }
}


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

int main() {
    int n;
    cin >> n;
    long long ans = 1;
    long double w = 1;
    bool f = true;
    for (int i = 1; i <= n; i++) {
        long long x;
        cin >> x;
        if (x == 0) {
            ans = 0;
            f = false;
        }
        if (f) {
            w *= x;
            ans *= x;
            if (w < 1e18 - 100) {
                
            } else if (w > 1e18 + 100) {
                f = false;
                ans = -1;
            } else {
                if (ans > 1000000000000000000LL) {
                    ans = -1;
                }
            }
        }
    }
    
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3604
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int N, M, K, A, B, L;

vector<vector<pair<int, int> > > G;

vector<int> P, D;

int main()
{
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &K);

	G = vector<vector<pair<int, int> > >(N);

	for (int i = 0; i < M; i++)
	{
		scanf("%d", &A);
		scanf("%d", &B);
		scanf("%d", &L);

		G[A - 1].push_back(make_pair(B - 1, L));
		G[B - 1].push_back(make_pair(A - 1, L));
	}

	P = vector<int>(K);

	for (int i = 0; i < K; i++)
	{
		scanf("%d", &P[i]); P[i]--; // 0 - indexed
	}

	D = vector<int>(N, 999999999);

	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;

	for (int i = 0; i < K; i++)
	{
		que.push(make_pair(0, P[i])); D[P[i]] = 0;
	}

	while (!que.empty())
	{
		pair<int, int> state = que.top(); que.pop();

		int dist = state.first;
		int node = state.second;

		for (int j = 0; j < G[node].size(); j++)
		{
			int node2 = G[node][j].first;
			int leng2 = G[node][j].second;

			if (D[node2] > D[node] + leng2)
			{
				D[node2] = D[node] + leng2;

				que.push(make_pair(D[node2], node2));
			}
		}
	}

	int ret = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < G[i].size(); j++)
		{
			ret = max(ret, D[i] + D[G[i][j].first] + G[i][j].second);
		}
	}

	printf("%d\n", (ret + 1) / 2);

	return 0;
}

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

using namespace std;

const int maxn = 305,mo = int(1e9) + 7;

bitset<maxn> a[maxn];
int f[maxn][maxn],pw[maxn * maxn],n;

int pow(int a,int b)
{
	int tmp = 1;
	for(;b;b >>= 1,a = a * 1ll * a % mo)
		if (b & 1) tmp = tmp * 1ll * a % mo;
	return tmp;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1;i <= n;i ++)
		for(int j = 1,v;j <= n;j ++)
			scanf("%d", &v),a[i][j] = v;
	int r = 0;
	for(int i = 1,j = 1;i <= n && j <= n;j ++)
	{
		for(int k = i;k <= n;k ++) if (a[k][j]) {swap(a[i],a[k]);break;}
		if (!a[i][j]) continue;
		++ r;
		for(int k = i + 1;k <= n;k ++) if (a[k][j]) a[k] ^= a[i];
		++ i;
	}
	pw[0] = 1;
	for(int i = 1;i <= n * n;i ++) pw[i] = pw[i - 1] * 2ll % mo;
	f[0][0] = 1;
	for(int i = 1;i <= n;i ++)
		for(int j = 0;j <= i;j ++)
		{
			f[i][j] = f[i - 1][j] * 1ll * pw[j] % mo; 
			if (j) f[i][j] = (f[i][j] + f[i - 1][j - 1] * 1ll * (pw[n] - pw[j - 1]) % mo) % mo;
		}
	int ans = 0;
	for(int i = r;i <= n;i ++)
		ans = (ans + f[n][i] * 1ll * pw[n * (n - i)] % mo * f[i][r]) % mo;
	printf("%d\n", (ans * 1ll * pow(f[n][r],mo - 2) % mo + mo) % mo);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

		for (int i=0; i< 4 ; i++) {
			s[i] = S.charAt(i);
		}

		int image = 0;
		for (char a : s) {
			if (("+").equals(String.valueOf(a))) {
				image++;
			} else {
				image--;
			}
		}
		System.out.println(image);
	}
}


Measured memory_bytes: 21844
import sys
import re

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    S = in_s()

    orda = ord('a')
    for c in range(orda, orda + 26):

        c = chr(c)

        pattern = c + c
        m = re.search(pattern, S)
        if m:
            a, b = m.span()
            print(a + 1, b)
            exit()

        pattern = c + '[^' + c + ']' + c
        m = re.search(pattern, S)
        if m:
            a, b = m.span()
            print(a + 1, b)
            exit()
    else:
        print(-1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10144
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e4 + 10;
inline int Max(int a, int b) { return a > b ? a : b; }
inline int Min(int a, int b) { return a > b ? b : a; }
namespace FastIO {
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
};
using namespace FastIO;
signed main()
{
    //freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    int A = read(), B = read();
    if (A > B)
        std::swap(A, B);
    if ((A < 0 && B > 0)) {
        puts("Zero");
    } else if (A == 0 || B == 0) {
        puts("Zero");
    } else if (A > 0) {
        puts("Positive");
    } else {
        int num = B - A + 1;
        if (num & 1) {
            puts("Negative");
        } else {
            puts("Positive");
        }
    }
    return 0;
}

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

using namespace std;

int main(){
	int N, M, T, cur=0, ans=0;
	cin >> N >> M >> T;
	rep(i,N){
		int a;
		cin >> a;
		ans += max(0, a-M - cur);
		cur = a+M;
	}
	ans += max(0, T - cur);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3104
S=input()
count=0
tmp=0
for i in range(len(S)):
	if i%2==0:
		if S[i]!="1":
			count+=1
	else:
		if S[i]!="0":
			count+=1
for i in range(len(S)):
	if i%2==1:
		if S[i]!="1":
			tmp+=1
	else:
		if S[i]!="0":
			tmp+=1
#print(count,tmp)
print(min(count,tmp))

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 90000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;


struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int N):par(N),rank(N){
        for(int i = 0;i < N;i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    bool same(int x,int y){
      return root(x) == root(y);
    }
};


int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> P(M);
  for(int i = 0;i < M;i++){
    cin >> P[i].first >> P[i].second;
  }
  int ans = 0;
  for(int i = 0;i < M;i++){
    UnionFind tree(N);
    for(int j = 0;j < M;j++){
     if(i != j){
       tree.unite(P[j].first-1,P[j].second-1);
     }
    }
    bool frag = 0;
    for(int j = 0;j < N;j++){
      if(!tree.same(0,j)){
        frag = 1;
      }
    }
    if(frag){
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256