akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = read::<usize>();
    let mut a :Vec<String> = vec![];
    for i in 1..6 {
        for j in 0..s.len() {
            let mut b = vec![];
            for k in 0..i {
                if j+k < s.len() {
                    b.push(s[k+j]);
                }
            }
            if !b.is_empty() && b.len() == i {
                let c :String = b.into_iter().collect();
                a.push(c);
            }
        }
    }
    a.sort();
    let mut cnt = 0;
    if a.len() == 1 {
        println!("{}", a[0]);
        return;
    }
    for i in 0..a.len()-1 {
        if a[i+1] != a[i] {
            cnt+=1;
        }
        if cnt == n-1 {
            println!("{}", a[i+1]);
            return;
        }
    }
}

Measured memory_bytes: 4352
c = []
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
sa = [[0,0,0],[0,0,0]]
for i in range(3):
    sa[0][i]=c[1][i]-c[0][i]
    sa[1][i]=c[2][i]-c[0][i]
if(all([x == sa[0][0] for x in sa[0]]) and all([x == sa[1][0] for x in sa[1]])):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    string S;
    long long int K, sum = 0, s;
    cin >> S >> K;
    for(long long int i = 0;i < (long long int)S.size(); i++){
      s = S[i] - '0';
      if(s == 1)  sum++;
      else  break;
    }
    if(K <= sum)  cout << 1 << endl;
    else cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#include <numeric>
using namespace  std;

using ll = long long;
const ll mod = 998244353;
typedef pair<int , int> pairs;
typedef complex<ll> G;
const int N = 1e6+5;

const int INF = 1e9;

void done() {
    int n, m;
    cin >> n >> m;
    char a[n][m];
    set<int>q;
    set<int>p;
    vector<int>pos1, pos2;
    pairs ap = {INF, INF};
    int ok = 0;
    for(int i=0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            cin >> a[i][j];
        }
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {


            if(i < n-1 && i!=0 && j != 0 && j < m-1) {
                if(a[i][j] == '*' && a[i][j+1] == '*' && a[i+1][j] == '*' && a[i-1][j] == '*' && a[i][j-1] == '*') {
                    ap  = make_pair(i, j);
                    ok++;
                }
            }
        }
    }

    if(ok != 1) {
        cout << "NO\n";
        return;
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            if(a[i][j] == '*') {
                if(i != ap.first && j!=ap.second) {
                    cout << "NO\n";
                    return;
                }
                if(j == ap.second)pos1.push_back(j);
                if(i == ap.first)pos2.push_back(i);
            }
        }
    }

    sort(pos1.begin(), pos1.end());
    sort(pos2.begin(), pos2.end());
    for(int i=0;i < pos1.size()-1;i++) {
        if(pos1[i+1]-pos1[i] > 1) {
            cout << "NO\n";
            return;
        }
    }
    for(int i=0;i < pos2.size()-1;i++) {
        if(pos2[i+1]-pos2[i] > 1) {
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";



}

void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i < n;i++) {
        cin >> a[i];
    }
    bool ok = 1;
    for(int i=0;i < n-1;i++) {
        if(a[i] > a[i+1]) {
            ok = 0;
            break;
        }
    }
    if(ok) {
        cout << 0 << '\n';
        return;
    }


}

void another() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i=l;i <=r;i++) {
        if(i % d == 0) {
            ans++;
        }
    }
    cout << ans << '\n';

}
void test_case() {
    int t;
    cin >> t;
    while(t--)solve();
}
int main() {

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    another();

}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int x[maxn],y[maxn];
int cntx,cnty;
int n,k;
int main(){
    while (cin>>n>>k){
        cntx=0;cnty = 0;
        for (int i=0,t;i<n;i++){
            cin>>t;
            if (t == 0) k--;
            if (t<0) x[cntx++] = -t;
            if (t>0) y[cnty++] = t;
        }
        reverse(x,x+cntx);
        int ans = 0x3f3f3f3f;

        if (k == 0) ans = 0;
        else{
            if (cntx >= k) ans = min(ans, x[k-1]);
            if (cnty >= k) ans = min(ans, y[k-1]);
            for (int i=0;i<min(k,cntx);i++)if (k-2-i < cnty){
                int tmp = x[i] + y[k-2-i] + min(x[i],y[k-2-i]);
                ans = min(ans,tmp);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
  int n, q;
  int S[10000], T[500];
  int i, j;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &T[i]);
  }
  int count = 0;
  for (i = 0; i < q; i++) {
    for (j = 0; j < n; j++) {
      if (T[i] == S[j]) {
	count++;
	break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    char c; cin >> c;
    if(islower(c)) cout << "a" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 3608
import numpy as np
A, B, K = map(int, input().split())
coo = np.array([A, B])
c = 0
for _ in range(K):
    if coo[0] % 2 == 0:
        pass
    else:
        coo[0] -= 1

    half = coo[0] / 2
    coo[1] += half
    coo[0] -= half
    coo = coo[::-1]

if K % 2 == 0:
    print(*coo)
else:
    print(*coo[::-1])


Measured memory_bytes: 21744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    cin>>n>>a;
    int s = 0;
    while(a--){
        int k;
        cin>>k;
        s+=k;
    }
    if(s>n) puts("-1");
    else cout<<n-s;
}


Measured memory_bytes: 3672
import java.io.*;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        String s = fs.next();
        String t = fs.next();
        for( int i = 0 ; i < n ; i++ ){
            System.out.print(s.charAt(i) + "" + t.charAt(i) );
        }
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) {
                return buffer[ptr++];
            } else {
                return -1;
            }
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21204
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let s = it.next().unwrap();
    let indices = |target| {
        s.chars()
            .enumerate()
            .filter(|&(i, c)| c == target)
            .map(|(i, c)| i)
            .collect::<Vec<usize>>()
    };
    let a = indices('D');
    let b = indices('M');
    let c = indices('C');
    let c2b = c
        .iter()
        .map(|x| b.binary_search(x).unwrap_err())
        .scan(0, |s, x| {
            *s += x;
            Some(*s)
        })
        .collect::<Vec<_>>();
    let q = parse!(it);
    let aicl = a
        .iter()
        .map(|ai| c.binary_search(ai).unwrap_err())
        .collect::<Vec<_>>();
    let cr = (0..(n + 1))
        .map(|x| c.binary_search(&x).unwrap_or_else(|x| x))
        .collect::<Vec<_>>();
    let aibj = a
        .iter()
        .map(|ai| b.binary_search(ai).unwrap_err())
        .collect::<Vec<_>>();
    for _ in 0..q {
        let k: usize = parse!(it);
        let mut ret = 0;
        for (i, ai) in a.iter().enumerate() {
            let l = aicl[i];
            let r = if ai + k > n { c.len() } else { cr[ai + k] };
            let j = aibj[i];
            if l >= c.len() || r == 0 || j >= b.len() {
                continue;
            }
            ret += c2b[r - 1] - (r - l) * j - if l > 0 { c2b[l - 1] } else { 0 };
        }
        println!("{}", ret);
    }
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        18
DWANGOMEDIACLUSTER
1
18
        ";
    }
}


Measured memory_bytes: 39644
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	char in[10000];
	gets(in);
	for(int i=0; i<strlen(in); i++){
		if(in[i]>='a' && in[i]<='z'){
			in[i] += 'A'-'a';
		}else if(in[i]>='A' && in[i]<='Z'){
			in[i] -= 'A'-'a';
		}
	}
	printf("%s\n", in);
	return 0;
}

Measured memory_bytes: 1096
#include <iostream>
#include <cstring>
#include <cstdio>
#include<string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	n++;
	int s = 0;
	while (n > 9)
	{
		s += 9;
		n /= 10;
	}
	s += (n - 1);
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> vc( N * M );
    for( auto &x : vc )
    {
        cin >> x;
    }
    REP( i, N * M )
    {
        if( vc[ i ] == "snuke" )
        {
            char c = i % M + 'A';
            cout << c << i / M + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque

in_str = list(map(int,input().split()))
x = in_str[0]
n = in_str[1]
p = []
if n:
    p = list(map(int,input().split()))

def solve():
    i = 0
    while True:
        if x - i not in p:
            return x - i
        if x + i not in p:
            return x + i
        i += 1

print(solve())

Measured memory_bytes: 9468
// failed to generate code
 
#include <bits/stdc++.h>
using namespace std;
 
int has[100010];
 
struct P{
	int l,r,o;
};
 
P val[100010];
vector<int> g[100010];
int mark[100010];
 
int sub(int x,int p){
	int ans = mark[x] != -1;
	for( auto c : g[x] )
		if( c != p ) ans += sub(c,x);
	return ans;
}
 
P merge(P a,P b){
	if( a.o == 2 ) return b;
	if( b.o == 2 ) return a;
	if( a.o == -1 or b.o == -1)
		return {-1,-1,-1};
	if( a.o != b.o )
		return {-1,-1,-1};
	a = {max(a.l,b.l),min(a.r,b.r),a.o};
	if( a.l > a.r )
		return {-1,-1,-1};
	return a;
}
P ex(P a){
	if( a.o == 2 ) return a;
	
	if( a.o == 0 or a.o == 1 ){
		a.l--;
		a.r++;
		a.o = !a.o;
		return a;
	}
	return {-1,-1,-1};
}
P dfs(int x,int p){
	P hoge = mark[x] == -1e9 ? P{0,0,2} : P{mark[x],mark[x],mark[x]%2};
	for( auto c : g[x] ){
		if( c != p ){
			hoge = merge(hoge,ex(dfs(c,x)));
		}
	}
	//cout << x+1 << " " << hoge.l << " " << hoge.r << " " << hoge.o << endl;
	return val[x] = hoge;
}
void dfs2(int x,int p,P www){
	P hoge = merge(val[x],www);
	val[x] = {hoge.l,hoge.l,hoge.l%2};
	mark[x] = hoge.l;
	for( auto c : g[x] ){
		if( c != p ){
			dfs2(c,x,ex(hoge));
		}
	}
	
}
int main(){	
	for(int i = 0 ; i < 100010 ; i++) mark[i] = -1e9;
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 0 ; i < n-1 ; i++){
		int a,b;
		cin >> a >> b;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int k;
	cin >> k;
	for(int i = 0 ; i < k ; i++){
		int a,v;
		cin >> a >> v;
		--a;
		mark[a] = v;
	}
	auto r = dfs(0,-1);
	if( r.o == -1 ){
		cout << "No" << endl;
		return 0;
	}
	
	
	val[0] = {val[0].l,val[0].l,val[0].l%2};
	queue<int> Q;
	dfs2(0,-1,{0,0,2});
	
	
	
	
	cout << "Yes" << endl;
	for(int i = 0 ; i < n ; i++)
		cout << mark[i] << endl;
	
}

Measured memory_bytes: 23680
n=int(input())
for i in range(0,11):
    if n>(26**(i+1)-26)//25:
        idx=i
        k=n-(26**(i+1)-26)//25
ans=[]
#print(k)
while idx>=0:
    for i in range(26):
        if k>i*26**idx:
            s=i
    #print(s)
    ans.append(chr(s+97))
    k-=s*26**idx
    idx-=1
print("".join(ans))

Measured memory_bytes: 9048
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
char D[1002][1002]={};

int main() {
	int M,N;
	char E[2][2];
	cin>>M>>N;
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			cin>>D[i][j];
		}
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			cin>>E[i][j];
		}
	}
	int a=0;
	for(int i=1;i<M;i++){
		for(int j=1;j<N;j++){
			if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1]){
				a+=1;
			}
		}
	}
	int a1=0,a2,a3,a4;
	char C;
	int R=0;
	for(int i=1;i<M+1;i++){
		for(int j=1;j<N+1;j++){
			a1=0;
			if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1])a1+=1;
			if(D[i][j-1]==E[0][0]&&D[i][j]==E[0][1]&&D[i+1][j-1]==E[1][0]&&D[i+1][j]==E[1][1])a1+=1;
			if(D[i-1][j-1]==E[0][0]&&D[i-1][j]==E[0][1]&&D[i][j-1]==E[1][0]&&D[i][j]==E[1][1])a1+=1;
			if(D[i-1][j]==E[0][0]&&D[i-1][j+1]==E[0][1]&&D[i][j]==E[1][0]&&D[i][j+1]==E[1][1])a1+=1;
			C=D[i][j];
			D[i][j]='J';
			a2=0;
			if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1])a2+=1;
			if(D[i][j-1]==E[0][0]&&D[i][j]==E[0][1]&&D[i+1][j-1]==E[1][0]&&D[i+1][j]==E[1][1])a2+=1;
			if(D[i-1][j-1]==E[0][0]&&D[i-1][j]==E[0][1]&&D[i][j-1]==E[1][0]&&D[i][j]==E[1][1])a2+=1;
			if(D[i-1][j]==E[0][0]&&D[i-1][j+1]==E[0][1]&&D[i][j]==E[1][0]&&D[i][j+1]==E[1][1])a2+=1;
			D[i][j]='O';
			a3=0;
			if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1])a3+=1;
			if(D[i][j-1]==E[0][0]&&D[i][j]==E[0][1]&&D[i+1][j-1]==E[1][0]&&D[i+1][j]==E[1][1])a3+=1;
			if(D[i-1][j-1]==E[0][0]&&D[i-1][j]==E[0][1]&&D[i][j-1]==E[1][0]&&D[i][j]==E[1][1])a3+=1;
			if(D[i-1][j]==E[0][0]&&D[i-1][j+1]==E[0][1]&&D[i][j]==E[1][0]&&D[i][j+1]==E[1][1])a3+=1;
			D[i][j]='I';
			a4=0;
			if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1])a4+=1;
			if(D[i][j-1]==E[0][0]&&D[i][j]==E[0][1]&&D[i+1][j-1]==E[1][0]&&D[i+1][j]==E[1][1])a4+=1;
			if(D[i-1][j-1]==E[0][0]&&D[i-1][j]==E[0][1]&&D[i][j-1]==E[1][0]&&D[i][j]==E[1][1])a4+=1;
			if(D[i-1][j]==E[0][0]&&D[i-1][j+1]==E[0][1]&&D[i][j]==E[1][0]&&D[i][j+1]==E[1][1])a4+=1;
			D[i][j]=C;

			R=max(R,a+a2-a1);
			R=max(R,a+a3-a1);
			R=max(R,a+a4-a1);

		}
	}


	cout<<R<<endl;
	return 0;
}

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


public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}
	
	// Math
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			long n = Long.parseLong(sc.next());
			if(n==0) break;
			
//			int cnt2 = 0;
			int cnt5 = 0;
//			for(long i=n; i>=2; cnt2+=i/2, i/=2);
			for(long i=n; i>=5; cnt5+=i/5, i/=5);
			
//			System.out.println(Math.min(cnt2, cnt5));
			System.out.println(cnt5);
		}
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int i,j,k,flag;
  char str[100],res[100]="#",T[100],tmp[100];
  cin >> str;
  cin >> T;
  for(i=0;i<strlen(str)-strlen(T)+1;i++){
    flag = 1;
    for(j=0;j<strlen(T);j++){
      if(!(T[j] == str[i+j] || str[i+j] == '?')){
        flag = 0;
      }
    }
    if(flag){
      strcpy(tmp,str);
      for(j=0;j<strlen(T);j++)
        tmp[j+i] = T[j];
      for(j=0;j<strlen(str);j++)
        if(tmp[j] == '?')
          tmp[j] = 'a';
      if(strcmp(tmp,res) < 0 || strcmp(res,"#") == 0)
        strcpy(res,tmp);
    }
  }
  flag = 1;
  if(strcmp(res,"#") == 0)
    flag = 0;
  if(flag)
  cout << res << endl;
  else
    cout << "UNRESTORABLE" << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
string s;
int z;
int main()
{
 cin>>s;
 for (int i=0;i<=5;i++)
 if (s[i]=='1') z++;
 cout<<z<<endl;
 return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

L = ni()
print((L/3)**3)

        



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

int n;
int a[101010];
int b[101010];
vector<int> c[101010];

int po(int v = 1)
{
  int ret = c[v].size();
  vector<int> pe;
  for (int i = 0; i < c[v].size(); i++){
    pe.push_back(po(c[v][i]) + 1);
  }

  sort(pe.begin(), pe.end(), greater<int>());
  for (int i = 0; i < c[v].size(); i++){
    ret = max(ret, pe[i] + i);
  }

  return ret;
}

int main()
{
  memset(b, -1, sizeof(b));
  cin >> n;
  a[1] = 1;
  for (int i = 2; i <= n; i++){
    cin >> a[i];
    c[a[i]].push_back(i);
  }

  cout << po() << endl;
}



Measured memory_bytes: 15872
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;

using ll = long long;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N, M, Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  
  REP(i,Q)
    cin >> a[i]>>b[i]>>c[i]>>d[i];
  
  ll r = 0;
  
  vector<int> aa(N+1, 1);
  
  auto solve = [&](auto f, int i) -> void {
    if (i >= N) {
      ll tmp = 0;
      REP(k, Q) {
        if (aa[b[k]-1]-aa[a[k]-1] == c[k])
          tmp+=d[k];
      }
      r = max(r, tmp);
    }
    else {
    for (int j = aa[i]; j <= M; j++) {
      aa[i+1] = j;
      f(f, i + 1);
    }
    }
  };
  
  for (auto i = 1; i <= M; i++) {
    aa[0] = i;
    solve(solve, 0);
  }


  return r;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

class UnionFind{
	vector<int> par, rnk, cnt;
	public:
	UnionFind(int n){
		par=vector<int>(n);
		rnk=vector<int>(n,0);
		cnt=vector<int>(n,1);
		for(int i=0; i<n; i++) par[i]=i;
	}
	int root(int i){
		if(par[i]==i) return i;
		return par[i]=root(par[i]);
	}
	void unite(int i, int j){
		int ri = root(i);
		int rj = root(j);
		if(ri==rj) return;

		if(rnk[ri]==rnk[rj]){
			cnt[rj] += cnt[ri];
			par[ri] = rj;
			rnk[rj]++;
		}
		else if(rnk[ri] < rnk[rj]){
			cnt[rj] += cnt[ri];
			par[ri] = rj;
		}
		else{
			cnt[ri] += cnt[rj];
			par[rj] = ri;
		}
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	int count(int i){
		return cnt[root(i)];
	}
};

int main(){
	int N, M;
	cin >> N >> M;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	UnionFind uf(N);
	for(int i=0; i<M; i++){
		int x, y;
		cin >> x >> y;
		uf.unite(x, y);
	}

	map<int, vector<int>> connected;
	for(int i=0; i<N; i++){
		connected[uf.root(i)].push_back(i);
	}

	if(2*connected.size()-2>N){
		cout << "Impossible" << endl;
		return 0;
	} else if(connected.size()==1){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	vector<ll> remain;
	for(auto p: connected){
		vector<int> v = p.second;
		vector<ll> va;
		for(int u: v) va.push_back(A[u]);
		sort(va.begin(), va.end());
		ans += va[0];
		for(int i=1; i<va.size(); i++) remain.push_back(va[i]);
	}
	sort(remain.begin(), remain.end());
	for(int i=0; i<(int)connected.size()-2; i++) ans += remain[i];
	debug(any{(int)connected.size(), (int)remain.size()});
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13184
X,K,D = [int(_n) for _n in input().split()]
X = abs(X)
if (X // D)+1 > K:
    print(X - D * K)
    # print(X/D, K)
else:
    K -= (X // D)
    X -= (X // D) * D
    if K % 2 == 0:
        print(abs(X))
    else:
        print(abs(X - D))

Measured memory_bytes: 61696
#include <iostream>

using namespace std;

int main(){
    int i;
    long long lucas[87]={0};
    lucas[0]=2;
    lucas[1]=1;
    for(i=2; i<=86; i++){
        lucas[i]=lucas[i-1]+lucas[i-2];
    }
    cin >> i;
    cout << lucas[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

double dp[3300][3300];
int n;
double p[3300];

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> p[i];
    dp[0][0] = 1;

    for(int i = 1;i <= n;i++){
        for(int j = 0;j <= i;j++){
            dp[i][j] = dp[i-1][j] * (1-p[i]);            
            if(j-1 >= 0)dp[i][j] += dp[i-1][j-1] * p[i];
        }
    }

    double ans;
    for(int i = 0;i <= n;i++){
        if(i > n-i)ans += dp[n][i];
    }
    printf("%.15lf\n", ans);
    
    return 0;
}

Measured memory_bytes: 76544
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
  vector<int> v(1024,0);
  int i,n,sum;
  double a=0;
  
  while( cin >> n, n != 0 ){
    for(i=0;i<n;i++){
      cin >> v[i];
      sum += v[i];
    }

    double m = (double)sum / (double)n;
    
    for(i=0;i<n;i++){
      a += pow((v[i]-m),2)/n;
    }
    printf("%.8f\n",sqrt(a));
    a=0;
    sum = 0;
    v.erase(v.begin(),v.end());
  }

  return 0;
}

Measured memory_bytes: 1228
import math
n = int(input())
prime_list = []

if n == 1:
    print(0)
    exit()

for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
        prime_list.append(i)
        n /= i
        index = 2
        counter = 0
        while 1:
            if n % i == 0:
                counter += 1
                n /= i
                if(counter == index):
                    prime_list.append(i ** index)
                    index += 1
                    counter = 0
            else:
                break
if n > 1:
    prime_list.append(n)

print(len(prime_list))


Measured memory_bytes: 9272
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005

int n;

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read(); int px,py,pt; px=py=pt=0;
	for (int i=1;i<=n;i++){
		int t=read(),x=read(),y=read();
		int dis=abs(x-px)+abs(y-py);
		if (dis>t-pt||(abs(dis-t+pt)&1)){puts("No"); return 0;}
		px=x,py=y,pt=t;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
A,B,K=map(int,input().split())
l=[]
if 2*K>=B-A+1:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(K):
        print(i+A)
    for i in range(K):
        print(B-K+1+i)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll L, N;
    cin >> L >> N;
    vector<ll> X(N + 1), Y(N + 1);
    FOR(i, 1, N + 1) {
        cin >> X[i];
        Y[N + 1 - i] = L - X[i];
    }
    vector<ll> sumx(N + 1), sumy(N + 1);
    rep(i, N) {
        sumx[i + 1] = sumx[i] + X[i + 1] * 2;
        sumy[i + 1] = sumy[i] + Y[i + 1] * 2;
    }
    ll ans = 0;
    // 反時計
    FOR(i, 1, N + 1) {
        ll x = (N - i) / 2 + i;
        ll y = N - x;
        ll num = sumx[x] + sumy[y] - sumx[i - 1];
        num -= (N + i & 1 ? Y[y] : X[x]);
        chmax(ans, num);
    }
    // 時計
    FOR(i, 1, N + 1) {
        ll y = (N - i) / 2 + i;
        ll x = N - y;
        ll num = sumx[x] + sumy[y] - sumy[i - 1];
        num -= (N + i & 1 ? X[x] : Y[y]);
        chmax(ans, num);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <utility>
#include <vector>

using namespace std;
typedef pair<int, int> Pii;

int highestWorth(vector<Pii> item, int weight)
{
    int item_len = item.size();

    int dp[item_len][weight + 1];

    for (int i = 0; i < item_len; i++)
    {
        for (int j = 0; j <= weight; j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
                continue;
            }

            int before = j - item[i].second;
            if (before >= 0)
            {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][before] + item[i].first);
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], before);
            }
        }
    }

    return dp[item_len - 1][weight];
}

int main()
{
    int N, W;
    vector<Pii> item;
    cin >> N >> W;

    item.push_back(make_pair(0, 0));

    for (int i = 0; i < N; i++)
    {
        int v_i, w_i;
        cin >> v_i >> w_i;

        item.push_back(make_pair(v_i, w_i));
    }

    cout << highestWorth(item, W) << endl;
}


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

int main() {
  int N, T, c, t, m=10000000;
  cin >> N >> T;
  for (int i=0; i<N; i++) {
    cin >> c >> t;
    if (t>T) {continue;}
    m=min(m,c);
  }
  if (m==10000000) {
    cout << "TLE" << endl;
  }
  else {
    cout << m << endl;
  }
}



Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#include <numeric>

using namespace std;

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)

using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

constexpr int MAX = 210000;
int Q;
ll type[MAX], a[MAX], b[MAX];

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

    cin >> Q;

    ll sum = 0;
    priority_queue<ll> zen;
    priority_queue<ll, vector<ll>, greater<ll>> kou;
    ll zensum = 0;
    ll kousum = 0;

    for (int i = 0; i < Q; i++)
    {
        cin >> type[i];
        if (type[i] == 1)
        {

            cin >> a[i] >> b[i];
            sum += b[i];
            if (zen.size() > kou.size())
            {
                int t = zen.top();
                if (a[i] >= t)
                {
                    kou.push(a[i]);
                    kousum += a[i];
                }
                else
                {
                    zen.pop();
                    zensum -= t;
                    zen.push(a[i]);
                    zensum += a[i];
                    kou.push(t);
                    kousum += t;
                }
            }
            else
            {
                if (zen.empty())
                    zen.push(a[i]), zensum += a[i];
                else
                {
                    int t = kou.top();
                    if (a[i] <= t)
                    {
                        zen.push(a[i]);
                        zensum += a[i];
                    }
                    else
                    {
                        kou.pop();
                        kousum -= t;
                        kou.push(a[i]);
                        kousum += a[i];
                        zen.push(t);
                        zensum += t;
                    }
                }
            }
        }
        else
        {
            ll x = zen.top();
            ll res = (x * (int)zen.size() - zensum) + (kousum - x * (int)kou.size()) + sum;
            cout << x << " " << res << endl;
        }
    }
}

Measured memory_bytes: 8692
s=input()
t=input()
for i in range(len(t)-1,len(s))[::-1]:
    if s[i]==t[-1] or s[i]=="?":
        if all(s[i-j]==t[-1-j] or s[i-j]=="?" for j in range(len(t))):
            s=s.replace("?","a")
            print(s[:i-len(t)+1]+t+s[i+1:])
            exit()
print("UNRESTORABLE")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  string s;
  string t;
  cin>>s>>t;
  string d;
  if(s==t){cout<<s.size()<<endl;return 0;}
  else{
	  int ans=s.size()+t.size();
   for(int i=0;i<N;i++){
	  if(s.substr(i)==t.substr(0,N-i)){
       d=s.substr(0,i)+t;
	   int a=d.size();
	   ans=min(ans,a);
	  }
  }
   cout<<ans<<endl;return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define np basic_string::npos
int main(void){
    int n,mm=0,i=1;
    cin>>n;
    while(mm<n){
        mm+=i;
        i++;
    }
    cout<<i-1<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val h = IntArray(n) { sc.nextInt() }

    var sum = 0

    (0 until h.size).forEach { i ->
        var cur = h[i]

        sum += cur

        (i until h.size).forEach { j ->
            cur = Math.min(cur, h[j])
            h[j] = h[j] - cur
        }
    }

    val ret = sum
    println(ret)
}

Measured memory_bytes: 31520
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
 
int main() {
  int64_t X;
  cin>>X;
  int sum=0;
  for(int i=0;i<=1000000000;i++){
    sum+=i;
    if(sum>=X){cout<<i<<endl;return 0;}
  }
  
  return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	void run(){
		int n = sc.nextInt();
		
		char[][] map = new char[n][];
		
		for(int i =0; i < n ; i++){
			map[i] = sc.next().toCharArray();
		}
		
		
		int ans = 0;
		
		
		for(int k = 0 ; k  < n ; k++){
			
			
			boolean flag = true;
			for(int i = 0; i < n ; i++){
				for(int j = i+1;j<n;j++){
					
					int ii = (i +k)%n;
					int jj = j;
					
					int jjj = i;
					int iii = (j+k)%n;
					
					flag &= map[ii][jj] == map[iii][jjj];
					if(!flag){
						break;
					}
				}
				if(!flag){
					break;
				}
			}
			
			if(flag){
				ans++;
			}
		}
		
		
		System.out.println(ans*n);
		
		
	}
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
	}
}

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

int main() {
	//int scores[8]={399,799, 1199, 1599, 1999, 2399, 2799, 3199};
	//string colors[8]={"gray","brown", "green", "cyan", "blue", "yellow","orange","red"};
	int colo[9]={};
	int n;
	cin>>n;
	int arr[n];
	for (int i=0; i<n; i++){
		cin >> arr[i];
	}
	for (int i=0; i<n; i++){
		if (arr[i]<=399) colo[0]++;
		else if (arr[i]<=799) colo[1]++;
		else if (arr[i]<=1199) colo[2]++;
		else if (arr[i]<=1599) colo[3]++;
		else if (arr[i]<=1999) colo[4]++;
		else if (arr[i]<=2399) colo[5]++;
		else if (arr[i]<=2799) colo[6]++;
		else if (arr[i]<=3199) colo[7]++;
		else colo[8]++;
	}
	int total=0;
	for (int i=0; i<8; i++){
		//cout << colo[i];
		if (colo[i]>0) total++;
	}
	//cout << endl;
	if (colo[8]==0)
		cout << total << ' ' << total << endl;
	else{ 
		if ( total>0 ) cout << total << ' ' << total+colo[8] << endl; 
		else cout << 1 << ' ' << colo[8] << endl; 
	} 
}

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

#define div 2019

ll rem[2019];

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

    string s;
    cin>>s;

    ll cur = 0;
    ll stha = 1;

    ll pairr = 0;

    for(ll i = s.size()-1; i >= 0; i--){
        ll temp = s[i]-48;
        temp *= stha;
        cur += temp;

        ll t_rem = cur%div;
        if(t_rem == 0) pairr++;
        pairr += rem[t_rem];
        rem[t_rem]++;

        stha *= 10;

        stha %= div;
        cur %= div;

    }

    cout<<pairr<<'\n';


    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int MAXN = 200;
//ll a[MAXN], ST[MAXN * 4], LZ[MAXN*4];

/*bool perfectSquare(ll x){
    ll s = sqrt(x);
    if(s *s == x) return true;
    else return false;
}*/
typedef long double ld;

int main() { 
    ll r = 0;
    cin >> r;
    float p = 3.14159;
    cout << setprecision(10) << r*2*p << endl;
  
    return 0; 
} 


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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

    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));

    if (m >= 5) {
        cout << "TBD" << endl;
    }
    else {
        cout << "Heisei" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>

int S[1000000],T[500000];

int binarySearch(int x,int n){
  int key = T[x];
  int left = 0;
  int right = n;
  int mid;
  
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key){
      return mid;
    }else if(key < S[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }

  return -1;
}

int main(){
  int n,q,cnt = 0;
  int ans;
  std::scanf("%d",&n);

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

  std::scanf("%d",&q);

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

  for(int i = 0;i < q;i++){
    ans  = binarySearch(i,n);
    if(ans != -1){
      cnt++;
    }
  }
  
  std::printf("%d\n",cnt);

  return 0;
}


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

def string_two_numbers_spliter():
    a, b, c = [int(i) for i in input().split()]
    return a, b, c


def count_nums_of_divisors_of_c_in_a_and_b(a, b, c):
    count = 0
    for i in range(1, c+1):
        if (c % i == 0):
            if i >= a and i <= b:
                count += 1
    return count


def main():
    a, b, c = string_two_numbers_spliter()
    print(count_nums_of_divisors_of_c_in_a_and_b(a, b, c))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7760
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     int N,M;
     cin >> N >> M;
     char A[N+10][N+10],B[M+10][M+10];
     for(int i=0; i<N; i++){
         for(int j=0; j<N; j++){
             cin >> A[i][j];
         }
     }for(int i=0; i<M; i++){
         for(int j=0; j<M; j++){
             cin >> B[i][j];
         }
     }
     bool ex=false;
     for(int i=0; i<N; i++){
         for(int j=0; j<N; j++){
             if(i+M-1>=N || j+M-1>=N) continue;

             bool ma=true;
             for(int y=0; y<M; y++){
                 for(int x=0; x<M; x++){
                     if(A[i+y][j+x]!=B[x][y]){
                         ma = false;
                     }
                 }
             }
             if(ma) ex=true;
         }
     }
    if(ex) cout << "Yes" << endl;
    else cout << "No" << endl;
 }


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

using namespace std;

int main(){

	int n, ofi=0, efi=0, oma=0, ema=0, oma2=0, ema2=0;
	vector<int> v, vo(100002, 0), ve(100002, 0);

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>> v[i];
		if(i%2==1){
			ve[v[i]]++;
		}else{
			vo[v[i]]++;
		}
	}

	for(int i=0;i<100002;i++){
		if(oma<=vo[i]){
			oma2=oma;
			oma=vo[i];
			ofi=i;
		}else if(oma2<=vo[i]){
			oma2=vo[i];
		}

		if(ema<=ve[i]){
			ema2=ema;
			ema=ve[i];
			efi=i;
		}else if(ema2<=ve[i]){
			ema2=ve[i];
		}
	}

	//cout<< oma2 << " " << oma << " " << ofi2 << " " << ofi << endl;
	//cout<< ema2 << " " << ema << " " << efi2 << " " << efi << endl;

	if(ofi!=efi){
		cout<< n-oma-ema << endl;
	}else{
		cout<< min(n-oma-ema2, n-oma2-ema) << endl;
	}

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll n, k;
ll mini;
int main() {
    IOS; cin >> n >> k;
    ll p=0LL;
    if(n>=k) p=(n-k)/k+1;
    n-=p*k;
    mini=(ll)1e18+99;
    mini=min(min(mini, n), k-n);
    cout << mini;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

// BEGIN NO SAD
#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()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

ll facs[3005];
ll ifacs[3005];

int ret[3005];
void solve() {
  int p;
  cin >> p;
  facs[0] = 1;
  for(int i = 1; i < p; i++) {
    facs[i] = facs[i-1] * i;
    facs[i] %= p;
  }
  ifacs[p-1] = p-1;
  for(int i = p-2; i >= 0; i--) {
    ifacs[i] = ifacs[i+1] * (i+1);
    ifacs[i] %= p;
  }
  for(int i = 0; i < p; i++) {
    vector<int> modpows;
    modpows.push_back(1);
    while(sz(modpows) < p) {
      int curr = modpows.back();
      curr *= -i;
      curr %= p;
      if(curr < 0) curr += p;
      modpows.push_back(curr);
    }
    int x;
    cin >> x;
    if(x == 1) {
      ret[0]++;
      for(int a = 0; a < p; a++) {
        long scale = facs[p-1];
        scale *= ifacs[a];
        scale %= p;
        scale *= ifacs[p-1-a];
        scale %= p;
        scale *= modpows[p-1-a];
        scale %= p;
        ret[a] -= scale;
        ret[a] %= p;
        ret[a] += p;
        ret[a] %= p;
      }
    }
  }
  for(int i = 0; i < p; i++) {
    if(i) cout << " "; cout << ret[i]%p;
  } cout << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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



int main()
{
    int a,b;
    cin >> a >> b;

    if(abs(a-b)%2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, maxi = -1e9, mini = 1e9;
	long long int sum = 0;
	cin >> n;
	int seq[n];
	for (int i = 0; i < n; i++) {
		cin >> seq[i];
	}
	for (int i = 0; i < n; i++) {
		maxi = max(maxi, seq[i]);
		mini = min(mini, seq[i]);
		sum += seq[i];
	}
	cout << mini << ' ' << maxi << ' ' << sum << endl;
	return 0;
}


Measured memory_bytes: 3144
n, m = gets.chomp.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
l = [n, m].inject(:gcd)
i = 0
j = 0
while i < n && j < m
  if s[i] != t[j]
    puts -1
    exit
  end
  i += n / l
  j += m / l
end
puts n/l*m

Measured memory_bytes: 2044
from collections import defaultdict
from collections import deque
d = defaultdict(list)
n, m = map(int, input().split())

for i in range(m):
    a, b = map(int, input().split())
    d[a-1].append(b-1)
    d[b-1].append(a-1)
seen = set([0])
q = deque([0])
ans = [0] * n
while q:
    parent = q.popleft()
    for child in d[parent]:
        if child not in seen:
            ans[child] = parent + 1
            q.append(child)
            seen.add(child)
    if len(seen) == n:
        break
print('Yes')
for i in ans[1:]:
    print(i)







Measured memory_bytes: 116100
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int n;
	ll a[200005];
	ll sol1=0,sol2=0,ans,sol=MAX;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sol1+=a[i];
	}
	for(int i=1;i<=n-1;i++){
		sol2+=a[i];
		sol1-=a[i];
		ans=abs(sol1-sol2);
		sol=min(sol,ans);
	}
	cout<<sol;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1792