akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <list>

#define ll long long

using namespace std;
int a[300005];

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

	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'E') {
			a[0]++;
		}

	}
	
	for (int t = 1; t<n; t++) {
		if (s[t - 1] == 'W' && s[t] == 'W') {
			a[t] = a[t - 1] + 1;
		}
		else if (s[t - 1] == 'E'&& s[t] == 'E') {
			a[t] = a[t - 1] - 1;
		}
		else {
			a[t] = a[t - 1];
		}
	}
	
	int min = 1000000;
	for (int t = 0; t<n; t++) {
		if (a[t]<min)min = a[t];
	}

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


Measured memory_bytes: 1796
import math

n = int(input())
lst = [int(i) for i in input().split()]
lst.sort(reverse=True)
primes = set()
flag = True
for i in range(n):
  num = lst[i]
  count = 0
  while num % 2 == 0:
    num //= 2
    count += 1
    if 2 in primes and count == 1:
      flag = False
      break
    if 2 not in primes and count == 1:
      primes.add(2)
  f = 3
  while f <= math.sqrt(lst[i]) and flag:
    count = 0
    while num % f == 0:
      num //= f
      count += 1
      if f in primes and count == 1:
        flag = False
        break
      if f not in primes and count == 1:
        primes.add(f)
    f += 2
  if num == 1:
    continue
  if num in primes:
    flag = False
    break
  primes.add(num)
if not flag:
  a = lst[0]
  for i in range(1, n):
    b = lst[i]
    c = math.gcd(a, b)
    a = c
  if a != 1:
    print('not coprime')
  else:
    print('setwise coprime')
else:
  print('pairwise coprime')


Measured memory_bytes: 197616
#include <iostream>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a > b) std::swap(a,  b);
    if (a < c && c < b)  {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sc(a) scanf("%d", &a)
#define scll(a) scanf("%lld", &a)
#define test(a) cout << '(' << a << ')'
#define rep(i,j,k) for(int i = j; i <= k; i++)
#define per(i,j,k) for(int i = k; i >= j; i--)
typedef long long ll;
using namespace std;

const int MAXN = 3e5 + 10;

int n, m, dir[MAXN], sum[MAXN], minn;
char s[MAXN];

int main(void) {
    sc(m);
    scanf("%s", s);
    rep(i,1,m) dir[i] = (s[i-1] == 'E');
    rep(i,1,m) sum[i] = sum[i-1] + dir[i];
    minn = INT_MAX;
    rep(i,1,m) {
        minn = min(minn, (i-1) - sum[i-1] + (sum[m] - sum[i]));
    }
    cout << minn;
    return 0;
}


Measured memory_bytes: 2944
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,A,B,C = inpl()

MAX = 2*N
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

bunbo = pow(A+B,2*N,mod)
bunsi = 0

facAB = [1]*(N+1)
facA  = [1]*(N+1)
facB  = [1]*(N+1)
for i in range(1,N+1):
    facAB[i] = facAB[i-1] * (A+B) %mod
    facA[i] = facA[i-1] * (A) %mod
    facB[i] = facB[i-1] * (B) %mod

# aoki
for i in range(N):
    tmp = (N+i) * facAB[N-i] %mod * Comb(N-1+i,i) %mod
    tmp1 = tmp * facA[N] * facB[i] %mod
    tmp2 = tmp * facB[N] * facA[i] %mod
    bunsi += tmp1 + tmp2
    bunsi %= mod

bunsi *= 100
bunbo *= (A+B)

ans = bunsi * pow(bunbo,mod-2,mod) % mod
print(ans%mod)


Measured memory_bytes: 31848
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int k, a, b;
  cin >> k >> a >> b;

  int t1 = k + 1;
  int t2 = ((k - a + 1) / 2) * b - ((k - a + 1) / 2 - 1)  * a + (k - a + 1) % 2;

  cout << max(t1, t2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll X,Y,a,b,c;cin>>X>>Y>>a>>b>>c;
    priority_queue<ll> p,q,que;
    ll res=0;
    rep(i,a){
        ll x;cin>>x;
        p.push(x);
    }
    rep(i,b){
        ll x;cin>>x;
        q.push(x);
    }
    rep(i,c){
        ll x;cin>>x;
        que.push(x);
    }
    rep(i,X){
        int x=p.top();p.pop();
        que.push(x);
    }
    rep(i,Y){
        int x=q.top();q.pop();
        que.push(x);
    }
    rep(i,X+Y){
        res+=que.top();que.pop();
    }
    cout<<res<<endl;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define F           first
#define S           second
#define ld          long double
#define rep(i,a,b)  for(ll i=a;i<b;i++)
 
void solve()
{
      string s; cin>>s;
      ll n=s.size();
      ll dp[n+1][13];
      memset(dp,0,sizeof dp);
      dp[0][0]=1;
      // dp[i][j] - till index i cnt of no. with modulo = j
      for(ll i=1; i<=n; i++)
      {
            if(s[i-1]=='?')
            {
                  // can put any value here from zero to 9
                  for(ll c=0; c<10; c++)
                  {
                        for(ll m=0; m<13; m++)
                        {
                              ll cur=(10*m + c) % 13;
                              dp[i][cur] = (dp[i][cur] + dp[i-1][m]) % mod;
                        }
                  }
            }
            else
            {
                  ll c=s[i-1]-'0';
                  for(ll m=0; m<13; m++)
                  {
                        ll cur=(10*m + c) % 13;
                        dp[i][cur] = (dp[i][cur] + dp[i-1][m]) % mod;
                  }
            }
      }
      ll ans = dp[n][5];
      cout<<ans<<endl;
}

int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}

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

int main() {
  static auto add = [](int a, int b) { return a + b; };
  static auto mul = [](int a, int b) { return a * b; };
  int n;
  while (cin >> n, n) {
    vector<string> a(n);
    for (auto& e : a) {
      cin >> e;
    }
    a.push_back("0");
    vector<pair<function<int(int, int)>, int>> v{make_pair(add, 0)};
    for (auto e : a) {
      while (e.size() - 1 < v.size() - 1) {
        (v.rbegin() + 1)->second = (v.rbegin() + 1)->first((v.rbegin() + 1)->second, v.rbegin()->second);
        v.pop_back();
      }
      char c = *e.rbegin();
      if (c == '+') {
        v.push_back(make_pair(add, 0));
      } else if (c == '*') {
        v.push_back(make_pair(mul, 1));
      } else {
        v.rbegin()->second = v.rbegin()->first(v.rbegin()->second, c - '0');
      }
    }
    cout << v.back().second << endl;
  }
  return 0;
}



Measured memory_bytes: 3176
package main

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

type splitter int

const (
	bySpace splitter = iota
	byLine
)

func newScanner(sp splitter) *sc {
	scanner := bufio.NewScanner(os.Stdin)
	if sp == bySpace {
		scanner.Split(bufio.ScanWords)
	}
	return &sc{
		s: scanner,
	}
}

type sc struct {
	s *bufio.Scanner
}

func (s *sc) nextInt() int {
	if s.s.Scan() {
		val := s.s.Text()
		v, err := strconv.Atoi(val)
		if err != nil {
			panic(err)
		}
		return v
	}
	panic("no more stdin")
}

type node struct {
	id int
	isVisited bool
	root int
	connected []*node
}

func main() {
	sc := newScanner(bySpace)
	n := sc.nextInt()
	m := sc.nextInt()
	nodes := make([]*node, n)
	for i := 0; i < n; i++ {
		nodes[i] = &node{
			id: i,
			root: i,
		}
	}
	for i := 0; i < m; i++ {
		a := sc.nextInt() - 1
		b := sc.nextInt() - 1
		nodes[a].connected = append(nodes[a].connected, nodes[b])
		nodes[b].connected = append(nodes[b].connected, nodes[a])
	}
	for _, n := range nodes {
		solve(n, n.id)
	}
	sum := 0
	for _, n := range nodes {
		if n.id == n.root {
			sum ++
		}
	}
	fmt.Println(sum - 1)
}

func solve(n *node, i int) {
	if n.isVisited {
		return 
	}
	n.isVisited = true
	n.root = i
	for _, m := range n.connected {
		solve(m, i)
	}
}

Measured memory_bytes: 15908
#include<iostream>
#include<vector>
#include<queue>

using namespace std;


bool cycle_detection(vector<vector<int>> &G, vector<bool> &used, vector<bool> &used2, deque<int> &C, int cur){
	used[cur] = true;
	used2[cur] = true;
	
	C.push_back(cur);
	
	for(int nex : G[cur]){
		if(used[nex]){
			if(used2[nex]) {
				while(C.front() != nex){
					C.pop_front();
				}
				return true;
			} else {
				continue;
			}
		}
		
		if(cycle_detection(G, used, used2, C, nex)) return true;
	}
	
	used2[cur] = false;
	
	return false;
}

deque<int> cycle_detection(vector<vector<int>> &G){
	int N = G.size();
	vector<bool> used(N), used2(N);
	deque<int> C;
	
	for(int i = 0; i < N; i++){
		if(used[i] == true) continue;
		C.clear();
		if(cycle_detection(G, used, used2, C, i)) return C;
	}
	
	return {};
}

int main(){
	int V, E;
	vector<vector<int>> G;
	
	cin>>V>>E;
	
	G.resize(V);
	
	for(int i = 0; i < E; i++){
		int s, t;
		
		cin>>s>>t;
		
		G[s].push_back(t);
	}
	
	if(cycle_detection(G).size()) cout<<1<<endl;
	else cout<<0<<endl;
	
	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mx 10000000000008
#define mod 1000000007
ll n,t,arr[sz],brr[sz],crr[sz],x,m;
vector<ll>v;
int main()
{
    scanf("%lld %lld %lld",&n,&x,&m);
    t=x;
    arr[x]=1;
    brr[1]=x;
    for(int i=2;i<=n;i++)
    {
        ll val=(x*x)%m;
        brr[i]=brr[i-1]+val;
        if(arr[val])
        {
            ll num=i-arr[val];
            ll sum=brr[i]-brr[arr[val]];
            ll rem=n-i;
            ll jog=(rem/num)*sum;
            ll ans=brr[i]+jog;
            ll bak=rem%num;
            for(int i=1;i<=bak;i++)
            {
                val=(val*val)%m;
                ans+=val;
            }
            printf("%lld\n",ans);
            return 0;
        }
        x=val;
        arr[val]=i;
    }
    printf("%lld\n",brr[n]);
    return 0;
}


Measured memory_bytes: 4816
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int n;
string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>s;
	int a=0;
	int b=s.size()-1;
	int cnt=0;
	while(a<=b){
		if(s[a]=='W'&&s[b]=='R'){cnt++;swap(s[a],s[b]);}
		else if(s[a]=='W') b--;
		else if(s[b]=='R') a++;
		else{
			a++;b--;
		}
	}
	cout<<cnt;
	return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<bool> w_seen(f / 100 + 1, false);
  vector<bool> s_seen(f + 1, false);

  queue<int> que;
  que.push(0);
  while(!que.empty())
  {
    int now = que.front();
    que.pop();

    if (now > f / 100) continue;
    if (w_seen[now]) continue;

    w_seen[now] = true;
    que.push(now + a);
    que.push(now + b);
  }

  que.push(0);
  while(!que.empty())
  {
    int now = que.front();
    que.pop();

    if (now > f) continue;
    if (s_seen[now]) continue;

    s_seen[now] = true;
    que.push(now + c);
    que.push(now + d);
  }

  vector<int> w;
  vector<int> s;
  for(int i = 0; i < (int)w_seen.size(); ++i) if(w_seen[i]) w.emplace_back(i);
  for(int i = 0; i < (int)s_seen.size(); ++i) if(s_seen[i]) s.emplace_back(i);

  int ans_sw = 100;
  int ans_s = 1;
  for(const auto& wv : w)
  for(const auto& sv : s)
  {
    if (wv * e < sv) break;

    int sw = wv * 100 + sv;
    if (sw > f) break;

    if (ans_s * sw <= sv * ans_sw)
    {
      ans_s = sv;
      ans_sw = sw;
    }
  }

  cout << ans_sw << " " << ans_s;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        
        int max =0;
            for(int j=1; j<N; j++){
                int count = 0;
                String str1 = S.substring(0,j);
                String str2 = S.substring(j,N);
                ArrayList <String> list = new ArrayList<>();
                for(int i=0; i<j; i++){
                    if(str2.contains(str1.substring(i,i+1)) == true && list.contains(str1.substring(i,i+1)) == false){
                        list.add(str1.substring(i,i+1));
                        count++;
                    }
                    if(max<count){
                        max = count;
                    }
                }
        }
        
        System.out.println(max);
        
    }
}


Measured memory_bytes: 36648
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i:=0;i<n;i++{
		fmt.Scan(&a[i])
	}
	fmt.Println(sub(a))
}

func sub(a []int) int {
	mapEx := make(map[int]int)
	for _, value := range a {
		mapEx[value] = 1
	}
	return len(mapEx)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define MAX 2000000
 
int H,A[MAX+1];
 
void maxHeapify(int i){
  int l,r,largest;
  l = 2 * i;
  r = 2 * i + 1;
 
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;
 
  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
 
int main(){
  cin >> H;
 
  for(int i = 1;i <= H; i++)cin >> A[i];
 
  for(int i = H / 2; i >= 1; i--)maxHeapify(i);
 
  for(int i = 1; i <= H; i++){
    cout << " " << A[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 5024
#include<stdio.h>
int main()
{
	double h, highest, lowest;
	scanf("%lf", &h);
	highest = lowest = h;
	while (scanf("%lf", &h)>0) {
		if (h > highest)
			highest = h;
		if (h < lowest)
			lowest = h;
	}
	printf("%g\n", highest-lowest);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int l, max=0,sum=0;
    for(int i=0; i<n; i++){
        cin >> l;
        sum += l;
        if (l>max) max = l;
    }
    cout << (2*max<sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
/*Problem Statement
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.

Given an integer N, determine whether it is a Harshad number.

Constraints
1≤N≤108
N is an integer.
Input
Input is given from Standard Input in the following format:

N
Output
Print Yes if N is a Harshad number; print No otherwise.

Sample Input 1
Copy
12
Sample Output 1
Copy
Yes
f(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.

Sample Input 2
Copy
57
Sample Output 2
Copy
No
f(57)=5+7=12. Since 57 is not divisible by 12, 12 is not a Harshad number.

Sample Input 3
Copy
148
Sample Output 3
Copy
No*/
#include <iostream>
using namespace std;
int main()
{
	int N,a,z,c,sum=0;
	cin>>N;
	int n=N;
	while(n>0)
	{
		sum+=n%10;
		n=n/10;
	}
	if(N%sum==0)
	{
		cout<<"Yes";
    } 
    else
    {
    	cout<<"No";
	}
	return 0;
}

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

int cnt = 0;
auto g_list = std::vector<int>{};

template <typename T>
string join_vector(std::vector<T> data)
{
  ostringstream buf;
  auto delimiter = " ";
  for (auto i = data.begin(); i != data.end(); i++)
  {
    buf << *i;
    if (std::distance(i, data.end()) > 1)
    {
      buf << delimiter;
    }
  }

  return buf.str();
}

template <typename T>
void print_vector(std::vector<T> data)
{
  cout << join_vector(data) << endl;
}

std::vector<int> insert_sort(std::vector<int> a, int n, int g)
{
  for (auto i = g; i < n; i++)
  {
    auto v = a[i];
    auto j = i - g;
    while (j >= 0 && a[j] > v)
    {
      a[j + g] = a[j];
      j -= g;
      cnt += 1;
    }
    a[j + g] = v;
  }

  return a;
}

std::vector<int> shell_sort(std::vector<int> vec, int n)
{
  auto a = std::vector<int>(vec);

  for (auto g : g_list)
  {
    a = insert_sort(a, n, g);
  }

  return a;
}

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

  auto a = vector<int>{};

  for (auto i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    a.push_back(k);
  }

  for (auto h = 1;;)
  {
    if (h > n)
      break;
    g_list.push_back(h);
    h = 3 * h + 1;
  }
  reverse(g_list.begin(), g_list.end());

  auto sorted = shell_sort(a, n);

  cout << g_list.size() << endl;
  print_vector(g_list);
  cout << cnt << endl;

  for (auto i : sorted)
  {
    cout << i << endl;
  }

  return 0;
}



Measured memory_bytes: 18584
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{

	cin >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a.at(i);
	bool x = true;
	rep(i, n)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
				x = false;
		}
	}
	
	if (x == true)
		cout << "APPROVED" << endl;
	else
		cout << "DENIED" << endl;
	return 0;
}


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

int main() {

	//initialize
	int N;
    int A[100];
    int Alice = 0;
    int Bob = 0;

    // input
    cin >> N;
    for (int i = 0; i < N; ++i) {
    	cin >> A[i];
    }

    sort(A, A+N, greater<int>());

    for (int i = 0; i < N; ++i){
    	if (i % 2 == 0){
    		Alice += A[i];
    	}else{
    		Bob += A[i];
    	}
    }

    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  int n;
  cin >> n;
  
  bool canDo = false;
  rep(i, 9) {
    if (n % (i+1) == 0) {
      if(n/(i+1) < 10) {
        canDo = true;
      }
    }
  }

  cout << (canDo?"Yes":"No") << endl;

}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
d = defaultdict(int)

for i in range(N):
    S = input()
    d[S] += 1

m = 0
for k in d.keys():
    m = max(d[k],m)

li = []
for k in d.keys():
    if d[k] == m:
        li.append(k)

li.sort()
for l in li:
    print(l)

Measured memory_bytes: 32480
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
bool rui(ll x){
    while(x%2==0)x/=2;
    return x==1;
}
int main(){
  ll n; cin>>n;
  if(n<3||rui(n)){
      cout<<"No"<<endl;
      return 0;
  }
  vector<ll> v;
  for(int i=0;i<(n+1)/4;i++){
      for(int k=0;k<2;k++){
	  for(int j=0;j<4;j++){
	      ll r=i*4+j; if(r==0)r=-1e9;
	      v.push_back(r+k*n);
	  }
      }
  }
  cout<<"Yes"<<endl;
  if((n+1)%4>=2){
      ll t=n; if(n%2==0)t--;
      ll a[]={t-1,t,1,t+n-1,t+n};
      for(int j=0;j<4;j++){
	  cout<<a[j]<<" "<<a[j+1]<<endl;
      }
  }
  if((n+1)%4==3){
      cout<<n<<" "<<n-1<<endl;
      cout<<2*n<<" "<<2<<endl;
  }
  if((n+1)%4==1){
      ll x=1; for(;x*2<n;x*=2){}
      ll y=n xor x;
      cout<<n<<" "<<x<<endl;
      cout<<2*n<<" "<<y<<endl;
      ll b=y/4,r=y%4;
      swap(v[b*8+r],v[b*8+3]);
      swap(v[b*8+r+4],v[b*8+7]);
  }
  
  ll bef=v[1];
  for(int i=2;i<v.size();i++){
      if(v[i]<0)continue;
      cout<<bef<<" "<<v[i]<<endl;
      bef=v[i];
  }
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int a,b; cin>>a>>b;
    cout<<a*b<<endl;
}


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

int main()
{
    int h,n;
    std::cin >> h >> n;
    std::vector<long long> a(n),b(n);
    std::vector<long long> dp(h +100000,1000000000000000); //体力をhにする最小コスト
    for(int i = 0; i < n; i++)std::cin >> a[i] >> b[i];
    dp[0] = 0;
    for(int i = 0; i <= h; i++){
        for(int j = 0; j < n; j++){
                dp[i + a[j]] = std::min(dp[i + a[j]], dp[i] + b[j]);
        }
    }
    long long min = 1000000000000000;
    for(int i = h; i < (int)dp.size(); i++){
        min = std::min(min,dp[i]);
    }
    std::cout << min <<std::endl;
    
}

Measured memory_bytes: 1152
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, X, *M = map(int, read().split())
print(N+(X-sum(M))//min(M))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(2e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
int n,m;
vector<int> adj[N];
int col[N];
pll ed[N];
bool vis[N];
int cnt = 1;
int ans = 0;
void dfs(int u){
    vis[u] = true;
    cnt++;
    for(auto v:adj[u]){
        if(vis[v] == false){
            dfs(v);
        }
    }
}
void solve(){
    cin >> n >> m;
    for(int i =1;i<=m;i++){
        int u,v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
        ed[i] ={u,v};
    }
    for(int i =1;i<=n;i++){
        if(vis[i] == 0){
            cnt = 0;
            dfs(i);
            ans = max(ans,cnt);
        }
    }   
    cout << ans << endl;

}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 24136
#include <iostream>

using namespace std;

int main() {
  long long N;
  cin >> N;
  long long tmp = N/4;
  for (long long h = tmp > 1 ? tmp : 1; (4*h <= 3*N) && (h <= 3500) ; h++) {
    for (long long n = h; n <= 3500; n++) {
      long long hn = h*n;
      long long h_n = h+n;
      for (long long w = 3*tmp > n ? 3*tmp : n; w <= 3500; w++) {
        if (4*hn*w == N*(hn+w*h_n)) {
          cout << h << ' ' << n << ' ' << w << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) { //にぶたんgreater
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

vector<ll> Divisor(ll x) { // 約数列挙
	vector<ll> result;
	ll i=1LL;
	for( ; i*i<x; i++) {
		if(x%i) continue;
		result.push_back(i);
		result.push_back(x/i);
	}
	if(i*i==x&&x%i==0)
		result.push_back(i);
	
	sort(result.begin(),result.end());
	return result;
}

vector<llpair> PrimeFact(ll x) { // 素因数分解 {素因数,指数}
	vector<llpair> result;
	ll ex=0LL;
	if(x%2==0) {
		while(x%2==0) {
			x/=2;
			ex++;
		}
		result.push_back({2,ex});
	}

	for(ll i=3LL; i*i<=x; i+=2) {
		if(x%i) continue;

		ex=0LL;
		while(x%i==0) {
			x/=i;
			ex++;
		}
		result.push_back({i,ex});
	}

	if(x!=1) result.push_back({x,1});

	return result;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

int main() {
	int N; cin>>N;
	int A[N+1], ballsum[N+1], sum=0;
	bool ball[N+1];
	for(int i=1; i<=N; i++) {
		cin>>A[i];
		ballsum[i]=0;
		ball[i]=false;
	}

	for(int i=N; i>=1; i--) {
		if(ballsum[i]%2==A[i]) continue;
		sum++;
		ball[i]=true;

		llvec v=Divisor(i);
		for(int j=0; j<v.size(); j++) {
			ballsum[v[j]]++;
		}
	}

	cout<<sum<<endl;
	for(int i=1; i<=N; i++) {
		if(ball[i]) cout<<i<<" ";
	}
}


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

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

  if (s == "SUN") {
    cout << 7 << endl;
  } else if (s == "MON") {
    cout << 6 << endl;
  } else if (s == "TUE") {
    cout << 5 << endl;
  } else if (s == "WED") {
    cout << 4 << endl;
  } else if (s == "THU") {
    cout << 3 << endl;
  } else if (s == "FRI") {
    cout << 2 << endl;
  } else if (s == "SAT") {
    cout << 1 << endl;
  }
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<pair<int,int>> vp;
typedef vector<vp> vvp;
typedef vector<vvp> vvvp;
typedef vector<vvvp> vvvvp;

const int INF=1e9;
const pair<int,int> UNSOLVED={-INF-1,INF+1};
const pair<int,int> BAD={-INF,-INF};

int h,w,s;
int all_sum;

pair<int,int> merge(pair<int,int> c1,pair<int,int> c2){
  return {c1.first+c2.first,min(c1.second,c2.second)};
}

pair<int,int> dfs(int i,int j,int ii,int jj,vvvvp& dp, const vvi& sum){
  if(dp[i][j][ii][jj]!=UNSOLVED){
    return dp[i][j][ii][jj];
  }  
  int val=sum[ii+1][jj+1]-sum[i][jj+1]-sum[ii+1][j]+sum[i][j];

  if(all_sum-val>s){
    return dp[i][j][ii][jj]=BAD;
  }
  
  pair<int,int> res={1,s-(all_sum-val)};
  for(int id=i;id<ii;id++){
    auto chunk1=dfs(i,j,id,jj,dp,sum);
    auto chunk2=dfs(id+1,j,ii,jj,dp,sum);
    auto kouho=merge(chunk1,chunk2);
    res=max(res,kouho);
  }
  
  for(int jd=j;jd<jj;jd++){
    auto chunk1=dfs(i,j,ii,jd,dp,sum);
    auto chunk2=dfs(i,jd+1,ii,jj,dp,sum);
    auto kouho=merge(chunk1,chunk2);
    res=max(res,kouho);
  }

  return dp[i][j][ii][jj]=res;
}
int main(){
  while(cin>>h>>w>>s,h){
    vvi u(h,vi(w));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>u[i][j];
      }
    }
    vvi sum(h+1,vi(w+1,0));
    vvvvp dp(h,vvvp(w,vvp(h,vp(w,UNSOLVED))));
    
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+u[i-1][j-1];
      }
    }
    all_sum=sum[h][w];
    auto res=dfs(0,0,h-1,w-1,dp,sum);

    cout<<res.first<<" "<<res.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 12684
n = int(input())
ans = str()
if n == 0:
  ans = 0
i = 0
while n != 0:
  b = n%2
  if (b==1 or b== -1):
    ans = "1" + ans
  else:
    ans = "0" + ans
  n -= abs(b) *(-1) ** (i)
  n = n//2
  i += 1
print(ans)

Measured memory_bytes: 3060
n=int(input())
a=map(int,input().split())
pulasu_i=dict()
mainasu_i=dict()
for i,num in enumerate(a):
    x=i+1
    if num+x not in pulasu_i:
        pulasu_i[num+x]=1
    else:
        pulasu_i[num+x]+=1
    if num-x not in mainasu_i:
        mainasu_i[num-x]=1
    else:
        mainasu_i[num-x]+=1
#print(pulasu_i,mainasu_i)
ans=0
for num,cnt in pulasu_i.items():
    if -num not in mainasu_i:
        continue
    else:
        ans+=cnt*mainasu_i[-num]
print(ans) 

Measured memory_bytes: 59728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=min(b-1,n);
    double d=(ans*1.0)/b;
    ll dd=(ans/b);
    double ddd=(d*a)-(dd*a);
    ll vv=floor(ddd*1.0);
    cout<<vv<<endl;
    // printf("%.6lf",ddd);
    return 0;
}

Measured memory_bytes: 3640
rc = input()
rc_list = rc.split(" ")
r = int(rc_list[0])
c = int(rc_list[1])
all_sum = 0
list = [[0 for l in range(c)] for m in range(r)]

for i in range(r):

    row = input()
    row_list = row.split(" ")
    tmp = 0
    row_ans = ""
    for j in range(c):
        list[i][j] = int(row_list[j])
    for k in list[i]:
        tmp += k
        row_ans += str(k) + " "
    row_ans += str(tmp)
    print(row_ans)
    all_sum += tmp

column_list = ""
for m in range(c):
    column = 0
    for n in range(r):
        column += list[n][m]
    column_list += str(column) + " "
print(column_list + str(all_sum))


Measured memory_bytes: 5708
#include<stdio.h>
int main(void){
    int N,K,count=0;
    scanf("%d%d",&N,&K);
    int h[N];
    for(int i=0;i<N;i++){
        scanf("%d",&h[i]);
        if(h[i]>=K)
            count++;
    }
    printf("%d\n",count);
    return 0;
}


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

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

    double center = (double)s.size()/2;
    int ans = 0;
    int left = 0;
    int right = s.size() -1;

    while(true){
        int lnx = s.find_first_of("abcdefghijklmnopqrstuvwyz");
        int rnx = s.find_last_of("abcdefghijklmnopqrstuvwyz");
        if (lnx == string::npos) {
            cout << ans << endl;
            return 0;
        }
        if(lnx == rnx){
          ans += abs(lnx - ((int)s.size() - rnx - 1));
          cout << ans << endl;
          return 0;
        }
        if((lnx != rnx) && s[lnx] == s[rnx]){
            ans += abs(lnx - ((int)s.size() - rnx -1));
            s = s.substr(lnx+1,rnx-(lnx+1));
            continue;
        }
        cout << -1 << endl;
        return 0;
    }
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N);
    for (auto & p : P) cin >> p;
    int ans = 1;
    int tmp = INT32_MAX;
    for (int i = 1; i < N; ++i) {
        tmp = min(tmp, P[i-1]);
        if (tmp >= P[i]) {
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()

int main(){

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
		
	ios::sync_with_stdio(0); cin.tie(0);
	int n, r; 
	cin >> n >> r;
	if(n >= 10) cout << r;
	else {
		cout << r + 100 * (10 - n);
	}
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt,sum[3][1100000],sum2[1100000], ans , dp, a[1100000], nxt[1100000];
string str, ss;
bool f[200][200];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<int>>vec;
vector<edge>ed;
vector<LL>v[3];
map<Pll, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	cin >> str;
	rep(i, 3) {
		v[i].push_back(-1);
	}
	rep(i, 3) {
		rep(j, n) {
			LL cur = 0;
			if (i == 0 && str[j] == 'D') {
				cur++;
			}
			if (i == 1 && str[j] == 'M') {
				cur++;
			}
			if (i == 2 && str[j] == 'C') {
				cur++;
			}
			if (cur == 1)
				v[i].push_back(j);
			sum[i][j+1] += sum[i][j]+cur;
		}
	}
	rep(i, 3) {
		v[i].push_back(INF);
	}
	cin >> q;
	rep(i, q) {
		LL x;
		ans = 0;
		cin >> x;
		rep(i, n) {
			sum2[i] = 0;
			nxt[i] = 0;
		}
		rep(j, v[0].size()) {
			if (j == 0||j==v[0].size()-1)continue;
			
			LL it = upper_bound(v[2].begin(), v[2].end(), v[0][j] + x-1) - v[2].begin();
			sum2[v[2][it - 1]] ++;
			sum2[v[0][j]]--;
			nxt[v[0][j]] = v[2][it - 1];
		}
		LL cur = 0;
		Rrep(j,n) {
			sum2[j] += sum2[j + 1];
			if (str[j]=='M') {
				ans += cur;
			}
			if (str[j] == 'C') {
				cur += sum2[j];
			}
			if (str[j] == 'D') {
				cur -= sum[2][nxt[j] + 1] - sum[2][j];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 56312
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;)
using namespace std;
#define LL long long int
#define MAX 1000001
bool prime[1000001];
LL count[1000001];

int main()
{
    ios_base::sync_with_stdio(false); 
        cin.tie(NULL); 
  
   LL X;cin>> X;
   cout<< !X<<endl;
}

Measured memory_bytes: 3644
from collections import deque

n = int(input())

color = [-1]*(n+1)
rel = [{} for i in range(n+1)]

for i in range(n-1):
    u, v, w = map(int, input().split())
    rel[u][v] = rel[v][u] = w

def f(n):
    color[n] = 0
    stack = deque()
    stack.append(n)
    while stack:
        new = stack.pop()
        for ver in rel[new]:
            if color[ver] == -1:
                color[ver] = 1-color[new] if rel[new][ver]&1 else color[new]
                stack.append(ver)

for i in range(1, n+1):
    if color[i] != -1: continue
    f(n)

print(*color[1:], sep="\n")


Measured memory_bytes: 46948
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0 && b==0)break;
        int s=b-a;
        int x,y,z;
        z=s/1000;
        s-=((int)(s/1000)*1000);
        y=s/500;
        s-=((int)(s/500)*500);
        x=s/100;
        s-=((int)(s/100)*100);
        cout<<x<<" "<<y<<" "<<z<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b;
  cin >> w >> a >> b;

  if(a > b) swap(a,b);
  
  if(a+w >= b){
    cout << 0 << endl;
  } else{
    cout << b-(a+w) << endl;
  }

  return 0;
}
  


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

namespace _02_ABC081A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0;
            int z = 0;
            bool check = false;
            string str;

            string s = Console.ReadLine();
            //string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            //int b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            //int c = int.Parse(str[1]);

            for (int i = 0; i < s.Length; i++)
            {
                if (!check)
                {
                    if (s[i] == 'A')
                    {
                        a = i;
                        check = true;
                    }
                }
            }
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'Z')
                {
                    z = i;
                }
            }

            //str = s.Substring(a, z - a + 1);

            //Console.WriteLine(str.Length);
            Console.WriteLine(z-a+1);
            Console.Read();


        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int d[N];
    int i;
    for (i = 0; i < N; i++) cin >> d[i];

    sort(d, d + N, greater<int>());
    int ans = 1;
    int d_now = d[0];

    for (i = 1; i < N; i++) {
        if (d[i] < d_now) {
            ans++;
            d_now = d[i];
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N,K;
    cin >> N >> K;
    ll out = (N-1)/(K-1);
    if((N-1)%(K-1)!=0) out++;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>

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

#define pi 3.141592653589793)
#define mod 1000000007

int a, b, c, d;

void solve() {
    int ans = min(a, b) + min(c, d);
    cout << ans << endl;
}

int main() {
    cin >> a >> b >> c >> d;
    solve();
    return 0;
}

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




int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;

  int ans=0;
  

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

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Sheep and Wolves
 * 羊が S 匹、狼が W 匹います。
 * 狼の数が羊の数以上のとき、羊は狼に襲われてしまいます。
 * 羊が狼に襲われるなら unsafe、襲われないなら safe を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 羊の数
        int s = sc.nextInt();
        // 狼の数
        int w = sc.nextInt();

        System.out.println( s > w ? "safe" : "unsafe" );

        sc.close();
    }
}

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

def main():
  s = input()
  maxi = 0
  _maxi = 0
  for x in s:
    if x in ['A', 'T', 'G', 'C']:
      _maxi += 1
    else:
      if maxi < _maxi:
        maxi = _maxi
      _maxi = 0
  if maxi < _maxi:
    maxi = _maxi
  print(maxi)


if __name__=='__main__':
  main()

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

int main(){
    int n,a; cin>>n>>a;
    typedef pair<int,string>yebi;
    vector<yebi>tiya;
    tiya.push_back(yebi(0,"kogakubu10gokan"));
    rep(i,n){
        char h;
        int num; string hoge;
        cin>>num>>hoge;
        tiya.push_back(yebi(num,hoge));
    }
    int last=0;
    rep(i,tiya.size()){
        if(!i)continue;
        if(last<=a&&a<tiya[i].first){cout<<tiya[i-1].second<<endl; return 0;}
        last=tiya[i].first;
    }
    cout<<tiya[tiya.size()-1].second<<endl;
}

Measured memory_bytes: 3216
/*input
20 30
*/

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a-2*b) << endl;
}

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

int main()
{
  ios::sync_with_stdio(0);
  int m, n;
  string a[2000];
  cin >> m >> n;
  for (int i = 0; i < m; i++)
    cin >> a[i];

  int cnt[2020][2020] = {0};

  for (int i = 0; i < m; i++)
  {
    int last = 0;
    for (int j = 0; j < n; j++)
      if (a[i][j] == '.')
      {
        if (j && a[i][j - 1] == '.') cnt[i][j] += j - last;
        else last = j;
      }

    last = n - 1;
    for (int j = n - 1; j >= 0; j--)
      if (a[i][j] == '.')
      {
        if (j + 1 < n && a[i][j + 1] == '.') cnt[i][j] += last - j;
        else last = j;
      }
  }

  for (int j = 0; j < n; j++)
  {
    int last = 0;
    for (int i = 0; i < m; i++)
      if (a[i][j] == '.')
      {
        if (i && a[i - 1][j] == '.') cnt[i][j] += i - last;
        else last = i;
      }

    last = m - 1;
    for (int i = m - 1; i >= 0; i--)
      if (a[i][j] =='.')
      {
        if (i + 1 < m && a[i + 1][j] == '.') cnt[i][j] += last - i;
        else last = i;
      }
  }

  int ans = 0;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      ans = max(ans, cnt[i][j] + 1);

  cout << ans << endl;
}

Measured memory_bytes: 20480
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
	int N;
	cin >> N;
	map<string, int> m;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		m[s]++;
	}

	cout << m.size() << endl;

	return 0;
}

Measured memory_bytes: 19092
import sys
from collections import deque
 
input = sys.stdin.readline
 
N,D,A = map(int,input().split())
XH = []
for i in range(N):
	x,h = map(int, input().split())
	XH.append([x,h])
 
XH.sort(key=lambda xh: xh[0])
que = deque()
D = 2*D
 
H = XH[0][1]
if(0==H%A): a = H//A
else: a = H//A+1
que.append([XH[0][0]+D,a*A])
tot = a * A
ans = a
for i in range(1,N):
	while XH[i][0] > que[0][0] :
		tot -= que[0][1]
		que.popleft()
		if(len(que)==0): break
	if(tot < XH[i][1]):
		H = XH[i][1]-tot
		if(0==H%A): a = H//A
		else: a = H//A+1
		ans += a
		que.append([XH[i][0]+D,a*A])
		tot += a*A
print(ans)

Measured memory_bytes: 86620
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (a + b == c || a + c == b || b + c == a) {
		Yes;
	}
	else {
		No;
	}

	return 0;
}


Measured memory_bytes: 256
fn is_palindromic(n: &i32) -> bool {
    let mut digits = [0; 5]; 
    let mut tmp = *n; 
    for i in 0..5 {
        digits[i] = tmp % 10; 
        tmp = tmp / 10; 
    }   
    digits[0] == digits[4] && digits[1] == digits[3]
}
fn main() {
    let stdin = std::io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line).ok();
    let inputs: Vec<&str> = line.split_whitespace().collect();
    let A: i32 = inputs[0].parse().unwrap();
    let B: i32 = inputs[1].parse().unwrap();
    let numbers = A..B+1;
    let x = numbers.filter(is_palindromic).count();
    println!("{}", x); 
}

Measured memory_bytes: 4352