akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 200000
#define MO 1000000007
#define INF 0x3FFFFFFF
using namespace std;
int n,X,Y;
int c[MAXN+5],w[MAXN+5];
int fact[MAXN+5],inv[MAXN+5];
int minpos[MAXN+5],minval[MAXN+5];
int cnt[MAXN+5];
bool vis[MAXN+5];
vector<int> G[MAXN+5];
int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
void Init()
{
	for(int i=0;i<=MAXN+3;i++)
		minval[i]=INF;
	fact[0]=1;
	for(int i=1;i<=MAXN;i++)
		fact[i]=1LL*fact[i-1]*i%MO;
	inv[MAXN]=PowMod(fact[MAXN],MO-2);
	for(int i=MAXN-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;
}
void DFS(int u)
{
	vis[u]=true;
	for(int i=0;i<(int)G[u].size();i++)
	{
		int v=G[u][i];
		if(vis[v]==false)
			DFS(v);
	}
}
int C(int a,int b)
{
	return 1LL*fact[a]*inv[b]%MO*inv[a-b]%MO;
}
int main()
{
	Init();
	scanf("%d %d %d",&n,&X,&Y);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&c[i],&w[i]);
		if(minval[c[i]]>w[i])
		{
			minval[c[i]]=w[i];
			minpos[c[i]]=i;
		}
	}
	for(int i=1;i<=n;i++)
		if(i!=minpos[c[i]]&&w[i]+minval[c[i]]<=X)
			G[i].push_back(minpos[c[i]]),G[minpos[c[i]]].push_back(i);
	int mn1=INF,mn2=INF;
	int mnp1,mnp2;
	//ÏÈÕÒ×îÐ¡Öµ 
	for(int i=1;i<=n;i++)
		if(w[i]<mn1)
			mn1=w[i],mnp1=i;
	//ÔÙÕÒÓë×îÐ¡ÖµÑÕÉ«²»Í¬µÄ×îÐ¡Öµ 
	for(int i=1;i<=n;i++)
		if(w[i]<mn2&&c[i]!=c[mnp1])
			mn2=w[i],mnp2=i;
	for(int i=1;i<=n;i++)
	{
		if(i==mnp1)
			continue;
		if(c[i]!=c[mnp1]&&w[i]+w[mnp1]<=Y)
			G[i].push_back(mnp1),G[mnp1].push_back(i);
		else if(mn2!=INF&&c[i]!=c[mnp2]&&w[i]+w[mnp2]<=Y)
			G[i].push_back(mnp2),G[mnp2].push_back(i);
	}
	DFS(mnp1);
	for(int i=1;i<=n;i++)
		if(vis[i]==true)
			cnt[c[i]]++;
	int tot=0,ans=1;
	for(int i=1;i<=n;i++)
		tot+=cnt[i];
	for(int i=1;i<=n;i++)
		if(cnt[i])
		{
			ans=1LL*ans*C(tot,cnt[i])%MO;
			tot-=cnt[i];
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 17272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(a==c) cout<<b<<endl;
    else if(b==c) cout<<a<<endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
    
s = a[0]
cnt = 1

for i in range(N):
    if s == 2:
        print(cnt)
        exit()
    cnt += 1
    s = a[s-1]
    
print(-1)

Measured memory_bytes: 7084
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] n = new int[3];
		Arrays.setAll(n, i -> sc.nextInt());
		System.out.println(n[2] + " " + n[0] + " " + n[1]);
		
	}
}


Measured memory_bytes: 27220
#include<stdio.h>

int main()
{
	float A,B;
	scanf("%f %f",&A,&B);
	
	for( int i=0; i<1100; i++){
		float Anuki = i * 0.08;
		float Bnuki = i * 0.1;
		if ( Anuki >= A  &&  Anuki < A+1  &&  Bnuki >= B  &&  Bnuki < B+1  ){
			printf("%d",i);
			return 0;
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
N,T = map(int,input().split())
time = list(map(int, input().strip().split()))
ans=0
for i in range(N):
    start = time[i]
    if i==(N-1):
        ans+=T
    else:
        if time[i]<=time[i+1]<=time[i]+T:
            ans+=time[i+1]-time[i]
        else:
            ans+=T
print(ans)

Measured memory_bytes: 26836
x=int(input())
for a in range(0,1000):
    for b in range(0,1000):
        a5=a**5
        b5=b**5
        if(a5-b5)==x:
            print(a,b)
            exit()
        if(a5+b5==x):
            print(a,-b) 
            exit()

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,n;
  cin>>a>>b>>n;
  if(n>=b-1){
  	cout<<(a*(b-1)/b)<<endl;
  }
  else{
  	cout<<a*n/b<<endl;
  }
}

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

using namespace std;

const long long mod = 1e9 + 7;
const long long max_a = 1e6;

long long exp(long long b, long long e) {
  long long ret = 1;
  while (e > 0) {
    if (e & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    e >>= 1;
  }
  return ret;
}

long long gcd(long long a, long long b) {
  while (a > 0 && b > 0) {
    if (a > b) a %= b;
    else b %= a;
  }
  return a + b;
}

vector<int> sp(max_a + 1);
void sieve() {
  for (int i = 1; i <= max_a; ++i) sp[i] = (i % 2 ? i : 2);
  for (int i = 3; i * i <= max_a; i += 2) {
    if (sp[i] != i) continue;
    for (int j = i * i; j <= max_a; j += i) {
      if (sp[j] == j) sp[j] = i;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  sieve();
  int n;
  cin >> n;
  vector<long long> a(n), count(1e6 + 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    long long dup = a[i];
    while (dup > 1) {
      int pf = sp[dup], cnt = 0;
      while (dup % pf == 0) {
      	dup /= pf;
        ++cnt;
      }
      count[pf] = max(count[pf], (long long)cnt);
    }
  }
  long long lcm = 1, ans = 0;
  for (int i = 2; i <= max_a; ++i) {
    if (count[i]) lcm = lcm * exp(i, count[i]) % mod;
  }
  for (int i = 0; i < n; ++i) {
  	ans += lcm * exp(a[i], mod - 2) % mod;
    if (ans >= mod) ans -= mod;
  }
  cout << ans << endl;
   
  return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    long long x;
    cin>>x;
    if(x%2==1)
    {
        cout<<0<<endl;
        return 0;
    }
    long long bas = 5;
    long long lim = 1e18;
    long long ans = 0;
    while(bas <= lim)
    {
        long long t = x/bas;
        ans += t/2;
        bas*=5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long x, y; cin >> x >> y;
  long long ans = 0;
  while (x <= y) {
    x <<= 1LL;
    ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	cout<<n*n*n<<endl;
	return 0;
}


Measured memory_bytes: 3096
card = [[],[],[]]

isBingo = False

for n in range(3):
    rawInput = input().split()
    for m in rawInput:
        card[n].append(int(m))

N = int(input())

shirushi = []

for n in range(N):
    shirushi.append(int(input()))

markedhairetu = [[False,False,False],[False,False,False],[False,False,False]]

for p in range(3):
    for q in range(3):
        for r in range(N):
            if shirushi[r] == card[p][q]:
                markedhairetu[p][q] = True

for n in range(3):
    if markedhairetu[n].count(True) == 3:
        isBingo = True

for n in range(3):
        if markedhairetu[0][n] == True and markedhairetu[1][n] == True and markedhairetu[2][n] == True:
            isBingo = True

if markedhairetu[0][0] == True and markedhairetu[1][1] == True and markedhairetu[2][2] == True:
    isBingo = True

if markedhairetu[2][0] == True and markedhairetu[1][1] == True and markedhairetu[0][2] == True:
    isBingo = True

if isBingo:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#!/usr/bin/env python3
import copy
h, w = map(int, input().split())
f = [ list(input()) for _ in range(h) ]
a = copy.deepcopy(f)
b = copy.deepcopy(f)
a[0] = '#' * w
for y in range(1, h - 1):
    for x in range(w):
        [a, b][x % 2][y][x] = '#'
b[h - 1] = '#' * w
print(*map(''.join, a), sep='\n')
print()
print(*map(''.join, b), sep='\n')


Measured memory_bytes: 12020
/*
AizuOnline A0177
Title distance betweeen cities
*/
#include <stdio.h>
#include <float.h>
#include <math.h>
#define PI (3.141592653589793)
//Global data section
double d2r=PI/180;
double a,b,c,d;
double r=6378.1;
double x1,y11,z1,x2,y2,z2;
void ki2xyz(double ido,double keido,double *x,double *y,double *z)
{
  
  *x = r*cos(d2r*keido)*cos(d2r*ido);
  *y = r*sin(d2r*keido)*cos(d2r*ido);
  *z = r*sin(d2r*ido);
}
// invert_cos (radian)

double calc_angle(double xa,double ya,double za,double xb,double yb,double zb)
{
  double c;

  c=(xa*xb+ya*yb+za*zb);
  c/=(r*r);
  return(acos(c));
}
//
main()
{
  double ang;

  while(EOF!=scanf("%lf %lf %lf %lf",&a,&b,&c,&d) && 
	((a != -1)||(b != -1)||(c != -1)||(d != -1)))
    {
      ki2xyz(a,b,&x1,&y11,&z1);
      ki2xyz(c,d,&x2,&y2,&z2);
      ang=calc_angle(x1,y11,z1,x2,y2,z2);
      printf("%.0lf\n",ang*r);
    }
return(0);
}

Measured memory_bytes: 744
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X, A;
  cin >> X >> A;
  int ans = (X < A) ? 0 : 10;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(){
    int a=0,b=0;
    int s=0,l=0;
    scanf("%d %d",&a,&b);
    s = a*b;
    l = (a+b)+(a+b);
//    printf("%d %d¥n",a*b,2*(a+b));
    printf("%d %d\n",s,l);
    return 0;
}


Measured memory_bytes: 1856
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    vector<int> y = x;
    sort(y.begin(), y.end());

    for(int i=0; i<n; ++i){
        if(x[i] < y[n/2])
            cout << y[n/2] << endl;
        else
            cout << y[n/2-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int turu = a*2;
      int kame = a*4;
      if(b%2==0){
      if(b <= kame&&b>=turu){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      }
      else{
        System.out.println("No");
      }
      
      
		
	
}
}

Measured memory_bytes: 35760
from collections import Counter
c = [Counter(), Counter()]
n = input()
a = map(int, raw_input().split())
for i in range(n):
	c[i & 1][a[i]] += 1
p = [(0, 0)]
q = [(0, 0)]
for i in c[0]:
	p.append((c[0][i], i))
for i in c[1]:
	q.append((c[1][i], i))
p.sort()
q.sort()
if p[-1][1] == q[-1][1]:
	print n - max(p[-1][0] + q[-2][0], p[-2][0] + q[-1][0])
else:
	print n - p[-1][0] - q[-1][0]


Measured memory_bytes: 21572
#include<bits/stdc++.h>
using namespace std;
 int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int N,a,A[100001];;
    cin>>N;
    for(int i=1;i<=N;i++){
    	cin>>a;
           A[a]=i;
    }
    for(int i=1;i<=N;i++){
        printf("%d ",A[i]);
    }
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int n;
    cin>>n;
    Vi a(n);
    REP(i,n) cin>>a[i];

    double inv_sum=0.0;
    REP(i,n) inv_sum += 1.0/a[i];

    cout<<fixed<<setprecision(10)<<1.0/inv_sum<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
n, m = map(int,input().split())
dic = {}

for i in range(m):
    aa, bb = map(int,input().split())

    if aa not in dic:
        dic[aa] = set()
        dic[aa].add(bb)
    else:
        dic[aa].add(bb)

    if bb not in dic:
        dic[bb] = set()
        dic[bb].add(aa)
    else:
        dic[bb].add(aa)

dist = 0
visited = set()

sirube = {}

queue = deque([1])
dist_dic = {}
dist_dic[1] = 0

while len(queue) != 0:
    v = queue.popleft()
    visited.add(v)
    
    for i in dic[v]:
        if i not in visited:
            visited.add(i)
            queue.append(i)
            dist_dic[i] = dist_dic[v] + 1
            sirube[i] = v

print("Yes")

sirube_sorted = sorted(sirube.items(), key=lambda x:x[0])

for i in range(n-1):
    print(sirube_sorted[i][1])

Measured memory_bytes: 91808
#include <stdio.h>
#include <math.h>
int main(){
    long long int S;
    scanf("%lld",&S);
    double s;
    s=sqrt((double)S);
    long long int t;
    t=(long long int)s;
    while(t*t<S){
        t=t+1;
    }
    long long int u;
    u=t*t-S;
    printf("0 0 1 %lld %lld %lld",t,t,u);
}

Measured memory_bytes: 128
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int n;
    cin >> n;
    cout << setprecision(15) << (44*n)/(double)7.0 << "\n";
}



Measured memory_bytes: 3832
#include<iostream>
typedef unsigned long long int ll;
ll m = 1000000007;
ll factorial(ll n){
  return ((n < 2) ? 1 : (n * factorial(n - 1))%m);
}
int main(){
  ll n;
  std::cin >> n;
  std::cout << factorial(n);
  return 0;
}


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

int n,m;
vector<bool>v(n);
vector<vector<int>>to(50,vector<int>(50));
void dfs(int x,int y,int z){
  if(v[x]==true) return;
  v[x]=true;
  for(int i=0; i<n; i++){
   if(x==y && i==z) continue;
   if(x==z && i==y) continue;
   if(to[x][i]==1) dfs(i,y,z); 
  }
}

int main() {  
  
  cin >> n >> m;
  
  for(int i=0; i<m; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
    to[a][b]=1;
    to[b][a]=1;
  }
  
  
  
  int count=0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      if(to[i][j]==0)continue;
      for(int k=0; k<n; k++) v[k]=false;
      bool connect=true;
      dfs(0,i,j);
      for(int k=0; k<n; k++){
       if(v[k]==false) connect=false;
      }
      
      if(connect==false) count++;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
a = np.array([i for i in list(map(int, input().split()))])
m = 10**9+7
ans = 0
for k in range(60):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)

Measured memory_bytes: 48852
// compile option: g++ -std=c++11
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s, t;
  cin >> s >> t;
  vector<int> pos[26];
  REP(i, s.size()) pos[s[i] - 'a'].push_back(i);
  int last = -1;
  ll ans = 0;
  REP(i, t.size()) {
    if (pos[t[i] - 'a'].empty()) {
      cout << -1 << endl;
      return 0;
    }
    auto it = upper_bound(ALL(pos[t[i] - 'a']), last);
    if (it == pos[t[i] - 'a'].end()) {
      ans += s.size();
      last = -1;
      it = upper_bound(ALL(pos[t[i] - 'a']), last);
    }
    last = *it;
  }
  cout << ans + last + 1 << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
void maxHeapify(int);
int H,A[500001];
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}
void maxHeapify(int i){
  int l=i*2,r=i*2+1,large,tmp;
  if(l<=H && A[l]>A[i])large=l;
  else large=i;
  if(r<=H && A[r]>A[large])large=r;
  if(large!=i){
    tmp=A[i];
    A[i]=A[large];
    A[large]=tmp;
    maxHeapify(large);
  }
}


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

using namespace std;

int main()
{
    int n , q;
    cin>>n>>q ;
    string s ;
    cin>>s ;
    int arr[n] ;
    memset(arr , 0 , sizeof(arr)) ;
    for(int i = 0 ; i < n ; ++i)
    {
        arr[i] = arr[i-1] ;
        if(s[i] == 'C' && s[i-1] == 'A')
            arr[i]++ ;
    }
    while(q--)
    {
        int l , r ;
        cin>>l>>r ;
        r-- , l-- ;
        cout<<(arr[r] * 1ll - arr[l] * 1ll)<<"\n";
    }
    return 0 ;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);

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

    std::sort(a.begin(), a.end());

    for(int i = 0; i < n - 1; i++) {
        if(a[i] == a[i +1] ) {
            cout << "NO" << endl;
            return 0;
        };
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ll k;
  cin >> k;
  ll ans = 0;
  rep(i, k) rep(j, k) rep(l, k) ans += gcd(i+1, gcd(j+1, l+1));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const ll MOD = 939561957918767; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
int n, c[N];
ll d[N];
V<int> e[N];
stack<int> t[N];
int dfs(int a, int p){
  int r = 1, cc = c[a];
  for(int b:e[a])if(p != b){
    t[cc].push(0);
    int rr = dfs(b, a);
    ll o = rr-t[cc].top();
    d[cc] += o*(o+1)/2;
    t[cc].pop();
    r += rr;
  }
  t[cc].top() += r;
  return r;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  scanf("%d", &n);
  FOR(i, 0, n){
    t[i].push(0);
    scanf("%d", &c[i]);
    c[i]--;
  }
  FOR(i, 1, n){
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    e[a].pb(b);
    e[b].pb(a);
  }
  dfs(0, -1);
  ll k = ll(n)*(n+1)/2;
  FOR(i, 0, n){
    ll o = n - t[i].top();
    printf("%lld\n", k - d[i] - o*(o+1)/2);
  }
}

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

int sumint(int i){
  int n=0;
  while(i>0){
    n+=i%10;
    i/=10;
  }
  return n; 
}

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int res=0;
  int sum=0;
  for (int i=1;i<=N;++i){
    sum=0;
    sum=sumint(i);
    if (A<=sum&&sum<=B) res+=i;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type Pod struct {
	Pos int
	Area int
}

func main() {
	var str string
	fmt.Scan(&str)

	downs := []int{}
	pods := []Pod{}
	sum := 0
	
	rs := []rune(str)
	for i := 0; i < len(rs); i++ {
		s := string(rs[i])
		switch s {
		case "\\":
			downs = append(downs, i)
		case "/":
			if len(downs) <= 0 {
				continue
			}
			down := downs[len(downs)-1]
			downs = downs[0:len(downs)-1]
			
			area := i - down
			sum += area

			for j := len(pods) - 1; j >= 0; j-- {
				pod := pods[j]
				if down < pod.Pos {
					area += pod.Area
					pods = pods[0:j]
				} else {
					break
				}
			}
			pods = append(pods, Pod{down, area})
		}
	}

	fmt.Println(sum)
	fmt.Print(len(pods))
	if len(pods) > 0 {
		for i := 0; i < len(pods); i++ {
			fmt.Print(" ")
			fmt.Print(pods[i].Area)
		}
	}
	fmt.Println()
}




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

int main(){
  int n, m;
  double g[100][100];
  double dp[100][100]; //dp[i][j]:i番目までで前に肥料jを与えたときの最大の苗木長

  while(scanf("%d %d", &n, &m), n){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        scanf("%lf", &g[i][j]);
      }
    }

    fill_n( *dp, 100 * 100, 0.0);

    for(int i = 0; i < n; i++){
      dp[0][i] = 1.0;
    }

    for(int i = 1; i < m; i++){
      for(int j = 0; j < n; j++){
        for(int k = 0; k < n; k++){
          dp[i][k] = max( dp[i][k], dp[i - 1][j] * g[j][k]);
        }
      }
    }
    cout << fixed << setprecision(2) << *max_element( dp[m - 1], dp[m] + n) << endl;
  }
  return 0;
}

Measured memory_bytes: 1452
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 205
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int H,W;
char s[MAXN][MAXN];
int cnt[27],fa[MAXN * 2];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int getfa(int x) {
    return x == fa[x] ? x : fa[x] = getfa(fa[x]);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void Solve() {
    read(H);read(W);
    for(int i = 1 ; i <= H ; ++i) {
	scanf("%s",s[i] + 1);
    }
    for(int i = 1 ; i <= H + W ; ++i) fa[i] = i;
    int ans = 1;
    if(H & 1) {
	bool f = 1;
	for(int j = 1 ; j <= W / 2 ; ++j) {
	    if(s[H / 2 + 1][j] != s[H / 2 + 1][W - j + 1]) {f = 0;break;}
	}
	if(!f) ans = mul(ans,2);
    }
    if(W & 1) {
	bool f = 1;
	for(int i = 1 ; i <= H / 2 ; ++i) {
	    if(s[i][W / 2 + 1] != s[H - i + 1][W / 2 + 1]) {f = 0;break;}
	}
	if(!f) ans = mul(ans,2);
    }
    int c = 0;
    for(int i = 1 ; i <= H / 2 ; ++i) {
	for(int j = 1 ; j <= W / 2 ; ++j) {
	    memset(cnt,0,sizeof(cnt));
	    cnt[s[i][j] - 'a']++;
	    cnt[s[H - i + 1][j] - 'a']++;
	    cnt[s[i][W - j + 1] - 'a']++;
	    cnt[s[H - i + 1][W - j + 1] - 'a']++;
	    bool f = 0;
	    int tmp = 24;
	    for(int k = 0 ; k < 26 ; ++k) {
		if(cnt[k] >= 2) {
		    f = 1;
		    if(cnt[k] == 2) tmp /= 2;
		    if(cnt[k] == 3) tmp /= 6;
		    if(cnt[k] == 4) tmp /= 24;
		}
	    }
	    if(!f) ans = mul(ans,tmp / 2);
	    else ans = mul(ans,tmp);
	    if(!f) {
		if(getfa(i) != getfa(j + H / 2)) {
		    ++c;
		    fa[getfa(i)] = getfa(j + H / 2);
		}
		
	    }
	}
    }
    ans = mul(ans,fpow(2,c));
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//動画解答写し
int main() {
  int MOD = 1000000007;
  int n;
  cin >>n;
  vector<long long>a(n);
  rep(i,n)cin>>a[i];
  long long kotae=0;
  rep(i,60){
    long long x=0;
    rep(j,n){
      if(a[j]>>i&1)++x;
    }
    long long tmp=x*(n-x)%MOD;
    rep(j,i)tmp=tmp*2%MOD;
    kotae+=tmp;
    kotae%=MOD;
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 2560
n = int(input())
h = list(map(int, input().split()))
# sv = h[n-1]
ok = True
for i in range(n-1)[::-1]:
    # if h[i] - sv + 1 >= 2:
        # ok = False
    if h[i] <= h[i+1]:
        continue
    elif h[i] == h[i+1] + 1:
        h[i] -= 1
    else:
        ok = False
    # if h[i] - h[i-1] < 0:
        # ok = False
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

ll dp[100009][2];

int main(void){
    string l;
    cin >> l;

    ll len = l.size();

    //確定(0, 0)
    dp[0][1] = 1;
    //未確定(1, 0), (0, 1)
    dp[0][0] = 2;

    rep(i, 1, len){
        //確定　→　確定
        dp[i][1] += dp[i - 1][1];
        dp[i][1] %= MOD;
        dp[i][1] += dp[i - 1][1] * 2 % MOD;
        dp[i][1] %= MOD;

        //未確定　→　未確定
        if(l[i] == '0'){
            dp[i][0] += dp[i - 1][0];
            dp[i][0] %= MOD;
        }else{
            dp[i][0] += dp[i - 1][0] * 2 % MOD;
            dp[i][0] %= MOD;
        }

        //未確定　→　確定
        if(l[i] != '0'){
            dp[i][1] += dp[i - 1][0];
            dp[i][1] %= MOD;
        }
    }

    cout << ( dp[len - 1][1] + dp[len - 1][0] ) % MOD << endl;
}


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

using namespace std;

int main()
{
    int n,a,b,sum;
    while(cin>>n)
    {
        sum=0;
        for(int i=0;i<n;++i)
        {
            cin>>a>>b;
            sum+=(b-a)+1;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
double w[15],d[15],num[15];
int n;

double wei(int bit){
	double ret = 0;
	for(int i = 0 ; i < n ; i++){
		if( bit & (1<<i) )ret += w[i];
	}
	return 20*ret;
}

int main(){
	cin >> n;
	
	vector< vector<double> > dp(1<<15,vector<double>(15,(1<<25))); 
	vector< vector<int> > prevPos(1<<15,vector<int>(15,0)); 
	vector< vector<int> > prevBit(1<<15,vector<int>(15,0));
	
	rep(i,n){
		cin >> num[i] >> d[i] >> w[i];
	}
	
	rep(i,n) dp[(1<<i)][i] = 0.0;
	for(int bit = 1; bit < (1<<n) ; bit++){ // visit info
		for(int i = 0; i < n ; i++){		// prev
			//if( bit & i == 0)continue;
			for(int j = 0; j < n ; j++){	// now
				if(bit & (1<<j) )continue;
				int nBit = bit | (1<<j);
				double newDist = dp[bit][i] + fabs(d[i]-d[j]) / ( (2000.0 / (70+wei(bit)) ) );
				
				if(dp[nBit][j] > newDist){
					prevPos[nBit][j] = i;
					prevBit[nBit][j] = bit;
					dp[nBit][j] = newDist;
				}
			}
		}
	}
	double ret = (1<<25);
	vector<int> route;
	int outBit = (1<<n)-1 ,outPos = -1;
	
	rep(i,n)if(ret > dp[outBit][i]){
		outPos = i;
		ret = dp[outBit][i];
	}
	
	route.push_back(outPos);
	
	while(prevBit[outBit][outPos]){
		//cout << dp[outBit][outPos] << endl;
		int a = prevPos[outBit][outPos] , 
			b = prevBit[outBit][outPos] ;
		outPos = a, outBit = b;
		route.push_back(outPos);
	}
	reverse(route.begin(),route.end());
	rep(i,route.size()){
		if(i)cout << " ";
		cout << num[route[i]];
	}
	cout << endl;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(int i=a;i<(int)b;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int x;
    cin>>x;
    int a=max(n,m);
    cout<<(a+x-1)/a<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sd second
#define ft first

int32_t main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    int sum = 0;
    for (auto x : mp)
    {
        sum += ((x.sd) * (x.sd - 1)) / 2;
    }
    for (auto x : a)
    {
        int m = mp[x];
        cout << sum - (m - 1) << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  long N, count;
  vector<long> V;
  cin>>N;
  while(N--)
  {
    cin>>count;
    V.push_back(count);
  }
  count = 0;
  for(long i=0;i<V.size();i+=2)
  {
     if(V[i]&1) count++;
  }
  cout << count;
  
  return 0;
}


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

int main(){
    
    for(ll n; cin >> n, n;){
        map<string, ll>idx;
        map<ll, vector<ll> >g;
        rep(i, n){
            ll head = 0;
            string s, tmp = "";
            cin >> s;
            rep(j, s.size()){
                if(s[j] == ':' || s[j] == ',' || s[j] == '.'){
                    if(idx[tmp] == 0)idx[tmp] = idx.size();
                    if(head == 0)head = idx[tmp];
                    else g[head].push_back(idx[tmp]);
                    tmp = "";
                }
                else tmp += s[j];
            }
        }
        map<ll, ll>flg;
        queue<ll>Q;
        Q.push(1);
        flg[1] = 1;
        ll ans = 0;
        while(!Q.empty()){
            ll q = Q.front();
            Q.pop();
            if(g[q].size()){
                rep(i, g[q].size())if(flg[g[q][i]] == 0){
                    Q.push(g[q][i]);
                    flg[g[q][i]] = 1;
                }
            }
            else ans++;
        }
        cout << ans << endl;
    }
    
    return 0;
}


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

int main() {
  int a,b; cin>>a>>b;
  if (a+b<10) cout<<a+b<<endl;
  else cout<<"error"<<endl;
}


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

using namespace std;

int main(void){

    int n, line;
    int count = 0;

    cin >> n >> line;

    int tall;

    for(int i = 0;i < n;i++){
        cin >> tall;
        if(tall >= line) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    s.insert(s.begin() + 4, ' ');
    Cout(s);
}





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

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    int ans = (a + b) * h / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a,b = map(int, input().split())
p = list(map(int, input().split()))

ans = [0,0,0]
for i in range(n):
    if p[i]<=a:
        ans[0]+=1
    elif p[i]<=b:
        ans[1]+=1
    else:
        ans[2]+=1
print(min(ans))

Measured memory_bytes: 38256
using System;
using System.Linq;

class Program {
  static void Main() {
    var a = Console.ReadLine().Split().ToArray();
    var n = int.Parse(a[0]);
    var t = double.Parse(a[1]);
    var mt = 0.0;
    for (int i = 0; i < n; i++) {
      var b = Console.ReadLine().Split().Select(double.Parse).ToArray();
      mt = Math.Max(b[1] / b[0], mt);
    }
    Console.WriteLine(mt * t);
  }
}


Measured memory_bytes: 18440
n = gets.strip.to_i

n.times.each do
  h, m = gets.strip.split(':').map{|s| s.to_i}

  dd = (30.0 * h + 0.5 * m - 6 * m).abs
  dd = 360 - dd if dd > 180

  if dd < 30
    puts "alert"
  elsif dd >= 90
    puts "safe"
  else
    puts "warning"
  end
end




Measured memory_bytes: 6884
N = int(input())
A = input().split()
px = py = pz = 0
for a in A:
  if a == '1':
    px += 1
  elif a == '2':
    py += 1
  elif a == '3':
    pz += 1

nx = px + py + pz
ny = py + pz
nz = pz

dp = [[[0]*(nx+1) for y in range(ny+1)] for z in range(nz+1)]

for z in range(nz+1):
  for y in range(ny+1-z):
    for x in range(nx+1-z-y):
      if x == y == z == 0:
        continue
      
      else:
        s = x + y + z
        t = N/s
        if x > 0:
          t += dp[z][y][x-1]*x/s
        if y > 0:
          t += dp[z][y-1][x+1]*y/s
        if z > 0:
          t += dp[z-1][y+1][x]*z/s
        
        dp[z][y][x] += t


print(dp[pz][py][px])

Measured memory_bytes: 493064
import sys

def gcd(a,b):
	a,b=max(a,b),min(a,b)
	while a%b:
		a,b=b,a%b
	return b
	
def lcm(a,b):
	return a//gcd(a,b)*b

s=input()
print(s[::-1])
#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Measured memory_bytes: 7408
#include <bits/stdc++.h>
#define mod 1000000007
using ll = long long;
using namespace std; 
const double pi = acos(-1);

int main(){
    char a; cin >> a;
    if (isupper(a)){
        cout << "A" << "\n";
    }
    else cout << "a" << "\n";
}



Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d;
  d = a * 100 + b * 10 + c;
  if ( d % 4 == 0 ) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}

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

const int maxn = 1e6;
int n;
char s[maxn + 5], t[maxn + 5];

int main() {
	scanf("%d %s %s", &n, s + 1, t + 1);
	bool fl = true;
	for (int i = 1; i <= n; i++) fl &= s[i] == t[i];
	if (fl) puts("0"), exit(0);
	queue<int> Q;
	int ans = 0;
	for (int i = n, j = n; i; i--, j--) {
		while (t[i] == t[i - 1]) i--;
		while (j && (j > i || s[j] != t[i])) j--;
		if (!j) puts("-1"), exit(0);
		while (!Q.empty() && i <= Q.front() - Q.size()) Q.pop();
		if (i != j) Q.push(j);
		ans = max(ans, (int)Q.size() + 1);
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main()
{
   int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  long int ans1=a*b;
  long int ans2=c*d;
  
  if(ans1>=ans2)
       printf("%ld",ans1);
  
  else
     printf("%ld",ans2);
}

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

int main()
{
    string S;
    cin >> S;
    vector<ll> ans(S.size(), 0);
    char prev = '-';
    ll odd = 0, even = 0, RL = -1;
    for (ll i = 0; i < S.size(); i++)
    {
        if (prev == 'R' && S[i] == 'L')
            RL = i;
        else if (prev == 'L' && S[i] == 'R')
        {
            if (RL % 2 == 0)
            {
                ans[RL] = even;
                ans[RL - 1] = odd;
            }
            else
            {
                ans[RL] = odd;
                ans[RL - 1] = even;
            }
            odd = even = 0;
        }
        (i % 2 == 0) ? even++ : odd++;
        prev = S[i];
    }
    if (RL % 2 == 0)
    {
        ans[RL] = even;
        ans[RL - 1] = odd;
    }
    else
    {
        ans[RL] = odd;
        ans[RL - 1] = even;
    }
    cout << ans[0];
    rep(i, S.size() - 1) cout << " " << ans[i + 1];
    cout << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
	char c;ll x;while(c=getchar(),c<'0'||c>'9');x=c-'0';
	while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0';return x;
}
ll n,res,flag,a[55],b[55],f[55][55],d[55][55];
ll pows(ll a,ll b){
	ll base=1;
	while(b){
		if(b&1) base*=a;
		a*=a;b/=2;
	}
	return base;
}
ll check(ll x){
	for(ll i=0;i<=50;i++)
	 for(ll j=0;j<=50;j++) d[i][j]=f[i][j];
	for(ll i=1;i<=x;i++)
	 for(ll j=0;j<=50;j++) d[j][j%i]=1;
	for(ll k=0;k<=50;k++) 
	 for(ll i=0;i<=50;i++)
	  for(ll j=0;j<=50;j++)
	   if(d[i][k]&&d[k][j]) d[i][j]=1;
	for(ll i=1;i<=n;i++) if(!d[a[i]][b[i]]) return 0;
	return 1;
}
void go(ll x){
	res+=pows(2,x);
	for(ll i=0;i<=50;i++) f[i][i%x]=1;
	for(ll i=x;i>=1;i--){
		if(check(i-1)) continue;
		if(i!=x) go(i);break;
	}
}
int main()
{
	n=read();
	for(ll i=1;i<=n;i++) a[i]=read();
	for(ll i=1;i<=n;i++) b[i]=read();
	for(ll i=0;i<=50;i++)
	 for(ll j=0;j<=i;j++) if(i==j) f[i][j]=1;else f[i][j]=0;
	for(ll i=51;i>=1;i--){
		if(check(i-1)) continue;
		if(i==51) flag=1;else go(i);break;
		//if(i!=51) go(i);
	}
	if(!flag) printf("%lld",res);
	else puts("-1");
	return 0;
}

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

constexpr double EPS = 1e-6;
constexpr int M = 256;

int S, A, C;

int R() {
    return S = (A * S + C) % M;
}

int main() {
    int N;
    while(cin >> N, N) {
        double H = 1e9;
        int ret_s=1e9, ret_a=1e9, ret_c=1e9;

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

        for(int s=0; s<16; ++s) {
            for(int a=0; a<16; ++a) {
                for(int c=0; c<16; ++c) {
                    S = s, A = a, C = c;
                    double h = 0;
                    map<int, int> m;
                    for(int n=0; n<N; ++n) {
                        int o = (v[n] + R()) % M;
                        m[o] += 1;
                    }

                    for(auto x : m) {
                        h -= static_cast<double>(x.second) / N * log(static_cast<double>(x.second)/N);
                    }
                    if(h + EPS < H) {
                        H = h;
                        ret_s = s;
                        ret_a = a;
                        ret_c = c;
                    }
                }
            }
        }
        cout << ret_s << " " << ret_a << " " << ret_c << endl;
    }
}


Measured memory_bytes: 3244
#include<stdio.h>
int main()
{
    int a,b,c,i,n;
    scanf("%d%d%d",&a,&b,&c);
    i=a+b+c;
    if(i>=22)
    {
        printf("bust");
    }
    else
    {printf("win");}

    return 0;
}


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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 5){
        a = 0;
    }
    else if(b == 5){
        b = 0;
    }
    else if(c == 5){
        c = 0;
    }
    else{
        cout << "NO\n";
        return 0;
    }
    if(a == 7){
        a = 0;
    }
    else if(b == 7){
        b = 0;
    }
    else if(c == 7){
        c = 0;
    }
    else{
        cout << "NO\n";
        return 0;
    }
    if(a == 5){
        a = 0;
    }
    else if(b == 5){
        b = 0;
    }
    else if(c == 5){
        c = 0;
    }
    else{
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
vector<ll> X;

int main(void) {
    cin >> N;

    ll sum = 0;
    rep(i, N) {
        ll x;
        cin >> x;
        X.push_back(x);
        sum += x;
    }

    ll med = (ll)(round(sum / (double)N));

    ll ans = 0;
    rep(i, N) {
        ans += abs(X[i] - med) * abs(X[i] - med);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
function main()
  
  (N,Q) = map(x -> parse(Int,x), split(readline()))
  check = zeros(Int,N)
  save = 1
  
  S = chomp(readline())

  for i in 2:N
    if S[i-1] == 'A' && S[i] == 'C'
      if save == 1
        check[i] += 1
        save = i
      else
        check[i] += check[save] + 1
        save = i
      end
    else
      check[i] = check[save]
    end
  end
  
  for i in 1:Q
    (l,r) = map(x -> parse(Int,x), split(readline()))
    println(check[r]-check[l])
  end
  
end

main()

Measured memory_bytes: 157096
N = int(input())
a14=set([])
a23=set([])
for _ in range(N):
	x,y=map(int, input().split())
	a14.add(x+y)
	a23.add(x-y)


b14=max(a14)-min(a14)
b23=max(a23)-min(a23)

print(max(b14,b23))



# 2darray [[0] * 4 for i in range(3)]
# import itertools

Measured memory_bytes: 39604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0,x;
	cin>>n;
	int shu[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>shu[i];
		s+=shu[i];
	}
	x=s/n;
	int a=0,b=0,c=0;
	for(int i=1;i<=n;i++)
	{
		a+=(shu[i]-x+1)*(shu[i]-x+1);
		b+=(shu[i]-x)*(shu[i]-x);
		c+=(shu[i]-x-1)*(shu[i]-x-1);
	}
	cout<<min(min(a,b),c);
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)
ok = 10**12
ng = -1

while ok-ng>1:
  X = (ok+ng)//2
  tmp = 0
  for i in range(N):
    tmp += max(A[i]-X//F[i],0)
  if tmp<=K:
    ok = X
  else:
    ng = X
print(ok)

    
  

Measured memory_bytes: 119500
// A - Sorted Arrays
#include <bits/stdc++.h>
using namespace std;

int solve();
vector<int> a;
int N;

int main(){
  cin >> N;
  a = vector<int>(N);

  for(int i=0; i<N; i++){
    cin >>a.at(i);
  }

  int count = 0;
  int state;
  //true 現象
  //false 増加

  if(N == 1){
    count =1;
  }


  for(int i = 0; i<N-1; i++){
    if(i == 0){
      // cout << a[i];
      count ++;
      if(a[i] <a[i+1]){
        state = 0;
      }else if(a[i] > a[i+1]){
        state = 1;
      }else{
        state = 2;
      }
    }else{
      if(a[i] <a[i+1]){
        // cout << a[i];
        if(state == 1){
          count++;
          state = 3;
          // cout << endl;
        }else{
          state = 0;
        }


      }else if(a[i] > a[i+1]){
        // cout << a[i];
        if(state == 0){
          count++;
          state = 3;
          // cout << endl;
        }else{
          state = 1;
        }
      }else{
        // cout << a[i];

      }

    }

  }

  cout << count <<endl;

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	static long a;
	static long b;
	static long x;
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long l = scan.nextLong();
		long r = scan.nextLong();

		if(r - l > 2020) {
			r = l + 2020;
		}

		long ans = Long.MAX_VALUE;
		for(long i = l; i <= r - 1; i++) {
			for(long j = i + 1; j <= r; j++) {
				if(ans > ((i % 2019) * j) % 2019) {
					ans = ((i % 2019) * j) % 2019;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        ans += t - 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
cnt=0
s=[]
kkk=[]
lll=[]
mmm=[]
nnn=[]
while cnt<m:
    num=list(map(int,input().split()))
    s+=num
    cnt+=1
for x in range(m*2):
    if s[x]==n:
        if x%2==0:
            kkk+=[x+1]
        else:
            kkk+=[x-1]
for x in range(len(kkk)):
        lll+=[s[kkk[x]]]
for x in range(m*2):
    if s[x]==1:
        if x%2==0:
            mmm+=[x+1]
        else:
            mmm+=[x-1]
for x in range(len(mmm)):
        nnn+=[s[mmm[x]]]
if len(list(set(lll)&set(nnn)))>0:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
print(ans)

Measured memory_bytes: 36084