akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
if(x<1200)std::cout << "ABC" << '\n';
else if(x<2800) std::cout << "ARC" << '\n';
else std::cout << "AGC" << '\n';
}



Measured memory_bytes: 256
N, M = map(int, input().split())
stu = []
check = []
for i in range(N):
    s = list(map(int, input().split()))
    stu.append(s)
for i in range(M):
    c = list(map(int, input().split()))
    check.append(c)
ans = [0 for i in range(N)]
for i in range(N):
    min = 10**20
    for j in range(M):
        dis = abs(stu[i][0]-check[j][0])+abs(stu[i][1]-check[j][1])
        if min > dis:
            min = dis
            ans[i] = j+1
for i in ans:
    print(i)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] map = new char[H][W];
    for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();
    int[][] dd = new int[][]{{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (map[i][j] == '#') continue;
        int cnt = 0;
        for (int[] d : dd) {
          int x = i + d[0];
          int y = j + d[1];
          if (x >= 0 && x < H && y >= 0 && y< W && map[x][y] == '#') cnt++;
        }
        map[i][j] = (char)('0' + cnt);
      }
    }
    for (int i = 0; i < H; i++) System.out.println(new String(map[i]));
  }
}


Measured memory_bytes: 23124
a,b,c=map(int,input().split())
if a==b==c:print(-(a%2==0));exit()
r=0
while(a-1)*(b-1)*(c-1)%2:a,b,c,r=(b+c)//2,(c+a)//2,(a+b)//2,r+1
print(r)

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N;
   cin>>N;
   if(N%2)cout<<2*N;
   else cout<<N;
   return 0;
}


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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=1LL<<60;


int main(){
    ll n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--;b--;c--;d--;
    for(ll i=a;i<max(c,d);i++){
        if(s[i]=='#' && s[i+1]=='#'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(c<d)cout<<"Yes"<<endl;
    else {
        for(ll i=b-1;i<d;i++){
            if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
    }
    
    

    
}
 
   

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

int P[100001];
int main() {
  int N,K,Q;
  

  cin >> N >> K >> Q;
  
  for(int i=0; i < Q; i++) {
    int a;
    cin >> a;
    P[a]++;
  }

  for(int i=1; i <= N; i++) {
    //P[i] -= K;
    if(Q - P[i] < K)
      cout << "Yes" << endl;
    else 
      cout << "No" << endl;
  }

  return 0;
}


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

int main(){
	long long int a, b;
  	string c, d;
  	cin >>c >> d;
  	
  	if(c[0] - '0' > d[0] - '0'  && c.size() == d.size()){
      cout << "GREATER" << endl;
      return 0;
    }
  	
  	if(c.size() > d.size()){
      cout << "GREATER" << endl;
      return 0;
    }
  	else if(c.size() < d.size()){
      cout << "LESS" << endl;
      return 0;
    }
   	else {
      for(int i = 0; i < c.size(); i++){
        if(c[i] > d[i]){
          cout << "GREATER" << endl;
          return 0;
        }
        else if(c[i] < d[i]){
          cout << "LESS" << endl;
          return 0;
        }
        else{
          if(i == c.size()-1){
            cout << "EQUAL" << endl;
            return 0;
          }
        }
      }
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

fact = [1 for _ in range(N + 10)]
invFact = [0 for _ in range(N + 10)]

def modInv(a):
    b = MOD
    u = 1
    v = 0
    while b :
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= MOD
    return u

for i in range(1, N + 10):
    fact[i] = (fact[i - 1] * i) % MOD
    invFact[i] = modInv(fact[i])

index = [[] for _ in range(N + 1)]

for i, a in enumerate(A):
    index[a].append(i)

left = 0
right = 0
for count in index:
    if len(count) == 2:
        left = min(count)
        right = max(count)

def comb(n, r):
    if 0 < r < n:
        return (fact[n] * invFact[r] % MOD) * invFact[n - r] % MOD
    if r == 0 or r == n:
        return 1
    return 0

les = left + (N - right)

for k in range(1, N + 2):
    r = comb(les, k - 1)
    ans = comb(N + 1, k) - r
    print(ans % MOD)


Measured memory_bytes: 30996
import * as fs from "fs";

let N = Number(fs.readFileSync("/dev/stdin", "utf8").trim());
let shichiGoSan = ["7", "5", "3"];

function count(s: string): number {
    if (Number(s) > N)
        return 0;
    let allPresent: boolean = true;
    let answer = 0;
    for(let sh of shichiGoSan) {
        allPresent = allPresent && s.indexOf(sh) != -1;
        answer += count(s+sh);
    }
    answer += allPresent?1: 0;
    return answer;
}

console.log(count("0"));


Measured memory_bytes: 34744
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+100;
typedef long long ll;
ll ans[maxn];

int main(){
     int k; cin >> k;
     for(int i = 1; i <= 9; i++) ans[i] = i;
     int l = 1, r = 9;
     int tot = 10;
     while(tot <= k){
          for(ll i = l; i <= r; i++){
               int digit = ans[i]%10;
               for(int j = -1; j <= 1; j++){
                    int last = digit + j;
                    if(last >= 0 && last <= 9)
                         ans[tot++] = ans[i]*10+last;
               }
          }
          l = r+1;
          r = tot-1;
     }
     cout << ans[k] << endl;
     return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for(int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int F[MAX];
LL Rank[MAX];
LL tot;
int get_p(int x){
    if(F[x] == x)
        return x;
    return F[x] = get_p(F[x]);
}
void add(int x, int y){
    int px = get_p(x);
    int py = get_p(y);
    if(px == py) return ;
    tot -= Rank[px] * Rank[py];
    if(Rank[px] < Rank[py]){
        F[px] = py;
        Rank[py] += Rank[px];
    }
    else{
        F[py] = px;
        Rank[px] += Rank[py];
    }
}
int main()
{
    LL n, m;
    cin >> n >> m;
    vector<P> E(m);
    rep(i, 0, m)
        cin >> E[i].first >> E[i].second;
    tot = (n-1) * n >> 1;
    rep(i, 1, n+1){
        F[i] = i;
        Rank[i] = 1;
    }
    vector<LL> ans(m);
    ans[m-1] = tot ;
    for(int i = m-2; i >= 0; i--){
        int x = E[i+1].first;
        int y = E[i+1].second;
        add(x, y);
        ans[i] = tot;
    }
    for(int i = 0; i < m; i++)
        cout << ans[i] << endl;
    return 0;
}

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

int main(){
    int d;
    cin>>d;
    int c[26];
    for(int i=0;i<26;i++)cin>>c[i];
    int s[d][26];
    for(int i=0;i<d;i++)for(int j=0;j<26;j++){
        cin>>s[i][j];
    }
    int t[d];
    for(int i=0;i<d;i++)cin>>t[i];
    int score=0;
    int last[26]={};
    for(int i=1;i<=d;i++){
        last[t[i-1]-1]=i;
        score+=s[i-1][t[i-1]-1];
        for(int j=0;j<26;j++){
            score-=(i-last[j])*c[j];
        }
        cout<<score<<endl;
    }
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void) {
    int A, B;
    int n = 0;
    int a = 0;
    
    scanf("%d %d", &A, &B);
    a = A;
    
    while(1){
        if(B == 1){
            break;
        }
        if(a < B){
            a = (a - 1) + A;
            n++;
        }
        else{
            n++;
            break;
        }
    }
    
    printf("%d\n", n);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
        ll n,k,pi,i,j,loc,tot,now,ans=-1e10;
        cin >> n >> k;
        vector<ll> p(n);
        vector<ll> c(n);
        for(i=0;i<n;++i){
                cin >> pi; --pi;
                p.at(i) = pi;
        }
        for(i=0;i<n;++i) cin >> c.at(i);
        for(i=0;i<n;++i){
                loc = i;
                tot = 0;
                vector<ll> s;
                while(1){
                        loc = p.at(loc);
                        tot += c.at(loc);
                        s.push_back(c.at(loc));
                        if(loc==i) break;
                }
                now = 0;
                for(j=0;j<s.size();++j){
                        now += s.at(j);
                        if(tot>0) ans = max(ans, now+tot*((k-j-1)/(ll)s.size()));
                        else ans = max(ans, now);
                        if(j+1==k) break;
                }
        }
        cout << ans << endl;
        return 0;
}

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

int main()
{
    int N, result = 0, index = 1;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for(int j=0;j<N;j++){
        if(a[j]==index){
            index++;
        }else{
            result += 1;
        }
    }

    if(result == N){
        result = -1;
    }

    cout << result << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
  int tmp;
  vector<int> heights;

  for(int i=0; i<10; i++) {
    cin>>tmp;
    heights.push_back(tmp);
  }
  sort(heights.begin(), heights.end(), greater<int>());
  cout<<heights[0]<<endl<<heights[1]<<endl<<heights[2]<<endl;
}

Measured memory_bytes: 1216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
   int n; cin >> n;
   int cnt = -1, num = -1;
   fo(i, 1, n+1){
       int m = i, cnt2 = 0;
       while(m%2==0){
           m /= 2;
           cnt2++;
       }
       if(cnt2 > cnt){
           cnt = cnt2;
           num = i;
       }
   }
    cout << num << ln;
}








Measured memory_bytes: 256
import math
import sys
MOD = 1000000007

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

if n == 1:
    print(m)
    sys.exit()

ans = 1
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        j = m / i
        if i <= m/n:
            ans = max(ans, i)
        if j <= m/n:
            ans = max(ans, j)

print(int(ans))


Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


int main()
{
	vector<int> a(5);
	rep(i, 5)
		cin >> a[i];

	int ans = 0;

	rep(i, 5) {
		if (a[i] != i + 1) {
			ans = i + 1;
			break;
		}
	}
	

	cout << ans;

	

}




Measured memory_bytes: 3616
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;

#define MAXN 1000005
#define INF 999999999

signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n, m, a;
	scanf("%d%d%d", &n, &m, &a);
	for (int i = 0; i < 10; i++) {
		a = n * a - m;
		printf("%d\n", a);
	}
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().strip().split())

ab = []
for _ in range(M):
  ab.append(tuple(map(int, input().strip().split())))

from1 = set()
is_reach = False
for a, b in sorted(ab, key=lambda x: x[0]):
  if a == 1:
    from1.add(b)
  else:
    if a in from1 and b == N:
      is_reach = True
      break
if is_reach:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 35176
#include<stdio.h>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 100005
using namespace std;
int A,B,C;
int main(){
	scanf("%d%d%d",&A,&B,&C);
	if(C-1<=A+B){
		printf("%d",B+C);
		return 0;
	}
	int ans=0;
	int tmp=min(B,C-1);
	ans+=2*tmp;
	B-=tmp,C-=tmp;
	if(!B&&C==1){
		printf("%d",ans+1);
	}
	else{
		tmp=min(A,C-1);
		ans+=tmp;
		printf("%d",ans+1);
	}
	return 0;
}

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

digit = 0
max = 0
while True:
    if N <= max:
        break
    digit += 1
    max += 26 ** digit
under_digit = 0

for i in range(1, digit):
    under_digit += 26 ** i

order = N - under_digit - 1 #0_index
# print("order:", order)

letter = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

remain = order
now = digit - 1

# print("digit:", digit)
ans = ""
# print(ans)
# counter = 0
if remain == 0:
    ans = "a" * digit
while remain != 0:
    # print("---------------")
    # counter += 1
    # print("counter", counter)
    # if counter >= 10:
    #     break

    ans = ans + letter[remain // (26 ** now)]
    remain %= 26 ** now
    now -= 1
    # print("ans:", ans, "remain:", remain, "now:", now)
    if remain == 0 and now == 0:
        ans = ans + "a"
        break

print(ans)


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n; cin >> n;
    long long p[5];
    for(int i = 0; i < 5; i++) cin >> p[i];
    sort(p,p+5);
    cout << (long long)(ceil((double)n/p[0])+4) << endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1e5 + 5, M = N << 1 ;
using namespace std ;

int n, e, ter[M], nxt[M], lnk[N], f[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

inline int count_max(int x) {
	int ret = - 1 ;
	rep(i, 0, 20) if ((x >> i) & 1) ret = i ;
	return ret ;
}

void dfs(int p, int fa) {
	int las = 0, must = 0 ;
	for (int i = lnk[p]; i; i = nxt[i]) if (ter[i] != fa) {
		dfs(ter[i], p) ;
		must |= las & f[ter[i]] ;
		las |= f[ter[i]] ;
	}
	int mx = count_max(must) + 1 ;
	for ( ; (1 << mx) & las ; ++ mx) ;
	f[p] = (las | (1 << mx)) >> mx << mx ;
}

int main() {
	scanf("%d", &n) ;
	int x, y ;
	rep(i, 1, n - 1) {
		scanf("%d%d", &x, &y) ;
		add(x, y), add(y, x) ;
	}
	dfs(1, 0) ;
	printf("%d\n", count_max(f[1])) ;
	return 0 ; 
}

Measured memory_bytes: 7168
#include<stdio.h>

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void print(int* A, int N){
  int i;
  for(i = 0; i < N; i++){
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

int selection_sort(int* A, int N){
  int i,j,cnt=0;
  
  for(i = 0; i < N; i++){
    int mini = i;
    for(j = i; j < N; j++) if(A[j] < A[mini]) mini = j;
    cnt += (i==mini?0:1);
    swap(&A[i],&A[mini]);
  }
  print(A,N);
  return cnt;
}

int main(){
  int i,N,data[100];
  scanf("%d",&N);
  for(i = 0; i < N; i++) scanf("%d",&data[i]);
  printf("%d\n",selection_sort(data,N));
  return 0;
}

Measured memory_bytes: 604
N=int(input())
s=list(map(int, input().split()))
A=[]
for i in range(len(s)):
  a=int(s[i])
  A.append(a)
B=[]
for i in range(len(A)):
  if A[i]%2==0:
    b=A[i]
    B.append(b)
C=[]
for i in range(len(B)):
  if (B[i]%3==0 or B[i]%5==0):
    c=B[i]
    C.append(c)
if len(B)==len(C):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include <stdlib.h>
#define MAX 2000005
#define VMAX 10005

int A[MAX], B[MAX];
int C[VMAX+1];

int main(){
  

  int n, i, j;

  scanf("%d", &n);



  for(i=1;i<=n;i++){
       scanf("%d",A+i);
   
  }
  
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
 
  for(i=1;i<=VMAX;i++){
    C[i] += C[i-1];
  }
 
  
  for(j=n;j>0;j--){
    B[C[A[j]]]= A[j];
    C[A[j]]--;
  }
    
  for(j=1;j<=n;j++){
    printf("%d",B[j]);
    if(j!=n)printf(" ");
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 17396
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int i,j,k,a,b;
    cin >> a >> b;
    i=(b*2);
    if(a>=i)
    {
        cout << a-i << endl;
    }
    else
    {
        cout << "0"<<endl;
    }
    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if ((A * B) % 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 最大公約数(ユークリッドの互除法)
// O(log max(a, b))
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    int n, k, g;
    bool ans = false;
    cin >> n >> k;
    vector<int> a(n), b(n-1);
    rep(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    g = a.at(0);
    rep2(i, 1, n){
        if(a.at(i) != a.at(i-1)) g = gcd(g, a.at(i) - a.at(i-1));
    }
    rep(i, n){
        if(a.at(i) == k) {
            ans = true;
            break;
        }
        if((a.at(i) - k) > 0 && (a.at(i) - k) % g == 0) {
            ans = true;
            break;
        }
    }
    if(ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

}

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

using namespace std;

typedef map <const pair<int, int>, int> uuu;

int n, a[100005], b[100005], vis[100005], ans;
vector <int> G[100005];
uuu um;

void colo(int id, int deco) {
	vis[id] = 1;
	int k = 1;
	for (int u : G[id]) {
		if (vis[u]) continue;
		if (k == deco) k++;
		um.insert(make_pair(make_pair(u, id), k));
		um.insert(make_pair(make_pair(id, u), k));
		ans = max(k, ans);
		k++;
	}
	for (int u : G[id]) {
		if (vis[u]) continue;
		colo(u, um.at(make_pair(u, id)));
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i=0; i<n - 1; i++) {
		cin >> a[i] >> b[i];
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	colo(a[0], 0);
	cout << ans << endl;
	for (int i=0; i<n-1; i++) {
		cout << um.at(make_pair(a[i], b[i])) << endl;
	}
}

Measured memory_bytes: 19712
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

int main() {

	int n;int k; cin >> n; cin >> k;

	int a = n + k;
	int b =  n - k;
	int c =  n * k;

	cout << std::max({a,b,c});

}


Measured memory_bytes: 256
//manhattan distance trick, constructive algorithm (partitioning area)
//https://code-festival-2017-quala.contest.atcoder.jp/tasks/code_festival_2017_quala_d

#include <iostream>
#include <vector>

using namespace std;

const int INF = 1231231234;

struct pt
{
    int x, y;

    pt(){}
    pt(int a, int b) : x(a), y(b) {}
};

pt toChebyshev(pt p)
{
    return {p.x + p.y, p.x - p.y};
}

char getColor(pt p, int minx, int miny, int d)
{
    int xPartition = (p.x - minx) / d, yPartition = (p.y - miny) / d;
    if (xPartition & 1)
    {
        return yPartition & 1 ? 'R' : 'B';
    }
    else
    {
        return yPartition & 1 ? 'G' : 'Y';
    }
}

int main()
{
    int h, w, d;
    cin>>h>>w>>d;

    vector <pt> corners = {{0, 0}, {h, 0}, {0, w}, {h, w}};
    int minX = INF, minY = INF;
    for (int i = 0; i < 4; i++)
    {
        pt p = toChebyshev(corners[i]);
        minX = min(minX, p.x);
        minY = min(minY, p.y);
    }

    char grid[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            pt p = toChebyshev({i, j});
            grid[i][j] = getColor(p, minX, minY, d);
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout<<grid[i][j];
        }
        cout<<'\n';
    }

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.size()){
      if(cnt == 1 && s[i] == 'F')++cnt;
      if(cnt == 0 && s[i] == 'C')++cnt;
    }
    puts((cnt >= 2) ? "Yes" : "No");


/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int num=0;
	for(int i=1;i<=n;i+=2){
		int count=0;
		for(int j=1;j<=n;j++){
			if(i%j==0){
				count++;
			}
		}
		if(count==8)
			num++;
	}
	cout<<num<<endl;
	return 0;
}

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

int A,B,m,ans=0x3f3f3f3f;
int a[100005];
int b[100005];
int c[100005];
int x[100005];
int y[100005];

int main(){

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

    cin>>A>>B>>m;
    for(int i=1;i<=A;i++)cin>>a[i];
    for(int i=1;i<=B;i++)cin>>b[i];
    for(int i=1;i<=m;i++){
        cin>>x[i]>>y[i]>>c[i];
        ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
    }
    cout<<min(ans,*min_element(a+1,a+1+A)+*min_element(b+1,b+1+B))<<endl;

    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#define M_NUM 100000

typedef struct Node{
    int key;
    int parent;
    int child;
    int sibling; 
}node;

node tree[M_NUM];

void Initialize(){
    int i;
    for(i=0; i<M_NUM; i++){
        tree[i].key = -1;
        tree[i].parent = -1;
        tree[i].child = -1;
        tree[i].sibling = -1;
    }
}


short CalcDepth(int i){
    int dep=0;
    int search = i;

    while(tree[search].parent != -1){
        dep++;
        search = tree[search].parent;
    }

    return dep;
}

int main(){
    int i,j,n,degree,num,childl=0,depth,buf;

    Initialize();
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d %d",&num, &degree);
        tree[num].key = num;
        for(j=0; j<degree; j++){
            buf = childl;
            scanf("%d",&childl);
            tree[childl].key = childl;
            tree[childl].parent = tree[num].key;
            if(j==0)tree[num].child = childl;
            if(j!=0)tree[buf].sibling = tree[childl].key;
        }
    }

    for(i=0; i<n; i++){
        buf = tree[i].child;
        depth = CalcDepth(i);
        printf("node %d: parent = %d, depth = %d, ",tree[i].key,tree[i].parent,depth);
        if(tree[i].parent == -1) printf("root");
        else if(tree[i].child == -1) printf("leaf");
        else printf("internal node");
        printf(", [");
        while(buf != -1){
            printf("%d",buf);
            if(tree[buf].sibling != -1) printf(", ");
            buf = tree[buf].sibling;
        }
        printf("]\n");
    }
    return 0;
}


Measured memory_bytes: 3308
import heapq
from collections import deque

class job:
    def __init__(self,date,award):
        self.award=award
        self.date=date
    def __gt__(self,other):
        if self.award<other.award:
            return True
#         elif self.award==other.award and self.date>other.date:
#             return True
#         elif self.award==other.award and self.date==other.date and self.name>other.name:
#             return True
        else:
            return False
    def __lt__(self,other):
        if self.award>other.award:
            return True
#         elif self.date==other.date and self.award>other.award:
#             return True
#         elif self.award==other.award and self.date==other.date and self.name<other.name:
#             return False
        else:
            return False
    def __eq__(self,other):
        if self.award==other.award:
            return True
        else:
            return False

jobs=[]
n,m=[int(i) for i in input().split()]
for i in range(n):
    info=[int(j) for j in input().split()]
    jobs.append(info)
jobs.sort()

jobdeque=deque()
for i in jobs:
    jobdeque.append(i)
    
ans=0
heap=[]
heapq.heapify(heap)
for i in range(m):
    while jobdeque:
        a=jobdeque.popleft()
        if a[0]==i+1:
            heapq.heappush(heap,job(a[0],a[1]))
        else:
            jobdeque.appendleft(a)
            break
    if heap:
        b=heapq.heappop(heap)
        ans+=b.award
                          
print(ans)


Measured memory_bytes: 87768
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    cnt = 0
    x = sum(a)
    for v in a:
        if v >= x/(4*m):
            cnt += 1
    if cnt >= m:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll D;
  cin >> D;
  string ans;
  switch (D) {
  case 25:
    ans = "Christmas";
    break;
  case 24:
    ans = "Christmas Eve";
    break;
  case 23:
    ans = "Christmas Eve Eve";
    break;
  case 22:
    ans = "Christmas Eve Eve Eve";
    break;
  default:
    break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
      String[] tA=sc.nextLine().split("");
      String[] tB=sc.nextLine().split("");
      String[] tC=sc.nextLine().split("");

//    String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();

//int n=Integer.parseInt(nyu);

//int A=Integer.parseInt(t[0]);
//int B=Integer.parseInt(t[1]);

Queue<String> qA = new ArrayDeque<>();
Queue<String> qB = new ArrayDeque<>();
Queue<String> qC = new ArrayDeque<>();

for(String tem:tA)qA.add(tem);
for(String tem:tB)qB.add(tem);
for(String tem:tC)qC.add(tem);

String beg=qA.poll();

while(true){
String pre=beg;

//System.out.println(beg+"--");
switch(beg){
case "a":
beg=qA.poll();
break;
case "b":
beg=qB.poll();
break;
case "c":
beg=qC.poll();
break;
}

if(beg==null){
System.out.println(pre.toUpperCase());
break;
}

}




	}
}

Measured memory_bytes: 21844
package main

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

func main() {
	K := nextInt()
	A := nextInt()
	B := nextInt()

	for i := A; i <= B; i++ {
		if i%K == 0 {
			fmt.Println("OK")
			return
		}
	}

	fmt.Println("NG")
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1788
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Reflection.PortableExecutable;
    using System.Text;
    using System.Xml.Serialization;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var xy = t.ParseIntList(t.ReadInput());
            var count = xy[0];
            var ans = "No";

            if(xy[0] == 1)
            {
                if(xy[1] == 4 || xy[1] == 2)
                {
                    ans = "Yes";
                }
            }
            else
            {
                for (var i = 0; i <= xy[0]; i++)
                {
                    if (4 * count + 2 * i == xy[1])
                    {
                        ans = "Yes";
                        break;
                    }
                    count--;
                }

            }

            Console.WriteLine(ans); 
        }

        public bool DicSearch(int x,Dictionary<int,int> dic)
        {
            return dic.ContainsKey(x);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 27832
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		int dp[][] = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(dp[i], Integer.MAX_VALUE>>2 );
		}
		Arrays.fill(dp[0], 0);
		for (int i = 1; i < n; i++) {
			for (int j = 0; i + j < n; j++) {
				for (int k = 0; k < i; k++) {
					dp[i][j] = Math.min(dp[i][j], dp[k][j] + dp[i-k-1][j+k+1] + a[j]*b[j+k]*a[j+k+1]*b[j+i]);
//					System.out.println(j +","+ (j+k)+","+(j+k+1)+","+(j+1));			
				}
			}
//			System.out.println(Arrays.toString(dp[i]));
		}
		
		System.out.println(dp[n-1][0]);
	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vl a(n);

  map<ll, ll> m;
  rep(i, n) {
    cin >> a[i];
    m[a[i]]++;
  }

  ll maxi = -1;
  for (auto&& i : m) {
    if (i.second >= 2 and maxi < i.first) {
      maxi = i.first;
    }
  }
  ll maxi2 = -1;
  if (maxi != -1 and m[maxi] >= 4) {
    maxi2 = maxi;
  }

  for (auto&& i : m) {
    if (i.second >= 2 and maxi2 < i.first and i.first != maxi) {
      maxi2 = i.first;
    }
  }

  if (maxi == -1 or maxi2 == -1) {
    cout << 0 << endl;
  } else {
    cout << maxi * maxi2 << endl;
  }
}


Measured memory_bytes: 7296
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){
	fast;
	int n;
	cin >> n;
	map<int,int> m;
	for(int i =0 ; i<n-1;i++){
		int temp;
		cin >> temp;
		m[temp]++;
	}
	for(int i = 1;i <=n;i++){
		cout<<m[i]<<"\n";
	}
	return 0;
}

	


Measured memory_bytes: 13028
#include <stdio.h>
#include <stdlib.h>
int main(void){
    long long int n, k;
    scanf("%lld %lld", &n, &k);
    long long int ans=n%k;
    if(llabs(ans-k)<ans)ans=llabs(ans-k);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1736
$input = <>; chomp $input;
($n, $k) = split / /, $input;

$input = <>; chomp $input;
@l = split / /, $input;

@l = sort { $b <=> $a } @l;

$len = 0;
for (0..$k-1) {
    $len += $l[$_];
}

print $len;


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>
#include <set>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;


int main()
{
    // 整数の入力
    ll N,K;
    queue<ll> next_nodes;
    map<ll,set<ll>> G,G2;
    set<ll> searched;

    cin >> N >> K;
    for (int i = 1;i<=N;i++){
        set<ll> s,s2;
        G[i] = s;
        G2[i] = s2;
    }

    for (int i = 0; i < N-1; i++)
    {
        ll a,b;
        cin >> a >> b;
        G[a].insert(b);
        G[b].insert(a);
    }
    next_nodes.push(1);
    searched.insert(1);

    ll total = K;
    while(!next_nodes.empty()){
        ll node = next_nodes.front();
        next_nodes.pop();
        for(auto n:G[node]){
            if(searched.find(n) == searched.end()){
                next_nodes.push(n);
                searched.insert(n);

                G2[node].insert(n);
                G2[n].insert(node);
                total = total * (K - G2[node].size()) % BASE_NUM;
            }

        }
    }

    cout << total << endl;
    return 0;
}

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

typedef long long LL;

const int MAXN = 1 << 18 | 1, MOD = 1e9 + 7;
inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
inline int sub(int x, int y) { return x < y ? x - y + MOD : x - y; }
inline int mul(int x, int y) { return 1LL * x * y - 1LL * x * y / MOD * MOD; }
inline int Qpow(int a, int b) { int ans = 1; for (; b; a = mul(a, a), b >>= 1) if (b & 1) ans = mul(ans, a); return ans; }

int n, l, h, ans;
int p[MAXN], val[MAXN];

template <int N, int S>
struct Trie {
	int QAQ[N];
	inline void insert(int x, int val) { for (; x > 1; x >>= 1) val = mul(val, x), QAQ[x] = add(QAQ[x], val); }
	inline int query(int x) {
		int ans = 0, pro = 1;
		for (; x > 1; x >>= 1) pro = mul(pro, x), ans = add(ans, mul(mul(QAQ[x ^ 1], pro), x >> 1));
		return ans;
	}
};
Trie <MAXN, 2> T;

void gao(int x, int L, int R) {
	if (L < R) {
		int mid = (L + R) >> 1;
		gao(x << 1, L, mid), gao(x << 1 | 1, mid + 1, R);
		for (int i = L; i <= mid; ++i) T.insert(p[i] + l - 1, val[i]);
		for (int i = mid + 1; i <= R; ++i) ans = add(ans, mul(mul(x, val[i]), T.query(p[i] + l - 1)));
		for (int i = L; i <= mid; ++i) T.insert(p[i] + l - 1, MOD - val[i]);
	}
	for (int i = L; i <= R; ++i) val[i] = mul(val[i], x);
}

int main() {
	scanf("%d", &h), n = (1 << h) - 1, l = 1 << (h - 1);
	for (int i = 1; i <= l; ++i) scanf("%d", p + i);
	for (int i = 1; i <= l; ++i) val[i] = 1;
	gao(1, 1, l);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5832
#include<bits/stdc++.h>
using namespace std;
int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
	}
	else{
		cout<<"win";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //    #ifndef ONLINE_JUDGE
    //        freopen("input.txt", "r", stdin);
    //        freopen("output.txt", "w", stdout);
    //    #endif
    int n;
    cin >> n;
    int a[n + 1];
    int i;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    vector<int> dp(n + 1, 0);
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n] << endl;
}

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

using namespace std;

using ll =  long long;

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

    int b[n+1];
    fill(b, b+(n+1), 0);
    vector<int> ans;
    for(int i=n;i>=1;--i) {
        if(b[i] == a[i]) continue;
        ans.push_back(i);
        for(int j=1;j*j<=i;++j) {
            if(i % j == 0) {
                b[j] = 1 - b[j];
                if(j*j != i) {
                    b[i/j] = 1 - b[i/j];
                }
            }
        }
        // for(int ii=1;ii<=n;++ii) cerr << b[ii] << " ";
        // cerr << endl;
    }

    for(int i=n;i>=1;--i) {
        if(b[i] != a[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << int(ans.size()) << endl;
    if(ans.size()) {
        for(int i: ans) cout << i << " ";
        cout << endl;
    }
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		if(N.charAt(0)==N.charAt(1)&&N.charAt(1)==N.charAt(2)||
				N.charAt(1)==N.charAt(2)&&N.charAt(2)==N.charAt(3)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i];
    sort(a, a + n);
    sort(c, c + n);
    ll cnt = 0;
    for (int j = 0; j < n; ++j) {
        ll aa = lower_bound(a, a + n, b[j]) - a;
        ll cc = upper_bound(c, c + n, b[j]) - c;
        cnt += aa * (n - cc);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std ;
int main()
{
int fre[26] ;
for(int i=0;i<26;i++) fre[i] = 0 ;
string str ;
cin>>str ;
int n = str.length() ;
for(int i=0;i<n;i++)
{
fre[str[i]-'a']++ ;
}
for(int i=0;i<26;i++)
if(fre[i]>1) {cout<<"no"; return 0 ; }
cout<<"yes";
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n:usize = read();
    let mut a: Vec<i64> = Vec::with_capacity(n);
    unsafe{
	a.set_len(n);
    }
    for i in 0..n{
	let number:i64 = read();
	a[i] = number;
    }
    a.sort();
    for i in 1..n{
	if a[i-1]==a[i] {
	    println!("NO");
	    return;
	}
    }
    println!("YES");
}


Measured memory_bytes: 6396
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll inf = numeric_limits<ll>::max() / 3;

ll work (const ll n, const ll a, const ll b, const ll c, const ll d, map<ll, ll> &mem)
{
	if (mem.count(n))
		return mem.at(n);

	auto &cur = mem[n];
	cur = inf;
	if (double(n) * double(d) < 2 * double(cur))
		cur = min(cur, n * d);

	for (int i = -4; i <= 4; i++)
	{
		const ll x = n + i;
		if (x < 0)
			continue;

		if (x / 2 < n && x % 2 == 0)
			cur = min(cur, a + abs(i) * d + work(x / 2, a, b, c, d, mem));
		if (x / 3 < n && x % 3 == 0)
			cur = min(cur, b + abs(i) * d + work(x / 3, a, b, c, d, mem));
		if (x / 5 < n && x % 5 == 0)
			cur = min(cur, c + abs(i) * d + work(x / 5, a, b, c, d, mem));
	}

	return cur;
}

void solve_test(istream &cin = std::cin, ostream &cout = std::cout)
{
	map<ll, ll> mem;

	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	cout << work(n, a, b, c, d, mem) << endl;
}

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int t;
	cin >> t;

	for (int i = 0; i < t; i++)
		solve_test(cin, cout);
}

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

#ifdef LOCAL
	auto st = clock();
	ifstream fin("../input.txt");
	solve(fin);

	cout << "clock: " << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}

Measured memory_bytes: 6480
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

ll gcd(ll a, ll b, ll c){
  return gcd(a, gcd(b, c));
}


int main(void){
  ll k;
  cin >> k;
  

  ll res = 0;
  for (int i = 0; i < k; i++){
    for (int j = 0; j < k; j++){
      for (int l = 0; l < k; l++){
        res += gcd(i + 1, j + 1, l + 1);
      }
    }
  }

  cout << res << endl;
  
  

  return 0;
}


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

int main(){
    double n;
    cin >> n;
    int k;
    cin >> k;
    double ans =0;
    for(int i=1;i<=n;i++){
        double t=i;
        double countt=1;
        while(t<k){
            t*=2;
            countt*=2;
        }
        ans+=1/(countt*n);
    }
    printf("%.12lf\n",ans);
}

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

int main(){
	string s;
	cin >> s;
	int i = 0,num,min = 1e9;
	while(s[i + 2] != '\0'){
		num = abs(753 - (100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + s[i + 2] - '0'));
		if(num < min)min = num;
		i++;
	}
	cout << min << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
//atcoder
public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int L = scanner.nextInt();
        int R = scanner.nextInt();
        if (R-L>= 2019) out.println(0);
        else {
            ArrayList<Integer> vals = new ArrayList<>();
            for(int i = L; i <= R; i++) {
                vals.add(i % 2019);
            }
            int ans = 2019;
            for(int i = 0; i < vals.size(); i++) {
                for(int j = i + 1; j < vals.size(); j++) {
                    ans = Math.min(ans, (int)vals.get(i)*(int)vals.get(j) % 2019);
                }
            }
            out.println(ans);
        }
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	string s,t;
	cin>>s>>t;
	reverse(all(s));
	if(s==t) cout<<"YES";
	else cout<<"NO";
	re 0;
}

Measured memory_bytes: 3648