akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		String s = scanner.next();

		int r = 0;
		int b = 0;
		for (int i = 0; i < N; i++) {
			if (s.charAt(i) == 'R') {
				r++;
			} else if (s.charAt(i) == 'B') {
				b++;
			}
		}

		if (r > b)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9;
const ll mod=998244353;
signed main(){
    ll I,O,T,J,L,S,Z;
    cin>>I>>O>>T>>J>>L>>S>>Z;
    ll ans=0;
    if(I&&J&&L){
        ll d=I%2+J%2+L%2;
        if(d>=2){
            I--;
            J--;
            L--;
            ans+=3;
        }
    }
    if(I%2)I--;
    if(J%2)J--;
    if(L%2)L--;
    ans+=I+J+L+O;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

## begin library unionfind
## usage: uf = UnionFind()
## usage: r = uf.Find_Root(x)
## usage: uf.Unite(x, y)
## usage: bool = uf.isSameGroup(x, y)
## usage: n = uf.Count(x)
class UnionFind():

    def __init__(self, n):
        self.n = n # number of nodes
        # if root[x]<0 then x is root and it has |x| leafs
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # find root of node x
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # path compression
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    # unite two trees which has node x and node y
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # same tree
        if(x == y):
            return
        # different tree
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # if same rank (same depth)
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # return number of leafs
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

## end library unionfind

N, M = iInM()
AB = iInLD1(M)

## 枝を一つずつ選んで、それ以外を全部つなげてみて、非連結になるか見る
## 一つの森を作る計算量: MlogN
## それをM回繰り返すので、全体の計算量: M^2 logN = N^4 logN

ans = 0
for i in range(M):
    ## 選んだ枝以外で森を作る
    uf = UnionFind(N)
    for j in range(M):
        if j == i:
            continue
        uf.Unite(AB[j][0], AB[j][1])
    if uf.Count(0) != N:
        ans += 1
    
print(ans)




Measured memory_bytes: 73796
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    vector<P> table(n);
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        table[i] = P(a, b);
    }
    sort(table.begin(), table.end(), [](const P& p1, const P& p2){
        if(p1.second == p2.second){
            return p1.first < p2.first;
        }
        return p1.second > p2.second;
    });
    set<int> bound;
    for(int i = 1; i <= m; ++i) bound.insert(i);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        auto it = bound.lower_bound(table[i].first);
        if(it == bound.end())   continue;
        ans += table[i].second;
        bound.erase(it);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll oo = 1e18;
const ll mod = 998244353,maxn = 3030;
const double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;

    int n = s.size(), l = 1, r = s.size();
    bool impossible = false;

    while (l < r){
        if (s[l-1] != s[r-1]) impossible = true;
        l++, r--;
    }
    l = 1, r = (n-1)/2;

    while (l < r){
        if (s[l-1] != s[r-1]) impossible = true;
        l++, r--;
    }

    l = (n+3)/2, r = n;
    while (l < r){
        if (s[l-1] != s[r-1]) impossible = true;
        l++, r--;
    }

    if (impossible) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 3572
#include <cstdio>
#include <cstdlib>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define min(q,w) ((q)>(w)?(w):(q))
#define abs(q) ((q)<0?-(q):(q))
using namespace std;
const int N=500500;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int f[N],a[N],c[N];
int main()
{
	int q,w;	
	read(n),read(m);
	c[0]=m;
	fo(i,1,n)read(a[i]),c[i]=min(c[i-1],abs(c[i-1]-a[i]));
	f[n+1]=0;
	fod(i,n,1)f[i]=f[i+1]+(f[i+1]*2+1>=a[i]?a[i]:0);
	read(m);
	fo(i,1,m)
	{
		read(q);
		if(c[q-1]>f[q+1])printf("YES\n");else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);	
int main()
{
	ll n,d;
	cin>>n>>d;
	vec x(n),y(n);
	ll ans=0;
	floop(i,0,n)
	{
		cin>>x[i];
		cin>>y[i];
		double dist=sqrt(x[i]*x[i] + y[i]*y[i]);
		if(dist<=d)
		ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 6492
n=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
min_t=1000000
for x in H:
    res=abs(A-(T-x*0.006))
    if min_t>=res:
        min_t=min(min_t,res)
        min_idx=H.index(x)
print(min_idx+1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin >> s >> t;
  bool res = false;
  if(s == t)res = true;
  for(int i = 0;i < s.size() - 1;i++){
    string now;
    now = s.substr(i + 1,s.size() - i + 1) + s.substr(0,i + 1);
    //cout << now << endl;
    if(t == now)res = true;
  }
  if(res)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

def count(a):
  if N < 10:
    if N < a:
      return 0
    else:
      return 1
  else:
    cnt_a = 1
    keta = 2
    while True:
      if N > int(str(a)+str(9)*(keta-2)+str(a)):
        cnt_a += 10 ** (keta-2)
        keta += 1
      elif N >= int(str(a)+str(0)*(keta-2)+str(a)):
        cnt_a += (N - a*(10**(keta-1)) - a) // 10 + 1
        break
      else:
        break
  return cnt_a
        
  
def count_(a, b):
  if N < 10:
    return 0, 0
  else:
    cnt_ = 0
    cnt__  = 0
    keta = 2
    while True:
      if N > int(str(b)+str(9)*(keta-2)+str(a)):
        cnt_ += 10 ** (keta-2)
        cnt__ += 10 ** (keta-2)
        keta += 1
      elif N >= int(str(b)+str(0)*(keta-2)+str(a)):
        cnt_ += (N - b*(10**(keta-1)) - a) // 10 + 1
        cnt__ += 10 ** (keta-2)
        break
      elif N > int(str(a)+str(9)*(keta-2)+str(b)):
        cnt_ += 10 ** (keta-2)
        break
      elif N >= int(str(a)+str(0)*(keta-2)+str(b)):
        cnt_ += (N - a*(10**(keta-1)) - b) // 10 + 1
        break
      else:
        break
  return cnt_, cnt__

ans = 0
for i in range(1, 10):
  for j in range(i, 10):
    # start, end  =  i, j
    if i == j:
      # １桁が可能
      #print(i, count(i))
      ans += count(i)**2
    else:
      pa, pa_ = count_(i,j)
      #print(i, j, pa, pa_)
      ans += pa * pa_ * 2
      
print(ans)      

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<queue>
using namespace std;
typedef vector<int>Vec;
int main()
{
	int a,b,arr[100],m=0;
	for(int i=1;i<=100;i*=2){
		arr[m++]=i;
	}
	cin>>a;
	for(int i=m-1;i>=0;i--){
		if(arr[i]<=a){
			cout<<arr[i]<<endl;
			return 0;
		}
	}
    return 0;
}

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

char num[5];

int small(void)
{
	int i, j, x;
	for(i = 0; i < 4; i++){
		for (j = 0; j < 3 - i; j++){
			if (num[j] > num[j + 1]){
				num[j] += num[j + 1];
				num[j + 1] = num[j] - num[j + 1];
				num[j] -= num[j + 1];
			}
		}
	}
	
	x = 0;
	for (i = 0; i < 4; i++){
		x = x * 10 + num[i] - '0';
	}
	return (x);
}

int lerge(void)
{
	int i, j, x;
	for(i = 0; i < 4; i++){
		for (j = 0; j < 3 - i; j++){
			if (num[j] < num[j + 1]){
				num[j] += num[j + 1];
				num[j + 1] = num[j] - num[j + 1];
				num[j] -= num[j + 1];
			}
		}
	}
	x = 0;
	for (i = 0; i < 4; i++){
		x = x * 10 + num[i] - '0';
	}
	return (x);
}

int main(void)
{
	int L, S, count, m;
	
	while (1){
		
		scanf("%s", num);
		count = 0;
		
		if (strcmp("0000", num) == 0){
			break;
		}
		
		if (num[0] == num[1] && num[1] == num[2] && num[2] == num[3]){
			printf("NA\n");
			continue;
		}
		
		while (1){
			
			if (strcmp("6174", num) == 0){
				printf("%d\n", count);
				break;
			}
			count++;
			
			L = lerge();
			S = small();
			m =  L - S;
			
			
			if (m < 1000){
				sprintf(num, "0%d", m);
			}
			else if(m < 100){
				sprintf(num, "00%d", m);
			}
			else if(m < 10){
				sprintf(num, "000%d", m);
			}
			else{
				sprintf(num, "%d", m);
			}
		}
	}
	
	return (0);
}
		

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

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

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

long long const MOD = 998244353;
long long const MAX = 300005;

//ax+by = (gcd of x and y)となるようにa,bを変更する
long long extgcd(long long x, long long y, long long &a, long long &b) {
	if (y == 0) {
		a = 1; b = 0;
		return x;
	}
	else {
		long long q = x / y; long long r = x % y;
		long long s;
		long long d = extgcd(y, r, s, a);
		b = s - a * q;
		return d;
	}
}

long long mod_inverse(long long x) {
	x %= MOD;
	long long a, b;
	a = b = 0;
	if (extgcd(x, MOD, a, b) != 1) {
		return -1;
	}
	else {
		return (MOD + a % MOD) % MOD;
	}
}
//階上をここに記憶
long long mod_fact[MAX];

void prep_fact(int n) {
	mod_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		mod_fact[i] = (mod_fact[i - 1] * i) % MOD;
	}
}

long long nCr(int n, int r) {
	return (((mod_fact[n] * mod_inverse(mod_fact[r])) % MOD)*mod_inverse(mod_fact[n - r])) % MOD;
}

int main() {
	prep_fact(MAX-1);
	int n; long long a,b,k;
	cin >> n >> a >> b >> k;
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		if ((k - a * i) < 0) {
			break;
		}
		if ((k - a * i) % b == 0) {
			long long  j = (k - a * i) / b;
			if (j > n) {
				continue;
			}
			ans = (ans + nCr(n, i)*nCr(n, j)) % MOD;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int a;
  cin >> a;
  int b[a];
  int i;
  int j;
  int max = 0;
  int max2;
  
  for(i = 0; i < a; i++){
    cin >> b[i];
  }
  for(i = 0; i < a; i++){
    if(max <= b[i]){
      max2 = max;
      max = b[i];
    }
    else if(b[i] > max2){
      max2 = b[i];
    }
  }
  for(i = 0; i < a; i++){
    if(b[i] != max){
      cout << max << endl;
    }
    else{
      cout << max2 << endl;
    }
  }
}


Measured memory_bytes: 2432
#include<iostream>
#include<string>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  int cnt(0);
  for(int i(0);i<a;i++){
    if(s[i]!='-')cnt++;
  }
  if(s[a]=='-')cnt++;
  for(int i(a+1);i<a+b+1;i++){
    if(s[i]!='-')cnt++;
  }
  if(cnt==a+b+1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,a[100][100];
int d[100];
int f[100];
int color[100];
int t;

void getnumber(int i){
  int k;
  color[i]=GRAY;
  d[i]=++t;
  for(k=0;k<n;k++){
    if(a[i][k]==0){
      continue;
    }
    if(color[k]==WHITE){
      getnumber(k);
    }
  }
  color[i]=BLACK;
  f[i]=++t;
}
void find(){
  int i;
  for(i=0;i<n;i++){
    color[i]=WHITE;
    t=0;
  }
  for(i=0;i<n;i++){
    if(color[i]==WHITE){
      getnumber(i);
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

int main(int argc, char const *argv[]) {
  int k,i,j,number,dimention,element;

  int d[100];
  int f[100];
  int color[100];
  scanf("%d",&n);
  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&number,&dimention);
    for(j=0;j<dimention;j++){
      scanf("%d",&element);
      a[number-1][element-1]=1;
    }
  }
  /*for(i=0;i<n;i++){
    color[i]=WHITE;
  }
  t=0;
  for(i=0;i<100;i++){
    if(color[i]==WHITE){
      visit(i);
    }
  }*/
  /*for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d ",a[i][j]);
    }
    printf("\n");
  }
*/
  find();
  return 0;
}




/*void visit(r){
  S.push(r);
  color[r]= GRAY;
  d[r]=++t;
  while(S)
}*/

Measured memory_bytes: 640
from itertools import accumulate
import sys

input = sys.stdin.buffer.readline

n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

kouho = []

used = [False] * (n)
for i in range(n):
    if used[i]:
        continue
    now = i
    cnt = 0
    res = 0
    route = []
    while True:
        if used[now]:
            break
        route.append(C[P[now] - 1])
        used[now] = True
        nex = P[now] - 1
        cnt += 1
        res += C[nex]
        now = nex
    kouho.append((res, cnt, route))

ans = -(10 ** 20)
for res, cnt, route in kouho:
    kaisu = min(k, cnt)
    temp2 = -(10 ** 20)
    route += route
    ACR = list(accumulate([0] + route))
    for shiten in range(cnt):
        for kosuu in range(1, kaisu + 1):
            temp3 = ACR[kosuu + shiten] - ACR[shiten]
            if res > 0 and k >= cnt:
                temp3 += (k - kosuu) // cnt * res
            temp2 = max(temp2, temp3)
    ans = max(ans, temp2)
    # print(ans)
print(ans)


Measured memory_bytes: 69376
n,x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
for i in range(n):
  a[i] = abs(a[i] - x)

def gcd(x,y):
  while y != 0:
    x, y = y, x % y
  return x

res = a[0]
for i in range(n):
  res = gcd(res,a[i])
print(res)

Measured memory_bytes: 19928
ABCD = list(input())
OP = (('+', '-'), ('+', '-'), ('+', '-'))
N = len(OP)
ans = 0

for i in range(2 ** N):
    op123 = ['+'] * 3
    for j in range(N):
        if ((i >> j) & 1):
            op123[j] = OP[j][1]
    ans = ABCD[0]+op123[0]+ABCD[1]+op123[1]+ABCD[2]+op123[2]+ABCD[3]
    if eval(ans) == 7:
        ans += '=7'
        break

print(ans)

Measured memory_bytes: 3064
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = inn()
print(a[k-1])


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  long long n, m;
  cin >> n >> m;
  cout << abs((n - 2) * (m - 2)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,L,t; cin >> n >> L >> t;
	vl place;
	vvl v(2);
	ll counter = 0;
	rep(i,n){
		ll x,w; cin >> x >> w; w--;
		if(!w) place.push_back((x+t)%L);
		else place.push_back((x-t%L+L)%L);
		if(!w){
			if(L-x > t) continue;
			counter -= (t - (L-x)) / L + 1;
		}else{
			if(x >= t) continue;
			counter += (t - x - 1) / L + 1;
		}
	}
	sort(all(place));
	if(counter < 0){
		counter = -counter;
		counter %= n;
		counter = (-counter + n) % n;
	}else{
		counter %= n;
	}
	rotate(place.begin(), place.begin()+n-counter, place.end());
	rep(i,n) cout << place[i] << "\n";
}

Measured memory_bytes: 4204
#include<iostream>
#include <string>
#include <vector>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n,k = map(int, input().split())
tmpNum = n
subtraction = n
if n % k == 0:
  print(0)
else:
  tmp = int(n/k)
  subtraction = n - (tmp*k)
  while(1):
    subtraction = abs(subtraction-k)
    if subtraction < tmpNum:
      tmpNum = subtraction
    else:
      break
  print(tmpNum)

Measured memory_bytes: 38256
def solve(n, xs):

    ans = 0
    tmp = {}
    for i in range(n-1, -1, -1):
        l = i+1 + xs[i]
        r = i+1 - xs[i]

        if l in tmp:
            ans += tmp[l]

        if r in tmp:
            tmp[r] += 1
        else:
            tmp[r] = 1

    return ans
if __name__ == "__main__":
    n = int(input())
    xs = [int(i) for i in input().split()]
    print(solve(n, xs))


Measured memory_bytes: 40428
#include <stdio.h>

int main(void){
  int N,counter;
  int min = 60000;
  long long a;
  scanf("%d",&N);

  for(int i = 0;i < N;i++){
    counter = 0;
    scanf("%lld",&a);
    while(a%2 == 0){
      a /= 2;
      counter++;
    }
    if(min > counter) min = counter;
  }

  printf("%d\n",min);

  return 0;
}

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

int main() {
  char b;
  cin >> b;
  if (b == 'A') {
    cout << 'T' << endl;
  } else if (b == 'T') {
    cout << 'A' << endl;
  } else if (b == 'C') {
    cout << 'G' << endl;
  } else {
    cout << 'C' << endl;
  }
}

Measured memory_bytes: 256
// C - Factors of Factorial
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

map<int, int> prime_count;

int div_counter(int n, int d){
	while(n%d==0){
		prime_count[d]++;
		n /= d;
	}
	return n;
}

void prime_creator(int n){
	n = div_counter(n,2);
	int d = 3;
	while(n!=1){
		n = div_counter(n,d);
		d += 2;
	}
}

int main(){
	int n; cin>>n;
	for(int i=n; i>1; i--) prime_creator(i);
	long long ans = 1;
	for(auto e:prime_count) ans = ans * (e.second+1) % MOD;
	cout<< ans <<endl;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        x1: i64,
        y1: i64,
        x2: i64,
        y2: i64,
    }
    let dx = (x2 - x1).abs();
    let dy = (y2 - y1).abs();
    if x1 <= x2 && y1 <= y2 {
        println!("{} {} {} {}", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
    } else if x1 > x2 && y1 <= y2 {
        println!("{} {} {} {}", x2 - dy, y2 - dx, x1 - dy, y1 - dx);
    } else if x1 > x2 && y1 > y2 {
        println!("{} {} {} {}", x2 + dy, y2 - dx, x1 + dy, y1 - dx);
    } else {
        println!("{} {} {} {}", x2 + dy, y2 + dx, x1 + dy, y1 + dx);
    }
}


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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
void solve()
{
    string s;
    cin>>s;
    int temp=0;
    int ans=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            temp++;
        else
        {
            
            ans=max(ans,temp);
            temp=0;
        }
    }
    ans=max(ans,temp);
    cout<<ans;
    return;
    
}
int32_t main()
{
    SKY;
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    return 0;
}
/*
 Umang Agrawal
 */


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


using namespace std;

int main(){
    int n;
    long long int a[100000], b[100000], c[100000];

    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
        cin >> c[i];

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    int a_pointer = 0;
    int c_pointer = 0;
    long long int ans = 0;
    for(int i = 0; i < n; i++){
        while(a_pointer < n && a[a_pointer] < b[i])
            a_pointer += 1;
        while(c_pointer < n && b[i] >= c[c_pointer])
            c_pointer += 1;

        if((a_pointer >= n && a[n-1] >= b[i]) || (c_pointer >= n && c[n-1] <= c[i]))
            break;
        ans += 1L * a_pointer * (n - c_pointer);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int p, q, a, n;
	static long ans = 0;

	public static void main(String[] args) {
		while (true) {
			p = sc.nextInt();
			q = sc.nextInt();
			a = sc.nextInt();
			n = sc.nextInt();
			if (p == 0) break;
			System.out.println(solve());
		}
	}

	static long solve() {
		ans = 0;
		dfs(new Rational(p, q), 1, 0, 1);
		return ans;
	}

	static void dfs(Rational cur, long mul, int depth, long prev) {
		if (depth == n) {
			return;
		}
		for (long i = prev; mul * i <= a; ++i) {
			Rational next = cur.sub(new Rational(1, i));
			if (next.num < 0) continue;
			if (next.num == 0) {
				++ans;
				continue;
			}
			if (mul * i * i > a) break;
			dfs(next, mul * i, depth + 1, i);
		}
	}

	static class Rational {
		long num, den;

		Rational(long num, long den) {
			long gcd = gcd(Math.abs(num), Math.abs(den));
			this.num = num / gcd;
			this.den = den / gcd;
		}

		Rational sub(Rational o) {
			long n = this.num * o.den - o.num * this.den;
			long d = this.den * o.den;
			return new Rational(n, d);
		}

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

	}

}

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

#define sd(a) scanf("%d",&a)
#define ss(a) scanf("%s",a)
#define sl(a) scanf("%lld",&a)
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define N 60

ll a[N];
ll b[N];

int main()
{
	int n,i,j;
	sd(n);
	for(i=0;i<n;i++)
		sl(a[i]);
	ll ops=0;
	while(true)
	{
		clr(b);
		ll Sum=0;
		for(i=0;i<n;i++)
		{
			if(a[i]<n-1)	continue;
			ll diff=a[i]-n+1;
			ll q=diff/n;
			if(q*n<diff)
				q++;
			Sum+=q;
			b[i]=q;
			a[i]-=q*n;
		}
		ops+=Sum;
		for(i=0;i<n;i++)
			a[i]+=Sum-b[i];
		if(!Sum)	break;
	}
	printf("%lld\n",ops);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node
{
   long long  int bl,wh;
}c[101];
int main()
{
  long long  int a,b,d,i,j,s=0;
   scanf("%lld %lld",&a,&b);
   memset(c,0,sizeof(c));
   for(i=1;i<=b;i++)
   {
       if(i%2==0) {c[i].bl=0;c[i].wh=1;}
       else {c[i].wh=0;c[i].bl=1;}
   }
  c[b].bl++;
   for(i=b+1;i<=a;i++)
   {
       c[i].bl=c[i-1].wh+c[i-b].wh;
       c[i].wh=c[i-1].bl;
   }
   for(i=1;i<=a;i++)
   {
       s=s+c[i].bl;
   }

   printf("%lld\n",s);
    return 0;
}



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

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

  const int M = 1e9 + 7;

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

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());

  if (N == K || A.back() < 0) {
    int res = 1;
    for (int i = 0; i < K; ++i) res = (int64_t) res * (K & 1 ? A.rbegin()[i] : A.begin()[i]) % M;
    if (res < 0) res += M;
    cout << res << endl;
  } else {
    int res = 1;
    int i = 0, j = N - 1;
    if (K & 1) --K, res = A[j--];
    for (; K; K -= 2) {
      int64_t v0 = (int64_t) A[i] * A[i + 1];
      int64_t v1 = (int64_t) A[j] * A[j - 1];
      if (v0 > v1) res = (int64_t) res * (v0 % M) % M, i += 2;
      else res = (int64_t) res * (v1 % M) % M, j -= 2;
    }
    if (res < 0) res += M;
    cout << res << endl;
  }

  return 0;
}



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

// 入力制約
#define NUM_MIN ( ( int ) 1 )
#define NUM_MAX ( ( int ) 10000 )
#define INT_MIN ( ( int ) 2 )
#define INT_MAX ( ( int ) 100000000 )

// 制約判定結果
typedef enum
{
	kSuccess,
	kError
}Result;

// プロトタイプ宣言
Result checkNumRange( int num, int min, int max );
int isPrimeNum( int num );

//****************************************************/
// @brief  メイン関数
// @param  無し
// @return 正常終了なら0、異常終了なら-1を返す
//****************************************************/
int main( void )
{
	int i;
	int num;
	int array[NUM_MAX];
	int primeNumCount = 0;

	// 入力判定
	scanf( "%d\n", &num );
	if( checkNumRange( num, NUM_MIN, NUM_MAX ) == kError )
	{
		return -1;
	}

	// 素数チェック
	for( i = 0; i < num; i++ )
	{
		// 入力判定
		scanf( "%d\n", &array[i] );
		if( checkNumRange( array[i], INT_MIN, INT_MAX ) == kError )
		{
			return -1;
		}

		// 素数の数をカウント
		if( isPrimeNum( array[i] ) == 0 )
		{
			++primeNumCount;
		}
	}

	// 素数の数を出力
	printf( "%d\n", primeNumCount );

	return 0;
}

//****************************************************/
// @brief  入力値の制約判定
// @param  num : 判定対象の入力値
//         min : 最小値
//         max : 最大値
// @return 制約内ならkSuccess、制約外ならkErrorを返す
//****************************************************/
Result checkNumRange( int num, int min, int max )
{
	return ( ( num >= min ) && ( num <= max ) ) ? kSuccess : kError;
}

//****************************************************/
// @brief  素数判定
// @param  num : 判定対象の入力値
// @return 素数なら0、素数でないなら-1を返す
//****************************************************/
int isPrimeNum( int num )
{
	int i;

	// 2は素数
	if( num == 2 )
	{
		return 0;
	}

	// 2未満、偶数は素数でない
	if( ( num < 2 ) || ( ( num % 2 ) == 0 ) )
	{
		return -1;
	}

	// 3以降の奇数は平方根まで判定すればよい
	for( i = 3; i <= (int)sqrt( (double)num ); i += 2 )
	{
		// 割り切れれば素数でない
		if( ( num % i ) == 0 )
		{
			return -1;
		}
	}

	// 上記以外は素数
	return 0;
}




Measured memory_bytes: 2100
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;

#define INF (1e9)

int gcd(int a, int b) {
    if (a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}
int main() {
    int N, X, x;
    cin >> N >> X;

    int ans;

    cin >> x;
    ans = X - x;

    for (int i = 1; i < N; i++) {
        cin >> x;
        ans = gcd(ans, X - x);
    }

    cout << abs(ans) << endl;
    return 0;
}


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

int main() {
  int a,b,x,y,z;
  cin >> a >> b;
  x = a + b;
  y = a - b;
  z = a* b;
  if(x >= y && x >= z){
    cout << x << endl;
  }else if(y >= x && y >= z){
     cout << y << endl;
  }else{
  cout << z << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input1.txt", "r", stdin);
    //     freopen("output1.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    double p[n+1];
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    int j;
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-p[i]);
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(j<i)
            {
                dp[i][j]=(dp[i-1][j]*(1-p[i]))+(dp[i-1][j-1]*p[i]);
            }
            if(j==i)
            {
                dp[i][j]=dp[i-1][j-1]*p[j];
            }
        }
    }
    // for(i=0;i<=n;i++)
    // {
    //     for(j=0;j<=n;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    double sum=0;
    int fuck=n/2;
    for(i=n;i>fuck;i--)
    {
        sum=sum+dp[n][i];
    }
    cout<<setprecision(12)<<sum<<endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105;
ll f[N][N][N],mo;
int n,m,k;
ll C[N][N];
ll pw[N][N*N];
void move(ll &a,ll b){
	a=(a+b)%mo;
}
int main(){
	cin>>n>>m>>k>>mo;
	for (int i=0;i<=100;i++){
		C[i][0]=C[i][i]=1;
		for (int j=1;j<i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
		pw[i][0]=1;
		for (int j=1;j<=10000;j++)
			pw[i][j]=pw[i][j-1]*i%mo;
	}
	f[0][0][0]=1;
	for (int h=1;h<=k;h++){
		for (int i=0;i<=n;i++)
		for (int j=0;j<=m;j++){
			ll p0=(pw[h][m-j]-pw[h-1][m-j]+mo)%mo*pw[k-h+1][j]%mo,p1=1;
			for (int x=i;x<=n;x++){
				move(f[h][x][j],f[h-1][i][j]*C[n-i][x-i]%mo*p1);
				p1=p1*p0%mo;
			}
		}
		for (int i=0;i<=n;i++)
		for (int j=m;j>=0;j--){
			ll p0=(pw[k-h+1][i]-pw[k-h][i]+mo)%mo*pw[h][n-i]%mo,p1=1;
			for (int x=j+1;x<=m;x++){
				p1=p1*p0%mo;
				move(f[h][i][x],f[h][i][j]*C[m-j][x-j]%mo*p1);
			}
		}
	}
	cout<<f[k][n][m]<<endl;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll m, d;
int main() {
    cin>>m>>d;
    
    ll cnt=0;
    REP(i, 1, m+1){
        REP(j, 10, d+1){
            int d1=j%10;
            int d2=j/10;
            if(d1>=2 && d2>=2 && d1*d2==i){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

long long gcd(long long a, long long b)
{
	long long temp;
	while (a % b != 0)
	{
		temp = b;
		b = a % b;
		a = temp;
	}
	return b;
}

long countDivisor(long long min_dividend, long long max_dividend, long long divisor)
{
	long count = 0;
	long long min = ((min_dividend + (divisor - 1)) / divisor);
	long long max = max_dividend / divisor;
	if (min * divisor >= min_dividend && max_dividend >= max * divisor)
	{
		count += max - min + 1;
	}
	return count;
}

int main()
{
	long long A, B, C, D;
	cin >> A >> B >> C >> D;

	long count = 0;
	count += countDivisor(A, B, C);
	count += countDivisor(A, B, D);

	long long g = C * D / gcd(C, D);
	count -= countDivisor(A, B, g);

	cout << (B - A + 1) - count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

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

    int ans = 0;
    int a, b;
    cin >> a >> b;
    for (int cnt = 1; cnt < b; cnt += a - 1) ans++;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string str;
	cin>>str;
	int i,res=0;
	if(str.size()%2==0){
		for(i=0;i<str.size()/2;i++){
			if(str[i]=='('){
				if(str[str.size()-i-1]!=')')res++;
			}else if(str[i]==')'){
				if(str[str.size()-i-1]!='(')res++;
			}else{
				if(str[i]!=str[str.size()-i-1])res++;
			}
		}
	}else{
		for(i=0;i<str.size()/2;i++){
			if(str[i]=='('){
				if(str[str.size()-i-1]!=')')res++;
			}else if(str[i]==')'){
				if(str[str.size()-i-1]!='(')res++;
			}else{
				if(str[i]!=str[str.size()-i-1])res++;
			}
		}
		if(str[str.size()/2]!='i'&&str[str.size()/2]!='w')res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 0
n = int(input())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
p_d = 0
q_d = 0
cnt = 0
if ps == qs:
    print(0)
    exit()
from itertools import permutations as perm
perms = list(range(1,n+1))
for p in perm(perms):
    if list(p) == ps:
        p_d = cnt
    elif list(p) == qs:
        q_d = cnt
    cnt += 1
print(abs(p_d-q_d))

Measured memory_bytes: 9096
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int

	fmt.Scanf("%d", &N)

	d := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &d[i])
	}

	sort.Sort(sort.IntSlice(d))

	x := 1
	for i := N - 1; i > 0; i-- {
		if d[i] > d[i-1] {
			x++
		}
	}

	fmt.Println(x)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=-1){
		string str;
		if(n!=0){
			while(n!=0){
				int t = n % 4;
				str+=(char)(t+'0');
				n/=4;
			}
			reverse(str.begin(),str.end());
			cout<<str<<endl;
		}
		else
			cout<<0<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s;
	cin >> s;
	if (c < b) {
		bool flag = true;
		FOR(i, a, c) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		FOR(i, b, d) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		if (flag) {
			put("Yes");
		}
		else {
			put("No");
		}
	}
	else if (c < d) {
		bool flag = true;
		FOR(i, a, d) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		if (flag) {
			put("Yes");
		}
		else {
			put("No");
		}
	}
	else {
		bool flag = true;
		FOR(i, a, c) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		if (!flag) {
			put("No");
			return 0;
		}
		bool flag2 = false;
		FOR(i, b-1, d) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				flag2 = true;
				break;
			}
		}
		if (flag2) {
			put("Yes");
		}
		else {
			put("No");
		}
	}
	return 0;
}


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

//単一始点最短経路（負の重みをもつ辺を含む）
//https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_B
#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

struct edge {
	int from;
	int to;
	ll cost;
};

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

struct KruskalRunner {
	static bool orderByCost(const edge& e1, const edge& e2) {
		return e1.cost < e2.cost;
	}

	ll solve(int vCount, vector<edge>& edges) {
		sort(edges.begin(), edges.end(), orderByCost);
		UnionFind uf = UnionFind(vCount);
		ll sum = 0;
		for (int i = 0; i < edges.size(); ++i) {
			edge e = edges[i];
			if (!uf.issame(e.from, e.to)) {
				uf.merge(e.from, e.to);
				sum += e.cost;
			}
		}
		return sum;
	}
};
int main(void)
{
	int v, e;
	cin >> v >> e;
	vector<edge> g;
	rep(i, e) {
		int s, t, c;
		cin >> s >> t >> c;
		g.push_back({ s, t, c });
	}
	KruskalRunner r;
	auto cost = r.solve(v, g);
	cout << cost << endl;
	return 0;
}



Measured memory_bytes: 4924
import kotlin.math.abs
import kotlin.math.min

fun main() {
    val n = readInt()
    val colors = readLn()
    val white = colors.count { it == 'W' }
    val whiteSuffix = IntArray(n)
    for (i in n - 1 downTo 0) {
        if (colors[i] == 'W') whiteSuffix[i] = 1
        if (i < n - 1) whiteSuffix[i] += whiteSuffix[i + 1]
    }

    var best = Int.MAX_VALUE
    for (i in n downTo 0) {
        val d = n - i
        val change = abs(white - d)
        val swaps = if (i < n) d - whiteSuffix[i] else d
        best = min(best, change + swaps)
    }

    println(best)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readInt() = readLn().toInt()


Measured memory_bytes: 39392