akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> S(H);
  vector< vector<int> > L(H,vector<int>(W)),R(H,vector<int>(W)),D(H,vector<int>(W)),U(H,vector<int>(W));
  for(int i=0;i<H;i++){
    cin >> S.at(i);
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)=='#'){
        L.at(i).at(j)=0;
        D.at(i).at(j)=0;
      }else{
        if(j==0){
          L.at(i).at(j)=1;
        }else{
          L.at(i).at(j)+=L.at(i).at(j-1)+1;
        }
        if(i==0){
          U.at(i).at(j)=1;
        }else{
          U.at(i).at(j)=U.at(i-1).at(j)+1;
        }
      }
    }
  }
  for(int i=H-1;i>=0;i--){
    for(int j=W-1;j>=0;j--){
      if(S.at(i).at(j)=='#'){
        R.at(i).at(j)=0;
        D.at(i).at(j)=0;
      }else{
        if(j==W-1){
          R.at(i).at(j)=1;
        }else{
          R.at(i).at(j)=R.at(i).at(j+1)+1;
        }
        if(i==H-1){
          D.at(i).at(j)=1;
        }else{
          D.at(i).at(j)=D.at(i+1).at(j)+1;
        }
      }
    }
  }
  priority_queue<int> pq;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      pq.push(L.at(i).at(j)+R.at(i).at(j)+D.at(i).at(j)+U.at(i).at(j)-3);
    }
  }
  cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 85228
#include<stdio.h>

int main(void)
{
	int i,x;
	x=999;
	for( i=1; 0 != x; i++ ) {
		scanf( "%d",&x );
		if( 0 != x ) {
			printf( "Case %d: %d\n", i, x );
		}
	}

	return 0;
}

Measured memory_bytes: 596
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    long long a,b;
    cin >> a >> b;
    long long sol =  1;
    long long fact =2;
    
    set<long long> set1;
    unordered_set<long long> set2;
    while(fact * fact <= a)
    {
        if(a % fact == 0)
        { 
            set1.insert(fact);
            while(a%fact ==0)
            {
                a/=fact;
            }
        }
        fact++;
    }
    if(a!= 1)
        set1.insert(a);
    fact = 2;
    while(fact * fact <= b)
    {
        if(b % fact == 0)
        { 
            set2.insert(fact);
            while(b%fact ==0)
            {
                b/=fact;
            }
        }
        fact++;
    }
    if(b!= 1)
        set2.insert(b);
    for(auto &elem : set1)
    {
        if(set2.find(elem) != set2.end())
        {
            sol++;
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	int n, k; cin >> n >> k;
	vector<int> sunuke(n);
	rep(i, k) {
		cin >> a;
		rep(j, a) {
			cin >> b; sunuke[b-1]++;
		}
	}
	int cnt = 0;
	rep(i, n) { if (sunuke[i] == 0)cnt++; }
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<map>
using namespace std;

string solve(string input);

int main(){
  string input;
  cin >> input;
  cout <<solve(input) <<endl;
}

string solve(string s){
  map<char, int> count;
  for(char &c : s) {
    if(count.find(c) == count.end()) {
      count[c] = 0;
    }
    count[c] += 1;
  }
  if(count.size() != 2){ return "No"; }
  for(auto& p : count){
    if(p.second != 2){ return "No"; }
  }
  return "Yes";
}


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

      int n = sc.nextInt();
      int x = sc.nextInt();
      int[] data = new int[n];
      int sum = 0;
      int count = 1;

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

      for (int i = 0;i<n ;i++ ) {
          sum = sum + data[i];
          if (sum<=x) {
              count++;
          }
      }
      System.out.println(count);
}
}


Measured memory_bytes: 21716
x, y = [ int(x) for x in input().split() ]

def group(x):
    g = {
        0: set([1, 3, 5, 7, 8, 10, 12]),
        1: set([4, 6, 9, 11]),
        2: set([2])
    }
    for k in g.keys():
        if x in g[k]:
            return k
    return len(g)
ans = group(x) == group(y)

print("Yes" if ans else "No")
print()


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;
    
int v[100100];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    cout << n/3 << endl;
    

    return 0;
}

Measured memory_bytes: 256
/**
 * King's Inspection
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		char[] stations = new char[52];
		for (int i = 0; i < 26; i++) {
			stations[i] = (char) ('a' + i);
		}
		for (int i = 0; i < 26; i++) {
			stations[i + 26] = (char) ('A' + i);
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line);
			if (n == 0) break;

			int[] keys = new int[n];
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < n; i++) {
				keys[i] = parseInt(st.nextToken());
			}

			line = br.readLine();
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < line.length(); i++) {
				char c = line.charAt(i);
				int j;
				if ('a' <= c && c <= 'z') {
					j = c - 'a';
				} else {
					j = c - 'A' + 26;
				}
				j -= keys[i % n];
				if (j < 0) {
					j += 52;
				}
				sb.append(stations[j]);
			}
			System.out.println(sb.toString());
		} //end while
	} //end main
}

Measured memory_bytes: 19112
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vi a(n), b(n - 1);
	rep(i, n - 1) cin >> b[i];
	a[n - 1] = b[n - 2];
	a[0] = b[0];
	bool flag = false;
	for (int i = n - 2; i >= 1; i--) {
		if ((b[i] > b[i - 1])) {
			a[i] = b[i - 1];
		}
		else {
			a[i] = b[i];
		}
	}
	ll sum = 0;
	rep(i, n) {
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,a;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a;
	cout<<(n-k)/(k-1)+((n-k)%(k-1)==0?0:1)+1; 
	return 0;
}

Measured memory_bytes: 380
#include <stdio.h>

int main()
{
  int x;
  int h, m, s;

  scanf("%d", &x);

  h = x / 3600;
  m = x % 3600 / 60;
  s = x % 3600 % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

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

def prime_factorization(n):
    originaln = n
    result = []
    f = 2
    while f*f <= originaln+10:
        a = 0
        while n%f ==0:
            n = n//f
            a = a+1
            # print(f,a,n)
        if a!=0:
            # result.append([f,a])
            result.append(a)
        f = f+1
    # print(result)
    ans = 1
    for i in result:
        ans *= (i+1)
    # print("ans is ",ans)
    if ans == 8:
        return True
    else:
        return False

finalans = 0
for i in range(2,N+1):
    if prime_factorization(i) == True and i%2 == 1:
        # print("bingo",i)
        finalans +=1
print(finalans)
# for i in range(N):
#     ans = 0
#     if prime_factorization(i) == True:
#         ans = ans + 1
    
# print(result)
# print(ans)


Measured memory_bytes: 3064
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var k = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var res = 0;
        for (int i = 0; i < n; i++)
            res += Math.Min(a[i], k - a[i]);
        Console.WriteLine(res * 2);
    }
}

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

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

int main() {
	int n;
	cin >> n;
	if (360 % n == 0) cout << 360 / n << '\n';
	else cout << lcm(360, n) / n << '\n';
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if ((n + 1) / 2 >= k) {
	  cout << "YES" << endl;
	} else {
	  cout << "NO" << endl;
	}
  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, P;

int main(){
  cin >> N >> P;
  if (N == 1){
    cout << P << endl;
    return 0;
  }
  ll now = P, ans = 1;
  for (ll i = 2; i * i <= P; i++){
    ll cnt = 0;
    while (now % i == 0){
      now /= i; cnt++;
    }
    while (cnt >= N){
      ans *= i; cnt -= N;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
	long long int n, d, e, f, g, h, j;
	long long int x[200000], y[200000];
	cin >> n >> d;
	e = d * d;
	g = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		h = x[i] * x[i];
		j = y[i] * y[i];
		f = h + j;
		if (f <= e) g = g + 1; 
	}
	cout << g;
	return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e10;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ll n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,s;
    cin>>k>>s;
    int meghans=0;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            int l=s-i-j;
            if(l>=0&&l<=k)
                meghans++;
        }
    }
    cout<<meghans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int N;
    cin>>N;
    string S;
    cin>>S;
    vi cnt(3,0);
    rep(i,0,S.size()){
        if(S[i]=='R')cnt[0]++;
        else if(S[i]=='G')cnt[1]++;
        else cnt[2]++;
    }
    ll res=1;
    rep(i,0,3)res*=cnt[i];
    rep(j,0,N){
        rep(i,0,j){
           ll k=2*j-i;
           if(k<N){
               if(S[i]==S[j])continue;
               if(S[j]==S[k])continue;
               if(S[k]==S[i])continue;
               res--;
           }
        }
    }
    cout<<res<<endl;
    return 0;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, ll> PPI;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int h,w,k;
char a[810][810];
int dd[]={1,0,-1,0,1};
int si,sj;
int dist[810][810],dist2[810][810];

bool valid(int i,int j){
  return i>=0&&i<h&&j>=0&&j<w;
}

int manh(int i,int j){
  return abs(i-si)+abs(j-sj);
}

int main(){
	cin.sync_with_stdio(false);
  cin>>h>>w>>k;
  rep(i,h){
    cin>>a[i];
    rep(j,w)if(a[i][j]=='S'){
      si=i; sj=j;
      a[i][j]='.';
    }
  }
  rep(i,h)rep(j,w)dist[i][j]=INF;
  queue<PPI> que;
  que.push(PPI(P(si,sj),0));
  while(que.size()){
    PPI np=que.front(); que.pop();
    int ni=np.fi.fi, nj=np.fi.se;
    if(dist[ni][nj]!=INF)continue;
    dist[ni][nj]=np.se;
    rep(d,4){
      int pi=ni+dd[d],pj=nj+dd[d+1];
      if(valid(pi,pj)&&a[pi][pj]!='#')que.push(PPI(P(pi,pj),np.se+1));
    }
  }
  int res=INF;
  rep(i,h)rep(j,w){
    if(dist[i][j]<=k){
      minch(res,(min(min(i,h-i-1),min(j,w-j-1))+k-1)/k+1);
    }
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4096
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func moveToN(n int) (int, int) {
	limit := int(math.Sqrt(float64(n)))
	for i := limit; i > 0; i-- {
		if n%i == 0 {
			return i, n / i
		}
	}
	return 1, 1
}

func count(n int) int {
	i, j := moveToN(n)
	return i - 1 + j - 1
}

func main() {
	n := nextInt()
	r := count(n)
	fmt.Println(r)
}


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

using namespace std;

bool dfs(int u, int r, const vector<vector<int>> &g,
         vector<int> &vis, vector<int> &res) {
    vis[u] = 1;
    for (int v : g[u]) {
        if (v != r && vis[v]) {
            return false;
        }
    }
    for (int v : g[u]) {
        if (v == r) {
            res.push_back(u);
            return true;
        }
    }
    for (int v : g[u]) {
        if (!vis[v]) {
            bool part = dfs(v, r, g, vis, res);
            if (part) {
                res.push_back(u);
                return true;
            }
        }
    }
    return false;
}

bool bfs(int r, const vector<vector<int>> &g, vector<int> &res) {
    queue<int> q;
    q.push(r);
    vector<int> vis(g.size(), 0), par(g.size(), -1);
    vis[r] = 1;
    par[r] = -1;
    //cout << "root " << r+1 << endl;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        //cout << u+1 << endl;
        bool ok = true;
        for (int v : g[u]) {
            if (v != r && vis[v] && vis[v] < vis[u]) {
                ok = false;
            }
        }
        //if (!ok) cout << "first" << endl;
        if (!ok) continue;
        for (int v : g[u]) {
            if (v == r) {
                int cur = u;
                do {
                    res.push_back(cur);
                    cur = par[cur];
                } while (cur != -1);
                return true;
            }
        }
        for (int v : g[u]) {
            if (!vis[v]) {
                q.push(v);
                par[v] = u;
                vis[v] = vis[u] + 1;
            }
            
        }
    }
    return false;
}
int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
    }
    for (int r = 0; r < N; ++r) {
        //cout << r+1 << endl;
        /*vector<int> vis(N, 0), res;
        if (dfs(r, r, g, vis, res)) {
            cout << res.size() << "\n";
            for (int x : res) {
                cout << x + 1 << "\n";
            }
            return 0;
        } else {
            assert(res.empty());
        }*/
        vector<int> res;
        if (bfs(r, g, res)) {
            cout << res.size() << "\n";
            for (int x : res) {
                cout << x + 1 << "\n";
            }
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

struct Node{
	int key;
	Node *parent,*left,*right;
};
int n;
Node *NIL,*root;
void insert(int k){
	Node *x = root;
	Node *y = NIL;
	Node *z;
	z = new Node();
	z->key = k;
	z->left = z->right = NIL;
	while(x != NIL){
		y = x;
		if(z->key > x->key){
			x = x->right;
		}else{
			x = x->left;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	}else{
		if(z->key > y->key){
			y->right = z;
		}else{
			y->left = z;
		}
	}
}

void inorder(Node *a){
	if(a == NIL) return;
	inorder(a->left);
	cout << " " << a->key; 
	inorder(a->right);
}

void preorder(Node *a){
	if(a == NIL) return;
	cout << " " << a->key; 
	preorder(a->left);
	preorder(a->right);	
}

int main(){
	cin >> n;
	int key;
	char s[10];
	for(int i = 0;i < n;i++){
		scanf("%s",s);
		if(s[0] == 'i'){
			cin >> key;
			insert(key);
		}else if(s[0] == 'p'){
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

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

#define endl "\n"

#define mod ll(1e9+7)

int main()
{
	faster;
	
	ll n,k;
	cin >> n >> k;

	vector<ll> a(n);

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

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

	ll res = 1,sign = 1,left = 0,right = n-1;

	if(k % 2){
		res = (a[right--]%mod);
		res %= mod;
		if(res < 0){
			sign = -1;
		}
		k--;
	}
	while(k){
		ll x = a[left] * a[left+1],y = a[right] * a[right-1];
		if(x * sign > y * sign){
			res *= (x % mod);
			res %= mod;
			left += 2;
		}else {
			res *= (y % mod);
			res %= mod;
			right -= 2;
		}
		k -= 2;
	}
	cout << ((mod+res) % mod)<< endl;
	
	return 0;
}

Measured memory_bytes: 4792
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

void actual() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    if (n * a > b) {
        ans = b;
    } else {
        ans = a * n;
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static int N, M, Q;
        static int[] a, b, c, A;
        static long[] d;
        static long ans = 0;
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            N = int.Parse (str[0]);
            M = int.Parse (str[1]);
            Q = int.Parse (str[2]);

            a = new int[Q];
            b = new int[Q];
            c = new int[Q];
            d = new long[Q];

            A = new int[N];

            for (int i = 0; i < Q; i++)
            {
                str = Console.ReadLine ().Split (' ');

                a[i] = int.Parse (str[0]);
                b[i] = int.Parse (str[1]);
                c[i] = int.Parse (str[2]);
                d[i] = long.Parse (str[3]);
            }

            Search (0, 1);

            Console.WriteLine (ans);
        }

        static void Search (int n, int prev)
        {

            for (int i = 0; i < M; i++)
            {
                if (n == N)
                {
                    long score = 0;
                    for (int j = 0; j < Q; j++)
                    {
                        if (A[b[j] - 1] - A[a[j] - 1] == c[j]) score += d[j];
                    }

                    ans = Max (ans, score);
                    return;
                }
                if (prev + i > M) return;

                A[n] = prev + i;
                Search (n + 1, prev + i);

            }

        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main()
{
    ll n,l;
    cin >> n >> l;

    vector<ll> aji(n);
    for(int i=0; i<n; i++) aji[i] = l+i;

    ll sum(0);
    for(int i=0; i<n; i++) sum += aji[i];

    ll diff_opt(1e+9);
    ll ans(0);
    for(int i=0; i<n; i++){
        ll diff = aji[i];
        if(fabs(diff) < diff_opt){
            diff_opt = fabs(diff);
            ans = sum-aji[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Text;
using System.Threading;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            String S = Console.ReadLine();
            //    int[] x = s2iarray(Console.ReadLine().Split(' '));
            if (S == "ABC") RESULT("ARC"); else RESULT("ABC");

        }
     public static bool checka(int[] a,int m)
        {
            int back = 1;
            for(int i = 0; i<a.Length;i++)
            {
                if(a[i] >=1 && a[i] <=m)
                {
if(a[i] >= back)
                    {
                        back = a[i];
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
        public static ulong pow(int a, int b)
        {
            ulong res = 1;
            for (int i = 0; i < b; i++)
            {
                res *= (ulong)a;
            }
            return res;
        }
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static ulong s2l(String s)
        {
            return Convert.ToUInt64(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
        static ulong[] s2larray2(String[] src)
        {
            int len = src.Length;
            ulong[] res = new ulong[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToUInt64(src[i]);
            }
            return res;
        }
    }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n , s ;
    cin >> n >> s ;
    vector<int> A(n) ;
    rep(i,n) cin >> A[i] ;
    vector<mint> DP(s+1) ;
    DP[0]  = 1 ;
    rep(i,n) {
        vector<mint> p(s+1) ;
        swap(DP,p) ;
        rep(j,s+1){
            DP[j] += p[j]*2 ;
            if( j + A[i] <= s ) DP[j+A[i]] += p[j] ;
        }
    }
    cout << DP[s] << endl;
}


Measured memory_bytes: 3688
import random

class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
    
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}

    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]

        if way==0:
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c
def dice_check(dice_1,dice_2):
    lst=["W","S"]
    flag=0
    for i in range(100):
        if dice_1.u==dice_2.u and dice_1.w==dice_2.w and dice_1.s==dice_2.s and dice_1.e==dice_2.e and dice_1.n==dice_2.n and dice_1.d==dice_2.d:
            flag=1
        dice_1.rot(random.choice(lst))
    return flag

flag2=0
dices = []
dice_number=int(input())
for i in range(dice_number):
    u,s,e,w,n,d=map(int,input().split())
    dice=Dice(u,w,s,e,n,d)
    dices.append(dice)
for i in range(dice_number):
    for j in range(i+1,dice_number):
        if dice_check(dices[i],dices[j])==1:
            flag2=1
if flag2==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8240
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int sol = 0;
	for (int ii = 0; ii < 4; ++ii){
		if (S[ii] == '+'){
			sol++;
		} else {
			sol--;
		}
	}

	cout << sol << endl;

	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

typedef long long ll;

using namespace std;

int m[100005];

int main(){
    int n;

    cin >> n;

    int cnt = 0;
    int now = 0;
    rep(i, n){
        int in;
        cin >> in;
        if(now <= in){
            cnt++;
            now = in;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	string s, t;
	cin >> s;
	cin >> t;
	int ans = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == t[i])
		ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPACE << " " <<
#define EXCEPTERROR cout << "-1" << endl;
#define rep(k,n)   for(int i=k; i<n;  i++)
#define rep2(k,n)  for(int j=k; j<n;  j++)
#define _for(a,b,c) for(ll  i=a; i<b;  i+=c)
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return (a+(b-1)/b);}
int main(){
    int n, k; cin >> n >> k;
    ll  attackCount=0;
    vector<ll> h(n);  rep(0,n) cin >> h[i];
    sort(h.begin(), h.end());
    k=min(n,k);
    rep(0,k) h.pb();
    rep(0,h.size()) attackCount += h[i];
    cout << attackCount << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(void){
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",&s[0]);
    int ans=0;
    for(int i=0;i<=n-3;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')ans++;
    }
    printf("%d\n",ans);
    return(0);
}

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

int main(){
  float D, T, S;
  std::cin >> D >> T >> S;
  float time = D/S;
  if(time<=T){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int main(){
  int64 a;
  while(cin >> a,a){
    int v;
    int64 sum = 0;
    int64 g = 1;
    while(a){
      v = a % 10;
      a /= -10;
      if(v < 0){
        v += 10;
        a++;
      }
      sum += v * g;
      g *= 10;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n; cin >> n;
	int i;
	ll tmp;
	ll a,b; cin >> a >> b;
	ll x = 0;
	Rep(n-2){
		ll t; cin >> t;
		x ^= t;
	}
	ll s = a+b;
	ll d = (s-x)/2;
	ll ans = d;
	if((s-x) %2 || d < 0 || (d&x) || ans > a){
		cout << -1 << endl;
		return 0;
	}
	for(i=50; i>=0; i--){
		if(x & (1LL << i)){
			tmp = ans + (1LL << i);
			if(tmp <= a) ans = tmp;
		}
	}
	if(ans > 0){
		cout << a-ans << endl;
		return 0;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e2+5, L = 14, OO = 0x3f3f3f3f;
const int M= 1e9+7;
const double ESP = 1e-8;

int n,m, u,v;
vector<int>adj[100005];
int dp[100005];

int solve(int u){
    int& ret = dp[u];
    if(~ret)return ret;

    ret = 0;
    for(int v: adj[u])
        ret = max(ret, solve(v)+1);

    return ret;
}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n>>m;
    memset(dp, -1, sizeof dp);
    while(m--){
        cin>>u>>v;
        adj[u].push_back(v);
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        ans = max(ans, solve(i));
    }
    cout<<ans;
}


Measured memory_bytes: 7552
import Data.Array
import Data.List
import Control.Monad

dfs :: Int -> Int -> [(Int, Int, Int, Int)] -> Array Int Int -> Int -> Int
dfs n m qs arr i
  | i == n = foldl' (+) 0 $ map (\(a, b, c, d) -> if (arr ! b) - (arr ! a) == c then d else 0) qs
  | otherwise = maximum [dfs n m qs (arr // [(i + 1, x)]) (i + 1) | x <- [arr ! i .. m]]

main :: IO ()
main = do
  [n, m, q] <- map read . words <$> getLine
  qs <- replicateM q $ (\line -> let [a, b, c, d] = map read $ words line in (a, b, c, d)) <$> getLine
  putStrLn $ show $ dfs n m qs (array (0, n) [(0, 1)]) 0

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

int main() {

  int n, d;
  cin >> n >> d;
  
  int c = 0;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(c <= i - d) {
      c = i + d+1;
      ans++;
    }
  }
  if(c < n) ans++;
  cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int a[3];
	rep(i,3) cin>>a[i];

	sort(a,a+3);

	int ans=0;
	while(a[0]+1<a[2]) a[0]+=2, ans++;
	while(a[1]+1<a[2]) a[1]+=2, ans++;

	sort(a,a+3);

	if     (a[0]<a[1]) ans+=2;
	else if(a[0]<a[2]) ans++;

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/**
        	C++14 (GCC 5.4.1)
**/
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

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

    double ans = 0.0;
    for(int i = 1; i <= N ; i++){
        int count = i;
        double k = 1.0 / N;
        while(count < K){
            k *= 1.0/2.0;
            count *= 2;
            // cout<< k << endl;
        }
        ans += k;
        // cout << endl;
    }
    cout << setprecision(10) <<ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	int n;
	cin >> n;
	n %= 10;
	if (n == 3) cout << "bon";
	else if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon";
	else cout << "pon";
}
void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

int main(){
  long long n,d;
  cin>>n>>d;
  d*=d;
  int count=0;
  for(int i=0;i<n;i++){
    long long x,y;
    cin>>x>>y;
    if(d>=x*x+y*y){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3548
#include<stdio.h>
int main()
{
     int k,a,b,sum=0;
     scanf("%d",&k);
     scanf("%d%d",&a,&b);
     for(a=a;a<=b;a++)
     {
          if((a%k)==0)
          {
               sum++;
          }
     }
     if(sum==0)
     {
          printf("NG\n");
     }
     else
     {
           printf("OK\n");
     }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> cnt(n,0);
    int a;
    int j;
    for(j=0;j<n-1;j++){
        cin >> a;
        cnt.at(a-1) += 1; 
    }
    cnt.at(n-1) = 0;
    for(j=0;j<n;j++){
        //cout << j << "  " << cnt.at(j) << endl;
        cout << cnt.at(j) << endl;
    }
    return 0;

    
}



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

bool IsPrime(int n){
  if(n<2)return false;
  else if(n==2)return true;
  else if(n%2==0)return false;
  double sn=sqrt(n);
  for(int i=3;i<=sn;i+=2){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

int main()
{
int n,i;
bool flag=false;
cin>>n;
if(IsPrime(n))cout<<n<<endl;
else{for(i=n+1;!flag;i++){
  flag=IsPrime(i);
}
i--;
cout<<i<<endl;
}
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace atcorder_keyence_2019
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            string ret = "NO";
            if(
                (Regex.IsMatch(line, "keyence$"))
                ||
                (Regex.IsMatch(line, "^keyence"))
                ||
                ((Regex.IsMatch(line, "^k")) && (Regex.IsMatch(line, "eyence$")))
                ||
                ((Regex.IsMatch(line, "^ke")) && (Regex.IsMatch(line, "yence$")))
                ||
                ((Regex.IsMatch(line, "^key")) && (Regex.IsMatch(line, "ence$")))
                ||
                ((Regex.IsMatch(line, "^keye")) && (Regex.IsMatch(line, "nce$")))
                ||
                ((Regex.IsMatch(line, "^keyen")) && (Regex.IsMatch(line, "ce$")))
                ||
                ((Regex.IsMatch(line, "^keyenc")) && (Regex.IsMatch(line, "e$")))      
            )
            {
                ret = "YES";
            }

            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 14136
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] res = new int[N];
        for (int i = 0; i < res.length - 1; i++) {
            int index = sc.nextInt() - 1;
            res[index]++;
        }
        for (int i : res) {
            System.out.println(i);
        }
        sc.close();
    }
}

Measured memory_bytes: 61732
#include <stdio.h>

void
print_num_digits_for(unsigned long a, unsigned long b)
{
    unsigned int num_digits, carry;

    if (0 == a && 0 == b) {
        puts("1");
        return;
    }

    num_digits = 0, carry = 0;
    while (a || b || carry) {
        int ia, ib;

        num_digits++;
        ia = a % 10, a /= 10;
        ib = b % 10, b /= 10;
        carry = (ia + ib + carry) / 10;
    }
    printf("%u\n", num_digits);
}

int
main(int argc, char *argv[])
{
    unsigned int BUF_LEN = 256;
    char buf[BUF_LEN];
    while(fgets(buf, BUF_LEN, stdin)) {
        unsigned long a, b;

        if (EOF == sscanf(buf, "%lu %lu\n", &a, &b)) break;
        print_num_digits_for(a, b);
    }

    return 0;
}

Measured memory_bytes: 620
#include <stdio.h>
int main(void){
    
    int n;
    int a;
    int x=0,y=0,z=0;
    scanf("%d",&n);
    for(;~scanf("%d",&a);){
        if(a%4==0){
            z++;
        }else if(a%2==0){
            y++;
            }else{
            z--;
        }
    }
    puts((y&&0<=z||!y&&-1<=z)?"Yes":"No");
}

Measured memory_bytes: 1620
#include<stdio.h>

int main(){
	char ev[30];
	int ten,n,out,rui[4];
	
	scanf("%d ",&n);
	
	while(n--){
		out=0;
		ten=0;
		rui[1]=rui[2]=rui[3]=0;
		while(out<3){
			scanf(" %s ",ev);
			
			if(ev[1]=='U'){
				++out;
			}
			if(ev[1]=='I'){
				if(rui[3]==1){
					++ten;
				}
				rui[3]=rui[2];
				rui[2]=rui[1];
				rui[1]=1;
			}
			if(ev[1]=='O'){
				ten+=rui[1]+rui[2]+rui[3]+1;
				rui[1]=rui[2]=rui[3]=0;
			}
//			printf("%d %d %d %d\n",ten ,rui[1],rui[2],rui[3]);
		}
		printf("%d\n",ten);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


class UnionFind:
    def __init__(self, node: int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]

    def find(self, x: int) -> int:
        if x == self.par[x]:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x: int, y: int) -> bool:
        if self.isSame(x, y):
            # print("x and y has already united")
            return False

        rx = self.find(x)
        ry = self.find(y)

        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = self.par[ry]
        else:
            self.par[ry] = self.par[rx]

            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

        return True

    def isSame(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)


n, m = li()
uf = UnionFind(n)

for _ in range(m):
    xi, yi, zi = li_()
    uf.unite(xi, yi)

for i in range(n):
    uf.find(i)

print(len(set(uf.par)))

Measured memory_bytes: 13992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




string s;
int ans, now;

int main() {

	cin >> s;

	rep(i, s.size()){
		if (s[i] == 'R'){
			now++;
			ans = max(ans, now);
		}
		else{
			now = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;

    int tmp = b;
    while (tmp) {
        tmp /= 10;
        a *= 10;
    }

    int sum = a + b;
    bool r = false;
    for (int i = 1; i <= 320; i++) {
        if (i * i == sum) r = true;
    }

    if (r) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3604