akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if((a+b) % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a+b) / 2 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  string str;
  cin >> str;
  string ans;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'B') {
      if (ans.size() > 0) ans.pop_back();
    } else ans += str[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    string w;
    map<string, int> mp;
    string tmp;
    rep(i, n) {
        cin >> w;
        if (i == 0) {
            tmp = w;
            mp[w] = 1;
            continue;
        }
        if (mp.count(w) || w[0] != tmp[tmp.size()-1]) {
            cout << "No" << endl;
            return 0;
        }
        mp[w] = 1;
        tmp = w;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = -1;
    for(int i = (10 * b); i <= (10 * b) + 10; i++) {
      int c1 = (i * 8) / 100;
      int c2 = (i * 10) / 100;
      if((c1 == a) && (c2 == b)) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
#include <iostream>
#include <string.h>

using namespace std;

struct node {
  char name[100];
  int value;
  int time;
} queue[1000000], ans[1000000];
int head = 0, tail = 0, _index = 0;

int main () {
  int n, q, cnt;

  cin >> n >> q;

  tail = n;
  cnt = 0;

  for (int i = 0; i < n; i++) {
    cin >> queue[i].name >> queue[i].value;

    queue[i].time = 0;
  }

  while (head != tail) {
    if (q - queue[head].value >= 0) {
      strcpy(ans[_index].name, queue[head].name);
      ans[_index].value = queue[head].value;
      ans[_index].time = cnt + queue[head].value;
      _index++;
      cnt += queue[head].value;
    } else {
      strcpy(queue[tail].name, queue[head].name);
      queue[tail].value = queue[head].value - q;
      tail++;
      cnt += q;
    }

    head++;
  }

  for (int i = 0; i < _index; i++) {
    cout << ans[i].name << ' ' << ans[i].time << endl;
  }

  return 0;
}


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

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

int main(){
	string W, s;
	long long int m, h[100], l;
	while (1){
		cin >> W;
		if (W == "-")break;
		l = W.length();
		cin >> m;
		REP(i, m){
			cin >> h[i];
			s = W.substr(0, h[i]);
			W += s;
			W = W.substr(h[i], W.length());
		}
		cout << W << '\n';
	}
	return 0;
}

Measured memory_bytes: 1208
n,m = map(int,input().split())

l = [0 for _ in range(m)]

for i in range(n):
	tmp = list(map(int,input().split()))
	for j in range(1,len(tmp)):
		l[tmp[j]-1] += 1

ans = 0
for i in range(m):
	if l[i] == n:
		ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
   string str; cin >> str;
   stack<char> st;

   for(int i=0 ; i<str.size(); i++){
        char ch = str[i];
        if(ch == '0') st.push('0');
        else if(ch == '1') st.push('1');
        else{
            if(st.empty()) continue;
            else st.pop();
        }
   }

   std::vector<char> v;

   while(!st.empty()){
        char tmp = st.top();
        v.push_back(tmp);
        st.pop();
   }

   for(int i = v.size()-1; i>=0 ; i--){
        cout << v[i];
   }


   return 0;   
}


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

string sub1(string a){
  assert(a!="0");
  
  int as=a.size();
  int len=as+5;
  vector<int> A(len,0);
  for(int i=0;i<as;i++)A[i]=a[as-1-i]-'0';
  
  A[0]--;
  for(int i=0;i+1<len;i++){
    if(A[i]<0){
      A[i+1]--;
      A[i]+=10;
    }
    A[i+1]+=A[i]/10;
    A[i]%=10;
  }
  
  string res="";
  for(int i=len-1;i>=0;i--){
    if(res.size()==0&&A[i]==0)continue;
    res.push_back('0'+A[i]);
  }
  return res;
}

string add1(string a){
  int as=a.size();
  int len=as+5;
  vector<int> A(len,0);
  for(int i=0;i<as;i++)A[i]=a[as-1-i]-'0';
  
  A[0]++;
  for(int i=0;i+1<len;i++){
    A[i+1]+=A[i]/10;
    A[i]%=10;
  }
  string res="";
  for(int i=len-1;i>=0;i--){
    if(res.size()==0&&A[i]==0)continue;
    res.push_back('0'+A[i]);
  }
  return res;
}


string mul(string a,string b){
  if(a=="0"||b=="0")return "0";  
  int as=a.size(),bs=b.size();
  int len=as+bs;
  vector<int> A(as),B(bs),C(len);
  for(int i=0;i<as;i++)A[i]=a[as-1-i]-'0';   
  for(int i=0;i<bs;i++)B[i]=b[bs-1-i]-'0';
 
  for(int i=0;i<as;i++)
    for(int j=0;j<bs;j++)
      C[i+j]+=A[i]*B[j];
 
  for(int i=0;i+1<len;i++){
    C[i+1]+=C[i]/10;
    C[i]%=10;
  }
   
  string res="";
  for(int i=len-1;i>=0;i--){
    if(res.size()==0&&C[i]==0)continue;
    res.push_back('0'+C[i]);
  }
  return res;
}

string i2s( int x ){
  stringstream ss;
  ss<<x;
  string res;
  ss>>res;
  return res;
}

const int MAX = 10000000;
bool isP[MAX];
int isQ[MAX];

int main(){
  int n;
  cin>>n;
  
  if(n==1){
    cout<<100<<endl;
    cout<<2<<endl;
    return 0;
  }
  
  for(int i=2;i<MAX;i++){
    isP[i]=true;
    isQ[i]=i;
  }
  
  for(int i=2;i*i<MAX;i++){
    if(!isP[i])continue;
    for(int j=i*i;j<MAX;j+=i){
      isP[j]=false;
      isQ[j]=i;
    }
  }
  
  vector<int> primes;  

  for(int i=2;i<=n;i++){
    if(isP[i]){
      primes.push_back(i);
    }
  }

  string base="100";
  for(int i=0;i<(int)primes.size();i++){
    string str=i2s(primes[i]);
    base = mul ( base, str);
  }

  string X = add1(base);
  string Y = sub1(base);


  
  base = mul(X,Y);
  base = add1(base);

  
  vector<string> ans;
  ans.push_back("2");
  base=sub1(base);
  ans.push_back(X);
  for(int i=0;i<n-2;i++){
    base = sub1(base);
    ans.push_back( i2s( isQ[i+2]) );
  }
  cout<<base<<endl;
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
  return 0;
}



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

int main() {
  char c;
  cin >> c;
  if ('a' <= c && c <= 'z') {
    cout << 'a' << endl;
  }
  if ('A' <= c && c <= 'Z') {
    cout << 'A' << endl;
  }
  // char b;
  // b = 'a';
  // b = b + 3;
  // cout << b;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

//最小公倍数を求める
ll gcd(ll a, ll b) {
    if(a % b == 0)
    return b;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
 
int main() {

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    ll e=lcm(c,d);

    ll r=b-(b/c)-(b/d)+(b/e);
    ll l=a-(a/c)-(a/d)+(a/e);
    ll ans=r-l;

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n,l,r;
string sl,sr,mem;

int main(){
	cin>>n;
	l=0;r=n-1;
	cout<<l<<endl;
	cin>>sl;
	if(sl=="Vacant")
		return 0;
	cout<<r<<endl;
	cin>>sr;
	if(sr=="Vacant")
		return 0;
	while(true){
		cout<<(l+r)/2<<endl;
		cin>>mem;
		if(mem=="Vacant")
			return 0;
		if((((l+r)/2-l)%2==0&&mem!=sl)||(((l+r)/2-l)%2==1&&mem==sl)){
			sr=mem;
			r=(l+r)/2;
		}
		else {
			sl=mem;
			l=(l+r)/2;
		}
	}
	return 0;
}


Measured memory_bytes: 852
#define _CRT_SECURE_NO_WARNINGS
#include <atcoder/all>
#include <cstdio>
#include <string>
#include <iostream>
#define int long long

using namespace std;
using namespace atcoder;


signed main() {
	string S;
	cin >> S;

	auto sa = suffix_array(S);

	auto lcp = lcp_array(S, sa);

	int slen = S.length();
	int ans = slen * (slen + 1) / 2;

	for (auto i : lcp) {
		ans -= i;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 15644
#include<iostream>

using namespace std;

int linear_search(int a[], int b[],int n,int q) {
	int count = 0;
	for (int i = 0; i < q; ++i) {
		for (int j = 0; j < n; ++j) {
			if (a[j] == b[i]) {
				++count;
				break;
			}
		}
	}
	return count;
}

int main() {
	int n, q, S[10000], T[500];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; ++i) {
		cin >> T[i];
	}
	cout << linear_search(S, T, n, q) << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int a, b, c, k, ans;

main () {
	cin >> a >> b >> c >> k;
	ans += min(k, a);
	k -= min(k, a);
	k -= min(k, b);
	ans -= min(k, c);
	cout << ans << endl; 
}


Measured memory_bytes: 3592
<?php
list($a,$b,$C) = explode(" ",trim(fgets(STDIN)));
$h = $b * sin(deg2rad($C));
$S = $a * $h / 2;
$CC = pow($a,2) + pow($b,2) - 2 * $a * $b * cos(deg2rad($C));
$L = $a + $b + sqrt($CC);
echo sprintf("%.5f\n%.5f\n%.5f\n",$S,$L,$h);

Measured memory_bytes: 15776
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++)
    cin >> S[i];
  set<string> s;
  for (string i : S)
    s.insert(i);
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
#define MOD 1000000007
const int INF = 1e9;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
 
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

void solve(){

}

int main(){
	load;
    int t;
    cin>>t;
    ull res = 1;
    ull arr[t];
    fori(i,t){
		cin >> arr[i];
		if (arr[i]==0){
			cout << 0 <<"\n";
			return 0;
		}
	}
	fori(i,t){
		if (arr[i] <= 1000000000000000000/res){
			res *= arr[i];
		}else{
			cout << -1 << "\n";
			return 0;
		}
	}
	cout << res;
	return 0;
}



Measured memory_bytes: 4384
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count = 0
for i in range(N):
  A = list(map(int, input().split()))
  num = sum([A[j]*B[j] for j in range(M)]) + C
  if num > 0:
    count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 205, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n, m;
char s[N][N];
struct Q
{
	int y, x;
}q[N * N];
int h, t;
int f[N][N];

void inq(int y, int x, int step)
{
	if (y > n || y < 1 || x > m || x < 1 || s[y][x] == '#')return;
	if (step >= f[y][x])return;
	f[y][x] = step;
	q[t++] = { y,x };
}
const int dy[4] = { -1,0,0,1 };
const int dx[4] = { 0,-1,1,0 };
int edy, edx;
int bfs()
{
	while (h < t)
	{
		int y = q[h].y;
		int x = q[h++].x;
		for (int k = 0; k < 4; ++k)
		{
			inq(y + dy[k], x + dx[k], f[y][x] + 1);
		}
	}
	return f[edy][edx];
}

int main()
{
	while(~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; ++i)
		{
			scanf("%s", s[i] + 1);
		}

		MS(f, 63);
		h = t = 0;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= m; ++j)
			{
				if (s[i][j] == '@')
				{
					inq(i, j, 0);
				}
				else if (s[i][j] == '%')
				{
					edy = i;
					edx = j;
				}
			}
		}
		int dis1 = bfs();

		MS(f, 63);
		h = t = 0;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= m; ++j)
			{
				if (s[i][j] == '$')
				{
					inq(i, j, 0);
				}
			}
		}
		int dis2 = bfs();

		if (dis1 < dis2)
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}
	}
	return 0;
}
/*
【trick&&吐槽】


【?意】


【分析】


【????度&&?化】


【数据】


*/

Measured memory_bytes: 3592
import math
def resolve():
    n = int(input())
    if float.is_integer(n/1.08):
        print(int(n/1.08))
        return None
    ans = math.floor(n/1.08)+1
    if ans < (n+1)/1.08:
        print(int(ans))
    else:
        print(":(")  
resolve()

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int N;
    scanf("%d", &N);
    int i;
    int count = 0;
    for(i=0; i<N; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        count += r - l  + 1;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>


using namespace std;
#define MAX 100000

int main(){
    int N;
    vector<int> A;
    scanf("%d", &N);
    
    for (int i = 0; i < N; i++){
        int temp;
        scanf("%d", &temp);
        A.push_back(temp);
    }
    int dif = 0;
    for (int j = 0; j < N; j++){
        for (int jj = j + 1; jj < N; jj++){
            int tempdif = abs(A[jj] - A[j]);

            if (tempdif > dif){
                dif = tempdif;
            }
        }
    }

    printf("%d", dif);
    return 0;

}

Measured memory_bytes: 256
import collections
# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
n=int(input())
l=[]
for i in range(n):
    l.append(str(input()))


# l = list(map(str, input().split()))
c = collections.Counter(l)
m=c.most_common()[0][1]
a=[]
values, counts=zip(*c.most_common())
for value, count in zip(values, counts):
    if count==m:
        a.append(value)
a=sorted(a)
for b in a:
    print(b)
        

# c=[i for i in value if value.count(i) == max(values)]
# c=sorted(c)
# print(c)

Measured memory_bytes: 59504
#pragma gcc optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
//#include <unordered_map>
#include <stack>
#include <cstdlib>
#include <numeric>
#include <cassert>
#include <complex>
using namespace std;
#define maxn 200007
#define maxm 400007
#define maxq 1000007
#define maxl 1234
#define modn 998244353
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define scanl2(a,b) scanf("%lld%lld",&a,&b)
#define scans(a) scanf("%s",a)
#define scans2(a,b) scanf("%s%s",a,b)
#define scand(a) scanf("%lf",&a)
#define scan2(a,b) scanf("%d%d",&a,&b)
#define scand2(a,b) scanf("%lf%lf",&a,&b)
#define scan3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scan5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define print(a) printf("%d\n",a);
#define printl(a) printf("%lld\n",a);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>= b;i--)
#define fscan(a) fscanf(stream,"%d", &a);
#define mp      make_pair	
#define pb      push_back
#define eb      emplace_back
#define mm(a,b) memset(a,b,sizeof a)
#define log2(n) (double)(log(n) / log(2.0))
#define _crt_disable_perfcrit_locks
#define bll __int128
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef pair <char, int> pci;
typedef complex<double> cd;
typedef vector<complex<double> > vcd;

const double eps = 1e-8;
const double pi = 2 * acos(0.0);

int cc, bb; char ch; inline int F() {
	while (ch = getchar(), (ch < 48 || ch> 57) && ch != '-'); ch == '-' ? cc = bb = 0 : (cc = ch - '0', bb = 1);
	while (ch = getchar(), ch > 47 && ch < 58)cc = (cc << 1) + (cc << 3) + (ch ^ 48); return bb ? cc : -cc;
}
void write(int x) {
	int y = 10, len = 1;
	while (y <= x) { y *= 10; len++; }
	while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}
int n;
string s;
int has1 = 0;
int sum = 0;
int main() {
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//FILE* stream = fopen("L:/1.in", "rb+");
	cin >> n >> s;
	int t = n - 2;
	for (int i = 0; i < n - 1; i++) {
		s[i] = abs(s[i] - s[i + 1]);
		if (s[i] & 1 && (t | i) == t)//如果s[i]是奇数且c(n-2,i)为奇数
			sum++;
		if (s[i] == 1)has1 = 1;
	}
	if (sum & 1)
		cout << 1 << endl;
	else if (has1)
		cout << 0 << endl;
	else {
		sum = 0;
		for (int i = 0; i < n - 1; i++) {//全是0和2
			s[i] >>= 1;
			if (s[i] & 1 && (t | i) == t)//如果s[i]是奇数且c(n-2,i)为奇数
				sum++;
		}
		if (sum & 1)
			cout << 2 << endl;
		else
			cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 1e6 + 7;
const int INF = 0x3f3f3f3f;

int a[maxn];

int main() {
    int n,k;
    while(cin >> n >> k) {
        int ans = 0;
        while(n) {
            n /= k;
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
ans= num2alpha(n)
print(ans.lower())

Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	ll s; cin >> s;
	set<ll> se;
	rep(i, 1e9) {
		if (se.count(s))return cout << i + 1 << endl, 0;
		se.insert(s);
		s = s % 2 == 0 ? s / 2 : 3 * s + 1;
	}
	return 0;
}

Measured memory_bytes: 384
dataset = []

while True:
    h, w = map(int, input().split())
    if (h >= 3 and h <= 300) and (w >= 3 and w <= 300):
        listed = []
        listed.append(h)
        listed.append(w)
        dataset.append(listed)
    elif h == 0 and w == 0:
        break
    else:
        break

for listed in dataset:
    h = listed[0]
    w = listed[1]

    for i in range(0, 1):
        for j in range(w):
            print("#", end="")
        print()
    for i in range(1, h-1):
        for j in range(0, 1):
            print("#", end="")
        for j in range(1, w-1):
            print(".", end="")
        for j in range(w-1, w):
            print("#", end="")
        print()
    for i in range(h-1, h):
        for j in range(w):
            print("#", end="")
        print()
    print()

Measured memory_bytes: 9152
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        var countb = 0;
        var C = false;
        if (s[0] == 'A')
        {
            for (int i = 1; i < s.Length; i++)
            {
                if (char.IsUpper(s[i]))
                    countb++;
                if (2 <= i && i <= s.Length - 2 && s[i] == 'C')
                    C = true;
            }
        }

        if (C && countb == 1)
            Console.WriteLine("AC");
        else
            Console.WriteLine("WA");
        Console.Out.Flush();
    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	string s;
	cin>>s;
	if(s.size()==2){
		if(s.at(0)==s.at(1)){
			cout<<"1 2"<<endl;
		}
		else{
			cout<<"-1 -1"<<endl;
		}
		return 0;
	}

	REP(i,0,s.size()-2){
		lli data[26]={0};
		data[s.at(i)-'a']++;
		data[s.at(i+1)-'a']++;
		data[s.at(i+2)-'a']++;
		REP(j,0,26){
			if(data[j]==2){
				cout<<i+1<<" "<<i+3<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1"<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define loop(i,n) for(ll i=0;i<n;i++)
#define cloop(i,m,n) for(ll i=m;i<n;i++)
#define Matrix vector<vector<ll>>
#define Point pair<ll,ll>
#define Coordinates vector<Point>
ll global =0;
using namespace std;

ll gcd(ll a, ll b){
    /*
    return gcd of a,b
    */
    if(b>a)return gcd(b,a);
    if(a%b)return gcd(b,a%b);
    return b;
}
void init_matrix( Matrix& graph, ll num){
    /*
    Initialize Matrix elements with num rows 
    */
    loop(i,num) graph.push_back(vector<ll>(1,LLONG_MAX));
}
auto max_mp(map<ll,ll>&mp){
    /*
    return max element of map in form pair<key,val>
    */
    auto max_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second > max_e->second){
            max_e = it;
        }
        it++;
    }
    return *max_e;
}

auto min_mp(map<ll,ll>&mp){
    /*
    return min element of map in form pair<key,val>
    */
    auto min_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second < min_e->second){
            min_e = it;
        }
        it++;
    }
    return *min_e;
}
vector<ll> generate_prime(ll n) { 
    /*
    generate all primes number less than equal to n
    */
    vector<bool> prime(n+1,true);
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    vector<ll> pr;
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          pr.push_back(p);
    return pr;
}



int main(){
    ll n;
    cin >> n;
    ll h=0 ;
    h += (n/500)*1000;
    h += ((n%500)/5)*5;
    cout << h << endl;
    return 0;
}
	
/*
input:

*/

/*
output:

*/	

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#include <assert.h>
#include <complex>
#include <random>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
mt19937 rr(random_device{}());

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) 
        cin >> a[i] >> b[i];

    ll cur = 0;
    for (int i = n - 1; i >= 0; --i) {
        ll x = 0;
        if ((a[i] + cur) % b[i]) {
            x = b[i] - ((a[i] + cur) % b[i]);
        }
        cur += x;
    }
    cout << cur << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x,z;
    x = 0;
    z = 0;
    //printf("x?");
    scanf("%d",&x);
    z = x * x * x;
    printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;

    int a_c = 0;
    while(a>0){
        a -= d;
        a_c++;
    }
    int b_c = 0;
    while(c>0){
        c -= b;
        ++b_c;
    }
    if(a_c >= b_c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 1100000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int C[20][20],A[20][20];

int main(){
  int N,M,X,Y,x,y,temp;
  cin>>N>>M>>X>>Y;
  x=X; y=Y;
  for(int i=0;i<N;i++){
    cin>>temp;
    x=max(x,temp);
  }

  for(int i=0;i<M;i++){
    cin>>temp;
    y=min(y,temp);
  }

  if(x<y) cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}


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

int main(){
  long long a, b, x; cin >> a >> b >> x;
  if(a%x!=0){
    a=a+(x-a%x);
  }
  if(a>b){
    cout << 0 << endl;
  }
  else cout << (b-a)/x+1 << endl;
}
  
  

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
var i=0;
while(true){
  // console.log(i);
var aopb = lines[i].split(' ');
  // console.log(aopb);
var a = Number(aopb[0]);
var op = aopb[1];
var b = Number(aopb[2]);
if(op == "?"){
  break;
}
switch(op){
  case("+"):
    console.log(a + b);
    i++;
    break;
  case("-"):
    console.log(a - b);
    i++;
    break;
  case("*"):
    console.log(a * b);
    i++;
    
    
    break;
  case("/"):
    console.log(Math.floor(a / b));
    i++;
    
  }
}
});


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

using namespace std;

int main() {
 //freopen("input.txt","r",stdin);
 char a;
 cin >> a;
 if (a >= 'A' && a <= 'Z') {
    cout << 'A';
 }
 else {
    cout << 'a';
 }
 return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll r = 0;
	bool flag = false;
	ll res;
	rep(i, n) {
		if (s[i] == 'R')r++;
		if (s[i] == 'W') {
			if (flag == false) {
				res = i;
				flag = true;
			}
		}
	}
	res = r;
	rep(i, res) {
		if (s[i] == 'R')r--;
	}
	cout << r << endl;
	return 0;
}


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

int main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	if(a < b) swap(a,b);
	string ans = (a - a%k >= b) ? "OK" : "NG";
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
int main(){
    int n,a,b,x=0,y=0,z,q;
    scanf("%d",&n);
    int p[n];
    scanf("%d %d",&a,&b);
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(int j=0;j<n;j++){
        if(p[j]<=a){
            x++;
        }
        if(p[j]>a && p[j]<=b){
            y++;
        }
    }
    z=n-x-y;
    if(x<=y && x<=z){
        q=x;
    }
    if(y<=x && y<=z){
        q=y;
    }
    if(z<=x && z<=y){
        q=z;
    }
    printf("%d",q);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   //freopen("error.txt", "w", stderr); 
   freopen("output.txt", "w", stdout); 
#endif 
   
 ll T = 1 ;
 //cin>>T;

 for(ll t=0;t<T;t++)
 {
  ll c;
  cin>>c;
  if(c)
    cout<<0<<endl;
  else cout<<1<<endl;

 }
  return 0;
}


Measured memory_bytes: 3644
c_list = []
for i in range(3):
    c = list(map(int, input().split()))
    c_list.append(c)
a_ans = [0 for i in range(3)]
b_ans = [0 for i in range(3)]
a_ans[0] = ((c_list[0][0]-c_list[1][0])+(c_list[0][1]-c_list[1][1]))//2
a_ans[1] = a_ans[0] - (c_list[0][0]-c_list[1][0])
a_ans[2] = c_list[2][0]-c_list[0][0] + a_ans[0]
b_ans[0] = c_list[0][0] - a_ans[0]
b_ans[1] = c_list[0][1] - a_ans[0]
b_ans[2] = c_list[0][2] - a_ans[0]
ans = "Yes"
for i in range(3):
    for j in range(3):
        if c_list[i][j]!=a_ans[i]+b_ans[j]:
            ans = "No"
            break
print(ans)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;
int main(){
    int i,j,k,n,x,count;
    count = 0;
    while(true){
        cin >> n >> x;
        if(n==0 and x==0){
            break;
        }
        else{
            for(i=1;i<=n;i++){
                for(j=i+1;j<=n;j++){
                    for(k=j+1;k<=n;k++){
                        if(i+j+k==x){
                            count += 1;
                        }
                    }
                }
            }
            cout << count<< endl;
            count = 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
W,H,N = map(int, input().split())
li = [list(map(int,input().split())) for i in range(N)]

a_x = 0
a_y = 0
b_x = W
b_y = 0
c_x = W
c_y = H
d_x = 0
d_y = H
area = 1

for l in li:
    if l[2] == 1:
        if l[0] >= b_x:
            area = 0
            break
        elif l[0] > a_x:
            a_x = l[0]
            d_x = l[0]
        
    elif l[2] == 2:
        if l[0] <= a_x:
            area = 0
            break
        elif l[0] < b_x:
            b_x = l[0]
            c_x = l[0]

    elif l[2] == 3:
        if l[1] >= d_y:
            area = 0
            break
        elif l[1] > a_y:
            a_y = l[1]
            b_y = l[1]
        
    elif l[2] == 4:
        if l[1] <= a_y:
            area = 0
            break
        elif l[1] < d_y:
            c_y = l[1]
            d_y = l[1]

if area != 0:
    area = (b_x - a_x)*(d_y - a_y)

print(area)



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

int a, b, c, x, y;

int main() {
    std::cin >> a >> b >> c >> x >> y;
    
    int common = std::min(a + b, c * 2);
    
    int m = std::min(x, y);
    int ans = common * m;
    
    x -= m, y -= m;
    
    if (x) {
        ans += std::min(c * 2, a) * x;
    }else {
        ans += std::min(c * 2, b) * y;        
    }
    
    std::cout << ans << std::endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    int nn=0,ns=0,nw=0,ne=0;
    REP(i,s.size()){
        if(s[i]=='N') nn++;
        else if(s[i]=='S') ns++;
        else if(s[i]=='W') nw++;
        else if(s[i]=='E') ne++;
    }

    Yes(   ((nn > 0 && ns > 0) || (nn == 0 && ns == 0))    
        && ((ne > 0 && nw > 0) || (ne == 0 && nw == 0)))

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int d;
    cin >> d;
    Vi ans(d, 0);
    Vi c(26, 0);
    rep(i, 26)
    {
        cin >> c[i];
    }
    VVi s(d, Vi(26, 0));
    rep(i, d)
    {
        rep(j, 26)
        {
            cin >> s[i][j];
        }
    }
    rep(i, d)
    {
        cin >> ans[i];
        ans[i]--;
    }
    ll res=0LL;
    Vi last(26,0);
    rep(i,d){
        res+=s[i][ans[i]];
        last[ans[i]]=i+1;
        rep(j,26){
            res-=c[j]*(i+1-last[j]);
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        a[x-1]++;
        a[y-1]++;
    }
    for(int i = 0; i < n; i++)
        cout << a[i] << endl;
}

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

int main(){
	vector<int> w, k;
	for (int i = 0; i < 10; i++){
		int x;
		scanf("%d", &x);
		w.push_back(x);
	}
	for (int i = 0; i < 10; i++){
		int x;
		scanf("%d", &x);
		k.push_back(x);
	}
	
	sort(w.begin(), w.end());
	sort(k.begin(), k.end());

	printf("%d %d\n", w[7] + w[8] + w[9], k[7] + k[8] + k[9]);

	return 0;
}

Measured memory_bytes: 1044
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")
#define ret return 0

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

	string s;
	cin >> s;
	if (s[0] != 'A')
	{
		cout << "WA" << endl;
		ret;
	}
	int cnt = 0;
	for (int i = 1; i < s.size(); i++)
	{
		if ('a' <= s[i] && s[i] <= 'z')
		{
			continue;
		}
		if (s[i] == 'C' && 2 <= i && i <= s.size() - 2 && !cnt)
		{
			cnt++;
		}
		else
		{
			cout << "WA" << endl;
			ret;
		}
	}
	if (cnt)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		String a = sc.next();
		String b = sc.next();
		String c = a + b;
		int d = Integer.parseInt(c);
		String ans = "";

		if (Math.sqrt(d)%1==0) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		// 出力
		System.out.println(ans);
	}
}


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

int main()
{
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1')
        ++counter;
    if (s[1] == '1')
        ++counter;
    if (s[2] == '1')
        ++counter;

    cout << counter << endl;
}

Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000009
#define mod 1000000000
#define INF 1000000000
#define PB push_back
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n;
vector<int> wn[100010];
vector<int> arr[100010];
int ans[100010];

int dfs(int v)
{
	//if (wn[v].size() <= 1) return 1;
	int ans = arr[v].size();
	vector<int> dd;
	For(i, 0, arr[v].size())
	{
		dd.push_back(dfs(arr[v][i]));
	}
	sort(dd.begin(), dd.end());
	For(i, 0, dd.size())
	{
		ans = max(ans, ((int)dd.size() - i) + dd[i]);
	}
	return ans;
}

int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(4);

	cin >> n;
	For(i, 2, n + 1)
	{
		int a;
		cin >> a;
		arr[a].push_back(i);
	}

	/*For(i, 1, n + 1)
	{
		wn[arr[i].size()].push_back(i);
	}*/

	cout << dfs(1) << endl;

	return 0;
}

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

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

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

bool checkACGT(char c)
{
  if (c == 'A' || c == 'C' || c == 'T' || c == 'G') {
    return true;
  }
  else {
    return false;
  }
}

int main(void)
{
  string S;
  cin >> S;

  int is = 0, ie = 0;
  bool flag = false;
  int max = 0;
  for (int i = 0; i < S.size(); i++) {
    if (checkACGT(S[i])) {
      // 最初に見つけた時
      if (!flag) {
        flag = true;
        is = i;
      }
      // 最後までACGTだった場合
      if (flag && i == S.size() - 1) {
        ie = i;
        if (max < ie - is + 1) {
          max = ie - is + 1;
        }
      }
    }
    else {
      //長さ測定中に違うのを見つけたら
      if (flag) {
        flag = false;
        ie = i - 1;
        if (max < ie - is + 1) {
          max = ie - is + 1;
        }
      }
    }
  }

  cout << max << endl;

  return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(2*n),na(2*n);
	iota(a.begin(), a.end(), 1);
	for(int i=0; i<m; i++){
		int k;
		cin >> k;
		if(k == 0){
			for(int i=0; i<n; i++){
				na[2*i] = a[i];
				na[2*i+1] = a[n+i];
			}
			a = na;
		}else{
			for(int i=0; i<k; i++){
				na[2*n-k+i] = a[i];
			}
			for(int i=0; i<2*n-k; i++){
				na[i] = a[k+i];
			}
			a = na;
		}
	}
	for(int i: a){
		cout << i << endl;
	}
	return 0;
}



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

#define ALL(obj) (obj).begin(),(obj).end()


int main(){
    int N;cin >> N;
    string s;cin >> s;
    vector<int> ruiseki;
    ruiseki.push_back(0);
    for(int a = 0;a < N;a++){
        if(s.at(a) == '.')ruiseki.push_back(ruiseki.back());
        else ruiseki.push_back(ruiseki.back()+1);
    }
    int ans = 1e9;
    for(int a = 0;a < N;a++){
      //  cout<<ruiseki.at(a)<<" "<<ruiseki.back()-ruiseki.at(a+1)<<endl;
        ans = min(ans, ruiseki.at(a) + ((N-a-1) -(ruiseki.back()-ruiseki.at(a+1))));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    int n,maximo,tiempoRequerido,horaMax,tiempoActual=0;
    bool posible=true;
    cin >> n;
    pii trabajos[n];
    for(int i=0;i<n;i++){
        cin >> tiempoRequerido >> horaMax;
        trabajos[i]={horaMax,tiempoRequerido};
    }
    sort(trabajos,trabajos+n);
    for(int i=0;i<n;i++){
        maximo=trabajos[i].first;
        tiempoActual+=trabajos[i].second;
        if(tiempoActual>maximo){
            posible=false;
            break;
        }
    }
    if(posible) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
//-------------------------------------------
ll mod=1000000007; //mod1000000007を扱うケース
//-------------------------------------------
//--------------------------------------------
//逆元の計算　フェルマーの小定理の利用,繰り返し二乗法
ll inv(ll x){
  ll res = 1;
  ll k=mod-2;
  ll y=x;
  while(k){//                          2進数表記に直して累乗を計算する（繰り返し二乗法）
    if(k&1) res=(res*y) % mod;   //&    ビットAnd、左辺と右辺のビットを合成し、互いに 1 のビットを 1 とする。
     //                              11111111 と 10101010 (16進数で、FFとAA),11111111 & 10101010 は、10101010
    y=(y*y)%mod;
    k/=2;//2進数の桁をずらすことに対応している 2^0の後は2^1,2^2...といった具合
  }
  return res;
}
//-----------------------------------------------
//階乗の累積和を計算しておく。fの要素の数は問題によって変えよう。
//逆元もあらかじめ計算してしまうことで高速化できる。
//逆元を求める関数を呼び出す回数を1回に抑えてより高速化
ll f[2010],rf[2010];
void init(){
  f[0]=1;
  rep(i,1,2010) f[i]=(f[i-1]*i)%mod;
  rf[2010 - 1]=inv(f[2010-1]);
  rrep(i,2010 - 2,0) rf[i]=(rf[i+1]*(i+1)) % mod;
}
//-------------------------------------------------
//nCrを求める関数
ll C(int n,int k){
  ll a = f[n];//=n!
  ll b = rf[n-k];//=(n-k)!
  ll c = rf[k];//=k!

  ll bc =(b*c)%mod;

  return (a*bc)%mod;//割り算ではなく逆元を用いてる（modの処理のため）
}

int main(){
  init();

  int n,k;
  ll ans;
  cin>>n>>k;
  rep(i,1,k+1){
  if(k==n&&i==1) ans=1;
  else{
  if(i>n-k+1) ans=0;
  else{
  ans=C(k-1,i-1)*C(n-k+1,i)%mod;
}
}
  cout<<ans<<endl;
}
}


Measured memory_bytes: 256