akhauriyash/Code-Regression huggingface dataset:
/*
    author:ujwalll
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std; 
#define rep(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1<<29;
const int MOD=1073741824;
#define pp pair<ll,ll>
#define ppi pair<int,int>
typedef long long int ll;
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
////////////////////////////////////////////////////////////////////
int freq[1000005];
// vector<int> v[100005];
bool solve(int a[],int n){
    rep(j,n){
        int x=a[j];
        for(int i=2;i*i<=x;i++){
            if(x%i==0)freq[i]++;
            if(freq[i]>1)return 0;
            while(x%i==0)x/=i;
        }
        if(x>1)freq[x]++;
        if(freq[x]>1)return 0;
    }
    return 1;
}
int main(){
    int tc=1;
    // cin>>tc;
    while(tc--){
        int n;
        cin>>n;
        int a[n];
        int gc=0;
        rep(i,n){
            cin>>a[i];
            gc=__gcd(gc,a[i]);
        }
        if(solve(a,n))cout<<"pairwise coprime";
        else if(gc==1)cout<<"setwise coprime";
        else cout<<"not coprime";
    }
    return 0;
}


Measured memory_bytes: 7772
if __name__ == '__main__':
    N, M = map(int, input().split())
    A = {}
    B = {}

    for i in range(N):
        A[i], B[i] = map(int, input().split())

    ans = 0
    for k, v in sorted(A.items(), key=lambda x: x[1]):
        if M > B[k]:
            ans += v * B[k]
            M -= B[k]
            if M < 1:
                break
        else:
            ans += v * M
            break

    print(ans)

Measured memory_bytes: 33424
import time
from random import randrange
start = time.time()

D=int(input())
c=list(map(int,input().split()))
def compare(d,q):
  score=maxscore
  changebefore=currentans[d]-1
  changeafter=q-1
  r=contests[changebefore]
  score-=s[d][changebefore]
  score+=s[d][changeafter]
  for j in range(len(r)-1):
    if r[j]==d:
      score-=c[changebefore]*((r[j+1]-r[j-1]-1)*(r[j+1]-r[j-1]))//2
      score+=c[changebefore]*((r[j+1]-d-1)*(r[j+1]-d))//2
      score+=c[changebefore]*((d-r[j-1]-1)*(d-r[j-1]))//2
      break
  r=contests[changeafter]
  for j in range(len(r)-1):
    if r[j+1]>d:
      score+=c[changeafter]*((r[j+1]-r[j]-1)*(r[j+1]-r[j]))//2
      score-=c[changeafter]*((r[j+1]-d-1)*(r[j+1]-d))//2
      score-=c[changeafter]*((d-r[j]-1)*(d-r[j]))//2
      break
  if score>maxscore:
    return score
  else:
    return maxscore

s=[0]
last=[0]*26
currentans=[0]*(D+1)
for i in range(D):
  s.append(list(map(int,input().split())))
contests=[]
for i in range(26):
  contests.append([])
  contests[-1].append(0)
  contests[-1].append(D+1)
#Donyoku
for i in range(1,D+1):
  score=0
  t=0
  score+=s[i][t]
  lasttemp=last[t]
  last[t]=i
  for j in range(26):
    score-=c[j]*(i-last[j])
  maxscore=score
  bestans=1
  last[t]=lasttemp
  for t in range(1,26):
    score=0
    score+=s[i][t]
    lasttemp=last[t]
    last[t]=i
    for j in range(26):
      score-=c[j]*(i-last[j])
    if maxscore<score:
      bestans=t+1
      maxscore=score
    last[t]=lasttemp
  last[bestans-1]=i
  currentans[i]=bestans
for i in range(1,D+1):
  contests[currentans[i]-1].append(i)
counter=0
breakflag=0
while True:
  if counter%100==0:
    now=time.time()
    if now-start>1.75:
      breakflag=1
  if breakflag==1:
    break
  q=randrange(26)+1
  d=randrange(D)+1
  if currentans[d]==q:
    continue
  score2=compare(d,q)
  if score2>maxscore:
    changebefore=currentans[d]-1
    changeafter=q-1
    contests[changebefore].remove(d)
    contests[changeafter].append(d)
    contests[changeafter].sort()
    currentans[d]=q
    maxscore=score2
  counter+=1
for i in range(1,D+1):
  print(currentans[i])

Measured memory_bytes: 82600
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct nodo{
	int num,tip;
} ;
nodo a[100010];
int n;
bool cmp(nodo x,nodo y){
	return x.num<y.num;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].num;
		a[i].tip=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		cout<<a[i].tip<<" ";
	}
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n, a[MAX];
  scanf("%d", &n);
  rep(i, 0, n) scanf("%d", &a[i]);

  int visited[MAX] = {0};
  int next = 1;
  int cnt = 0;
  while ( next != 2 ) {
    int now = next;
    if ( visited[now] ) {
      printf("-1\n");
      return 0;
    }
    next = a[now-1];
    visited[now] = 1;
    cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  map<ll,ll> c;
  for(ll i=0;i<n;i++) {
    c[a[i]]=c[a[i]-1]+1;
  }
  ll m=0;
  for(auto p:c) {
    m=max(m,(ll)p.second);
  }
  cout << n-m << endl;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

struct Dice {
    int f[6];

    Dice() {
        f[0] = 1; f[1] = 6; f[2] = 2; f[3] = 3; f[4] = 5; f[5] = 4;
    }

    void roll(int i,int j,int k,int l) {
        int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }

    void move(char ch) {
        if(ch == 'E') roll(0,5,1,3);
        if(ch == 'W') roll(0,3,1,5);
        if(ch == 'N') roll(0,2,1,4);
        if(ch == 'S') roll(0,4,1,2);
        if(ch == 'R') roll(2,3,4,5);
        if(ch == 'L') roll(2,5,4,3);
    }
};

int main() {
    int n;

    while(cin >> n && n) {
        int sum = 1;
        Dice dice;
        rep(i,n) {
            string s;
            cin >> s;


            dice.move(s[0]);
            sum += dice.f[0];
        }

        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner c = new Scanner(System.in);
        int n = c.nextInt();
        long k = 0;
        for(int i=1;i<=n;i++) {
            long s = n/i;
            k+=(s+1)*i*s/2;
        }
        System.out.println(k);
    }
}


Measured memory_bytes: 35492
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 m = sc.nextInt();
        int[] nums = new int[n + 1];
        int[] counts = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            nums[i] = sc.nextInt();
            counts[nums[i]]++;
        }
        int[] imos = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            imos[Math.max(i - counts[i], 0)]++;
            imos[i]--;
        }
        int zeros = -1; //imos[n] == 0のため
        if (imos[0] == 0) {
            zeros++;
        }
        for (int i = 1; i <= n; i++) {
            imos[i] += imos[i - 1];
            if (imos[i] == 0) {
                zeros++;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < m; i++) {
            int idx = sc.nextInt();
            int x = nums[idx];
            if (x - counts[x] >= 0) {
                imos[x - counts[x]]--;
                if (imos[x - counts[x]] == 0) {
                    zeros++;
                }
            }
            counts[x]--;
            int y = sc.nextInt();
            nums[idx] = y;
            counts[y]++;
            if (y - counts[y] >= 0) {
                if (imos[y - counts[y]] == 0) {
                    zeros--;
                }
                imos[y - counts[y]]++;
            }
            sb.append(zeros).append("\n");
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 162716
n,*a=`dd`.split.map &:to_i;f=0;puts %w(Second First)[loop{b=a.map{|e|e&1^1};s=b.reduce :+;(s==n&&a[0]-=1)||(s==n-1&&(0...n).find{|i|b[i]==0&&a[i]>1&&a[i]-=1})||(break f^=s&1);g=a.reduce :gcd;a=a.map{|e|e/g};f^=1}]

Measured memory_bytes: 31852
#include<iostream>
using namespace std;
int main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  int x[N],y[M];
  for(int i=0;i<N;i++) cin>>x[i];
  for(int i=0;i<M;i++) cin>>y[i];
  int max_x=-100, min_y=100;
  for(int i=0;i<N;i++) if(max_x<x[i]) max_x=x[i];
  for(int i=0;i<M;i++) if(min_y>y[i]) min_y=y[i];
  int r1=min_y-X,r2=Y-max_x,r3=min_y-max_x,r4=Y-X;
  cout<<(r1>0&&r2>0&&r3>0&&r4>0?"No War":"War")<<endl;
}

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

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

  string t = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i, S.size()) {
    if (S[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

signed main() {
  int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int x = tx - sx, y = ty - sy;
	string ans = "";
	for (int i = 0; i < x; ++i)
		ans += 'R';
	for (int i = 0; i < y; ++i)
		ans += 'U';
	for (int i = 0; i < x; ++i)
		ans += 'L';
	for (int i = 0; i < y; ++i)
		ans += 'D';
	ans += 'L';
	for (int i = 0; i <= y; ++i)
		ans += 'U';
	for (int i = 0; i <= x; ++i)
		ans += 'R';
	ans += 'D';
	ans += 'R';
	for (int i = 0; i <= y; ++i)
			ans += 'D';
	for (int i = 0; i <= x; ++i)
		ans += 'L';
	ans += 'U';
	cout << ans << '\n';
}

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

int main() {
	ll n;
	cin>>n;
	ll ans=0,ch=inf;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ans+=x;
		if(x%10!=0){
			ch=min(ch,x);
		}
	}
	if(ans%10!=0){
		cout <<ans;
		return 0;
	}
	cout << max(ll(0),ans-ch);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
x=input()
i=0
while int(x)>i :
    a,b,c=input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    if a*a==b*b+c*c or b*b==c*c+a*a or c*c==b*b+a*a :
        print("YES")
    else :
        print("NO")
    i=i+1


Measured memory_bytes: 5592
import collections
S = list(input())
c_odd = collections.Counter(S[::2])
c_evn = collections.Counter(S[1::2])
if c_odd['0'] > c_evn['0']:
    a = c_odd['1'] + c_evn['0']
else:
    a = c_odd['0'] + c_evn['1']

if c_odd['1'] > c_evn['1']:
    b = c_odd['0'] + c_evn['1']
else:
    b = c_odd['1'] + c_evn['0']
print(min(a, b))

Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;
 
 
bool isPrime(ll n) {
    if(n <= 1) return false;
    if(n <= 3) return true;
 
    if(n % 2 == 0) return false;
    if(n % 3 == 0) return false;
 
    for(ll i = 5; i * i <= n; i += 6) {
        if(n % i == 0 || n % (i + 2) == 0) return false;
    }
    return true;
}
 
unordered_map< ll, ll > powerOfPrimeDivisors(ll number) {
    unordered_map< ll, ll > P;
 
    ll n = number;
    ll sqrtn = (ll)sqrt(n + 10);
 
    while(n % 2 == 0) { n /= 2; P[2]++;}
    while(n % 3 == 0) { n /= 3; P[3]++;}
 
    for (ll i = 5; i <= sqrtn; i = i + 6) {
        while(n % i == 0) { n /= i; P[i]++;}
        while(n % (i+2) == 0) { n /= (i+2); P[i + 2]++;}
    }
 
    if(n != 1) P[n]++;
    return P;
}
 
int prime[N];
 
void sieve() {
    memset(prime, 0, sizeof(prime));
    prime[0] = prime[1] = 1;
 
    for (int i = 2; i < N; i++) {
        if (prime[i] == 0) {
            for (int j = i; j < N; j += i) prime[j] += 1;
        }
    }
}
 
 
int main() {
    fast;
 
    // sieve();
    ll n; cin >> n;
 
    if(n <= 1)
        cout << 0 << "\n";
    else if( isPrime(n) )
        cout << 1 << "\n";
    else {
        unordered_map< ll, ll > primefactor = powerOfPrimeDivisors(n);
 
        int ans = 0;
        for(auto e: primefactor) {
            ll powerOfDiv = e.second;
 
            for(ll i = 1; powerOfDiv >= i; i++) {
                ans++;
                powerOfDiv -= i;
            }
        }
 
        cout << ans << "\n";
    }
    return 0;
}

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

const int N = 1300;

int main()
{
	char str1[N], str2[N];
	
	while(fgets(str1, N, stdin))
	{
		int s1 = strlen(str1) - 1, go = 0;
		
		for(int i = s1, j = 0; i < s1 * 2; i++, j++)
		{
			str1[i] = str1[j];
		}
		fgets(str2, N, stdin);
		for(int i = 0; i < strlen(str1); i++)
		{
			int k = 0;
			for(int j = 0; j < strlen(str2) - 1; j++)
			{
				if(str1[i + j] == str2[j])
				{
					k++;
				}
				else
				{
					break;
				}
			}
			if(k == strlen(str2) - 1)
			{
				go = 1;
				break;
			}
		}
		if(go)
		{
			printf("Yes\n"); 
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
    int ansum=0,ansugar=0;
    double den=0;
    for(int i=0;100*a*i<=f;i++){
        for(int j=0;100*a*i+100*b*j<=f;j++){
            int water=100*a*i+100*b*j;
            if(water==0) continue;
            for(int k=0;water+c*k<=f;k++){
                for(int l=0;water+c*k+d*l<=f;l++){
                    int sugar=c*k+d*l;
                    if(water/100*e>=sugar){
                        double dentmp=1.0*100*sugar/(water+sugar);
                        if(den<=dentmp){
                            den=dentmp;
                            ansum=water+sugar;
                            ansugar=sugar;
                        }
                    }
                }
            }
        }
    }
    cout<<ansum<<" "<<ansugar<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a, ans;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a;
        int count = 0;
        while (a%2==0) {
            a = a/2;
            count++;
        }
        if (i == 0) {
            ans = count;
        } else if (ans > count) {
            ans = count;
        }
    }
    cout << ans << endl;
}

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

int main() {
	long n,m,i,j,k,a,b,c,d,ans,cur,res;
	cin >> a >> b >> c >> d;
	if((c+b-1)/b >(a+d-1)/d){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
#define MN 1000
#define MX 5000
int p[MN+5],x[MN+5],f[MN+5][MX+5];
int main()
{
	int n,i,j;
	scanf("%d",&n); 
	for(i=2;i<=n;++i)scanf("%d",&p[i]);
	for(i=1;i<=n;++i)scanf("%d",&x[i]);
	for(i=n;i;--i)for(j=x[p[i]];j>=0;--j)
		f[p[i]][j]=min(x[i]<=j?f[p[i]][j-x[i]]+f[i][x[i]]:1e9,
					   f[i][x[i]]<=j?f[p[i]][j-f[i][x[i]]]+x[i]:1e9);
	puts(f[1][x[1]]<1e9?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 18432
using System;
class Program
{
  static void Main(string[] args)
  {
    var input = Console.ReadLine().Split(' ');
    int ball = int.Parse(input[0]);
    int people = int.Parse(input[1]);
    if(people == 1) Console.WriteLine("0");
    else Console.WriteLine("{0}", ball-people);
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)
const int mx=1e5+7;
vector<p>adj[mx];
vector<ll> vis(mx),dis(mx);
 queue<ll> q;
void bfs(ll s)
{

    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        for(auto i:adj[u])
        {
            if(!vis[i.ff])
            {
                q.push(i.ff);
                vis[i.ff]=1;
                dis[i.ff]=dis[u]+i.ss;
            }
        }
    }
}
//for a tree
int main()
{
    fast;
    ll n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        adj[u].pb({v,w});
        adj[v].pb({u,w});
    }
    bfs(1);
    for(int i=1;i<=n;i++)
    {
       // cout<<dis[i]<<" ";
        cout<<(dis[i]&1?1:0)<<endl;
    }
}


Measured memory_bytes: 12128
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    H, W = map(int, input().split())

    if H == 1 or W == 1:
        print(1)
    else:
        print((H * W + 1) // 2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 63980
Plist =[]
Xlist =[]
boxlist =[]
ans = 0

N = int(input())
T = input().split()
M = int(input())

for j in range(M):
    P, X = map(int, input().split())
    Plist.append(P)
    Xlist.append(X)
    
for k in range(M):
    for l in range(len(T)):
        a = int(T[l])
        boxlist.append(a)
    
    num = Plist[k] -1
    
    boxlist[num] = Xlist[k]
    
    for j in range(len(boxlist)):
        ans = ans + boxlist[j]

    print(ans)
    ans = 0
    boxlist.clear()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool prime(int x){
  bool ok=true;
  for(int i=2;i<x;i++){
    if(x==2)return ok;
    if(x%i==0){
      ok=false;
      return 0;
    }
  }
  return ok;
}
int main(){
  int x;
  cin>>x;
  while(!prime(x)){
    x++;
  }
  cout<<x<<endl;
  
  
}

Measured memory_bytes: 256
#include<iostream>
//#include<cmath>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,l,k,n,m,s,t,a,b;
    scanf("%d %d",&a,&b);
    if(a<=8 && b<=8) cout<<"Yay!"<<"\n";
   else cout<<":("<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
#define dump(x)  cerr << #x << " = " << (x) << endl

bool cheak(int x,int y,int xMax,int yMax)
{return x >= 0 && y >= 0 && xMax > x && yMax > y;}
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int INF = 2147483647;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

//???????????¢?´¢
struct Bfs
{
	set<string> memo;
	int search(string s)
	{
		queue<string> que;
		queue<int>    time;
		que.push(s);
		time.push(0);
		memo.insert(s);
		while(que.size())
		{
			string now = que.front();que.pop();
			int anstime = time.front();time.pop();
			//??????
			
			bool end = true;
			REP(i,now.size()-1)
			if(now[i] != now[i+1])
			end = false;
			if(end)return anstime; 
			//

			REP(i,now.size()-1)
			{
				string ts = now;
				char c0 = now[i];
				char c1 = now[i+1];
				char sc;
				if(c0 != c1)
				{
					if(c0 != 'b' && c1 != 'b')
						sc = 'b';
					if(c0 != 'r' && c1 != 'r')
						sc = 'r';
					if(c0 != 'g' && c1 != 'g')
						sc = 'g';
					
					ts[i] = sc;ts[i+1] = sc;
					if(!memo.count(ts))
					{
						memo.insert(ts);
						que.push(ts);
						time.push(1+anstime);
					}
				}
			}
		}
		return -1;
	}
};

int main()
{
	string str;
	while(cin >> str && str != "0")
	{
		Bfs bfs;
		int ans = bfs.search(str);
		if(ans == -1)
			cout << "NA" << endl;
		else
			cout <<  ans << endl;
	}
	return 0;
}


//????¬????????????????????????¨?????????
/*
	REP(i,mx)
	{
		REP(j,my)
		cout << n[i][j];
		cout << endl;
	}
	cout << endl;
*/

Measured memory_bytes: 2664
#include<iostream>
#include<vector>
int main(void){
	int n;
	std::cin>>n;
	std::vector<int> array(n);
	
	for(int i=0;i<n;i++){
		std::cin>>array[i];
	}
	
	int i,j,v,k;
	
	for(i=0;i<n-1;i++){
		
	std::cout<<array[i]<<' ';
	
	}
	
	std::cout<<array[i]<<'\n';
	
	for(i=1;i<n;i++){
	
		v=array[i];
		j=i-1;
		
		while(j>=0 && array[j]>v){
			array[j+1]=array[j];
			j--;
		}
		
		array[j+1]=v;
		
		for(k=0;k<n-1;k++){
			std::cout<<array[k]<<' ';
		}
		
		std::cout<<array[k]<<'\n';
		
	}
	
	return 0;
}


Measured memory_bytes: 3068
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int a,b;
	cin >> a >> b;
	string s;
	cin >> s;
	rep(i, a) {
		if (i != b - 1) {
			cout << s[i];
		}
		else {
			cout << char(s[i] + 32);
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(n) for (int i = 0; i < (n); ++i)
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(n)
    {
        cin >> s[i];
    }
    vector<vector<int>> c(n, vector<int>(26));
    rep(n)
    {
        for (int j = 0; j < 10; ++j)
        {
            c[i][s[i][j] - 'a']++;
            //cout << c[i][s[i][j] - 'a'] << " ";
        }
        //cout << endl;
    } //26
    rep(n)
    {
        s[i] = "";
        for (int j = 0; j < 26; ++j)
        {
            for (int k = 0; k < c[i][j]; ++k)
            {
                s[i] += (j + 'a');
            }
            //cout << c[i][s[i][j] - 'a'] << " ";
        }
    }
    sort(s.begin(), s.end());
    string now = s[0];
    int nmb = 0;
    long long cnt = 0;
    rep(n - 1)
    {
        if (now == s[i + 1])
        {
            cnt += (i + 1 - nmb);
        }
        else
        {
            now = s[i + 1];
            nmb = i + 1;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 22656
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

int main()
{
  int N,A,B,C,K,res=0;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << endl;
    return 0;
  }else{
    cin >> A;
    cin >> B;
    cout << (A+B) << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
S = defaultdict(lambda: 0)
N = int(input())
ma = 0
for _ in range(N):
    s = input()
    S[s] += 1
    ma = max(ma, S[s])
res = [s for (s, cnt) in S.items() if cnt == ma]
res.sort()
print(*res, sep='\n')

Measured memory_bytes: 34368
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
void swap(int& a,int& b)
{
	int temp;
	temp=a;
	a=b;
	b=temp;
}
 int main()
{
ll a,b;
cin>>a>>b;
ll ans=__gcd(a,b);
a=a*b;ans=a/ans;
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int d[101]={};
int n;
int temp;
int ans=0;
std::cin >> n;

for (int i = 0; i < n; i++) {
  std::cin >> temp;
  if(d[temp]==0){d[temp]=1;ans++;}
}

std::cout << ans << '\n';
return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
#print("H={}, W={}".format(H, W))
S = [list(input()) for _ in range(H)] # input().split()だと分割されない！！！
#print(S)

def maxCost(s0, s1):
    """
    (s0, s1)から任意の道に最短経路で移動するとして、その中での最大コストを算出する
    """
    maxCost = 0
    visited = [[10**9 for _ in range(W)] for _ in range(H)] # そのマスへの移動の最小コスト
    q = deque([(s0, s1, 0)])
    visited[s0][s1] = 0

    while q:
        u0, u1, cost = q.popleft()
        #print("({}, {}), cost={}".format(u0, u1, cost))
        if u0 < H - 1 and S[u0+1][u1] == "." and visited[u0+1][u1] > cost+1:
            #print("first")
            visited[u0+1][u1] = cost+1
            maxCost = max(maxCost, cost+1)
            q.append((u0+1, u1, cost+1))
        if u0 > 0 and S[u0-1][u1] == "." and visited[u0-1][u1] > cost+1:
            #print("second")
            visited[u0-1][u1] = cost+1
            maxCost = max(maxCost, cost+1)
            q.append((u0-1, u1, cost+1))
        if u1 < W - 1 and S[u0][u1+1] == "." and visited[u0][u1+1] > cost+1:
            #print("third")
            visited[u0][u1+1] = cost+1
            maxCost = max(maxCost, cost+1)
            q.append((u0, u1+1, cost+1))
        if u1 > 0 and S[u0][u1-1] == "." and visited[u0][u1-1] > cost+1:
            #print("fourth")
            visited[u0][u1-1] = cost+1
            maxCost = max(maxCost, cost+1)
            q.append((u0, u1-1, cost+1))

    return maxCost

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, maxCost(i, j))
print(ans)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int s;
  cin >> s;
  
  int h = s / 3600;
  s %= 3600;
  int m = s / 60;
  s %= 60;
  
  cout << h << ':' << m << ':' << s << '\n';
}


Measured memory_bytes: 3216
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)



int main() {
	int N;
	cin >> N;
	int d[60];
	rep(i, N)cin >> d[i];

	int sum = 0;
	rep(i, N) {
		for (int j = i+1; j < N; j++) {
			sum += d[i] * d[j];
		}
	}

	cout << sum<< endl;
return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
string a;
int A,s,e;
int main(void){
	A=0;
	cin>>a;
	for(int i=0;i<a.size();i++){
	if(a[i]=='A'){
		s=i;
		break;
	
	}
}	
	for(int i=0;i<a.size();i++){
	if(a[i]=='Z'){
		e=i;
	
	}	
}


	cout<<e-s+1<<endl;
return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            br.lines()
                .forEach(n -> met(n));
        }catch(Exception e){
        }
    }

    public void met(String n){
        String[] tmp = n.split(" ");
        Integer w = Integer.parseInt(tmp[0]);
        Integer a = Integer.parseInt(tmp[1]);
        Integer b = Integer.parseInt(tmp[2]);

        if(a <= b){
            if(a + w >= b)
                System.out.println(0);
            else
                System.out.println(b - (a + w));
        }
        else{
            if(b + w >= a)
                System.out.println(0);
            else
                System.out.println(a - (b + w));
        }
    }


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


Measured memory_bytes: 26836
n = int(input())
x = input()
COUNT = x.count('1')
mod1 = COUNT - 1
mod2 = COUNT + 1

# その桁に1が立っていた時の余り
mod = [[0, 0] for _ in range(n+1)]
mult = 1
if mod1 != 0:
    mod[0][0] = 1 % mod1
mod[0][1] = 1 % mod2
for i in range(1, n+1):
    if mod1 != 0:
        mod[i][0] = (mod[i-1][0] * (2 % mod1)) % mod1
    mod[i][1] = (mod[i-1][1] * (2 % mod2)) % mod2

all_mod1 = 0
all_mod2 = 0
for i in range(n):
    if x[i] == '1':
        if mod1 != 0:
            all_mod1 = (all_mod1 + mod[n-1-i][0])
        all_mod2 = (all_mod2 + mod[n-1-i][1])
if mod1 != 0:
    all_mod1 %= mod1
all_mod2 %= mod2

def popcount(idx):
    idx -= 1
    ret = 0
    if x[idx] == '1':
        if mod1 != 0:
            ret = (all_mod1 - mod[n-1-idx][0]) % mod1
        else:
            ret = -1
    else:
        ret = (all_mod2 + mod[n-1-idx][1]) % mod2
    return ret

bit_cnt_table = [0 for _ in range(n+1)]
bit_cnt_table[1] = 1
base = 0
i = 2
while i <= n:
    if i % (2 ** base) == 0:
        base += 1
    bit_cnt_table[i] = 1 + bit_cnt_table[i - 2**(base)]
    i += 1

def func(num):
    if bit_cnt_table[num] == 0:
        return 0
    return num % bit_cnt_table[num]

f = [-1 for _ in range(n+1)]
f[0] = 0
f[1] = 1
for i in range(2, n+1):
    tmp = func(i)
    f[i] = 1 + f[tmp]
# print("all_mod", all_mod1, all_mod2)
ans = []
for i in range(1, n+1):
    p = popcount(i)
    if p == -1:
        ans_i = 0
    else:
        ans_i = 1 + f[p]
    # print(i, p, ans_i)
    ans.append(str(ans_i))
print("\n".join(ans))
# print(f)
# print(bit_cnt_table)

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

int main(){
	int64_t n, k;
	cin >> n >> k;
	int64_t a[n], b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	bool puni[32]{};
	for(int i = 0; i < 32; i++){
		puni[i] = (k >> i) & 1;
	}
	int64_t ans = 0;
	for(int i = 0; i < 32; i++){
		if(puni[i]){
			bool muni[32];
			for(int j = 0; j < 32; j++){
				if(i == j) muni[j] = false;
				if(i < j) muni[j] = puni[j];
				if(j < i) muni[j] = true;
			}
			int64_t score = 0;
			for(int j = 0; j < n; j++){
				bool f = true;
				for(int k = 0; k < 32; k++){
					if(!muni[k]){
						f &= !((a[j] >> k) & 1);
					}
				}
				if(f) score += b[j];
			}
			ans = max(ans, score);
		}
	}
	{
		int64_t score = 0;
		for(int i = 0; i < n; i++){
			bool f = true;
			for(int j = 0; j < 32; j++){
				if(!puni[j]){
					f &= !((a[i] >> j) & 1);
				}
			}
			if(f) score += b[i];
		}
		ans = max(ans, score);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll h;
int main()
{
    cin >> h;
    ll tong = 0,dem = 0;
    while(h >= 1)
    {
        h = floor(h / 2);
        tong += pow(2,dem);
        dem ++;
    }
    cout << tong ;
    return 0;
}
// 1000000000000


Measured memory_bytes: 640
import numpy as np

A , B , H , M = map(int,input().split())

angle_M = M/60*2.*np.pi
angle_H = H/12*2.*np.pi+M/60*np.pi/6.

D = np.sqrt(A**2 + B**2 - 2.*A*B*np.cos(angle_M-angle_H))
print(D)

Measured memory_bytes: 27176
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define L(i,u) for (int i=head[u]; i!=0; i=edge[i].nxt)
#define abs(a) ((a)>0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
const int N = 16300, M = 8003;
int n,x[N],tx,y[N],ty;
int dir;
bool ok[16006];
int sta[N],len,tmp[N];
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}
inline bool judge(int *s, int n, int tar) {
	len=2; sta[1]=s[1]; sta[2]=-s[1];
	rep(i,2,n) {
		memset(ok,0,sizeof(ok)); int Len=0;
		rep(j,1,len) {
			if (!ok[sta[j]+s[i]+M]) {tmp[++Len]=sta[j]+s[i]; ok[sta[j]+s[i]+M]=1;}
			if (!ok[sta[j]-s[i]+M]) {tmp[++Len]=sta[j]-s[i]; ok[sta[j]-s[i]+M]=1;}
		}
		memcpy(sta,tmp,sizeof(tmp)); len=Len;
	}
	rep(i,1,len) if (sta[i]==tar) return 1;
	return 0;
}
char s[N];
int main() { //freopen("1.in","r",stdin);
	scanf("%s",s+1); n=strlen(s+1);
	int a,b; read(a); read(b);
	rep(i,1,n) {
		int j; for (j=i+1; j<=n; j++) if (s[j]!=s[i]) break;
			//[i,j-1]
			if (s[i]=='F') {
				if (i==1) a-=(j-1);
				else if (dir==0) x[++tx]=j-i;
				else y[++ty]=j-i;
			}
			else {
				if ((j-i)&1) dir^=1;
			}
			i=j-1;
		
	}
//	rep(i,1,tx) printf("%d ",x[i]); puts("");
//	rep(i,1,ty) printf("%d ",y[i]); puts("");
	if (judge(x,tx,a)&&judge(y,ty,b)) puts("Yes");
	else puts("No");
	return 0;
}

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

int read() {
    int ans=0,flag=1;
    char ch=getchar();
    while( (ch>'9' || ch<'0') && ch!='-' ) ch=getchar();
    if(ch=='-') flag=-1,ch=getchar();
    while(ch>='0' && ch<='9') ans=ans*10+ch-'0',ch=getchar();
    return ans*flag;
}
int main()
{
	int n;
	string ss;
	cin>>ss;
	long len=ss.length();
	for(int i=0;i<len;i++){
		printf("x");
	}
 	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
A=list(map(int,input().split()))
mina = min(A)
dp = [0]*(k+1)
for left in range(k+1):
  win = False
  for i, ai in enumerate(A):
    if left - ai >= 0 and dp[left-ai] == 0:
      win = True
    dp[left] = (1 if win else 0)
print("First"if dp[k] else "Second")

    


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


int main()
{
	int n;
	int room[4][3][10] = { { 0 } };
	cin >> n;
	for (int i = 0; i < n; i++){
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		room[b - 1][f - 1][r - 1] = room[b - 1][f - 1][r - 1] + v;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				cout <<" "<< room[i][j][k];
			}
			cout << endl;
		}
		if (i < 3){
			for (int l = 0; l < 20; l++){
				cout << "#";
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int trueN = n;
			int sum = 0;
			sc.close();
			while(n>=1){
				int k = n%10;
				sum=sum+k;
				n = (n - k) / 10;
			}
			if(trueN%sum==0) 
				System.out.println("Yes");
			else 
				System.out.println("No");
		}
	
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 21844
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto A = RD;
	auto B = RD;
	auto C = RD;
	auto ans = (A == B && A != C) || (A == C && A != B) || (B == C && A != B);

	writeln(ans ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

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

int main(void)
{
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    int sum=0;
    if(N<=K)
    {
        sum+=N*X;
    }
    else
    {
        sum+=K*X;
    }
    if(N>K)
    {
        sum+=(N-K)*Y;
    }
    cout << sum <<endl;
    return 0;
}


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

int a[1000];
int main() {
	int n; scanf("%d\n", &n);
	rep(i, n)scanf("%d", &a[i]);
	int Max = -1;
	rep(i, n)rep(j, n) {
		if (i == j)continue;
		string s = to_string(a[i]*a[j]);
		char back = 0;
		bool ok = true;
		for (char c : s) {
			if (back&&back + 1 != c)ok = false;
			back = c;
		}
		if (ok)Max = max(Max, stoi(s));
	}
	printf("%d\n", Max);
}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C; cin>>A>>B>>C;
    cout<<min(C,B/A)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

template<class T>
struct Combination{
	vector<T> fact,factinv;
	Combination(int n) : fact(n + 1),factinv(n + 1){
		fact[0] = 1;
		for(int i = 1;i <= n;i++) fact[i] = fact[i - 1] * T(i);
		factinv[n] = ~fact[n];
		for(int i = n;i >= 1;i--) factinv[i - 1] = factinv[i] * T(i);
	}
	T nCr(int n,int r){
		if(r < 0 || n < r) return 0;
		return fact[n] * factinv[r] * factinv[n - r];
	}
};

signed main(){
	int k;
	Combination<modint<>> comb(2000100);
	string s;
	cin >> k >> s;
	int n = s.length();
	modint<> ans = 0;
	for(int i = n;i <= n + k;i++){
		ans += comb.nCr(i - 1,n - 1) * modint<>(25).pow(i - n) * modint<>(26).pow(n + k - i);
	}
	cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  string S; cin>>S;
  string res = "Yes";
  int l = S.size();
  rep(i,l){
    if(i%2==0){
      if(S.at(i)!='R'&&S.at(i)!='U'&&S.at(i)!='D')res="No";
    }else{
      if(S.at(i)!='L'&&S.at(i)!='U'&&S.at(i)!='D')res="No";
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
def sum_digit(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num //= 10
    return sum

N = int(input())

ans = float("inf")

for A in range(1, N):
    B = N - A
    ans = min(ans, sum_digit(B) + sum_digit(A))

print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";
const int dx[9] = { 1,1,1,0,0,0,-1,-1,-1 }, dy[9] = { 1,0,-1,1,0,-1,1,0,-1 };

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int h, w, n, cnt, sum;
vector<int>v;
map<int, bool>mp;
int ans[10];
signed main() {
	scanf("%lld %lld %lld", &h, &w, &n);
	rep(i, n) {
		int a, b;
		scanf("%lld %lld", &a, &b);
		--a; --b;
		v.emplace_back(w * a + b);
	}
	sort(all(v));
	for (int i : v) {
		int y = i / w, x = i % w;
		rep(j, 9) {
			int nx = x + dx[j], ny = y + dy[j];
			if (1 <= nx && nx < w - 1 && 1 <= ny && ny < h - 1) {
				if (!mp[w * ny + nx]) {
					mp[w * ny + nx] = true;
					rep(k, 9) {
						int nnx = nx + dx[k], nny = ny + dy[k];
						if (binary_search(all(v), w * nny + nnx)) {
							cnt++;
						}
					}
					++ans[cnt];
					cnt = 0; 
				}
			}
		}
	}
	rep(i, 10) {
		sum += ans[i];
	}
	ans[0] += (h - 2) * (w - 2) - sum;
	rep(i, 10) {
		printf("%lld\n", ans[i]);
	}
}

//map


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

  for(int i=a; i<=b; i++){
    if(i%k==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG" << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  long long int sum = 0;
  for(int i = 1; i <= N; i++){
    if(i % 3 == 0) continue;
    if(i % 5 == 0) continue;
    sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3640
// atcoder 
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

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

    int count = 0;
    for (int i=0; i<N-1; i++){
        if (a[i] == a[i+1]){
            a[i+1] = 0;
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,k;
vector<int> w;

bool check(int m){
	int i = 0,count = 0;
	while(true){
		count++;
		if(count > k) return false;
		int sum = 0;
		while(sum + w[i] <= m and i != n) sum += w[i], i++;
		if(i == n) break;
	}
	return true;
}

int bainary_search(int right){
	int left = 0, mid;
	while(left < right){
		mid = (left + right) / 2;
		if(check(mid) == true) right = mid;
		else left = mid + 1;
	}
	return left;
}

int main(){
	cin >> n >> k;
	w.resize(n);
	int maxR = 0;
	for(int i = 0; i < n; i++) cin >> w[i], maxR += w[i];
	cout << bainary_search(maxR) << endl;
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
long double w,h,x,y;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>w>>h>>x>>y;
	if(w-x==x&&h-y==y){
		cout<<(w*h)/(2.00)<<' '<<1<<endl;
	}
	else{
		cout<<(w*h)/(2.00)<<' '<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256