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


#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
	int n;
	int a,b;
	cin >> n >> a >> b;
	vector<int> d(n);
	for (int i = 0;i < n;i++) {
		d[i] = i+1;
	}
	
	int ans = 0;
	for(int i = 0;i < n;i++) {
		int sum = 0;
		while(d[i] > 0) {
		sum += d[i] % 10;
		d[i] /= 10;
		}
		if (sum >= a && sum <= b) ans += i + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws IOException {
		// 2020/2/4 No.148
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();

		while (sc.hasNextLine()) {
		    String str = sc.nextLine();
            if ("".equals(str)) {
                break;
            }
		    list.add(Integer.parseInt(str));
		}

		int A = list.get(0);
		int B = list.get(1);

		if((A == 1 && B == 2) || (A == 2 && B == 1))
			System.out.println(3);
		else if((A == 1 && B == 3) || (A == 3 && B == 1))
			System.out.println(2);
		else if((A == 2 && B == 3) || (A == 3 && B == 2))
			System.out.println(1);
	}
}

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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert_tree(int num){
    Node *find = root;
    Node *tmp_parent = NIL;
    Node *obj;

    obj = new Node;
    obj->key = num;
    obj->left = NIL;
    obj->right = NIL;

    while (find != NIL){
        tmp_parent = find;
        if(find->key > obj->key){
            find = find->left;
        }
        else{
            find = find->right;
        }
    }
    obj->parent = tmp_parent;

    if(tmp_parent == NIL){
        root = obj;
    }
    else{
        if(tmp_parent->key > obj->key){
            tmp_parent->left = obj;
        }
        else{
            tmp_parent->right = obj;
        }
    }
}

void find_key(int num){
    
    Node *find = root;

    while (find != NIL){
        if(find->key == num){
            cout << "yes" << endl;
            return;
        }
        else if(find->key > num){
            find = find->left;
        }
        else{
            find = find->right;
        }
    }
    cout << "no" << endl;
}

void inorder(Node *node){

    if(node == NIL){
        return;
    }
    inorder(node->left);
    cout << " " << node->key;
    inorder(node->right);
}

void preorder(Node *node){

    if(node == NIL){
        return;
    }
    cout << " " << node->key;
    preorder(node->left);
    preorder(node->right);
}

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

    string command;
    int num;
    rep(i, n){
        cin >> command;
        if(command == "insert"){
            cin >> num;
            insert_tree(num);
        }
        else if(command == "print"){
            inorder(root);
            cout << "\n";
            preorder(root);
            cout << "\n";
        }
        else if(command == "find"){
            cin >> num;
            find_key(num);
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
//freopen("in.txt","r",stdin);
  long long n;
  cin>>n;
  long ans=1;
  for(long  i=1;i*i<=n;i++)
  {
      if(n%i==0)
      {
          if(ans<i)
            ans=i;
      }
  }
  if(ans==1)
    cout<<n-1<<endl;
  else
  {
        long long m= n/ans;
        cout<< m+ans-2;
  }




    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N,i,ret;
	while(scanf("%d",&N), N){
		ret = 0;
		for(i = 2;i <= 44;i++){
			if ((N << 1) % i == 0 && (((N << 1) / i + i) & 1) && (N << 1) / i > i)
				ret++;
		}
		printf("%d\n",ret);
	}
	return 0;
}

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

using namespace std;

const int N = 100010;

int n;
int a[N];
int b[N];

long long calc(int p, int k) {
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    bool ok = true;
    for (int j = 29; j >= p; --j) {
      int ba = (a[i] >> j) & 1;
      int bk = (k >> j) & 1;
      if (ba == 1 && bk == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      res += b[i];
    }
  }
  return res;
}

int main() {
  int k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", a + i, b + i);
  }
  long long ans = calc(0, k);
  for (int i = 0; i < 30; ++i) {
    if ((k >> i) & 1) {
      ans = max(ans, calc(i, k ^ (1 << i)));
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool check(string &a, string &b){
	for (int i=0;i<a.length();i++)
		if (a[i]!=b[i])
			return false;
	return true;
}
int main(){
	string a,b;
	cin>>a>>b;
	if ((b.length()-a.length()==1)&&check(a,b))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
	return *(  int *) b - *(int *) a;
	//qsort(b, a, sizeof(long long int), int_sort);
}

int main() {
	int a,b;
	vector<int>A(1000000,0);
	cin>>a>>b;
	if(a*b%2==1){
		cout<<"Odd";
		return 0;
	}
	else{
		cout<<"Even";
		return 0;
	}

	return 0;


}


Measured memory_bytes: 4096
n=int(input())
ac=0
wa=0
tle=0
re=0
for m in range(n):
  a=input()
  if a=='AC':
    ac=ac+1
  elif a=='WA':
    wa=wa+1
  elif a=='TLE':
    tle=tle+1
  else:
    re=re+1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9120
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        if (N == 1)
        {
                cout << "Hello World" << endl;
        } else{
                int A, B;
                cin >> A >> B;
                cout << A + B << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn=1e7+5;
int n,primes[maxn],low[maxn],pcnt=0;bool isprime[maxn];
int cnt[maxn],e[maxn];
int main()
{
	scanf("%d",&n);
	isprime[1]=false,low[1]=cnt[1]=1;
	for(int i=2;i<=n;++i) isprime[i]=true;
	for(int i=2;i<=n;++i)
	{
		if(isprime[i]) primes[pcnt++]=i,low[i]=i,cnt[i]=2,e[i]=1;
		for(int j=0;j<pcnt&&i*primes[j]<=n;++j)
		{
			isprime[i*primes[j]]=false;
			if(i%primes[j]==0){
				low[i*primes[j]]=low[i]*primes[j];
				e[i*primes[j]]=e[i]+1;
				cnt[i*primes[j]]=cnt[i*primes[j]/low[i*primes[j]]]*(e[low[i*primes[j]]]+1);
				break;
			} else {
				low[i*primes[j]]=primes[j];e[i*primes[j]]=1;
				cnt[i*primes[j]]=cnt[i]*2;
			}
		}
	}
	LL ans=0;
	for(int i=1;i<=n;++i) ans+=(LL)cnt[i]*i;
	printf("%lld",ans);
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	string s; cin >> s;
	int sum = 0;
	for (int i = 0; i < s.length(); i++)
	{
		sum += (s[i] - '0');
	}
	if (sum % 9 == 0)
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++){
      if((i*7)+(j*4)==n){
        cout<<"Yes"<<endl;
        return 0;
        }
      }
  cout<<"No"<<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // メインプログラムここから
    string A, B, C; cin >> A >> B >> C;
    // cout << "A" << B[0] << "C" << endl;
    cout << "A" << B.front() << "C" << endl;
    // ここまで
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

template<typename Monoid> class RangeActionSegTree {
  using T = typename Monoid::value_type;

  Monoid m;
  vector<T> tree; // 1-indexed
  int size = 1;

public:
  RangeActionSegTree(const int &n = 0) {
    while (size < n) size *= 2;
    tree.assign(size * 2, m.id());
  }

  void act(int l, int r, const T &x) { // [l, r) += x
    for (l += size, r += size; l < r; l /= 2, r /= 2) {
      if (l & 1) tree[l] = m(tree[l], x), l++;
      if (r & 1) r--, tree[r] = m(tree[r], x);
    }
  }

  T operator[](int i) {
    T acc = tree[i += size];
    while (i /= 2) acc = m(acc, tree[i]);
    return acc;
  }
};

template<typename T> struct sumMonoid {
  using value_type = T;
  value_type id() { return 0; }
  value_type operator()(const value_type &a, const value_type &b) { return a + b; }
};

main {
  int n, q;
  cin >> n >> q;
  RangeActionSegTree<sumMonoid<int>> ras(n);
  while (q--) {
    if (in()) {
      cout << ras[in() - 1] << endl;
    } else {
      int s, t, x;
      cin >> s >> t >> x;
      ras.act(--s, t, x);
    }
  }
}



Measured memory_bytes: 4948
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    int r = n%10;
    if(r == 3) cout << "bon" << endl;
    else if(r == 0 || r == 1 || r == 6 || r == 8) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            // 条件を順番に潰していく。
            // WAの条件に引っかかった時点で出力し、最後まで残ったものがACになる。

            // Aから始まるか判定
            if (!S.StartsWith("A"))
            {
                Console.WriteLine("WA");
                return;
            }

            // 3文字目と末尾から2文字目の間にCがあるか判定
            var tmp = S.Substring(2, S.Length - 3);
            if (tmp.Where(x => x == 'C').ToList().Count != 1)
            {
                Console.WriteLine("WA");
                return;
            }

            // 3文字目と末尾から2文字目に存在する大文字Cの位置を求める
            var cindex = tmp.IndexOf('C') + 2;

            // AとCを消す
            S = S.Remove(cindex, 1).Remove(0, 1);

            // AとCを消した後の文字列に大文字が含まれるか判定
            foreach (var item in S)
            {
                if (char.IsUpper(item))
                {
                     Console.WriteLine("WA");
                     return;
                }
            }

            Console.WriteLine("AC");
        }
    }
}

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

using namespace std;

int main(void){
    unsigned long long  N, K;
    cin >> N >> K;
    unsigned long long ans = 0;
    
    // a = b
    //if(K == 0) ans += N;

    // a < b
    for(unsigned long long  a=max<unsigned long long>(K, 1);a<=N;a++){
        ans += N-a;
    }

    // a >= b
    for(unsigned long long b=N;b>K;b--){
        unsigned long long u = (N-b)/b;
        unsigned long long d = (N-b)%b;
        ans += (b-K)*u + (d>=K?d-K+1:0);
    }

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

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

using namespace std;

const int N = 1e5 + 5;
vector<pair<int, int>> thing[N], things;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin.exceptions(cin.failbit);
	int n, c;
	cin >> n >> c;
	
	for (int i = 0; i < n; ++i) {
		int s, t, channel;
		cin >> s >> t >> channel;
		--channel;
		thing[channel].emplace_back(s, 0);
		thing[channel].emplace_back(t, 1);
	}
	for (int i = 0; i < c; ++i) {
		sort(thing[i].begin(), thing[i].end());
		for (int j = 0; j < thing[i].size(); ++j)
			if (j + 1 < thing[i].size() and thing[i][j].first == thing[i][j + 1].first and thing[i][j].second != thing[i][j + 1].second)
					++j;
			else
				things.push_back(thing[i][j]);
	}
	sort(things.begin(), things.end());
	int beg = 0, mx = 0;
	for (int i = 0; i < things.size(); ++i) {
//				cerr << things[i].first << ' ' << things[i].second << endl;
		if (things[i].second == 0)
			++beg;
		if (things[i].second == 1)
			--beg;
		mx = max(mx, beg);
	}
	cout << mx << endl;
}


Measured memory_bytes: 7156
int main()
{
   char s[5];
   int i,ln=0,j;
   gets(s);
    for(i=0;i<4;i++){
     for(j=0;j<4;j++){
        if(s[i]==s[j+1]){
            ln++;
        }
        j++;
     }

     }
    if(ln==4)
        printf("Yes\n");
        else
            printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  string s;
  cin >> s;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      cout << "Bad";
      return 0;
    }
  }
  
  cout << "Good";
  return 0;
}


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

namespace CSharpSample01
{
    class Program
    {
        static bool[,] q;
        const int N = 8;
        const int Free = -1;
        const int Not_Free = 1;
        static int[] row;  
        static int[] culm;  
        static int[] slan_right; 
        static int[] slan_left;
        

        
       
        static void Visit(int i)
        {
            
            if(i == N)
            {
                Print();
                return;
            }
            
            for(int j = 0; j < N; j++)
            {

                if(culm[j] == Not_Free || slan_right[i + j] == Not_Free || slan_left[i - j + N - 1] == Not_Free)
                {
                    continue;
                }

                row[i] = j;  
                culm[j] = Not_Free;
                slan_right[i + j] = Not_Free;
                slan_left[i - j + N - 1] = Not_Free;

                
                Visit(i + 1);

                row[i] = Free;
                culm[j] = Free;
                slan_right[i + j] = Free;
                slan_left[i - j + N - 1] = Free;

            }

        }

        static void Print()
        {
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    if(q[i, j])
                    {
                        if(row[i] != j)
                        {
                            return;
                        }
                    }
                }
            }


            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    if(row[i] == j)
                    {
                        Console.Write("Q");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }

        }

        static void Initial()
        {
            for(int i = 0; i < N; i++)
            {
                row[i] = Free;
                culm[i] = Free;
            }
            for(int i = 0; i < 2 * N - 1; i++)
            {
                slan_left[i] = Free;
                slan_right[i] = Free;
            }

        }


        static void Main(string[] args)
        {

            q = new bool[N, N];
            row = new int[N];
            culm = new int[N];
            slan_right = new int[2 * N - 1];
            slan_left = new int[2 * N - 1];
            
            Initial();
    
            int k = int.Parse(Console.ReadLine());

            string[] input;
            int r;
            int c;
            for(int i = 0; i < k; i++)
            {
                input = Console.ReadLine().Split(' ');
                r = int.Parse(input[0]);
                c = int.Parse(input[1]);
                q[r, c] = true;
            }

            Visit(0);            
                  
        }
    }
}



Measured memory_bytes: 17936
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  double r;cin>>r;
  printf("%.12lf\n",2*r*M_PI);
  return 0;
}


Measured memory_bytes: 3780
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static long INF = Long.MAX_VALUE/2;
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int V = stdIn.nextInt();
		int E = stdIn.nextInt();
		long[][] d = new long[V][V];
		for(int i=0;i<V;i++){
			Arrays.fill(d[i],INF);
			d[i][i] = 0;
		}
		
		for(int i=0;i<E;i++){
			int s = stdIn.nextInt();
			int t = stdIn.nextInt();
			int l = stdIn.nextInt();
			d[s][t] = l;
		}
		
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				for(int k=0;k<V;k++){
					if(d[j][i]+d[i][k]<d[j][k]){
						d[j][k] = d[j][i]+d[i][k];
					}
				}
			}
		}
		
		for(int i=0;i<V;i++){
			if(d[i][i]<0){
				System.out.println("NEGATIVE CYCLE");
				return;
			}
		}
		
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				if(d[i][j]>=INF/2){
					System.out.print("INF");
				}
				else{
					System.out.print(d[i][j]);
				}
				if(j!=V-1){
					System.out.print(" ");
				}
			}
				System.out.println();
		}
	}
}

Measured memory_bytes: 51056
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int ans = pow(3, N);
  int odd = 1;
  for (int i = 0; i < N; i++) if (!(a[i] & 1)) odd *= 2;

  // 解答
  cout << ans - odd << endl;

  return 0;
}


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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String A = keyboard.next();
		String B = keyboard.next();
		String C = keyboard.next();

		System.out.print("A"+B.charAt(0)+"C");
		keyboard.close();	
	}
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
int main(){
    long long power = 1;
    long long a = 1000000007;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        power *= (i + 1);
        power = power % a;
    }
    cout << power << endl;
    return 0; 
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for (int i = 0; i < m; i++)cin >> x[i];
	sort(x.begin(), x.end());
	int ret = x[m - 1] - x[0];

	vector<int> sa(m - 1);
	for (int i = 0; i < m - 1; i++)sa[i] = x[i + 1] - x[i];
	sort(sa.begin(), sa.end());
	reverse(sa.begin(), sa.end());

	for (int i = 1; i < min(n, m); i++)ret -= sa[i - 1];
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int scount = sc.nextInt();
		int tcount = sc.nextInt();

		String u = sc.next();
		
		if(s.equals(u)) {
			scount = --scount; 
			
		}else {
			tcount= --tcount;
		}
		

		System.out.println(scount+" "+tcount);
		

	}
}

Measured memory_bytes: 38856
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int A, B;

	cin >> A >> B;
	cout << max({A+B, A-B, A*B}) << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	cout <<(long long) ceil((double)n / min({a,b,c,d,e})) + 4 << endl;
}

Measured memory_bytes: 256
n = int(input().strip())
d = list(map(int, input().split()))
h = [0] * n
for x in d:
  h[x] += 1

ans = 1
mod = 998244353
for i in range(1, n):
  ans = (ans * pow(h[i-1], h[i], mod)) % mod

if h[0] != 1 or d[0] != 0:
  ans = 0

print (ans)


Measured memory_bytes: 13892
#include <iostream>
#include <math.h>
#include <string.h>

#include <algorithm>

using namespace std;

int main()
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	int l;
	l = x - a;
	int j;
	j = l % b;
	printf("%d\n",j);
	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();
    String c = sc.next();
    sc.close();
    int[] w_cnt = new int[n];
    for(int i = 0; i < c.length(); i++){
      if(i != 0){
        w_cnt[i] = w_cnt[i - 1];
      }
      if(c.charAt(i) == 'W'){
        w_cnt[i]++;
      }
    }
    int r_cnt = n - w_cnt[w_cnt.length - 1];
    System.out.println(r_cnt == 0 ? 0 : w_cnt[r_cnt - 1]);
  }
}

Measured memory_bytes: 41440
def solve():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
    
        divisors.sort()
        return divisors
    
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        if len(make_divisors(i)) == 8 and i%2 == 1:
            ans += 1
    
    print(ans)

if __name__ == "__main__":
    solve()
    

Measured memory_bytes: 9448
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename V> class BIT {
private:
	int n; vector<V> bit;
public:
	void add(int i,V x){ i++; while(i < n) bit[i] += x, i += i & -i;}
	V sum(int i){ i++; V s = 0; while(i>0) s += bit[i], i -= i & -i; return s;} //0_indexedでi以下の要素の和
	BIT(){} BIT(int sz){ n = sz + 1, bit.resize(n,0);} //初期値がすべて0の場合
	BIT(vector<V> v){ n = (int)v.size()+1; bit.resize(n); rep(i,n-1) add(i,v[i]);}
	void print(){ rep(i,n-1)cout<<sum(i)-sum(i-1)<< " ";cout<<endl;}
	void print_sum(){ rep(i,n)cout<<sum(i-1)<<" ";cout<<endl;}	//-1スタート
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> X(2*n),Y(2*n);
    vector<int> a(n),b(n),c(n),d(n);
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        if(a[i] > c[i]) swap(a[i],c[i]);
        if(b[i] > d[i]) swap(b[i],d[i]);
        X[2*i] = a[i], X[2*i+1] = c[i];
        Y[2*i] = b[i], Y[2*i+1] = d[i];
    }
    zip(X),zip(Y);
    vector<vector<int> > st(len(Y)),ed(len(Y));
    vector<vector<P> > ch(len(Y));
    rep(i,n){
        if(a[i] != c[i]){
            //横線
            ch[lower_bound(all(Y),b[i])-Y.begin()].pb(P(lower_bound(all(X),a[i])-X.begin(),lower_bound(all(X),c[i])-X.begin()));
        }else{
            //縦線
            st[lower_bound(all(Y),b[i])-Y.begin()].pb(lower_bound(all(X),a[i])-X.begin());
            ed[lower_bound(all(Y),d[i])-Y.begin()].pb(lower_bound(all(X),a[i])-X.begin());
        }
    }
    int ans = 0;
    BIT<int> bt(len(X));
    rep(i,len(Y)){
        each(j,st[i]){
            bt.add(j,1);
        }
        each(j,ch[i]){
            ans += bt.sum(j.se) - bt.sum(j.fi-1);
        }
        each(j,ed[i]){
            bt.add(j,-1);
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 12596
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
bitset<4000010>dp;
int a[100010]; 
int main()
{
	int n,Sum=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),Sum+=a[i];
	dp[0]=1;
	for (int i=1;i<=n;i++)
		dp|=dp<<a[i];
	for (int i=(Sum+1)>>1;i<=Sum;i++)
		if (dp[i]) 
		{
			printf("%d\n",i);
			break;
		}
	return 0;
}

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

using namespace std;

const int nax=3003;
long long int dp[nax][nax];

int main()
{
    int n; cin>>n;
    int * a=new int[n+1];
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) dp[i][i]=a[i];
    for(int len=2;len<=n;len++)
    {
        for(int i=1;i<=n;i++)
        {
            int j=i+len-1;
            if(j>n) continue;
            dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
    cout<<dp[1][n];
    return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define rei register int
using namespace std;
int n;
int a1[200],a2[200];
int main(){
	cin >> n; int now = 0,maxx = 0;
	for(rei i = 1;i <= n;++i){
		scanf("%d%d",&a1[i],&a2[i]);
		if(a1[i] == a2[i]) now = now + 1;
		else now = 0; maxx = max(maxx,now);
	} if(maxx >= 3) puts("Yes");
	else puts("No"); return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define MAX 100010
using namespace std;
int A[100000];
int table[100010];
int table_2[100010];
int main() {
  int N; cin >> N;
  rep (i, N) {
    cin >> A[i];
  }
  table[N - 1] = abs(A[N - 1]);
  int next_pos = A[N - 1];
  table_2[0] = abs(A[0]);
  int pos = A[0];
  REP(i, 1, N) {
    table[N - i - 1] = abs(A[N - i - 1] - next_pos) + table[N - i];
    next_pos = A[N - i - 1];
    table_2[i] = table_2[i - 1] + abs(A[i] - A[i-1]);
    pos = A[i];

  }
  // rep(i, N) {
  //   cout << i << " -> " << table[i] << endl;
  //   cout << i << " -> " << table_2[i] << endl;
  // }
  rep(i, N) {
    // i を除いた場合の値を返す
    // i + 1 までにかかる値 + table[i+1]
    ll val = 0;
    if (i == 0) {
      val = abs(A[1]) + table[1];
    } else if (i == N-1) {
      val = table_2[N-2] + abs(A[N-2]);
      // cout << "asdf " << table_2[N-2] << endl;
    } else {
      val = table_2[i-1] + abs(A[i+1] - A[i-1]) + table[i+1];
    }
    cout << val << endl;
  }
}

Measured memory_bytes: 2432
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;

class Iku {
  int dist;
  long cost;
}

class Node {
  int now;
  long cost;
}

void bfs(int k, int n, Iku[][] adj, long[] memo)
{
  Node[] queue;
  Node atom = new Node();
  atom.now = k;
  atom.cost = 0;
  queue ~= atom;
  bool[] done = new bool[n + 1];
  while (queue.length) {
    Node node = queue.front;
    queue = queue[1..$];
    if (done[node.now]) {
      continue;
    }
    done[node.now] = true;
    memo[node.now] = node.cost;
    foreach (Iku iku; adj[node.now]) {
      Node next = new Node();
      next.cost = node.cost + iku.cost;
      next.now = iku.dist;
      queue ~= next;
    }
  }
}

void main()
{
  int n = readln.chomp.to!int;
  Iku[][] adj = new Iku[][](n + 1, 0);
  foreach (i; 0..n - 1) {
    auto l = readln.chomp.split.map!(to!int).array;
    Iku left = new Iku();
    left.dist = l[1];
    left.cost = l[2];
    adj[l[0]] ~= left;
    Iku right = new Iku();
    right.dist = l[0];
    right.cost = l[2];
    adj[l[1]] ~= right;
  }
  long[] memo = new long[n + 1];
  memo[] = -1;
  auto l = readln.chomp.split.map!(to!int).array;
  int q = l[0];
  int k = l[1];
  bfs(k, n, adj, memo);
  foreach (i; 0..q) {
    auto m = readln.chomp.split.map!(to!int).array;
    int x = m[0];
    int y = m[1];
    long sum = memo[x] + memo[y];
    writeln = sum;
  }
}


Measured memory_bytes: 38396
n,k = map(int,input().split())
a = list(map(int,input().split()))

l = 0
r = 10**10

while r > l + 1:
    m = (r+l)//2
    count = 0
    for i in a:
        if i <= m:
            continue
        count += (i-1)//m
        
    if count > k:
        l = m
    else:
        r = m
    
print(r)

Measured memory_bytes: 30988
n = int(input())
a = list(map(int, input().split()))
aset = set(a)
d = {i:0 for i in aset}
for i in range(n):
    d[a[i]] += 1
aset = sorted(aset)
if len(aset) == 1:
    print(d[aset[0]])
    exit()
if len(aset) == 2:
    if abs(aset[0]-aset[1]) <= 1:
        print(d[aset[0]] + d[aset[1]])
    else:
        print(max(d[aset[0]], d[aset[1]]))
    exit()
ans = 0
for i in range(len(aset)-2):
    ans = max(d[aset[i]], ans)
    if aset[i+1] - aset[i] == 1:
        ans = max(d[aset[i+1]]+d[aset[i]], ans)
    if aset[i+2] - aset[i] == 2:
        ans = max(d[aset[i+2]]+d[aset[i+1]]+d[aset[i]], ans)
print(ans)


Measured memory_bytes: 16228
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (Math.abs(a - c) <= d) {
			pr.println("Yes");
		} else if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll n;
  cin>>n;

  ll ans=0;
  rep(i,n){
    ans+=(ll)(i+1)*(ll)(n-i);
  }

  ll a,b;
  rep(i,n-1){
    cin>>a>>b;
    if(a>b) swap(a,b);
    ans-=a*(ll)(n+1-b);
  }

  cout << ans << endl;
}


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

int main(){
	string d;
	cin >> d;
	if(d == "SAT"){
		cout << "1" << endl;
	}else if(d == "FRI"){
		cout << "2" << endl;
	}else if(d == "THU"){
		cout << "3" << endl;
	}else if(d == "WED"){
		cout << "4" << endl;
	}else if(d == "TUE"){
		cout << "5" << endl;
	}else if(d == "MON"){
		cout << "6" << endl;
	}else{
		cout << "7" << endl;
	}
		
}
		




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N;
int A[210];

int main() {
  cin >> N;
  int r = 0;
  for(int i=0; i<N; i++) cin >> A[i];
  while(true) {
    bool exist_odd = false;
    for(int i=0; i<N; i++) {
      if(A[i]%2!=0) exist_odd = true;
    }
    
    if(exist_odd) break;
    for(int i=0; i<N; i++) {
      A[i] = A[i] /2;
    }
    r++;
  }

  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
import itertools 

A = [list(map(int,input().split())) for i in range(3)]
AA = list(itertools.chain.from_iterable(A))
grid = []
N = int(input())
for i in range(N):
  b = int(input())
  if b in AA:
    grid.append(AA.index(b))
    
#print(grid)

if (0 in grid and 4 in grid and 8 in grid) or (2 in grid and 4 in grid and 6 in grid):
  print("Yes")
elif(0 in grid and 1 in grid and 2 in grid) or (3 in grid and 4 in grid and 5 in grid) or (6 in grid and 7 in grid and 8 in grid):
  print("Yes")
elif(0 in grid and 3 in grid and 6 in grid) or (1 in grid and 4 in grid and 7 in grid) or (2 in grid and 5 in grid and 8 in grid):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main (void)
{
 string s;

  cin >> s;

  if(s[0] + s[1] + s[2] == 'a' + 'b' + 'c'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int dp[2005][2005];

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

    
    ll a,b; cin >> a >> b;

    if(a==b) cout << 1 << endl;
    else{
        if((a+b)%2LL==1LL) cout << "IMPOSSIBLE" << endl;
        else cout << (a+b)/2LL << endl;
    }
    

    return 0;
}

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

// main.cpp

int main() {
  std::int_fast64_t N;
  std::cin >> N;
  std::vector<std::int_fast64_t> d;
  d.reserve(N);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), N, std::back_inserter(d));
  std::sort(d.begin(), d.end());

  std::cout << d[N / 2] - d[N / 2 - 1] << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<deque>
#include<iostream>
#include<cstdio>
#include<algorithm>
#define F first
#define S second
using namespace std;

bool check(deque<int>& deq,int counter)
{
  for(int i=deq.size()-1;i>=0;i--)
	    {		
	      if(deq[i] != counter)
		return false;
	      else		
		counter--;
	    }
  return counter == 0;
}

int main()
{
  int N;

  //deque<int> tes;
  //for(int i=0;i<5;i++)
    //tes.push_back(i);
  //deque<int>::iterator it = tes.begin();
  //tes.erase(it+3);
  //for(deque<int>::iterator it = tes.begin();it!=tes.end();it++)
    //{
      //(*it)+=2100;
      //}
  //for(int i=0;i<tes.size();i++)
    //cout << tes[i] << endl;
    //cout << "----" << endl;
  //         0 1 2 3 4
  //index -> 0 1 2 3 4

  while(true)
    {
      cin >> N;
      if(!N)
	break;
      deque<int> deq;
      for(int i=0;i<N;i++)
	{
	  int input;
	  cin >> input;
	  deq.push_back(input);
	}

      if(check(deq,N))
	{
	  cout << 0 << endl;
	  continue;
	}     

      bool fin = true;

      for(int m = 1;m <= 10000;m++)
	{/*1*/
	  //cout << "m = " << m << endl;
	  fin = true;
	  int counter = 0;
	  deque<int> n_deq;
	  for(int i=0;i<deq.size();i++)
	    {
	      if(deq[i] >= 1)
		{
		  counter++;
		  deq[i]--;
		}
	      if(deq[i] >= 1)
		{
		  n_deq.push_back(deq[i]);
		}
	    }
	  
	  /*
	  for(deque<int>::iterator it = deq.begin();it != deq.end(); it++)
	    {
	      if((*it) >= 1)
		{
		  counter++;
		  (*it)-=1;
		}
	      if((*it) <= 0)
		{
		  deq.erase(it);
		}
	    }
	  */
	  deq = n_deq;
	  deq.push_back(counter);
	  /*
	  for(int i=deq.size()-1;i>=0;i--)
	    {		
	      if(deq[i] != counter)
		  fin = false;		
	      else 
		counter--;
	    }
	  */
	  if(check(deq,counter))
	    {
	      cout << m << endl;
	      fin = false;
	      break;
	    } 
	}/*1*/
      if(fin)
	cout << -1 << endl;
     
    }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int n,m;
int d[200005];
int op,u,v;
/*
 4 7
 1 0 1
 0 0 1
 0 2 3
 1 0 1
 1 1 2
 0 0 2
 1 1 3
 */

int find(int u){
    if(d[u]<0) return u;
    return d[u]=find(d[u]);
}

bool union_join(int u, int v){
    int a=find(u);
    int b=find(v);
    if(a==b) return false;
    if(a>b)swap(a, b);
    d[a]+=d[b];
    d[b]=a;
    return true;
}

bool same_set(int u, int v){
    return find(u)==find(v);
}

int main() {
    cin>>n>>m;
    memset(d, -1, sizeof(d));
    while(m--){
        cin>>op>>u>>v;
        if(op==0){
            union_join(u, v);
        }else{
            if(same_set(u, v)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3940
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		
		while(true){
			int num = scan.nextInt();
			if(num == 0){
				break;
			}
			int count = 0;
			int div = 5;
			
			while(num/div != 0){
				count += num/div;
				div *= 5;
			}
			
			System.out.println(count);
		}
	}
}

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

string S;
bool used[26];
int ans = 1000;

bool check_same(string st) {
	int len = st.length();
	string same = string(len, st[0]);
	return st == same;
}

string do_1time(string st, int cn) {
	char ch = (char)(cn + 'a');
	string ret = st;
	for (int i = 1; i < (int)st.length(); ++i) {
		if (st[i - 1] == ch || st[i] == ch)
			ret[i - 1] = ch;
		else
			ret[i - 1] = st[i - 1];
	}
	ret.erase((int)st.length() - 1);
	return ret;
}

int main(void) {
	cin >> S;
	fill(used, used + 26, false);
	for (int i = 0; i < (int)S.length(); ++i) {
		int c_num = (int)(S[i] - 'a');
		if (used[c_num])
			continue;
		used[c_num] = true;
		string str = S;
		int times = 0;
		while (true) {
			if (check_same(str))
				break;
			++times;
			str = do_1time(str, c_num);
		}
		ans = min(ans, times);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <tuple>
#include <string>

using namespace std;

#define MAX(A, B)	((A) > (B) ? (A) : (B))
#define MIN(A, B)	((A) < (B) ? (A) : (B))

int main(int argc, char const *argv[]) {
	string s, t;
	cin >> s >> t;

	if (t.size() > s.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	vector<string> v;

	for (int i = s.size() - t.size(); i >= 0; --i) {
		bool canInsert = true;
		for (int j = 0; j < t.size(); ++j) {
			// cout << s[i + j] << " : " << t[j] << ", ";
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				canInsert = false;
				break;
			}
		}

		if (canInsert) {
			string str;
			for (int k = 0; k < i; ++k) {
				str += (s[k] == '?' ? 'a' : s[k]);
			}
			str += t;
			for (int k = i + t.size(); k < s.size(); ++k) {
				str += (s[k] == '?' ? 'a' : s[k]);
			}
			v.push_back(str);
		}
	}

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

	if (v.size() == 0)
		cout << "UNRESTORABLE" << endl;
	else
		cout << v[0] << endl;
	return 0;
}

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

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

	vector<int> av(n);
	for (auto& i : av) {
		cin >> i;
	}

	sort(av.begin(),av.end(), std::greater<int>());

	int sumA = 0;
	int sumB = 0;
	for (int i = 0; i < n; ++i) {
		if (i % 2 == 0) {
			sumA += av[i];
		}
		else {
			sumB += av[i];
		}
	}

	cout << sumA - sumB << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] a = new int[10000];
		
		int max= -1000000;
		int min = 1000000;
		long sum = 0;
		for(int i=0; i<n; i++)
		{
			a[i] = scanner.nextInt();
			if(i == 0)
			{
				max = a[0];
				min = a[0];
			}
			else
			{
					if(a[i] > max)
					{
						max = a[i];
					}
					else if(a[i] < min)
					{
						min = a[i];
					}
			}
			
			sum += a[i];
		}
		
		System.out.printf("%1$d %2$d %3$d\n", min, max, sum);
	}
}

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


void solve(long long N, std::vector<long long> P, std::vector<long long> Q)
{
    long long k=0,a=0,b=0;
    vector<long long> A(N);
    for(unsigned int i=0;i<N;i++)
        A[i]=i+1;
    do
    {
        k++;        
        bool flag=true;
        for(unsigned int i=0;i<N;i++)
            if(P[i]!=A[i])
            {
                flag=false;
                break;
            }
        if(flag)
            a=k;
        flag=true;
        for(unsigned int i=0;i<N;i++)
            if(Q[i]!=A[i])
            {
                flag=false;
                break;
            }
        if(flag)
            b=k;    
    }while(next_permutation(A.begin(),A.end()));
    cout<<abs(a-b)<<endl;
}

int main()
{
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int count = 0;
    rep(i, n){
        if(s[i] == 'R'){
            count++;
        }
    }
    if(count > n - count)cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int main(){
	int A,V,B,W,T;
	cin>>A>>V>>B>>W>>T;
	if(W>=V){puts("NO");return 0;}
	int dist=abs(A-B),spd=V-W;
	int tim=(dist-1)/spd+1;
	if(tim<=T)puts("YES");
	else puts("NO");
}



Measured memory_bytes: 3552
n = gets.chomp.to_i
t, x, y = [], [], []
t[0] = x[0] = y[0] = 0
1.upto(n) do |i|
  t[i], x[i], y[i] = gets.chomp.split(" ").map(&:to_i)
end

can = true
i = 0
while i < n
 #puts "#{i}, #{t[i+1]}, #{t[i]}"
  dt = (t[i+1] - t[i])
  dist = (x[i+1] - x[i]).abs + (y[i+1] - y[i]).abs
  can = false if dist > dt || dt % 2 != dist % 2
  
 #puts "#{dist}, #{dt}, #{can}"
  i += 1
end

if can
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 4296
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    vector<int> b(n - 1);
    for(int i = 0; i < n - 1; ++i)
        cin >> b[i];

    vector<int> a(n);

    b.push_back(b.back());

    a[0] = b[0];
    for(int i = 1; i < n; ++i)
        a[i] = min(b[i], b[i - 1]);

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

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256