akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;

// GCD, LCM
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;}

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

    if(S.length()<=K){
        cout<<S<<endl;
    }else{
        cout<<S.substr(0,K)+"...";
    }

    return 0;
}

Measured memory_bytes: 3624
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

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

int main()
{
  string s;
  cin >> s;
  int size = s.size();
  int k;
  cin >> k;

  vector<string> v;
  for (int i = 1; i <= k; i++)
  {
    for (int j = 0; j < size - i + 1; j++)
    {
      v.push_back(s.substr(j, i));
    }
  }
  sort(v.begin(), v.end());
  unique(v.begin(), v.end());
  cout << v[k - 1] << "\n";
}

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

using namespace std;

int main(int argc, char *argv[]) {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) printf("GREATER\n");
	else if (A.size() < B.size()) printf("LESS\n");
	else if (A > B) printf("GREATER\n");
	else if (A == B) printf("EQUAL\n");
	else printf("LESS\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
const long long INF = 1LL<<60;

int main() {
    int n, k; cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    long long ans = INF;
    for (int bit = 0; bit < (1<<n); bit++) {
        int t = bitset<20>(bit).count();
        if (t < k) continue;
        long long cost = 0;
        int highest = a[0];
        for (int i = 1; i < n; i++) {
            if (bit & (1<<i) && a[i] <= highest) {
                cost += highest - a[i] + 1;
                highest++;
            }
            else {
                highest = max(highest, a[i]);
            }
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

x = LIST()

sqsum = 0
sum1 = 0
for el in x:
    sqsum+=el*el
    sum1+=el
z = 10**9
for p in range(0, 101):
    z = min(z, sqsum+p*p*n - 2*p*sum1)

print(z)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int prerate, exrate, total;
ll tax(ll rate, ll price_without_tax) {
    return price_without_tax * (100 + rate) / 100.0;
}
ll solve() {
    ll maximum = 0;
    for (ll i = 1; i < total; ++i) {
        for (ll j = 1; j < total; ++j) {
            if (total == tax(prerate, i) + tax(prerate, j)) {
                maximum = max(maximum, tax(exrate, i) + tax(exrate, j));
            }
        }
    }
    return maximum;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    #define int long long;
    while (cin >> prerate) {
        cin >> exrate >> total;
        if (exrate == 0 && prerate == 0 & total == 0) {
            return 0;
        }
        cout << solve() << endl;
    } 
    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define maxn 500005
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fu(i,l,r) for(int i=(l);i<=(r);i++)
#define fd(i,l,r) for(int i=(l);i>=(r);i--)
#define Set set<int>
using namespace std;
#define int long long
#define P pair<int,int>
int n,m,a[maxn],b[maxn];

int32_t main()
{
    IOS;
    int x,y,z;
    cin>>x>>y>>z;
    int cha=z/x;
    cout<<cha*y;
    return 0;
}


Measured memory_bytes: 256
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

for i in range(N):
    for j in range(3):
        if B[i] in A[j]:
            index_v = A[j].index(B[i])
            A[j][index_v] = 0

if (A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0) or (A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0) or (A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0) or (A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0) or (A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0) or (A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0) or (A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0) or (A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

  if (A == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll sum = A+B;
  ll n = N / sum;
  ll x = n * A;
  ll a = N % sum;
  if (a >= A) x += A;
  else x += a;
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=1e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=2e3+10;
	//------------------FIXED------------------
	int a[N][N],b[N];
	void solve(int n)
	{
		if(n==1){ a[1][1]=1;return; }
		solve(n-1);a[bin(n-1)][bin(n-1)]=1;
		fo(i,1,bin(n-1)-1) fo(j,1,bin(n-1)-1) a[i+bin(n-1)][j+bin(n-1)]=a[i+bin(n-1)][j]=a[i][j+bin(n-1)]=a[i][j];
	}
	void main()
	{
		int n=qread(),m=qread();bool tg=0;if(n<m) swap(n,m),tg=1;
		solve(n);
		if(!tg) fo(i,1,bin(n)-1) {fo(j,1,bin(m)-1) write(a[i][j]);puts("");}
		else fo(j,1,bin(m)-1) {fo(i,1,bin(n)-1) write(a[i][j]);puts("");}
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//线性预处理模意义
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 34304
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 100002;
int main(){
    int n;
    bool change[maxn];
    memset(change, false, sizeof(change));
    cin >> n;
    int tmp;
    for (int i = 1 ; i <= n ; i++){
        cin >> tmp;
        if (tmp == i)
            change[i] = true;
    }
    int cnt = 0, index = 1;
    while (index <= n){
        if (change[index]){
            cnt++;
            index+=2;
        }else
            index++;
    }
    cout << cnt << '\n';
    return 0;
}


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

using namespace std;

int main(){
	int D, G;
	cin >> D >> G;
	vector<int> P(D);
	vector<int> C(D);

	for (int d=0; d<D; d++){
		cin >> P[d] >> C[d];
	}

	int min_solve = 1000;
	int score;
	int solve;
	int maxpro;
	int extra;

	//bit全探索, 完全に解く場合
	for (int bit=0; bit <(1<<D); bit++){
		score=0;
		solve=0;
		maxpro = -1;
		for (int i=0; i<D; i++){
			if (bit & (1 << i)){
				score += (i+1)*100*P[i];
				score += C[i];
				solve += P[i];
			}
			else{
				maxpro = i;
			}
		}

		if (score >= G){
			if (min_solve > solve) min_solve = solve;
		}else{
			if (maxpro >= 0){
				//extra = ceil((G-score)/((maxpro+1)*100));
				extra = (G-score+(maxpro+1)*100 - 1)/((maxpro+1)*100);
              	//cout << bit << " " << extra << endl;
				if (extra < P[maxpro]){
					solve += extra;
					if (min_solve > solve) min_solve = solve;			
				}
			}
		}
	}

	cout << min_solve << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<P>>;
 
int main() {
    int N;
    cin >> N;
    Graph G(N);
    rep(i, N-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(P(b, c));
        G[b].push_back(P(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    K--;
 
    vector<ll> dist(N, -1);
    queue<int> que;
    dist[K] = 0;
    que.push(K);
 
    while (!que.empty()) {
        int v = que.front(); que.pop();
 
        for (P nv: G[v]) {
            if (dist[nv.first] != -1) continue;
            dist[nv.first] = dist[v] + nv.second;
            que.push(nv.first);
        }
    }
    
    rep(i, Q) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 10740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
int cost[510][510];
int ext[510][510];

void update(int x, int y) {
    queue<P> q;
    q.push(P(x, y));
    while (q.size()) {
        P p = q.front(); q.pop();
        int cx = p.first, cy = p.second;
        rep(i, 4) {
            int nx = cx+dx[i], ny = cy+dy[i];
            if (0<=nx && nx<N && 0<=ny && ny<N && cost[nx][ny]>cost[cx][cy]+ext[cx][cy]) {
                cost[nx][ny] = cost[cx][cy]+ext[cx][cy];
                q.push(P(nx, ny));
            }
        }
    }
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) rep(j, N) cost[i][j] = min({i, j, N-1-i, N-1-j});
    rep(i, N) rep(j, N) ext[i][j] = 1;
    int ans = 0;
    rep(i, N*N) {
        int P; cin >> P;
        P--;
        ans += cost[P/N][P%N];
        ext[P/N][P%N] = 0;
        update(P/N, P%N);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int a,b,c,d;

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

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()


def pow(x, y, mod=1000000007):
	pow_list = [x]
	i = 1
	while 2**i <= y:
		a = pow_list[-1]**2
		if mod != 0:
			a = a % mod
		pow_list.append(a)
		i += 1
	ans = 1
	for bit in range(len(pow_list)):
		if (2**bit) & y != 0:
			ans *= pow_list[bit]
			if mod != 0:
				ans = ans % mod
	return ans

def fact(n, mod=100000007):
	ans = 1
	for i in range(n):
		ans *= i + 1
		if mod != 0 and ans >= mod:
			ans = ans % mod
	return ans

def mod_rev(x, mod):
	"""
	関数powが必要
	"""
	return pow(x, mod - 2, mod)

N, A, B, C, D = list(map(int, input().split()))
mod = 1000000007

mod_sho = [0]
for i in range(N):
	mod_sho.append(mod_rev(i + 1, mod))

comb = [[0]*(N + 1) for _ in range(N + 1)]
comb[0][0] = 1
for n in range(1, N + 1):
	comb[n][0] = 1
	comb[n][n] = 1
	for i in range(1, n):
		comb[n][i] = comb[n - 1][i - 1] + comb[n - 1][i]
		comb[n][i] = comb[n][i] % mod
plus_list = []
for i in range(A, B + 1):
	G = []
	for j in range(C, D + 1):
		if i*j > N:
			break
		else:
			G.append(i*j)
	if len(G) > 0:
		plus_list.append(G)

sum = [0]*(N + 1)
sum[0] = 1

if len(plus_list) == 0:
	print(0)
	exit()
num = A - 1
for number in plus_list:
	#print(number)
	num += 1
	sum_next = [0] * (N + 1)
	for n in range(0, N + 1):
		if sum[n] == 0:
			continue
		sum_next[n] += sum[n]
		sum_next[n] = sum_next[n] % mod
		times = 1
		rest = N - n
		seki = 1
		for x in range(1, D + 1):

			if n + x*num <= N:
				seki *= comb[rest][num]
				seki = seki*mod_sho[times]
				seki = seki % mod
				if x >= C:
					sum_next[n + x*num] += (sum[n]*seki) % mod
					sum_next[n + x*num] = sum_next[n + x*num] % mod
					#print(sum_next, sum, seki)
				times += 1
				rest -= num
			else:
				break
	sum = copy.deepcopy(sum_next)


print(sum[N])


Measured memory_bytes: 122584
#include<iostream>
#include<string>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    map<string,int> mp;
    int n;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        string str;
        cin>>str;
        mp[str]++;
    }
    cout<<mp.size()<<endl;

    return 0;
}

Measured memory_bytes: 19224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<typename T>
struct Edge{
    int u, v;
    T cost;
    
    Edge() = default;
    Edge(int u, int v, T cost) : u(u), v(v), cost(cost) {}

    bool operator<(const Edge& other) const{
        return cost < other.cost;
    }
};

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

// クラスカル法を適用してグラフの最小全域木を求める
template<typename T>
T Kruskal(vector<Edge<T>> &es, int VertexNumber){
    T res = 0;    
    sort(es.begin(), es.end());
    int sz = es.size();
    UnionFind tree(VertexNumber);
    for(int i = 0; i < sz; ++i){
        if(!tree.same(es[i].u, es[i].v)){
            tree.unite(es[i].u, es[i].v);
            res += es[i].cost;
        }
    }
    return res;
}

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

    int V, E;
    cin >> V >> E;
    vector<Edge<int>> es;
    for(int i = 0; i < E; ++i){
        int u, v, w;
        cin >> u >> v >> w;
        es.emplace_back(u, v, w);
    }
    cout << Kruskal(es, V) << endl;
}


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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,m;
    cin>>n>>m;
    vector<ll> h(n);
    vector<vector<int>> load(n);
    rep(i,0,n)cin>>h[i];
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        load[a].push_back(b);
        load[b].push_back(a);
    }
    int ans=0;
    rep(i,0,n){
        int num=true;
        rep(j,0,load[i].size()){
            int to=load[i][j];
            if(h[i]>h[to])num=true;
            else {num=false;break;}
        }
        ans+=num;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9084
s ={}
n = int(input())
for _ in range(n):
    word = input()
    s[word] = s.get(word, 0)+1
m = int(input())
for _ in range(m):
    word = input()
    s[word] = s.get(word, 0)-1

ans = max(max(s[i],0) for i in s)
print(ans)


Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  if(k>((n-1)*(n-2))/2){
    std::cout << -1 << '\n';
    return 0;
  }
  if(n==2){
    if(k==0){
      std::cout << 1 << '\n';
      std::cout << 1 << " " << 2 << '\n';
    }else std::cout << -1 << '\n';
    return 0;
  }
  ll t = 0;
  for(int j=n-2;j>0;j--){
    if(k<j) break;
    k -= j, t++;
  }
  //std::cout << k << " " << t << '\n';
  vvl ans = vv(0, 2, 0, ll);
  re(i, t) ans.push_back(vll{i+1, n});
  deque<vll> q;
  for(int i=t+1;i<n;i++) for(int j=i+1;j<n;j++) q.push_back(vll{i, j});
  re(i, k) q.pop_front();
  while(!q.empty()){
    vll tmp = q.front();q.pop_front();
    ans.push_back(tmp);
  }
  for(int i=t+1;i<n;i++) ans.push_back(vll{i, n});
  std::cout << ans.size() << '\n';
  re(i, ans.size()) std::cout << ans[i][0] << " " << ans[i][1] << '\n';
  return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

ll n, a, b;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> a >> b;
    if(a > b){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1 and a != b){
        cout << 0 << endl;
        return 0;
    }
    if(a == b){
        cout << 1 << endl;
    }else{
        ll ub = (n - 2) * b;
        ll lb = (n - 2) * a;
        cout << ub - lb + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,as,af,end;
  cin >> a >> b >> c;
  as=0,af=a;
  end=c-af;
  while(1){
    if(as<=c&&c<=af){
      cout << c << endl;
      break;
    }
    as+=a+b,af+=a+b;
    if(as>c) c+=60;
    if(c-af==end){
      cout << -1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		if((i%3) && (i%5))
			ans+=i;
	}
	cout << ans;


	return 0;
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define SZ(x) ((int)(x).size())
#define ll long long
#define int ll
#define el '\n'
template<class T> bool inline rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool inline rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);

int m1, d1, m2, d2;
cin>>m1>>d1>>m2>>d2;
cout<<(m1!=m2)<<el;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  int i;
  for(i=0;i<n;i++)cin>>s.at(i)>>t.at(i);
  string x;cin>>x;
  int chi;
  for(i=0;i<n;i++)
  {
    if(s.at(i)==x)chi=i;
  }
  int ans=0;
  for(i=chi+1;i<n;i++)ans+=t.at(i);
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

inline void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int t = min(a, k);
	int otv = t;
	k -= t;
	t = min(b, k);
	k -= t;
	t = min(c, k);
	otv -= t;
	k -= t;
	cout << otv;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 3652
# coding: utf-8
# Your code here!
n,l=map(int,input().split())
flg=0
ans=0
if l>=0:
    flg=1
else:
    if abs(l)<=n-1:
        flg=2

if flg ==0:
    for i in range(n-1):
        ans+=i+l
if flg==1:
    for i in range(1,n):
        ans+=i+l
if flg==2:
    for i in range(n):
        if i!=abs(l):
            ans+=i+l
print(ans)


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

int main() {
  static map<string, string> m;
  m["Sunny"] = "Cloudy";
  m["Cloudy"] = "Rainy";
  m["Rainy"] = "Sunny";

  string s;
  cin >> s;
  cout << m[s] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
struct edge{
	int to,next;
}e[410000];
int first[210000];
queue<int> q;
void addedge(int num,int x,int y)
{
	e[num].to=y;
	e[num].next=first[x];
	first[x]=num;
}
int main()
{
	int n,m,x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		addedge(2*i-1,x,y);
		addedge(2*i,y,x);
	}
	for(int i=first[1];i;i=e[i].next)
	if(e[i].to==n) {printf("POSSIBLE\n");return 0;}
	else q.push(e[i].to);
	while(!q.empty())
	{
		int now=q.front();
		q.pop();
		for(int i=first[now];i;i=e[i].next)
		if(e[i].to==n) {printf("POSSIBLE\n");return 0;}
	}
	printf("IMPOSSIBLE\n");
	return 0;
} 

Measured memory_bytes: 4608
# -*- coding: utf-8 -*-

N = int(input())
a = list(map(int, input().split()))
count=0
#a = {int(x) for x in input().split()}
for i in range(N - 2):
    if (a[i] > a[i + 1] & a[i + 1] > a[i + 2]):
        count += 1
    elif (a[i] < a[i + 1] & a[i + 1] < a[i + 2]):
        count += 1
print(count)

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

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

signed main(){
    string s; cin >> s;
    int cnt1 = 1, cnt2 = 1;
    char c1 = 'a', c2 = 'a';
    REP( i, s.size() ){
        if( c1 == 'a' ) c1 = s[i];
        else if( c1 == s[i] ) cnt1++;
        else if( c2 == 'a' ) c2 = s[i];
        else if( c2 == s[i] ) cnt2++;
    }

    if( cnt1 == cnt2 && cnt1 == 2 ) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import math
a, b, x = map(int, input().split(" "))

if x <= 0.5 * (a ** 2) * b:
    tan_theta = a * (b ** 2) / (2 * x) 
else:
    tan_theta = (2 * (a ** 2) * b - 2 * x) / (a ** 3)

theta = math.degrees(math.atan(tan_theta))
print(theta)

Measured memory_bytes: 3060
#include <iostream>
#include<vector>
using namespace std;
int main(){
    int h=0,x=0,o=0;
    cin>>h;
    cin>>x;
    vector<int> n(x);
    for(int i=0;i<x;i++){
        cin>>n[i];
        o=o+n[i];
        
    }
    h=h-o;
    if(h<=0){
        cout<<"Yes";
    }else if(h>0){
        cout<<"No";
    }
    cout<<endl;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class t, class u>
ostream& operator<<(ostream& os, const pair<t,u> &p){
	return os << "{"<<p.a<<", "<<p.b<<"}";
}
template<class t>
ostream& operator<<(ostream& os,const vector<t> &v){
	os << "{";
  for (auto e : v)
    os << e << ", ";
	return os << "}";
}
using uint = unsigned;
const uint mod = 998244353;
struct mint{
	uint v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int m = (int)1e6 + 10;
  vector<mint> inv(m);
  for (int i = 1; i < m; ++i) {
    inv[i] = mint(i).inv();
  }
  vector<mint> w(m);
  for (int i = 1; i < m; ++i) {
    w[i] += inv[i];
    for (int j = i * 2; j < m; j += i) {
      w[j] -= w[i];
    }
  }
  int n;
  cin >> n;
  vector<mint> a(m);
  mint ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[x] += mint(x);
    ans -= mint(x);
  }
  for (int i = 1; i < m; ++i) {
    mint x = 0;
    for (int j = i; j < m; j += i) {
      x += a[j];
    }
    ans += x * x * w[i];
  }
  cout << ans / 2 << endl;
  return 0;
}


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

int main()

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    string s;
    cin >> n >> s;
    long long r = 0, g = 0, b = 0;
    for(int i = 0; i < n; i++)
        if(s[i] == 'R')
            r++;
        else if(s[i] == 'G')
            g++;
        else if(s[i] == 'B')
            b++;
    long long ans = r * g * b;
    for(int i = 1; i <= n; i++)
    {
        for(int j = i + 2; j <= n; j += 2)
        {
            int k = (i + j) / 2;
            if(s[i - 1] + s[j - 1] + s[k - 1] == 'R' + 'G' + 'B')
            {
                ans--;
            }
        }
    }
    cout << ans;
}


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

#define int long long

#define x first
#define y second
#define pb push_back
#define mp make_pair

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

const int M = 1e9 + 7;

int pw(int a, int n) {
    a %= M;
    int b = 1;
    while (n > 0) {
        if (n & 1) {
            b = b * a % M;
            n--;
        } else {
            a = a * a % M;
            n /= 2;
        }
    }
    return b;
}

int fact[200001], inv[200001];

int C(int n, int k) {
    if (k > n) return 0;
    assert(k >= 0);
    return fact[n] * inv[k] % M * inv[n - k] % M;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % M;
    for (int i = 0; i <= n; i++) inv[i] = pw(fact[i], M - 2);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (n - i <= k) {
            ans += C(n, i) * C(n - 1, i - 1) % M;
            if (ans >= M) ans -= M;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
 // 整数の宣言
    int A,B,C;
 // スペース区切りの整数の入力
    scanf("%d %d %d", &A,&B,&C);
    // 出力
    if (A==B)
    printf("%d\n",C);
    else if (A==C)
    printf("%d\n",B);
    else
    printf("%d\n",A);
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    A_idx = dict()
    B_idx = dict()

    for i, x in enumerate(A, 1):
        A_idx[x] = i

    for i, x in enumerate(B, 1):
        B_idx[x] = i

    grid = [[0] * (M + 1) for _ in range(N + 1)]

    def calc():
        ans = 1
        cnt_r = 0
        cnt_c = 0

        for i in range(N * M, 0, -1):
            row = A_idx.get(i)
            col = B_idx.get(i)
            cnt = 0

            if row and col:
                cnt_r += 1
                cnt_c += 1
                if grid[row][col]:
                    return 0
                else:
                    grid[row][col] = i
                    cnt = 1
            elif row:
                cnt_r += 1
                for j in range(M):
                    if B[j] > i and not (grid[row][j]):
                        cnt += 1
            elif col:
                cnt_c += 1
                for j in range(N):
                    if A[j] > i and not (grid[j][col]):
                        cnt += 1
            else:
                cnt = cnt_r * cnt_c - (N * M - i)
            ans *= cnt
            ans %= MOD
        return ans

    ans = calc()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82064
while True:
	a,b = map(int,raw_input().split())
	if a == 0 and b == 0:
		break
	
	list = []
	for i in xrange(a):
		code = raw_input()
		for j in xrange(b):
			if len(list) < b:
				list.append(0)
			list[j] += int(code.split()[j])
		
	dict = {}
	for i in xrange(b):
		dict[i] = list[i]
	
	dic = sorted(dict.items(), key=lambda x:x[1], reverse = True)
	
	for var in dic:
		print var[0] + 1,
	print 

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

#define mp                  make_pair
#define F                   first
#define S                   second
#define pb                  push_back
#define FOR(i,j,n)          for(int i=j;i<n;i++)
#define F0R(i,j,n)          for(int i=j;i<=n;i++)
#define RFOR(i,j,n)         for(int i=n-1;i>=j;i--)
#define RF0R(i,j,n)         for(int i=n;i>=j;i--)
#define FOREACH(x,v)        for(auto x:v)
#define ITFOR(it,v)         for(__typeof(v.begin()) it =v.begin();it!=v.end();++it)
#define __in_arr__(a,j,n)   FOR(i,j,n)cin >> a[i];
#define __out_arr__(a,j,n)  FOR(i,j,n)cout << a[i];
#define LOG                 cout << "[ !" << __LINE__ << "L ] " << endl;
#define PLOG(x)             cout << "[ !" << __LINE__ << "L ] " \<<x<<endl;

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;

const int MAXN = 55;
const int MAXM = 55;
vii g[MAXN];
bool mark[MAXN];
bool mark_true = true;

void dfs(int v,int l,int r) {
    //if(mark[v] == mark_true)return;
    mark[v] = !mark[v];
    for(auto u : g[v])
        if((u.S<l || u.S>r) && mark[u.F]!=mark_true)
            dfs(u.F,l,r);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,m;
    cin >> n >> m;
    F0R(i,1,m) {
        int x,y;
        cin >> x >> y;
        g[x].pb(mp(y,i));
        g[y].pb(mp(x,i));
    }
    int ans = 0;
    F0R(i,1,m) {
        int l = i,c=0;
        F0R(i,1,n)
            if(mark[i] != mark_true)
                dfs(i,l,l),c++;
        if(c == 1) ans++;
        mark_true = !mark_true;
    }
    cout << m-ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Text.Printf
import Control.Monad
import Data.Char
import Data.List
import Debug.Trace

isXXX :: [Int]->(Int,Int,Int)->Bool
isXXX dat (a,b,c) = (dat!!a)==(dat!!b) && (dat!!a)==(dat!!c)

isXYZ :: [Int]->(Int,Int,Int)->Bool
isXYZ dat (a,b,c) = ((dat!!a)+1)==(dat!!b) && ((dat!!a)+2)==(dat!!c)

--has XXX or XYZ pattern
check'' :: [Int]->Bool
check'' []  = True
check'' dat = 
--    trace ("        check'' "++show dat) $
    or $ map hasXXXorXYZ $ comb
    where 
        hasXXXorXYZ (a,b,c)
            | (isXXX dat (a,b,c))||(isXYZ dat (a,b,c))  = check'' (dat' a b c)
            | otherwise                     = False
        comb = filter (\(a,b,c)->(a<b)&&(b<c)) [(a,b,c)|a<-nums,b<-nums,c<-nums]
        nums = [0..((length dat)-1)]
        dat' a b c = concat $ map (\i->if i/=a && i/=b && i/=c then [dat!!i] else []) [0..(length dat)-1]

--has XX pattern
check' :: [Int]->Bool
check' dat = 
--    trace ("    check' "++show dat) $
    or $ map hasXX [0..((length dat)-1-1)] 
    where
        hasXX n
            | dat!!n==dat!!(n+1)  = check'' ((take n dat)++(drop (n+2) dat))
            | otherwise           = False
            
--not more than 4
check :: [Int]->Int->Bool
check dat i =
--    trace ("check "++show dat++" "++show i) $
    if maxnums>4 then False else check' dat'
    where 
        dat' = sort (dat++[i])
        nums = map (\i->length i) $ map (\i->filter (==i) dat') [1..9]
        maxnums = last $ sort $ nums

solve :: [Int]->IO ()
solve dat = do
    let output = map (check dat) [1..9]
    let output' = concat $ map (\i->if output!!(i-1) then [i] else []) [1..9]
    let output'' = if null output' then [0] else output'
    let str = foldr (++) "" $ (map (\x->(show x)++" ") (init output'')) ++ [show $ last output'']
    putStrLn(str)

main :: IO ()
main = do
    s<-getContents :: IO String 
    mapM_ solve $ map (\x->map (\y->digitToInt(y)) x) $ lines $ s

Measured memory_bytes: 5424
#include <iostream>
#include <set>

using namespace std;

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

    set<int> A;
    bool ans = true;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        auto r = A.insert(a);
        if (r.second == false) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 9600
n=int(input())
dp=[0]*(10**5)
for x in range(1,10**2):
  for y in range(1,10**2):
    for z in range(1,10**2):
      dp[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(n):
  print(dp[i+1])
  

Measured memory_bytes: 74892
import sys
from collections import deque
from itertools import islice
from operator import itemgetter


def resolve(in_):
    N, D, A = map(int, next(in_).split())
    def f(line):
        x, h = map(int, line.split())
        return x, (h + A - 1) // A
    XH = list(map(f, islice(in_, N)))
    XH.sort(key=itemgetter(0))
    assert N == len(XH)

    bomb_attack = deque()
    bomb = 0
    ans = 0
    for x, h in XH:
        while bomb_attack and bomb_attack[0][0] < x:
            e = bomb_attack.popleft()
            bomb -= e[1]

        h_real = h - bomb
        if h_real <= 0:
            continue
        ans += h_real
        bomb_attack.append((x + D * 2, h_real))
        bomb += h_real

    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51156
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define mem(a,b) memset(a,b,sizeof(a))
#define loop(i,n) for(int i=0;i<(n);i++)
#define fors(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fastm_fast ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL)
using namespace std;
const int  mod = 1e9 + 7;
#define pb push_back
#define mp make_pair
#define S second
#define F first
const int MAX = 1e5;

  
void sujho()
{
  int n;
  cin >> n;
  string acl = "ACL";
  loop(i,n)
  {
     cout << acl ;
  }
  
}
int32_t main()
 {
 fastm_fast;
  {
    sujho();
 }
 return 0;
 }

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	sc.close();
    	String ans = Integer.toString(n, k);
    	System.out.println(ans.length());
    }
}

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

int dp[4][4001] = {0};

int main()
{
	for (int i = 0; i <= 1000; i++){
		dp[0][i] = 1;
	}
	
	for (int i = 0; i < 3; i++){
		for (int j = 0; j <= 1000 * (i + 1); j++){
			for (int k = 0; k <= 1000; k++){
				dp[i + 1][j + k] += dp[i][j];
			}
		}
	}
	
	int n;
	while (scanf("%d", &n) != EOF){
		printf("%d\n", dp[3][n]);
	}
	
	return 0;
}

Measured memory_bytes: 1076
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	m := make([]int, n)
	for i := range m {
		fmt.Scan(&m[i])
	}

	sum := 0
	for _, v := range m {
		sum += v
	}
	rem := x - sum
	sort.Ints(m)
	canMake := rem / m[0]

	fmt.Println(n + canMake)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    string S;
    cin >> N >> S;
    string ans;
    int rank = 0;
    for(auto c:S){
        if(c == ')')rank++;
        else rank--;
        if(rank > 0){
            ans = "(" + ans;
            rank--;
        }
        ans.push_back(c);
    }
    if(rank < 0)ans += string(-rank, ')');
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;*/
vector<string>v;
vector<int>ansl;
string s;
int ary[100005] = {0};
int mp[200][200];
int cnt = 0;
int d_x[] = {1, 1, 0, -1, -1, 0};
int d_y[] = {1, 0, -1, -1, 0, 1};
int t;
/*
void dfs(int x,int y,int lpcnt){
  mp[x][y] = 1;
  cout <<"Debug ";
  cout <<x-30<<' '<<y-30<<endl;
  cnt++;
  lpcnt++;
  int watasi = lpcnt;
  int used[6] = {0};
  for(int dx = 0;dx<6;dx++){
    int nx = x+d_x[dx],ny = y+d_y[dx];
    int dft = sqrt((nx-30)*(nx-30)+(ny-30)*(ny-30));
    if((dft<=30)&&(watasi < t)&&(mp[nx][ny] == 0)){
        dfs(nx,ny,watasi);
        used[dx] = 1;
    }
    for(int i = 0;i<6;i++){
      if(used[i]){
        if((nx == x + d_x[i])&&(ny == y + d_y[i])){
          dfs(nx,ny,watasi);
        }
      }
    }
    }
}
*/
int main(){
  int n,t;

  cin >>t>>n;
  while(!((t == 0)&&(n == 0))){
    int fx,fy;
    cnt = 0;
    for(int i = 0;i<200;i++){
      for(int j = 0;j<200;j++){
        mp[i][j]=-1;
      }
    }
    for(int i = 0;i<n;i++){
      int x,y;
      cin >>x>>y;
      mp[x+100][y+100] = 1;
    }
    cin >>fx>>fy;

    cnt = 0;

    queue< pair<int, int> > qu;
    qu.push(make_pair(fx+100,fy+100));
    mp[fx+100][fy+100] = 0;
    while (!qu.empty()) {
      pair<int ,int> pr = qu.front();
      qu.pop();
      int nx = pr.first,ny= pr.second;
      cnt++;
      if(mp[nx][ny] == t)continue;
      for(int i = 0;i<6;i++){
        int cx = nx+d_x[i],cy = ny+d_y[i];
        if(mp[cx][cy] != -1)continue;
        mp[cx][cy] = mp[nx][ny] + 1;
        qu.push(make_pair(cx,cy));
      }
    }

    cout <<cnt<<endl;
    cin >>t>>n;
  }
  return 0;
}



Measured memory_bytes: 3272
import sys
input = sys.stdin.readline

def main():
    n, m, l = map(int, input().split())
    f_inf = float('inf')
    dist = [[f_inf]*n for _ in range(n)]
    
    def Warshall_Floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k]+d[k][j])
        return d
      
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c

    Warshall_Floyd(dist)

    dist2 = [[f_inf]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if dist[i][j] <= l:
                dist2[i][j] = 1
    
    Warshall_Floyd(dist2)

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        if dist2[s][t] == f_inf:
            print(-1)
        else:
          ans = dist2[s][t]
          print(ans-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 125020
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        vector<int>V(n);
        int sum=0;
        for(int i=0;i<n;i++)cin>>V[i];
        sort(V.begin(),V.end());
        for(int i=0;i<n-1;i++)V[i+1]+=V[i];
        for(int i=0;i<n;i++)sum+=V[i];
        cout<<sum<<endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w,a,b;

ll fact[252521];
void init(){
  fact[0] = 1;
  FOR(i,1,252521)fact[i] = i*fact[i-1]%MOD;
}
ll inv(ll x){
  ll t = MOD-2;
  ll r = 1;
  while(t){
    if(t&1)r=r*x%MOD;
    x=x*x%MOD;
    t>>=1;
  }
  return r;
}
ll comb(ll n,ll k){
  return fact[n]*inv(fact[n-k])%MOD*inv(fact[k])%MOD;
}
ll route(ll a,ll b){
  return comb(a+b,b);
}

int main(){
  init();
  scanf("%d%d%d%d",&h,&w,&a,&b);
  ll ans = route(h-1,w-1);
  REP(i,b-1){
    ll sub = route(h-a,i) * route(a-2,w-i-1) % MOD;
    ans = FIX(ans-sub);
  }
  ll sub = route(h-a,b-1) * route(a-1,w-b) % MOD;
  ans = FIX(ans-sub);
  printf("%lld\n",ans);
  return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int ans=0,x;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x >= k)ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
def solve():
    cost = 1001
    N, time = map(int, input().split())
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= time and c <= cost:
            cost = c
    print('TLE' if cost is 1001 else cost)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
S = input()
if S[0] != 'A' or S[2:-1].count('C') != 1:
    print("WA")
    exit()
else:
    S = S.replace('A', 'a', 1)
    S = S.replace("C", 'c', 1)
    if not S.islower():
        print("WA")
        exit()
    else:
        print("AC")


Measured memory_bytes: 2940