akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Globalization;
using System.IO;
using System.Text;

public class Program
{
    public static void Main(string[] args)
    {
        var stdin = Console.OpenStandardInput();
        var ss = new StreamScanner(stdin);
        var p = new Program();
        p.solve(ss);
        stdin.Close();
    }

    private void solve(StreamScanner ss)
    {
        var x = ss.IntArray(5);
        var i = 0;
        while (i < 5)
        {
            if (x[i] == 0) break;
            ++i;
        }
        Console.WriteLine(++i);
    }
}
public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char
    {
        get
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
    }

    public string Scan
    {
        get
        {
            var sb = new StringBuilder();
            for (var b = Char; b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
    }

    public long Long
    {
        get
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
    }

    public int Int => (int)Long;

    public int[] IntArray(int n)
    {
        var arr = new int[n];
        for (var i = 0; i < n; ++i)
        {
            arr[i] = Int;
        }
        return arr;
    }

    public double Double => double.Parse(Scan, CultureInfo.InvariantCulture);
}


Measured memory_bytes: 25812
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N;
    cin >> N;
    set<int> s;
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        if(s.count(a) == 1) {
            s.erase(a);
        } else {
            s.insert(a);
        }
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 4864
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize,
        k: usize
    }
    if k >= a + b {
        println!("0 0");
    } else if k <= a {
        println!("{} {}", a - k, b);
    } else {
        println!("0 {}", a + b - k);
    }
}


Measured memory_bytes: 4352
from math import sqrt
from math import ceil
from collections import defaultdict
N=int(input())
done=defaultdict(int)
ans=0
#割る数がi 商とあまりがi 
for i in range(1,ceil(sqrt(N))+1):
    if N//i == N%i:
        if done[i]==0:
            ans+=i
            #print(i)
            done[i]=1
    if (N-i)%i==0:
        if done[(N-i)//i]==0 and (N-i)//i>i:
            ans+=(N-i)//i
            #print((N-i)//i)
            done[(N-i)//i]=1
print(ans)
#print(ceil(sqrt(1000000000000)))

Measured memory_bytes: 68444
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll gcd = __gcd(c,d);
  ll lcm = c * d / gcd;
  ll n1, n2,n3;
  n1 = b / c - (a-1) / c;
  n2 = b / d - (a-1) / d;
  n3 = b / lcm - (a-1) / lcm;
  ll ans = b - a + 1 - n1 - n2 + n3;
  cout << ans << endl;
}

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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int N;
	cin >> N;
	
	int ans = 0;
	int sum = 0;

	int A;
	rep(i, 0, N)
	{
		cin >> A;
		ans += sum * A;
		sum += A;
		sum %= MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			long[] array = new long[n];
			for (int i = 0; i<n; i++) array[i] = sc.nextLong();
			int query = sc.nextInt();
			for (int i = 0; i<query; i++) {
				Long k = sc.nextLong();
				if (k > array[n - 1]) System.out.println(n + " " + n);
				else {
					System.out.println(lowerBound(array,k) + " " + upperBound(array,k));
				}
			}
		}
	}

	static int lowerBound(long[] array, long target) {
		int low = 0;
		int high = array.length-1;  //最後

		while (low < high) {
			//System.out.println(low + "    "+ high);
			int mid = (high + low)/2;
			if (array[mid] == target) {
				while ((mid != 0)&&(array[mid - 1] == target)) mid--;  //前がある場合移動
				return mid;
			}
			else if (array[mid] < target) low = mid + 1;
			else high = mid;
		}
		while ((high != 0)&&(array[high - 1] == array[high])) high--;  //前がある場合移動
		return high;
	}

	static int upperBound(long[] array, long target) {
		int low = 0;
		int high = array.length-1;  //最後

		if (array[high] <= target) return array.length;  //targetより大きい数値が存在しない場合nをreturn

		while (low < high) {
			//System.out.println(low + "    "+ high);
			int mid = (high + low)/2;
			if (array[mid] <= target) low = mid + 1;
			else high = mid;
		}
		while ((high != 0)&&(array[high - 1] == array[high])) high--;  //前がある場合移動
		return high;
	}
}


Measured memory_bytes: 120728
#include<iostream>
#include<cstdio>
#include<string>
using namespace std; 

int main(){
	int a,b,c,d,x,y;
	cin>>a>>b>>c>>d;
	x=a*b;y=c*d;
	
	if(x>y)cout<<x;
	else cout<<y;
	return 0;
}

Measured memory_bytes: 256
// C++ program to find the longest
	// path in the DAG

	#include <bits/stdc++.h>
	using namespace std;
	void dfs(int node,vector<int>adj[], vector<int>&dp,vector<bool>&vis)
	{
		vis[node]=true;
		for(int j=0;j<adj[node].size();j++){
			if(!vis[adj[node][j]])dfs(adj[node][j],adj,dp,vis);
			 dp[node]=max(dp[node],dp[adj[node][j]]+1);
		}
	}
	int findLongestPath(vector<int>adj[], int n){
		vector<int>dp(n+1,0);
		vector<bool>vis(n+1,false);
		for(int i=1;i<=n;i++)if(!vis[i])dfs(i,adj,dp,vis);
		int ans=0;
		for(int i=1;i<=n;i++){
			ans=max(ans,dp[i]);
		}
		return ans;
	}
	// Driver Code
	int main()
	{
		int n ;
		cin>>n;
		int m;
		cin>>m;

		vector<int> adj[n + 1];
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
	}
		// Example-1
		// addEdge(adj, 1, 2);
		// addEdge(adj, 1, 3);
		// addEdge(adj, 3, 2);
		// addEdge(adj, 2, 4);
		// addEdge(adj, 3, 4);

		cout << findLongestPath(adj, n);
		return 0;
	}


Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    int n; cin>>n;
    vector<ll> v(n);
    int k=0;
    for(auto& a:v) cin>>a;
    sort(v.begin(), v.end());
    for(int i=0; i<=n-3; i++)
    	for(int j=i+1; j<=n-2; j++)
    		for(int m=j+1; m<=n-1; m++){
    			if(v[i]!=v[j]&&v[j]!=v[m]&&v[m]!=v[i]&&v[i]+v[j]>v[m]) k++;
    		}
    cout<<k<<endl;
    return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

template<class T> class segtree{
public:
    int n,size_;
    vector<T> dat;
    function<T(T,T)> fun_;
    T id_;
    segtree()=default;
    segtree(int size,function<T(T,T)> fun,T id,T initial_value){ init(size,fun,id,initial_value); }
    void init(int size,function<T(T,T)> fun,T id,T initial_value){
        size_=size;
        fun_=fun;
        id_=id;
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,id);
        for(int i=0; i<size; ++i) update(i,initial_value);
    }
    int size()const{ return size_; }
    void update(int k, T a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=fun_(dat[k*2+1],dat[k*2+2]);
        }
    }
    T at(int index){ return dat[index+n-1]; }
    void add(int k,T a){ update(k,at(k)+a); }
    T query(int a,int b) { return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return id_;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return fun_(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    string s;
    cin >> s;
    vector<int> cnt[26];
    rep(i,0,26) cnt[i].resize(s.size());

    ++cnt[s[0]-'a'][0];
    rep(i,1,s.size()){
        rep(j,0,26) cnt[j][i]=cnt[j][i-1];
        ++cnt[s[i]-'a'][i];
    }

    segtree<pii> seg[26];
    rep(i,0,26) seg[i].init(s.size(),[](pii x,pii y){ return max(x,y); },make_pair(-inf,-1),make_pair(-inf,-1));
    rep(c,0,26) rep(i,0,s.size()) seg[c].update(i,make_pair(2*cnt[c][i]-i,i));

    int x=s.size()-2;
    for(int i=-1; i<=x; ++i){
        //rep(c,0,26){
            int c=s[i+1]-'a';
            int k=-i;
            if(i>=0) k+=2*cnt[c][i];
            pii p=seg[c].query(i+2,s.size());
            if(p.first>=k){
                int j=p.second;
                int y=cnt[c][j];
                if(i>=0) y-=cnt[c][i];
                if(y<(j-i+2)/2) continue;
                cout << i+2 << " " << j+1 << endl;
                return;
            }
        //}
    }
    cout << "-1 -1" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 64080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long K){
	if (K>1) cout << N-K << endl; else cout << 0 << endl;
}

int main(){	
	long long N;
	long long K;
	scanf("%lld",&N);
	scanf("%lld",&K);
	solve(N, K);
	return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
A=[]
par=[-1]*n
def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True
def same(x,y):
  return find(x)==find(y)
def size(x):
  return -par[find(x)]
for i in range(m):
  a,b=map(int,input().split())
  A.append([a,b])
A=A[::-1]
ans=n*(n-1)//2
Ans=[ans]
for i in range(m):
  a,b=A[i]
  if not same(a-1,b-1):
    ans-=(size(a-1)*size(b-1))
  Ans.append(ans)
  unite(a-1,b-1)
Ans=Ans[::-1][1:]
print(*Ans,sep="\n")


Measured memory_bytes: 28636
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using namespace atcoder;
using ll = long long;
const int mod = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    int r = 0, g = 0, b = 0;
    rep(i, n)
    {
        if (s[i] == 'R')
            r++;
        if (s[i] == 'G')
            g++;
        if (s[i] == 'B')
            b++;
    }
    ans += (ll)r * g * b;
    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
    {
        for (int j = 1;; j++)
        {
            if (i - j < 0 || n <= i + j)
                break;
            if (s[i - j] == 'R' && s[i] == 'G' && s[i + j] == 'B')
                cnt++;
            if (s[i - j] == 'R' && s[i] == 'B' && s[i + j] == 'G')
                cnt++;
            if (s[i - j] == 'B' && s[i] == 'G' && s[i + j] == 'R')
                cnt++;
            if (s[i - j] == 'B' && s[i] == 'R' && s[i + j] == 'G')
                cnt++;
            if (s[i - j] == 'G' && s[i] == 'R' && s[i + j] == 'B')
                cnt++;
            if (s[i - j] == 'G' && s[i] == 'B' && s[i + j] == 'R')
                cnt++;
        }
    }
    ans -= cnt;
    cout << ans << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}


void Main() {
    ll N;
    cin >> N;
    map<ll, ll> div;
    rep2(i, 1, N + 1) {
        for (auto p : prime_factorize(i)) {
            div[p.first] += p.second;
        }
    }
    ll ans = 0;
    for (P p : div) {
        if (p.second >= 74) {
            ans++;
        }
    }
    ll a24 = 0;
    ll a2 = 0;
    for (P p : div) {
        if (p.second >= 24) {
            a24++;
        }
        if (p.second >= 2) {
            a2++;
        }
    }
    ans += a24 * (a2 - 1);

    ll a14 = 0;
    ll a4 = 0;
    for (P p : div) {
        if (p.second >= 14) {
            a14++;
        }
        if (p.second >= 4) {
            a4++;
        }
    }
    ans += a14 * (a4 - 1);

    ll b4 = 0;
    ll b2 = 0;
    for (P p : div) {
        if (p.second >= 4) {
            b4++;
        }
        if (p.second >= 2) {
            b2++;
        }
    }
    ans += (b4 - 1) * b4 * (b2 - 2) / 2;
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int IsPrime(int a){
    if(a==2) return 1;
    int k,j;
    j = sqrt(a);
    for(k=2; k<=j; k++){
        if(a%k == 0) return 0;
    }
    return 1;
}


int main()
{
    int N;
    int counter=0;
    scanf("%d",&N);
    int arr[N];
    int i=0;
    for(i=0; i<N; i++){
        scanf("%d",&arr[i]);
        if(IsPrime(arr[i])==1) counter = counter+1;
    }
    printf("%d\n",counter);

    return 0;
}



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

int main()
{
	long long int N, i, k, ans, a[100001], b[100001]; 
	cin>> N;
	ans=0;
	for(i=1;i<=N;i++)
	{
		b[i]=0;
	}
	for(i=1;i<=N;i++)
	{
		cin >> a[i];
		if(a[i]>N) ans++;
		else 
		{
			k=a[i];
			b[k]++;	
		}

	}
	for(i=1;i<=N;i++)
	{
		if(b[i]<i) ans+=b[i];
		else ans+=b[i]-i;	
	}
	cout<< ans;
}
  

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X, K, D = map(int, input().split())
X = abs(X)

need = X // D
t = min(need, K)

X -= D * t
K -= t

if K > 0:
    if K % 2:
        X -= D
print(abs(X))



Measured memory_bytes: 10840
#include <stdio.h>
#include<math.h>
#include<stdlib.h>


int main(int argc, const char * argv[]) {
    int n,i;
    double sum1=0,sum2=0,sum3,max=0,ans[4];
    
    scanf("%d",&n);
    double x[n],y[n];
    for(i=0;i<n;i++)
        scanf("%lf",&x[i]);
    for(i=0;i<n;i++)
        scanf("%lf",&y[i]);
    for(i=0;i<n;i++){
        
        sum1+=abs(x[i]-y[i]);
        if(abs(x[i]-y[i])>max)
            max=abs(x[i]-y[i]);
        
        sum2+=pow(abs(x[i]-y[i]),2);
        sum3+=pow(abs(x[i]-y[i]),3);
        
    }
    
    
    printf("%lf\n",sum1);
    printf("%lf\n",sqrt(sum2));
    printf("%lf\n",cbrt(sum3));
    printf("%lf\n",max);
    
    return 0;
    
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int N; cin >> N;

	bool ans = false;
	FOR(i,1,10){
		int p = N / i;
		if(N % i == 0 and (p >= 1 and p <= 9)) ans = true;
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        str = string.Join("", str.Reverse());
        var p = new[] { "maerd", "remaerd", "esare", "resare" };
        var index = 0;
        while (index != str.Length)
        {
            if (str.Substring(index, 5) == p[0] ||
                str.Substring(index, 5) == p[2]) index += 5;
            else if (str.Substring(index, 6) == p[3]) index += 6;
            else if (str.Substring(index, 7) == p[1]) index += 7;
            else break;
        }
        WriteLine(index == str.Length? "YES" : "NO");
    }
}


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

ll ceil(ll a, ll b){
    ll ci=1;
    if(a % b == 0) ci = 0;
    return a/b+ci ;
}

int main() {
    ll N; cin >> N;
    vector<pair<ll, ll>> R(N);
    for(ll i = 0; i < N; i++){
        ll a, b; cin >> a >> b; 
        R[i] = make_pair(a, b);
    }
    ll minx=R[0].first, miny=R[0].second;
    for(ll i = 1; i < N; i++){
        ll rx, ry;
        rx = R[i].first, ry = R[i].second;
        ll n;
        n = max(ceil(minx, rx), ceil(miny, ry));
        minx = rx*n; miny = ry*n;
    }
    cout << minx+miny << endl;
}

Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second


int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
//ios_base& scientific (ios_base& str);

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	if (k - a <= 0)
		cout << k << "\n";
	else if (k - a - b <= 0)
		cout << a << "\n";
	else
		cout << a - (k - a - b) << "\n";
	return 0;
}

Measured memory_bytes: 3640
#import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

fibo = [1, 1]
for i in range(1, 10**5+2):
    fibo.append(fibo[i]+fibo[i-1])

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

a=[]
for i in range(m):
    a.append(int(input()))

flg=True
for i in range(m-1):
    if a[i]+1==a[i+1]:
        flg=False
        break

if not flg:
    print(0)

else:
    ans=1
    if m==1:
        print(fibo[a[0]-1]*fibo[n-a[0]-1] % (10**9+7))

    elif m==0:
        print((fibo[n]) % (10**9+7))

    else:
        for i in range(1,m):
            ans*=fibo[a[i]-a[i-1]-2]   
        print(ans*fibo[a[0]-1]*fibo[n-a[m-1]-1]%(10**9+7))




Measured memory_bytes: 464184
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

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

	set<int> info;

	for (int i = 0; i < K; i++)
	{
		int d;
		cin >> d;

		for (int j = 0; j < d; j++)
		{
			int a;
			cin >> a;

			info.insert(a);
		}
	}

	cout << N - info.size();

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

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

int N,C;
vector<P> A[32];
bool used[SIZE];

bool comp(const P &a,const P &b){
	if(a.first != b.first){
		return a.first < b.first;
	}else{
		return a.second > b.second;
	}
}

int main()
{
	cin >> N >> C;
	int fst,snd,c;
	rep(i,0,N){
		cin >> fst >> snd >> c;
		A[c].push_back(P(fst,snd));
	}
	vector<P> D;
	rep(i,1,C+1){
		if(A[i].size() == 0)continue;
		sort(A[i].begin(),A[i].end());
		stack<P> S;
		S.push(A[i][0]);
		rep(j,1,A[i].size()){
			if(A[i][j-1].second == A[i][j].first){
				P s = S.top();S.pop();
				s.second = A[i][j].second;
				S.push(s);
			}else{
				S.push(A[i][j]);
			}
		}
		while(!S.empty()){
			P s = S.top();S.pop();
			D.push_back(s);
		}
	}
	sort(D.begin(),D.end(),comp);
	int cnt=0,ans=0,t=0;
	while(cnt < D.size()){
		t=0;
		ans++;
		rep(i,0,D.size()){
			if(used[i])continue;
			if(D[i].first <= t)continue;
			t = D[i].second;
			used[i] = true;
			cnt++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2552
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto ts=readln.split.to!(int[]);
  auto vs=readln.split.to!(int[]);

  foreach(i; 1..n) ts[i]+=ts[i-1];

  int T=100*200*2+1, V=100*2+1;
  auto dp=new double[][](T, V);
  foreach(i; 0..T)foreach(j; 0..V) dp[i][j]=-1;
  dp[0][0]=0;
  int t=0;
  foreach(i; 0..n){
    do{
      for(int v=0; v<=vs[i]*2; v++)if(dp[t][v]>=0){
        chmax(dp[t+1][v], dp[t][v]+v);
        if(v+1<=vs[i]*2) chmax(dp[t+1][v+1], dp[t][v]+(v+(v+1))/2.0);
        if(v-1>=0) chmax(dp[t+1][v-1], dp[t][v]+(v+(v-1))/2.0);
      }
    }while((++t)<ts[i]*2);
  }

  writefln("%.18f", dp[ts[$-1]*2][0]/4.0);
}

void chmax(T)(ref T l, T r){if(l<r)l=r;}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


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

int main()
{
    int a, b;
    cin>>a>>b;
    if(a==b)cout<<"Draw"<<endl;
    else if(b==1)cout<<"Bob"<<endl;
    else if(a==1)cout<<"Alice"<<endl;
    else if(a>b)cout<<"Alice"<<endl;
    else if(a<b)cout<<"Bob"<<endl;


    return 0;
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << C << " " << A << " " << B << endl;
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int main(void){
	int64 N;
	cin >> N;
	vector<double> p(N);
	REP(i, N) cin >> p[i];
	vector<double> dp(N+1, 0);
	dp[0] = 1;
	REP(i, N){
		vector<double> dp2(N+1, 0);
		REP(j, i+1){
			dp2[j+1] += dp[j]*p[i];
			dp2[j] += dp[j]*(1-p[i]);
		}
		swap(dp, dp2);
	}
	double res = 0;
	FOR(i, N/2+1, N+1){
		res += dp[i];
	}
	cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
d.sort()
t=[0,24]
for i in range(n):
  if i%2==1:t.append(d[i])
  else:t.append((24-d[i])%24)
t.sort()
print(min(t[i]-t[i-1]for i in range(1,len(t))))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll C[N-1],S[N-1],F[N-1];
    ll i,j;
    for(i=0;i<N-1;i++){
      cin >> C[i] >> S[i] >> F[i];
    }
    ll ans;
    for(i=0;i<N-1;i++){
      ans=0;
      for(j=i;j<N-1;j++){
        if(ans<=S[j]){
          ans=C[j]+S[j];
        }else{
          ans=(ans+F[j]-1)/F[j]*F[j]+C[j];
        }
      }
      cout << ans<<endl;
    }
    cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    double n;
    cin >> n;
    for (double i = 1; i <= 50000; ++i) {
        if(floor(i * 1.08) == n){
            pf(i)
            return 0;
        }
    }
    pf(":(")
    return 0;
}


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

typedef pair<int,int>P;
typedef pair<int,P>PP;

int L[524288];
int R[524288];
int xmax[524288];
int xmin[524288];
int ymax[524288];
int ymin[524288];
vector<int>B;
void init(){
	L[0]=0;
	R[0]=524286;
	for(int i=0;i<262144;i++){
		L[i+262143]=R[i+262143]=i;
		
		xmax[i+262143]=-1;
		ymax[i+262143]=-1;
		xmin[i+262143]=81089319;
		ymin[i+262143]=81089319;
		
	}
	for(int i=262142;i>=0;i--){
		L[i]=L[2*i+1];
		R[i]=R[2*i+2];
		
		xmax[i]=-1;
		ymax[i]=-1;
		xmin[i]=81089319;
		ymin[i]=81089319;
		
		
	}
}

int tmpb,tmpx;
void update(int x,int y,int b){
	if(b>tmpb){
		tmpx++;
		tmpb=b;
		B.push_back(b);
	}
	xmax[tmpx]=max(x,xmax[tmpx]);
	xmin[tmpx]=min(x,xmin[tmpx]);
	ymax[tmpx]=max(y,ymax[tmpx]);
	ymin[tmpx]=min(y,ymin[tmpx]);
	
	for(int i=(tmpx-1)/2;true;i=(i-1)/2){
		xmax[i]=max(xmax[2*i+1],xmax[2*i+2]);
		xmin[i]=min(xmin[2*i+1],xmin[2*i+2]);
		ymax[i]=max(ymax[2*i+1],ymax[2*i+2]);
		ymin[i]=min(ymin[2*i+1],ymin[2*i+2]);
		if(i==0)break;
	}
	
}

int l,r,tmp;
stack<int>st;
void xmx(int p){
	if(r<L[p] || l>R[p])return;
	if(L[p]<l || r<R[p]){
		st.push(p*2+1);
		st.push(p*2+2);
		return;
	}
	tmp=max(tmp,xmax[p]);
	return;
}
void xmn(int p){
	if(r<L[p] || l>R[p])return;
	if(L[p]<l || r<R[p]){
		st.push(p*2+1);
		st.push(p*2+2);
		return;
	}
	tmp=min(tmp,xmin[p]);
	return;
}
void ymx(int p){
	if(r<L[p] || l>R[p])return;
	if(L[p]<l || r<R[p]){
		st.push(p*2+1);
		st.push(p*2+2);
		return;
	}
	tmp=max(tmp,ymax[p]);
	return;
}
void ymn(int p){
	if(r<L[p] || l>R[p])return;
	if(L[p]<l || r<R[p]){
		st.push(p*2+1);
		st.push(p*2+2);
		return;
	}
	tmp=min(tmp,ymin[p]);
	return;
}


int main(){
	
	init();
	
	
	int n,d;cin>>n>>d;
	vector<PP>V(n);
	for(int i=0;i<n;i++){
		cin>>V[i].second.first>>V[i].second.second>>V[i].first;
	}
	sort(V.begin(),V.end());
	tmpb=-1,tmpx=262142;
	for(int i=0;i<n;i++)update(V[i].second.first,V[i].second.second,V[i].first);
	
	long long ans=0;
	
	for(int i=0,j=0;i<B.size();i++){
		
		while(j+1<B.size()){
			if(d>=B[j+1]-B[i])j++;
			else break;
		}
		l=i;
		r=j;
		
		tmp=-1;
		st.push(0);
		while(!st.empty()){
			int k=st.top();
			st.pop();
			xmx(k);
		}
		long long x=tmp;
		tmp=81089319;
		st.push(0);
		while(!st.empty()){
			int k=st.top();
			st.pop();
			xmn(k);
		}
		x-=tmp;
		tmp=-1;
		st.push(0);
		while(!st.empty()){
			int k=st.top();
			st.pop();
			ymx(k);
		}
		long long y=tmp;
		tmp=81089319;
		st.push(0);
		while(!st.empty()){
			int k=st.top();
			st.pop();
			ymn(k);
		}
		y-=tmp;
		
		
		ans=max(ans,x*y);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int pcount = 0;
  int gcount = 0;
  for (int i=0; i<s.size(); i++){
    if (s[i] == 'p') pcount++;
    else gcount++;
  }
  cout << s.size()/2 - pcount << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		long long a,b,c;
		scanf("%lld%lld",&a,&b);
		c=int(sqrt(a*b));
		if(c*(c+1)<a*b)
			printf("%lld\n",2*c-1);
		else if(c*c==a*b){
			if(a==b)
				printf("%lld\n",2*c-2);
			else
				printf("%lld\n",2*c-3);
		}
		else
			printf("%lld\n",2*c-2);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;
 
int main(){
    vector<tuple<string, int, int>> res;
    int n, p;
    string s;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s >> p;
        res.push_back(make_tuple(s,-p,i+1));
    }
    sort(res.begin(), res.end());
    for(auto v: res){
        cout << get<2>(v) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int H, W;
char map[50][50];

int paint(int h, int w) {
  if (h-1 >= 0) {
    if (map[h-1][w] == '#') return 1;
  }
  if (h+1 < H) {
    if (map[h+1][w] == '#') return 1;
  }
  if (w-1 >= 0) {
    if (map[h][w-1] == '#') return 1;
  }
  if (w+1 < W) {
    if (map[h][w+1] == '#') return 1;
  }
  return 0;
}

int main() {
  int i, j;
  
  scanf("%d %d", &H, &W);
  getchar();
  
  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      scanf("%c", &map[i][j]);
    }
    getchar();
  }
  
  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      if (map[i][j] == '#') {
	if (!paint(i, j)) {
	  printf("No\n");
	  return 0;
	}
      }
    }
  }

  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
str = input()

split = str.split(" ")

Member = int(split[0])
Point = int(split[1])
Ans = int(split[2])
MemPoint = [0 for i in range(Member)]

for i in range(Ans):
  MemPoint[int(input())-1] += 1

for i in range(Member):
  if Point - (Ans - MemPoint[i]) > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4620
import math

N, K = map(int, input().split())
ans = 0

for i in range(1, N+1):
  if i < K:
    cnt = math.ceil(math.log2(K / i))
    ans += (1 / N) * (1 / 2)**cnt
  else:
    ans += 1 / N

print(ans)

Measured memory_bytes: 3188
def main():
    from decimal import Decimal

    a,b,c = map(int, input().split())
    a,b,c = Decimal(a) ,Decimal(b), Decimal(c)
    f = a.sqrt() + b.sqrt() < c.sqrt()
    print("Yes" if f else "No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
def main20():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    if buf[0] <= 0 and 0 <= buf[1]:
        print("Zero");
    elif buf[0] > 0:
        print("Positive");
    else:
        kazu = buf[1] - buf[0] + 1;
        if kazu % 2 == 0:
            print("Positive");
        else:
            print("Negative");


if __name__ == '__main__':
    main20()

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}




void solve(){
  ll N; cin>>N;
  ll z_min,z_max,w_min,w_max;
  REP(i,N){
    ll x,y; cin>>x>>y;
    if(i>0){
      chmin(z_min,x+y);
      chmax(z_max,x+y);
      chmin(w_min,x-y);
      chmax(w_max,x-y);
    }else{
      z_min = x+y;
      z_max = x+y;
      w_max = x-y;
      w_min = x-y;
    }
  }
  ll ans = max(z_max-z_min,w_max-w_min);
  cout << ans << "\n";
}
int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int res = 0;
        for (int i=0; i<N; i++) {
            int h = sc.nextInt();
            if (h>=K) {
                res += 1;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 46212
n = int(input())
t0 = x0 = y0 = 0
for _ in range(n):
  t, x, y = map(int, input().split())
  dt, dx, dy = t - t0, x - x0, y - y0
  dist = abs(dx) + abs(dy)
  if dist > dt or dist % 2 != dt % 2 :
    print('No')
    exit()
  t0, x0, y0 = t, x, y
print('Yes')

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<utility>
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
const int maxn = 2e5 + 233;
long long ans = 0;
int a[maxn];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)a[i]-=i;
	sort(a+1,a+1+n);
	int t = n>>1;
	if(n%2==1)t++;
	int b = a[t];
	for(int i=1;i<=n;i++)ans += abs(a[i]-b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import deque
H, W = map(int, input().split())
sheet = [[0]*(W+2) for i in range(H+2)]
for i in range(H):
  s = input()
  for j in range(W):
    if s[j]=='.':
      sheet[i+1][j+1] = 1

ans = -1
for i in range(1, H+1):
  for j in range(1, W+1):
    m = -1
    if sheet[i][j]==0:
      continue
    stuck = deque([(j, i, 0)])
    log = [[10**5]*(W+2) for i in range(H+2)]
    log[i][j] = 0
    while stuck:
      x, y, c = stuck.popleft()
      if c>m:
        m = c
      for dx, dy in [(0,1), (0,-1), (1,0), (-1,0)]:
        if sheet[y+dy][x+dx]==1 and log[y+dy][x+dx]>c+1:
          log[y+dy][x+dx] = c+1
          stuck += [(x+dx, y+dy, c+1)]
    if ans<m:
      ans = m
print(ans)

Measured memory_bytes: 43308
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include<math.h>
using namespace std;
vector<long long> code(26, 0);

vector<long long> l(51, 0);

int main() {
	int N,K;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> l[i];
	}

	sort(l.begin(), l.end(), greater<int>());

	int total = 0;
	for (int i = 0; i < K; i++)
	{
		total += l.front();
		l.erase(l.begin());
	}
	cout << total << endl;
	return 0;
}


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

using namespace std;

const int N = 1e5 + 2;

int n, a[N], pref[N], suff[N];

int main(){
      cin >> n;

      for(int i = 1; i <= n; i ++){
            cin >> a[i];
      }

      for(int i = 1; i <= n; i ++){
            int cur = abs(a[i] - a[i - 1]);
            pref[i] += pref[i - 1] + cur;
      }

      for(int i = n; i >= 1; i --){
            int cur = abs(a[i] - a[i + 1]);
            suff[i] = suff[i + 1] + cur;
      }

      for(int i = 1; i <= n; i ++){
            int res = pref[i - 1] + suff[i + 1];
            res += abs(a[i - 1] - a[i + 1]);
            cout << res << endl;
      }
}


Measured memory_bytes: 2432
#include <stdio.h>
int main() {
	int N, K, X, Y,A;
	scanf("%d %d %d %d", &N, &K, &X, &Y);
	if (N - K <= 0) {
		A = N*X;
	}
	else {
		A = K*X + (N - K)*Y;
	}
	printf("%d\n", A);
return		0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 1010
#define MO 1000000007
#define LL long long
int cnt,s1,s2,f1,f2,n,m;
LL k;
char s[MAXN][MAXN];
LL PowMod(LL a,LL b)
{
	b%=(MO-1);
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
struct maz
{
	LL a[2][2];
	maz(){memset(a,0,sizeof a);};
	maz operator*(maz &m)
	{
		maz ret;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					ret.a[i][j]=(ret.a[i][j]+a[i][k]*m.a[k][j]%MO)%MO;
		return ret;
	}
};
int main()
{
	scanf("%d%d%lld",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
			if(s[i][j]=='#')
			{
				cnt++;
				s1+=(s[i-1][j]=='#');
				s2+=(s[i][j-1]=='#');
			}
		if(s[i][1]=='#'&&s[i][m]=='#') f2++;
		if(i==n)
		{
			for(int j=1;j<=m;j++)
				if(s[1][j]=='#'&&s[n][j]=='#') f1++;
		}
	}
	if((f1&&f2)||k==0)
	{
		printf("1\n");
		return 0;
	}
	else if(f1==0&&f2==0)
	{
		printf("%lld\n",PowMod(cnt,k-1));
		return 0;
	}
	if(f1==0)
	{
		swap(f1,f2);
		swap(s1,s2);
	}
	maz A,ans;
	A.a[0][0]=cnt,A.a[1][0]=s1,A.a[1][1]=f1;
	ans.a[0][0]=ans.a[1][1]=1;
	k--;
	while(k)
	{
		if(k&1) ans=ans*A;
		A=A*A;
		k>>=1;
	}
	printf("%lld\n",(ans.a[0][0]-ans.a[1][0]+MO)%MO);
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

        if(a==b &&b!=c || b==c && a!=c || a==c && b!=c) printf("Yes\n");
        else if(a==b && b==c) printf("No\n");
        else if(a!=b && b!=c && c!=a) printf("No\n");

    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);	
    
    int x, y, t;
    cin >> x >> y >> t;
    t *= ceil((double) x/y);
    cout << t;
    
    return 0;
} 
 


Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,k;
	cin>>n>>k;
	int t[101010]={},d[101010]={};
	map<int,int> mp;
	priority_queue<pair<int,int>> pq;
	priority_queue<pair<int,int>> pq2;
	FOR(i,0,n){
		cin>>t[i]>>d[i];
		pq.push(MP(d[i],t[i]));
	}
	cerr<<"test"<<endl;
	LL ans=0,cnt=0,mx=0;
	FOR(i,0,k){
		pair<int,int> pii=pq.top();
		pq.pop();
		ans+=pii.ST;
		if(mp[pii.ND]==0){
			mp[pii.ND]=1;
			cnt++;
		}else{
			pq2.push(MP(-pii.ST,pii.ND));
		}
	}
	mx=ans+cnt*cnt;
	cerr<<mx<<" "<<cnt<<endl;
	FOR(i,k,n){
		if(pq.empty())break;
		pair<int,int> pii=pq.top();
		pq.pop();
		if(mp[pii.ND]!=0)continue;
		if(pq2.empty()){
			break;
		}
		pair<int,int> pii2=pq2.top();
		pq2.pop();
		mp[pii.ND]=1;
		cnt++;
		ans=ans+pii.ST+pii2.ST;
		mx=max(mx,ans+cnt*cnt);
	}
	cerr<<cnt<<endl;
	cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 5236
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
ll n, m, ans, A[101010];
string s;
int ketasum(int n) {
	int ans = 0, x = 10, i = 1;
	while (n > 0) {
		ans += ((n % x) / i);
		n -= (n % x);
		x *= 10;
		i *= 10;
	}
	return ans;
}
int main() {
	cin >> n;
	if (n%ketasum(n) == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math

a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())

lis=[0,0,0,0,0]
lis[a1]+=1
lis[b1]+=1
lis[a2]+=1
lis[b2]+=1
lis[a3]+=1
lis[b3]+=1

if(3 in lis):print("NO")
else:print("YES")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
int main(){
    using namespace std;
    char ch;
    int x;
    int counter[26]={0};

    while(cin >> ch){
        x = ch - 'A';
        if(x>=0&&x<=25){
            counter[x]++;
        }else if(x>=32&&x<=57){
            counter[x-32]++;
        }
    }

    for(int i=0;i<26;i++){
        printf("%c : %d\n", i+'a', counter[i]);
    }

    return 0;
}


Measured memory_bytes: 3148
#include<iostream>

int main() {

	int n;

	int a[1000];

	int b[1000];

	for (int i = 0; i < 1000; i++){
		a[i] = 0;
	b[i] = 0;
}

	int x, y;

	int j=0;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a[j] += (x + y);
		if (x < y)
			b[j] += (x + y);
		if (x == y){
			a[j] += x;
		b[j] += y;
	}
	}

	j++;

	goto f;

flag:

	for(int i=0;i<j;i++)
	std::cout << a[i] << ' ' << b[i] << std::endl;

	return 0;

}

Measured memory_bytes: 3004
def main():
    N = int(input())

    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))

    def lowerBound(a, v):
        # 以上
        return lb(a, 0, len(a), v)

    def upperBound(a, v):
        # より大きい
        # 値をプラス1
        return lb(a, 0, len(a), v + 1)

    def lb(a, l, r, v):
        low = l - 1
        high = r

        while high - low > 1:
            mid = low + high >> 1
            if a[mid] >= v:
                high = mid
            else:
                low = mid

        return high

    print(sum([lowerBound(A, Bi) * (N - upperBound(C, Bi)) for Bi in B]))

    return


main()


Measured memory_bytes: 23328
# include <cstdio>
# include <iostream>
# include <string>
using namespace std;

int main(void)
{
	string str; cin>>str;
	for ( int i = 0;i <(1<<3);i++ ) {
		int cur = str[0]-'0';
		string tmp;
		tmp+=str[0];
		for ( int j = 1;j < 4;j++ ) {
			if ((i>>(j-1))&1) {
				cur += str[j]-'0';
				tmp+='+';
				tmp+=str[j];
			}
			else {
				cur-=str[j]-'0';
				tmp+='-';
				tmp+=str[j];
			}
		}
		if (cur==7){
			cout<<tmp<<"=7"<<endl;
			return 0;
		}
	}


	return 0;
}

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

int main(int argc, char const *argv[]) {
    string S, Ss, Sc, Sr;
    Ss = "Sunny";
    Sc = "Cloudy";
    Sr = "Rainy";

    cin >> S;

    if (S == Ss) {
        cout << Sc << endl;
    } else if (S == Sc) {
        cout << Sr << endl;
    } else if (S == Sr) {
        cout << Ss << endl;
    }
    return 0;
}


Measured memory_bytes: 256