akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
int N;
vector<long long> A;
 
int main() {
    while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        long long sum = 0;
        map<long long, long long> ma;
        ma[sum]++;
        for (int i = 0; i < N; ++i) {
            sum += A[i];
            ma[sum]++;
        }
        
        long long res = 0;
        EACH(it, ma) {
            res += (it->second - 1) * it->second / 2;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
using namespace std;
int N, M;
vector <int> G[100005];
int nb[2];
bool Use[100005], ok;
int Colour[100005];
void Read()
{
    cin >> N >> M;
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}

void DFS(int node, int father)
{
    Use[node] = 1;
    Colour[node] = 1 - Colour[father];
    nb[Colour[node]]++;
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father)
            continue;
        if(Use[neighb] == 1)
        {
            if(Colour[neighb] == Colour[node])
            {
                ok = 1;
            }
        }
        else
            DFS(neighb, node);

    }
}

int main()
{
    Read();
    DFS(1, 0);
    if(ok == 1)
    {
        cout << (1LL * N * (N - 1)) / 2 - M << "\n";
    }
    else
    {
        cout << (1LL * nb[0] * nb[1]) - M << '\n';
    }
}


Measured memory_bytes: 7424
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();

            if (N[0] == N[1] && N[0] == N[2] || N[1] == N[2] && N[1] == N[3])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<math.h>
using namespace std;

int main(){
long long n;
 cin>>n;
  long long a[n];
  // long long sum=0;
  
     for(long long i=0;i<n;i++){
      cin>>a[i];
       a[i]=a[i]-(i+1);
     }

     sort(a,a+n);
     long long mid=a[n/2],sum=0;
     for(int i=0;i<n;i++){
      sum+=(max(a[i],mid)-min(a[i],mid));
     }
     cout<<sum;

}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << ' ' << b << ' ' << c << '\n';
	return 0;
}


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

using namespace std;

void Main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N, "");
    vector<string> B(M, "");
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
    }

    for (int i = 0; i < N - M + 1; ++i) {
        for (int j = 0; j < N - M + 1; ++j) {
            bool matched = true;
            for (int k = 0; k < M; ++k) {
                if (A[i + k].substr(j, M) != B[k]) {
                    matched = false;
                    break;
                }
            }
            if (matched) {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
    return;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
res=[0]*N
ac,wa=0,0
for i in range(M):
  p,s=input().split()
  p=int(p)-1
  if res[p]==-1:
    continue
  else:
    if s=="AC":
      wa+=res[p]
      res[p]=-1
      ac+=1
    else:
      res[p]+=1
print(ac,wa)

Measured memory_bytes: 50520
while (a,b,c=gets.split.map(&:to_i))!=[-1,-1,-1]
	if 2.step(16).none?{|base|begin Integer(a.to_s(base))==b rescue nil end} then p -1;next end
	(a+1).step(c){|i|
		b=2.step(16).map{|base|z=i.to_s(base).to_i;b<=z ? z : 1e9}.min
	}
	p b
end

Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A[3];
int main(){
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<3;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sort(A,A+3);
  if(A[0]==A[1] && A[1]==5&&A[2]==7){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A[3];
// {
//   rd(A(3));
//   sort(A,A+3);
//   wt( if[A[0]==A[1]==5&&A[2]==7, "YES", "NO"] );
// }
// 


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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		char[] ac = a.toCharArray();
		char[] bc = b.toCharArray();
		int time = ac.length;
		while(time != 0) {
			
			if(Arrays.equals(ac, bc)) {
				break;
			}else {
				time--;
				rotate(ac);
			}
		}
		
		if(time == 0) {
			System.out.printf("No");
		}else {
			System.out.printf("Yes");
		}
		
		sc.close();
	}
	
	public static void rotate(char[] c) {
		char t = c[c.length-1];
		for(int i = c.length-2; i >= 0; i--) {
			c[i+1] = c[i];
		}
		c[0] = t;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    int r,c;
    cin>>r>>c;
    int blocks=a*b;
    int val=a-r;
    //cerr<<r*b<<endl;
    int ans=blocks-(r*b);
    ans-=val*c;
    cout<<ans<<endl;
    
    return 0;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
int a[MAXN];
long long l[MAXN], r[MAXN];

int main() {

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

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      l[i] = abs(a[i]);
    } else {
      l[i] = l[i - 1] + abs(a[i] - a[i - 1]);
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      r[i] = abs(a[i]);
    } else {
      r[i] = r[i + 1] + abs(a[i] - a[i + 1]);
    }
  }

  for (int i = 0; i < n; i++) {
    long long cur = 0;
    if (i == 0) {
      cur = r[i + 1] + abs(a[i + 1]);
    } else if (i == n - 1) {
      cur = l[i - 1] + abs(a[i - 1]);
    } else {
      cur = l[i - 1] + r[i + 1] + abs(a[i + 1] - a[i - 1]);
    }
    printf("%lld\n", cur);
  }

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

char s[MAXN];
int a[3];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	scanf("%s", s);
	for (int i = 0; s[i]; i ++)
		a[s[i] - 'a'] ++;
	return puts(*max_element(a, a + 3) - *min_element(a, a + 3) <= 1 ? "YES" : "NO"), 0;
}


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

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,d;cin>>n>>d;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        int x,y;cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}
/*



*/



Measured memory_bytes: 3652
N=int(input())
X=[]
Y=[]
for n in range(N):
    A=int(input())
    lx=[]
    ly=[]
    for m in range(A):
        x,y=map(int,input().strip().split())
        lx.append(x)
        ly.append(y)
    X.append(lx)
    Y.append(ly)    

def judge(l,X,Y):
    honest=True
    for n in range(N):
        if l[n]==1:
            for i in range(len(X[n])):
                if l[X[n][i]-1]!=Y[n][i]:
                    honest=False
    return honest

ans=0
def dfs(l,N): #honest=1,unkind=0
    if len(l)==N:
        global ans
        if judge(l,X,Y):
            ans=max(ans,sum(l))
            return
    else:
        for n in range(2):
            l.append(n)
            dfs(l,N)
            l.pop()

dfs([],N)
print(ans)  

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

int main() {
  int a, b, t;
  std::cin >> a >> b >> t;

  int64_t n = 0;
  int aa = a;
  while (aa < t + 0.5) {
    n += b;
    aa += a;
  }

  std::cout << n << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	string s; cin >> s;
	int n = s.size();
	long long ans = 0;
	for (int i = n - 1, cnt = 0; i >= 0; i--) {
        if (s[i] == 'B') ans += cnt;
        else cnt++;
	}
	cout << ans << endl;
	return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, k;
    cin >> n >> k;
    ll ans = k;
    for (int i = 0; i < n - 1; i++)
    {
        ans *= (k - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
t = input()

res = float('inf')
for i in range(len(s)-len(t)+1):
    tmp_s = s[i:i+len(t)]

    cnt = 0
    for j in range(len(t)):
        if tmp_s[j] != t[j]:
            cnt += 1
    
    res = min(res, cnt)

print(res)

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

int main() {
  int N, M, A, B;
  cin >> N >> M;
  map<int, int> mp;
  int arr[N];
  for(int i = 0; i < N; i++){
    cin >> arr[i];
    mp[i] = 1;
  }
  
  for(int i = 0; i < M; i++){
    cin >> A >> B;
  	if(arr[A - 1] < arr[B - 1]){
      if(mp.count(A - 1)){
        N -= mp.at(A - 1);
        mp.erase(A - 1);
      }
    }
    else if(arr[A - 1] > arr[B - 1]){
      if(mp.count(B - 1)){
        N -= mp.at(B - 1);
        mp.erase(B - 1);
      }
    }
    else{
      if(mp.count(A - 1)){
        N -= mp.at(A - 1);
        mp.erase(A - 1);
      }
      if(mp.count(B - 1)){
        N -= mp.at(B - 1);
        mp.erase(B - 1);
      }
    }
  }
    
  cout << N << endl;
  
  return 0;
        
}


Measured memory_bytes: 8672
n=int(input())
a=[int(input()) for _ in range(n)]
ans=-1
b=a[0]
if b==2:
    print(1)
else:
    for i in range(n):
        b=a[b-1]
        # print(f"b={b}")
        if b==2:
            ans=i+2
            break
    print(ans) 

Measured memory_bytes: 7084
c,q;t['   '];main(p){for(;~scanf("%d%d",&p,&q);memset(t,c=!puts(t),4e6)){for(;p&&!t[p];p=p*10%q)t[p]=++c,putchar(p*10/q+48);for(p&&printf("\n%*s",q=t[p]-1,t);q++<c;)putchar(94);}}

Measured memory_bytes: 4328
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(){

  string s;
  cin >> s;
  int N = s.length();

  int ans[2];
  ans[0] = 0; //start from 0
  ans[1] = 0; //start from 1

  for(int i= 0; i < N; ++i){

    if(i%2 == 0){
      if(s[i] == '0'){
        ans[1] += 1;
      }
      else{
        ans[0] += 1;
      }
    }
    else{
      if(s[i] == '0'){
        ans[0] += 1;
      }
      else{
        ans[1] += 1;
      }
    }
  }

  cout << min(ans[0], ans[1]) << endl;

  return 0;

}

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

using ll=long long;



void solve(){
    int n;
    cin>>n;
    if(n>=1000){
        n-=999;
        cout<<"ABD"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

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

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = A*X+B*Y;
    for (int i=0; i<=max(X,Y); i++)
      ans = min(ans,A*max(0,(X-i))+B*max(0,(Y-i))+C*2*i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	N -= M;
	cout << N%K << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env run-cargo-script

use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;

fn main() {
    let mut sc = Scanner::new();
    let (a, b, c) = (sc.parse::<usize>(), sc.parse::<usize>(), sc.parse::<usize>());
    if 100 + b - a == 100 + c - b {
        println!("YES");
    } else {
        println!("NO");
    }
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		long ans = 0;
		if(N%2==1) {
			System.out.println(0);
			return;
		}
		long n = N;
		ans += N/10;
		n = N/10;
				while(n>0) {
					ans += n/5;
					n /=5;
				}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
h, w = map(int, input().split())
def guki(n):
    if n%2 == 0:
        return "gu"
    else:
        return "ki"

def check(h, w):
    if h == 1 or w == 1:
        return 1
    else:
        if guki(w) == "gu":
            k = w//2
            g = w//2
            if guki(h) == "gu":
                return (k+g)*(h//2)
            else:
                return (k+g)*(h//2)+k
        else:
            k = w//2 + 1
            g = k-1
            if guki(h) == "gu":
                return (k+g)*(h//2)
            else:
                return (k+g)*(h//2)+k

print(check(h, w))

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

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

    int N, K;
    cin >> N >> K;

    int ans = 0;

    do {
        ++ans;
        N /= K;
    } while (N);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll b[n+1];
    ll a;
    memset(b,0,sizeof(b));
    for(int i=1;i<n;i++){
    	cin>>a;a--;
    	b[a]++;
    }
    for(int i=0;i<n;i++){
    	cout << b[i] <<endl;
    }
    return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int N, S, E;
  scanf("%d%d%d", &N, &S, &E);

  int ans = 0;
  rep(i, N) {
    int a;
    scanf("%d", &a);
    if (S <= a && a < E) continue;
    ans++;
  }

  _p("%d\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
def z_advanced(s, Z_max):
    """An advanced computation of Z-values of a string."""

    Z = [0] * len(s)
    Z[0] = len(s)

    rt = 0
    lt = 0

    for k in range(1, len(s)):
        if k > rt:
            # If k is outside the current Z-box, do naive computation.
            n = 0
            while n + k < len(s) and s[n] == s[n+k]:
                n += 1
            Z[k] = n
            if n > 0:
                lt = k
                rt = k+n-1
        else:
            # If k is inside the current Z-box, consider two cases.

            p = k - lt  # Pair index.
            right_part_len = rt - k + 1

            if Z[p] < right_part_len:
                Z[k] = Z[p]
                    
            else:
                i = rt + 1
                while i < len(s) and s[i] == s[i - k]:
                    i += 1
                Z[k] = i - k

                lt = k
                rt = i - 1
                
        Z_max = max(Z_max, min(k, Z[k]))  # check_k_zk()を参考のこと
    
    # return Z, Z_max
    return Z_max
  
N = int(input())
S = input()
Z_max = 0
for i in range(N):
    Z_max = z_advanced(S[i:], Z_max)

print(Z_max)

Measured memory_bytes: 51292
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1(1),v2;
		
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
//			v2.insert(v2.end(),ity-v1.begin()&1?1:2,0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back())++it,v2.pop_back();
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it){
			m=*it;++it;
			x+=*it-m;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL n, ans = 0;
	cin >> n;
	vector<LL> a(n), s(n + 1);
	REP(i, n)cin >> a[i];
	REP(i, n + 1) {
		s[i] = i == 0 ? 0 : s[i - 1] + a[i - 1];
	}
	SORT(s);
	LL i = 0;
	while (i < n + 1) {
		LL elem = s[i], cnt = 0;
		while (i < n + 1 && s[i] == elem) { cnt++; i++; }
		ans += (cnt - 1)*cnt / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{
	 public static void main(String[] args)throws IOException{
		 Scanner sc = new Scanner(System.in);
		 ArrayList<Integer> al = new ArrayList<Integer>();
		 for(int i = 0; i< 10; i++){
			 int w = sc.nextInt();
			 al.add(Integer.valueOf(w));
		 }
		 Collections.sort(al);
		 System.out.println(al.get(9));
		 System.out.println(al.get(8));
		 System.out.println(al.get(7));
    	
    }
}

Measured memory_bytes: 26300
#include <iostream>
#include <string>

#define MAX 100005
#define rep(i, n) for(int i = 0; i < n; i++)
#define abrep(i, a, b) for(int i = a; i < b; i++)

using namespace std;

bool p[MAX];
int pp[MAX];

int main() {
    abrep(i, 2, MAX) p[i] = true;
    for(int i = 2; i * i < MAX; i++) {
        if (p[i] == true) {
            for(int j = i * 2; j < MAX; j += i) 
                p[j] = false;
        }
    }
    
    abrep(i, 2, MAX) pp[i] = (p[i] && p[(i + 1) / 2])? 1:0;
    
    abrep(i, 2, MAX) pp[i + 1] += pp[i];
    
    int Q; cin >> Q;
    rep(i, Q) {
        int l, r, n;
        cin >> l >> r;
        n = pp[r] - pp[l];
        if(pp[l] - pp[l-1] != 0) n += 1;
        cout << n << endl;
    }

}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>
 int main()
{
       int i,j;
       float c;
       scanf("%d%d",&i,&j);
       c=(i+j)/2;
       if(i%2==0&&j%2!=0||i%2!=0&&j%2==0){printf("%.f",round(c)+1);}
       else if(i%2==0&&j%2==0){
       printf("%.f",round(c));}
       else if(i%2!=0&&j%2!=0){printf("%.f",round(c));}
       return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,i,j;
  cin>>n>>k;
  int arr[n]={0};
  while(k--)
  {
    cin>>i;
    while(i--)
    {
      cin>>j;
      arr[j-1]++;
    }
  }
  int count=0;
  for(i=0;i<n;i++){
    if(arr[i]==0)
           count++;
           }
           cout<<count<<"\n";
     return 0;
}


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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  for(int i = 0;i < dx;i++)
    cout << 'R';
  for(int i = 0;i < dy;i++)
    cout << 'U';
  for(int i = 0;i < dx;i++)
    cout << 'L';
  for(int i = 0;i < dy;i++)
    cout << 'D';
  cout << "DR";
  for(int i = 0;i < dx;i++)
    cout << 'R';
  for(int i = 0;i < dy;i++)
    cout << 'U';
  cout << "ULUL";
  for(int i = 0;i < dx;i++)
    cout << 'L';
  for(int i = 0;i < dy;i++)
    cout << 'D';
  cout << "DR\n";
  return 0;
}
  

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<P> ab;
    for(int i=0; i<n; i++){
        int a, b; cin>>a>>b;
        ab.emplace_back(a, b);
    }

    sort(ab.begin(), ab.end());

    priority_queue<int> pq;
    int id = 0;
    int ans = 0;
    // M-1 日から働くことを考える（逆順）
    // i 日後に報酬が貰える
    for(int i=1; i<=m; i++){
        while(id < n && ab[id].first <= i){
            pq.emplace(ab[id].second);
            id++;
        }

        if(pq.size()){
            ans += pq.top();
            pq.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1908
public class Main {
  private static void solve() {
    char c = ns()[0];
    
    if (c == 'A') {
      System.out.println("T");
    } else if(c =='T') {
      System.out.println("A");
    }else if(c == 'G') {
      System.out.println("C");
    }else {
      System.out.println("G");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll n;
	cin >> n;
	vector<ll> v(5);
	rep(i,5) cin >> v[i];
	ll mn = v[0];
	rep(i,5) mn = min(v[i], mn);
	if (mn == n) {
		cout << 5 << endl;
		return;
	}
	cout << (n + mn - 1) / mn + 4ll << endl;
}

int main() {
	solve();
	return 0;
}

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

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

vector<pair<ll,ll>> prime_factorization(ll N) {
    vector<pair<ll,ll>> res;
    for(ll i = 2; i*i <= N; i++) {
        if(N%i == 0) {
            ll ex = 0;
            while(N%i == 0) {
                N /= i;
                ++ex;
            }
            res.push_back(make_pair(i,ex));
        }
    }
    if(N != 1) {
        res.push_back(make_pair(N,1));
    }
    return res;

}

int main() {
    ll A,B; cin >> A >> B;
    ll g = gcd(A,B);
    cout << prime_factorization(g).size()+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N,K;
  cin >> N >> K;
  N%=K;

  cout << min(N,K-N) << endl;
  
  return 0;
}


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

using namespace std;

int calc(int e) {
	if(e == 1) return 1;

	int len = 0;

	for(int i=1; e>1; i++) {
		e -= i;
		if(e >= 0)len++;
	}

	return len;
}

int main() {
	long long n; cin>>n;
	long long ans = 0; long long p = 2;

	while(n > 1 && p <= 1e6) {
		int e = 0;

		while(n % p == 0) {
			e++;
			n /= p;
		}


		if(e > 0) {
			//printf("%lld^%d : calc(%d) = %d\n", p, e, e, calc(e));
			ans += calc(e);
		}

		p++;
	}

	if(n > 1) ans++;

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

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (i > 0 && s[i] == s[i-1]) continue;
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3724
from bisect import bisect, bisect_left
s = input()
n = len(s)
ans = [0 for _ in range(n)]
R = []
L = []
for i in range(n):
	if s[i] == "R":
		R.append(i)
	else:
		L.append(i)
#print(RL)
for i in range(n):
	if s[i] == "R":
		ind = bisect(L, i)
		#print(ind)
		if (L[ind] - i)%2 == 0:
			ans[L[ind]] += 1
		else:
			ans[L[ind]-1] += 1
	else:
		ind = bisect(R, i)-1
		#print(ind)
		if (i - R[ind])%2 == 0:
			ans[R[ind]] += 1
		else:
			ans[R[ind]+1] += 1
print(*ans)

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

signed main(){
	string S, T;
	cin >> S;
	cin >> T;
	int i, j, ans = T.size();
	for(i = 0; i + T.size() <= S.size(); i++){
		int now = 0;
		for(j = 0; j < T.size(); j++){
			if(S[i + j] != T[j]){
				now++;
			}
		}
		ans = min(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int ans = 1;
	FOR(i,1, x) {
		int p = (i + 1)*(i + 1);
		while (p <= x) {
			ans = max(ans, p);
			p *= (i + 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    char s[10][10];

    for(int i = 0; i < 3; ++i){
        scanf("%s", s[i]);
        printf("%c", s[i][i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ll b=n/i;
        if(n%i==0)
            b--;
        ans+=b;
    }
    cout<<ans;
}



Measured memory_bytes: 3672
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
count, result = 0, []
(0...n).each do |i|
  if result.count + 1 == arr[i]
    result << arr[i]
  else
    count += 1
  end
end
if result.count != 0
  puts count
else
  puts "-1"
end

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b,c;
    cin >> a >> b >> c;
    YES(c % __gcd(a, b) == 0);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll a = 0,w = 0,t = 0,r = 0;
    ll n;
    cin>>n;
    fo(i,n){
        string s;
        cin>>s;
        if(s == "AC")a++;
        else if(s == "TLE")t++;
        else if(s == "RE")r++;
        else w++;
    }
    cout<<"AC x "<<a<<nl;
    cout<<"WA x "<<w<<nl;
    cout<<"TLE x "<<t<<nl;
    cout<<"RE x "<<r<<nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


Measured memory_bytes: 3792
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use math::*;
use string_algorithm::*;
use util::*;
use input_scanner::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let m: usize = scan.next();
    let mut edge: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 0..m {
        let a: usize = scan.next();
        let b: usize = scan.next();
        let a = a-1;
        let b = b-1;
        edge[a].push(b);
        edge[b].push(a);
    }
    let mut ans: Vec<usize> = vec![0; n];
    let mut vis: Vec<bool> = vec![false; n];
    let mut q: VecDeque<usize> = VecDeque::new();
    q.push_back(0);
    vis[0] = true;
    let mut cnt = 0;
    while let Some(u) = q.pop_front() {
        cnt += 1;
        for v in &edge[u] {
            if !vis[*v] {
                vis[*v] = true;
                q.push_back(*v);
                ans[*v] = u;
            }
        }
    }
    if cnt == n {
        println!("Yes");
        for x in &ans[1..] {
            println!("{}", *x + 1);
        }
    }else{
        println!("No");
    }
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }
    
    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


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

ll gcd(ll a,ll b){return b==0 ? a : gcd(b,a%b);}

bool solve(ll a,ll b,ll c,ll d){
    if(a < b) return false;
    if(b > d) return false;
    if(b <= c) return true;
    ll g = gcd(b,d);
    return c >= b - g + a%g;
}

int main(void){
    ll T;
    cin>>T;
    rep(_,T){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<((solve(a,b,c,d)) ? "Yes" : "No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int w,i,j,k,ans;
    while(1){
    scanf("%d",&w);
    if(w==-1)break;
    if(w<10){
        ans=1150;
    }
    else if(w<=20){
        ans=1150+(w-10)*125;
    }
    else if(w<=30){
        ans=2400+(w-20)*140;
    }
    else{
        ans=3800+(w-30)*160;
    }
    if(ans>4280){
        printf("-%d\n",ans-4280);
    }
    else{
        printf("%d\n",4280-ans);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,a[110]; 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	a[0]=0x3f3f3f3f;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]!=a[i-1]){
			ans++;
		} 
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
    ll mini=min(a,min(b,min(c,min(d,e))));
    ll res=(n+mini-1)/mini+4;
    cout<<res<<endl;
}

Measured memory_bytes: 256
S=input()
a=1
if S[0] == 'A':
    if S[1] == 'A':
        if S[2] == 'A':
            a = 0
if S[0] == 'B':
    if S[1] == 'B':
        if S[2] == 'B':
            a = 0

if a == 0:
    print('No')
else:
    print('Yes')

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, k; cin >> n >> k;
  ll tmp1 = (k + k + 2 * n - 1) * n;
  ll tmp2 = (k + 2 * n + k + 3 * n - 1) * n / 2;
  //cout << tmp1 << " " << tmp2 << endl;
  if(tmp1 > tmp2) {
    cout << -1 << endl;
    return 0;
  }

  for(int i=0;i<n/2;++i) {
    cout << k + i << " " << k + n + n / 2 + n % 2 + i << " " << k + 2 * n + 2 * i + 1 << endl;
  }
  for(int i=n/2;i<n;++i) {
    cout << k + i << " " << k + n + i - n / 2 << " " << k + 2 * n + 2 * (i - n/2) << endl;
  }

}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
int main(){
    int h,w,n; cin >> h >> w >> n;
    int x=max(h,w);
    int ans=n/x;
    if(n%x!=0) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	long long int a, b, c, k;
	cin >> a >> b >> c >> k;
	b -= a;
	c -= a;
	a = 0;
	if (k % 2 == 0) {
		cout << -b << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;
 
int main(){
  
 int A,B;
	int tap=0;
  int soc=1;
  
   cin >> A;
   cin >> B;
 
  
  while(soc < B){
    
    tap++;
    
    soc--;
    
    soc += A;
    
  }

    cout << tap;

  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
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; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod=1000000007,MAX=200005,INF=1<<30;

int main() {
  	int n;
  	cin>>n;
  
  	if(n%111==0){
    	cout<<n<<endl;
    }
  
  	else{
    	n+=111-(n%111);
      	cout<<n<<endl;
    }
  



}

Measured memory_bytes: 3552
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		bool[] hasFrom1 = new bool[N];
		bool[] hasToN = new bool[N];
		for(int i = 0; i < M; i++)
		{
			int a = GetInt();
			int b = GetInt();
			if(a == 1)
				hasFrom1[b] = true;
			if(b == N)
				hasToN[a] = true;
		}

		for(int i = 2; i <= N-1; i++)
		{
			if(hasFrom1[i] && hasToN[i])
			{
				Console.WriteLine("POSSIBLE");
				return;
			}
		}
		Console.WriteLine("IMPOSSIBLE");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

int main() {
	ll a;
	cin>>a;
  double num;
	if(a%2)num=(a+1)/2;
	else num=a/2;
	double ans=num/a;
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256