akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
s = list(input())
que = deque()
stack = []

for i in range(n):
    t = s[i]
    if t == '(':
        stack.append(t)
        que.append(t)
    else: # t == ')'
        if stack:
            if stack[-1] == '(':
                stack.pop()
                que.append(')')
            else:
                stack.append(')')
        else:
            que.appendleft('(')
            que.append(')')

print(''.join(que) + ')' * len(stack))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
ll digitPoor(ll n)
{
    assert(INT_MAX == 2147483647);
    assert(n >= 0);

    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;
    if (n < 10000000)   return 7;
    if (n < 100000000)  return 8;
    if (n < 1000000000) return 9;
    return 10;
}
struct p{
  ll x;
  bool b;
};
int main(){
    ll N;
    cin>>N;
    ll t=1000-N%1000;
    cout<<(t==1000?0:t);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (auto& h : H) {
        cin >> h;
    }
    sort(all(H));
    int ans = 1 << 30;
    rep(i, K - 1, N) {
        chmin(ans, H[i] - H[i - K + 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   int ans = 0;
   for (int i = 1; i <= n; i++) {
      int x = i;
      int cnt = 0;
      while (x) {
         x /= 10;
         cnt++;
      }
      if (cnt % 2)
         ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
N = int(input())
S,T = map(str,input().split())
ans = ""
for i in range(N):
    ans += S[i]
    ans += T[i]
print(ans)

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

struct Card {
  char suit;
  int value;
};

struct Card L[100000 / 2 + 2], R[100000 / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right ) {
  int i,j;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];  
  L[n1].value = R[n2].value = 10000000;
  i = j = 0;
  for ( int k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = ( left + right ) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  struct Card x;
  int i, j;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j].value <= x.value ) {
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, n, p, r );
    quickSort(A, n, p, q - 1 );
    quickSort(A, n, q + 1, r );    
  }
}

int main() {
  int n, v;
  struct Card A[100000], B[100000];
  char ch;

  
  //入力
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> ch >> v;
    A[i].suit = B[i].suit = ch;
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1 );

  //安定しているかどうか調べる
  int stable = 1;
  for ( int i = 0; i < n; i++ ) {
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  //出力
  for ( int i = 0; i < n; i++ ) {
    cout << B[i].suit << " " << B[i].value << endl;
  }

}

Measured memory_bytes: 3508
#include<stdio.h>

int CountDivisers(int a, int b, int c)
{
	int i;
	int count = 0;
	
	for(i = a; i<=b ; i++){
		if(c % i == 0){
		count++;
		}		
	}
	
	return count;
}

int main(void)
{
	int a;
	int b;
	int c;
	int count;
	
	count = 0;

	scanf("%d %d %d",&a,&b,&c);
	printf("%d\n",CountDivisers(a,b,c));
	return 0;
}

Measured memory_bytes: 596
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

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

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

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

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$A = $sc->nextInt();
$B = $sc->nextInt();
$c = 0;
for ($i = $A; $i <= $B; $i++) {
    $num = $i;
    $num_rev = strrev($num);
    if ($num == $num_rev){
       $c++;
    }
}
echo $c;

Measured memory_bytes: 4728
n = gets.to_i

ary = []

n.times do
    ary << gets.split(' ').map(&:to_i)
end

ary = ary.sort_by{|x| x[1]}

f = 1
time = 0
n.times do |i|
    time += ary[i][0]
    if time > ary[i][1] then
        f = 0
        break
    end
end

if f == 0 then
    print 'No'
else
    print 'Yes'
end

Measured memory_bytes: 22648
import itertools

N, M = map(int, input().split())
switches = []
for i in range(M):
    swi = input().split()
    swi = [int(x)-1 for x in swi][1:]
    switches.append(swi)
    
needs = [int(x) for x in input().split()]

ans = 0
def checkLightsUp(swi_ptn):
    for i in range(M):
        need = needs[i]
        cnt = 0
        for s in switches[i]:
            if swi_ptn[s] == 1:
                cnt  += 1
        if cnt % 2 != need:
            return False
    return True

for swi_ptn in itertools.product([0, 1], repeat=N):
    if checkLightsUp(list(swi_ptn)):
        ans += 1
print(ans)

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

int main(){
    vector<string> s(3);
    for(int i=0; i<3; i++){
        cin >> s[i];
    }

    int ans = 6000;
    sort(s.begin(), s.end());
    //int count = 0;
    do{
        vector<vector<vector<bool>>> match(3, vector<vector<bool>>(3, vector<bool>(4001, true)));
        //cout << count << " ";
        //count += 1;
        for(int i=0; i<3; i++){
            for(int j=i+1; j<3; j++){// (0,1), (0,2), (1,2)
                int li = s[i].length();
                int lj = s[j].length();

                for(int dx=0; dx<li; dx++){
                    bool flag = true;
                    for(int y=0; y<lj; y++){
                        int x = y + dx;
                        if(x < li
                        && s[i][x] != '?' 
                        && s[j][y] != '?' 
                        && s[i][x] != s[j][y]){
                            flag = false;
                            break;
                        }
                    }
                    match[i][j][dx] = flag;
                }
            }
        }
        for(int dx1=0; dx1<=2000; dx1++){
            for(int dx2=0; dx2<=2000; dx2++){
                if(match[0][1][dx1] == true
                && match[1][2][dx2] == true
                && match[0][2][dx1 + dx2] == true){
                    int l0 = s[0].length();
                    int l1 = s[1].length();
                    int l2 = s[2].length();
                    ans = min(ans, max({l0, dx1 + l1, dx1 + dx2 + l2}));
                }
            }
        }
    }while(next_permutation(s.begin(),s.end()));
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b;
  if (a<=5) {
    c=0;
  }
  else if (a>5 && a<=12) {
    c=b/2;
  }
  else {
    c=b;
  }
  cout << c << endl;
}


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

int main(int argc, char const *argv[])
{
    int n,m;cin>>n>>m;
    int l,r;
    int min_num=1;
    int max_num=n;
    for(int i=0;i<m;++i){
        cin>>l>>r;
        min_num = max(min_num, l);
        max_num = min(max_num, r);
    }
    if(max_num<min_num)cout << "0" << endl;
    else cout << max_num - min_num + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int pos(){
	cout << "POSSIBLE" << endl;
	return 0;
}
int imp(){
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

int main(){
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for( auto &i : a ){
		cin >> i;
		if( i == k ) return pos();
	}
	if( k >= *( max_element(a.begin(), a.end()) ) ) return imp();
	int g = a[0];
	for( int i = 1; i < n; ++i ){
		g = __gcd(g, a[i]);
	}
	if( k % g == 0 ) return pos();
	else imp();
}

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

int main() {
  string s,t;
  cin>>s>>t;
  int a=s.size();
  int b=t.size();
  int ans=-1;
  for(int i=0;i<=a-b;i++){
    bool cur=true;
    for(int j=0;j<b;j++){
      if(s.at(i+j)!='?'&&s.at(i+j)!=t.at(j)){
        cur=false;
      }
    }
    if(cur){
      ans=i;
    }
  }
  if(ans==-1){
    cout<<"UNRESTORABLE"<<endl;
  }
  else{
    for(int i=0;i<ans;i++){
      if(s.at(i)=='?'){
        cout<<'a';
      }
      else{
        cout<<s.at(i);
      }
    }
    for(int i=ans;i<ans+b;i++){
      cout<<t.at(i-ans);
    }
    for(int i=ans+b;i<a;i++){
      if(s.at(i)=='?'){
        cout<<'a';
      }
      else{
        cout<<s.at(i);
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int, input().split()))

A=[]
B=[]
while len(a)>0:
    A.append(max(a))
    a.remove(max(a))
    if len(a)>0:
        B.append(max(a))
        a.remove(max(a))
print(sum(A)-sum(B))


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

struct am{
	char s[11];
	int num;
	int n;
};

int compare_int(const void *a,const void *b){
	struct am A=*(struct am*)a,B=*(struct am*)b;
	return strcmp(A.s,B.s);
}


int main(){
	int n,i;
	struct am sp[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d",sp[i].s,&sp[i].num);
		sp[i].n=i+1;
	}
	qsort(sp,n,sizeof(struct am),compare_int);
	int tmp[100][2],c=0;
	tmp[0][0]=sp[0].num;
	tmp[0][1]=sp[0].n;
	c++;
	for(i=1;i<n;i++){
		if(strcmp(sp[i].s,sp[i-1].s)!=0){
			for(int j=0;j<c;j++){
				for(int k=0;k<c;k++){
					if(tmp[j][0]>tmp[k][0]){
						int l=tmp[j][0];
						int l2=tmp[j][1];
						tmp[j][0]=tmp[k][0];
						tmp[j][1]=tmp[k][1];
						tmp[k][0]=l;
						tmp[k][1]=l2;
					}
				}
			}
			for(int j=0;j<c;j++)printf("%d\n",tmp[j][1]);
			c=1;
			tmp[0][0]=sp[i].num;
			tmp[0][1]=sp[i].n;
		}
		else {
			tmp[c][1]=sp[i].n;
			tmp[c++][0]=sp[i].num;
		}
	}for(int j=0;j<c;j++){
				for(int k=0;k<c;k++){
					if(tmp[j][0]>tmp[k][0]){
						int l=tmp[j][0];
						int l2=tmp[j][1];
						tmp[j][0]=tmp[k][0];
						tmp[j][1]=tmp[k][1];
						tmp[k][0]=l;
						tmp[k][1]=l2;
					}
				}
			}
	for(int j=0;j<c;j++)printf("%d\n",tmp[j][1]);
	return 0;
}

Measured memory_bytes: 128
from operator import mul

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

A = []
B = []

for i in range(n):
    A.append(list(map(int, input().split(' '))))

for j in range(m):
    B.append(int(input()))

for a in A:
    print(sum(map(mul, a, B)))

Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=0;
	for(ll i=l;i<=r;i++){
		if(i%d==0){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3564
from collections import deque

def bfs(graph, start):
    visited = {start: None}
    unvisited = deque()
    unvisited.append(start)
    while unvisited:
        now = unvisited.popleft()
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return  visited                                

n, m = map(int, input().split())
g = [set() for _ in range(n)]
group = []

for i in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    for j in range(len(group)):
        if s in group[j] and t in group[j]:
            print('yes')
            break
        elif s in group[j]:
            print('no')
            break
    
    else:
        group_tmp = set(bfs(g, s).keys())
        if t in group_tmp:
            print('yes')
        else:
            print('no')
        group.append(group_tmp)



Measured memory_bytes: 47116
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if(a[i] == a[j]) continue;
                for (int k = j+1; k < n; k++) {
                    if(a[i] == a[k] || a[j] == a[k]) continue;
                    if(a[i] + a[j] > a[k]) res++;
                }
            }
        }
        System.out.println(res);
    }



}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>s;
	if(s[0]!=s[1] || s[1]!=s[2]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define db double
#define ld long double
#define pii pair<int,int> 
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define fore(i,a) for(int i=0;i<a.size();++i) 
const int N=105,P=1e9+7;
int T,A,B,C,a,b,c,ans,g[N],Ch[N][N];
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*r*a%P;return r;}
inline int C2(int A,int B,int a,int b){return (1ll*pw(a,B)*b+1ll*pw(b,A)*a+P-a*b)%P;}//calc the 2d patterns with A*B rectangles in size a*b
inline void sol()
{
	scanf("%d%d%d%d%d%d",&a,&b,&c,&A,&B,&C);
	if(A%a||B%b||C%c){puts("0");return;}
	A/=a;B/=b;C/=c;ans=0;
	for(int p=1;p<A;p++)for(int q=B;q;q--)
	{
		int s=g[q]=1ll*pw(pw(c,B-q)-1,A-p)*Ch[B][q]%P;
		for(int i=q+1;i<=B;i++)//binomial invertion
		{
			int t=1ll*g[i]*Ch[i][q]%P;
			if((i+q)&1)t=P-t;s=(s+t)%P;
		}
		if(q==B)continue;
		int aq=pw(a,q),bp=pw(b,p),t=(1ll*pw(aq+bp-1,C)+P-pw(aq,C)+P-pw(bp,C)+1)%P;
		ans=(ans+1ll*s*Ch[A][p]%P*t)%P;
	}
	ans=(1ll*ans*a*b*c+1ll*pw(C2(A,B,a,b),C)*c+1ll*pw(C2(A,C,a,c),B)*b+1ll*pw(C2(B,C,b,c),A)*a)%P;
	int t=(1ll*a*b*pw(c,A*B)+1ll*a*c*pw(b,A*C)+1ll*b*c*pw(a,B*C))%P;ans=(ans+P-t+a*b*c)%P;printf("%d\n",ans);
}
int main()
{
	for(int i=Ch[0][0]=1;i<=100;i++)for(int j=Ch[i][0]=1;j<=i;j++)Ch[i][j]=(Ch[i-1][j-1]+Ch[i-1][j])%P;
	sol();return 0;	//	scanf("%d",&T);while(T--)sol();return 0;
}


Measured memory_bytes: 256
from collections import Counter
N=int(input())
B=[tuple(map(int, input().split())) for _ in range(N)]
R=[(x[0]-y[0],x[1]-y[1]) for x in B for y in B if x!=y]
C=Counter(R).most_common(1)
print(N-C[0][1] if C else N)

Measured memory_bytes: 39280
from collections import defaultdict
import math
N = int(input())
ps = defaultdict(int)
for i in range(2, int(math.sqrt(N))+1):
    while N % i == 0:  
        ps[i] += 1
        N //= i
    i += 1
if N > 1:
    ps[N] += 1
ans = 0
for p in ps:
    k = 1
    while ps[p] >= k:
        ans += 1
        ps[p] -= k
        k += 1
print(ans)

Measured memory_bytes: 68188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                if ((y - i * 1000 - j * 5000) % 10000 == 0)
                    if ((y - i * 1000 - j * 5000) / 10000 == n - i - j) {
                        System.out.println((y - i * 1000 - j * 5000) / 10000 + " " + j + " " + i);
                        System.exit(0);
                    }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }
}

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

int n;
vector<P>E[200000];
ll cost[200000],ans[200000];
ll s[200000];
int sz[200000];

int id=-1;
void dfs(int v,int p,int idx){
	sz[v]=1;
	for(auto u:E[v]){
		if(u.second==p)continue;
		dfs(u.second,v,u.first);
		sz[v]+=sz[u.second];
	}
	if(p!=-1){
		if(n-2*sz[v]==0){id=idx;cost[v]=ans[idx]=0;}
		else cost[v]=ans[idx]=(s[v]-s[p])/(n-2*sz[v]);
	}
}
ll calc(int v,int p){
	ll res=0;
	for(auto u:E[v]){
		if(u.second==p)continue;
		res+=cost[u.second]*(ll)sz[u.second]+calc(u.second,v);
	}
	return res;
}
int main(){
	scanf("%d",&n);
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(P(i,b));
		E[b].push_back(P(i,a));
	}
	rep(i,n){
		scanf("%lld",&s[i]);
	}
	dfs(0,-1,-1);
	if(id!=-1)ans[id]=(s[0]-calc(0,-1))/(n/2);
	rep(i,n-1){
		printf("%lld\n",ans[i]);
	}
	
}

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

ll modPow(ll n, ll p, ll mod) {
    n %= mod;
    // return (n^p) % mod
    if (p == 0)
        return 1;
    ll res = modPow(n * n % mod, p / 2, mod);
    if (p % 2 == 1)
        res = res * n % mod;
    return res;
}

int main() {
    int N, P;
    string S;
    cin >> N >> P >> S;

    ll ans = 0;
    if (P == 2) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % 2 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    } else if (P == 5) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % 5 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> res(N);
    map<int, ll> cnt;
    cnt[0] = 1;
    for (int i = N - 1; i >= 0; i--) {
        ll n = S[i] - '0';
        if (i == N - 1) {
            res[i] = n % P;
        } else {
            res[i] = (modPow(10, N - 1 - i, P) * n + res[i + 1]) % P;
        }

        ans += cnt[res[i]];
        cnt[res[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2564
n = int(input())
c = input()

n_w  = c.count("R")

goal = []
for i in range(n_w):
    goal.append("R")
for j in range(n-n_w):
    goal.append("W")

W2R = 0
R2W = 0

for i in range(n):
    if c[i]=="W" and goal[i]=="R":
        W2R += 1
    elif c[i]=="R" and goal[i]=="W":
        R2W += 1
        
ans = max(W2R, R2W)
print(ans)

Measured memory_bytes: 10936
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        long sum = 0;
        int x = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            sum += Math.abs(x - temp);
            a[i] = temp;
            x = temp;
            if (i == n - 1) {
                sum += Math.abs(temp);
            }
        }
        long[] ans = new long[n];
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans[i] = sum - Math.abs(a[i]) - Math.abs(a[i + 1] - a[i]) + Math.abs(a[i + 1]);
            } else if (i == n - 1) {
                ans[i] = sum - Math.abs(a[i] - a[i - 1]) - Math.abs(a[i]) + Math.abs(a[i - 1]);
            } else {
                ans[i] = sum - Math.abs(a[i] - a[i - 1]) - Math.abs(a[i + 1] - a[i]) + Math.abs(a[i + 1] - a[i - 1]);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (long l : ans) {
            sb.append(l);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 47856
import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
def fact(n):
    mod=10**9+7
    if n==0:
        return 1
    else:
        return (n*fact(n-1))%mod
mod=10**9+7
if n==m:
    print(2*fact(n)*fact(m)%mod)
elif n==m+1 or m==n+1:
        print(fact(n)*fact(m)%mod)
else:
    print(0)

Measured memory_bytes: 88948
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

vector<int>a;
vector<vector<int>>dp;
int n;
int f(int l,int r){
    if(l==r)return (n%2==0?-a[l]:a[l]);
    int &ret=dp[l][r];
    if(ret!=INF)return ret;
    if((n-r+l)%2==1) ret = max(f(l+1,r)+a[l],f(l,r-1)+a[r]);
    else ret = min(f(l+1,r)-a[l],f(l,r-1)-a[r]);
    return ret;
}

signed main(){
    cin>>n;
    a.resize(n);
    dp.resize(n,vector<int>(n,INF));
    REP(i,n)cin>>a[i];
    cout<<f(0,n-1)<<endl;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int res = 1;
  int plus = 0;
  int mul = 0;
  for (int i=0; i < N; i++) {
    plus = res + K;
    mul = res * 2;
    
    if (plus <= mul) {
      res = plus;
    } else {
      res = mul;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double l,mx=0;
double fun(double a)
{
	double low = 0,high = 1001;
	double b,c;
	double temp=0;
	while(low<high)
	{
		b = low+(high-low)/2;
		c = l-a-b;
		if((a*b*c)>temp) temp=(a*b*c),low=b;
		else high=b;
	}

	return temp;

}

int solve()
{
	ll n;cin>>n;
	vi a(n);
	map<ll,ll> fq;
	rep(i,0,n) cin>>a[i],fq[a[i]]++;
	ll ans=0;
	all(it,fq)
	{
		ll v = it->S;
		ans+=(v*v-v)/2;
	}

	rep(i,0,n)
	{
		ll v = fq[a[i]];
		ll temp_ans = ans;
		temp_ans-=(v*v-v)/2;
		v--;
		temp_ans+=(v*v-v)/2;
		cout<<temp_ans<<"\n";
	}
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 11136
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        sc.close();
        long  count = N -1;
        double max = Math.ceil(Math.sqrt(N));

        for (long i=1 ; i < max +1 ; i++) {
        	if ( N % i == 0) {
        		if (N / i + i - 2 < count ) {
        			count = N / i + i - 2;
        		}
        	}
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 21972
#  = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp

r = true
S.chars.each.with_index do |c, i|
  i += 1
  
  if (i % 2 == 1) # odd
    if !['R', 'U', 'D'].include?(c)
      r = false
      break
    end
  else # odd
    if !['L', 'U', 'D'].include?(c)
      r = false
      break
    end
  end
end

if r
  print "Yes\n"
else
  print "No\n"
end

Measured memory_bytes: 1788
N = int(input())

NL = list(str(N))
a = int(NL[-1])
#print(NL)
#print(NL[-1])

if a == 3:
    print("bon")

elif a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")

else:
    print("hon")

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int k,s; cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++)
    {
        for (int y = 0; y <= min(s-x,k); y++)
        {
            int z = s-x-y;
            if (0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int cards[4][13] = {};
	int n, mark, number;
	char c;

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			cards[i][j] = 0;
		}
	}

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> c;
		if (c == 'S') {
			mark = 0;
		}
		else if (c == 'H') {
			mark = 1;
		}
		else if (c == 'C') {
			mark = 2;
		}
		else if (c == 'D') {
			mark = 3;
		}

		cin >> number;

		cards[mark][number - 1] = number;
	}

	for (int i = 0; i<4; i++)
		for (int j = 0; j < 13; j++) {
			if (cards[i][j] == 0) {
				if (i == 0) {
					cout << "S" << " " << j + 1 << endl;
				}
				else if (i == 1) {
					cout << "H" << " " << j+1 << endl;
				}
				else if (i == 2) {
					cout << "C" << " " << j+1 << endl;
				}
				else if (i == 3) {
					cout << "D" << " " << j+1 << endl;
				}
			}
		}
	
	return 0;
}




Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#define MAX_H 400
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s[MAX_H];
bool used[MAX_H][MAX_H]={};
ll h,w;
void dfs(ll x,ll y,ll& cnt,ll& bc){
  if(used[x][y]){
    return;
  }
  used[x][y]=true;
  cnt++;
  if(s[x][y]=='#'){
    bc++;
  }
  ll vx[]={1,0,-1,0},vy[]={0,1,0,-1};
  ll nx,ny;
  for(int i=0;i<4;i++){
    nx = x+vx[i];
    ny = y+vy[i];
    if(nx>=0&&ny>=0&&nx<h&&ny<w&&s[x][y]!=s[nx][ny]){
      dfs(nx,ny,cnt,bc);
    }
  }
}
signed main(){
  ll ans=0,tmp,bc;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      if(!used[i][j]){
        tmp=0;
        bc=0;
        dfs(i,j,tmp,bc);
        ans += bc*(tmp-bc);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 28160
#include<stdio.h>
int main()
{
    int n,i,cnt=0,p;
    scanf("%d",&n);
    int a[n];
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(i!=a[i])
            cnt++;
    }
    if(cnt==2 || cnt==0)
        printf("YES");
    else
        printf("NO");

    return 0;
}

Measured memory_bytes: 1716
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10)cout << a * b << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}


int main(){

    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll num=0;
    ll ans = 0;
    map<ll,ll> q;

    if(p==2){
        rep(i,n){
            if((s[i]-'0')%2==0)ans+=(i+1);
        }
    }else if(p==5){
        rep(i,n){
            if(s[i]=='5'||s[i]=='0')ans+=(i+1);
        }
    }else {


        q[0]++;
        ll fac = 1;
        for (int i = n - 1; i >= 0; i--) {
//        num=num*10;
//        num+=s[i]-'0';
            num += (s[i] - '0') * fac;
            ll k = num % p;
            //if(k==0)ans++;
            ans += q[k];
            q[k]++;
            fac = fac * 10 % p;
        }
    }



    cout<<ans<<endl;






    
return 0;
}


Measured memory_bytes: 1028
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let age: i32 = read_as_vec()[0];

    if age == 3 || age == 5 || age == 7{
        println!("YES");
        return;
    }
    println!("NO");
    
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define reg register
using namespace std;
#define N 200005
#define M N

int n, m;
int tot = 0, fir[N], nxt[N << 1], to[N << 1];
int x[N << 1], y[N << 1], z[N << 1];

inline void addEdge(reg int u, reg int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int vis[N], d[N];

void dfs(reg int u) {
    vis[u] = 1;
    for (reg int i = fir[u], v; i; i = nxt[i]) {
        v = to[i]; if (vis[v]) continue;
        dfs(v);
        if (d[v]) z[(i + 1) / 2] ^= 1, d[v] = 0, d[u] ^= 1;
    }
}

int main() {
    scanf ("%d%d", &n, &m);
    for (register int i = 1; i <= m; ++i)
        scanf("%d%d", x + i, y + i),
        addEdge(x[i], y[i]), addEdge(y[i], x[i]), d[x[i]] ^= 1, z[i] = 1;
    dfs(1);
    if (d[1]) {
        puts("-1");
        return 0;
    }
    for (register int i = 1; i <= m; ++i)
        if (z[i]) printf("%d %d\n", x[i], y[i]);
        else printf("%d %d\n", y[i], x[i]);
    return 0;
}

/*
 _____________________________________ 
< B.cpp is created by zrz who is weak >
 ------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
*/


Measured memory_bytes: 14208
N = gets.to_i
points = []
N.times do 
    points << gets.split.map(&:to_i)
end

sum = 0.0
for i in 0..N-2
    for j in i+1..N-1
        sum += Math.sqrt((points[i][0] - points[j][0]) ** 2 + (points[i][1] - points[j][1]) ** 2)
    end
end

p sum * 2 * (1..N-1).to_a.inject(:*) / (1..N).to_a.inject(:*)

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

using namespace std;

int main() {
 	ios_base::sync_with_stdio(0); cin.tie(0);
  	string s,t;
  	cin>>s;
  	t=s;
  	for (int i=0;i<s.length();i++)
    	if (s[i]=='?') t[i]='D';

  	cout<<t<<endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <cstdio>
using namespace std;
#define MAX 200000

int main(){
    int i=1,n;
    scanf("%d",&n);
    while(n>=(i*=2));
    printf("%d\n",i/2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string A, B; cin >> A >> B;
  if(A.size() > B.size()) {
    cout << "GREATER" << endl;
    return 0;
  }
  else if(A.size() < B.size()) {
    cout << "LESS" << endl;
    return 0;
  }
  else {
    rep(i,A.size()) {
      if(A.at(i) > B.at(i)) {
        cout << "GREATER" << endl;
        return 0;
      }
      else if(A.at(i) < B.at(i)) {
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>

using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  if(x/w>=1/2.0-0.000000000001&&x/w<=1/2.0+0.000000000001&&y/h>=1/2.0-0.000000000001&&y/h<=1/2.0+0.000000000001){
    cout<<fixed;
    cout<<setprecision(10);
    cout<<w*h/2.0<<" ";
    cout<<1<<endl;
  }
  else {
    cout<<fixed;
    cout<<setprecision(10);
    cout<<w*h/2.0<<" ";
    cout<<0<<endl;
  }
  
  return 0;
}


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

void Main() {
  int n;
  cin >> n;
  unordered_map<string, long long> cnt;
  for (int i = 0; i < n; i++) {
    char s[10];
    for (int j = 0; j < 10; j++) {
      cin >> s[j];
    }
    sort(s, s + 10);
    string sorted;
    sorted = s;
    if (cnt.find(sorted) == cnt.end()) {
      cnt.insert(pair<string, int>(sorted, 1));
    } else {
      int c = cnt[sorted];
      cnt.erase(sorted);
      cnt.insert(pair<string, int>(sorted, c + 1));
    }
  }

  long long ans = 0;
  for (decltype(cnt)::iterator it = cnt.begin(); it != cnt.end(); it++) {
    long long tmp = (*it).second;
    ans += tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
}

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

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

typedef long long ll;

int n, a, b;
vector <vector <int> > res;
vector <int> seq;

int main()
{
	scanf("%d %d %d", &n, &a, &b);
	if (a + b - 1 > n) { printf("-1\n"); return 0; }
	if (ll(a) * b < n) { printf("-1\n"); return 0; }
	for (int i = a - 1; i >= 0; i--) {
		vector <int> tmp; tmp.push_back(n - i);
		res.push_back(tmp);
	}
	int cur = 1;
	for (int i = 0; i < a && cur <= n - a; i++) {
		int tk = min(b - 1, n - a - cur + 1);
		cur += tk;
		for (int l = 1; l <= tk; l++)
			res[i].push_back(cur - l);
	}
	for (int i = 0; i < res.size(); i++)
		for (int j = 0; j < res[i].size(); j++)
			seq.push_back(res[i][j]);
	for (int i = 0; i < seq.size(); i++)
		printf("%d%c", seq[i], i + 1 < seq.size()? ' ': '\n');
	return 0;
}

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

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

int main() {
  int N, M;
  cin >> N >> M;

  if (N <= M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
S = list(input())

if (S[0] != S[2]) and (S[0] == S[1]) and (S[2] == S[3]):
    print("Yes")
elif (S[0] != S[1]) and (S[0] == S[2]) and (S[1] == S[3]):
    print("Yes")
elif (S[0] != S[1]) and (S[0] == S[3]) and (S[1] == S[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


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


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

using namespace std;

int main(){
int num;
long sum;

cin>>num;

sum=0;

for(int i=1;i<num+1;i++){
if(i%3==0||i%5==0){
continue;
}else{
sum = sum+i;
}
}

cout<<sum<<endl;
return 0;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
#define MAXN 2005
#define INF 1000000007
 
 
int main()
{ 
	FIN;
	
	#ifdef input
		//freopen("test1.txt", "r", stdin);
	#endif
	
	int x, n;
	cin >> x >> n;
	vector <int> v(n);
	forn(i,n) cin >> v[i];
	bool d=false;
	int pos = x;
	while(d==false)
	{
		d=true;
		forn(i,n) if(v[i]==pos) d=false;
		if(d==true) break;
		pos++;
	}
	int ans=pos;
	pos = x; d=false;
	while(d==false)
	{
		d=true;
		forn(i,n) if(v[i]==pos) d=false;
		if(d==true) break;
		pos--;
	}
	if(x-pos <= ans-x) ans=pos;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<queue>
using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if (a <= 9 && b <= 9) {
		cout << a * b << endl;
	}
	else {
		cout << -1 << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;





int main() {
    
    queue<int> q;
    int H,W,N;
    vector< vector<int> > ans;
    vector<int> A;
    cin >> H >> W >> N;
    
    A.resize(N);
    
    ans.resize(H);
    
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        
        for ( int j = 0; j < a; j++ ) {
            q.push( i+1 );
        }
    }
    
    
    
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            
            int a = q.front();
            q.pop();
            
            ans[h].push_back( a );
            
        }
    }
    
    for ( int h = 1; h < H; h += 2 ) {        
        reverse( ans[h].begin(), ans[h].end() );
    }
    
    
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            cout << ans[h][w];
            if ( w != W-1 ) { cout << " "; }
        }
        cout << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(Math.abs(a-b)>=2){
            if(a > b){
                System.out.println(a+(a-1));
            }else{
                System.out.println(b+(b-1));
            }
        }else{
            System.out.println(Math.max(a, b)+Math.min(a, b));
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_add_and_mul(void) {
	int n, k;
	cin >> n >> k;
	int now = 1;
	int min;
	for (int i = 0; i <= n; i++) {
		now = 1;
		now = (now << (1 * i)) + k * (n-i);
		if (i == 0) min = now;
		else {
			if (now < min) min = now;
		}
	}
	cout << min << endl;
}

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

Measured memory_bytes: 3588