akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int atkCountA = (C+B-1) / B;
    int atkCountC = (A+D-1) / D;

    bool ans = (atkCountA <= atkCountC);
    cout << YesNo(ans) << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
typedef long long ll;



map<ll,ll> pf(ll n){
    map<ll,ll> mp;
    int i=2;
    while(i<=sqrt(n)){
        if(n%i==0){
            mp[i]++;
            n/=i;
            continue;
        }
        i++;
    }
    mp[n]++;
    return mp;
}

int main(){
    ll n;cin>>n;
    auto mp = pf(n);
    ll ans=0;
    for(auto x:mp){
        ll p=x.first,e=x.second;
        if(p==1) continue;
        ll n=(-1+sqrt(1+8*e+1))/2;
        if(n*(n+1)>2*e) n--;
        ans+=n;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define EPS 1e-12

struct Node {
	double t;
	double rest;
	int x;
};

bool operator >(Node& n1, Node& n2) {
	return n1.t > n2.t;
}

typedef long long ll;

int main() {
	int N, K, T, U, V, L; cin >> N >> K >> T >> U >> V >> L;
	vector<int> d(N);
	for (int i = 0; i < N; ++i) {
		cin >> d[i];
	}
	d.push_back(L);

	ll rest = 0;
	int x = 0;
	ll vl = 0, ul = 0;
	for (int i = 0; i < N+1; ++i) {
		int dx = d[i]-x;
		if (rest >= dx) {
			vl += dx;
			rest -= dx;
		}
		else {
			vl += rest;
			ul += dx-rest;
			rest = 0;
		}

		rest += (ll)T * V;
		if (rest >= (ll)(K+1) * T * V) rest = (ll)(K+1) * T * V;

		x = d[i];
	}
	printf("%.10f\n", (double)((long double)vl/V + (long double)ul/U));
}

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

public class Main {

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


		while(true){
			int n=sc.nextInt();
			int m=sc.nextInt();

			if(n+m==0) break;

			int taro[]=new int[n];
			int hana[]=new int[m];
			int tsum=0,hsum=0;

			for(int i=0; i<n; i++){
				taro[i]=sc.nextInt();
				tsum+=taro[i];
			}
			for(int i=0; i<m; i++){
				hana[i]=sc.nextInt();
				hsum+=hana[i];
			}

			Arrays.sort(taro);
			Arrays.sort(hana);
			int k;
			boolean f=false;

			if((tsum-hsum)%2==0){
				if(tsum<hsum){

					k=(hsum-tsum)/2;

					for(int i=0; i<m; i++){
						if(f) break;
						for(int j=0; j<n; j++){
							if(f) break;
							
							if(hana[i]-taro[j]==k){
								f=true;
								System.out.println(taro[j]+" "+hana[i]);
							}
							else if(hana[i]<taro[j]) break;
						}
					}
				}
				else{//hsum<=tsum
					//if((tsum-hsum)%2!=0) break;
					k=(tsum-hsum)/2;

					for(int i=0; i<n; i++){
						if(f) break;
						for(int j=0; j<m; j++){
							if(f) break;
							
							if(taro[i]-hana[j]==k){
								f=true;
								System.out.println(taro[i]+" "+hana[j]);
							}
							else if(taro[i]<hana[j]) break;
						}
					}
				}//else
			}
			//System.out.println(f+" "+tsum+" "+hsum);
			if(!f) System.out.println("-1");
		}

	}

}

Measured memory_bytes: 21040
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long long a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    
    if(c > a + b)
    {
        if((long long)4 * a * b < (c - a - b) * (c - a - b))printf("Yes");
        else printf("No");
    }
    else
    {
        printf("No");
    }
    
}


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

typedef long long ll;
const int maxn=2*(18+2);
int n;
char s[maxn],t[maxn];
vector<int> a,b;
ll ans;

void dfs(int pos){
	if(pos>=n){
		static int dp[20][20];
		for(int i=0;i<=a.size();++i)
			for(int j=0;j<=b.size();++j)
				dp[i][j]=0;
		dp[0][0]=1;
		for(int i=0;i<=a.size();++i)
			for(int j=0;j<=b.size();++j){
				if(i<a.size()&&t[i+j]==a[i])
					dp[i+1][j]+=dp[i][j];
				if(j<b.size()&&t[i+j]==b[j])
					dp[i][j+1]+=dp[i][j];
			}
		ans+=dp[a.size()][b.size()];
		return;
	}
	a.push_back(s[pos]);
	dfs(pos+1);
	a.pop_back();
	b.push_back(s[pos]);
	dfs(pos+1);
	b.pop_back();
}

int main(){
	cin>>n;
	cin>>s;
	for(int i=0;i<n;++i)
		t[i]=s[2*n-1-i];
	dfs(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  map<int,bool> mp;
  rep(i,n){
    int a; cin>>a;
    if(mp[a]) mp[a]=0;
    else mp[a]=1;
  }
  int sum=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(itr->sc) sum++;
  }
  cout<<sum<<endl;

  return 0;
}


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

int a[200];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];
    int count = 0;
    while (true) {
        for (int i = 0; i < N; i++)
            if (a[i] % 2 == 0)
                a[i] /= 2;
            else
                goto END;
        count++;
    }
END:
    cout << count << endl;
}


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

int main()
{
    unsigned W, H;
    std::cin >> W >> H;
    unsigned s[1000][1000] = {};
    for(unsigned i = 0; i != H; ++i)
    {
        for(unsigned j = 0; j != W; ++j)
        {
            std::cin >> s[i][j];
        }
    }
    int diff = 0;
    for(unsigned i = 0; i < H; i++)
    {
        if(s[i][0])
        {
            diff++;
        }
        else
        {
            diff--;
        }
    }
    if(diff > 1 || diff < -1)
    {
        std::cout << "no\n";
        return 0;
    }
    diff = 0;
    for(unsigned i = 0; i < W; i++)
    {
        if(s[0][i])
        {
            diff++;
        }
        else
        {
            diff--;
        }
    }
    if(diff > 1 || diff < -1)
    {
        std::cout << "no\n";
        return 0;
    }
    for(unsigned i = 1; i != H; ++i)
    {
        for(unsigned j = 1; j != W; ++j)
        {
            if((s[i - 1][j - 1] + s[i - 1][j] + s[i][j - 1] + s[i][j]) % 2 != 0)
            {
                std::cout << "no\n";
                return 0;
            }
        }
    }
    std::cout << "yes\n";
}


Measured memory_bytes: 7004
N,K=map(int, input().split())
S=input()
comp=[]
tmp=""

for i in range(N):
  if tmp=="":
    tmp=S[i]
    cnt=1
  else:
    if S[i]==tmp:
      cnt +=1
      
  if S[i]!=tmp:
    comp.append([tmp,cnt])
    tmp=S[i]
    cnt=1
  if i==N-1:
    comp.append([tmp,cnt])
  
ans=0  
for run in comp:
  ans += run[1]-1
ans += K*2
ans = min(ans,N-1)
print(ans)

Measured memory_bytes: 13300
#include <stdio.h>
int n;
int count=0;

void Process(int A[ ], int n){
	int i;
	for(i=0;i<n-1;i++)
		printf("%d ",A[i]);
	printf("%d\n",A[i]);
}


void SelectionSort(int A[ ], int n){
	int i,j,temp,min;
	for(i=0;i<n-1;i++){
		min=i;
		for(j=i+1;j<n;j++){
			if(A[j] < A[min]){
				min = j;
			}
		}
		if(A[i]!=A[min]){
		temp = A[i];
		A[i] = A[min];
		A[min] = temp;
		count++;
	}
	}
}


int main(void){
	int i;
	scanf("%d",&n);
	int A[100];
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	
	SelectionSort(A, n);
	Process(A, n);

	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 1764
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

struct element
{
	int b;
	int c;
};

bool operator<(const element &a, const element &b)
{
	return a.c > b.c;
}

element input[100005];
int builded[100005];
int original[100005];

int concat[200010];

int main()
{
	int N, M;

	scanf("%d %d", &N, &M);

	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &original[i]);
		concat[i] = original[i];
	}

	for (int i = 0; i < M; ++i)
	{
		scanf("%d %d", &input[i].b, &input[i].c);
	}

	sort(input, input + M);

	int cur_sz = 0;

	for (int i = 0; i < M; ++i)
	{
		if (cur_sz + input[i].b >= N)
		{
			for (int j = 0; j < N - cur_sz; ++j) builded[j] = input[i].c;
			break;
		}
		for (int j = 0; j < input[i].b; ++j) builded[N - cur_sz - 1 - j] = input[i].c;
		cur_sz += input[i].b;
	}

	for (int i = 0; i < N; ++i) concat[N + i] = builded[i];

	sort(concat, concat + 2 * N, [&](const int &a, const int &b) {return a > b; });

	long long ans = 0LL;

	for (int i = 0; i < N; ++i) ans += concat[i];

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 2560
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

x,n = na()
p = na()
q = [i for i in range(-1,102) if i not in p]
r = []

for i in range(len(q)):
    r.append(abs(q[i]-x))

if n == 0:
    print(x)
    exit()

k = min(r)
if x-k in q:
    print(x-k)
else:
    print(x+k)


Measured memory_bytes: 9248
N, M = gets.chomp.split(" ").map(&:to_i)
X = gets.chomp.split(" ").map(&:to_i).sort

if N < M then
  d = Array.new(M-1)
  (0...M-1).each{|i| d[i] = X[i+1] - X[i]}

  puts d.sort[0, M-N].inject(:+)
else
  puts 0
end


Measured memory_bytes: 11888
#include<bits/stdc++.h>
using namespace std;
int a[100005],n,p[100005],b[100005],m,t1,t2,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++)
		p[i]=__gcd(p[i-1],a[i]);
	b[n]=a[n];
	for(int i=n-1;i>=1;i--)
		b[i]=__gcd(b[i+1],a[i]);
	for(int i=1;i<=n;i++)
		ans=max(ans,__gcd(p[i-1],b[i+1]));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
//#pragma optimize GCC("O3")
typedef long long ll;
typedef long double ld;
using namespace std;

ll divup(ll a, ll b)
{
	if (a%b == 0) return a / b;
	return a / b + 1;
}
bool check(ll maxi, vector<ll>&a, ll k)
{
	for (int i = 0; i < a.size(); i++)
	{
		if (a[i] <= maxi) continue;
		k -= divup(a[i], maxi)-1;
	}
	if (k < 0) return false;
	return true;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll lo = 1, hi = 1000000079;
	while (lo + 1 < hi)
	{
		ll mi = (lo + hi) >> 1;
		if (check(mi, a, k))
			hi = mi;
		else
			lo = mi;
	}
	if (check(lo, a, k)) cout << lo << endl;
	else cout << hi << endl;
	return 0;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll h, w;
  cin >> h >> w;
  ll a, b;
  cin >> a >> b;

  ll ans = h * w - (a * b + a * (w - b) + b * (h - a));
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,k,x,y,i,fee;
  fee = 0;
  scanf("%d %d %d %d",&n,&k,&x,&y);
  for(i=1;i<=k;i++){
    fee += x;
    if(i==n) { printf("%d\n",fee); return 0; }
  }
  for(i=k+1;i<=n;i++){
    fee += y;
  }
  printf("%d\n",fee);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N,M,Asum=0,tmp;
  cin >> N >> M;
  vector<int> A(M);
  for(int i=0;i<M;i++) {
    cin >> tmp;
    Asum = Asum+tmp;
  }
  if(N-Asum<0) cout << -1 << endl;
  else cout << N-Asum << endl;
}

Measured memory_bytes: 3664
def resolve():
    (N,M) = (int(i) for i in input().split())
    AB = [[int(j) for j in input().split()] for i in range(N)]
    AB.sort()
    cost=0
    for i in AB:
        if i[1] >= M:
            cost += M*i[0]
            print(cost)
            break
        else:
            cost += i[0]*i[1]
            M -= i[1]


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 60504
# https://atcoder.jp/contests/abc144/tasks/abc144_c C - Walk on Multiplication Table
N=int(input())
S_List=[i for i in range(1,int(N**0.5)+1,1) if N % i ==0]

Answer = 10**12
for i in range(len(S_List)):
    Current_Answer = int(S_List[i] + (N/S_List[i]) -2)
    if Current_Answer < Answer:
        Answer = Current_Answer

print(Answer)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(a-b>=0) cout << "delicious" << "\n";
  else if(abs(a-b)<=x) cout << "safe" << "\n";
  else cout << "dangerous" << "\n";
  return 0;
}                                                                                       

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

int main() {
    int d;
    cin >> d;

    string s;
    s = "Christmas";

    if (d < 25) {
        for (int i = 0; i < 25 - d; i ++) {
            s += " Eve";
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256
R,G,B,N=map(int,input().split())
total=0
for i in range(int(N/R)+1):
    tmp_R=N-R*i
    if tmp_R==0:
        total+=1
    else:
        for j in range(int(tmp_R/G)+1):
            tmp_G=tmp_R-G*j
            if tmp_G==0:
                total+=1
            else:
                if tmp_G%B==0:
                    total+=1
print(total)

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

using namespace std;

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

    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'U' || s[i] == 'D') continue;
        else if (s[i] == 'R' && i % 2 == 0) continue;
        else if (s[i] == 'L' && i % 2 == 1) continue;
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  REP(i, n){
    cin >> a[i];
    mp[a[i]]++;
  }
  set<int> st;
  for(auto i : mp){
    if(i.second == 1) st.insert(i.first);
  }
  for(auto i : mp){
    for(int j = 2 * i.first; j <= 1000000; j += i.first){
      if(mp.count(j)){
        st.erase(j);
      }
    }
  }
  cout << st.size() << endl;
}

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

using namespace std;

int top, Stack[1000];

void push (int x) {
  top++;
  Stack[top] = x;
}

int pop () {
  top--;
  return Stack[top+1];
}

int main () {
  int a, b;
  top = 0;
  string s;

  while (cin >> s) {
    if (s == "+") {
      a = pop();
      b = pop();
      push(a+b);
    } else if (s == "*") {
      a = pop();
      b = pop();
      push(a*b);
    } else if (s == "-") {
      b = pop();
      a = pop();
      push(a-b);
    } else {
      push(stoi(s));
    }
  }

  cout << pop() << endl;

}

Measured memory_bytes: 3192
s = [(input().split()) for i in range(2)]
N = int(s[0][0])
t = s[1]
a = 1000000
b = 1
for i in range(N - 1):
    a = min(a,int(t[i]))
    c = int(t[i + 1])
    if a >= c:
        b = b + 1
print(b)

Measured memory_bytes: 17940
while True:
    h, w = map(int, input().split())
    if h == w == 0: break
    for c in ['\n' if y == w else '#' if (x+y) % 2 == 0 else '.' for x in range(0,h) for y in range(0, w + 1)]: print(c, end='')
    print('')

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

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;
}

// void swap(int x, int y){
//     int sub_x = x;
//     x = y;
//     y = sub_x;
//     cout << x << y << endl;
// }

int main(){
    int a, b, c; cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

long long pow(int a, int b)
{
    long long ans = 1;
    for (int i = 0; i < b; i++)
    {
        ans *= a;
    }
    
    return ans;
}

int main(void)
{
    int N, P;
    cin >> N >> P;

    // event ... true
    // odd ... false
    vector<int> a(N, 0);

    int even_count = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        if(a[i] % 2 == 0) even_count++;
    }

    long long ans;
    // all even number
    if (even_count == N)
    {
        if (P == 0)
        {
            ans = pow(2, N);
        }
        else
        {
            ans = 0;
        }
        
    }
    else
    {
        ans = pow(2, N - 1);
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    ll k,s;cin>>k>>s;
    ll ans=0;
    rep(a,0,k){
        rep(b,0,k){
            ll c=s-a-b;
            if(0<=c&&c<=k)ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}






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

ans = float('inf')
a = 1

for i in range(N//2):
    b = N - a
    ans = min(ans, sum(list(map(int,list(str(a))))) + sum(list(map(int,list(str(b))))) )
    a += 1                                                        
                                                            
print(ans)  

Measured memory_bytes: 3060
n = gets.to_i
four_arr = gets.chomp.split(' ').map(&:to_i).map{|i| i%4}.sort
two_arr = four_arr.map{|i| i %2}.sort.reverse
num_of_odd = two_arr.bsearch_index{|i| i < 1} || two_arr.size
num_of_four = four_arr.bsearch_index{|i| i > 0} || four_arr.size
# p two_arr
# puts "奇数の個数は#{num_of_odd.to_s}"
# puts "４の倍数の個数は#{num_of_four.to_s}"
if num_of_four > num_of_odd - 1
  puts "Yes"
elsif num_of_four == num_of_odd - 1
  if (n - num_of_four - num_of_odd) % 2 == 0
    puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

Measured memory_bytes: 25628
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;


public class Main {



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, ArrayList<Integer>> graph = new HashMap<>();
		for (int i=1;i<=n;i++) {
			graph.put(i,new ArrayList<Integer>());
		}
		for (int i=0;i<n-1;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		
		
		ArrayDeque<Integer> pointDeq = new ArrayDeque<Integer>();
		ArrayDeque<Integer> distDeq = new ArrayDeque<Integer>();
		boolean[] visited = new boolean[n+1];
		int[] dist = new int[n+1];
		pointDeq.push(1);
		distDeq.push(0);
		while (!pointDeq.isEmpty()) {
			int next = pointDeq.pop();
			int nextDist = distDeq.pop();
			dist[next] = nextDist;
			visited[next]=true;
			for (Integer intg : graph.get(next)) {
				if(!visited[intg]) {
					pointDeq.push(intg);
					distDeq.push(nextDist+1);
				}
			}
		}
		
		int oddCount = 0;
		int evenCount = 0;
		for (int i=1;i<=n;i++) {
			if (dist[i]%2==1) {
				oddCount++;
			} else {
				evenCount++;
			}
		}
		
		ArrayDeque<Integer> zero = new ArrayDeque<>();
		ArrayDeque<Integer> one = new ArrayDeque<>();
		ArrayDeque<Integer> two = new ArrayDeque<>();
		
		for (int i=1;i<=n;i++) {
			if (i%3==0) {
				zero.offer(i);
			} else if (i%3==1) {
				one.offer(i);
			} else {
				two.offer(i);
			}
		}
		
		if (oddCount>evenCount*2) {
			for (int i=1;i<=n;i++) {
				if (dist[i]%2==0) {
					System.out.println(zero.poll());
				} else if (!one.isEmpty()) {
					System.out.println(one.poll());
				} else if (!two.isEmpty()){
					System.out.println(two.poll());
				} else {
					System.out.println(zero.poll());
				}
			}
			
		} else if (evenCount>oddCount*2) {
			for (int i=1;i<=n;i++) {
				if (dist[i]%2==1) {
					System.out.println(zero.poll());
				} else if (!one.isEmpty()) {
					System.out.println(one.poll());
				} else if (!two.isEmpty()) {
					System.out.println(two.poll());
				} else {
					System.out.println(zero.poll());
				}
			}
		} else {
			for (int i=1;i<=n;i++) {
				if (dist[i]%2==0) {
					if (!one.isEmpty()) {
						System.out.println(one.poll());
					} else {
						System.out.println(zero.poll());
					}
				} else {
					if (!two.isEmpty()) {
						System.out.println(two.poll());
					} else {
						System.out.println(zero.poll());
					}
				}
			}
		}
	}


}



Measured memory_bytes: 203316
#include <iostream>

using namespace std;

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

	switch(N % 10){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

U = 5*10**5
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def perm(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[n-k]
    z %= MOD
    return z

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z *= fact_inv[n-k]
    z %= MOD
    return z

n, m = map(int, input().split())
ans = 0
for i in range(n+1):
  temp = (-1)**i * comb(n, i)
  temp *= perm(m, i)
  temp %= MOD
  temp *= perm(m-i, n-i)**2
  temp %= MOD
  ans += temp
  ans %= MOD
print(ans)

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

unsigned long long N,M;
unsigned long long ans;

int main(){
    cin>>N>>M;
    ans=0ULL;
    if(N==1 && M==1) ans=1;
    else if(N==1 && M>1) ans=M-2;
    else if(N>1 && M==1) ans=N-2;
    else ans=(N-2)*(M-2);

    cout<<ans<<"\n";
}

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

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int memo[11][50];
int main(){
	int n,s;
	
	for(int i=0; i<(1<<10); i++){
		int sum = 0;
		int bitc = 0;
		for(int j=0; (1<<j)<=i; j++)if( i&(1<<j) ){
			sum += j;
			bitc++;
		}
		memo[bitc][sum]++;
		//printf("bitc:%d  , sum:%d\n",bitc,sum);
	}
	
	while(scanf("%d%d",&n,&s),n|s){
		printf("%d\n",s<50 ? memo[n][s] : 0);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    lint A, B, ans;
    cin >> A >> B;
    if (A==B){
        cout << A;
        return 0;
    }
    if (A+1==B){
        cout << (A^B);
        return 0;
    }
    if (A%2==0){
        if(B%2==0){
            ans = (((B-A)/2)%2==0?0:1) ^ B;
        }
        else{
            ans = ((B-A+1)/2)%2==0?0:1;
        }
    }
    else{
        if(B%2==0){
            ans = A ^ (((B-A-1)/2)%2==0?0:1) ^ B;
        }
        else{
            ans = A ^ (((B-A)/2)%2==0?0:1);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
    (a (make-array n :initial-element 0))
    (flg 0)
    (ans -1))
    (loop for i below n do
        (progn
            (setf (aref a i) (read))
            (if (= (aref a i) 2) (setq flg 1))
        )
    )

    (if (= flg 1)
        (let ((b 0))
            (loop for i below n do
                (progn
                    (if (not (= (aref a b) 2))
                        (setq b (- (aref a b) 1))
                        (progn
                            (setq ans (+ i 1))
                            (return)
                        )
                    )
                )
            )
        )
    )
    (format t "~D~%" ans)
)

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

const int MAX = 10000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//Write From this Line

int main()
{
	COMinit();
	
	int x , y ;
	cin >> x >> y ;
	//一回の移動でx,y合わせて3マス動くことになるので、x + y が3の倍数でないと行けない
	//0,3みたいなのは行けない。
	if(( (2*y - x) % 3 == 0) && ((2 * x - y) % 3 ==0) ){//このとき答えが求まる。気がする
		int a = (2 * x - y) / 3; 
		int b = (2 * y - x) / 3; 
		//a + b C a　かな？
		int n = a + b ;
		int k = min(a,b);
		cout << COM(n,k) << endl;
	} else {
		puts("0");
	}

}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }
    vector<ll> B(M), C(M);
    vector<pair<ll, ll>> swapP;
    REP(i, M)
    {
        cin >> B[i] >> C[i];
        swapP.push_back(make_pair(C[i], B[i]));
    }

    sort(ALL(A));
    sort(ALL(swapP));
    reverse(ALL(swapP));

    ll index = 0;
    bool flag = true;
    REP(i, M)
    {
        pair<ll, ll> p = swapP[i];
        ll b, c;
        b = p.second;
        c = p.first;
        REP(j, b)
        {
            if (A[index] < c)
            {
                A[index] = c;
                index++;
            }
            else
            {
                flag = false;
                break;
            }
        }
        if (!flag)
        {
            break;
        }
    }
    ll ans = 0;
    REP(i, N)
    {
        ans += A[i];
    }

    cout << ans << endl;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define EPS 0.0000000001
#define pb push_back
#define space " "
#define ar array
#define pi pair<int,int>
#define ff first
#define ss second

void solve() {
    const int Mod = (int) 1e9 + 7;
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        sum %= Mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        sum -= a[i];
        sum = (sum % Mod + Mod) % Mod;
        ans += a[i] * 1ll * sum;
        ans %= Mod;
    }
    cout << ans << endl;
}

int main() {
//    freopen("input.txt" , "r" , stdin) ;
//    freopen("output.txt" , "w" , stdout) ;
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4044
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

/// [..)
struct SegTree(alias _fun, alias def, T)
if (is(typeof(def) : T))
{
    import std.functional : binaryFun;
    alias fun = binaryFun!_fun;

    ///
    this(size_t n, T[] ts) {
        this.n = 1;
        while (this.n < n) this.n *= 2;
        this.tree.length = this.n * 2 - 1;
        foreach (ref e; this.tree) e = def;
        foreach (i, e; ts) this.put(i, e);
    }

    ///
    void put(size_t i, T e) {
        i += this.n - 1;
        this.tree[i] = e;
        while (i > 0) {
            i = (i-1) / 2;
            this.tree[i] = fun(this.tree[i*2+1], this.tree[i*2+2]);
        }
    }

    ///
    T query(size_t a, size_t b) {
        T impl(size_t i, size_t l, size_t r) {
            if (r <= a || b <= l) return def;
            if (a <= l && r <= b) return this.tree[i];
            return fun(
                impl(i*2+1, l, (l+r)/2),
                impl(i*2+2, (l+r)/2, r)
            );
        }
        return impl(0, 0, this.n);
    }

private:
    size_t n;
    T[] tree;
}

///
SegTree!(f, def, T) seg_tree(alias f, alias def, T)(size_t n, T[] arr = [])
{
    return SegTree!(f, def, T)(n, arr);
}

///
SegTree!(f, def, T) seg_tree(alias f, alias def, T)(T[] arr)
{
    return SegTree!(f, def, T)(arr.length, arr);
}

void main()
{
    auto N = readln.chomp.to!int;
    auto hs = readln.split.to!(int[]);
    auto as = readln.split.to!(long[]);

    auto SEG = seg_tree!("a > b ? a : b", 0, long)(new long[](N));
    foreach (i; 0..N) {
        SEG.put(hs[i]-1, SEG.query(0, hs[i]-1) + as[i]);
    }
    writeln(SEG.query(0, N));
}

Measured memory_bytes: 20788
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>num(3);
  for(int i=0;i<3;i++){
    cin>>num[i];
  }
  sort(num.begin(),num.end());
  int ans=num[2]*10+num[1]+num[0];
  cout<<ans<<endl;
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 3e3 + 5;
int n;
int a[N];
int dp[N][N];

/// dp[i][j] là số điểm cao nhất mà khi tới trạng thái [i , j] thì thằng đi sẽ được nhiều điểm nhất.

main()
{
    //freopen("L.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    int sum = 0;
    FOR(i , 1 , n)
    {
        cin >> a[i];
        sum += a[i];
    }
    FOR(i , 1 , n)
        dp[i][i] = a[i];
    FOR(i , 2 , n)
        dp[i - 1][i] = max(a[i - 1] , a[i]);
     FOR(r , 1 , n)
        FORD(l , r - 2 , 1)
            dp[l][r] = max(min(dp[l + 1][r - 1] , dp[l + 2][r]) + a[l] , min(dp[l + 1][r - 1] , dp[l][r - 2]) + a[r]);
    cout << dp[1][n] - (sum - dp[1][n]);
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define INF 2000000001

using namespace std;

typedef pair<ll, ll> pi;

ll n, m, o, a;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int n, int m) { return n * m / gcd(n, m); }
int main() {
	cin >> n >> m >> o;
	a = n + m;
	if (a >= o) cout << m + o << endl;
	else cout << a + m + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		while(sc.hasNext()){
			String str = sc.nextLine();
			char[] c = str.toCharArray();
			String temp="";
			for(int j = 0; j < 26; j++){
				for(int i=0;i<c.length;i++){
					if('a' <= c[i] && c[i] <= 'z')
						if(c[i] == 'z')
							c[i] = 'a';
						else
							c[i]++;
				}
				temp = String.valueOf(c);
				if (temp.contains("that")||
						temp.contains("this")||
						temp.contains("the")){
					System.out.println(temp);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 17992
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a;
set<int> st;
int i=1;

signed main(){
    in(a);
    st.insert(a);
    while(i++){
        if(a&1){
            a=3*a+1;
        }else{
            a /= 2;
        }
        if(st.find(a)!=st.end()) {
            out(i);
            break;
        }
        st.insert(a);
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (-1000000)
using namespace std;
typedef pair<int, int> P;

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

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}


int main(void) {
	string s;
	cin >> s;
	string t = "2019/04/30";
	if (s <= t)cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	return 0;
}

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

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

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  for (int i = 0; i < k; i++) {
    vector<int> imos(n);
    for (int j = 0; j < n; j++) {
      int l = max(0, j - a[j]);
      int r = j + a[j] + 1;
      imos[l]++;
      if(r < n) imos[r]--;
    }
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if(j != 0) imos[j] += imos[j - 1];
      if(imos[j] == n) cnt++;
    }

    for (int j = 0; j < n; j++) a[j] = imos[j];

    if(cnt == n) break;
  }

  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << '\n';

}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
void add(string s, int i, int N){
    if(s.size() == N){
        cout << s << endl;
        return;
    }
    for(int j = 0; j <= i; j++){
        string t = s;
        char ad = 'a' + j;
        t += ad;
        if(j < i) add(t, i, N);
        else add(t, i + 1, N);
    }
}
int main(){
    int N;
    cin >> N;
    string s;
    s += 'a';
    int i = 1;
    add(s, i, N);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int h, w;
	cin >> h >> w;
	int mp[h][w];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++) cin >> mp[i][j];
	}
	vector<int> te[4];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(!(i + 1 == h && j + 1 == w)){
				if((mp[i][j] % 2)){
					if(j + 1 != w){
						mp[i][j]--; mp[i][j + 1]++;
						te[0].push_back(i + 1); te[1].push_back(j + 1);
						te[2].push_back(i + 1); te[3].push_back(j + 2);
					} else {
						mp[i][j]--; mp[i + 1][j]++;
						te[0].push_back(i + 1); te[1].push_back(j + 1);
						te[2].push_back(i + 2); te[3].push_back(j + 1);
					}
				}
			}
		}
	}
/*	cout << endl;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++) cout << mp[i][j] << ' ';
		cout << endl;
	}
	cout << endl;*/
	cout << te[0].size() << endl;
	for(int i = 0; i < te[0].size(); i++)
		cout << te[0][i] << ' ' << te[1][i] << ' ' << te[2][i] << ' ' << te[3][i] << endl;
	return 0;
}

Measured memory_bytes: 5220
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String[] line = br.readLine().split(" ");
    int[] nums = new int[n];
    int i;
    boolean flag = false;
    nums[n-1] = Integer.parseInt(line[n-1]);
    for(i=n-2; 0<=i; i--){
      if( !flag )
        nums[i] = Integer.parseInt(line[i]);
      if( nums[i] > nums[i+1] ){
        if( flag ){
          System.out.println("No");
          System.exit(0);
        }else{
          nums[i]--;
          i++;
          flag = true;
        }
      }else
        flag = false;
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 45780
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

comb_count = {1:1, 2:3, 3:6}
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            ans += gcd(a, b, c) * comb_count[len(set([a, b, c]))]
print(ans)

Measured memory_bytes: 9632
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   string a, b, c;
   cin >> a >> b >> c;
   string ret = "";
   ret += toupper(a[0]), ret += toupper(b[0]) , ret+= toupper(c[0]);
   cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

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; }

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

    string s;cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1]<<el;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int n,w;
	cin >> n >> w;
	vector<long long int> weights(n),values(n),dp(w+1);
	for(int i=0; i<n; i++)
	{
		cin >> weights[i] >> values[i];
	}
	dp[0] = 0;
	for(int i=0; i<n; i++)
	{
		for(int j=w; j>=0; j--)
		{
			if(j+weights[i] <= w)dp[j+weights[i]] = max(dp[j]+values[i],dp[j+weights[i]]);
		}
	}

	long long int ans = 0;
	for(int i=0; i<=w; i++)ans = max(ans,dp[i]);
	cout << ans ;
}


			






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

man_c=[]
for i in range(0,n-1):
    if a[i+1]==a[i]+1:
        man_c.append(c[(a[i]-1)])
print(sum(b)+sum(man_c))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

    for(int a=0; a<=N; ++a) {
        for(int b=0; b<=N; ++b) {
            int total = 4*a + 7*b;
            if (total==N) { 
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,g;
  cin >> d >> g;
  vector<int>p(d);
  vector<int>c(d);
  int i;
  for(i=0;i<d;i++){
    cin >> p[i] >> c[i];
  }
  int ans = 1<<30;
  for(int bit = 0;bit<1<<d;bit++){
    int tmp = 0;
    int num = 0;
    for(i=0;i<d;i++){
      if(1<<i & bit){
        tmp += p[i]*100*(i+1)+c[i];
        num += p[i];
      }
    }
    if(tmp>=g && ans>num)ans=num;
    else{
      for(i=d-1;i>=0;i--){
        if(!(bit & 1<<i)){

          if((g-tmp)<p[i]*(i+1)*100){
            while(tmp<g){
              num++;
              tmp+=(i+1)*100;
            }
            if(ans>num)ans=num;
          }

          break;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#import deque
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

N, Q = map(int, input().split())

Graph = [[] for i in range(N)]
#print(Graph)
for _ in range(N-1):
    a, b = map(int, readline().split())
    #print(a, b)
    Graph[a-1].append(b-1)
    Graph[b-1].append(a-1)

score = [0] * N
for _ in range(Q):
    p, x = map(int, readline().split())
    score[p-1] += x

ans = [0] * N
def dfs(v, u, counter):
    counter += score[v]
    ans[v] = counter
    for c in Graph[v]:
        if c == u:
            continue
        dfs(c, v, counter)

dfs(0, -1, 0)

print(*ans)


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

#define MOD 1000000007ll
#define INV2 500000004ll

using namespace std;

typedef long long ll;
ll a[100005];
ll fact[100005];
ll dp[100005];

ll fast_pow(ll n, ll e){
    if(!e)
        return 1ll;
    ll tmp = (fast_pow(n,e/2ll));
    tmp = (tmp*tmp)%MOD;
    if(e&1)
        return (tmp*n)%MOD;
    return tmp;
}

int main(){
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    fact[0] = 1;
    for(int i = 1; i<=n; i++)
        fact[i] = (fact[i-1]*i)%MOD;
    for(int i = 0; i<n; i++)
        cin >> a[i];
    dp[1] = fact[n-1];
    for(int i = 2; i<n; i++){
        dp[i] = dp[i-1];
        ll adder = (fact[n-1]*fast_pow(i,MOD-2ll));
        dp[i] = (dp[i]+adder)%MOD;
    }
    ll ans = 0;
    for(int i = 1; i<n; i++){
        ll adder = (a[i]-a[i-1])*dp[i];
        adder %= MOD;
        ans = (ans+adder)%MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<vector<pair<int, int>>> dat(n);
    FOR(i, 0, n) {
        int a; cin >> a;
        dat[i].resize(a);
        cin >> dat[i];
    }

    int ans = 0;
    FOR(bit, 0, (1 << n)) {
        int cnt = 0;
        vector<bool> t(n);
        FOR(j, 0, n)if (bit & (1 << j)) {
            t[j] = true;
            ++cnt;
        }
        bool ng = false;
        FOR(i, 0, n){
            if (!t[i])continue;

            for (auto x : dat[i]) {
                if (t[x.first - 1] && x.second == 0)ng = true;
                if (!t[x.first - 1] && x.second == 1)ng = true;
            }
        }
        if (ng)continue;
        chmax(ans, cnt);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256