akhauriyash/Code-Regression huggingface dataset:
S = list(input())
T = list(input())

# 前計算
S_n = [0] * (len(S) + 1)
# S_n[0] = 1 if S[0] == 'A' else 2
for i in range(1, len(S) + 1):
    if S[i - 1] == 'A':
        S_n[i] = S_n[i - 1] + 1
    else:
        S_n[i] = S_n[i - 1] + 2

T_n = [0] * (len(T) + 1)
# T_n[0] = 1 if T[0] == 'A' else 2
for i in range(1, len(T) + 1):
    if T[i - 1] == 'A':
        T_n[i] = T_n[i - 1] + 1
    else:
        T_n[i] = T_n[i - 1] + 2

q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    #output
    S_A = S_n[b] - S_n[a - 1]
    T_A = T_n[d] - T_n[c - 1]
    delta = abs(S_A - T_A)
    if delta % 3 == 0:
        print ('YES')
    else:
        print ('NO')    




Measured memory_bytes: 14684
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool flag = false;
  for(int i = 1; i < b; i++){
    if((i*a)%b==c){
      flag = true;
    }
  }
  if(flag) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

  



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            for(int k = j+1; k < n; k++) {
                if(a[k] < (a[i]+a[j])) {
                    ans++;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int D,G,A=1e9;
vector<int> p(11),c(11);
void Bin(string str,int n)
{
  if(n==0)
  {
    int point=0,count=0,pos=D-1;
    for(char x:str)
    {
      if(x=='1')
      {
        rep(j,p.at(pos))
        {
          count++;
          point+=(pos+1);
          if(j==p.at(pos)-1){point+=c.at(pos);}
          if(point>=G){A=min(A,count);break;}
        }
      }
      pos--;
    }
  }
  else
  {
    Bin(str+"0",n-1);
	Bin(str+"1",n-1);
  }
}
int main()
{
  string str="";
  cin>>D>>G;
  G/=100;
  rep(i,D){cin>>p.at(i)>>c.at(i);c.at(i)/=100;}
  Bin(str,D);
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 200000
int main(){
  string str;
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  cin >> str;
  //str[A-1] = 'A';
  //str[B-1] = 'D';
  while(1){
    if(A == C && B == D){
      cout << "Yes";
      break;
    }
    if(A < C && str[A] == '.' && A+1 != B){
      A++;
    }else if(A+1 < C && str[A+1] == '.' && A+2 != B){
      A += 2;
    }else if(B < D && str[B] == '.' && B+1 !=  A){
      B++;
    }else if(B+1 < D && str[B+1] == '.'  &&  B+2 != A){
      B +=  2;
    }else{
      cout << "No";
      break;
    }
  }
}
                  
  


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}




int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];
	ll Q;
	cin >> Q;
	vector<ll> B(Q), C(Q);
	for(int i=0; i<Q; i++) cin >> B[i] >> C[i];

	map<ll, int> mp;
	ll sum = 0;
	for(int i=0; i<N; i++){
		mp[A[i]]++;
		sum += A[i];
	}

	for(int i=0; i<Q; i++){
		ll num = mp[B[i]];
		mp[B[i]] = 0;
		sum += (C[i] - B[i]) * num;
		mp[C[i]] += num;
		cout << sum << endl;
	}
	
	
	
}


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

using namespace std;

template<class T>
using V = vector<T>;
template<class T>
using VV = V<V<T>>;

using ld = long double;
#define ll long long
using ull = unsigned ll;
using PLL = pair<ll, ll>;
using VLL = V<ll>;
using VB = V<bool>;
using VVB = VV<bool>;
using VVLL = VV<ll>;
using Gr = VVLL;
using MLL = map<ll, ll>;
#define UMLL unordered_map<ll, ll, custom_hash>
//typedef __int128 int128;
//typedef __float128 double128;

#define fast ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);

#define INF LLONG_MAX
#define MINF LLONG_MIN

#define R &
#define CR const R

#define FORI(i, a, b) for(ll i = a, max##i = b; i < max##i; ++i)
#define FOR(i, n) FORI(i, 0, n)
#define RFORI(i, a, b) for(ll i = a, min##i = b; i >= min##i; --i)
#define RFOR(i, n) RFORI(i, n, 0)
#define FORA(i, a) for(auto i : a)
#define FORAR(i, a) for(auto R i : a)
#define FORACR(i, a) for(auto CR i : a)
#define ALL(obj) begin(obj), end(obj)
#define Count(q) while(q--)
#define OK cerr << "OK\n";

#define mp make_pair
#define pb push_back

//#define DEBUG

template<class T>
T sqr(T x)
{
    return x * x;
}

void YES(bool g, ostream R os, bool upper = false)
{
    if(g)
        if(upper)
            os << "YES";
        else
            os << "Yes";
    else
        if(upper)
            os << "NO";
        else
            os << "No";

    os << "\n";
}

template<class T>
ll cast(T CR t)
{
    return static_cast<ll>(t);
}

template<class T>
void show(T CR t, ostream R os = cerr)
{
    FORACR(i, t)
        os << i << " ";
    os << "\n";
}

constexpr ll MOD = 1e9 + 7;
//constexpr ll len = 2 * ('z' - 'a' + 1);
//constexpr ld eps = 1e-9;

//constexpr ld unreal = -1e9;

constexpr ld PI = atanl(1.0L) * 4;

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator() (uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve(istream R is, ostream R os)
{
    string s, t;
    is >> s >> t;
    ll n = s.size(), m = t.size();

    ll a = 0;
    FOR(i, n - m + 1)
    {
        ll c = 0;
        FORI(j, i, i + m)
            c += s[j] == t[j - i];

        a = max(a, c);
        //cerr << c << " ";
    }

    os << m - a << "\n";
}

int main()
{
    fast
    ll q = 1;
    //cin >> q;
    cout << setprecision(999);
    Count(q)
        solve(cin, cout);
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int n,sum,a[2020];
bitset<4040404>dp,yl;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	dp|=1;
	for(int i=0;i<n;i++)
	{
		dp|=(dp<<a[i]);
	}
	for(int i=0;i<=sum;i++)
	{
		if(dp[i] && i>=(sum+1)/2)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 5104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] prime = new int[1000001];
    prime[1] = 1;
    for(int i = 2; i <= 1000000; i++) {
      if(prime[i] == 0) {
        for(int j = i; j <= 1000000; j += i) {
          prime[j] = i;
        }
      }
    }
    int g = 1;
    int[] prime2 = new int[1000001];
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if(i == 0) {
        g = a;
      } else {
        g = gcd(g, a);
      }
      HashSet<Integer> set = new HashSet<Integer>();
      while(a > 1) { 
        set.add(prime[a]);
        a /= prime[a];
      }
      for(Integer e : set){
        prime2[e]++;
      }
    }
    String ans = "not coprime";
    if(g == 1) ans = "setwise coprime";
    int p = 0;
    for(int i = 0; i <= 1000000; i++) {
      if(prime2[i] > 1) p++;
    }
    if(p == 0) ans = "pairwise coprime"; 
    System.out.println(ans);
  }

  public static int gcd(int x, int y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}

Measured memory_bytes: 70212
/*input
2
1 1
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n) {
		repl(j, i+1, n) {
			while(j<n && a[j]==a[i]) j++;
			repl(k, j+1, n) {
				while(k<n && (a[k]==a[i] || a[k]==a[j])) k++;
				vector<int> cur(3);
				cur[0]=a[i];cur[1]=a[j];cur[2]=a[k];
				sort(all(cur));
				if(cur[2]<cur[0]+cur[1]) {
					// cout << i+1 << " " << j+1 << " " << k+1 << endl; 
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;
using std::queue;

void solve() {
    long k; cin >> k;
    queue<long> que;
    for (int i = 1; i <= 9; ++i) {
        que.push(i);
    }

    for (int i = 1; i <= k; ++i) {
        long x = que.front(); que.pop();

        if (i == k) {
            cout << x << endl;
        }

        if (x % 10 != 0) {
            que.push(10 * x + x % 10 - 1);
        }

        que.push(10 * x + x % 10);

        if (x % 10 != 9) {
            que.push(10 * x + x % 10 + 1);
        }
    }

}

int main() {

#ifdef DEV
    std::ifstream in("AtCoder/ABC161/Lunlun Number.input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


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

int main() {
  int n;cin>>n;
  vector<string> s(n);
  string t="MARCH";
  vector<ll> vec(5);
  rep(i,n){
    cin>>s[i];
    rep(j,5){
      if(s[i][0]==t[j])vec[j]++;
    }
  }
  ll ans=0;
  rep(i,3)for(int j=i+1;j<4;j++)for(int k=j+1;k<5;k++){
    ans+=vec[i]*vec[j]*vec[k];
  }
  cout<<ans<<endl;
}

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

int C[1001][1001];

int main(){
  int n,i,j,k,l;
  char str1[1001],str2[1001];

   scanf("%d",&n);

   for(i = 0;i < n;i++){
     scanf("%s%s",str1,str2);

     int X,Y;
     X = strlen(str1);
     Y = strlen(str2);

     for(j = 0;j < X;j++){
       C[0][j] = 0;
     }
     for(j = 0;j < Y;j++){
       C[j][0] = 0;
     }

     for(k = 1;k <= Y;k++){
       for(l = 1;l <= X;l++){
         if(str1[l-1] == str2[k-1]) C[k][l] = C[k-1][l-1] + 1;
         else if(C[k][l-1] <= C[k-1][l]) C[k][l] = C[k-1][l];
         else C[k][l] = C[k][l-1];
       }
     }
     printf("%d\n",C[Y][X]);
   }
  return 0;
}



Measured memory_bytes: 5700
#include <iostream>
#include <vector>
#include <queue>
typedef int64_t i64;
#define rep(i, n) for (i64 i = 0; i < n; ++i)

using namespace std;
int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    rep(i, N) cin >> h[i];
    
    vector<i64> dp(N, 1e11);
    dp[0] = 0;
  
    priority_queue<pair<i64, i64>> que;
    que.emplace(0, 0);
    while (!que.empty()) {
        auto it = que.top(); que.pop();
        auto i = it.second;
        if (-it.first <= dp[i]) {
            rep(k, K) {
                auto j = i + 1 + k;
                if (j < N) {
                    if (dp[j] > dp[i] + abs(h[j] - h[i])) {
                        dp[j] = dp[i] + abs(h[j] - h[i]);
                        que.emplace(-dp[j], j);
                    }
                }
            }
        }
    }
    cout << dp.back() << endl;
    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>

int n, A[50];

int main(){
 int q, m, i;
  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i=0; i<q; i++) {
    scanf("%d", &m);
    if(solve(0, m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


int solve(int i, int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}

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

int main(){
    int n;
    bool f = false;
    int cake7max;
    scanf("%d",&n);
    cake7max = n / 7;
    for(int i = 0; i <= cake7max; i++){
        if(((n-i*7)%4) == 0){
            f = true;
            break;
        }
    }
    if(f){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main() {
    int n;
    scanf("%d", &n);
    int p = (float) n / 1.08;
    if (((int) floor(p * 1.08) != n) && (int) floor((p + 1) * 1.08) != n) printf(":(\n");
    else {
        if ((int) floor(p * 1.08) == n) printf("%d\n", p);
        else printf("%d\n", p + 1);
    }
}

Measured memory_bytes: 128
#include<stdio.h>

int h[100];
int w[100];
int i;
int j;
int k;

int main(void){
	
	for(i=0;i<100;i++){
		scanf("%d %d",&h[i],&w[i]);
		if(h[i] == 0 && w[i] == 0){
			break;
		}
	}
	for(i=0;i<100;i++){
		for(j=0;j<h[i];j++){
			for(k=0;k<w[i];k++){
				if(j%2 == k%2){
				printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
			
		}
			printf("\n");
				if(h[i+1] == 0 && w[i+1] == 0){
				break;
				}
			}
	return 0;
}

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

const int INF = 1 << 30;

int N, K;
int h[100010];

int dp[100010];

int main() {
    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> h[i];

    for(int i = 0; i < 100010; i++)
        dp[i] = INF;

    dp[0] = 0;
    for(int i = 0; i < N; i++)
        for(int j = 1; j <= K; j++)
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll k;
    char s[1000];
    cin >> k;
    cin >> s;
    ll n = strlen(s);
    if (n <= k)
        cout << s << endl;
    else
    {
        for (ll i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll N,M;
    cin>>N>>M;
    cout<<(int64_t)abs((N-2)*(M-2))<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        
        int n = int.Parse(Console.ReadLine());
        long[][] plot = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();

        for (long i = 0; i < plot.Length; i++)
        {
            long[] basev = new long[0];
            double lcos = 1;
            double rcos = 1;
            for (long j = 0; j < plot.Length; j++)
            {
                if (i != j)
                {
                    long[] v = vectorminus(plot[i], plot[j]);
                    if (basev.Length == 2)
                    {
                        double vdeg = kakudo(basev, v);
                        //ベクトルがベースの右側だったら(外積がマイナス)
                        if (gaiseki(basev, v) < 0)
                        {
                            //今のtopとなす角を比較
                            if (rcos > vdeg)
                            {
                                //大きかったら代入
                                rcos = vdeg;
                            }
                        }
                        //左だったら
                        else if (gaiseki(basev, v) > 0)
                        {
                            //今のtopとなす角を比較
                            if (lcos > vdeg)
                            {
                                //大きかったら代入
                                lcos = vdeg;
                            }
                        }
                        else
                        {
                            long[] super = new long[] { 17178467375, 778918612 };
                            if ((gaiseki(super, v) < 0 && gaiseki(super, basev) > 0) || (gaiseki(super, v) > 0 && gaiseki(super, basev) < 0))
                            {
                                lcos = -1;
                                rcos = -1;
                            }
                        }
                    }
                    else
                    {
                        //初期化
                        basev = new long[] { v[0], v[1] };
                    }
                }
            }
            
            double deg = Math.Max(Math.PI - (Math.Acos(lcos) + Math.Acos(rcos)), 0);
            Console.WriteLine(deg / (Math.PI * 2));
        }
    }
    static long gaiseki(long[] a, long[] b)
    {
        return a[0] * b[1] - a[1] * b[0];
    }
    static double kakudo(long[] a, long[] b)
    {
        return (a[0] * b[0] + a[1] * b[1]) / (vectorlength(a) * vectorlength(b));
    }
    static double vectorlength(long[] a)
    {
        return Math.Sqrt(a[0] * a[0] + a[1] * a[1]);
    }
    static long[] vectorminus(long[] a, long[] b)
    {
        return new long[] { a[0] - b[0], a[1] - b[1] };
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
const int N=1e6;
typedef long long ll;
ll arr[N];
int main(){
	int n,k,q,a;
	int flag=0;
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;i++){
		arr[i]=k;
	} 
	for(int i=0;i<q;i++){
		scanf("%d",&a);
		arr[a]++;
		flag++;
	} 
	for(int i=1;i<=n;i++){
		if(arr[i]-flag<=0){
			puts("No");
		}
		else{
			puts("Yes");
		}
	}
	 
	
	
	return 0; 
}

Measured memory_bytes: 1408
#include<iostream>
#include<complex>
using namespace std;
typedef long long int llint;

int main(){
	llint max=1;
	for(int i=0;i<9;i++){
		max*=10;
	}
	max+=7;
	llint n,m;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<0<<endl;
		return 0;
	}
	if(m<n){
		n=m;
		m=n+1;
	}
	llint ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=max;
	}
	ans*=ans;
	ans%=max;
	if(n<m){
		ans*=n+1;
		ans%=max;
	}
	else{
		ans*=2;
		ans%=max;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const int INF = 1e9 + 7;

int n,m,i,j;
pair <int, int> ppl[55],pt[55];

int main(){
	scanf("%d%d", &n, &m);
	for(i = 0; i < n; i++)
	scanf("%d%d", &ppl[i].first, &ppl[i].second);
	for(i = 0; i < m; i++)
	scanf("%d%d", &pt[i].first, &pt[i].second);
	
	for(i = 0; i < n; i++){
		int res = INF;
		int ind = -1;
		for(j = 0; j < m; j++){
			int d = abs(ppl[i].first - pt[j].first) + abs(ppl[i].second - pt[j].second);
			if(d < res){
				res = d;
				ind = j; 
			}
		}
		printf("%d\n", ind + 1);
	}
}


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

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

Measured memory_bytes: 256
from collections import deque

N = int(input())
tree = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1  # 番号: 0 ~ N-1 で統一
    w %= 2
    tree[u].append((v, w))
    tree[v].append((u, w))

D = deque([0])
ans = [None] * N
ans[0] = 0
while D:
    x = D.popleft()
    for v, w in tree[x]:
        if ans[v] is None:
            ans[v] = (ans[x] + w) % 2
            D.append(v)

for i in range(N):
    print(ans[i])


Measured memory_bytes: 35960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int k, s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k >> s;
  int ans = 0;
  FOR(x, 0, k+1)FOR(y, 0, k+1) if(0<=s-x-y && s-x-y<=k) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
using vi = vector<int> ;
using P = pair<int, int>;

template<typename T>
class segtree {
public:
	segtree(int n) {
		for (size = 1; size < n; size *= 2);
		vec.resize(2 * size -1, zero);
	}
	segtree(std::vector<T> v) {
		int n = v.size();
		for (size = 1; size < n; size *= 2);
		vec.resize(2 * size -1, zero);
		for (int i = 0; i < n; i++) {
			vec[i + size-1] = v[i];
		}
		for (int i = size - 2; i >= 0; i--) {
			vec[i] = func(vec[i * 2 + 1], vec[i * 2 + 2]);
		}
	}
	void set(int n, T x) {
		n += size - 1;
		while (n >= 0) {
			vec[n] = func(vec[n], x);
			n = (n + 1) / 2 - 1;
		}
	}
	int get(int a, int b) {
		return get_func(0, 0, size, a, b);
	}
private:
	T zero =2147483647;
	std::function<T(T, T)> func = [](T a, T b) {return std::min(a, b); };
	vector<T> vec;
	int size;
	
	int get_func(int n, int p, int q, int x, int y) {
		if (q - p == 1)return vec[n];
		if (x == p && q == y) return vec[n];
		int mean = (p + q) / 2;
		T l = zero;
		T r = zero;
		if (x < mean)l = get_func(n * 2 + 1, p, mean, x, std::min(y,mean));
		if (mean < y)r = get_func(n * 2 + 2, mean, q, std::max(x,mean), y);
		return func(l, r);
	}
};

int main() {
	int n;
	cin >> n;
	vi p(n);
	vi index(n+1);
	segtree<int> evens(n);
	segtree<int> odds(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		index[p[i]] = i;
		if (i % 2 == 0) {
			evens.set(i, p[i]);
		}
		else {
			odds.set(i, p[i]);
		}
	}
	priority_queue<pair<int, P>> que;
	que.emplace(-evens.get(0,n), P(0, n));
	vi ans;
	while (!que.empty()) {
		pair<int,P> p = que.top(); que.pop();
		int minimum = -p.first;
		int a = p.second.first;
		int b = p.second.second;
		int pos = index[minimum];
		int next;
		if (pos % 2 == 0) {
			next = odds.get(pos+1, b);
		}
		else {
			next = evens.get(pos+1, b);
		}
		ans.push_back(minimum);
		ans.push_back(next);
		if (a < pos) {
			if ((a) % 2 == 0) {
				int m = evens.get(a ,pos);
				que.emplace(-m, P(a, pos));
			}
			else {
				int m = odds.get(a, pos);
				que.emplace(-m, P(a, pos));
			}
		}
		if (pos + 1 < index[next]) {
			if ((pos + 1) % 2 == 0) {
				int m = evens.get(pos + 1, index[next]);
				que.emplace(-m, P(pos + 1, index[next]));
			}
			else {
				int m = odds.get(pos + 1, index[next]);
				que.emplace(-m, P(pos + 1, index[next]));
			}
		}
		if (index[next] + 1 < b) {
			if ((index[next] + 1) % 2 == 0) {
				int m = evens.get(index[next] + 1, b);
				que.emplace(-m, P(index[next] + 1, b));
			}
			else {
				int m = odds.get(index[next] + 1, b);
				que.emplace(-m, P(index[next] + 1, b));
			}
		}
	}

	for (int x : ans) {
		cout << x << " ";
	}
	cout << endl;

}



Measured memory_bytes: 8616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	long i,n,a=0;
	cin>>s;
	n=s.size();
	for(i=0;i<n;i++)
	{
		a=a+(s[i]-'0');
	}
	if(a%9==0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int p,q,a,n;

int dfs(int denom,int numer,int prev,int product,int num){
    {
        int tmp1=denom*prev,tmp2=numer*prev+denom*num;
        if((double)tmp2/tmp1+eps<(double)p/q) return 0;
    }
    if((double)numer/denom-eps>(double)p/q) return 0;

    int res=0;
    if((double)p/q-eps<=(double)numer/denom  and (double)numer/denom<=(double)p/q+eps) ++res;
    if(num==0) return res;

    int x=prev;
    while(true){
        if(product*x>a) break;
        res+=dfs(denom*x,numer*x+denom,x,product*x,num-1);
        ++x;
    }
    return res;
}

void solve(){
    while(cin >> p >> q >> a >> n){
        if(p==0 and q==0 and a==0 and n==0) break;
        cout << dfs(1,0,1,1,n) << endl;
    }
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    ll ap = k+1;
    ll c = k-(a-1), d = b - a;
    ll e = c/2*d, f = c%2;
    ll ans = 0;
    if(f == 1) ans = e-d + b + 1;
    else ans = e-d + b;
    if(ap > ans) cout << ap << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main(void){
	int a,b,c,n,i;
	std::cin>>n;
	for(i=0;i<n;i++){
	std::cin>>a>>b>>c;
	if(a*a==b*b+c*c)
		std::cout<<"YES"<<std::endl;
	else if(b*b==a*a+c*c)
		std::cout<<"YES"<<std::endl;
	else if(c*c==a*a+b*b)
		std::cout<<"YES"<<std::endl;
	else
		std::cout<<"NO"<<std::endl;
	}
	return 0;	
}

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

int main() {
  int N;
  int ans = 0;
  cin >> N;
  int arr[N];
  bool f = false, s = false;
  cin >> arr[0];
  cin >> arr[1];
  if (arr[0] < arr[1]) f = true;
  for (int i = 2; i < N; i++) {
    cin >> arr[i];
    if (arr[i - 1] < arr[i])
      s = true;
    else
      s = false;
    if ((f && s) || (!f && !s)) ans++;
    f = s;
  }
  cout << ans;
  return 0;
}

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

namespace AIDU {
    class AIDU0016
    {
        public static void Main(){
            string s,ss2;
            string[] ss;
            int key=0;
            List<string> ress=new List<string>();

            while(true) {
                s=Console.ReadLine();
                if(string.IsNullOrEmpty(s))break;

                ss=s.Split();
                foreach(string ss1 in ss) {
                    if(ss1.Length<2)continue;
                    ss2=ss1.Substring(0,2);

                    for(int i=0;i<26;i++) {
                        if(Shift(ss2,i)=="th") {
                            if(contains(Shift(ss1,i))) {   //decoded
                                key =i; break;
                            }
                        }
                    }
                }

                ress.Add(Shift(s, key));
            }
            foreach(string ress1 in ress) 
                Console.WriteLine(ress1);
        }

        static string Shift(string s,int N) {
            char[] chars = s.ToCharArray();
            int c;
            for(int i=0;i<chars.Length;i++) {
                c=chars[i];
                if(c>=97&&c<=122)chars[i]=(char)((chars[i]+N-97)%26+97);
            }
            return new string(chars);
        }

        static bool contains(string x) {
            return contains(x,3)||contains(x,4);
        }
        static bool contains(string x,int l) {
            if(x.Length<l)return false;
            string xd=x.Substring(0,l);
            switch (l) {
                case 3:
                    return xd=="the";
                case 4:
                    return xd=="this"||xd=="that";
                default:
                    return false;
            }
        }
    }
}

Measured memory_bytes: 8824
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;


double ShahenArray[1003];

double Shahen(int n){
	if (n == 2){
		ShahenArray[n] = sqrt(1 * 1 + 1 * 1);
		return ShahenArray[2];
	}
	ShahenArray[n] = sqrt(pow(Shahen(n - 1), 2.0) + 1 * 1);
	// pow使わずShahen(n-1) * Shahen(n-1) にするととんでもなく遅い.
	return ShahenArray[n];
}

double Kakudo(int n, double rad){
	double ans=0;
	if (n == 2){
		rad = atan2(1.0 , 1.0);
		return rad;
	}
	else{
		rad = atan2(1.0, ShahenArray[n-1]);
		return rad + Kakudo(n - 1, rad);
	}
}

double toKakudo(double rad){
	return rad * 180.0 / M_PI;
}

int main(){
	int n;
	double x=1, y=1;

	Shahen(1000);

	while (cin >> n, n != -1){
		x = 0;
		y = 0;
		double shahen = ShahenArray[n];
		double kakudo = Kakudo(n, 0);
		x = shahen * cos(kakudo);
		y = shahen * sin(kakudo);
		printf("%.7f\n", x);
		printf("%.7f\n", y);
	}
	 
	// cout << Shahen(n) << " " << toKakudo(Kakudo(n,0)) << endl;

	return 0;
}

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

using namespace std;

int main() {
  int n, k;
  int count[10];
  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < 10; ++i) {
      count[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> k;
      ++count[k];
    }
    for (int i = 0; i < 10; ++i) {
      if (count[i] == 0) {
        cout << "-" << endl;
      } else {
        cout << string(count[i], '*') << endl;
      }
    }
  }
}

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

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

    int a;
    cin >> a;
    string s;
    cin >> s;
    
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }

    return 0;
}


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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int start = max(a, c);
  int end = min(b, d);

  cout << max(0, end - start) << "\n";
}


Measured memory_bytes: 3648
//https://atcoder.jp/contests/abc143/tasks/abc143_b
//2019-11-27
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    int box[110];
    cin >> num;
    for(int i=0;i<num;i++){
        cin >> box[i];
    }
    long ans=0;
    for(int i=0;i<num;i++){
        for(int j=i+1;j<num;j++){
            ans += box[i] * box[j];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 00:58:18 2020

@author: liang
"""

N = int(input())
H = [0] + [int(i) for i in input().split()]
flag = True
for i in range(N):
    if H[i] - H[i+1] >= 2:
        print("No")
        break
    if H[i] - H[i+1] == 1 :
        if flag :
            flag = False
        else:
            print("No")
            break
    if H[i] < H[i+1]:
        flag = True            
    
else:
    print("Yes")
                  
        

Measured memory_bytes: 20848
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll N, W, w[210], dp[100010], ans, sum;

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

	for (int i = 0; i < N; i++)
	{
		cin >> w[i];
		sum += w[i];
	}

	sort(w, w + N);

	if (sum <= W)
	{
		ans++;
	}
	else
	{
		if (sum - w[N - 1] <= W)
		{
			ans++;
		}
	}

	dp[0] = 1;

	for (int i = N - 1; i >= 1; i--)
	{
		for (int j = W; j >= w[i]; j--)
		{
			(dp[j] += dp[j - w[i]]) %= mod;
		}

		ll par_sum = 0;
		for (int j = 0; j < i - 1; j++)
		{
			par_sum += w[j];
		}

		for (int j = 0; j <= W; j++)
		{
			if (j + par_sum <= W && j + par_sum + w[i - 1] > W)
			{
				(ans += dp[j]) %= mod;
			}
		}
	}

	cout << ans << endl;

	int www;
	cin >> www;
}


Measured memory_bytes: 3188
s = input()
l = len(s)
if l%2 == 0:
	s1 = s[:l//2]
	s2 = s[l//2:]
else:
	s1 = s[:l//2]
	s2 = s[l//2+1:]
cnt = 0
s2 = s2[::-1]
for i in range(len(s1)):
	if s1[i] != s2[i]:
		cnt += 1

print(cnt)

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
ll MOD = 1e9 + 7;

int main() {
    ll n; cin >> n;
    vector<ll> ac(n);
    for(ll i = 0; i < n; i++){
        ll a; cin >> a;
        ac[a]++;
    }
    ll s = n % 2 + 1;
    ll ans = 1;
    for(ll i = s; i < n; i+=2){
        if(ac[i] == 2){
            ans *= 2;
            ans %= MOD;
        }else{
            ans = 0;
            break;
        }
    }
    if(n % 2 != 0 && ac[0] != 1) ans = 0;
    cout << ans << endl;

}


Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  cout << A * B << endl;
}


Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			list.add(a);
			set.add(a);
		}
		
		if (list.size() == set.size()) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}




Measured memory_bytes: 104188
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
    
    static int[] w;
    static long[] v;
    static int n, W;
    static long[][] dp;
    
    static long solve(int idx, int knapCap)
    {
        //base cases
        if(knapCap<0 || idx==n)
            return 0;
        
        
        if(knapCap<w[idx])
            return solve(idx + 1, knapCap);
        else
        {
            if(dp[idx][knapCap]==-1)
            {
                long temp = Math.max(v[idx] + solve(idx + 1, knapCap - w[idx]), solve(idx + 1, knapCap));
                dp[idx][knapCap] = temp;
                return temp;
            }        
            else
                return dp[idx][knapCap];
        
        }        
    }
	public static void main (String[] args) {
		
		Scanner scn = new Scanner(System.in);
		
		n = scn.nextInt();
		W = scn.nextInt();
		w = new int[n];
		v = new long[n];
		for(int i=0;i<n;i++)
		{
		    w[i] = scn.nextInt();
		    v[i] = scn.nextLong();
		}
		dp = new long[n][W + 1];
		for(long[] i:dp )
    		Arrays.fill(i, -1L);
		long ans = solve(0, W);
		
		System.out.println(ans);
	}
}

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

using namespace std;

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

  bool f = true;
  for (int i = 0; i < s.length()-1; i++) {
    int cnt = 0;
    for(int j = 0; j < s.length(); j++) {
      if (s.at(i) == s.at(j)) {
        cnt++;
      }
    }
    if (cnt != 2) {
      f = false;
      break;
    }
  }
  if (f) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";

  }
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int ans;
  if(N >1 ) ans = N * (N-1) / 2;
  if(N <2) ans = 0;
  if(M > 1) ans += M * (M-1) / 2;
  cout << ans << endl;
}
  

Measured memory_bytes: 256
n=int(input())
while n!=0:
    total=0
    saidai=None
    saishou=None
    for i in range(n):
        s=int(input())
        total+=s
        if saidai is None or s>saidai:
            saidai=s
        if saishou is None or s<saishou:
            saishou=s
    print((total-saidai-saishou)//(n-2))        
    n=int(input())   
    


Measured memory_bytes: 5592
import sys
from pprint import pprint

def solve(n, l):
    n_min = 100000
    v_min = n_min
    pre_n_min = 100000
    sum_n = 0
    for i in range(1, n+1):
        n_min = min(n_min, abs(l + i - 1))
        if pre_n_min != n_min:
            pre_n_min = n_min
            v_min = l + i - 1

        # print i, l + i - 1, n_min
        sum_n += (l + i - 1)

    return sum_n - v_min


if __name__ == '__main__':

    n, l = map(int, sys.stdin.readline().strip().split(" "))
    print solve(n, l)

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int a;
  froop1(1,6){
    cin >> a;
    if(a == 0){
      cout << i << endl;
  }
  }
    
 
return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include <algorithm>
#include <map> // pair
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n) a[i] = 0;
    for (int i = 0; i < k; i++) {
        ll d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            ll b;
            cin >> b;
            a[b - 1] = 1;
        }
    }
    ll count = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            count++;
        }
    }
    cout << count << endl;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, 0, N) {
    cin >> P[i];
  }

  sort(All(P));

  int ans = 0;

  rep(i, 0, N - 1) {
    ans += P[i];
  }

  ans += (P[P.size() - 1] / 2);
  cout << ans << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a*b<c)cout<<a*b;
    else cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <list>
#include <vector>
#include <tuple>
using namespace std;
//#define FILENAME "./F/in/b04"
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

#define MOD 1000000007

int n;
vector<int> a;
vector<int> x;

int main(int argc, char *argv[]) {

#ifdef FILENAME
  ifstream file(FILENAME);
  cin.rdbuf(file.rdbuf());
#endif

  cin >> n;
  a.resize(n);

  rep(i,n) {
    cin >> a[i];

    if(x.size()==0) { x.push_back(a[i]); continue; }

    if(a[i] <= x[0]) x.insert(x.begin(),a[i]);
    else if(a[i] > x[x.size()-1]) x[x.size()-1] = a[i];
    else {
      int l = 0; int r = x.size()-1; int k = 0;
      while(r-l>1) { // x[l] < a[i] <= x[r]
	k = (l+r)/2;
	if(x[k] < a[i]) l = k;
	else r = k;
      }
      x[l] = a[i];
    }
  }
  
  cout << x.size() << endl;
  
  return 0;
}


Measured memory_bytes: 1276
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;



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

vector<vector<int>>field;

int ob(const int num,const int way) {
	if (num == 0) {
		return way;
	}
	else if (num == 1) {
		return (way + 3) % 4;
	}
	else if (num == 2) {
		return (way + 2) % 4;
	}
	else if (num == 3) {
		return (way + 1) % 4;
	}
	else if (num == 4) {
		return -1;
	}
	else {
		assert(false);
	}
}

int memo[32][32][4];

int c[4];

struct aa {
	int ny;
	int nx;
	int co;
	int way;
};
class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.co> r.co;
	}
};

long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}
struct Bunnsuu {
	long long int si;
	long long int bo;
	bool reduction(){
		if (si < 0) {
			long long int agcd = gcd(-si, bo);
			bo /= agcd; si /= agcd;
			if (agcd == 1) {
				return false;
			}
			else {
				return true;
			}
		}
		else if (si == 0) {
			bo = 1;
			return false;
		}
		else {
			long long int agcd = gcd(si, bo);
			bo /= agcd; si /= agcd;
			if (agcd == 1) {
				return false;
			}
			else {
				return true;
			}
		}
	}
	operator long double(){
		assert(bo);
		return static_cast<long double>(si) / bo;
	}
};
Bunnsuu operator-(const Bunnsuu&l, const Bunnsuu&r) {
	long long int bo = l.bo*r.bo;
	long long int si = l.si*r.bo - l.bo*r.si;
	Bunnsuu b{ si,bo };
	b.reduction();
	return  b;
}
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}
long long int getans(const int p, const int q, const int a, const int n,const int pre) {
	if (n == 0)return 0;
	if (a <= 1)return 0;
	const Bunnsuu origin{ p,q };
	long double value = static_cast<long double>(p) / q;
	int amin = max(pre+1,static_cast<int>(1 / value));
	long long int ans = 0;
	for (int i = amin;true; ++i) {
		const int  needtime = (value / ((1.0) / i));
		if (powint(i,needtime) > a)break;
		{
			for (int j = 1; powint(i, j) <= a; ++j) {
				if (j > n)break;
			
				Bunnsuu rest = origin;
				for (int k = 0; k < j; ++k) {
					rest=rest-Bunnsuu{ 1,i };
				}
				if (rest.si < 0) {
					break;
				}
				else if (rest.si == 0) {
					ans += 1;
				}
				else
					ans += getans(rest.si, rest.bo, a / powint(i, j), n - j,i);
			}
		}
	}
	return ans;
}

int main() {
	while (1) {
		int p, q, a, n; cin >> p >> q >> a >> n;
		if (!p)break;
		long long int ans(getans(p, q, a, n,0));
		cout << ans << endl;
	}
	return 0;

}

Measured memory_bytes: 3044
local read = io.read

local N, M = read("*n", "*n")
local load_s = {}
for i = 1, N do
	load_s[i] = 0
end

for i = 1, 2 * M do
	local ab_i = read("*n")
	load_s[ab_i] = load_s[ab_i] + 1
end

print(table.concat(load_s, "\n"))


Measured memory_bytes: 2696
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

class Graph{
	private:
	int V;
	vvp List;
	public:
	Graph(int v){
		V=v;
		List=vvp(v);
	}
	void add_edge(int s,int t,int c){
		List[s].push_back(P(t,c));
		List[t].push_back(P(s,c));
	}
	int DIJ(int s,int t){
		priority_queue<P> que;
		vi d(V,inf);
		d[s]=0;
		que.push(P(0,s));
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<List[v].size();i++){
				int F=List[v][i].first,S=List[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					que.push(P(-d[F],F));
				}
			}
		}
		return (d[t]==inf)?-1:d[t];
	}
};

int n;

int main(){
	while(1){
		int n,k;
		cin>>n>>k;
		if(!n) break;
		Graph g(n);
		for(int i=0;i<k;i++){
			int a;
			cin>>a;
			if(a){
				int s,t,c;
				cin>>s>>t>>c;
				g.add_edge(s-1,t-1,c);
			}
			else{
				int s,t;
				cin>>s>>t;
				cout<<g.DIJ(s-1,t-1)<<endl;
			}
		}
	}
}

Measured memory_bytes: 3044
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n;
		
		n = sc.nextInt();
		
		if(n < 1000){
			System.out.println("ABC");
		}else{
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 25556