akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : aoj2515.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <stdio.h>
#include <string.h>

int translate(char *s){
	int h, m;
	h = (s[0] - '0') * 10 + s[1] - '0';
	m = (s[3] - '0') * 10 + s[4] - '0';
	return h * 60 + m;
}


int main() {
	int i, n, t, cnt = 0;
	char tm1[5], tm2[5], name[256], ans[500][1000];
	scanf("%d %d", &n, &t);

	scanf("%s", tm1);
	for (i = 0; i < n - 1; i++){
		scanf("%s", name);
		scanf("%s", tm1);
		scanf("%s", name);
		scanf("%s", tm2);
		int tmp = translate(tm2) - translate(tm1);
		if (tmp >= t){
			sprintf(ans[cnt++], "%s %d", name, tmp);
		}
	}
	printf("%d\n", cnt);
	for (i = 0; i < cnt; i++){
		printf("%s\n", ans[i]);
	}
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 200100
ll OFF;

ll L[MAXN];
ll R[MAXN];
ll sum_left[MAXN];
ll sum_right[MAXN];
ll tri_left[MAXN];
ll tri_right[MAXN];
ll len,N;
ll ans = 0;

ll range_left(ll x, ll y){
	return sum_left[y] - sum_left[x-1];
	// cout<<x<< ' '<<y<<' '<<tri_left[y] - tri_left[x-1] - (x-1) * (sum_left[y] - sum_left[x-1])<<'\n';
	// return tri_left[y] - tri_left[x-1] - (x-1) * (sum_left[y] - sum_left[x-1]);
}

ll range_right(ll x, ll y){
	return sum_right[x] - sum_right[y+1];
	// cout<<x<< ' '<<y<<' '<<tri_right[x] - tri_right[y+1] - (N-x+1) * (sum_right[x] - sum_right[y-1])<<'\n';
	// return tri_right[x] - tri_right[y+1] - (N-x+1) * (sum_right[x] - sum_right[y-1]);
}

int main(){
	cin>>len>>N;
	for (ll i=1;i<=N;++i){
		cin>>L[i];
		R[i] = len-L[i];
		tri_left[i] = tri_left[i-1] + L[i]*i;
		sum_left[i] = sum_left[i-1] + L[i];
	}
	for (ll i=N;i>0;--i){
		sum_right[i] = sum_right[i+1] + R[i];
	}
	// for (ll i=1;i<=N;++i)cout<<tri_left[i]<< ' ';cout<<'\n';
	// for (ll i=1;i<=N;++i)cout<<sum_left[i]<< ' ';cout<<'\n';
	// Firstly consider if we ending on the left
	for (ll lend = 1;lend<N;++lend){
		ll lstart = 1;
		ll rstart = lend + 1;
		ll rend = N;
		ll offset = 0;
		ll dif = (rend - rstart) - (lend - lstart) + 1; // -1 if we ending on the right
		if (dif > 0){
			// Go to right first
			rend -= dif;
			offset = R[rend+1];
		}else if (dif < 0){
			lstart -= dif;
			offset = L[lstart-1];
		}
		ll tot = 0;
		// First bit is the left
		tot = tot + range_left(lstart,lend) * 2 - (L[lend]);
		// cout<<tot<<'\n';
		tot = tot + range_right(rstart,rend) * 2;
		// cout<<tot<<'\n';
		if (dif > 0)tot = tot + offset*2;
		ans = max(ans,tot);
		// cout<<tot<<'\n';

		// cout<<"Left "<<lstart<<' '<<lend<<'\n';
		// cout<<"Right "<<rstart<<' '<<rend<<'\n';
		// cout<<"Offset "<<offset<<'\n';
	}
	// return 0;
	// Firstly consider if we ending on the right
	for (ll lend = 1;lend<N;++lend){
		ll lstart = 1;
		ll rstart = lend + 1;
		ll rend = N;
		ll offset = 0;
		ll dif = (rend - rstart) - (lend - lstart) - 1; // -1 if we ending on the right
		// cout<<"Dif "<<dif<<'\n';
		if (dif > 0){
			// Go to right first
			rend -= dif;
			offset = R[rend+1];
		}else if (dif < 0){
			lstart -= dif;
			offset = L[lstart-1];
		}
		ll tot = 0;
		// First bit is the left
		tot = tot + range_left(lstart,lend) * 2;
		tot = tot + range_right(rstart,rend) * 2 - R[rstart];
		if (dif < 0)tot = tot + offset*2;

		ans = max(ans,tot);
		// cout<<tot<<'\n';

		// cout<<"Left "<<lstart<<' '<<lend<<'\n';
		// cout<<"Right "<<rstart<<' '<<rend<<'\n';
		// cout<<"Offset "<<offset<<'\n';
	}
	ans = max({ans, L[N], R[1]});
	cout<<ans;
}

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

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] p = new int[n];

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

    Arrays.sort(p);
    int sum = 0;
    for (int i = 0; i < k; i++) {
      sum += p[i];
    }
    System.out.println(sum);
  }

}

Measured memory_bytes: 39012
#include<cstdio>
int a[100005];

int abs(int u){ return u>0?u:-u; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    int ans = 0;
    a[0] = a[n+1] = 0;
    for(int i = 0; i <= n; i++){
        ans += abs(a[i]-a[i+1]);
    }
    //printf("ans = %d\n",ans);
    for(int i = 1; i <= n; i++){
        int cur = ans;
        cur -= abs(a[i-1]-a[i]);
        cur -= abs(a[i]-a[i+1]);
        cur += abs(a[i-1]-a[i+1]);
        printf("%d\n",cur);
    }
    
    return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
map<string,int> x;
int main()
{
	ll n,sum=0;
	string a;
	cin >> n;
	while(n--){
		cin >> a;
		if(x[a]==0){
			sum++;
			x[a]++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 19088
import sys
sys.setrecursionlimit(10**6)
def dfs(G,v,p,color):
    cnt=1
    for nv in G[v]:
        if(nv==p):
            continue
        if cnt in liset[v]:
            while(cnt in liset[v]):
                cnt+=1
        liset[v].add(cnt)
        liset[nv].add(cnt)
        dic[str(v)+'t'+str(nv)]=cnt
        dfs(G,nv,v,cnt)
N=int(input())
G=[[] for i in range(N)]
e=[]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
    e.append([a,b])
l=0
for i in range(N):
    l=max(l,len(G[i]))
liset=[set() for i in range(N)]
dic={}
dfs(G,0,-1,0)
print(l)
for i in range(N-1):
    if str(e[i][0])+'t'+str(e[i][1]) in dic:
        print(dic[str(e[i][0])+'t'+str(e[i][1])])
    else:
        print(dic[str(e[i][1])+'t'+str(e[i][0])])

Measured memory_bytes: 92080
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ABC159 {
    public class B {
        static void Main(string[] args) {
            var s = Console.ReadLine();
            bool strongKaibun = IsKaibun(s) &&
                                IsKaibun(s.Substring(0, s.Length / 2)) &&
                                IsKaibun(s.Substring(s.Length / 2 + 1));
            Console.WriteLine(strongKaibun? "Yes" : "No");
        }

        static bool IsKaibun(string source) {
            int centerIndex = source.Length / 2;
            int offset = source.Length % 2 == 1 ? 0 : 1;
            for (int i = 1; i <= centerIndex; i++) {
                if (source[centerIndex - i] != source[centerIndex + i - offset]) return false;
            }
            return true;
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll POW3(ll x,ll n,ll m){
  x%=m;
  if(n==0)return 1;
  if(n%2==0)return POW3(x*x,n/2,m)%m;
  return x*POW3(x,n-1,m)%m;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)//xのm進数でのx^nの位の値
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)//xのn進数での桁数
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)//x!のnで割り切れる回数
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)//xのnで割り切れる回数
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

ll SGS(ll x,ll y, ll m)//1+x+…+x^(y-1)をmで割った余り
{
  if(y==0)return 0;
  if(y%2==0){
    return (1+POW3(x,y/2,m))*SGS(x,y/2,m)%m;
  }
  return (1+x*SGS(x,y-1,m))%m;
}

ll SSGS(ll x,ll y,ll m)//Σ[k=1→y](1+x+…+x^(k-1))をmで割った余り
{
  if(y==0)return 0;
  if(y==1)return 1;
  if(y%2==0){
    return (SSGS(x,y/2,m)*(POW3(x,y/2,m)+1)%m+SGS(x,y/2,m)*y/2%m)%m;
  }
  return (SSGS(x,y-1,m)*x%m+y)%m;
}

int main()
{
  ll n,l;
  cin >> n >> l;
  if(l>=0)printf("%lld",(2*l+n)*(n-1)/2);
  else if(l+n-1<0)printf("%lld",(2*l+n)*(n-1)/2+l-l-n+1);
  else printf("%lld",(2*l+n)*(n-1)/2+l);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<stdio.h>
using namespace std;


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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)


int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    int a[50][50]={0};
    rep(i,n){
        cin>>s[i];
    }
    int b[26]={0};
    rep(i,n){
        rep(k,s[i].size()){
            for(char l='a';l<='z';l++){
                if(s[i][k]==l){
                    a[i][l-'a']=a[i][l-'a']+1;
                }
            }
        }
    }
    
    for(int i=0;i<26;i++){
        int temp=100000;
        for(int k=0;k<n;k++){
            temp=min(a[k][i],temp);
        }
        b[i]=temp;
    }
    
    for(int i=0;i<26;i++){
        if(b[i]){
        while(b[i]){
            char c;
            c='a'+i;
            printf("%c",c);
            b[i]--;
        }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 1e5+5;
const ll M = 1e9+7;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,m,a[maxn];
ll f[maxn];
int main()
{
    fastio();
    cin>>n>>m;
    rep(i,1,m) {int x;cin>>x;a[x] = 1;}
    f[0] = 1;
    rep(i,1,n){
        if(a[i]) continue;
        f[i] = f[i-1];
        if(i>=2) f[i] = (f[i] + f[i-2])%M;
    }
    cout<<f[n]<<endl;
    return 0;
}


Measured memory_bytes: 4784
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  int a[26]={},b[26]={};
  cin >> s >> t;
  for(auto p:s) {
    a[p-'a']++;
  }
  for(auto p:t) {
    b[p-'a']++;
  }
  sort(a,a+26);
  sort(b,b+26);
  for(int i=0; i<26; i++) {
    if(a[i]!=b[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,ok;

int a[maxn];

signed main()
{
    cin>>m>>n;
    for(int i = 1; i <= n; i++) 
    {
        cin>>a[i];
    }
    a[n+1] = a[1]+m;
    int ans = 0,mx = 0;
    for(int i = 2; i <= n+1; i++) 
    {
        ans += (a[i]-a[i-1]);
        mx = max(mx,(a[i]-a[i-1]));
    }
    cout<<ans-mx<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
long long int subCount(long long int arr[], long long int n, long long int k)
{
    map<long long int, long long int> mod;
    long long int cumSum = 0;
    for (long long int i = 0; i < n; i++) {
        cumSum += arr[i];
        mod[((cumSum % k) + k) % k]++;
    }
    long long int result = 0;
    for (auto i : mod)
        if (i.second > 1)
            result += (i.second * (i.second - 1)) / 2;
    result += mod[0];
    //cout << result << " ";
    return result;
}
int main()
{
    long long int n, k;
    cin >> n >> k;
    long long int arr[n + 1];
    for(long long int i = 0; i < n; i++){
      cin >> arr[i];
    }
    cout << subCount(arr, n, k) << endl;
    return 0;
}

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

bool used[8];
int k[8][8];
int n,m,ans=0;
bool check(){ //すべて訪問済みか
  for(int i=0;i<n;i++){
    if(!used[i]) return false;
  }
  return true;
}
void dfs(int a){
  used[a]=true;
  for(int i=0;i<n;i++){
    if(!used[i]&&k[a][i]){
      dfs(i);
    }
  }
  if(check()) ans++;
  used[a]=false;
  return;
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b; a--,b--;
    k[a][b]=k[b][a]=1;
  }
  dfs(0);
  cout<<ans<<"\n";

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int count =0;
        ArrayList<Integer> list = new ArrayList<>();
        for(int i=0; i<S.length(); i++){
            if(S.charAt(i) == 'B'){
                if(list.size()>0){
                list.remove(count-1);
                count--;
                }
            }else if(S.charAt(i) == '0'){
                list.add(0);
                count++;
            }else if(S.charAt(i) == '1'){
                list.add(1);
                count++;
            }
        }
        
        for (int i = 0 ; i < list.size() ; i++){
            System.out.print(list.get(i));
        }
    }
}


Measured memory_bytes: 35508
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        map<string,int> m;
        rep(i,n){
            string s;cin>>s;
            m[s]=1;
        }
        cout<<m.size();
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 19140
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val nList = Array(n) { false }
    (0 until k).forEach { _ ->
        val di = readLine()!!.toInt()
        val ai = readLine()!!.split(' ').map { it.toInt() }
        ai.forEach {
            nList[it - 1] = true
        }
    }
    println(nList.filter { it.not() }.size)
}


Measured memory_bytes: 38980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,K;
vector<int> G[2000];
int sz[2000][2];
void dfs(int v,int p,int d){
	if(K%2==1&&p==-1){
		int sum=0;
		int mx=0;
		for(int u:G[v]) if(u!=p){
			dfs(u,v,d+1);
			sum+=sz[u][0];
			chmax(mx,sz[u][1]-sz[u][0]);
			sz[v][0]=sum+mx+1;
		}
		return;
	}
	sz[v][0]=sz[v][1]=0;
	for(int u:G[v]) if(u!=p){
		dfs(u,v,d+1);
		sz[v][0]+=sz[u][0];
		sz[v][1]+=sz[u][1];
	}
	if(d<=K/2) sz[v][0]++;
	if(d<=K/2+1) sz[v][1]++;
}
int main(){
	cin>>N>>K;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	int ans=0;
	rep(r,N){
		dfs(r,-1,0);
		chmax(ans,sz[r][0]);
	}
	cout<<N-ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f(i,a,b) for(i=a;i<=b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define scan1(x) scanf("%lld",&x)
#define scan2(x,y) scanf("%lld %lld",&x,&y)
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define print(x) printf("%lld\n",x)
#define ff first
#define ss second
using namespace std;


int main(){
    ll n,i,j,k;
    scan2(n,k);
    ll h[n+1];
    f(i,1,n)
    scan1(h[i]);
    
    vector<ll> dp(n+1);
    
        f(i,1,n){
            ll ans=INT_MAX;
            for(ll j=i-1,cnt=1;j>0&&cnt<=k;cnt++,j--)
            ans=min(dp[j]+abs(h[i]-h[j]),ans);
            dp[i]=(ans==INT_MAX)?0:ans;
        }
        cout<<dp[n]<<"\n";
    
    
}

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

const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

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

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

    int maxDis = k-a[n-1] + a[0];

    for (int i = 1; i < n; ++i) {
        maxDis = max(maxDis, a[i]-a[i-1]);
    }

    cout << k - maxDis << "\n";
    return 0;
}

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

int main() {
  int a, b;
  int s[5];
  while(1) {
    for(int i=0; i<5; i++) {
      cin >> a >> b;
      if(a+b == 0) return 0;
      
      s[i] = a+b;
    }
    int num;
    int temp=-987654321;
    for(int i=0; i<5; i++) {
      temp = max(temp, s[i]);
      if(s[i] == temp) num = i;
    }
    cout << (char)('A'+num) << " " << temp << endl;
  }
  
  return 0;
}

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


#define ll long long
#define pb push_back

#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const ll inf = 2e18+5;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    ll h;
    cin>>h;
    /*
    ll p=1;
    while(p<=h){
        p*=2;
        
    }
    cout<<p-1; 
    OR */

    //__built_inctzll(n); //for trailing zeroes   
    //__built_inclzll(n); //for leading zeroes  

    ll c=64-__builtin_clzll(h);
    ll ans = 1LL << c;
    ans=ans-1;
    cout<<ans;
    return 0;
}   

Measured memory_bytes: 256
def main():
    N, M = (int(x) for x in input().split())
    SC = [list(map(int, input().split())) for _ in range(M)]
    for i in range(10 ** N):
        _str = str(i)
        k = True
        if len(_str) == N:
            for j in range(M):
                if _str[SC[j][0]-1] != str(SC[j][1]):
                    k = False
            if k:
                return print(i)
    return print('-1')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

namespace B___Collatz_Problem
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            var list = new List<int> { };

            list.Add(S);

            for (int i = 0; ; i++)
            {
                if((list[i] % 2) == 0)
                {
                    list.Add(list[i] / 2);
                }
                else
                {
                    list.Add(list[i] * 3 + 1);
                }
                if (list.IndexOf(list[i])!=i)
                {
                    Console.WriteLine(i+1);
                    break;
                }
            }
        }
    }
}

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

//Swimming Jam
public class Main{

	class R implements Comparable<R>{
		int speed, lap, now;
		public R(int speed, int lap) {
			this.speed = speed;
			this.lap = lap;
		}
		public int compareTo(R o) {
			return o.speed-speed;
		}
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			R[] r = new R[n];
			for(int i=0;i<n;i++)r[i]=new R(sc.nextInt(), sc.nextInt()*2);
			Arrays.sort(r);
			int[][] lane = new int[n][150001];
			int[][] begin = new int[n][501];
			int t = 0, res = 0;
			for(int i=1;i<=r[0].lap;i++){
				begin[0][i] = t;
				for(int j=0;j<r[0].speed;j++){
					lane[0][t++] = i;
				}
				res = Math.max(res, t);
			}
			//Ú
			for(int i=1;i<n;i++){
				t = 0;
				for(int j=1;j<=r[i].lap;j++){
					begin[i][j] = t;
					for(int k=0;k<r[i].speed;k++){
						lane[i][t++] = j;
					}
					int max = t;
					for(int k=0;k<i;k++){
						if(lane[k][t-1]==0)continue;
						if(j%2!=lane[k][t-1]%2)continue;
						int x = lane[k][t-1];
						if(begin[i][j]<=begin[k][x])continue;
						int pos = t;
						while(lane[k][pos]==x)pos++;
						max = Math.max(max, pos);
					}
					while(t<max)lane[i][t++] = j;
					res = Math.max(res, t);
				}
			}
			System.out.println(res);
		}
	}

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

Measured memory_bytes: 57000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  int money = 0;
  cin >> A >> B;
  if(A == 1){
    if(B == 1){
      money = 1000000;
    }else if(B == 2){
      money = 500000;
    }else if(B == 3){
      money = 400000;
    }else{
      money = 300000;
    }
  }else if(A == 2){
    if(B == 1){
      money = 500000;
    }else if(B == 2){
      money = 400000;
    }else if(B == 3){
      money = 300000;
    }else{
      money = 200000;
    }
  }else if(A == 3){
    if(B == 1){
      money = 400000;
    }else if(B == 2){
      money = 300000;
    }else if(B == 3){
      money = 200000;
    }else{
      money = 100000;
    }
  }
  
  if(B == 1){
    if(A == 1){
      money = 1000000;
    }else if(A == 2){
      money = 500000;
    }else if(A == 3){
      money = 400000;
    }else{
      money = 300000;
    }
  }else if(B == 2){
    if(A == 1){
      money = 500000;
    }else if(A == 2){
      money = 400000;
    }else if(A == 3){
      money = 300000;
    }else{
      money = 200000;
    }
  }else if(B == 3){
    if(A == 1){
      money = 400000;
    }else if(A == 2){
      money = 300000;
    }else if(A == 3){
      money = 200000;
    }else{
      money = 100000;
    }
  }
  
  if(A>3 && B>3){
    money =0;
  }
  cout << money <<endl;
}

Measured memory_bytes: 256
primes = Enumerator.new {|y|
	ps = [2]
	cp = 3
	y << 2
	while true 
		if ps.take_while {|x|
			x*x <= cp
		}.all? {|x|
			cp % x != 0
		}
			y << cp
			ps.push cp
		end
		cp+=2
	end
}
cache = Enumerator.new {|y|
	primes.inject {|a,b|
		y << a
		a+b
	}
}.take(10000).to_a
while (n = gets.to_i)!= 0
	puts cache[n-1]
end 

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "YES";
const string NO = "NO";

int main(){
    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    int t;
    cin >> t;
    if (w >= v) {
        cout << NO << endl;
        return 0;
    }
    int val = (abs(b-a) + (v-w-1)) / (v - w);
    if (val <= (ll)(t)) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3636
#pragma warning(disable:4996)
#include<stdio.h>

int main(void) {
	int k, h, count = 0, n;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &h);
		if (h >= k) {
			++count;
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
  int n;
  char s[100][11],c;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s",s[i]);
    if(i>0&&c!=s[i][0]){
      printf("No\n");
      return 0;
    }
    for(int j=0;j<i;j++)
      if(strcmp(s[i],s[j])==0){
        printf("No\n");
        return 0;
      }
    c=s[i][strlen(s[i])-1];
  }
  printf("Yes\n");
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

struct edge{lint to;double cost;};
lint V;
vector<edge> G[2000]; // MAX_V
double d[2000]; // MAX_V
void dijkstra(lint S){
  priority_queue<plint,vector<plint>,greater<plint>> que;
  fill(d,d+V,LINF);
  d[S]=0;
  que.push(plint(0,S));
  while(!que.empty()){
    plint p=que.top();
    que.pop();
    lint v=p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(plint(d[e.to],e.to));
      }
    }
  }
}

int main(void){
    lint sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int N;
    cin >> N;
    V=N+2;
    lint X[V],Y[V],R[V];
    X[0]=sx,Y[0]=sy,R[0]=0;
    X[V-1]=gx,Y[V-1]=gy,R[V-1]=0;
    rep(i,N) cin >> X[i+1] >> Y[i+1] >> R[i+1];
    for(int i=0;i<V;i++) for(int j=i+1;j<V;j++){
        double dis=sqrt(pow(X[i]-X[j],2)+pow(Y[i]-Y[j],2));
        double leng=max(0.0,dis-R[i]-R[j]);
        edge in;
        in.to=j,in.cost=leng;
        G[i].push_back(in);
        in.to=i;
        G[j].push_back(in);
    }
    dijkstra(0);
    cout << d[V-1] << endl;
}

Measured memory_bytes: 22128
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double xa, ya, ra, xb, yb, rb;
	int N;
	cin >> N;
	
	for (int i=0; i<N; i++) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		
		double D = sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
		if ( D > ra + rb ) {
			cout << "0" << endl;
		}
		else if ( abs(ra - rb) <= D ) {
			cout << "1" << endl;
		}
		else {
			if (rb < ra) {
				cout << "2" << endl;
			}
			else {
				cout << "-2" << endl;
			}
		}
	}
	
		
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 8 || b > 8 || a > 2 * b || b > 2 * a) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}


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

int days(int y, int m, int d)
{
    if (m < 3) {
        --y;
        m += 12;
    }
    return 365 * y + y / 4 - y / 100 + y / 400 + (306 * (m + 1)) / 10 + d - 428;
}

int main() {
    int y1, m1, d1, y2, m2, d2;
    while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
        if (y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0) {
            break;
        }
        cout << days(y2,m2,d2) - days(y1,m1,d1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int A,B,C; cin >> A >> B >> C;
    if (C>B){
        cout << 2*B + min(C-B,A) + 1*((C-B)>A); rn 0;
    }
    else if (C==B){
        cout << 2*B; rn 0;
    }
    else{
        cout << C + B; rn 0;
    }
    
    rn 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, M;
    cin >> N >> M;
    if (N == 1 || M == 1) {
        if (N == M) {
            cout << 1 << endl;
            return 0;
        }
        cout << N * M - 2 << endl;
        return 0;
    }
    cout << max((M - 2) * (N - 2), int64_t(0)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,x,ans;
	while(1){
	    ans=0;
	    cin >> x>> n;
	    if(n==0&&x==0)break;
	    fro(i,1,n/3){
	        if(x<=n/3)break;
	        fro(j,i+1,min(x,(n-i+1)/2)){
	            if(n-i-j<=x){
                  ans++;           
                }
	        }
	    }
	    cout << ans << endl;
	}
}


Measured memory_bytes: 3088
a,b,c,d = list(map(int,list(input())))
if a + b + c + d == 7:
 print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
elif a + b + c - d == 7:
 print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
elif a + b - c + d == 7:
 print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
elif a - b + c + d == 7:
 print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
elif a - b - c + d == 7:
 print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
elif a - b + c - d == 7:
 print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
elif a + b - c - d == 7:
 print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
elif a - b - c - d == 7:
 print("{0}-{1}-{2}{3}=7".format(a,b,c,d))








Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int f = 0, b = 0;
  for (int i = 0; i < n; ++i)
  {
    if (s[i] == '(')
    {
      f++;
    }
    else
    {
      b++;
      if (f)
        f--, b--;
    }
  }
  for (int i = 0; i < b; ++i)
    cout << '(';
  cout << s;
  for (int i = 0; i < f; ++i)
    cout << ')';
  cout << endl;

  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll sum2[1000005];

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  vector<ll> list1(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list1[i] = v;
  }

  vector<ll> list2(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list2[i] = v;
  }

  vector<ll> list3(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list3[i] = v;
  }

  sort(list1.begin(), list1.end());
  sort(list2.begin(), list2.end());
  sort(list3.begin(), list3.end());

  // sum2;

  ll sum = 0;

  for (ll i2 = 0; i2 < list2.size(); i2++) {
    ll v2 = list2[i2];
    auto ite = upper_bound(list3.begin(), list3.end(), v2);
    ll s = list3.end() - ite;
    sum2[i2] = s;
    // cout << "s:" << s << endl;
  }
  for (ll i = N - 2; i >= 0; i--) {
    sum2[i] += sum2[i + 1];
  }

  for (ll i1 = 0; i1 < list1.size(); i1++) {
    ll v = list1[i1];

    auto ite = upper_bound(list2.begin(), list2.end(), v);
    ll index = ite - list2.begin();  // 先頭までの距離
    ll plus = sum2[index];
    sum += plus;

    // cout << "index:" << index << endl;
    // cout << "plus:" << plus << endl;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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(){
    string s1,s2,s3; cin >> s1 >> s2 >> s3;
    string ans="";
    ans+=toupper(s1[0]);
    ans+=toupper(s2[0]);
    ans+=toupper(s3[0]);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   string s;
   cin >> s;

   if(s[0] == s[1] && s[0] != s[2] && s[2] == s[3])
      cout << "Yes" << endl;
   else if(s[0] == s[2] && s[0] != s[1] && s[1] == s[3])
      cout << "Yes" << endl;
   else if(s[0] == s[3] && s[0] != s[1] && s[1] == s[2])
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,c = map(int, input().split())
    stc = [list(map(int, input().split())) for _ in range(n)]
    rokuga = [[0]*c for _ in range(2*10**5+10)]

    for s,t,ch in stc:
        for i in range(int((s-0.5)*2), 2*t):
            rokuga[i][ch-1] = 1
    
    res = 0
    for i in range(1, 2*10**5+10):
        res = max(res, sum(rokuga[i]))
    print(res)

if __name__ == '__main__':
    main()



Measured memory_bytes: 125536
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m),c(n,0);
  for(int i=0;i<m;i++)
    cin>>a.at(i)>>b.at(i);
  for(int i=0;i<m;i++){
    c.at(a.at(i)-1)++;
    c.at(b.at(i)-1)++;
  }
  for(int i=0;i<n;i++)
    cout<<c.at(i)<<endl;
}

Measured memory_bytes: 256
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int x;

cin>>n>>x;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
int b=0;
int c=0;
int i;
for(i=0;i<n;i++)
{c+=a[i];
if(x>=c)
b++;
if(x<c)
break;

}

if(i==n)
{
if(x!=c)
cout<<b-1;
else
cout<<b;}
else
cout<<b;
}


Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();

        int array[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


        System.out.println(array[a - 1]);

    }


}

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

int l[10];

int main(void){
	int n, sum=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> l[i];
		sum += l[i];
	}
	sort(l, l+n);
	sum -= l[n-1];
	if(l[n-1]<sum) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,ba=0;
	cin>>n;
	for(long long t=1;t<=n;t++)
	{
		if(t%3!=0&&t%5!=0)
		{
			ba+=t;
		}
	}
	cout<<ba;
	return 0;
} 

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


void solve(long long N, std::string S) {
    char last = ' ';
    int res = 0;
  for (int i = 0; i < N; i++) {
      if (S[i] != last) res++;
      last = S[i];
  }
  cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main() {
	
	int n, a = 0, ans = 0, tmp;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &tmp);
		a |= tmp;
	}
	while (!(a & (1 << ans)))++ans;
	printf("%d\n", ans);
	
	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll n,m;
vector<ll> a;

int main(){
    int n;
    cin>>n;
    ll ans[26]={};
    rep(i,n){
        string s;ll c[26]={};
        cin>>s;
        if(i==0){
            for(auto x:s){
                ans[x-'a']++;
            }
        }
        for(auto x:s){
            c[x-'a']++;
        }
        for(int j=0;j<26;j++){
            ans[j]=min(c[j],ans[j]);
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<ans[i];j++)
        cout<<(char)('a'+i);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){ 
	int N;
	cin>>N;
	int Cx;
	int Cy;
	int H;
	int flag=0;
	int u;
	
	int x[101],y[101],h[101];
	for(int i=1;i<=N;i++){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]!=0)
			u=i;
	}

	for(int Cx=0;Cx<=100;Cx++)
		for(int Cy=0;Cy<=100;Cy++){
			flag=0;
			int zeta=abs(x[u]-Cx)+abs(y[u]-Cy)+h[u];
			
			for(int k=1;k<=N;k++){	
				if(h[k]==0)
					continue;	
				if(zeta!=abs(x[k]-Cx)+abs(y[k]-Cy)+h[k])
					flag=1;

			}
			if(flag==0){
				int flag2=1;
				H=max(abs(x[u]-Cx)+abs(y[u]-Cy)+h[u],1);
				for(int k=1;k<=N;k++)
					if(h[k]==0)
						if(H>abs(x[k]-Cx)+abs(y[k]-Cy))
							flag2=0;
				if(flag2){
					cout<<Cx<<" "<<Cy<<" "<<H; 
					return 0;
				}
			}
		}

	return 0;		
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b;
    cin >> a >> b;
    if(a*b == 2) cout << 3 << endl;
    if(a*b == 3) cout << 2 << endl;
    if(a*b == 6) cout << 1 << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = l[i];
      int b = l[j];
      int idr = lower_bound(l.begin(), l.end(), a + b) - l.begin();
      int idl = j + 1;
      int num = idr - idl;
      ans += num;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#define N 251
void sum(int);
void num(int);
void tum(int);
int n;
int rum[N];
int main(){
    
    scanf("%d",&n);
    int i;
    
    for(i=1;i<=n;i++)scanf("%d",&rum[i]);
    for(i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,rum[i]);
        sum(i);
        num(i);
        tum(i);
        printf("\n");
    }
    return 0;
}

void sum(int i){
    int b=i/2;
    if(b>=1)
    {
        printf("parent key = %d, ",rum[b]);
    }
}
void num(int i){
    if(2*i<=n)
    {
        printf("left key = %d, ",rum[2*i]);
        
    }
}
void tum(int i){
    if(2*i+1<=n){
        printf("right key = %d, ",rum[2*i+1]);
        
    }
}        

  



Measured memory_bytes: 2108
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
#品物は0～N-1と考えるので注意！

DP = [0]*(W+1) #0~W
#各iにつき、残り重さがWの時の最大価値をDPに入れる


#i=N-1までいった時のmax(DP)が答え
for i in range(0, N, 1): #0~N-1
  w, v = wv[i]
  #残りwei(W-DPの2個目の添字)がw未満の場合入れられない
  #入れない場合は変えなければいい
  for nw in range(W, w-1, -1):
    iretaV = DP[nw-w] + v
    if iretaV > DP[nw]:
      DP[nw] = iretaV

print(max(DP))

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

class Osa_k {
private:
    int n;
    vector<int> factor;
public:
    Osa_k(int _n):n(_n) {
        factor.assign(n, 0);
        iota(factor.begin(), factor.end(), 0);
        for(int i = 2; i < n; i++) {
            if(factor[i] != i)continue;
            for(int j = i + i; j < n; j += i) factor[j] = i;
        }
    }

    vector<pair<int,int>> fact(int v) {
        unordered_map<int, int> ret;
        while(v != factor[v]) {
            ret[factor[v]]++;
            v /= factor[v];
        }
        if(v != 1)ret[v]++;
		vector<pair<int,int>> t;
		for(auto i : ret)t.push_back(i);
        return t;
    }

    vector<int> divisor(int v) {
        vector<int> que = {1};
        vector<pair<int,int>> a = fact(v);
        for(auto i : a) {
            int num = 1;
            vector<int> nxt;
            for(int j = 0; j <= i.second; j++) {
                int m = que.size();
                for(int k = 0; k < m; k++)nxt.push_back(num * que[k]);
                num *= i.first;
            }
            swap(que, nxt);
        }
        sort(que.begin(), que.end());
        return que;
    }

}fact(1000001);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> in(1000001);
    for(int i = 0; i < n; i++)cin >> a[i], in[a[i]]++;
    int sum = 0;
 
    for(int i = 0; i < n; i++) {
        vector<int> num = fact.divisor(a[i]);
        int res = 0;
        for(int j = 0; j < (int)num.size(); j++) {
            res += in[num[j]];
        }
        if(res == 1)sum++;
    }
    cout << sum << '\n';
}

Measured memory_bytes: 11876