akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define int long long 
vector<ll> p,q;
vector<bool>fp,fq;
vector<vector<pair<int,ll> > > g;

bool flag = 0;
void dfs(int x,ll s,bool f){
    if(f){
        if(fp[x]==1){
            if(p[x]!=s)flag = 1;
            return ;
        }
        p[x] = s;
        fp[x] = 1;
        for(auto y:g[x]){
            dfs(y.first,y.second-s,0);
        }
    }else{
        if(fq[x]==1){
            if(q[x]!=s)flag = 1;
            return ;
        }
        q[x] = s;
        fq[x] = 1;
        for(auto y:g[x]){
            dfs(y.first,y.second-s,1);
        }
    }
}

signed main(){
    int n,m;
    cin >> n >> m;
    p.resize(n);
    q.resize(n);
    g.resize(n);
    fp.resize(n);
    fq.resize(n);
    for(int i=0;i<m;i++){
        ll u,v,s;
        cin >> u >> v >> s;
        u--;
        v--;
        g[u].PB(MP(v,s));
        g[v].PB(MP(u,s));
    }
    dfs(0,0,1);
    if(flag){
        cout << 0 << endl;
        return 0;
    }
    ll lo=1;
    ll up = inf;
    set<ll> st;
    for(int i=0;i<n;i++){
        if(fp[i]&&fq[i]){
            ll x = q[i]-p[i];
            if(x<=0){
                flag  =1;
            }else if(x%2!=0){
                flag = 1;
            }
            st.insert(x);
        }
    }
    if(flag||st.size()>1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(fp[i])lo = max(lo,-p[i]+1);
        if(fq[i])up = min(up,q[i]-1);
    }
    if(lo<=0||up<=0||lo>up){
        cout << 0 << endl;
        return 0;
    }
    if(st.size()==1){
        cout << 1 << endl;
        return 0;
    }
    cout << up-lo+1 << endl;
    return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;

typedef long long ll;

int main(void) {
  ll x, y;
  scanf("%lld%lld", &x, &y);
  if(x % y == 0) {
    puts("-1");
    return 0;
  }
  for(ll i = x; ; i += x) {
    if(i % y != 0) {
      printf("%lld\n", i);
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a = get_nums_l()
xxx = get_nums_l()

valMax = 2505

# dp[i][j][k] = i番目まで処理して、選択した個数がjで、合計がkのとき、平均aにできるパターン数
dp = [ [ [0]*valMax for __ in range(n+1) ] for _ in range(n+1) ]

for j in range(n+1):
    for k in range(valMax):
        dp[n][j][k] = 1 if k == j*a else 0

for i in range(n-1, -1, -1):
    for j in range(i+1):
        for k in range(valMax):
            no_pic = dp[i+1][j][k]
            pic = dp[i+1][j+1][k + xxx[i]] if k+xxx[i] < valMax else 0
            dp[i][j][k] = no_pic + pic
            # if no_pic+pic > 0:
                # log((i,j,k), no_pic, pic, no_pic+pic)

print(dp[0][0][0] - 1)

Measured memory_bytes: 93276
from heapq import heappop, heappush

def dijkstra(s):
    used = [1] * N
    dp = [INF] * N
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

INF = 10 ** 18
N, M = map(int, input().split())
cost = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cost[a].append([1, b])
    cost[b].append([1, a])
dp1 = dijkstra(0)
for i in dp1:
    if i == INF:
        print('No')
        exit()
print('Yes')
for i in range(1, N):
    tmp = dp1[i] - 1
    for j in cost[i]:
        if dp1[j[1]] == tmp:
            print(j[1] + 1)
            break

Measured memory_bytes: 152904
#include<cstdio>
#include<iostream>
int main(){
    int n,ansn,spot,judge=1,lastans=0;
    char ans[10],ring[11];
    scanf("%s",ans);
    for(int i=0;;i++){
        if(ans[i]=='\0'){
            ansn=i;
            break;
        }
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",ring);
        for(int j=0;j<10;j++){
            judge=1;
            for(int k=0;k<ansn;k++){
                spot=(j+k)%10;
                if(ring[spot]!=ans[k])
                    judge=0;
            }
            if(judge==1){
                lastans++;
                break;
            }
        }
    }
    printf("%d\n",lastans);
    return 0;
}

Measured memory_bytes: 1188
package main

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

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

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

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

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

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

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

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

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

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	nn := map[int]int{}
	for i := 0; i < 4; i++ {
		n := getNextInt(scanner)
		nn[n] = 1
	}
	check := [4]int{
		1,
		9,
		7,
		4,
	}

	for _, n := range check {
		if nn[n] == 0 {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	fmt.Fprintln(writer, "YES")
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  string a;
  cin>>a;
  int b=0;
  rep(i,6){
  if(a[i]=='1')
    b++;
  }
  out(b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

ll fc[200010]={1};
ll fct(ll x){
  if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
  return fc[x];
}

ll ifc[200010]={1};
ll ifct(ll x){
  if(ifc[x]==0) ifc[x]=inv(fct(x));
  return ifc[x];
}

ll comb(ll n,ll r){
  if(n<0 || r<0 || n<r) return 0;
  return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}

int main(){
  ll n,N,m,ans=1;
  cin>>n>>m;
  N=m;
  vector<int> fcn;
  for(ll i=2;i*i<=N;i++){
    if(N%i==0){
      int cnt=0;
      while(N%i==0){
        cnt++;
        N/=i;
      }
      fcn.pb(cnt);
    }
  }
  if(N>1) fcn.pb(1);
  fr(i,fcn.size()) ans=mlt(ans,comb(n+fcn[i]-1,fcn[i]));
  cout<<ans<<endl;
}

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

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

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int n,k;
int r,s,p;
string t;

vvint d;

int dp(int po, int te){
	if(po > n)return 0;
	
	if(d[po][te] != -1)return d[po][te];

	int res=0;
	if(te != 0){chmax(res, (t[po]=='s'?r:0)+dp(po+k, 0));}
	if(te != 1){chmax(res, (t[po]=='p'?s:0)+dp(po+k, 1));}
	if(te != 2){chmax(res, (t[po]=='r'?p:0)+dp(po+k, 2));}
	return d[po][te] = res;
}


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	
	cin>>n>>k>>r>>s>>p>>t;
	
	initvv(d, n+2, 4, -1);
	int ans = 0;
	rep(i, k){
		ans += dp(i, 3);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15056
'use strict';

const main = (input) => {
    const t = input.split('\n');
    const hw = t[0].split(' ');
    const H = parseInt(hw[0], 10);
    const W = parseInt(hw[1], 10);
    const a = [];
    for (let y = 0; y < H; y++) {
        a[y] = [];
        const l = t[y + 1].split(' ');
        for (let x = 0; x < W; x++) {
            a[y][x] = parseInt(l[x], 10);
        }
    }
    const log = [];
    const move = function (sx, sy, ex, ey) {
        log.push([sy + 1, sx + 1, ey + 1, ex + 1].join(' '));
        a[ey][ex]++;
        a[sy][sx]--;
    };

    // 奇数の場合は隣に移動していくのを繰り返す
    for (let y = 0; y < H; y++) {
        for (let x = 0; x < W; x++) {
            if (a[y][x] % 2 != 0) {
                // 奇数
                if (x + 1 < W) {
                    // 右へ
                    move(x, y, x + 1, y);
                } else if (y + 1 < H) {
                    // 下へ
                    move(x, y, x, y + 1);
                }
            }
        }
    }
    console.log(log.length);
    console.log(log.join('\n') + '\n');
};

const isTest = false;

if (isTest) {
    main('2 3\n1 2 3\n0 1 1\n');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}

Measured memory_bytes: 64552
# coding: utf-8
# Your code here!
import heapq
import sys
NIL = -1

def dfs(current, prev):
    global timer
    lowest[current] = timer
    prenum[current] = timer
    timer += 1
    visited[current] = True
    
    for i in range(len(G[current])):
        nex = G[current][i]
        if visited[nex] == False:
            parent[nex] = current
            
            dfs(nex, current)

            
            lowest[current] = min(lowest[current], lowest[nex])
        elif(nex != prev):
            lowest[current] = min(lowest[current], prenum[nex])


sys.setrecursionlimit(1000000)

nums=list(map(int,input().split()))
n = nums[0]
e = nums[1]

G = [[] for j in range(n)]
for i in range(e):
    nums=list(map(int,input().split()))
    G[nums[0]].append(nums[1])
    G[nums[1]].append(nums[0])

S = []
visited = [False] * n
parent = [NIL] * n
prenum = [NIL] * n
lowest = [NIL] * n
timer = 1

dfs(0, -1)

ap = set()
np = 0

for i in range(n):
    p = parent[i]
    if p == 0:
        np += 1
    elif prenum[p] <= lowest[i]:
        ap.add(p)
if np > 1:
    ap.add(0)
ap = list(ap)

heapq.heapify(ap)
for i in range(len(ap)):
    x = heapq.heappop(ap)
    if x != NIL:
        print(x)




















Measured memory_bytes: 19380
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << min(a*b*((c + 1) / 2) - a*b*(c / 2), min(a*c*((b + 1) / 2) - a*c*(b / 2), c*b*((a + 1) / 2) - c*b*(a / 2)));
	}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	bool ans = false;
	while (n > 0) {
		if (n % 10 == 7) ans = true;
		n /= 10;
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3652
from itertools import *
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"({a} {x} ({b} {y} {c})) {z} {d}"]:
    if eval(t)==10:return'('+t+')'
 else:return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5664
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

solve [] lim tmp ans = ans
solve (arr:arrs) lim tmp ans
    | arr + tmp > lim = ans
    | otherwise = solve arrs lim (arr + tmp) (ans + 1)

main = do
    [_,lim] <- map read . words <$> getLine
    arr <- map read . words <$> getLine
    let answer = solve arr lim 0 1
    print answer


Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;
int a[100001],b[100001],c[100001],n,d[100001][4];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	d[1][1]=a[1];
	d[1][2]=b[1];
	d[1][3]=c[1];
	for(int i=2;i<=n;i++){
		d[i][1]=max(d[i-1][2],d[i-1][3])+a[i];
		d[i][2]=max(d[i-1][1],d[i-1][3])+b[i];
		d[i][3]=max(d[i-1][2],d[i-1][1])+c[i];
	}
	printf("%d",max(d[n][3],max(d[n][2],d[n][1])));
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;  
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
int a , b ,c , d;
int main(){
    cin >> a >> b >>c >> d;
    if(c / b + (c % b != 0) <= a / d + (a % d != 0) )
        cout << "Yes";
    else cout <<"No";
    return 0;
}


Measured memory_bytes: 3528
#include<string>
#include <iostream>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	string g1(120000, 'a');
	string g2(120000, 'a');
	bool flag = true;
	for (int i = 0; i < int(s.length()); i++) {
		if (flag) {
			g1[i] = '0';
			g2[i] = '1';
			flag = false;
		}
		else {
			g1[i] = '1';
			g2[i] = '0';
			flag = true;
		}
	}
	int count1 = 0, count2 = 0;
	for (int i = 0; i < int(s.length()); i++) {
		if (s[i] != g1[i]) {
			count1++;
		}
		if (s[i] != g2[i]) {
			count2++;
		}
	}
	if (count1 < count2) { cout << count1 << endl; }
	else { cout << count2 << endl; }
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <ios>
#include <limits.h>
using namespace std;
int n, k, sum;

int GetMax(int a, int b) { return (a > b ? a : b); }

int getMinCand(int s, int q)
{
	return ((double)s / (double)q + 0.9999);
}

bool partition(const vector<int>& vN, int minCand)
{
	int i, subsum = 0, s = vN.size(), w = 0, p = 0, r;
	for (i = 0; i < s; ++i){
		if (w + vN[i] <= minCand){
			w += vN[i];
		}else{
			subsum += w;
			w = vN[i];
			++p;
			if (p == k)
				return false;
			if (i != s - 1){
				r = getMinCand(sum - subsum, k - p);
				if (r > minCand)
					return false;
			}
		}
	}

	return true;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	vector<int> vN(n, 0);
	int maxV = INT_MIN;
	for (int i = 0; i < n; ++i){
		cin >> vN[i];
		sum += vN[i];
		if (vN[i] > maxV)
			maxV = vN[i];
	}
	int l, r, m;
	l = GetMax(getMinCand(sum, k), maxV);
	r = l + maxV;
	while (l < r){
		m = (l + r) / 2;
		if (partition(vN, m)) r = m;
		else l = m + 1;
	}

	cout << l << "\n";

	return 0;
}

Measured memory_bytes: 1532
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

/* how that?
 * We have n segments, so at every position there is a number
 * of intersecting segments.
 * Doing one step is sweepline, then replace a[] by b[]
 * But we cannot do this k times :/
 * ...
 * After some short time all are on, then we can stop.
 */
void solve() {
    cini(n);
    cini(k);
    cinai(a,n);

    bool fini=false;
    for(int i=0; !fini && i<k; i++) {
        vector<pii> evt;
        for(int j=0; j<n; j++) {
            evt.emplace_back(j-a[j],  1);
            evt.emplace_back(j+a[j]+1, -1);
        }
        sort(all(evt));

        vi b(n);
        int cnt=0;
        int eidx=0;

        fini=true;
        for(int j=0; j<n; j++) {
            while(eidx<evt.size() && evt[eidx].first<=j) {
                cnt+=evt[eidx].second;
                eidx++;
            }
            b[j]=cnt;
            if(b[j]!=a[j])
                fini=false;
        
        }
        a.swap(b);
    }
    for(int ans : a)
        cout<<ans<<" ";
    cout<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 19804
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
vector<bool> prime;
void make(int num){
    prime.resize(num,true);
    prime[0]=false;
    for(int i=0;i*i<num;i++){
        if(prime[i]){
            for(int j=2;(i+1)*j<=num;j++){
                prime[(i+1)*j-1]=false;
            }
        }
    }
}
int main(){
int n;
cin>>n;
make(1e6);
for(int i=n-1;i<1e6;i++)if(prime[i]){cout<<i+1<<endl;return 0;}
}

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

int main() {
  int R, G, B, N, ans;
  cin >> R >> G >> B >> N;
  for (int r = 0; N - R * r >= 0; r++) {
    for (int g = 0; N - R * r - G * g >= 0; g++) {
      if ((N - R * r - G * g) % B == 0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/* Stay Home, Stay Safe */
#include <iostream>
using namespace std;
int main()
{
	int ans1=0, ans2=0;
	int n;
	cin>>n;
	int ans = n / 500;
	n = n%500;
	ans2 = n/5;
	
	int ans22;
	ans22 = ((ans*1000) + (ans2*5));
	cout<<ans22<<endl;
	
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        double x1,y1,x2,y2,dis;
        x1=sc.nextDouble();
        y1=sc.nextDouble();
        x2=sc.nextDouble();
        y2=sc.nextDouble();
        dis=Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
  	    System.out.println(dis);
    }
}


Measured memory_bytes: 28112
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
#define rep2(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const int inf=1e9+7;
typedef long long ll;
//------------------------------------------head---------------------------------------------------//
int a[N];
int main()
{
	int n;scanf("%d",&n);n*=2;
	rep(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+1+n);int ans=0;
	for(int i=1;i<=n;i+=2)ans+=a[i];printf("%d",ans);puts("");
	return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.readline

n = int(input())
a_list = [int(input()) for _ in range(n)]
sorted_list = sorted(a_list, reverse=True)
for a in a_list:
    check = sorted_list[0]
    if a == check:
        print(sorted_list[1])
    else:
        print(check)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n, a[100005], ct;

main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] == i)
            swap(a[i], a[i + 1]), ++ct;
    }
    cout << ct;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	vector<ll> v;
	ll po = 1;
	for(ll i = 0; i < 3; ++i){
		ll a; cin >> a;
		v.push_back(a);
		po &= a % 2;
	}
	sort(v.begin(), v.end());
	cout << po * v[0] * v[1] << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
xs.sort!
a = []
m.times do |i|
  break if xs[i+1].nil?
  a << (xs[i] - xs[i+1]).abs
end

a.sort!.reverse!
(n-1).times do
  a.shift
end

ans = a.reduce(0){|a,e|a += e}
puts ans


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll N, A, B;
	cin >>N >>A >>B;
	if (0==A) {
		cout <<0 <<endl;
		return 0;
	}
	ll C=A+B;
	ll D=N/C;
	ll E=N%C;
	cout <<D*A+min(E, A) <<endl;
	return 0;
}



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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if ( M[u][v] ) return v;
    }

    return -1;
}

void dfs_visit(int r) {
    for (int i = 0; i < n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt; //time stomp

    while ( !S.empty() ) {
        int u = S.top();
        int v = next(u);
        if ( v != -1) {
            if ( color[v] == WHITE ) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs() {
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }

    tt = 0;

    for (int u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl; 
    }
}

int main() {
    int u, k, v;

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

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}


Measured memory_bytes: 3132
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> a(n);
		REP(i, n) cin >> a[i];
		LL iv = 0;
		REP(i, n) {
			if(i%2 == 0) {
				iv += a[i];
			} else {
				iv -= a[i];
			}
		}
		DEBUG(iv);
		vector<LL> ans(n);
		ans[0] = iv;
		FOR(i, 1, n) {
			ans[i] = (a[i - 1] - ans[i-1] / 2) * 2;
		}
		pite(ALL(ans));
	}
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

char s[300][300];
int ans[300][300];
int empties[300];

int main()
{
	int H, W, K, cnt = 0;
	int strawberry = 0;
	int eindex = 0;

	cin >> H >> W >> K;
	rep(i, H) rep(j, W) cin >> s[i][j];

	rep(i, H) {
		cnt++;
		strawberry = 0;

		rep(j, W) {
			if (s[i][j] == '.') ans[i][j] = cnt;
			else {
				strawberry++;
				if (strawberry >= 2) {
					cnt++;
					strawberry = 1;
					ans[i][j] = cnt;
				}
				else {
					ans[i][j] = cnt;
				}
			}
		}

		if (strawberry == 0) {
			empties[eindex] = i;
			eindex++;
			cnt--;
		}
		else if (strawberry >= 1 && eindex > 0) {
			rep(j, W) {
				rep(k, eindex) {
					ans[empties[k]][j] = ans[i][j];
				}
			}
			eindex = 0;
		}
	}

	if (eindex > 0) {
		int inedx = empties[0] - 1;
		rep(j, W) {
			rep(k, eindex) {
				ans[empties[k]][j] = ans[inedx][j];
			}
		}
	}

	rep(i, H) {
		cout << ans[i][0];
		repc(j, 1, W - 1) cout << ' ' << ans[i][j];
		cout << endl;
	}

	return 0;
}


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

int main(){
   int N;
   int temp;
   cin >> N;
   for(int i = 1;i <= N;i++){
       temp = i;
       if(i%3 == 0){
           cout << " " << i;
       }else{
           while(temp){
               if(temp%10 == 3){
                   cout << " " << i;
                   break;
               } 
               temp /= 10;
               } 
           }
       }
       cout << endl;
       return 0;
   }

Measured memory_bytes: 1164
from queue import deque


S = deque(input())
mod = 2019
T = [0] * mod
T[0] = 1
a, b = 0, 1

for _ in range(len(S)):
    s = int(S.pop())
    a = a + s * b
    a = a % mod
    T[a] += 1
    b = b * 10
    b = b % mod
    
print(sum((i * (i - 1) // 2 for i in T)))

Measured memory_bytes: 11152
/*



やり方：
	・変換表のデータを入力。
	・


*/

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

int main()
{
	int n,m;
	int i;
	int length;
	int check;
	char data[2][71]={'\0','\0'};
	char answer[1000001];
	char str[1001];
	while(1){
		//printf("nを入力してください。\n");
		fgets(str, sizeof(str), stdin);
		sscanf(str, "%d", &n);
		//printf("nは%d, %d回ループ\n\n",n,n);
		if(n==0){
			break;
		}
		for(i=0; i<n; i++){
			fgets(str, sizeof(str), stdin);
			length=strlen(str);
			str[length-1]='\0';
			//printf("str = %s\n\n", str);
			sscanf(str, "%c %c", &data[0][i], &data[1][i]);
			//printf("data[0][%d] = %c\ndata[1][%d] = %c\n\n", i, data[0][i], i, data[1][i]);
			//printf("i = %d\n", i);
			//printf("%s\n", data);
		}
		//printf("mを入力してください。\n");
		fgets(str, sizeof(str), stdin);
		sscanf(str, "%d", &m);
		//printf("mは%d, %d回ループ\n\n",m,m);
		for(i=0; i<m; i++){
			fgets(str, sizeof(str), stdin);
			length=strlen(str);
			str[length-1]='\0';
			sscanf(str, "%c", &answer[i]);
			for(check=0; check<n; check++){
				//printf("checkループ中。 %d/%d\n", check+1,n);
				//printf("今の変換表\は、before:%c, after:%c\n\n", data[0][check], data[1][check]);
				if(answer[i]==data[0][check]){
					//printf("%cを ",answer[i]);
					answer[i]=data[1][check];
					//printf("%cに変換!\n\n",answer[i]);
					break;
				}
			}
			//printf("ループ終端。i は %dになる\n", i+1);
		}
		printf("%s\n", answer);
	}
	return 0;
}

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

int main() {

    ll n, h;
    cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    
    ll ans = 0;
    for(int i=n-1; i>=0; --i){
        if(b[i] > a[n-1]){
            h -= b[i];
            ans++;
        }
        else{
            break;
        }
        if(h <= 0){
            break;
        }
    }
    if(h > 0)
        ans += (h + a[n-1] -1) / a[n-1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split();
        string ans = "";
        for(int i = 0; i < 2 * N; i++)
        {
            if (i % 2 == 0) { ans += input[0][i/2]; }
            else { ans += input[1][i/2]; }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
X = int(input())

A = 0

while True:
    temp = X - A ** 5
    if temp >= 0:
        B = int(pow(temp, 1/5))
    else:
        B = -int(pow(-temp, 1/5))
    if A ** 5 + B ** 5 == X:
        print(A, -B)
        break
    A += 1


Measured memory_bytes: 62320
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i;
    cin>>n>>k;
    vector<ll> v(n),pre(n,0);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    pre[0]=v[0];
    for(i=1;i<n;i++)
    {
        pre[i]=pre[i-1]+v[i];
    }
    cout<<pre[k-1];
    return 0;
     
}

Measured memory_bytes: 3668
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# D - Friend Suggestions

from collections import deque

n, m, k = map(int, input().split())

adj = {a: [] for a in range(1, n+1)}
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

# 連結成分

connOf = {}
for a in range(1, n+1):
    if a in connOf:
        continue
    conn = set()
    queue = deque()
    queue.append(a)
    while len(queue) > 0:
        p = queue.popleft()
        if p not in conn:
            conn.add(p)
            connOf[p] = conn
            queue.extend(adj[p])

# (同じ連結成分中の)ブロック関係

block = {a: [] for a in range(1, n+1)}
for i in range(k):
    c, d = map(int, input().split())
    if c in connOf[d]:
        block[c].append(d)
        block[d].append(c)

# 友達候補 = 同じ連結成分 - 自分 - 友達関係 - ブロック関係

nCandidate = [len(connOf[a]) - 1 - len(adj[a]) - len(block[a])
  for a in range(1, n+1)]
print(' '.join(map(str, nCandidate)))


Measured memory_bytes: 126308
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports, dead_code, non_camel_case_types)]

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// お約束
use std::collections::{HashMap, BinaryHeap, BTreeMap};
const MOD : usize = 1_000_000_007;
macro_rules! myprint {($t:expr) => {println!("{}", $t);};}
macro_rules! debug {($t:expr) => {println!("{:?}", $t);};}

// エントリーポイント
fn main() {
    input! {
        A : isize,
        S : String
    }
    if A < 3200 {
        myprint!("red")
    } else {
        myprint!(S)
    }
}


Measured memory_bytes: 4352
def main():
    s = input()
    q = int(input())

    rule = 0
    pre, suf = '', ''
    for _ in range(q):
        query = input()
        if query[0] == '1':
            rule += 1
        else:
            if rule % 2 == 0:
                if query[2] == '1':
                    pre = query[4] + pre
                else:
                    suf += query[4]
            else:
                if query[2] == '1':
                    suf += query[4]
                else:
                    pre = query[4] + pre

    s = pre + s + suf
    print(s if rule % 2 == 0 else s[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
int gcd(int x,int y){
	return (x%y==0)?y:gcd(y,x%y);
}
int lcm(int x,int y){
	return x/gcd(x,y)*y;
}
int n;
LL t;
int a[3010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		t+=a[i]-1;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    int[] a=new int[N];
    for(int i=0;i<N;i++){
      a[i]=scan.nextInt();
    }
    int count4=0;
    int count2=0;
    int odd=0;
    for(int i=0;i<N;i++){
      if(a[i]%4==0){
        count4++;
      }
      else if(a[i]%2==0){
        count2++;
      }
      else{
        odd++;
      }
    }
    if(count2>=1){
      odd++;
    }
    if(odd-1<=count4){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }    
  }
}

Measured memory_bytes: 50280
import itertools
import math

LIM = 50



def do():
    ans = 0
    A,B,C,D,E,F= list(map(int,input().split(" ")))
    waters = []
    for i in range(31):
        for j in range(31):
            water = A*i* 100+B*j* 100
            if water <= F and water != 0:
                waters.append(water)
    solts = []
    for i in range(3000):
        for j in range(3000):
            solt = C * i + D * j
            if solt > E * F /100:
                break
            solts.append(solt)

    max_nodo = -1
    ans_water = 0
    ans_solt = 0
    for solt in solts:
        for water in waters:
            if solt/(water/100) <= E:
                if (100 * solt)/(solt+water) >= max_nodo and water + solt <= F:
                    max_nodo =(100 * solt)/(solt+water)
                    ans_water = water + solt
                    ans_solt = solt

    print(ans_water,ans_solt)





if __name__ == "__main__":
    do()

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, L, ans;
    scanf("%d %d", &N, &L);

    ans = 0;

    REP(int, i, 1, N+1){
        ans += L + i - 1;
    }
    if ( L >= 0 ) ans -= L;
    else if ( L <= - N ) ans -= L + N - 1;

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#define MAX 1024
char *tolowerstr(char*s){
    int i;
    for(i=0;s[i]!='\0';i++){
        s[i]=tolower(s[i]);
    }
    return s;
}
int main(void){
  char w[MAX],t[MAX];
  int c=0;
  scanf("%s",w);
  tolowerstr(w);
  while(scanf("%s",t),strcmp(t,"END_OF_TEXT")!=0){
      if(strcmp(w,tolowerstr(t))==0){
          ++c;
      }
  }
  printf("%d\n",c);
  return 0;  
}


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

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> arr(n);
    for (auto &el: arr) cin >> el.first;
    for (auto &el: arr) cin >> el.second;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (arr[i].first > arr[i].second) 
            ans += arr[i].first - arr[i].second;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0;i < N; i++) {
    cin >> A[i];
  }
  int minv = A[0];
  int maxv = A[0];
  for (int i = 1; i < N; i++) {
    minv = min(minv, A[i]);
    maxv = max(maxv, A[i]);
  }
  cout << abs(maxv - minv) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        int n = s.length();

        for (int i = 0; i < n; i++) {
            System.out.print("x");
        }
        System.out.println();
    }
}

Measured memory_bytes: 25044
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int N, A, B, C;
vector<int> l;

int get_sum(vector<int>& yes) {
	int s = 0;

	for (auto e : yes)
		s += e;

	return s;
}

int solve(vector<int>& aset, vector<int>& bset, vector<int>& cset) {
	int a = 10 * (aset.size() - 1) + abs(get_sum(aset) - A);
	int b = 10 * (bset.size() - 1) + abs(get_sum(bset) - B);
	int c = 10 * (cset.size() - 1) + abs(get_sum(cset) - C);

	return a + b + c;
}

int back(int cnt, vector<int>& aset, vector<int>& bset, vector<int>& cset) {
	if (cnt == N) {
		if (aset.size() == 0 || bset.size() == 0 || cset.size() == 0)
			return INT_MAX;
		else
			return solve(aset, bset, cset);
	}
	else {
		int a, b, c, d;

		aset.push_back(l[cnt]);
		a = back(cnt + 1, aset, bset, cset);
		aset.pop_back();

		bset.push_back(l[cnt]);
		b = back(cnt + 1, aset, bset, cset);
		bset.pop_back();

		cset.push_back(l[cnt]);
		c = back(cnt + 1, aset, bset, cset);
		cset.pop_back();

		d = back(cnt + 1, aset, bset, cset);

		return min(min(a, b), min(c, d));
	}
}

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

	cin >> N >> A >> B >> C;

	vector<int> a, b, c;

	for (int n = 0; n < N;n++) {
		int tmp;
		cin >> tmp;
		l.push_back(tmp);
	}

	cout << back(0, a, b, c);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int p = 1;
    int ans = 0;
    int A,B;

    cin >> A >> B;

    while(p < B){
        p += A - 1;
        ans++;
    }

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



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = list(map(int, input().split()))

result = True
sum = 0
a.sort(reverse=True)

for i in range(n):
    sum += a[i]

threshould = sum / 4 / m

for i in range(m):

    if a[i] < threshould:
        result = False
if result:
    print("Yes")
else:
    print("No")


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

for _ in range(K):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N: B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    B,A = A,B
    if min(A) == N:
        break
print(*A)


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

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
 
int a[3][N], dp[3][N];
 
int main() {
    int n;
    cin >> n;
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[j][i];
        }
    } 
 
    dp[0][0] = a[0][0];
    dp[1][0] = a[1][0];
    dp[2][0] = a[2][0];
    for (int i = 1; i < n; i++) {
        dp[0][i] = a[0][i] + max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = a[1][i] + max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = a[2][i] + max(dp[0][i - 1], dp[1][i - 1]);
    }
 
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(ans, dp[i][n - 1]);
    }
 
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560