akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second
const int MAXN = 100100;
const int MAXC = 1000100;
vector<pii> adj[MAXN];
int vis[MAXN];
vector<pii> edges[MAXC];
map<pii, int> cmap;
vi nw;
void dfs(int u, int c, int dist){
    vector<pii> &e = edges[c];
    int L = int(lower_bound(e.begin(), e.end(), pii(u, -1)) - e.begin());
    int R = int(upper_bound(e.begin(), e.end(), pii(u, INT_MAX)) - e.begin());
    for (int i = L; i < R; i++){
        int v = e[i].Y;
        if (vis[v] == -1){
            vis[v] = dist;
            nw.push_back(v);
            cmap[{v, c}] = 1;
            dfs(v, c, dist);
        } else if (vis[v] == dist && !cmap.count({v, c})){
            cmap[{v, c}] = 1;
            dfs(v, c, dist);
        }
    }
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++){
        int u, v, c; cin >> u >> v >> c;
        u--; v--;
        adj[u].emplace_back(v, c);
        adj[v].emplace_back(u, c);
        edges[c].emplace_back(u, v);
        edges[c].emplace_back(v, u);
    }
    for (int i = 0; i < MAXC; i++) sort(edges[i].begin(), edges[i].end());
    memset(vis, -1, sizeof vis);
    vis[0] = 0;
    nw.push_back(0);
    vector<pii> cur;
    vi expl(n, 0);
    for (int layer = 1; ; layer++){
        cur.clear();
        for (int x : nw) {
            if (expl[x]) continue;
            expl[x] = 1;
            for (pii v : adj[x]){
                if (vis[v.X] != -1 && vis[v.X] < layer) continue;
                if (cmap.count(v)) continue;
                if (v.X == n-1) {
                    cout << layer << endl;
                    return 0;
                }
                cmap[v] = 1;
                vis[v.X] = layer;
                cur.emplace_back(v);
            }
        }
        nw.clear();
        // same lines
        for (pii p : cur){
            nw.push_back(p.X);
            dfs(p.X, p.Y, layer);
        }
        // different line
        for (int x : nw) {
            if (x == n-1) {
                cout << layer << endl;
                return 0;
            }
        }
        if ((int)nw.size() == 0 && (int)cur.size() == 0) break;
    }
    cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 48896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    int ans=n*n*n;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> l(n);
	int mx, sum=0;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		mx = max(mx, l[i]);
		sum += l[i];
	}
	puts(mx < (sum - mx) ? "Yes" : "No");

	return 0;
}

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

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif

    string str;
    long long k;
    cin >> str >> k;
    if(str[0] == '1') {
        int count = 1;
        int i = 1;
        while(str[i] == '1') {
            i++;
            count++;
        }
        if(k <= count) {
            cout << 1 << endl;
        }
        else {
            cout << str[i] << endl;
        }
    }
    else {
        cout << str[0] << endl;
    }

    return 0;
}


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

int main(void) {
  int a, b, c;
  set<int> s;
  cin >> a >> b >> c;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,a,b;
    cin>>n>>a>>b;
    VL arr(n);
    fr(i,0,n)
        cin>>arr[i];
    sort(ALL(arr));
    ll ans=0;
    if(a>=b)
    {
        cout<<(n-1)*b<<endl;
    }
    else
    {
        fr(i,1,n)
        {
            ll diff=(arr[i]-arr[i-1])*a;
            if(diff<b)
            {
                ans+=diff;
            }
            else
            {
                ans+=b;
            }
        }
        cout<<ans<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3980
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int ans[200003]={0};
int already[200003]={0};
int main(){
    int N,X;
    cin>>N>>X;
    if(X==1||X==2*N-1){
        puts("No");
    }
    /*
    else if(N==3){
        if(X==1||X==5)puts("No");
        else if(X==3)puts("1\n2\n3\n4\n5");
        else if(X==2)puts("5\n3\n2\n1\n4");
        else puts("1\n3\n4\n5\n2");
    }
    */
    else{
        puts("Yes");

        if(N==2){
            puts("1\n2\n3");
        }
        else if(N==3){
            if(X==3)puts("1\n2\n3\n4\n5");
            else if(X==2)puts("5\n3\n2\n1\n4");
            else puts("1\n3\n4\n5\n2");
        }
        else{
            if(X==2||X==2*N-2){
                ans[N]=X;
                ans[N-1]=1;
                ans[N+1]=N*2-1;
                already[X]=1;
                already[1]=1;
                already[N*2-1]=1;
            }
            else{
                ans[N]=X;
                ans[N+1]=1;
                ans[N+2]=N*2-1;
                ans[N-1]=N*2-2;
                ans[N-2]=2;
                already[X]=1;
                already[1]=1;
                already[N*2-1]=1;
                already[2]=1;
                already[N*2-2]=1;
            }
            int checknow=1;
            for(int i=1;i<=2*N-1;i++){
                if(ans[i])continue;
                while(checknow++){
                    if(!already[checknow]){
                        ans[i]=checknow;
                        break;
                    }
                }
            }
            for(int i=1;i<=2*N-1;i++){
                cout<<ans[i]<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>

int hikaku(int*,int,int);

int main(){

  int i,n1,n2,k,m=0;
  int A[10001],B;
  
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&B);
    if(hikaku(A,B,n1) != 0) m++;
  }
  printf("%d\n",m);
  return 0;
}

int hikaku(int A[],int key,int n1){
  int i = 0;
  A[n1] = key;
  while(A[i] != key) i++;
  if(i == n1) return 0;
  return 1;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define MOD 1000000007
int h,w;
int m[1000][1000];
int dx[2]={1,0};
int dy[2]={0,1};

int dp[1000][1000];

int solve(int i,int j){
	int &ret=dp[i][j];
	if(ret!=-1) return ret;
	if(i==h-1 && j==w-1) return 1;
	ret=0;
	for(int k=0;k<2;k++){
		int ni=i+dx[k];
		int nj=j+dy[k];
		if(ni<h && nj<w && m[ni][nj]=='.'){
			ret=(ret+solve(ni,nj))%MOD;
		}
	}
	return ret;
}

int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		for(int j=0;j<w;j++){
			m[i][j]=s[j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,0);
	return 0;
}

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

using namespace std;

int main(void){
  char c;
  int w, n, a, b;
  vector<int> v;
  vector<pair<int, int> > p;

  cin >> w;
  cin >> n;
  for(int i=1; i<=w; i++){
    v.push_back(i);
  }

  for(int i=0; i<n; i++){
    cin >> a >> c >> b;
    p.push_back(make_pair(a, b));
  }

  for(int i=0; i<n; i++){
    swap(v[p[i].first-1], v[p[i].second-1]);
  }

  for(int i=0; i<w; i++){
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
h, n = map(int, input().split())
dp = [10**10]*(h+1)
dp[0] = 0
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

for start in range(h):
    for a, b in ab:
        end = min(start+a, h)
        dp[end] = min(dp[end], dp[start]+b)
print(dp[h])


Measured memory_bytes: 41324
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

vector<ll>G[100004];
vector<ll>memo(100004,-1);
ll dp(ll i){
	if(memo[i]!=-1)return memo[i];
	ll ret=0;
	ll size=G[i].size();
	for(int j=0;j<size;j++){
		ret=max(dp(G[i][j])+1,ret);
	}
	memo[i]=ret;
	return memo[i];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll H,W;
	cin>>H>>W;
	char map[H][W];
	for(ll i=0;i<H;i++){
		for(ll j=0;j<W;j++){
			cin>>map[i][j];
		}
	}
	
	vector<vector<ll>>dp(H,vector<ll>(W,0));
	for(int i=0;i<H;i++){
		if(map[i][0]=='#')break;
		dp[i][0]=1;
	}
	for(int i=0;i<W;i++){
		if(map[0][i]=='#')break;
		dp[0][i]=1;
	}
	for(int i=1;i<H;i++){
		for(int j=1;j<W;j++){
			if(map[i][j]=='#')continue;
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=MOD;
		}
	}
	cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 12288
N = int(input())
L = list(map(int,input().split()))
L.sort()
def gcd(x,y):
  while y != 0:
    k = x
    x = y
    y = k%y
  return x
G = gcd(L[0],L[1])
for i in range(1,N-1):
  if G >= gcd(L[i],L[i+1]):
    G = gcd(L[i],L[i+1])
print(G)

Measured memory_bytes: 14224
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static String IDENTICAL = "IDENTICAL";
    public static String CLOSE = "CLOSE";
    public static String DIFFERENT = "DIFFERENT";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int i = 0;
        String c1 = "";
        String c2 = "";
        while (true) {
            String line = sc.nextLine();
            if (line.equals(".")) {
                return;
            }

            if (i % 2 == 0) {
                c1 = line;
            } else {
                c2 = line;
                System.out.println(process(c1, c2));
            }
            i++;
        }

    }


    public static String process(String c1, String c2) {
        if (c1.equals(c2)) {
            return IDENTICAL;
        }
        String regex = "\\\"(.*?)\\\"";

        String removeCommand1 = c1.replaceAll(regex, "");
        String removeCommand2 = c2.replaceAll(regex, "");
        if(!removeCommand1.equals(removeCommand2)) {
            return DIFFERENT;
        } else {
            String [] arrC1 = c1.split(regex);
            String [] arrC2 = c2.split(regex);

            for (int i = 0; i < arrC1.length && i < arrC2.length; i++) {
                if(!arrC1[i].equals(arrC2[i])){
                    return DIFFERENT;
                }
            }
        }

        Pattern p = Pattern.compile(regex);
        Matcher m1 = p.matcher(c1);
        Matcher m2 = p.matcher(c2);
        ArrayList<String> arrCommand1 = new ArrayList<>();
        while(m1.find()) {
            arrCommand1.add(m1.group(1));
        }

        ArrayList<String> arrCommand2 = new ArrayList<>();
        while(m2.find()) {
            arrCommand2.add(m2.group(1));
        }

        int countCommandDiff = 0;
        if(arrCommand2.size() != arrCommand1.size()){
            return DIFFERENT;
        }
        for (int i = 0; i < arrCommand1.size() && i < arrCommand2.size(); i++) {
            if(!arrCommand1.get(i).equals(arrCommand2.get(i))) {
                countCommandDiff ++;
            }
        }

        if(countCommandDiff < 2) {
            return CLOSE;
        }

        return DIFFERENT;
    }
}


Measured memory_bytes: 32300
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll a,b;
  cin>>a>>b;
  //q=stoi(b);p=stoi(a);10000
  rep(i,b-a+1){
    p=a+i;
    if((p/10000==p%10)&&(p/1000-(10*(p/10000))==(p%100-p%10)/10))
    q++;
    
  }
  print(q)
  
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

const ll MAX = 1e18;

int main(void){
    std::ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    ll ans = 1;
    bool ng = false;
    FOR(i, n){
    	ll tmp;
    	cin >> tmp;

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

    	if(ng || MAX/ans < tmp || ans*tmp > MAX){
    		ng = true;
    	}

    	ans *= tmp;    	
    }

    if(ng) 
    	cout << -1 << endl;
	else
    	cout << ans;

    return 0;
}

Measured memory_bytes: 3628
S = [int(n) for n in list(input())]
K = int(input())
c = 0
for i in range(len(S)):
	s = S[i]
	if s == 1:
		c += 1
	else:
		k = 0
		while c < K:
			c += k ** s
			k += 1
	if c >= K:
		print(s)
		break

Measured memory_bytes: 3060
/**
 *      AGC 18 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-15 16:41:55
**/

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

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

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

    int N, K; cin >> N >> K;
    int A[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A, A + N);
    if (A[N - 1] < K){
        cout << "IMPOSSIBLE" << endl; return 0;
    }

    for (int i = 0; i < N; ++i) {
        if (A[i] == K){
            cout << "POSSIBLE" << endl; return 0;
        }
    }
    
    int answer = A[0];
    for (int i = 1; i < N; ++i) {
        answer = gcd(answer, A[i]);
    }
    K % answer == 0 ? cout << "POSSIBLE" << endl : cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> ans;
    for(int i = 0; i < k && a+i <= b; i++) {
        ans.insert(a+i);
        ans.insert(b-i);
    }
    for(int i : ans) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
inputAB = input().split()
a = int(inputAB[0])
b = int(inputAB[1])

coin = 0

if a == b:
    coin = a * 2
elif abs(a - b) == 1:
    coin = a + b
elif a - b >= 2:
    coin = a + (a - 1)
elif a - b <= -2:
    coin = b + (b - 1)

print(coin)


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    cout << "x" << (i == n - 1 ? "\n" : "");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Friendships | diff Friendships.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Friendships.cpp && ./a.out

/*
 
 6/22/2019
 
 5:50-
 
 */

const int MAX_N=101+1;
int N,K;

int mx[MAX_N][MAX_N],mx2[MAX_N][MAX_N];
void check() {
  const int Inf=1e5;
  REP(i,N)REP(j,N) {
    mx2[i][j]=mx[i][j]?1:Inf;
  }
  REP(k,N)REP(i,N)REP(j,N) {
    SMIN(mx2[i][j],mx2[i][k]+mx2[k][j]);
  }
  int res=0;
  REP(j,N)REP(i,j) if(mx2[i][j]==2) ++res;
  assert(res==K);
}
void solve() {
  if(K>(N-1)*(N-2)/2) {
    println("-1");
    return;
  }
  REP(i,N)REP(j,N)if(i!=j) mx[i][j]=1;
  int k=K,u=1,v=u+1;
  while(k--) {
    mx[u][v]=mx[v][u]=0;
    if(++v>=N) ++u,v=u+1;
  }
  check();
  vector<II> res;
  REP(j,N)REP(i,j)if(mx[i][j]==1) res.emplace_back(i,j);
  println("%d", SZ(res));
  REP(i,SZ(res)) println("%d %d", res[i].first+1,res[i].second+1);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K;
  solve();
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define ll long long

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

  for(int i=1; i<n; ++i) {
    ans*=k-1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3564
N = int(input())
AC, WA, TLE, RE = 0, 0, 0, 0
for _ in range(N):
    S = input()
    if S == 'AC':
        AC += 1
    elif S == 'WA':
        WA += 1
    elif S == 'TLE':
        TLE += 1
    elif S == 'RE':
        RE += 1
print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')

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

int main() {
  int N, A, B, C, D;
  cin >> N;
  A = N / 1000;
  B = N / 100 % 10;
  C = N / 10 % 10;
  D = N % 10;
  
  int delt = (A+B+C+D-7)/2;
  vector<char> f(3,'+');
  vector<int> fugo(3);
  vector<int> vdelt = {0, D, C, D+C, B, D+B, C+B, D+C+B};
  
  for (int i = 0; i < 8; i++) {
    if (delt == vdelt[i]) {
      fugo[0] = i/4;
      fugo[1] = i/2%2;
      fugo[2] = i%2;
      break;
    }
  }
  
  for (int i = 0; i < 3; i++) {
    if(fugo[i]) f[i] = '-';
  }
  
  cout << A << f[0] << B << f[1] << C << f[2] << D << "=7" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String n = sc.next();

    String ans;
    
    if(n.charAt(0)=='7'||n.charAt(1)=='7'||n.charAt(2)=='7') ans = "Yes";
    else ans = "No";
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35564
#include <iostream>

int main() {
	int n;
	int a = 0, b = 0;
	scanf("%d", &n);
	int res = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &a, &b);
		res = res + b - a + 1;
	}
	printf("%d", res);
 	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MAX_N=1<<17;
int m, mx[2*MAX_N];
void init(int m_){
	m=1;
	while(m<m_) m<<=1;
	for(int i=1; i<=2*m-1; i++) mx[i]=0;
}

void update(int k, int a){
	k+=m;
	mx[k]=a;
	while(k>1){
		k>>=1;
		mx[k]=max(mx[2*k], mx[2*k+1]);
	}
}

int query(int a, int b){
	a+=m, b+=m;
	int ans=0;
	for(;a<b; a>>=1, b>>=1){
		if(b&1){
			b--;
			ans=max(ans, mx[b]);
		}
		if(a&1){
			ans=max(ans, mx[a]);
			a++;
		}
	}
	return ans;
}
int main()
{
    int n; cin>>n;
    int a[100010];
    vector<int> as(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
        as[i]=a[i];
    }
    sort(as.begin(), as.end());
    as.erase(unique(as.begin(), as.end()), as.end());
    for(int i=0; i<n; i++){
        a[i]=lower_bound(as.begin(), as.end(), a[i])-as.begin();
    }
    int c=as.size();
    init(c);
    int ans=0;
    for(int i=0; i<n; i++){
        int x=query(a[i], c);
        ans=max(ans, x+1);
        update(a[i], x+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2048
module Main where
import System.IO
import Data.Function
import Control.Monad
import Control.Applicative
main :: IO ()
main = do
     fix $ \loop -> do
       e <- isEOF
       unless e $ do
         a:b:_ <- readInts <$> getLine
         print $ length $ show $ a + b
         loop
     return ()
readInts :: String -> [Int]
readInts = map read . words

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

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

  vector<int> black(n + 1), white(n + 1);
  rep(i, n) {
    black[i + 1] = black[i] + (s[i] == '#');
    white[i + 1] = white[i] + (s[i] == '.');
  }

  int ans = INF;
  rep(i, n + 1) ans = min(ans, black[i] + white[n] - white[i]);
  cout << ans << endl;
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll B, W;
ll black[200050];
ll white[200500];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> B >> W;
    for(ll i = 0; i < W; i++) {
        black[i] = 0;
    }
    for(ll i = W; i <= B + W; i++) {
        black[i] = (black[i - 1] + combination(i - 1, W - 1) * beki(inv[2], i)) % mod;
        //cerr << i << " " << black[i] << endl;
    }
    for(ll i = 0; i < B; i++) white[i] = 0;
    for(ll i = B; i <= B + W; i++) {
        white[i] = (white[i - 1] + combination(i - 1, B - 1) * beki(inv[2], i)) % mod;
        //cerr << i << " " << white[i] << endl;
    }
    for(ll i = 1; i <= B + W; i++) {
        cout << (black[i - 1] + ((mod * 2 + 1 - black[i - 1] - white[i - 1]) % mod) * inv[2]) % mod << "\n";
    }
    return 0;
}


Measured memory_bytes: 28800
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

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

int flag[MAX_N][MAX_N],n;

void dfs(int u,int v)
{
	flag[u][v] = 1;
	rep(i,4){
		int nx = u + dx[i];
		int ny = v + dy[i];
		if(nx >= 0 && nx < 300 && ny >= 0 && ny < 300){
			if(flag[nx][ny] == 0){
				dfs(nx,ny);
			}
		}
	}
	return;
}

int main()
{
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		vector<double> x,y;
		vector<int> bx,by;
		rep(i,300){
			rep(j,300){
				flag[i][j] = 0;
			}
		}
		rep(i,n){
			int s,t,u,v;
			scanf("%d%d%d%d",&s,&t,&u,&v);
			x.push_back(s),x.push_back(s-0.5),x.push_back(s+0.5);
			x.push_back(u),x.push_back(u-0.5),x.push_back(u+0.5);
			bx.push_back(s),bx.push_back(u);
			y.push_back(t),y.push_back(t-0.5),y.push_back(t+0.5);
			y.push_back(v),y.push_back(v-0.5),y.push_back(v+0.5);
			by.push_back(t),by.push_back(v);
		}
		sort(x.begin(),x.end());
		sort(y.begin(),y.end());
		x.erase(unique(x.begin(),x.end()),x.end());
		y.erase(unique(y.begin(),y.end()),y.end());
		for(int i=0;i<n*2;i+=2){
			bx[i] = lower_bound(x.begin(),x.end(),(double)bx[i]) - x.begin();
			bx[i+1] = lower_bound(x.begin(),x.end(),(double)bx[i+1]) - x.begin();
			by[i] = lower_bound(y.begin(),y.end(),(double)by[i]) - y.begin();
			by[i+1] = lower_bound(y.begin(),y.end(),(double)by[i+1]) - y.begin();
			for(int j=bx[i];j<=bx[i+1];j++){
				flag[j][by[i]] = 1;
				flag[j][by[i+1]] = 1;
			}
			for(int j=by[i+1];j<=by[i];j++){
				flag[bx[i]][j] = 1;
				flag[bx[i+1]][j] = 1;
			}
		}
		int cnt = 0;
		rep(i,300){
			rep(j,300){
				if(flag[i][j] == 0){
					cnt++;
					dfs(i,j);
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 7724
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define INF 1000000007
using namespace std ;

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

	int n,l ;
	cin>>n>>l ;

	vector<string> s ;

	for(int i = 0 ; i < n ; i++) 
	{
		string temp ;
		cin>>temp ;
		s.push_back(temp) ;
	}

	sort(s.begin(),s.end()) ;
	string ans =  "" ;

	for(auto i : s) ans+=i ;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll d,t,s;
  cin>>d>>t>>s;
  if(s*t>=d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N,K;

int main() {

	scanf("%d%d", &N, &K);



	printf("%d\n", N-K+1);

	return 0;
}


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

div = [0]*101

for i in range(2,n+1):
    j=2
    t=i
    while i > 1 and j<=t:
        if i%j==0:
            div[j]+=1
            i//=j
        if i%j!=0:
            j+=1

n2=0
n4=0
n14=0
n24=0
n74=0

for i in range(n):
    if div[i]>=2:
        n2+=1
    if div[i]>=4:
        n4+=1
    if div[i]>=14:
        n14+=1
    if div[i]>=24:
        n24+=1
    if div[i]>=74:
        n74+=1

print(n24*(n2-1)+n14*(n4-1)+n4*(n4-1)//2*(n2-2)+n74)


Measured memory_bytes: 9136
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let x: usize = iterator.next().unwrap().parse().unwrap();
    let a_original: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut a = a_original.clone();
    if a[0] > x {
        a[0] = x;
    }
    for i in 1..n {
        if a[i] + a[i - 1] > x {
            let dec = a[i] + a[i - 1] - x;
            if a[i] >= dec {
                a[i] -= dec;
            } else {
                a[i] = 0;
                a[i - 1] = x;
            }
        }
    }

    let mut ans: usize = 0;
    for i in 0..n {
        ans += a_original[i] - a[i];
    }
    ans.to_string()
}


Measured memory_bytes: 4796
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

class WeightedGraph
{
private:
    const int INF = 1e9;
    int m_nodeNum;
    vector<vector<int>> m_adList;
    vector<vector<int>> m_weights;
    vector<vector<int>> m_dists;

    void DFS(const int v)
    {
        deque<int> Q{ v };
        vector<int> dists(m_nodeNum, INF);
        dists[v] = 0;
        while (!Q.empty())
        {
            const int u = Q.front(); Q.pop_front();
            for (const int n : m_adList[u])
            {
                if (dists[n] > dists[u] + m_weights[u][n])
                {
                    dists[n] = dists[u] + m_weights[u][n];
                    Q.push_back(n);
                }
            }
        }
        m_dists[v] = dists;
    }

public:

    WeightedGraph(int nodeNum) : m_nodeNum(nodeNum)
    {
        m_adList.assign(nodeNum, vector<int>());
        m_weights.assign(nodeNum, vector<int>(nodeNum));
        m_dists.assign(nodeNum, vector<int>(nodeNum, INF));
    }

    void AddEdge(const int v1, const int v2, const int weight)
    {
        m_adList[v1].push_back(v2);
        m_adList[v2].push_back(v1);
        m_weights[v1][v2] = m_weights[v2][v1] = weight;
    }

    void ComputeDistance()
    {
        for (int v = 0; v < m_nodeNum; ++v)
        {
            DFS(v);
        }
    }

    const int GetDistance(const int v1, const int v2)
    {
        return m_dists[v1][v2];
    }
};

int main()
{
    int N, M, R; cin >> N >> M >> R;    // N <= 200, R <= 8
    vector<int> rs(R);
    for (auto &ri : rs)
    {
        cin >> ri;
        --ri;
    }
    WeightedGraph graph(N);
    // 全ての街間の最短移動距離を計算し，全ての経路順(高々R! <= 8! = 40,320)を試す
    for (int i = 0; i < M; ++i)
    {
        int ai, bi, ci; cin >> ai >> bi >> ci; --ai; --bi;
        graph.AddEdge(ai, bi, ci);
    }
    // 前処理：全ての頂点間の距離を計算:O(N^2?)
    graph.ComputeDistance();
    // 全ての経路順を試す:O(R!*R)
    LLONG minDist = 1e9;
    sort(rs.begin(), rs.end());
    do
    {
        LLONG dist = 0;
        for (int i = 0; i < R - 1; ++i)
        {
            dist += graph.GetDistance(rs[i], rs[i + 1]);
        }
        minDist = min(minDist, dist);
    } while (next_permutation(rs.begin(), rs.end()));
    cout << minDist << endl;
}


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

int n,p,t;
deque<int> q;

int main()
{
	scanf("%d",&n);
	p = 1;
	if(n&1)	p ^= 1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&t);
		if(p&1)	q.push_back(t);
		else q.push_front(t);
		p ^= 1;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d ",q.front());
		q.pop_front();
	}
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int,int> PA;
#define INF (1<<30)
int main(){
  int n,k,a,b;
  int t_cost[5001],t_sum[5001];
  vector<int> t_to[5001];
  cin >> n >> k;
  for(int i=1;i<=n;i++)
    cin >> t_cost[i] >> t_sum[i];
  for(int i=0;i<k;i++){
    cin >> a >> b;
    t_to[a].push_back(b);
    t_to[b].push_back(a);
  }
  // que:firstは現在地、secondは通った道の数
  queue<PA> que;
  // vec:firstは移動できるところ、secondは運賃
  vector<PA> vec[5001];
  PA p;
  int memo[5001];
  for(int i=1;i<=n;i++){
    fill(memo,memo+5001,0);
    memo[i]++;
    que.push(PA(i,0));
    while(!que.empty()){
      p = que.front();
      que.pop();
      if(p.second == t_sum[i]) continue;
      for(int j=0;j<t_to[p.first].size();j++){
	if(memo[t_to[p.first][j]] != 0) continue;
	memo[t_to[p.first][j]]++;
	vec[i].push_back(PA(t_to[p.first][j],t_cost[i]));
	que.push(PA(t_to[p.first][j],p.second+1));
      }
    }
  }
  // vec:firstは移動できるところ、secondは運賃
  priority_queue<PA,vector<PA>,greater<PA> > pq;
  int min_cost[5001];
  fill(min_cost,min_cost+5001,INF);
  min_cost[1] = 0;
  pq.push(PA(1,0));
  while(!pq.empty()){
    p = pq.top();
    pq.pop();
    for(int i=0;i<vec[p.first].size();i++){
      int next_cost = p.second + vec[p.first][i].second;
      int next_to = vec[p.first][i].first;
      if(min_cost[next_to] > next_cost){
	min_cost[next_to] = next_cost;
	pq.push(PA(next_to,next_cost));
      }
    }
  }
  cout << min_cost[n] << endl;
  return (0);
}

Measured memory_bytes: 127528
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
long long n,x,y;
long long b;
unordered_map <long long,int> a;

int main()
{
    cin >> n;
    long long i;
    long long ma = 0;
    for(i = 0;i < n;i++){
        scanf("%lld",&b);
        a[b]++;
        if(a[b] > 1){
            if(b > x){
                y = x;
                x = b;
            }
            if(b > y && b != x){
                y = b;
            }
        }
    }
    if(a[x] >= 4){
        ma = x*x;
    }
    else ma = x*y;
    printf("%lld",ma);
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
struct d_heap {
  int d;
  vector<T> heap;

  d_heap(int d): d(d) {}
  void push(const T& t) {
    heap.push_back(t);

    int i = heap.size() - 1;
    while(i > 0){
      if(heap[(i - 1) / 2] > heap[i]) swap(heap[(i - 1) / 2], heap[i]);
      i = (i - 1) / 2;
    }
  }

  T pop() {
    T ans = heap[0];
    swap(heap.back(), heap.front());
    heap.pop_back();
    for(int i = 1;i < heap.size() && i <= d;i++) {
      if(heap[0] > heap[i]) swap(heap[0], heap[i]);
    }
    return ans;
  }

  bool empty() const {
    return heap.empty();
  }

  T top() {
    return heap[0];
  }
};
#include <vector>
#include <queue>
#include <set>
using namespace std;
 
struct edge{
  int to;
  int cost;
};
int INF = 1 << 30;
using Pii = pair<int,int>;
 
vector<int> Dijkstra(const vector<vector<edge>>& G,int s){
  vector<int> dist(G.size(),INF);
  dist[s] = 0;
  d_heap<Pii> que(10);
  que.push({dist[s],s});
  while(!que.empty()){
    auto d = que.top().first;
    auto v = que.top().second;
    que.pop();
    if(dist[v] < d) continue;
    for(auto & e : G[v]){
      if(dist[e.to] > d + e.cost){
        dist[e.to] = d + e.cost;
        que.push({dist[e.to],e.to});
      }
    }
  }
  return dist;
}
 
#include <iostream>
 
int main(){
  int v,e,r;
  cin >> v >> e >> r;
  vector<vector<edge>> G(v);
  for(int i = 0;i < e;i++){
    int s,t,d;
    cin >> s >> t >> d;
    G[s].push_back({t,d});
  }
  auto res = Dijkstra(G,r);
  for(auto i : res){
    if(i == INF) cout << "INF";
    else cout << i;
    cout << endl;
  }
}




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

int main() {
  ll n;
  cin >> n;
  ll a[n];
  map<ll, ll> count;
  ll prefix[n + 1];
  memset(prefix, 0, sizeof(prefix));
  count[prefix[0]] = 1;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    prefix[i + 1] = prefix[i] + a[i];
    count[prefix[i + 1]] += 1;
  }
  map<ll, ll>::iterator it;
  ll ans = 0;
  ll second = 0;
  for (it = count.begin(); it != count.end(); it++) {
    second = it->second;
    ans += (second * (second-1))/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>

using namespace std;

int main(int argc, char* argv[])
{
    int input,count;
    vector<int> inputs;

    input = 1;

    while(input != 0)
    {
        cin >> input;
        if(input != 0)
        {
            inputs.push_back(input);
            count++;
        }
    }
    count = 1;
    for(auto value: inputs)
    {
        cout <<"Case "<< count << ": " << value << endl;
        count++;
    }
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";
const int dx[9] = { 1,1,1,0,0,0,-1,-1,-1 }, dy[9] = { 1,0,-1,1,0,-1,1,0,-1 };

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int h, w, n, cnt, sum;
vector<int>v;
map<int, bool>mp;
int ans[10];
signed main() {
	cin >> h >> w >> n;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v.push_back(w * a + b);
	}
	sort(all(v));
	rep(i, v.size()) {
		int y = v[i] / w, x = v[i] % w;
		rep(j, 9) {
			int nx = x + dx[j], ny = y + dy[j];
			if (1 <= nx && nx < w - 1 && 1 <= ny && ny < h - 1) {
				if (!mp[w * ny + nx]) {
					mp[w * ny + nx] = true;
					rep(k, 9) {
						int nnx = nx + dx[k], nny = ny + dy[k];
						if (binary_search(all(v), w * nny + nnx)) {
							cnt++;
						}
					}
					ans[cnt]++;
					cnt = 0; 
				}
			}
		}
	}
	rep(i, 10) {
		sum += ans[i];
	}
	ans[0] += (h - 2) * (w - 2) - sum;
	rep(i, 10) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 57332
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力
 
 
 
int main() {
    
    ll A,B,C,X,Y,ans;
    cin >>A>>B>>C>>X>>Y;
    if(A+B < 2*C){
        ans = A*X+B*Y;
    }else if(A < 2*C && B < 2*C){
        if(X > Y){
            ans = Y*2*C + (X-Y)*A;
        }else{
            ans = X*2*C + (Y-X)*B;
        }
         
    }else if(B < 2*C){
        if(X > Y){
            ans = X*2*C;
        }else{
            ans = X*2*C + (Y-X)*B;
        } 
    }else if(A < 2*C){
        if(X > Y){
            ans = Y*2*C + (X-Y)*A;
        }else{
            ans = Y*2*C;
        } 
    }else{
        if(X > Y){
            ans = X*2*C;
        }else{
            ans = Y*2*C;
        } 
    }
    cout << ans << endl;
    
    
    
    return 0;
    
 
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll r,d,x;
    cin>>r>>d>>x;
    ll i;
    for(i=0;i<10;i++)
    {
        cout<<r*x-d<<endl;
        x=r*x-d;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int a,b;
  char c;cin>>a>>c>>b;
  if(c=='+')
  cout<<a+b<<endl;
  else
  cout<<a-b<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n = int(input())
node_list = []

sys.setrecursionlimit(10 ** 8)
for i in range(n):
    node_list.append(list(map(int, sys.stdin.readline().split())))

parents = [-1 for i in range(n)]
right = [None for i in range(n)]
left = [None for i in range(n)]
depth = [None for i in range(n)]


def get_children(num):
    c = left[num]
    r = []
    while c is not None:
        r.append(c)
        c = right[c]
    return r


def set_depth(num, p):
    depth[num] = p
    if right[num] is not None:
        set_depth(right[num], p)
    if left[num] is not None:
        set_depth(left[num], p + 1)


for i in range(n):
    node = node_list[i]
    v = node[0]
    d = node[1]
    for j in range(d):
        if j == 0:
            left[v] = node[2 + j]
        else:
            right[m] = node[2 + j]
        m = node[2 + j]
        parents[node[2 + j]] = v
root = -1
for i in range(n):
    if parents[i] == -1:
        root = i
set_depth(root, 0)
for i in range(n):
    print("node " + str(i) + ":", end=" ")
    print("parent = " + str(parents[i]) + ",", end=" ")
    print("depth = " + str(depth[i]) + ",", end=" ")

    if parents[i] == -1:
        print("root,", end=" ")
    elif left[i] is None:
        print("leaf,", end=" ")
    else:
        print("internal node,", end=" ")
    print(get_children(i))



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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int64_t x, a, b, temp, ans1, ans2;

	cin >> x;
	queue<int64_t> q;
	for (int64_t i = 1; i * i <= x; i++)
	{
		if (x % i != 0)
			continue;
		q.push(x / i);
		for (int64_t j = i / 2; j < x; j++)
		{
			a = pow(j, 5);
			b = pow(j - i, 5);
			if (a - b >= x)
			{
				ans1 = j;
				ans2 = j - i;
				break;
			}
		}
		if (a - b == x)
			break;
	}
	if (a - b != x)
	{
		while (!q.empty())
		{
			temp = q.front();
			q.pop();
			for (int64_t j = temp / 2; j < x; j++)
			{
				a = pow(j, 5);
				b = pow(j - temp, 5);
				if (a - b >= x)
				{
					ans1 = j;
					ans2 = j - temp;
					break;
				}
			}
			if (a - b == x)
				break;
		}
	}
	cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 4112
N = int(input())
S = input()

ans = 0
for i in range(N):
  j_start = ans + 1
  for j in range(j_start, N-i):
    base = S[i:i+j]
    if base in S[i+j:]:
      ans = max(ans, j)
    else:
      break


print(ans)

Measured memory_bytes: 3188