akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define EPS 1e-9
using namespace std;

typedef complex<double> P;

P rot (P x, P p, double ang) {
    ang = ang / 180.0 * M_PI;
    double p1 = p.real() - x.real();
    double p2 = p.imag() - x.imag();
    return P( p1 * cos(ang) - p2 * sin(ang) + x.real()
              , p1 * sin(ang) + p2 * cos(ang) + x.imag() );
}

int main () {
    int n;
    while (cin >> n, n) {
        vector<P> v(n);
        for (auto &i : v) {
            double x, y;
            char c;
            cin >> x >> c >> y;
            i = P(x,y);
        }

        int res = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j && abs(v[i] - v[j]) <= 2. + EPS) {
                    int count = 0;
                    P m = P(abs(v[i].real() + v[j].real()) / 2., abs(v[i].imag() + v[j].imag()) / 2.);
                    P p = m + (m - v[i]) / abs(m - v[i]) * sqrt(1. - pow(abs(m - v[i]), 2.));
                    p = rot(m, p, 90);
                    for (int k = 0; k < n; k++) {
                        if (abs(p - v[k]) <= 1. + EPS) count++;
                    }

                    res = max(res, count);
                }
            }
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

int main(){
    int n, ans = 0, temp = 0;
    string s;
    set<char> s1, s2;
    cin >>n >>s;
    for(int i = 0; i < n -1; i++){
        for(int k = 0; k <= i; k++){
            s1.insert(s[k]);
        }
        for(int k = i + 1; k < n; k++){
            s2.insert(s[k]);
        }
        //for(auto test1 = s1.begin(); test1 != s1.end(); ++test1){
          //  cout << *test1;
        //}
        //cout << endl;
        //for(auto test2 = s2.begin(); test2 != s2.end(); ++test2){
          //  cout << *test2;
        //}
        //cout << endl;
        for(auto itr = s1.begin(); itr != s1.end(); ++itr){
            auto search = s2.find(*itr);
            if(search != s2.end()){
                temp++;
                //cout << i << ":" << *itr << ":" << *search << ":" << temp <<endl;
            }
        }

        ans = max(ans, temp);
        temp = 0;
        s1.clear();
        s2.clear();
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct segtree{
    int bin;
    int sum[3000010];
    int idx[3000010];
    void init(int a){
        for(int i=0;i<2*a;i++){
            sum[i] = -1000;
            idx[i] = 1;
        }
        bin = 1;
        while(bin < a) bin *= 2;
        for(int i=0;i<a;i++){
            sum[i+bin-1] = 0;
            idx[i+bin-1] = i+1;
        }
    }
    
    void add(int a,int v){
        int now = a+bin-1;
        sum[now] += v;
        while(now > 0){
            now = (now-1)/2;
            if(sum[2*now+1] < sum[2*now+2]){
                sum[now] = sum[2*now+2];
                idx[now] = idx[2*now+2];
            } else {
                sum[now] = sum[2*now+1];
                idx[now] = idx[2*now+1];
            }
        }
    }
    int max(){
        return sum[0];
    }
    
    int maxidx(){
        return idx[0];
    }
    
};
segtree seg;
int main()
{
    int n,q,a,v;
    cin >> n >> q;
    seg.init(n);
    for(int i=0;i<q;i++){
        cin >> a >> v;
        seg.add(a-1,v);
        cout << seg.maxidx() << " " << seg.max() << endl;
    }
    return 0;
}



Measured memory_bytes: 19104
from math import ceil
import heapq

N, M = map(int, input().split())
tmpA = list(map(int, input().split()))
A = [-a for a in tmpA]
heapq.heapify(A)

for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, ceil(a / 2))

print(-sum(A))


Measured memory_bytes: 14380
/*=======================
Author    : Shounak Dey
Filename  : b.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll n;
	cin >> n;
	vector<double> arr(n);
	REP(i,n)
		cin >> arr[i];
	double num=1;
	double denum = 0;
	REP(i,n)
		num = num * arr[i];
	REP(i,n) 
		denum += num/arr[i];
	cout << setprecision(10) << fixed;
	cout << num/denum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int h, w;
    const int INF = 50 * 50;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<int>> d;
    d.resize(h);
    for (int i = 0; i < h; ++i){
        cin >> s[i];
        d[i].resize(w);
    }
    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            d[i][j] = INF;
        }
    }

    // search
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    d[0][0] = 0;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    while(!q.empty()){
        pair<int, int> p = q.front();
        q.pop();
        for (int i = 0; i < 4; ++i){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && s[nx][ny] != '#'){
                q.push(make_pair(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    if(d[h-1][w-1] == INF){
        cout << -1 << endl;
    }
    else {
        int itr = 0;
        int ans = 0;
        for (int i = 0; i < h; ++i){
            for (int j = 0; j < w; ++j){
                if(s[i][j] == '.'){
                    ans++;
                }
            }
        }
        ans -= (d[h-1][w-1] + 1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 888
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl       '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii        map<ll,ll>
using namespace std;

#define N  100005
ll n,m,cnt=0;
vi a[N],in(N,0),order;
set<ll> nextnode;
ll dp[N];
void topsort()
{
    rep(i,1,n+1)
    if(!in[i])
        {dp[i]=0;nextnode.insert(i);}
    while(!nextnode.empty())
    {
        ll cur=*nextnode.begin();
        nextnode.erase(cur);
        order.pb(cur);
        cnt++;
        for(auto i:a[cur])
        {
            in[i]--;
            dp[i]=max(dp[i],dp[cur]+1);
            if(!in[i])
                nextnode.insert(i);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll u,v;
        cin>>n>>m;
        rep(i,0,m)
        {
            cin>>u>>v;
            a[u].pb(v);
            in[v]++;
        }
        topsort();
        ll ans=0;
        rep(i,1,n+1)
        ans=max(ans,dp[i]);
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 9340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		char a[][] = new char[H][W];
		for (int i = 0 ; i < H ; i++) {
				String t = sc.next();
	            a[i] = t.toCharArray();
		}
		sc.close();

		int ans = 0;
		for (int h = 0; h < (Math.pow(2, H)); h++) {
			for (int w = 0; w < (Math.pow(2, W)); w++) {
				int count = 0;
				for (int j = 0; j < H; j++) {
					for (int k = 0; k < W; k++) {
						if((h>>j & 1)==1 && (w>>k&1)==1 && a[j][k]=='#') {
								count++;
						}
					}
				}
				if(count==K) {
					ans++;
				}
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int (i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int (i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int (i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}
string alphabet() { return "abcdefghijklmnopqrstuvwxyz"; }

int main() {
	string S;
	cin >> S;
	
	string last = S.substr(S.length() - 1, 1);
	int result = 0;
	repeat_r(i, S.length() - 2, -1) {
		string current = S.substr(i, 1);
		if (current == last) continue;

		last = current;
		result++;
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 512
def gcd(*numbers):
    """Return the greatest common divisor of the given integers"""
    from fractions import gcd
    return reduce(gcd, numbers)

# Least common multiple is not in standard libraries? It's in gmpy, but this is simple enough:

def lcm(*numbers):
    """Return lowest common multiple."""    
    def lcm(a, b):
        return (a * b) // gcd(a, b)
    return reduce(lcm, numbers, 1)
l = []
for x in range(int(raw_input())):
	l.append(int(raw_input()))
ans = 1
for x in l:
	ans = lcm(ans,x)
print(ans)

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

using namespace std;

const int A = 0, B = 1, C = 2;
const int M = 3;

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

    int n;
    cin >> n;

    vector<vector<int>> h(M, vector<int>(n)), dp(M, vector<int>(n));

    for (int i = 0; i < n; ++i) {
        cin >> h[A][i] >> h[B][i] >> h[C][i];
    }

    dp[A][0] = h[A][0];
    dp[B][0] = h[B][0];
    dp[C][0] = h[C][0];

    for (int i = 1; i < n; ++i) {
        dp[A][i] = max(dp[B][i - 1], dp[C][i - 1]) + h[A][i];
        dp[B][i] = max(dp[A][i - 1], dp[C][i - 1]) + h[B][i];
        dp[C][i] = max(dp[A][i - 1], dp[B][i - 1]) + h[C][i];
    }

    cout << max(max(dp[A][n - 1], dp[B][n - 1]), dp[C][n - 1]) << '\n';

    return 0;
}


Measured memory_bytes: 3064
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=3005;
const int mod=1e9+7;

int n;
bool visit[N][N];
db h[N],dp[N][N];
db rec(int i,int hd){
    if(i>n) return hd>n/2;
    db &cache=dp[i][hd];
    if(visit[i][hd]) return cache;
    visit[i][hd]=1;
    return cache=h[i]*rec(i+1,hd+1)+(1.0-h[i])*rec(i+1,hd);
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n) cin>>h[i];
    cout<<fix<<rec(1,0);
    return 0;
}


Measured memory_bytes: 78208
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
using namespace std;


int main(){
	string s;
	cin >> s;
	int ans = s.length();
	for (int i = 0; i < s.length()-1; i++){
		if (s[i] != s[i+1]){
			int temp = max(i+1, (int)s.length()-i-1);
			ans = min(temp, ans);
		}
	}
	cout << ans << endl;
	return 0;
}


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

const int MAXN = 1010;
typedef long long LL;
int xs[MAXN], ys[MAXN], n;
char step[50];
const int UP = 39;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> xs[i] >> ys[i];
	for (int i = 1; i <= n; ++i)
		if ((xs[i] + ys[i] & 1) != (xs[1] + ys[1] & 1))
			return std::cout << -1 << std::endl, 0;
	int typ = (xs[1] + ys[1] & 1) ^ 1;
	std::cout << UP + typ << '\n';
	if (typ) std::cout << 1 << ' ';
	for (int i = 0; i < UP; ++i)
		std::cout << (1ll << i) << (" \n" [i == UP - 1]);
	for (int i = 1; i <= n; ++i) {
		LL x = xs[i], y = ys[i];
		if (typ) step[0] = 'L', ++x;
		int cur = typ + UP - 1;
		for (int j = UP - 1; ~j; --j, --cur) {
			const LL L = 1ll << j;
			if (std::abs(x) > std::abs(y)) {
				if (x > 0) step[cur] = 'R', x -= L;
				else step[cur] = 'L', x += L;
			} else {
				if (y > 0) step[cur] = 'U', y -= L;
				else step[cur] = 'D', y += L;
			}
		}
		std::cout << step << '\n';
	}
	return 0;
}


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

typedef long long ll;

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

// chmax, chmin
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; }

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    REP(i,N) {
        cin >> p[i];
        p[i] -= 1;
    }
    
    vector<int> c;
    int count = 0;
    REP(i,N){
        if ( i == p[i] ) {
            ++count;
        } else {
            c.push_back(count);
            count = 0;
        }
    }
    c.push_back(count);
    
    int ans = 0;
    for ( auto a: c){
        ans += ( (a+1)/2 );
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4232
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0
    for (i in 0 until n step 2) {
        if (aa[i] % 2 == 1) cnt++
    }

    println(cnt)
}

Measured memory_bytes: 36704
n = int(input())
a= list(map(int, input().split()))
from collections import deque
d=deque()
if n%2==0:
    flag=1
else:
    flag=-1
for i in a:
    if flag==1:
        d.append(i)
        flag*=-1
    else:
        d.appendleft(i)
        flag*=-1
for i in d:
    print(i,end=" ")
print()

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
char in[100005],mod1[100005],mod2[100005];
int main(){
	while(~scanf("%s",in)){
		int l=strlen(in),ans1=0,ans2=0;
		F(i,0,l){
			if(i%2) mod1[i]='0',mod2[i]='1';
			else mod1[i]='1',mod2[i]='0';
		}
		F(i,0,l){
			if(in[i]!=mod1[i]) ans1++;
			if(in[i]!=mod2[i]) ans2++;
		}
		printf("%d\n",min(ans1,ans2));
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n, i;
  ll ans = 0;
  vector<ll> a;

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

  for(i=0;i<n;i++) cin >> a[i];

  for(i=0;i<n-1;i++){
    ans += a[i]/2;

    if(a[i]%2==1&&a[i+1]!=0){
      ans += 1;
      a[i+1] -= 1;
    }
  }
  ans += a[n-1] / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    static int mod=1000000007;
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        String s=sc.next();
        int ans=0;
        for (int i = 0; i <4 ; i++) {
            if(s.charAt(i)=='2')ans++;
        }
        out.println(ans);
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a,int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	int H,W;
	std::cin >> H >> W;
	int c[10][10];
	int A[H][W];
	for (size_t i = 0; i < 10; i++) {
		for (size_t j = 0; j < 10; j++) {
			std::cin >> c[i][j];
		}
	}
	for (size_t i = 0; i < H; i++) {
		for (size_t j = 0; j < W; j++) {
			std::cin >> A[i][j];
		}
	}

	// ワーシャルフロイド法
	// 経由する頂点
	for (size_t i = 0; i < 10; i++) {
		// 開始頂点
		for (size_t j = 0; j < 10; j++) {
			// 終端
			for (size_t k = 0; k < 10; k++) {
				c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
			}
		}
	}

	unsigned long long cost = 0;
	for (size_t i = 0; i < H; i++) {
		for (size_t j = 0; j < W; j++) {
			if (A[i][j] != -1) {
				cost = cost + c[A[i][j]][1];
			}
		}
	}

	std::cout << cost << '\n';
	return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n)cin>>h[i];
	REV(h);
	rep(i,n-1){
		if(h[i] >= h[i+1]){
			// ok
		} else {
			h[i+1]--;
			if(h[i] >= h[i+1]){
				// ok;
			} else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
  ll h,w,k;cin>>h>>w>>k;
  ll dp[h+1][w];
  memset(dp,0,sizeof dp);
  dp[0][0]=1;
  ll hon[w][2];
  memset(hon,0,sizeof hon);
  hon[0][0]=1;
  ll hh[w+1];
  hh[0]=1;
  for(int i=0;i<w-1;i++){
    (hon[i+1][0]+=hon[i][0]+hon[i][1])%=mod;
    (hon[i+1][1]+=hon[i][0])%=mod;
    hh[i+1]=hon[i][0]+hon[i][1];
    hh[i+1]%=mod;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        ll sum=dp[i][j]*hh[w-1-j];
        sum%=mod;
        sum*=hh[j];
        sum%=mod;
        dp[i+1][j]+=sum;
        dp[i+1][j]%=mod;
        if(j>0){
          sum=dp[i][j]*hh[w-1-j];
          sum%=mod;
          sum*=hh[j-1];
          sum%=mod;
          dp[i+1][j-1]+=sum;
          dp[i+1][j-1]%=mod;
        }
      if(j<w-1){
        sum=dp[i][j]*hh[j];
        sum%=mod;
        sum*=hh[w-2-j];
        sum%=mod;
        dp[i+1][j+1]+=sum;
        dp[i+1][j+1]%=mod;
      }
    }
  }
  cout<<dp[h][k-1]<<endl;
}
      
  

Measured memory_bytes: 256
# AOJ 0287: Jinkoki
# Python3 2018.6.26 bal4u

unit = ("", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", \
"Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts")

while True:
	m, n = map(int, input().split())
	if m == 0: break
	s = str(m ** n)[::-1]
	ans, j = [], 0
	for i in range(0, len(s), 4):
		t = str(int(s[i:i+4][::-1]))
		if t != "0": ans += [unit[j], t]
		j += 1
	print(*ans[::-1], sep='')


Measured memory_bytes: 5604
import sys

n = int(input())
l = []
l += list(map(int, input().split()))

if l.count(0) >= 1:
    print('0')
    sys.exit()

r = 1
for e in l:
    r = r * e

    if r > 10 **18:
        print('-1')
        sys.exit()
        
print(r)

Measured memory_bytes: 84736
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int binary_search(int* a,long long k,int n){
    int R = n,L = 0;
    while(L < R){
        int mid = (L+R)/2;
        if (a[mid] == k) return 1;
        else if (k < a[mid]) R = mid;
        else L = mid+1;
    }
    return 0;
}

int main(){
    int n; cin >> n; 
    
    vector<pair<int,int> > p(0);
    for(int i = 0; i < n; i++){
        int x,y; cin >> x >> y;
        p.push_back({x,y});
    }
    sort(p.begin(),p.end());
    for(int i = 0; i < n; i++){
        cout << p[i].first << " " << p[i].second << endl;
    }
}
  




Measured memory_bytes: 3884
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=20;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=100500;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n+1)/2);
            contest[type].last=day;
        }
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp_score=Score(ans[p]);
    int temp=ans[p];
    ans[p]=rand()%ntype+1;
    int delta=Score(ans[p])-temp_score;
    if(delta>0) max_score+=temp_score;
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0) max_score+=temp_score;
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void solve(int times){
    max_score=0;
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    Output();
}


Measured memory_bytes: 3680
n,k=map(int,input().split())
a=list(map(int,input().split()))
MOD=10**9+7

a.sort()

perm=[1]*n
perm_inv=[1]*n
for i in range(n-1):
    perm[i+1]=perm[i]*(i+1)
    perm[i+1]%=MOD
def egcd(a, b):
    """return (g, x, y) such that a*x + b*y = g = gcd(a, b)"""
    if a == 0:
        return (b, 0, 1)
    else:
        b_div_a, b_mod_a = divmod(b, a)
        g, x, y = egcd(b_mod_a, a)
        return (g, y - b_div_a * x, x)
_,buf,_=egcd(perm[-1],MOD)
perm_inv[-1]=buf
for i in range(n-2,-1,-1):
    perm_inv[i]=perm_inv[i+1]*(i+1)
    perm_inv[i]%=MOD
#print(perm_inv,perm)
count=0
for i in range(n-k+1):
    buf=perm[n-1-i]
    buf*=perm_inv[k-1]
    buf%=MOD
    buf*=perm_inv[n-1-i-(k-1)]
    buf%=MOD
    count+=buf*(-1*a[i]+a[-1*i-1])
    count%=MOD
    #print(buf,count)
print(count)

Measured memory_bytes: 63344
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll d,t,s;
  cin>>d>>t>>s;
  if (d <= t*s) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3692
A,B = list(map(int,input().split()))
z=0

for x in range(int(((25*A)+1)/2),int((25*(A+1)-1)/2)):
    for y in range(int(10*B),int(10*(B+1))):
        if x==y:
            print(x)
            break
        else:
            z += 1
    if x==y:
        break
 
if z==(int((25*(A+1)-1)/2)-int(((25*A)+1)/2))*(int(10*(B+1))-int(10*B)):    
    print(-1)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
D = LIST()

time = [0]*13
time[0] = 1
for d in D:
	time[d] += 1

if 2 <= time[0] or 2 <= time[12]:
	print(0)
	exit()
elif any(3 <= x for x in time):
	print(0)
	exit()

time_ = [0]*24
time_koho = []
for i, cnt in enumerate(time[1:], 1):
	if cnt:
		if cnt == 2:
			time_[i] = 1
			time_[24-i] = 1
		else:
			time_koho.append(i)

ans = 0
for x in product([0, 1], repeat=len(time_koho)):
	time_tmp = time_.copy()
	for idx, y in enumerate(x):
		if y:
			time_tmp[24-time_koho[idx]] = 1
		else:
			time_tmp[time_koho[idx]] = 1

	time_diff = INF
	tmp = 0
	for j, c in enumerate(time_tmp[1:]+[1], 1):
		if c:
			time_diff = min(time_diff, j-tmp)
			tmp = j

	ans = max(ans, time_diff)

print(ans)

Measured memory_bytes: 10580
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextBuf() []byte {
	sc.Scan()
	buf := sc.Bytes()
	return buf
}

func main() {
	buf := nextBuf()

	ans := 0
	for i := 0; i < len(buf)/2; i++ {
		if buf[i] != buf[len(buf)-i-1] {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
		String str = sc.nextLine();
		int[][] a = new int[10][10];
		int count = 9;
		for(int i = 0 ; i < 10 ; i++){
			a[0][i] = Integer.parseInt(str.substring(i,i+1)); 
		}
		for(int j = 1 ; j <= 9 ; j++){
			for(int k = 0 ; k < count ; k++){
				a[j][k] = (a[j-1][k] + a[j-1][k+1])% 10;
			}
			count--;
		}
		System.out.println(a[9][0]);
		}
		sc.close();
	}

}

Measured memory_bytes: 17140
#cording:utf-8

A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for i in range(0,A+1):
  for j in range(0,B+1):
    for k in range(0,C+1):
      total = 500*i + 100*j + 50*k
      if total == X:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong(),b=sc.nextLong();
		long c = sc.nextInt(),d=sc.nextInt();
		
		long l = lcm(c,d);
		a--;
		long ans1 = a-a/c-a/d+a/l;
		long ans2 = b-b/c-b/d+b/l;
		
		long ans = ans2-ans1;
		
		System.out.println(ans);
		
		
		
	}
		


}


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

int n, a[100009],f[100009][2], pre[100009] , suff[100009] ;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  cin>>n;
  for(int i=1 ; i<=n; i++){
    cin>>a[i];
    f[a[i]][i%2]++;
  }
  
  pre[1] = n/2 - f[1][0] ;
  suff[100000] = n/2 - f[100000][0];
  
  for(int i=2 ; i<=100000; i++){
    pre[i] = min(pre[i-1] , n/2 - f[i][0]);
  }
                 
  for(int i=99999; i>=1; i--){
    suff[i] = min(suff[i+1] , n/2 - f[i][0]);
  }
   pre[0] = suff[0] = n;
   pre[100001] = suff[100001] = n ;
   int ans = n;
  for(int i=1 ; i<=100000; i++){
    int temp = n/2 - f[i][1];
    temp = temp + min(pre[i-1] , suff[i+1]);
    ans = min(ans , temp);
  }
                 
   cout<<ans;
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,ans=0;
    string s;
    cin >> n >> s;
    REP(i,n-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* ex 9_1
   kohei_suzuki */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100
 
//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
 
//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}
 
//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    char input[SIZE];
    stack stk;

    initialize_stack(&stk);//stkの初期化 

    scanf("%s", input);//入力受取

    for(int i=0; i<strlen(input); i++){
        if(input[i] == '0' || input[i] == '1'){
            push(&stk, input[i]);
        }
        else if(input[i] == 'B' && stk.count > 0){
            pop(&stk);
        }
    }

    //古いデータから出力
    for (int i=0; i<stk.count; i++){
        printf("%c", stk.data[SIZE-i-1]);
    }

}

Measured memory_bytes: 1616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		IO io = new IO();
		while(true) {
			int n = io.nextInt();
			if (n == 0) {
				break;
			}
			char[] dic = new char[256];
			for(int i=0;i<n;i++) {
				char a = io.nextChar();
				char b = io.nextChar();
				if (dic[a] == 0) {
					dic[a] = b;
				}
			}
			int m = io.nextInt();
			for(int i=0;i<m;i++) {
				char c = io.nextChar();
				if (dic[c] == 0) {
					io.print(c);
				}else{
					io.print(dic[c]);
				}
			}
			io.println();
			io.flush();
		}
	}

}

class IO {
	BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
	StringBuilder out = new StringBuilder();
	int index = 0;
	String bfl = null;
	String[] bf = new String[0];
	private boolean read() {
		try {
			bfl = bi.readLine();
			if (bfl == null) {
				return false;
			}
			bf = bfl.split("\\s");
			index = 0;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return true;
	}
	public boolean hasNext() { return index < bf.length ? true : read(); }
	public boolean hasNextLine() { return read(); }
	public String next() { return hasNext() ? bf[index++] : null; }
	public String nextLine() { return hasNextLine() ? bfl : null; }
	public int nextInt() { return Integer.parseInt(next()); }
	public long nextLong() { return Long.parseLong(next()); }
	public double nextDouble() { return Double.parseDouble(next()); };
	public char nextChar() { return next().charAt(0); }
	public void println(long x) { out.append(x); out.append("\n"); }
	public void println(double x) { out.append(x); out.append("\n"); }
	public void println(String s) { out.append(s); out.append("\n"); }
	public void println() { out.append("\n"); }
	public void print(long x) { out.append(x); }
	public void print(double x) { out.append(x); }
	public void print(String s) { out.append(s); }
	public void print(char c) {out.append(c);}
	public void flush() {System.out.print(out); out = new StringBuilder(); }
	public int[] arrayInt(int n) {
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = nextInt();
		}
		return a;
	}
	public long[] arrayLong(int n) {
		long[] a = new long[n];
		for(int i=0;i<n;i++) {
			a[i] = nextLong();
		}
		return a;
	}
	public double[] arrayDouble(int n) {
		double[] a = new double[n];
		for(int i=0;i<n;i++) {
			a[i] = nextDouble();
		}
		return a;
	}
}

Measured memory_bytes: 69188
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

int main(){
    int N;
    while(scanf("%d",&N),N){
        vi V(N*N);
        rep(i,N*N){
            int x,y;
            scanf("%d%d",&x,&y);
            V[i]=y*N+x;
        }
        int cnt=0;
        bool used[10000]={0};
        rep(i,N*N){
            if(used[i])continue;
            int pos=i;
            bool u[10000]={0};
            while(!u[pos]){
                u[pos]=true;
                pos=V[pos];
            }
            if(pos!=i)continue;
            cnt++;
            rep(i,N*N)used[i]|=u[i];
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1252
#include<cstdio>
#include<iostream>
#include<vector>
#include<utility>
using namespace std;

int main(){

  int n;
  cin>>n;
  int array[n][3];
  int sum[n];
  typedef pair<int,int> P;
  P p;
  vector< P > v;
  //init
  for(int i=0;i<n;i++)
    sum[i]=0;

  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      cin>>array[i][j];

  for(int l=0;l<3;l++)
    for(int i=0;i<n-1;i++)
      for(int j=i+1;j<n;j++)
	if(array[i][l]==array[j][l]){ 
	  p.first=i;
	  p.second=l;
	  v.push_back(p);
	  p.first=j;
	  p.second=l;
	  v.push_back(p);
	}

  while(!v.empty()){
    p=v.back();
    array[p.first][p.second]=0;
    v.pop_back();
  }

  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      sum[i]+=array[i][j];
  
  for(int i=0;i<n;i++)
    cout<<sum[i]<<endl;
    
  return 0;
}

Measured memory_bytes: 1228
// https://atcoder.jp/contests/abl/tasks/abl_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll K;
  cin >> K;

  string res = "";
  rep(i, K) res += "ACL";

  cout << res << "\n";
}


Measured memory_bytes: 3652
H,W=map(int,input().split())
A=[input() for i in range(H)]

IsPossible=True
res=[]
for y in range(H):
    left=-1
    right=0
    for x in range(W):
        if A[y][x]=='#':
            if left<0:
                left=x
                right=x
            else:
                if x-right==1:
                    right=x
                else:
                    IsPossible=False
                    break
    res.append((left,right))

for y in range(1,H):
    if res[y-1][1]!=res[y][0]:
        IsPossible=False

if IsPossible:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 9208
#include <cstdio>
#include <cstring>

int main() {
  int k, l;
  char s[101];
  scanf("%d", &k);
  scanf("%s", s);
  l = std::strlen(s);
  if (l <= k) {
    printf("%s\n", s);
  } else {
    for (int i = 0; i < k; i++) {
      std::putchar(s[i]);
    }
    printf("...\n");
  }
  return 0;
}

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

int main(){
 int N;
  cin >>N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >>H.at(i);
  }
  int ans=1;
  for(int i=1;i<N;i++){
    int check=1;
  for(int j=0;j<i;j++){
    if(H.at(i)<H.at(j)){check=0;}
  }
    if(check==1){ans++;}
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    ll total = 0;
    for(int i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0){
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3636
a, b, k = gets.chomp.split.map(&:to_i)

ans_a, ans_b = 0, 0
if k >= a
  ans_a = 0
  if b >= k - a
    ans_b = b - (k - a)
  else
    ans_b = 0
  end
else
  ans_a = a - k
  ans_b = b
end

print "#{ans_a} #{ans_b}\n"

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

int N, Q, A[100001];
int S[100001], Sdiv[100001];
pair<int, int> X[100000];
int ans[100000];

signed main() {
  cin >> N >> Q;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    S[i] = S[i-1] + A[i];
    Sdiv[i] = A[i];
    if (i - 2 > 0) Sdiv[i] += Sdiv[i-2];
  }

  for (int i = 0; i < Q; i++) {
    int x;
    cin >> x;
    X[i] = {x, i};
  }
  sort(X, X+Q);

  int y = 1;
  for (int q = 0; q < Q; q++) {
    int x = X[q].first;
    while (y <= N && A[y] < x) y++;
    while (y <= N) {
      int upper = N - y + 1;
      int lower = y - (lower_bound(A, A+N+1, max(1LL, 2*x-A[y])) - A) + 1;
      if (upper > lower) {
        y++;
      } else {
        break;
      }
    }
    int result = S[N] - S[y-1];
    int t_first = N - (N - y + 1) * 2;
    if (t_first > 0) result += Sdiv[t_first];
    ans[X[q].second] = result;
  }

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

  return 0;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if ((A.at(A.size() - 1) == B.at(0)) && (B.at(B.size() - 1) == C.at(0))){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/segment_tree.hpp"



#include <vector>
#include <algorithm>
#include <functional>

template<typename Monoid>
class SegmentTree {
public:
    using Operator = std::function<Monoid(Monoid, Monoid)>;

    SegmentTree(int n, const Operator &op, const Monoid init)
        : op(op), init(init) {

        num = 1;
        while (num < n) num *= 2;
        dat.resize(2 * num, init);
    }

    SegmentTree(const std::vector<Monoid> &m,
        const Operator &op, const Monoid init)
        : SegmentTree(m.size(), op, init) {

        int n = m.size();
        for (int i = 0; i < n; i++) {
            dat[num - 1 + i] = m[i];
        }
        for (int i = num - 2; i >= 0; i--) {
            dat[i] = op(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    // Update the k-th value (0-indexed) to a.
    void update(int k, Monoid a) {
        k += num - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    // Get the value of the range [a, b).
    // k: The index of the node.
    // [left, right): The range corresponds to the k-th node.
    // Call like getval(a, b).
    Monoid getval(int a, int b, int k = 0, int left = 0, int right = -1) {
        if (right < 0) right = num;
        if (right <= a || b <= left) return init;
        if (a <= left && right <= b) return dat[k];
        Monoid vleft = getval(
            a, b, 2 * k + 1, left, left + (right - left) / 2);
        Monoid vright = getval(
            a, b, 2 * k + 2, left + (right - left) / 2, right);
        return op(vleft, vright);
    }

private:
    int num;
    std::vector<Monoid> dat;
    const Operator op;
    const Monoid init;
};


int main() {
    int n; long long x; std::cin >> n >> x;
    std::vector<long long> a(2*n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n; i++) a[n + i] = a[i];
    SegmentTree<long long>
        seg(a, [](auto a, auto b) {return std::min(a, b); }, 1e18);
    long long ans = 1e18;
    for (long long i = 0; i < n; i++) {
        long long s = i*x;
        for (int j = n; j < 2 * n; j++) {
            s += seg.getval(j - i, j + 1);
        }
        ans = std::min(ans, s);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 384