akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

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

    auto func=[&](int a,int b) {return max(a,b);};
    SegTree<int> seg(510000,func,0);
    rep(i,n){
        int a;
        cin>>a;
        int left=max(0,a-k);
        int right=min(510000,a+k+1);
        int val=seg.get(left,right);
        seg.update(a,val+1);
    }

    cout<<seg.get(0,510000)<<endl;
}

Measured memory_bytes: 7468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		char[] A = scn.nextLine().toCharArray();
		char[] B = scn.nextLine().toCharArray();
		char[] C = scn.nextLine().toCharArray();

		int ans = 0;
		for(int i = 0;i < N;i++) {
			char a,b,c;
			a = A[i];
			b = B[i];
			c = C[i];

			if(a != b) {
				if(a!=c) {
					if(b != c) {
						ans+=2;
					}else {
						ans++;
					}
				}else {
					ans++;
				}
			}else {
				if(a != c) {
					ans++;
				}else {

				}
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23636
def main():
    n = int(input())
    l = list(map(int, input().split()))
    ll = len(l)
    ans = 0

    for i in range(ll):
        for j in range(i+1, ll):
            for k in range(j+1, ll):
                if len(set([l[i], l[j], l[k]])) != 3:
                    continue
                item = [l[i], l[j], l[k]]
                if max(item) < sum(item) - max(item):
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    vi ans(4500);
    ans[0] = 0;
    rep1(i, 4490) {
        ans[i] = ans[i-1]+i;
    }
    // rep(i, 20) cout << ans[i] << endl; //確認済
    // cout << ans[4490] << endl; //確認済
    vi v;
    int k = 0;
    while(ans[k]<=n) {
        k++;
    }
    rep1(i, k) {
        if(i==ans[k]-n) continue;
        cout << i << endl;
    }
    // cout << k << endl;
    return 0;
}

Measured memory_bytes: 3644
// A - Rotation

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string C1, C2;
	cin >> C1 >> C2;

	string ans = "YES";

	for (int i=0; i<3; i++) {
		if (C1[i] != C2[2-i]) ans = "NO";
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int N;
	int ans = 0;
	int highest = 0;
	cin >> N;
	vector <int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
		if (highest <= H.at(i)) {
			ans++;
			highest = H.at(i);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;    
    map<string,int> smap;
    for(int i=0;i<n;i++){
        string si;
        cin>>si;
        sort(si.begin(),si.end());
        smap[si]++;
    }
    ll ans=0;
    
    for(const auto& item:smap){
        ll num=item.second;
        ans+=num*(num-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <set>
#include <map>

using namespace std;

bool f(int x, int n)
{
    long sum = 0;
    for(int i=0; i<x; i++)
    {
        if(n > 0 && i%2 == 0) sum += (1ll << i);
        if(n < 0 && i%2 == 1) sum -= (1ll << i);
    }
    if(n >= 0 && n <= sum) return true;
    if(n <= 0 && n >= sum) return true; 

    return false;
}

int main(){

    int n;
    cin >> n;

    if(n == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    long s = 0;
    int base = 32;
    for(int i=base; i>0; i--)
    {
        if(!f(i, n))
        {
            long next = (1ll << i);
            s += next;
            if(i%2 == 0) n -= next;
            else n += next;
        }
    }
    if(n == 1) s += 1;

    bool first = true;
    for(int i=base; i>0; i--)
    {
        if(s & (1ll<<(i-1))) {cout << 1; first = false;}
        else if(!first) cout << 0;
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,l,r,ans=0,k,mid,ct;
            cin>>n>>k;
            ll ar[n+1];
            r=0;
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
                r=max(r,ar[i]);
            }
            ans=r;
            l=1;
            while(l<=r)
            {
                mid=(l+r)/2;
                ct=0;
                for(i=1;i<=n;++i)
                {
                    ct=ct+(ar[i]-1)/mid;
                }
                if(ct<=k)
                {
                    ans=mid;
                    r=mid-1;
                }
                else
                {
                    l=mid+1;
                }
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
int n;
long long value[2][3];
long long dfs(long long capital, long long i, vector<pair<long long,long long>> &product){
  if(product.size() == 0) return capital;
  else if(i == product.size()-1){
  	return capital/product[i].first*product[i].second + capital%product[i].first;
  }
  long long ret=capital;
  for(int j=0;j*product[i].first<=capital;j++){
    ret=max(ret,dfs(capital-j*product[i].first,i+1,product) + j*product[i].second);
  }
  return ret;
}
int main(){
  cin >> n;
  for(int i=0;i<2;i++) for(int j=0;j<3;j++) cin >> value[i][j];
  vector<pair<long long,long long>> forth,back;
  for(int j=0;j<3;j++){
    if(value[0][j]<value[1][j]) forth.push_back({value[0][j],value[1][j]});
    if(value[0][j]>value[1][j]) back.push_back({value[1][j],value[0][j]});                                             
  }
  long long acorn1=dfs(n,0,forth);
  long long acorn2=dfs(acorn1,0,back);
  cout << acorn2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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


ll INF = 1000000000;
//ll dp[1000000];

int main() {
    int N;
    ll W, w[110], v[110];
    cin >> N >> W;
    REP(i, N) { cin >> w[i] >> v[i]; }
    ll dp[110][100100] = {0};
    //dp[i][j]はi回取った後に重さW以下となる際の，価値の最大値(これからi番目を取る)
    REP(i, N) {
        REP(j, W+1) {
            if (j - w[i] >= 0) {
                chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 86272
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> W(N); cin >> W;
  int sum1 = 0, sum2 = 0;
  for (int w : W) sum2 += w;

  int vmin = 1e9;
  for (int i = 0; i < N; ++i) {
    sum1 += W[i], sum2 -= W[i];
    vmin = min(vmin, abs(sum1-sum2));
  }
  cout << vmin << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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


vector<string> S(3);
char next_turn;
int turn_n;

int solve(char turn){
	turn_n=turn-'a';
	if(S[turn_n].size()==0){
		cout<<char(turn+'A'-'a')<<endl;
		return 0;
	}
	next_turn = S[turn_n][0];
	S[turn_n].erase(S[turn_n].begin());
	solve(next_turn);
}
int main() {
	cin>>S[0]>>S[1]>>S[2];
	solve(S[0][0]);
}

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

int main() {
    int w=0;
    int h=0;
    int W, H, N;
    cin >> W >> H >> N;
    vector <int> x(N);
    vector <int> y(N);
    vector <int> a(N);
    for (int i=0; i<N; i++) {
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }
    for (int i=0; i<N; i++) {
        switch (a.at(i)) {
            case 1:
                if (w<x.at(i)) w=x.at(i);
                break;
            case 2:
                if (W>x.at(i)) W=x.at(i);
                break;
            case 3:
                if (h<y.at(i)) h=y.at(i);
                break;
            case 4:
                if (H>y.at(i)) H=y.at(i);
                break;
        }
    }
    if ((W-w)>=0 && (H-h)>=0) cout << (W-w)*(H-h) << "\n";
    else cout << "0\n";
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
from collections import defaultdict

def main():

	mod=10**9+7

	n=II()
	s=input()
	s=len(s)

	pp=[1]
	for i in range(n+10):
		pp.append(pp[-1]*25%mod)


	nn=n+s

	comb=[1]
	for i in range(1,n+10):
		comb.append(comb[-1]*(nn-i+1)*pow(i,mod-2,mod)%mod)
	#print(comb)


	ans=0

	for i in range(n+1):
		ans+=(pp[i]*comb[i])%mod
		ans%=mod
	print(ans)












if __name__ == "__main__":
	main()


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

int A[100]; 
int B[100]; 
int C[100]; 
int main(void) {
    int N;
    cin >> N;
    A[0]=-1;
    for (int i=1;i<=N;i++)
        cin >> A[i];
    for (int i=1;i<=N;i++)
        cin >> B[i];
    for (int i=1;i<=N-1;i++)
        cin >> C[i];

    int ans=0;
    for (int i=1;i<=N;i++)
    {
        ans += B[A[i]];
        if (A[i] == A[i-1]+1)
            ans += C[A[i-1]];
    }


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


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
ll kai(int n){
    if(n == 0 || n == 1)return 1;
    else if(n >= 2){
        return kai(n-1) * n;
    }else{
        return 0;
    }
}


int main(void){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    tx -= sx;
    ty -= sy;
    sx = 0;
    sy = 0;
    for(int i = 0; i < tx; i++){
        cout << 'R';
    }
    for(int i = 0; i < ty; i++){
        cout << 'U';
    }
    for(int i = 0; i < tx; i++){
        cout << 'L';
    }
    for(int i = 0; i < ty; i++){
        cout << 'D';
    }
    cout << 'D';
    for(int i = 0; i < tx+1; i++){
        cout << 'R';
    }
    for(int i = 0; i < ty+1; i++){
        cout << 'U';
    }
    cout << 'L';
    cout << 'U';
    for(int i = 0; i < tx+1; i++){
        cout << 'L';
    }
    for(int i = 0; i < ty+1; i++){
        cout << 'D';
    }
    cout << 'R' << endl;
}


Measured memory_bytes: 256
input()
nums = [int(i) for i in input().split()]
col = {
	i : 0 for i in range(min(nums)-1, max(nums)+2)
}

for i in nums:
	col[i-1] += 1
	col[i] += 1
	col[i+1] +=1

print(max(col.values()))

Measured memory_bytes: 20704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a[n+1];
    ll sum=0;
    for(int i=0;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    ll he[n];
    for(int i=0;i<n;i++){
        cin>>he[i];
    }
    for(int i=0;i<n;i++){
        if(he[i]<=a[i])a[i]-=he[i];
        else{
            he[i]-=a[i];
            a[i+1]=max(0ll,a[i+1]-he[i]);
            a[i]=0;
        }
    }
    for(int i=0;i<=n;i++){
        sum-=max(0ll,a[i]);
    }
    cout<<sum<<"\n";
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll x,a,b;
    cin >> x >> a >> b;
    if(a>=b){
        cout << "delicious" << "\n";
    }else{
        if(b-a<=x){
            cout << "safe" << "\n";
        }else{
            cout << "dangerous" << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	string s[3];
	bool flg = false;
	cin >> s[0];
	if(s[0] == "0") break;
	cin >> s[1] >> s[2];
	REP(i,3)
	    if(s[i][0] == s[i][1] && s[i][0] == s[i][2]){
		if(s[i][0] == '+') continue;
		cout << s[i][0] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;
	REP(i,3)
	    if(s[0][i] == s[1][i] && s[0][i] == s[2][i]){
		if(s[0][i] == '+') continue;
		cout << s[0][i] << endl;
		flg = true;
		break;
	    }
	if(flg) continue;

	if(s[0][0] == s[1][1] && s[0][0] == s[2][2]){
	    if(s[0][0] != '+'){
		cout << s[0][0] << endl;
		flg = true;
	    }
	}
	if(flg) continue;
	if(s[0][2] == s[1][1] && s[2][0] == s[1][1]){
	    if(s[0][2] != '+'){
		cout << s[0][2] << endl;
		flg = true;
	    }
	}
	if(flg) continue;
	cout << "NA" << endl;
    }
    return 0;
}

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

int s1[]={0,0,1,1,2,2,3,3};
int s2[]={1,3,0,2,1,3,0,2};


int main(){
	int n;
	cin>>n;
	for(int l=0;l<n;l++){
		string str;
		cin>>str;
		set<string> ans;
		for(int i=1;i<str.size();i++){
			string s[4];
			s[0]=str.substr(0,i);
			s[1]=str.substr(i,str.size()-i);
			s[2]=s[0];reverse(s[2].begin(),s[2].end());
			s[3]=s[1];reverse(s[3].begin(),s[3].end());
			for(int j=0;j<8;j++)(ans.insert(s[s1[j]]+s[s2[j]]));
			
		}
		cout<<ans.size()<<endl;
	}
}

Measured memory_bytes: 1292
def main():
    n, a = map(int, input().split())
    x = list(map(int, input().split()))

    mx = max(x + [a])

    for i in range(n):
        x[i] -= a

    sm = 2 * n * mx

    dp = [[0] * (sm + 1) for _ in range(n + 1)]

    dp[0][n*mx] = 1

    for i, e in enumerate(x, 1):
        for j in range(sm + 1):
            if 0 <= j - e <= sm:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-e]
            else:
                dp[i][j] = dp[i-1][j]

    ans = dp[n][n*mx] - 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main(void)
{
	char characters[4] = { 'A', 'C', 'G', 'T' };
	char input;

	cin >> input;
	for (int i = 0; i < 4; i++) {
		if (input == characters[i]) {
			cout << characters[3 - i];
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
double ans,x,d;
int n,m;
int main()
{
	scanf("%d%lf%lf",&n,&x,&d);
	m=2*n;
	while(m)
	{
		ans+=x+(m-1)*d/2;
		x=(x*(m+2)+5*d)/m;
		d=(m+4)*d/m;
		m-=2;
	}
	printf("%.10lf\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
    int k;
    string s="ACL";
    cin>>k;
    while(k--)
        cout<<s;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n);

    int index = 0;
    rep(i, n) {
        cin >> as[i];
        if (as[i] == 1) {
            index = i;
        }
    }

   ll g = (n - k + (k - 1)- 1 ) / (k - 1 ) + 1;
    cout << g << endl;

}




Measured memory_bytes: 1024
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector::<isize>();
    let mut ans = 999_999_999;
    for i in -100..101 {
        let mut ans_buf = 0;
        for j in 0..n {
            ans_buf += (i - v[j]).abs().pow(2);
        }
        ans = std::cmp::min(ans, ans_buf);
    }
    p(ans);
}

Measured memory_bytes: 4352
N, K = map(int, input().split())
TD = [tuple(map(int, input().split())) for _ in range(N)]
M = len(set([t for t, d in TD]))
 
TD.sort(key=lambda x: x[1], reverse=True)
p, S, V = 0, [], set()
for t, d in TD[:K]:
    p += d
    if t in V:
        S.append(d)
    else:
        V.add(t)
p += len(V) ** 2
ans = p
for t, d in TD[K:]:
    if len(S) == 0:
        break
    if t not in V:
        p += 2 * len(V) + 1 - S.pop() + d
        V.add(t)
        ans = max(ans, p)
print(ans)

Measured memory_bytes: 23528
function Main(input) {
    input = input.split('\n');
    nidan = input[1].split(' ') ;
    flag = null;
    for(i = 0; i < nidan.length-1; i++) {
        if(nidan[i] === 'Y') {
            flag = true;
        }
    }
    if(flag) {
        console.log('Four');
} else {
    console.log('Three');
}
    
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			int y=sc.nextInt(),m=sc.nextInt(),d=sc.nextInt();

			if(y*10000+m*100+d
					<1868*10000+9*100+8
			){
				ln("pre-meiji");
			}else if(
					y*10000+m*100+d
					<1912*10000+7*100+30){
				ln("meiji "+ (y-1868+1) +" "+m+" "+d);
			}else if(
					y*10000+m*100+d
					<1926*10000+12*100+25){
				ln("taisho "+ (y-1912+1) +" "+m+" "+d);
			}else if(
					y*10000+m*100+d
					<1989*10000+1*100+8){
				ln("showa "+ (y-1926+1) +" "+m+" "+d);
			}else{
				ln("heisei "+ (y-1989+1) +" "+m+" "+d);
			}

			if(1868*10000+9*100+8
			<=y*10000+m*100+d){

			}

		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

class P {
	double x;
	double y;

	P(double _x, double _y) {
		x = _x;
		y = _y;
	}

	public static final P Xunit = new P(1, 0);
	public static final P Yunit = new P(0, 1);

	public static double dot(P a, P b) {
		return a.x * b.x + a.y * b.y;
	}

	public static double cross(P a, P b) {
		return a.x * b.y - a.y * b.x;
	}

	public static boolean isParallel(P a1, P a2, P b1, P b2) {
		return Math.abs(cross(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL;
	}

	public static boolean isVertical(P a1, P a2, P b1, P b2) {
		return Math.abs(dot(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL;
	}

	public P a(P a) {
		return new P(x + a.x, y + a.y);
	}

	public P s(P a) {
		return new P(x - a.x, y - a.y);
	}

	public double norm() {
		return Math.sqrt(x * x + y * y);
	}

	public double arg() {
		double s = Math.acos(x / norm());
		return y > 0 ? s : 2 * Math.PI - s;
	}

	public P rotate(double t) {
		return new P(Math.cos(t) * this.x - Math.sin(t) * this.y, Math.sin(t)
				* this.x + Math.cos(t) * this.y);
	}

	public static int ccw(P a, P b, P c) {
		if (P.cross(b.s(a), c.s(a)) > Double.MIN_NORMAL) {
			return 1;
		}
		if (cross(b.s(a), c.s(a)) < -Double.MIN_NORMAL) {
			return -1;
		}
		if (dot(b, c) < -Double.MIN_NORMAL)
			return 2;
		if (b.norm() < c.norm() - Double.MIN_NORMAL)
			return -2;
		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof P) {
			P p = (P) obj;
			return x == p.x && y == p.y;
		}
		return false;
	}

	public String toString() {
		return "(" + x + "," + y + ")";
	}
}

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

int main() {
int a, b;
cin >> a >> b;
bool answer = false;

if (a * b % 2 == 0) {
  answer = true;
}

if (answer) {
  cout << "Even" << endl;
}
else {
  cout << "Odd" << endl;
}

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
  long int x;cin>>x;
  
  for(int i=1;i<=sqrt(x);i++){
    if(x%i==0){
      for(long int a=0;a<1000;a++){
        long int b=a-i;
        if(a*a*a*a*a-b*b*b*b*b==x){
          cout<<a<<" "<<b;
          return 0;
        }
      }
    }
  }
  
  
  
  
  //cout<<count;
  
  
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  string acgt = "ACGT";
  int ans = 0;
  for (int i = 0; i < S.size(); ++i) {
    for (int j = i; j < S.size(); ++j) {
      string str = S.substr(i, S.size() - j);
      bool ok = true;
      for (int k = 0; k < str.size(); ++k) {
        if (acgt.find(str.at(k)) == string::npos) {
          ok = false;
          break;
        }
      }
      if (ok) {
        ans = max(ans, (int)str.size());
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  vector<string> stringList;
  
  int N;
  cin >> N;
  vector<string> blue(N);
  for (int i=0; i<N; i++){
    cin >> blue.at(i);
    if (stringList.size() == 0) {
      stringList.push_back(blue.at(i));
    } else {
      bool existFlg = false;
      for (int j=0; j<stringList.size(); j++){
        if (stringList.at(j) == blue.at(i)){
          existFlg = true;
          break;
        }
      }
      if (!existFlg) {
        stringList.push_back(blue.at(i));
      }
    }
  }
  
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i=0; i<M; i++){
    cin >> red.at(i);
    bool existFlg = false;
    for (int j=0; j<stringList.size(); j++){
      if (stringList.at(j) == red.at(i)){
        existFlg = true;
        break;
      }
    }
    if (!existFlg) {
      stringList.push_back(red.at(i));
    }
  }
  
  vector<int> pointList(stringList.size(), 0);
  for (int i=0; i<stringList.size(); i++){
    for (int j=0; j<N; j++){
      if (stringList.at(i) == blue.at(j)) pointList.at(i)++;
    }
    for (int j=0; j<M; j++){
      if (stringList.at(i) == red.at(j)) pointList.at(i)--;
    }

  }
  
  int gain = 0;
  for (int i=0; i<pointList.size(); i++){
    if (pointList.at(i) > gain) gain = pointList.at(i);
  }
  
  cout << gain << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func BeginerB(src string) (int, error) {

	return calcLength(src, 0, 0), nil
}

func calcLength(src string, current, longest int) int {
	if src == "" {
		return longest
	}

	var atcf = map[string]bool{"A": true, "T": true, "C": true, "G": true}
	if _, ok := atcf[src[0:1]]; !ok {
		return calcLength(src[1:], 0, longest)
	}

	next := current + 1
	nextLongest := longest

	if longest < next {
		nextLongest = next
	}

	return calcLength(src[1:], next, nextLongest)
}

func main() {
	var input string

	fmt.Scan(&input)

	result, err := BeginerB(input)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(result)
}


Measured memory_bytes: 512
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read1::<usize>();
    for i in 0..50_000 {
        if (i as f64 * 1.08) as usize == n {
            println!("{}", i);
            return;
        } 
    }
    println!(":(");
}

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

#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
	double W,H,x,y;
	
	cin >> W >> H >> x >> y;
	
	printf("%lf ",W*H/2);
	
	if(x==W/2 && y==H/2)	cout << "1" << endl;
	else	cout << "0" << endl;
	
	return 0;
}

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

int main() {
  long long a,b;
  cin >> a >> b;
  long long g=__gcd(a,b);
  long long ans=1;

  for(long long i=2;i*i<=g;i++){
    if(g%i==0){
      ans++;
      while(g%i==0)
      g/=i;
    }
  }
  if(g!=1)
  ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";r.r(t);var n,o,u=r(0);n=u.readFileSync("/dev/stdin","utf8"),o=n.trim().split(" "),console.log(`${o[1]}${o[0]}`)}]);

Measured memory_bytes: 7372
import java.util.Scanner;
 
class Main {
    public static void main(String[] a){
        Scanner scan = new Scanner(System.in);
        int time = Integer.parseInt(scan.nextLine());
        while(time -- > 0){
            String input = scan.nextLine().replaceAll("Hoshino","Hoshina");
            System.out.println(input);
        }
    }
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n,a;
  cin>>n>>a;
  n%=500;
  if(n<=a) print("Yes");
  else print("No");

  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> r(n+1,0);
    r[1] = 1;
    vector<int> w(n+1,1);
    w[1] = 0;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(r[x]){
            r[x]--;
            r[y]++;
            if(w[y]){
                r[y] += w[y];
                w[y] = 0;
            }
        }
        else{
            w[x]--;
            if(r[y])
                r[y]++;
            else
                w[y]++;
        }
    }
    int ans = 0;
    for(int i = 1; i < n+1; i++)
        if(r[i])ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define INF 10000000
#define MAX 100

int matrixChain(int *, int);

  
int main()
{
  int i, n, p[MAX];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
	scanf("%d%d",&p[i], &p[i+1]);
  }
  printf("%d\n",matrixChain(p,n));

  return 0;
}

  
int matrixChain(int *p, int n)
{
  int i, j, k, l, q;
  int m[MAX][MAX];

  for(i=1; i<=n; i++){
    m[i][i] = 0;
  }
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k = i; k < j; k++){
    q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
    if(m[i][j] > q) m[i][j] = q;
      }
    }
  }
  return m[i-1][j];
}

Measured memory_bytes: 636
#include <cstdio>

int main()
{
    int d[50];
    int N;

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

    int total = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            if (i == j)
            {
                continue;
            }
            total += d[i] * d[j];
        }
    }

    printf("%d\n", total);
}


Measured memory_bytes: 888
#include <stdio.h>
int main(void)
{
    int a, b,c ;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(a < b && b < c){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2104
import sys
input = sys.stdin.readline
N = int(input())
t = [tuple(map(int, input().split())) for _ in range(N)]
res = [0] * N
for i in range(N):
  p = 0
  for j in range(i, N - 1):
    if p <= t[j][1]:
      p = t[j][1]
    else:
      p += (-p % t[j][2])
      #print(px)
    p += t[j][0]
    #print(i, p)
  res[i] = p
for r in res: print(r)

Measured memory_bytes: 39664
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a * b % 2 == 0 ? "Even" : "Odd");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int> edge[610];
double dp[610];
double dpp[610];
double dfs(int from) {
	if(dp[from] != -1) {
		return dp[from];
	}
	double ret = 0;
	for(int to : edge[from]) {
		ret += dfs(to) + 1;
	}
	double sz = edge[from].size();
	if(sz != 0) ret /= sz;
	return dp[from] = ret;
}
double dfsp(int from) {
	if(dpp[from] != -1) {
		return dpp[from];
	}
	double ret = 0;
	for(int to : edge[from]) {
		ret += dfsp(to) + 1;
	}
	double sz = edge[from].size();
	if(sz != 0) ret /= sz;
	return dpp[from] = ret;
}
int main() {
	int n, m; cin >> n >> m;
	pair<int, int> p[m];
	for(int i = 0; i < m; ++i) {
		int s, t; cin >> s >> t;
		--s, --t;
		p[i] = {s, t};
		edge[s].push_back(t);
	}
	rep(i,n) dp[i] = -1;
	double ans = dfs(0);
	for(int s = 0; s < n - 1; ++s) {
		vector<pair<double, int>> c;
		if(edge[s].size() == 1) continue;
		for(int to : edge[s]) {
			c.emplace_back(dp[to], to);
		}
		sort(all(c));
		reverse(all(c));
		int t = c.front().second;
		edge[s].erase(find(all(edge[s]), t));
		rep(i,n) dpp[i] = -1;
		dfsp(0);
		ans = min(ans, dpp[0]);
		edge[s].push_back(t);
	}
	printf("%.10f\n", ans);
	// double sz = edge[0].size();
	// if(sz != 1) {
	// 	double ans = LINF;
	// 	for(int to : edge[0]) {
	// 		// cerr << to << " " << dp[to] << endl; 
	// 		// printf("%.10f\n", (dp[0] / sz - (dp[to] + 1)) / (sz - 1));
	// 		ans = min(ans, (dp[0] * sz - (dp[to] + 1)) / (sz - 1));
	// 	}
	// 	printf("%.10f\n", ans);
	// } else {
	// 	printf("%.10f\n", dp[0]);
	// }
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
 
int main() {
    IN(int, n);
    int ac = 0;
    int re = 0;
    int wa = 0;
    int tl = 0;
    
    REP(i, n){
        IN(string, c);
        if (c=="AC") {
            ac++;
        }else if (c=="TLE"){
            tl++;
        }else if(c=="RE"){
            re++;
        }else if(c== "WA"){
            wa++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tl << endl;
    cout << "RE x " << re << endl;
}


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

using namespace std;
#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;

#define pb push_back
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int mod = 1e9+7;



int main(){
    IOS

    int n, m; cin>>n>>m;

    unordered_set<int> correct;

    bool vis[n+5];
    int cnt[n+5];
    memset(cnt, 0, sizeof cnt);    
    memset(vis, false, sizeof vis);

    for(int i = 0; i < m; i++){
        int p; string s;
        cin>>p>>s;
        if(s=="AC")correct.insert(p), vis[p] = true;
        if(!vis[p] && s == "WA"){
            cnt[p]++;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(vis[i])
            ans += cnt[i];
    }
    cout<<correct.size()<<" "<<ans<<"\n";

   


}


Measured memory_bytes: 4900
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <map>
#include <set>

using namespace std;


int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<vector<int>> to(n);
    map<pair<int, int>, int> color;
    vector<pair<int, int>> order;
    for (int i = 0; i < (n - 1); i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
        color[make_pair(a, b)] = 0;
        color[make_pair(b, a)] = 0;
        order.push_back(make_pair(a, b));
    }
    int c_max = 0;
    for (int i = 0; i < n; i++) {
        set<int> used;
        for (int j = 0; j < to[i].size(); j++) {
            int c = color[make_pair(i, to[i][j])];
            if (c != 0) {
                used.insert(c);
            }
        }
        for (int j = 0; j < to[i].size(); j++) {
            int c = color[make_pair(i, to[i][j])];
            if (c != 0) {
                used.insert(c);
            }
        }
        // cout << "used: ";
        // for (auto c: used) {
        //     cout << c << ", ";
        // }
        // cout << endl;
        int c_now = 1;
        for (int j = 0; j < to[i].size(); j++) {
            if (color[make_pair(i, to[i][j])] == 0) {
                // select color
                while (used.find(c_now) != used.end()) {
                    c_now++;
                }
                color[make_pair(i, to[i][j])] = c_now;
                color[make_pair(to[i][j], i)] = c_now;
                used.insert(c_now);
                c_max = max(c_max, c_now);
            }
        }
    }
    cout << c_max << endl;
    for (auto p: order) {
        cout << color[make_pair(p.first, p.second)] << endl;
    }    
    return 0;
}


Measured memory_bytes: 19316
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int i,j,k,n,m,N,P[200000],A[200000],ans;

int main()
{
  cin >> N;
  
  for(i=0;i<N;i++)
  {
    cin>>P[i];
    
  }
  
  ans=1;
  for(i=1;i<N;i++)
  {
    if(P[i-1]<P[i])
    {
      P[i]=P[i-1];
    }
    else
    {
      ans++;
    }
  }
  
  cout <<ans;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define ll long long 
using namespace std;

int main() {
	string s, ans[10];
	int num = 0;
	cin >> s;
	for (int i = 0; i < s.length();i++) {
		if (s[i] != 'B') {
			ans[num] = s[i];
			num++;
		} else if(num != 0){
			num--;
		}
	}
	for (int i = 0; i < num; i++) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val h = sc.nextInt()
  val w = sc.nextInt()

  val a = Array(h) { sc.next().toCharArray() }

  val hh = mutableListOf<Int>()
  for (i in 0 until h) {
    var all = true
    for (j in 0 until w) {
      if (a[i][j] == '#') {
        all = false
        break
      }
    }
    if (!all) {
      hh.add(i)
    }
  }

  val ww = mutableListOf<Int>()
  for (j in 0 until w) {
    var all = true
    for (i in 0 until h) {
      if (a[i][j] == '#') {
        all = false
        break
      }
    }
    if (!all) {
      ww.add(j)
    }
  }

  val ans = mutableListOf<String>()

  for (i in hh) {
    for (j in ww) {
      ans.add(a[i][j].toString())
    }
    ans.add("\n")

  }

  println(ans.joinToString(""))

}


Measured memory_bytes: 40676
n = int(input())
shogens = []
ans = 0
for i in range(n):
    a = int(input())
    shogens.append([])
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        shogens[-1].append((x, y))

def is_honest(i, j):
    return (i >> j) % 2 == 1

def honest_cnt(i):
    ans = 0
    for j in range(n):
        ans += is_honest(i, j)
    return ans 

for i in range(1 << n):
    ok = True
    for j in range(n):
        if not is_honest(i, j):continue
        for (x, y) in shogens[j]:
            if y == 0 and is_honest(i, x): ok = False
            if y == 1 and not is_honest(i, x): ok = False
    if ok:
        ans = max(ans, honest_cnt(i))

print(ans)

Measured memory_bytes: 3064