akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		double result = 0.0;
		double cnt = 0;
		for(int i = 1;i<=N;i++) {
			if(i%2 == 1) {
				cnt++;
			}
		}
		result = cnt/N;
		System.out.println(result);
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b){ll res=1;a=a%mod; while(b){if(b&1)res=(res*a)%mod; a=(a*a)%mod;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
int main(void)
{
    FIO	
    int n;
    cin>>n;
    int ans=0,x=1;
    vector<int> dp(n+1,mod);
    dp[0]=0;
    dp[1]=1;
    for(int i=1;i<=n;i++){
        x=1;
        while(x<=i)
        {
            dp[i]=min(dp[i],dp[i-x]+1);
            x*=6;
        }
        x=9;
        while(x<=i)
        {
            dp[i]=min(dp[i],dp[i-x]+1);
            x*=9;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

using namespace std;

int n;
int main ()
{
    ios::sync_with_stdio (false) ;
    while (cin>>n)
    {
        if (n>=1 && n<1000)
            cout<<"ABC"<<endl;
        else cout<<"ABD"<<endl;
    }
    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++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { string S;
  cin >> S;
  char c = S[0];
  ll ans = 0;
  REP(i,S.size()){
    if(c!=S[i]){
      c = S[i];
      ans++;
    }
  }
  cout << ans << "\n";
}

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

namespace Myatcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            char[] a = A.ToCharArray(), b = B.ToCharArray();

            Dictionary<char, int> x = new Dictionary<char, int>(25);
            Dictionary<char, int> y = new Dictionary<char, int>(25);
            if (A.Length == B.Length) {
                for (int i = 1; i < A.Length; i++)
                {
                    if (x.ContainsKey(a[i])) x[a[i]] += 1;
                    else x[a[i]] = 1;

                    if (y.ContainsKey(b[i])) y[b[i]] += 1;
                    else y[b[i]] = 1;
                }
                int[] avals = new int[x.Count];
                int[] bvals = new int[y.Count];
                x.Values.CopyTo(avals, 0);
                y.Values.CopyTo(bvals, 0);
                Array.Sort(avals);
                Array.Sort(bvals);
                bool judge = true;

                if (x.Count != y.Count) judge = false;
                if (judge) {
                    for (int i = 0; i < avals.Length; i++) {
                        if (avals[i] != bvals[i]) {
                            judge = false;
                            break;
                        }
                    }
                }
                if (judge) Console.WriteLine("Yes");
                else Console.WriteLine("No");

            }
            else {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 15584
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    cout << 6-a-b << endl; return 0;
}


Measured memory_bytes: 256
n = gets.to_i
t = gets.split.map(&:to_i)
m = gets.to_i

a = []
m.times do
  a << gets.split.map(&:to_i)
end


a.each do |b|
  u = t.dup
  u[b[0]-1] = b[1]
  puts u.inject(:+)
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 60
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	int n;
	cin >> n;
	lli ans = 0;
	for(lli i = 1; i <= n; i++) {
		if((i % 3) == 0 or (i % 5) == 0) {
			continue;
		} else ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.*;
//System.out.println("")

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt =1;
        int h[]= new int[n];
        
        for(int i = 0; i<n; i++){
            h[i] = sc.nextInt();
        }
        int max =h[0];
        for(int i=1; i<n; i++){
                if(max<=h[i]){
                    cnt++;
                    max = Math.max(max,h[i]);
                }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 22612
import java.util.Scanner;

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

        int N = sc.nextInt();
        int C = sc.nextInt();
        int[][] D = new int[C][C];
        for (int i = 0; i < C; ++i) {
            for (int j = 0; j < C; ++j) {
                D[i][j] = sc.nextInt();
            }
        }
        int[][] c = new int[N][N];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                c[i][j] = sc.nextInt() - 1;
            }
        }

        System.out.println(solve(c, D));

        sc.close();
    }

    static int solve(int[][] c, int[][] D) {
        int N = c.length;
        int C = D.length;

        int[][] colorCounts = new int[3][C];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                ++colorCounts[(i + j) % 3][c[i][j]];
            }
        }

        int result = Integer.MAX_VALUE;
        int[] targetColors = new int[3];
        for (targetColors[0] = 0; targetColors[0] < C; ++targetColors[0]) {
            for (targetColors[1] = 0; targetColors[1] < C; ++targetColors[1]) {
                if (targetColors[1] != targetColors[0]) {
                    for (targetColors[2] = 0; targetColors[2] < C; ++targetColors[2]) {
                        if (targetColors[2] != targetColors[0] && targetColors[2] != targetColors[1]) {
                            int cost = 0;
                            for (int i = 0; i < 3; ++i) {
                                for (int j = 0; j < C; ++j) {
                                    cost += D[j][targetColors[i]] * colorCounts[i][j];
                                }
                            }

                            result = Math.min(result, cost);
                        }
                    }
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 92336
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, W;
    cin >> N >> W;
    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vv<int> val(4);
    ll w0 = w[0];
    rep(i, N) {
        val[w[i] - w0].push_back(v[i]);
    }
    vv<ll> sum(4);
    rep(i, 4) {
        sort(all(val[i]), greater<int>());
        sum[i].resize(val[i].size() + 1, 0);

        rep(j, val[i].size()) {
            sum[i][j + 1] = sum[i][j] + val[i][j];
        }
    }

    ll ans = 0;
    rep(n0, val[0].size() + 1) rep(n1, val[1].size() + 1) rep(n2, val[2].size() + 1) rep(n3, val[3].size() + 1) {
        if (w0 * n0 + (w0 + 1) * n1 + (w0 + 2) * n2 + (w0 + 3) * n3 > W) continue;

        ll total = sum[0][n0] + sum[1][n1] + sum[2][n2] + sum[3][n3];
        ans = max(ans, total);
    }
    write(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include <iomanip>
using namespace std;

int main(){
    string s1,s2;
    int cnt=0;
    cin>>s1;
    for(int i=0; i<s1.size(); i++){
        s2.push_back(s1[s1.size()-1-i]);
    }
    //cout<<s2<<endl;
    for(int i=0; i<s1.size(); i++){
        if(s1[i]!=s2[i]){
            cnt++;
        }
    }

    cout<<cnt/2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;                                                                     
class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        String b = in.nextLine();
        int n = Integer.parseInt(b);
        String a = in.nextLine();
        String[] strAry = a.split(" ");

          while(n > 0){
              n--;
              //System.out.print(strAry[n]);
              sb.append(strAry[n] + " ");
          }
          String str = new String(sb);
          String str_new = str.trim();
          System.out.print(str_new + "\n");
    }
}

Measured memory_bytes: 26152
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

int n, m;
vector<ll> x, y, z, s;

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

ll func(int a, int b, int c){
	for (int i = 0; i < n; i++){
		s[i] = x[i] * a + y[i] * b + z[i] * c;
	}
	sort(s.begin(), s.end(), greater<ll>());
	return accumulate(s.begin(), s.begin() + m, 0LL);
}


int main(){
	cin >> n >> m;
	x = vector<ll> (n, 0);
	y = vector<ll> (n, 0);
	z = vector<ll> (n, 0);
	s = vector<ll> (n, 0);
	for (int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> z[i];
	}

	ll ans = 0;
	int i, j, k;
	REP(i, 2)REP(j, 2)REP(k, 2){
		ans = max(ans, func(dx[i], dy[j], dz[k]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u64>();

    let (n, k) = (line[0], line[1]);

    let a = read_as_vec::<u64>();
    let mut counter_vec: Vec<u64> = vec![0;64];
    for elem in &a{
        for shift in 0..64{
            if (*elem >> shift) &1 > 0{
                counter_vec[shift] += 1;
            }
        }
    }
    //println!("{:?}",counter_vec);
    //counter_vec.reverse();
    //println!("{:?}",counter_vec);
    let mut x: u64 = 0;
    //for elem in &counter_vec{
    for i in 0..64{
        if counter_vec[63-i] <= n/2{
            // check if x gets to be less than k
            if ((1<<(63-i)) | x) <= k{ 
                x = (1<<(63-i)) | x;
            }
        }
    }

    //println!("x={}", x);
    //println!("a = {:?}", a);
    let mut ans: u64 = 0;
    for elem in &a{
        ans += (*elem^x);
    }
    println!("{}", ans);
}


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

#define int long long
#define pb push_back
#define F first
#define S second
#define MAX 10000000
#define MOD 1000000007

typedef pair<int, int> PII;

signed main(){
    int N;
    cin>>N;
    double p[N+1];
    for(int i=1; i<=N; i++) cin>>p[i];
    double dp[N+1][N+1];
    dp[1][1] = p[1];
    dp[1][0] = 1-p[1];
    for(int i=2; i<=N; i++){
        for(int j=0; j<=i; j++){
            if(j==0) dp[i][0] = dp[i-1][0]*(1-p[i]);
            else if(j==i) dp[i][i] = dp[i-1][i-1]*p[i];
            else dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
        }
    }
    double res = 0.0;
    for(int i=0; i<=N; i++){
        if(i>N-i) res += dp[N][i];
    }
    printf("%0.10f\n", res);

    return 0;
}

Measured memory_bytes: 70400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int t = Integer.parseInt(str[1]);
		int[] a = new int [n];
		String[] str1 = br.readLine().split(" ");
		int maxdiff = 0;
		int min = Integer.MAX_VALUE;
		int cnt = 0;
		boolean minf = false;
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(str1[i]);
			if(a[i]<min){
				min = a[i];
				minf = true;
			}else{
				int diff = a[i] - min;
				if(maxdiff<diff){
					maxdiff = diff;
					cnt = 1;
					minf = false;
				}else if(maxdiff==diff && minf){
					cnt++;
				}
			}
		}
		sb.append(cnt);
		System.out.println(sb);
	}
}

Measured memory_bytes: 25972
def __min_cost(idx, cost, studied, costs):
    if idx >= n:
        return
    __min_cost(idx+1, cost, studied, costs)
    cost += cs[idx]
    studied = [s+i for s, i in zip(studied, mat[idx])]
    if all(s >= x for s in studied):
        costs.add(cost)
    __min_cost(idx+1, cost, studied, costs)

def min_cost():
    costs = set()
    __min_cost(0, 0, [0]*m , costs)
    if len(costs) > 0:
        return min(costs)
    else:
        return -1

n, m, x = map(int, input().split())
mat = []
cs = []
for _ in range(n):
    data = list(map(int, input().split()))
    cs.append(data[0])
    mat.append(data[1:])
print(min_cost())

Measured memory_bytes: 9268
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

vector<int>cc;
void dfs(vector<vector<int>> &g,int v,int id){
    cc[v]=id;
    for(auto e:g[v]){
        if(cc[e]==-1){
            dfs(g,e,id);
        }
    }
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int q;
    cin>>q;
    vector<int> s(q),t(q);
    for(int i=0;i<q;++i){
        cin>>s.at(i)>>t.at(i);
    }
    cc.assign(n,-1);
    int id=0;
    for(int i=0;i<n;++i){
        if(cc[i]==-1){
            dfs(g,i,id);
            id++;
        }
    }
    for(int i=0;i<q;++i){
        if(cc[s[i]]==cc[t[i]])cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 13552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
ll l[maxn],r[maxn],m[maxn],a[maxn];
ll cal(ll x){ if(x<3) return 0;
	return max(max(l[x-1],r[x-1]),cal(x-2)+a[x]);
}
int main(){
	int n;scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=2;i<=n;i+=2){
		l[i]=l[i-2]+a[i-1];
		r[i]=max(r[i-2],l[i-2])+a[i];
	}if(n%2){
		printf("%lld\n",cal(n));
	}else printf("%lld\n",max(l[n],r[n]));
}

Measured memory_bytes: 10064
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
    LL n,a,b;
    cin>>n>>a>>b;
    // if(!a)
    // {
    //     cout<<"0"<<endl;return;
    // }
    LL tot = a+b;
    LL ans = (n/(a+b))*a;
    n %= a+b;
    ans += min(n,a);
    cout<<ans;
    
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    reverse(a.begin(), a.end());
    for(i=0; i<n; i++) {
        printf("%d", a[i]);
        if(i!=n-1) printf(" ");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2692
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
string P[4] = {
    "dream",
    "dreamer",
    "erase",
    "eraser"
};
char buf[100111];
string S;
bool B[100111] ;

int main() {
    scanf("%s", buf);
    S = buf;
    N = S.size();

    B[0] = true;

    REP (i, N) if (B[i]) {
	REP (j, 4) {
	    if (i + (int)P[j].size() <= N) {
		if (P[j].compare(0, P[j].size(), S, i, P[j].size()) == 0) {
		    B[i + P[j].size()] = true;
		}
	    }
	}
    }

    puts(B[N]? "YES": "NO");

    return 0;
}



Measured memory_bytes: 764
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

int main() {
  ll N, K;
  cin >> N >> K;
  map<ll, bool> m;
  rep(k, K) {
    ll d;
    cin >> d;
    rep(i, d) {
      ll s;
      cin >> s;
      m.emplace(s, true);
    }
  }
  ll ans = 0;
  rep1(i, N) if (!m[i]) ans += 1;
  ANS(ans);
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

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

        // 入力値を受け取りinputに格納，inputが0でない限りfor文内の処理を行う
        int input;
        for(int i = 1; (input = scan.nextInt()) != 0; ++i){
            System.out.println("Case " + i + ": " + input);
        }
    }
}


Measured memory_bytes: 41624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n;
    cin >> n;
    int dp[n+1][n+1] = {};
    f(n) {
        dp[0][i] = 1;
    }
    string s;
    cin >> s;
    s = " " + s;
    f1(n - 1) {
        if (s[i] == '<') {
            for (int j = 1 ; j <= i ; j++) {
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % mod;
            }
        }
        else {
            for (int j = i - 1 ; j >= 0 ; j--) {
                dp[i][j] = (dp[i][j + 1] + dp[i - 1][j]) % mod;
            }
        }
    }
    int ans = 0;
    f(n) {
        ans += dp[n - 1][i];
        ans %= mod;
    }
    cout << ans << '\n';
} 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        //cout << "Case #"<<(c++) << ": ";
        go();
    }
    
}

Measured memory_bytes: 38800
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

/*
ll bfs(ll resN, const ll& nine, const ll& six, ll count, ll depth)
{
    bool isNine=false, isSix =false;
    if(depth > count) return count;
    for(size_t i=1;i<=nine; i++)
    {
        if(resN - pow(9, i) >= 0)
        {
            isNine = true;
            depth+=1;
            count = min(count, bfs(resN-pow(9, i), nine, six, count, depth));
        }

    }
    for(size_t i=1;i<=six; i++)
    {
        if(resN - pow(6, i) >= 0)
        {
            isSix=true;
            depth+=1;
            count = min(count, bfs(resN-pow(6, i), nine, six, count, depth));
        }
    }
    if(!isNine && !isSix)
    {
        count = depth + resN;
    }
    else{
        count = depth;
    }
    return count;
}
*/

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    // 1
    //6, 6^2, 6^3, ...
    //9, 9^2, 9^3, ...
    //全探索
    // Nは最大でも 100,000
    //ll nine = 0;
    //while(pow(9, nine) < N) nine++;
    //cerr << nine-1 << ":" << pow(9, nine-1) << endl;
    // 9は５まで
    //ll six = 0;
    //while(pow(6, six) < N) six++;
    // 6は6まで
    //cerr << six-1 << ":" << pow(6, six-1)<< endl;
    ll count_max = N;
    //cout << bfs(N, nine, six, N, 0) << endl;
    for(int i=0; i<=N; i++)
    {
        int count=0;
        //6で割る数
        int t = i;
        //cerr << "i:" << i << endl;
        while(t > 0) count+= t%6, t/=6;
        //cerr << "\t:"<< count << endl;
        //9で割る数
        t=N-i;
        while(t > 0) count+= t%9, t/=9;
        if(count_max > count) count_max = count;
        //cerr << "\t:" << count_max << endl;
    }
    cout << count_max << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
//Comentary AC
#include <iostream>
#include <string>
using namespace std;
long long int f_n(long long int n, long long int x){
    if (n>=0) return n/x+1;
    else return 0;
}

int main() {
    long long int a, b, x;
    cin >> a >> b >> x; 
    cout << f_n(b,x) - f_n(a-1,x) << endl; 
}

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

int main(){
	int n;
	string set;
	stack<int> st[2000];
	
	cin >> n;
	while(n > 0){
		int count = 0;
		string val;
		cin >> set;
		for(int i=0; i<set.length(); i++){
			if(set[i] == '['){
				count++;
			}else if(set[i-1] == ']' && set[i] == ']'){
				int tmp[5000],sum=0,stsize,p=0;;
				stsize = st[count+1].size();
				while(!st[count+1].empty() ){
					tmp[p++] = st[count+1].top();
					st[count+1].pop();
				}
				sort(tmp, tmp+stsize);
				for(int j=0; j<(stsize+1)/2; j++){
					sum += tmp[j];
				}
				st[count].push(sum);
				count--;
			}else if(set[i] == ']'){
				st[count].push( (atoi(val.c_str())+1)/2 );
				count--;
			}else{
				int beg=i;
				while(set[i+1] != ']'){
					i++;
				}
				val = set.substr(beg, i-beg+1);
			}
		}
		cout << st[1].top() << endl;
		n--;
	}
}

Measured memory_bytes: 2592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int x,y;
int main()
{ 
    scanf("%d%d",&x,&y);
    if(x%y!=0) printf("%d\n",x);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// Union-Find; 素集合データ構造
class UnionFind {
public:
    vector<long long> parent;
    long long n;
    UnionFind(long long x) :parent(x, -1), n(x){}
    bool unite(long long x, long long y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y]; parent[y] = x;
        return true; }
    bool same(long long x, long long y){ return find(x) == find(y); }
    long long find(long long x){ return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    long long size(long long x){ return -parent[find(x)]; }
};

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vi p(n);
    UnionFind uf(n);
    rep(i, n){
        cin >> p[i];
        p[i]--;
    }

    rep(i, m){
        ll x, y; cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    ll ans = 0;
    rep(i, n){
        if(uf.same(i, p[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a<b && b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 25980
#include<iostream>
#include<string>
#include<map>
#include<set>
#define rep(i,n) for(long long i=0;i<(n);i++)

using namespace std;

long long gcd(long long a,long long b){
    if(b==0){
        return a;
    }
    if(b>a){
        return gcd(a,b%a);
    }else{
        return gcd(b,a%b);
    }
}
 
int main(){
    long long  n;
    long long ans =0;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                ans += gcd(gcd(i+1,j+1),k+1);
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	int a = n % 10;
	int b = n / 10;
	if (a == 9 || b == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

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

  int64_t res = 0;
  rep(i,n+1) {
    if (i % 3 != 0 && i % 5 != 0) res += i;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

typedef struct {
	char name[31];
	int page[100];
	int num;
} WORD;

WORD word[100];

int cmp(int A, int B)
{
	int i = 0;
	
	while (word[A].name[i] != '\0' && word[B].name[i] != '\0'){
		if (strncmp(word[A].name, word[B].name, i + 1) < 0){
			return (0);
		}
		else if (strncmp(word[A].name, word[B].name, i + 1) > 0){
			return (1);
		}
		i++;
	}
	
	if (word[A].name[i] == '\0'){
		return (0);
	}
	return (1);
}

int main(void)
{
	char str[31];
	int i, j = 0, k, l, number, temp, order[100];
	
	for (i = 0; i < 100; i++){
		order[i] = i;
	}
	
	while (scanf("%s %d", str, &number) != EOF){
		for (i = 0; i < j; i++){
			if (strcmp(word[i].name, str) == 0){
				word[i].page[word[i].num] = number;
				word[i].num++;
				break;
			}
		}
		
		if (i == j){
			strcpy(word[j].name, str);
			word[j].page[word[j].num] = number;
			word[j].num++;
			j++;
		}
	}
	
	for (i = 0; i < j; i++){
		for (k = 0; k < word[i].num - 1; k++){
			for (l = k + 1; l < word[i].num; l++){
				if (word[i].page[k] > word[i].page[l]){
					temp = word[i].page[k];
					word[i].page[k] = word[i].page[l];
					word[i].page[l] = temp;
				}
			}
		}
	}
	
	for (i = 0; i < j - 1; i++){
		for (k = i + 1; k < j; k++){
			if (cmp(order[i], order[k]) == 1){				
				temp = order[i];
				order[i] = order[k];
				order[k] = temp;
			}
		}
	}
	
	for (i = 0; i < j; i++){
		printf("%s\n", word[order[i]].name);
		for (k = 0; k < word[order[i]].num; k++){
			if (k != 0){
				printf(" ");
			}
			printf("%d", word[order[i]].page[k]);
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 652
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

typedef pair<int, int> P;

P p[1024];
int dp[1024][1024];

bool cmp(const P&x, const P&y) {
  if (x.second != y.second)
      return x.second < y.second;
  return x.first < y.second;
}

int main() {
  int N; scanf("%d", &N);
  REP(i, N) {
      scanf("%d%d", &p[i].first, &p[i].second);
  }
  sort(p, p + N, cmp);

  const int inf = 100100100;
  REP(i, 1024) REP(j, 1024) dp[i][j] = inf;
  dp[0][0] = 0;
  for (int n = 0; n < N; n++) {
      for (int k = 0; k <= n + 1; k++) {
          dp[n + 1][k] = min(dp[n + 1][k], dp[n][k]);
          if (dp[n][k] + p[n].first <= p[n].second) {
              dp[n + 1][k + 1] = min(dp[n + 1][k + 1], dp[n][k] + p[n].first);
          }
      }
  }
  int ans = 0;
  for (int k = 0; k <= N; k++) {
      if (dp[N][k] < inf) {
          ans = k;
      }
  }
  cout << ans << endl;

  return 0;
}

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

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

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

	ll stock = 0;
	ll money = 1000;

	for (int i = 0; i < N - 1; i++) {
		ll max_j = i;
		ll max_price = A[i];
		for (int j = i + 1; j < N; j++) {
			if (max_price > A[j]) {
				break;
			} else if (A[j] > max_price) {
				max_price = A[j];
				max_j = j;
			}
		}
		stock = money / A[i];
		money -= stock * A[i];
		money += stock * A[max_j];
		stock = 0;
		// cout << i << " " << max_j << " " << money << endl;
		i = max_j;
	}

	cout << money << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, K;
  cin >> N >> K;

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

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

  int ans = 0;

  for (int i = 0; i < K; i++) {
    ans += vec.at(i);
  }
  cout << ans << endl;

}

Measured memory_bytes: 3628
from collections import deque

n = int(input())
linked_list = deque([])

for i in range(n):
    line = input().split()
    cmd = line[0]

    if len(line) == 2:
        value = line[1]

    if cmd == "insert":
        linked_list.appendleft(value)
    elif cmd == "delete":
        if value in linked_list:
            linked_list.remove(value)
    elif cmd == "deleteFirst":
        linked_list.popleft()
    elif cmd == "deleteLast":
        linked_list.pop()

print(*linked_list)

Measured memory_bytes: 71868
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w;
 
ll x[800005],y[800005],z[900005];
ll l[500005],r[500005];

int main(){	
	cin>>n>>k;
	ans = INF;
	for(i=0;i<n;i++){
		cin>>x[i];
	}
	if(x[0]>=0){
		p(x[k-1]);
		return 0;
	}else if(x[n-1]<0){
		p(-x[n-k]);
		return 0;
	}else{
		for(i=0;i<n-1;i++){
			if(x[i]<0 && x[i+1]>=0){
				num = i;
			}
		}
		a = num + 1;
		b = n - num - 1;
		vector <ll> r,l;
		for(i=0;i<a;i++){
			l.pb(-x[i]);
		}
		for(i=a;i<n;i++){
			r.pb(x[i]);
		}
		sort(l.begin(),l.end());
		for(i=0;i<k;i++){
			if(i>=a || k-i-2>=b)continue;
			num = min(2*l[i] + r[k-i-2],l[i] + 2*r[k-i-2]);

			ans = min(ans,num);
		}
		if(b>=k){
			ans = min(ans,r[k-1]);
		}
		if(a>=k){
			ans = min(ans,l[k-1]);
		}
	}
	p(ans);

		
	return 0;
}


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

int main()
{
    char s[3];
    cin >> s[0] >> s[1] >> s[2];
    int cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == '1')
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}
	sort.Ints(A)

	a, b := 0, 0
	for i := N - 1; i > 0; i-- {
		if A[i] == A[i-1] {
			if a == 0 {
				a = A[i]
			} else {
				b = A[i]
				break
			}
			i--
		}
	}
	fmt.Println(a * b)
}


Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
//n以下の素数列挙(O(nloglogn))
vector<ll> primes(ll n){
    bool judge[n+1];
    for(int i = 0;i<=n;i++){
        judge[i] = true;
    }
    vector<ll> prime;
    for(int i = 2;i<=n;i++){
        if(judge[i]){
            for(int j = 2*i;j<=n;j+=i){
                judge[j] = false;
            }
            prime.push_back(i);//ここでprimeに入れられる素数の条件を指定できる
        }
    } 
    return prime;
}
//x^n(MOD)
long long power(long long n,int x,long long MOD){
    long long a = 1;
    long long b = x;
    while(n>0){
        if(n%2==1){
            a*=b;
            a%=MOD;
        }
        n/=2;
        b = b*b;
        b%=MOD;
    }
    return a;
}
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> num(k+1);
    fill(All(num),0LL);
    ll ans = 0;
    rep(i,k){
        ll now = i+1;
        ll tmp = (now-num[now])*power(n,k/now,MOD);
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
        for(int j = 2*now;j<=k;j+=now){
            num[j]+=(now-num[now]);
            num[j]%=MOD;
        }
    }
    if(ans<0) ans+=MOD;
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  long ans;
  cin >> n;
  vector<long> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  ans = 0;
  for(int i=1;i<n;i++){
    if(a[i] < a[i-1]){
      ans += a[i-1] - a[i];
      a[i] = a[i-1];
    }
  }
  cout << ans;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int A, B, K; scanf("%d %d %d", &A, &B, &K);
  vector<int> ans;
  for (int i = A; i <= min(A + K - 1, B); ++i) {
    ans.push_back(i);
  }
  for (int i = max(A + K, B - K + 1); i <= B; ++i) {
    ans.push_back(i);
  }
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if((a * b) % 2 == 0)
	{
		printf("Even\n");
		}
		else
			printf("Odd\n");
	}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    char a[4];
    cin>>a;
    if ((a[0] == 'a'&&a[1] == 'b'&&a[2] == 'c')||(a[0] == 'b'&&a[1] == 'a'&&a[2] == 'c')||(a[0] == 'a'&&a[1] == 'c'&&a[2] == 'b')||(a[0] == 'c'&&a[1] == 'a'&&a[2] == 'b')||(a[0] == 'b'&&a[1] == 'c'&&a[2] == 'a')||(a[0] == 'c'&&a[1] == 'b'&&a[2] == 'a'))
       cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define INF INT_MAX
  const int  N= 200005;
  vector<vector<int>> g;
  vector<bool> vis;
  vector<int> node;
  vector<int> ans;
  multiset<int> ss;
 
  //LIS on tree
  //O(N Log N) solution

void dfs(int s,int ps)
{
 
    auto it = ss.lower_bound(node[s]);
    int y = -1 ;
    ss.insert(node[s]);
    if(it != ss.end())
      {
        y = *it;
        ss.erase(it);
      }
 
 
    ans[s] = ss.size();
    for(auto &i : g[s])
    {
      if(i == ps)continue;
 
      dfs(i,s);
    }
 
 
    auto it1 = ss.find(node[s]);
    if(it1 != ss.end())ss.erase(it1); // to delete vertices not in current path
 
 
    if(y != -1)ss.insert(y); // to restore LIS 
 
 
}

int32_t main()
  { 
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    IOS
    int n,u,v;
    cin>>n;
    g.resize(n+1);
    node.resize(n+1,0);
    ans.resize(n+1,0);
    for(int i=1;i<=n;i++)
      cin>>node[i];
    for(int i=1;i<=n-1;i++)
    {
      cin>>u>>v;
      g[u].pb(v);
      g[v].pb(u);
    }
    
      vis.resize(n+1,false);
      dfs(1,0);
    for(int i=1;i<=n;i++)
    {
    	cout<<ans[i]<<endl;
    }
      
 
   return 0;
   
}



Measured memory_bytes: 29160
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;j++)
		if(k==(i*j)+(n-i)*(m-j))
		{
			cout<<"Yes";
		return 0;
		}
			cout<<"No";
			return 0;
		
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 W, H, x, y;
  cin >> W >> H >> x >> y;
  f80 ans = (f80) W * H / 2;
  cout << ans << ' ';
  if (W == x * 2 && H == y * 2) {
    cout << 1 << '\n';
  } else {
    cout << 0 << '\n';
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
constexpr int N_MAX = 1e5;

struct Edge {
  int to;
  ll w;

  Edge(int _to, ll _w)
    : to(_to), w(_w) {}
};

vector<vector<Edge> > G(N_MAX);
vll d(N_MAX, 0);
vector<bool> visited(N_MAX);

void dfs(int x) {
  for (const auto& e : G[x]) {
    if (visited[e.to]) continue;

    d[e.to] = (e.w+d[x])%2;
    visited[e.to] = true;
    dfs(e.to);
  }
}

int main(int argc, char** argv) {
  int N;
  cin >> N;

  if (N==1) {
    cout << "0" << endl;
    return 0;
  }

  for (int i=0; i<N-1; i++) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    u--; v--; // 0-indexed
    G[u].emplace_back(v, w);
    G[v].emplace_back(u, w);
  }

  visited[0] = true;
  d[0] = 0;
  dfs(0);

  for (int i=0; i<N; i++) {
    cout << d[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
int n;
  cin>>n;
  int count = 0;
  int ans = 0;
  FOR(i,1,n+1){
    count = 0;
    FOR(j,1,i+1){
      if(i%2==0)break;
      if(i%j==0){
        count++;
      }
    }
    if(count==8){
      ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
/*ex4_2
ryo_1129*/
#include<stdio.h>
#include<math.h>
double distance(int length_hour,int length_minute,double rad);

int main(void){
    //変数宣言
    int A,B,H,M;
    double radlong,radshort,rad,length;
    //入力
    scanf("%d %d %d %d",&A,&B,&H,&M);
    //演習率πを決める。
    const double pi = 3.14159265358979;
    //時針、分針を求める。
    radlong = 2*pi*M/60;
    radshort = 2*pi*(H*60+M)/720;
    //角度の差を求める
    rad = radlong - radshort;
    //出力
    length = distance(A,B,rad);
    printf("%.9f\n",length);
    return 0;
}
double distance(int length_hour,int length_minute,double rad){
    double length;
    length = sqrt(pow(length_hour,2)+pow(length_minute,2)-2*length_hour*length_minute*cos(rad));
    return length;
}

Measured memory_bytes: 2592
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,l):
    res = 0
    for x,u in l:
        res += calc(x,u)
    return res
    
def calc(x,u):
    return int(x) if u == "JPY" else float(x) * 380000

n = ii()
l = list([input().split() for _ in range(n)])
print(main(n,l))

Measured memory_bytes: 3064
n,a,b=map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  ans=min(n-a,b-1)
  ans=min(ans,a+(b-a-1)//2)
  ans=min(ans,n-b+1+(b-a-1)//2)
  print(ans)


Measured memory_bytes: 2940