akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a)

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

struct UnionFind{
    int size;
    vector<int> par;
    vector<int> rank;
    UnionFind(int x){
        size=x;
        par=vector<int> (x);
        rank=vector<int> (x,1);
        for (int i=0;i<x;i++){
            par[i]=i;
        }
    }
    int root(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=root(par[x]);
        }
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y){
            return;
        }
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
        }
        if(rank[x]==rank[y]){
            rank[x]++;
        }
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;
            rank[i]=1;
        }
    }
};

int main(){
	int n, k, l; cin >> n >> k >> l;
	UnionFind road(n), train(n);
	int q, p;
	rip(i, k, 0){
		cin >> p >> q;
		road.unite(p-1, q-1);
	}
	rip(i,l,0){
		cin >> p >> q;
		train.unite(p-1, q-1);
	}
	map<ll, vector<int>> mp;
	rip(i,n,0){
		ll now = (ll) road.root(i) * n + train.root(i);
		if(mp.count(now)){
			mp[now].push_back(i);
		}else{
			mp[now] = vector<int>(1, i);
		}
	}
	vector<int> ans(n);
	for(auto i:mp){
		int connect = i.second.size();
		for(auto j:i.second){
			ans[j] = connect;
		}
	}
	vdeb(ans);
}

Measured memory_bytes: 24576
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    char c;
    bool odd = true;
    while (std::scanf("%c", &c) == 1) {
        if (odd) {
            std::putchar(c);
        }
        odd = !odd;
    }
    return 0;
}

Measured memory_bytes: 256
def kaibun(s):
    #print('[debug]',s)

    for i in range(len(s) // 2):
        if s[i] != s[len(s)-1 - i]:
            return False
    
    return True

def main():
    S = input()
    N = len(S)
    if kaibun(S) == False:
        #print('[debug]','if 1')
        print('No')
        return

    if kaibun(S[0:(N-1)//2]) == False:
        #print('[debug]','if 2')
        print('No')
        return
    if kaibun(S[(N+3)//2 - 1:N]) == False:
        #print('[debug]','if 3')
        print('No')
        return

    print('Yes')

if __name__ == '__main__':
    main()




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X ;
  cin >> A >> B >> C >> X;
  int d =0;
  
  for(int a = 0; a<=A; a++){
    for(int b = 0; b<=B; b++){
      for(int c = 0; c<=C; c++){
  if(X == 500*a + 100*b + 50*c) d++;
      }
    }
  }
  
  cout <<  d << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main(){
  int n,buf,minv,maxv;
  cin >> n;

  cin >> minv;
  cin >> buf;
  maxv = buf-minv;
  minv = std::min(minv,buf);

  for(int i=0;i<n-2;i++){
    cin >> buf;
    maxv=std::max(maxv,buf-minv);
    minv=std::min(minv,buf);
  }
  cout << maxv << endl;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = Integer.parseInt(sc.next());
		String op = sc.next();
		int b = Integer.parseInt(sc.next());
		
		if (op.equals("+")) {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
		
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int k;
    int lower, upper;
    cin>>k;
    cin>>lower>>upper;
    int dist = 0;
    while (dist < lower) dist += k;
    if (dist > upper) printf("NG");
    else printf("OK");
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

ll n,m,T,k,q;
const ll big = 1000000007;
const ll big2 = 998244353;

string S[3];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,e;
    cin >> n;

    for(int c1 = 0; c1 < 3; c1++){
        cin >> S[c1];
    }

    ll ans = 0;
    for(int c1 = 0; c1 < n; c1++){
        ll eq = 0;
        eq += (S[0][c1]==S[1][c1]);
        eq += (S[0][c1]==S[2][c1]);
        eq += (S[1][c1]==S[2][c1]);
        if(eq == 0)ans += 2;
        if(eq == 1)ans++;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))
a_list = sorted(a_list, reverse=True)

# N組できる
x_list = a_list[: 2 * N]
ans = sum([x for i, x in enumerate(x_list) if i % 2 == 1])

print(ans)


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

p = 0
ans = 0

for i in range(N):
    if A[i] <= p:
        ans += A[i]
        p = B[i]
    elif A[i] <= B[i]+p:
        ans += A[i]
        p = B[i]-(A[i]-p)
    else:
        ans += B[i]+p
        p = 0
    

if A[N] <= p:
    ans += A[N]
else:
    ans += p

print(ans)

Measured memory_bytes: 18476
<?php
    $n = str_split(trim(fgets(STDIN)));
    if($n[0] == $n[1] && $n[1] == $n[2]){
        echo "Yes";
    }elseif($n[1] == $n[2] && $n[2] == $n[3]){
        echo "Yes";
    }else{
        echo "No";
    }
?>

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

using namespace std;

int table[10][10];

int check(vector<int> &vec){
	int cur = 0;
	for(auto v : vec){
		cur = table[cur][v];
	}
	return cur;
}

int main(){
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> table[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < 10000; i++){
		vector<int> vec;
		int num = i;
		for(int j = 0; j < 4; j++){
			vec.push_back(num % 10);
			num /= 10;
		}
		reverse(vec.begin(), vec.end());
		vec.push_back(check(vec));
		//for(auto v : vec) cout << v << " ";
		//cout << endl;

		bool flg = true;	
		for(int i = 0; flg && i < 5; i++){
			for(int j = 0; j < 10; j++){
				if(vec[i] == j) continue;
				int tmp = vec[i];
				vec[i] = j;
				if(check(vec) == 0){
					flg = false;
					break;
				}
				vec[i] = tmp;
			}
		}

		for(int i = 0; flg && i < 4; i++){
			if(vec[i] != vec[i + 1]){
				swap(vec[i], vec[i + 1]);
				if(check(vec) == 0){
					flg = false;
					break;
				}
				swap(vec[i], vec[i + 1]);
			}
		}
		if(!flg){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
#define per(i,a,b) for (int i=(a); i>=int(b); i--)
using namespace std;

const int maxn = 1005, maxm = 5005;
int f[maxn][maxm], x[maxn], y[maxn], n, p;
vector<int> e[maxn];

void dfs(int u) {
	f[u][0] = 0;
	for (auto v : e[u]) {
		dfs(v);
		per (i, x[u], 0) {
			int A = (i >= x[v] ? f[u][i-x[v]] + y[v] : 1e9 + 99);
			int B = (i >= y[v] ? f[u][i-y[v]] + x[v] : 1e9 + 99);
			f[u][i] = min(A, B);
		}
	}
	rep (i, 0, x[u]) y[u] = min(y[u], f[u][i]);
}

int main() {
	scanf("%d", &n);
	rep (i, 2, n) {
		scanf("%d", &p);
		e[p].push_back(i);
	}
	rep (i, 1, n) scanf("%d", &x[i]);
	memset(f, 0x3f, sizeof f);
	memset(y, 0x3f, sizeof y);
	dfs(1);
	if (y[1] < 1e9) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 19968
#include <bits/stdc++.h>
#define REP(i,n) for(LL i=0;i<(LL)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<LL,LL>
#define pll pair<LL,LL>

using namespace std;

LL D;
map<LL,LL> cnt0;
map<LL,LL> cnt1;

LL comb(LL k,LL d){
    LL nine=1;
    REP(i,k)nine*=10;
    nine--;
    vector<LL> ele;
    while(nine>0){
        LL p=(10-(abs(d)%10))*(d>0 ? -1:1);
        if(abs(p)==10)p=0;
        d = (d +p*nine)/10;
        ele.push_back(-p);
        nine/=100;
    }
    LL res=0;
    if(d==0){
        res=cnt0[ele[0]];
        for(LL i=1;i<ele.size();i++)res*=cnt1[ele[i]];
        if(k%2==0)res*=10;
    }
    return res;

}

int main(){

    cin>>D;
    for(LL i=1;i<10;i++){
        REP(j,10){
            cnt0[j-i]=cnt0[j-i]+1;
        }
    }
    REP(i,10)REP(j,10)cnt1[i-j]=cnt1[i-j]+1;

    LL ans=0;
    for(LL i=1;i<20;i++)ans+=comb(i,D);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll time10[20];
ll cnt[10];
void init() {
	rep(i, 10) {
		cnt[i] = 10 - i;
	}
	time10[0] = 1;
	rep1(i, 19) {
		time10[i] = time10[i - 1] * 10;
	}
}
int main() {
	init();
	ll d; cin >> d;
	ll ans = 0;
	Rep1(i,2, 18) {
		ll sum = 1; ll c = d;
		rep1(j, i / 2) {
			ll dif = time10[i - j] - time10[j - 1];
			ll r = (c / time10[j - 1]) % 10; r = (r + 10) % 10;
			ll t = 10 - r; if (t == 10)t = 0;
			c -= t * dif;
			if (abs(c) >= dif&&t!=0) {
				c += 10 * dif;
				t = 10 - t;
				sum *= cnt[t];
			}
			else {
				if (j == 1)sum *= cnt[t] - 1;
				else sum *= cnt[t];
			}
		}
		if (i % 2)sum *= 10;
		if(!c)ans += sum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
class UnionFind :
    def __init__(self, size) :
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        return self.size[self.root(index)]

    def getComponent(self) :
        return self.component

N, M, K = map(int, input().split())
AB = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(M)]
CD = [tuple(map(lambda a: int(a) - 1, input().split())) for _ in range(K)]

friends = UnionFind(N)
for a, b in AB:
    friends.union(a, b)

ans = [0] * N
for i in range(N):
    ans[i] = friends.sizeOfSameRoot(i) - 1
for a, b in AB:
    ans[a] -= 1
    ans[b] -= 1
for c, d in CD:
    if friends.isSameRoot(c, d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)


Measured memory_bytes: 38768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int gcd = gcd(a, b);

//		if(a % b == 0 && c != 0){
		if(c % gcd != 0){
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}

//		for(int i = 1; i <= 20; i++){
//			System.out.println(a*i%b);
//		}
	}

	static int gcd(int a, int b){
        int tmp;

        while (a % b != 0)
        {
            tmp = b;
            b = a % b;
            a = tmp;
        }
        return b;
    }
}

Measured memory_bytes: 23124
#import sys
#sys.setrecursionlimit(100000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for i in range(K):
    if N - K - i >= 0:
        print(cmb(K-1, i) * cmb(A, i+1) % MOD)
    else:
        print(0)


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, d[222222], sum[222222] = {}, res = -INF;
    bool flag = false;
    map<int, vector<int>> m;
    cin>>n;
    rep(i, n){
        cin>>d[i];
        sum[i + 1] = sum[i] + d[i];
        m[sum[i]].push_back(i - 1);
    }
    m[sum[n]].push_back(n - 1);
    each(p, m){
        if(p.second.size() == 1) continue;
        flag = true;
        sort(all(p.second));
        chmax(res, p.second[p.second.size() - 1] - p.second[0]);
    }
    if(flag) cout<<res<<endl;
    else cout<<0<<endl;
}



Measured memory_bytes: 28244
S = input()
K = int(input())

pre_c = ''
flg = 0
count = 1

f_c = S[0]
f_e = S[-1]
t = []

for c in S:
  if c == pre_c:
    count += 1
  elif pre_c == '':
    pass
  else:
    t.append(count)
    count = 1
  pre_c = c

t.append(count)
count_1 = 0
for i in t:
  count_1 += i // 2
  
if f_c == f_e and len(t) != 1:
  t[0] = t[0] + t[-1]
  t.pop(-1)

count_2 = 0
for i in t:
  count_2 += i // 2
  
if len(S) == 1:
  print(K // 2)
elif len(t) == 1:
  print(K * len(S) // 2)
else:
  print(count_1 + count_2 * (K - 1))
  

    
  

Measured memory_bytes: 3064
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    N, K = wi()
    mod = 10 ** 9 + 7
    s = 0
    s_1 = 0
    a = []
    b = 0
    ans = 0
    for i in range(N+1):
        b += i
        a.append(b)
    for i in range(K, N+1):
        s = a[i-1]
        s_1 = a[N]-a[N-i]
        ans += s_1-s + 1
    print(ans % mod + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81660
#include <iostream>
using namespace std;
const int MaxN=100001;
long long int ans=1;
long long int arr[MaxN];
int main(){
  int N;
  int i;
  cin>>N;
  for(i=0;i<N;i++)cin>>arr[i];
  for(i=0;i<N;i++){
   	if(arr[i]==0){
    	cout<<0;
        return 0;
    }
  }
  long long int MAX=1e18;
  for(i=0;i<N;i++){
   	if(arr[i]>(MAX/ans)){
      cout<<-1;
      return 0;
    }
    ans*=arr[i];
  }
  if(ans>MAX){
   	cout<<-1; 
  }
  else cout<<ans;
  
  
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H + 2, vector<char>(W + 2, '-'));
    REP (i, 1, H + 1) REP (j, 1, W + 1) cin >> S[i][j];
    REP (i, 1, H + 1) {
        REP (j, 1, W + 1) {
            if (S[i][j] == '#') {
                cout << S[i][j];
            } else {
                int tmp = 0;
                REP (y, -1, 2) REP (x, -1, 2) {
                    if (S[i + y][j + x] == '#') tmp++;
                }
            cout << tmp;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0133
{
    public class Program

    {
        public const int SIZE_H = 8;
        public const int SIZE_W = 8;

        public static void Main(string[] args)
        {
            string[] line = new string[SIZE_H];
            for (int i = 0 ; i < SIZE_H ; i++)
            {
                line[i] = RSt();
            }
            Console.WriteLine(90);
            line = Rotate(line);
            foreach (var item in line) Console.WriteLine(item);
            Console.WriteLine(180);
            line = Rotate(line);
            foreach (var item in line) Console.WriteLine(item);
            Console.WriteLine(270);
            line = Rotate(line);
            foreach (var item in line) Console.WriteLine(item);
        }

        public static string[] Rotate(string[] line)
        {
            int newH = line[0].Length;
            int newW = line.Length;
            string[] newline = new string[newH];
            for (int i = 0 ; i < newH ; i++)
            {
                for (int j = 0 ; j < newW ; j++)
                {
                    newline[i] += line[(newW - 1) - j][i];
                }
            }
            return newline;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

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

  for (int i = 0; i < n - k; i++) {
    cout << (a[i] < a[i + k] ? "Yes" : "No") << '\n';
  }

  return 0;
}



Measured memory_bytes: 4036
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

int N; string s;
bool a[100010],b[100010];


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;

    N=s.length();
    int i;
    for (i=1; i<=N; i++){
        a[i]=s[i-1]-'0';
        b[i]=a[i]^a[i-1];
    }


    int res=N;
    for (i=1; i<=N; i++)
        if (b[i]) res=min(res,max(i-1,N+1-i));

    cout << res <<  "\n";
	return 0;
}


Measured memory_bytes: 720
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$N = $in->nextInt();

$i = 1;
while($i * 2 <= $N) {
	$i *= 2;
}

$out->println($i);

?>


Measured memory_bytes: 4604
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String T = sc.next();
      
      // ?の置換
      String[] arr = T.split("");
      int len = T.length();
      StringBuilder sb = new StringBuilder("");
      
      for(int i = 0; i < len; i++){
        if(arr[i].equals("?")){
          sb.append("D");
        }else{
          sb.append(arr[i]);
        }
      }
      
      // 出力
      System.out.println(sb);
    }
    

}

Measured memory_bytes: 65784
r, c, *D = map(int, open(0).read().split())
A = [D[i:i+c] for i in range(0, r*c, c)]
A.append([0 for _ in range(c+1)])
for i in range(r):
    A[i].append(sum(A[i]))
    for j in range(c+1):
        A[r][j] += A[i][j]
for i in range(r+1):
    print(' '.join(map(str, A[i])))



Measured memory_bytes: 6132
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	a, b := make([]int, N), make([]int, N)
	c, d := make([]int, M), make([]int, M)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&c[i], &d[i])
	}

	res := make([]int, N)
	for i := 0; i < N; i++ {
		minValue := 2147483647
		minIndex := 0
		for j := 0; j < M; j++ {
			v := abs(a[i]-c[j]) + abs(b[i]-d[j])
			if minValue > v {
				minValue = v
				minIndex = j
			}
		}
		res[i] = minIndex + 1
	}

	for i := 0; i < N; i++ {
		fmt.Println(res[i])
	}
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N;
  A = 2;
  
  for (int i = 0; i < N; i++) {
    A = A * 2;
      if ( N < A ) {
        break;
      }
  }
  if (1 < N) 
    cout << A / 2 << endl;
  else
    cout << 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main
{
    static class Len
    {	
	int a[]; //= new int[2000010];
	int b[]; //= new int[2000010];
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
	PrintStream out = new PrintStream(System.out);

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(100);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	out.println(s);
	//	out.print(len.b[i]+" ");
	//out.println(len.b[n]);

	/*
	for(i=1; i<n; i++)System.out.print(len.b[i]+" ");
	System.out.println(len.b[n]);*/

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	//for(i=0; i<=max; i++)c[i]=0;
	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

Measured memory_bytes: 102000
n = gets.chomp
s = gets.chomp.split(//)

ans = 10000000

a = 0
b = s.count{|e| e == '.'}

s.size.times do |i|
  if s[i] == '#'
    a += 1
  else
    b -= 1
  end
  count = a + b
  # p count
  ans = [ans, count].min
end



200000.times do
  s.shift if s[0] == '.'
  s.pop if s[-1] == '#'
end

a = 0
b = 0

s.each do |c|
  a += 1 if c == '#'
  b += 1 if c == '.'
end

puts [ans, a, b].min


Measured memory_bytes: 18844
import numpy as np
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n>=m:
    print(0)
else:
    b = sorted(x)
    d = list(np.diff(b))
    d.sort(reverse=True)
    sum = sum(d[:n-1])
    print(b[m-1]-b[0]-sum)

Measured memory_bytes: 23060
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

ans = 0
for _ in range(N):
    A = list(map(int,input().split()))
    sum_value = 0
    for i in range(M):
        sum_value += A[i]*B[i]
    if sum_value+C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

int main() {
    ll a,b,x;cin>>a>>b>>x;
    
    ll ans = b/x;
    
    if (a%x == 0){ans-=a/x;ans++;}
    else ans-=a/x;
    
    cout << ans << endl;
    return 0;
}






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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	int pa=a&1,pb=b&1,pc=c&1;
	if(pa==pb&&pb==pc){
		int t=max({a,b,c});
		cout<<(3*t-a-b-c)/2<<'\n';
		return 0;
	}
	if(pa==pb) a++,b++;
	else if(pb==pc) b++,c++; 
	else if(pc==pa) c++,a++;
	int t=max({a,b,c});
	cout<<(3*t-a-b-c)/2+1<<'\n';
}



Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
int main(void){
 
    int n,i,ans=0;
    char sar[321],ring[321],temp[321];
 
    scanf("%s%d",sar,&n);
 
    for(i=0;i<n;i++){
        scanf("%s",ring);
        strcpy(temp,ring);
       strcat(ring,temp);
 
        if(strstr(ring,sar) != NULL) ans++;
    }
 
    printf("%d\n",ans);
 
    return 0;
}


Measured memory_bytes: 2104
n = int(input())
s = input()
x = int(s, 2)
pcx = s.count("1")
pc1 = x % (pcx - 1) if pcx > 1 else 0
pc2 = x % (pcx + 1)

def f(j):
    cnt = 0
    while j:
        j %= bin(j).count("1")
        cnt += 1
    return cnt

for i, y in enumerate(s):
    k = n - 1 - i
    if y == "0":
        print(f((pc2 + pow(2, k, pcx + 1)) % (pcx + 1)) + 1)
    elif pcx > 1:
        print(f((pc1 - pow(2, k, pcx - 1)) % (pcx - 1)) + 1)
    else:
        print(0)



Measured memory_bytes: 9400
# input
N, K = map(int, input().split())
D = []
A = []
for _ in range(K):
    D.append(int(input()))
    A.extend(list((map(int, input().split()))))

# process
ans = 0
for i in range(1, N+1):
    if not i in A:
        ans += 1

# output
print(ans)


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

using namespace std;

#define ll long long
#define pii pair<int, int>
#define MAX 200005

int m[MAX][3];
ll dp[MAX][3];


int main() {

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

    dp[1][0] = m[1][0];
    dp[1][1] = m[1][1];
    dp[1][2] = m[1][2];

    for(int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1] , dp[i - 1][2]) + m[i][0];
        dp[i][1] = max(dp[i - 1][0] , dp[i - 1][2]) + m[i][1];
        dp[i][2] = max(dp[i - 1][0] , dp[i - 1][1]) + m[i][2];
    }

    cout << max(dp[n][0] , max(dp[n][1], dp[n][2])) << '\n';


    return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

Int n, l[100001], r[100001], cnt[100001] = {0}, d[100003] = {0};
bool b[100001] = {0};

int main(){
	for(int i = 1; i < 100001; i+=2){
		if(sosuu(i) && sosuu((i+1)/2)) b[i] = 1;
		d[i+2] = d[i] + b[i];
	}
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> l[i] >> r[i];
		cnt[i] = d[r[i]+2] - d[l[i]];
	}
	
	for(int i = 0; i < n; i++){
		cout << cnt[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3840
var a,b,la,lb,ra,rb:Longint;
begin
read(a,b);
la:=25*a;ra:=25*a+25;
lb:=20*b;rb:=20*b+20;
if la<lb then la:=lb;
if ra>rb then ra:=rb;
if la mod 2=1 then inc(la);
if la<ra then writeln(la div 2)else writeln(-1);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    int flag = 0;
    int i;
    for(i=a;i<=b;i++){
        if(i%k==0){
            flag = 1;
            break;
        }
    }
    if(!flag){
        cout << "NG" << endl;
    }
    else{
        cout << "OK" << endl;
    }
}   

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // int t;
    // cin >> t;
    // while(t--){
    	solve();
    // }
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void){
    int N;
    vector <int> t, x, y;
    int sub;
    bool judge = true;
    
    t.push_back(0);
    x.push_back(0);
    y.push_back(0);
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> sub;
        t.push_back(sub);
        cin >> sub;
        x.push_back(sub);
        cin >> sub;
        y.push_back(sub);
    }
    
    for(int i = 0; i < N; i++){
        int a1 = abs(x[i + 1] - x[i]);
        int a2 = abs(y[i + 1] - y[i]);
        int a3 = t[i + 1] - t[i];
        // int a4 = a1 % 2;
        // int a5 = a2 % 2;
        // int a6 = a3 % 2;
        
        if(a1 + a2 > a3){
            judge = false;
            break;
        }
        
        int cnt = a3;
        cnt -= a1 + a2;
        if(cnt % 2 != 0){
            judge = false;
            break;
        }
    }
    
    if(judge){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1<<29;
/****** define constant end ********/


/****** define variable start ******/
ll a, b;
/******* define variable end *******/
ll solve() {
    cin >> a >> b;
    for(ll i = 1; i <= 1100; i++){
        if(floor(i * 0.08) == a && floor(i * 0.1) == b){
            cout << i <<endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    
    return (int)end_solve;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int f,s;
    if(c%b==0) f=c/b;
    else f=(c+b-1)/b;
    if(a%d==0) s=a/d;
    else s=(a+d-1)/d;
    if(f<s) cout<<"Yes"<<endl;
    else if(f>s) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

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

const int MAX = 100;
const int BIG = 2147483647;
int main() {
	int N, a[MAX], min = BIG;
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	
	for (int i = -100;i <= 100;i ++) {
		int cost = 0;
		for (int j = 0;j < N;j ++) cost += (a[j] - i) * (a[j] - i);
		if (cost < min) min = cost;
	}
	
	cout << min;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int x,y,z;
        for(int i=1;i<=num;i++){
            x=i/10;
            y=i/100;
            z=i/1000;
            if(i%3==0 ||x%10==3 ||y%10==3 ||z%10==3||i%10==3){
                System.out.print(" "+i);
            }
            
        }
        System.out.println("");
        
    }
}


Measured memory_bytes: 29008
A,B,C = list(map(int, input().split()))

#容器 1 には水を A ミリリットルまで入れることができ、水が Bミリリットル入っています。
#容器 2には水が Cミリリットル入っています。
#容器 2から容器 1に入るだけ水を移します。
#容器 2の中には何ミリリットルの水が残るでしょうか。

if C-(A-B)>0:
    print(C-(A-B))
else:
    print("0")

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

int main(){
    //個数の指定
    int N,M,C;
    int count;
    cin >> N >> M >> C;
    vector<int> dots(N);
    vector<int> A(M);
    vector<int> B(M);
    for(int i = 0;i < M;i++){
        cin >> B.at(i);
    }
    //vectorを作りカウント
    for(int k = 0;k < N;k++){
        for(int i = 0;i < M;i++){
        cin >> A.at(i);
        dots.at(k) += A.at(i) * B.at(i); //AとBの内積を取りdotsベクトルの要素とする
    }
    if(dots.at(k) + C > 0){
        count++;
    }
}
cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

bool binarySearch(int* A, int key);
int n;

int main(){

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

    int counter = 0;
    for(int i=0; i<q; i++){
        if(binarySearch(S, T[i])) counter++;
    }

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

bool binarySearch(int* A, int key){
    int left = 0;
    int right = n;
    while(left < right){
        int mid = (left + right)/2;
        if(A[mid]==key) return true;
        else if(key < A[mid]) right = mid;
        else left = mid + 1;    //midを調べる必要はない
    }
    return false;
}


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

int main(){
	ll n, x, t, ans;
  	cin>>n>>x>>t;
  	ans = ceil(n*1.0/x)*t;
  	cout<<ans;
  	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <algorithm>

int x, y, X, Y;
int ans;

int main(void)
{
	scanf("%d%d", &x, &y);

	X = (x < 0 ? -x : x);
	Y = (y < 0 ? -y : y);
	ans = (Y - X)*(Y - X < 0 ? -1 : 1);
	if (X < Y)
	{
		if (x < 0) { ++ans; }
		if (y < 0) { ++ans; }
	}
	else if (X == Y)
	{
		if (x != y) { ++ans; }
	}
	else
	{
		if (x > 0) { ++ans; }
		if (y > 0) { ++ans; }
	}

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<int> edge[605];
double d[605];
int n,m;
double dp(int x){
    for(int i=1;i<=n;i++) d[i]=0;
    for(int i=n-1;i>=1;i--){
        if(x==i&&edge[i].size()==1){
            d[i]=100000000.0;
            continue;
        }
        double sum=0,sz=(double)(edge[i].size()-(x==i)),mx=0;
        for(int j=0;j<edge[i].size();j++){
            int v=edge[i][j];
            d[i]+=(1.0+d[v])/sz;
            mx=max(mx,(1.0+d[v])/sz);
        }
        if(x==i) d[i]-=mx;
    }
    return d[1];
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        edge[u].push_back(v);
    }
    double ans=dp(0);
    for(int i=1;i<=n;i++){
        ans=min(ans,dp(i));
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 1408
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll a,b;cin>>a>>b;
  if(b==1)
  {cout<<"0";return 0;}
  ll s=0,t=1;
  s+=a;
  while(s<b)
  {
     --s;
     s+=a;
     ++t;
  }
  cout<<t;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,k,s,m=1e9,i,a[100005];
int main(){
	scanf("%d%d%d",&n,&k,&s);
	if(s>n){
		for(i=1;i<=k;++i)a[i]=s;
		for(;i<=n;++i)a[i]=1,--a[k];
	}else{for(i=1;i<=k;++i)a[i]=s;for(;i<=n;++i)a[i]=m;}
	for(i=1;i<=n;++i)printf("%d%c",a[i],i==n?'\n':' ');
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

string trans(string s)
{
  string s_tr = string(26, '0');
  string trans_s = "";

  int now = 0;
  for(int i = 0; i < s.length(); ++i)
  {
    int ind = (int)(s[i] - 'a');
    if (s_tr[ind] == '0')
    {
      s_tr[ind] = (char)(now + 'a');
      now++;
    }
    trans_s += s_tr[ind];
  }
  return trans_s;
}

void solve()
{
  string s, t;
  cin >> s >> t;

  cout << (trans(s) == trans(t) ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::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>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

struct range_edge_graph {
    int n;
    struct edge { int to; long long weight;};
    vector<vector<edge>> g;
    
    range_edge_graph(int n_) {
        n = 1;
        while (n < n_) n <<= 1;
        g.resize(4*n);
        for (int i = 1; i < n; ++i) {
            int c1 = i<<1|0, c2 = i<<1|1;
            g[i].push_back({c1, 0});
            g[i].push_back({c2, 0});
            g[c1+2*n].push_back({i+2*n, 0});
            g[c2+2*n].push_back({i+2*n, 0});
        }
        for (int i = n; i < 2*n; ++i)
            g[i].push_back({i+2*n, 0});
    }

    // from [l1, r1) to [l2, r2)
    void add_edge(int l1, int r1, int l2, int r2, int w) {
        int id = g.size();
        l1 += n, r1 += n;
        while (l1 < r1) {
            if (l1 & 1) g[l1+2*n].push_back({id, 0}), l1++;
            if (r1 & 1) --r1, g[r1+2*n].push_back({id, 0});
            l1 >>= 1, r1 >>= 1;
        }
        vector<edge> res;
        l2 += n, r2 += n;
        while (l2 < r2) {
            if (l2 & 1) res.push_back({l2, w}), l2++;
            if (r2 & 1) --r2, res.push_back({r2, w});
            l2 >>= 1, r2 >>= 1;
        }
        g.push_back(res);
    }

    vector<long long> dijkstra(int s) {
        s += n;
        vector<long long> dist(g.size(), numeric_limits<long long>::max());
        dist[s] = 0;
        using P = pair<long long, long long>;
        priority_queue<P, vector<P>, greater<P>> que;
        que.emplace(0, s);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (edge& e : g[v]) {
                if (dist[e.to] > dist[v] + e.weight) {
                    dist[e.to] = dist[v] + e.weight;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        vector<long long> res(dist.begin() + n, dist.begin() + 2*n);
        return res;
    }
};

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

    int n, m;
    cin >> n >> m;
    range_edge_graph g(n);

    rep(i, m) {
        int l, r, c;
        cin >> l >> r >> c;
        l--; r--;
        g.add_edge(l, r+1, l, r+1, c);
    }
    auto dist = g.dijkstra(0);
    ll ans = dist[n-1];
    cout << (ans > 1e18 ? -1 : ans) << endl;
}


Measured memory_bytes: 99444
//this library has many things needed for arrays, the asterisc means we get everything is inside, the dot says where is is inside, you need the ; to tell the line has ended, like in C
import java.util.*;

//the name of the main function has to be the same name of the program
//what public class mean in java: it means that other function scan also access the class. What happens if we dont make it public? Well, it stil works, but it will be visivle to code only in the same package
public class Main {
	//this is a method, it tells that it will execute the things that are inside, it takes string as args when we execute the program, it is optional. What if instead we use int? It does not work, it has to be String[] args
	public static void main(String[] args){
		//it is a class of the .util that is used to take input from the user. Why it is used as class?
		Scanner sc = new Scanner(System.in);
		// get a integer
		//nextInt is a method, it will take text and turn it into an integer. It is looking for space or line break? Yes, if it is a line break or a space it treats it the same way. How to consider it is different?
		int N = sc.nextInt();
      	int[][] numbers = new int[2][N];
      	for (int i = 0; i < N; i++){
          numbers[0][i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++){
          numbers[1][i] = sc.nextInt();
        }
      	//there are N positions to go down see all of them
      	int max = 0;
      	for (int i = 0; i < N; i++){
        	//sum subarrayL1[0:i] with L2[i:N]
            int b = 0;
          	for(int j = 0; j < N; j++){
				
            	if(j <= i){
                	b += numbers[0][j];
                    }
        			
               
              	if(j >= i){
                	b += numbers[1][j];
                }
            }
          	if(b > max){
            	max = b;
            }
        }
  

      System.out.println(max);
	}
}



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


int main(void) {

    long x[5];
    long ans;
    for (long i = 0; i < 5; i++) {
        cin >>x[i];
        if (!x[i]) ans = i+1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3564