akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  string s;
  getline(cin, s);
  s += ' ';
  string tmp = "";
  string maxword = "";
  vector< pair<string, int> > p;
  for(int i=0; i<s.size(); i++){
    if( s[i] != ' ' ) tmp += s[i];
    else{
      if( maxword.size() < tmp.size() ) maxword = tmp;
      bool f = false;
      for(int j=0; j<p.size(); j++){
        if( p[j].first == tmp ){
          f = true;
          p[j].second++;
        }
      }
      if( !f ) p.push_back( make_pair(tmp, 1) );
      tmp = "";
    }
  }
  int mx = 0;
  string med;
  for(int i=0; i<p.size(); i++){
    if( mx < p[i].second ){
      mx = p[i].second;
      med = p[i].first;
    }
  }
  cout << med << " " << maxword << endl;

  return 0;
}


// EOF

Measured memory_bytes: 3160
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        int i = 1;
        long cur = 100;
        for (; i < 100000; i++) {
            cur = (long) Math.floor(cur * 1.01);
            if (cur >= x) {
                break;
            }
        }
        System.out.println(i);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

void Main()
{
	int A, B, C; cin >> A >> B >> C;
	map<int, int> mp;
	mp[A] += 1;
	mp[B] += 1;
	mp[C] += 1;
	if (mp[5] == 2 && mp[7] == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,d;
	int t=0;
	cin >> m>>d;
	for(int i=2;i<=m;i++){
		for(int j=10;j<=d;j++){
			if((j%10)*(j/10)==i){
				if(j%10!=1&&j/10!=1){
					t++;
				}
				
			}
		}
	}
	cout << t;
}
 

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

class UnionFind {
private:
    int n;
    vector<pii> par;
public:
    UnionFind(int n) : n(n), par(n, {-1, 0}) {}

    pii root(int x) {
        if (par[x].first < 0) return {x, par[x].second};

        pii pp = par[x];
        pii rp = root(par[x].first);
        return par[x] = {rp.first, pp.second + rp.second};
    }

    bool same(int x, int y) { return root(x).first == root(y).first; }

    bool unite(int l, int r, int d) {
        pii lp = root(l), rp = root(r);
        if (lp.first != rp.first) {
            par[lp.first] = {par[lp.first].first + par[rp.first].first, 0};
            par[rp.first] = {lp.first, d + lp.second - rp.second};
        }
        else {
            return rp.second - lp.second == d;
        }
        return true;
    }

    int set_size(int x) { return -par[root(x).first].first; }

    int size() const { return n; }
};

int main() {
    int N, M, L, R, D;
    cin >> N >> M;

    UnionFind uf(N);
    bool ok = true;
    REP(i, M) {
        cin >> L >> R >> D;
        ok &= uf.unite(L - 1, R - 1, D);
    }

    if (ok) cout << "Yes" << endl;
    else    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

S = rs()

prev = ''
for c in S:
	if prev == c:
		print('Bad')
		exit()
	prev = c
print('Good')


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

const int MAX_N = 10000000;
vector<ll> G[MAX_N];
bool seen[MAX_N];
vector<int> ans;

void dfs(int v, int p = -1)
{
    for (int g : G[v])
    {
        if (g == p)
            continue;
        ans[g] += ans[v];
        dfs(g, v);
    }
    return;
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ans.resize(N);
    for (int i = 0; i < Q; i++)
    {
        ll root, cost;
        cin >> root >> cost;
        root--;
        ans[root] += cost;
    }

    dfs(0);
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 254720
N = int(input())
if N == 10**5:
  ans = 90909
elif N >= 10**4:
  ans = 9+900+(N-10**4+1)
elif N >= 10**3:
  ans = 909
elif N >= 10**2:
  ans = 9+(N-10**2+1)
elif N>=10:
  ans = 9
else:
  ans = N

print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, ll> P;
map<P, ll> dp;
ll f(ll X, ll Y) {
	if (dp.find(P(X, Y)) != dp.end()) return dp[P(X, Y)];
	if (X == 0 && Y == 0) return 1;
	ll sum = f(X / 2, Y / 2);
	if (X >= 1 && Y >= 1) (sum += f((X - 1) / 2, (Y - 1) / 2)) %= MOD;
	if (X >= 1 && Y >= 2) (sum += f((X - 1) / 2, (Y - 2) / 2)) %= MOD;
	return dp[P(X, Y)] = sum;
}
int main() {
	ll N;
	cin >> N;
	cout << f(N, N) << endl;
}


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

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

}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int OA[100050], A[100050], OB[100050], B[100050], P[100050];

int main() {
  int N = in();
  vector<pair<int, int>> X;
  for (int i = 0; i < N; ++i) {
    OA[i] = A[i] = in();
  }
  for (int i = 0; i < N; ++i) {
    OB[i] = B[i] = in();
    X.emplace_back(B[i], A[i]);
  }
  
  sort(A, A + N);
  sort(B, B + N);
  for (int i = 0; i < N; ++i) {
    if (A[i] > B[i]) {
      puts("No");
      return 0;
    }
  }

  set<int> PS;
  sort(X.begin(), X.end());
  for (int i = 0; i < N; ++i) {
    P[i] = lower_bound(B, B + N, X[i].second) - B;
    PS.insert(P[i]);
  }
  if (PS.size() < N) {
    puts("Yes");
    return 0;
  }

  vector<int> vis(N, 0);
  int u = 0, k = 0;
  while (true) {
    vis[u] = 1;
    ++k;
    int v = P[u];
    if (vis[v] == 1) break;
    vis[v] = 1;
    u = v;
  }

  if (k == N) {
    puts("No");
  } else {
    puts("Yes");
  }

  return 0;
}


Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,ll> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;
ll n,c,k;
ll t[100005];
int main()
{
  cin>>n>>c>>k;
  for(int i=0;i<n;i++) cin>>t[i];
  sort(t,t+n);
  ll sobrou=0;
  ll lastbus=0;
  ll resp=0;
  for(int i=0;i<n;i++)
  {
    if(t[i]<=lastbus and sobrou>0)
    {
      sobrou--;
    }
    else
    {
      resp++;
      lastbus=t[i]+k;
      sobrou=c-1;
    }
  }
  cout<<resp<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int
main() {
	char s[4] = {0};
	int r     = 0;
	scanf("%s", s);
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') r++;
	}
	printf("%d\n", r);
	return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
a=list(range(1,n+1))
l=0
l1=0
r=0
r1=10**10

for i in range(m):
	l,r=map(int,input().split())
	if l>l1:
		l1=l
	if r<r1:
		r1=r
b=list(range(l1,r1+1))
a=list(set(b) & set(a))
print(len(list(a)))

Measured memory_bytes: 25960
f, s, idx = [0, 0, 0]
N = gets.to_i
N.times{|i|
  a = gets.to_i
  if a > f then
    s = f
    f = a
    idx = i
  elsif a > s then
    s = a
  end
}

N.times{|i|
  i == idx ? (puts s) : (puts f)
}


Measured memory_bytes: 3452
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(2 * n);
	for (int i = 0; i < 2 * n; i++) cin >> a[i];
	sort(all(a));
	int l = 0;
	for (int i = 2 * n - 1; i > l; i--) {
		while (a[i] + a[l] < m && l < i - 1) l++;
		if (a[i] + a[l] >= m) {
			a[i] -= m; l++;
		}
	}
	int s = 2 * n;
	for (int i = 2 * n - 1; i >= 0; i--) {
		if (a[i] < 0) s = i;
	}
	int ans = 0;
	for (int i = s; i < 2 * n; i++) {
		ans = max(ans, a[i] + a[2 * s - 1 - i]);
	}
	for (int i = 0; i < s - n; i++) {
		ans = max(ans, a[i] + a[2 * s - 2 * n - i - 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

/**
 *
 * @author Suraj
 */
public class Main{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in =  new Scanner(System.in);
        long A=in.nextLong();
        long B=in.nextLong();
        long C=in.nextLong();
        long K=in.nextLong();
        double x = Math.pow(10,18);
        
        if(K%2==0){
            if(Math.abs(A-B)>=x){
                System.out.println("Unfair");
            }
            else{
                System.out.println(A-B);
            }
        }
        else{
            if(Math.abs(B-A)>=x){
                System.out.println("Unfair");
            }
            else{
                System.out.println(B-A);
            }
        }
        
        
        
    }
    
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	int d_cnt = 0;
	for(int i = s.size()-1; i >= 0; i--) {
		if(s[i]=='A') {
			ans += d_cnt;
			continue;
		}
		if(s[i]=='C') {
			if(i>0&&s[i-1]=='B') {
				i--;
				d_cnt++;
				continue;
			}
		}
		d_cnt = 0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
 
int main(){
  int A,B,C,i,j;
  i=0;
  j=0;
  scanf("%d %d %d",&A,&B,&C);
  if(A==5){
    i++;
  }else if(A==7){
    j++;
  }
  if(B==5){
    i++;
  }else if(B==7){
    j++;
  }
  if(C==5){
    i++;
  }else if(C==7){
    j++;
  }
  if(i==2&&j==1){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define rep(x,to) for(int x=0; x<(to); ++(x))
#define INF 1<<29
int main() {
    int m,n;

    while(cin >> n >> m, m) {
        int d[100][100];
        bool ok[100][100] = {};
        rep(i,100) {
            fill(d[i],d[i]+100,INF);
        }
        rep(i,100) {
            d[i][i] = 0;
        }
        int s,t,cost;
        rep(i,m) {
            cin >> s >> t >> cost;
            s--, t--;
            d[s][t] = d[t][s] = cost;
            ok[s][t] = ok[t][s] = true;
        }
        rep(i,n) {
            rep(j,n) {
                rep(k,n) {
                    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
                }
            }
        }
        int ans = d[0][n-1];
        rep(i,n) {
            rep(j,n) {
                if(i==j) continue;
                rep(k,n) {
                    if(k==i || k==j) continue;
                    if(ok[i][k] && ok[k][j]) {
                        ans = min(ans, d[0][i] + d[j][n-1]);
                        break;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

bool kaibun(string s, int l, int n){
  string s1, s2;
  if(n==0){
    for(int i=0; i<(l-1)/2; i++) s1+=s[i];
    for(int i=l-1; i>(l+3)/2-2; i--) s2+=s[i];
    if(s1==s2) return (kaibun(s1, s1.length(), 1) && kaibun(s2, s2.length(), 1));
  }
  else if(n==1){
    for(int i=0; i<l/2; i++) s1+=s[i];
    if(l%2!=0) for(int i=l-1; i>l/2; i--) s2+=s[i];
    else for(int i=l-1; i>=l/2; i--) s2+=s[i];
    if(l==1 || s1==s2) return true;
  }
  return false;
}

int main(void){

  string S;
  int N;

  cin >> S;
  N = S.length();

  if(kaibun(S, N, 0)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
m = []
for i in range(n):
    m.append(int(input()))
    x -= m[i]

counter = len(m)
while(1):
    if x < 0:
        print(counter - 1)
        break
    else:
        x -= min(m)
        counter += 1

Measured memory_bytes: 9152
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
   
  		int[][] ab=new int[n][2];
		for(int c=0;c<n;c++){
    		ab[c][0]=sc.nextInt();
          	ab[c][1]=sc.nextInt();
    	}
  	long count=0;
    Arrays.sort(ab,(a,b)->a[1]-b[1]);
 		for(int d=0;d<n;d++){
        	count+=ab[d][0];
          if(count>ab[d][1]){
           System.out.println("No");
            return;
          }
        }

    	System.out.println("Yes");
    }
}

Measured memory_bytes: 110864
#include<stdio.h>
int main() {
	int A, B, C,a,b,c;
	long long int ans = 0;
	scanf("%d%d%d", &A, &B, &C);

	//無限に可能の場合（全て偶数で同じ値）
	if (A == B &&  B == C && A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
	{
		puts("-1");
		return 0;
	}
	while (1)
	{
		//奇数があり不可能な場合は終了
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1)
		{
			break;
		}
		//可能なので交換を行う
		else
		{
			a = (B + C) / 2;
			b = (A + C) / 2;
			c = (B + A) / 2;
			A = a;
			B = b;
			C = c;
		}
		ans++;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
class Rori:
  B1 = 1009
  B2 = 1007
  MOD1 = 10 ** 9 + 7
  MOD2 = 10 ** 9 + 9
  H1, H2 = None, None
  P1, P2 = None, None
  def __init__(s, L):
    n = len(L) + 1
    s.H1 = [0] * n
    s.H2 = [0] * n
    s.P1 = [1] * n
    s.P2 = [1] * n
    for i in range(n - 1):
      S = ord(L[i]) - ord('a') + 1
      s.H1[i + 1] = (s.H1[i] * s.B1 + S) % s.MOD1
      s.H2[i + 1] = (s.H2[i] * s.B2 + S) % s.MOD2
      s.P1[i + 1] = s.P1[i] * s.B1 % s.MOD1
      s.P2[i + 1] = s.P2[i] * s.B2 % s.MOD2
  def hashLR(s, l, r):
    t = ((s.H1[r] - s.H1[l] * s.P1[r - l]) % s.MOD1 + s.MOD1) % s.MOD1
    k = ((s.H2[r] - s.H2[l] * s.P2[r - l]) % s.MOD2 + s.MOD2) % s.MOD2
    return (t, k)


class AVL:
  import sys
  sys.setrecursionlimit(1000000)
  class Node:
    def __init__(s, k):
      s.k = k
      s.l = None
      s.r = None
      s.d = 1
  def __init__(s):
    s.x = None
  def l_rot(s, z):
    y = z.r
    t = y.l
    y.l, z.r = z, t
    z.d = s.get_depth(z)
    y.d = s.get_depth(y)
    return y
  def r_rot(s, z):
    y = z.l
    t = y.r
    y.r, z.l = z, t
    z.d = s.get_depth(z)
    y.d = s.get_depth(y)
    return y
  def depth(s, node):
    if not node:
      return 0
    else:
      return node.d
  def get_depth(s, node):
    return 1 + max(s.depth(node.l), s.depth(node.r))
  def add(s, k):
    s.x = s.add_sub(s.x, k)
  def add_sub(s, node, k):
    if not node:
      return s.Node(k)
    elif node.k == k:
      return node
    elif node.k > k:
      node.l = s.add_sub(node.l, k)
    else:
      node.r = s.add_sub(node.r, k)
    node.d = s.get_depth(node)
    bal = s.depth(node.l) - s.depth(node.r)
    if bal > 1:
      if node.l.k > k:
        return s.r_rot(node)
      else:
        node.l = s.l_rot(node.l)
        return s.r_rot(node)
    elif bal < -1:
      if node.r.k < k:
        return s.l_rot(node)
      else:
        node.r = s.r_rot(node.r)
        return s.l_rot(node)
    return node
  def check(s, k):
    return s.check_sub(k, s.x)
  def check_sub(s, k, node):
    if node == None:
      return False
    if node.k == k:
      return True
    if node.k > k:
      return s.check_sub(k, node.l)
    else:
      return s.check_sub(k, node.r)

def hersCode(n):
  ok = 0
  ng = n
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if nasu(mid):
      ok = mid
    else:
      ng = mid
  return ok

def nasu(n):
  L = [None] * (N - n + 1)
  for i in range(len(L)):
    L[i] = R.hashLR(i, i + n)
  T = AVL()
  T.add(L[0])
  for i in range(n, len(L)):
    if T.check(L[i]):
      return True
    T.add(L[i - n + 1])
  return False

def honya(x, y, n):
  for i in range(n):
    if S[x + i] != S[y + i]:
      return i
  return n

N = int(input())
S = input()

R = Rori(S)
print(hersCode(N))


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

n=int(input())
a=[]
for i in range(3):
    aa=list(map(int,input().split()))
    a.append(aa)
ans=0
num=-1
num2=-1
for j in a[0]:
    ans+=a[1][j-1]
    num2=j
    if num2-num==1:
        ans+=a[2][j-2]
    num=j
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n,l;
    cin>>n>>l;
    vin a(n);
    rep(i,n)a[i]=abs(l+i);
    int mina=a[0];
    int b=0;
    rep(i,n){
        if(mina>a[i]){
            mina=a[i];
            b=i;
        }
    }
    cout<<l*n+n*(n-1)/2-l-b<<endl;
}

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

int main(){
  int ans, N;
  cin >> N;
  vector<int> a(N);
  
  for(int i = 0; i < N; i++) cin >> a.at(i);
  
  vector<int> dp(2);
  dp.at(0) = 0;
  dp.at(1) = abs(a.at(0) - a.at(1));
  
  for(int i = 2; i < N; i++){
    int b;
    b = min(dp.at(1) + abs(a.at(i) - a.at(i-1)), dp.at(0) + abs(a.at(i) - a.at(i-2)));
    dp.at(0) = dp.at(1);
    dp.at(1) = b;
  }
  
  ans = dp.at(1);
  cout << ans << endl;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
a=[None]*m
b=[None]*m
edge=[[] for _ in range(n)]
for i in range(m):
  a0,b0=map(int,input().split())
  a[i]=a0-1
  b[i]=b0-1
  edge[a0-1]+=[b0-1]
  edge[b0-1]+=[a0-1]

def dfs(v,nodes):
  u_nodes=nodes[:]
  if v not in u_nodes:
    return 0
  u_nodes.remove(v)
  if len(set(u_nodes) & set(edge[v]))==0:
    return 0
  if len(u_nodes)==1:
    return 1
  ret=0
  for i in set(u_nodes) & set(edge[v]):
    ret+=dfs(i,u_nodes)
  return ret

nodes=[i for i in range(n)]
print(dfs(0,nodes))

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

int main(void) {
	int a, b, c;
  	cin >> a >> b >> c;
  	
  if (a == b && b == c) cout << '1' << endl;
  else if (a == b || b == c || c == a) cout << '2' << endl;
  else cout << '3' << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
    long x, y;
    cin >> x >> y;

    long now = x;

    int count = 0;

    while (now <= y) {
        now*=2;
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
list($x,$y,$z,$n)=explode(" ",trim(fgets(STDIN)));
$r=max($x,$y,$z);
$b=min($x,$y,$z);
$g=$x+$y+$z-$r-$b;
$ans=0;
$i=0;
while($i*$r<=$n){
  $j=0;
  while($j*$g<=$n-$i*$r){
    if(($n-$i*$r-$j*$g)%$b==0){
      ++$ans;
    }
    ++$j;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4604
import java.util.*;
public class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		char a1 = a.charAt(0);
		char z = 'z';
		int asciiZ = (int) z; 
		a1=Character.toLowerCase(a1);
		int ascii = (int) a1;
		//System.out.println(ascii);
		if(ascii!=asciiZ) {
		ascii++;
		char res = (char) ascii;
		System.out.println(res);
		}
	}	
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define de(x) cout << #x << "=" << x << endl;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i > b; i--)
#define setI freopen("input.txt", "r", stdin);
#define setIO(x) freopen(x".in", "r", stdin);freopen(x".out","w", stdout);
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 2e5 + 5;

int main()
{
	#ifdef M1saki
		setI;
	#endif
//	ios::sync_with_stdio(false);
	int A, B, C, D, E, F;
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	int ans1 = 0, ans2 = 0;
	for (int a = 0; 100 * A * a <= F; a++)
	{
		for (int b = 0; 100 * A * a + 100 * B * b <= F; b++)
		{
			for (int c = 0; 100 * A * a + 100 * B * b + c * C <= F; c++)
			{
				for (int d = 0; 100 * A * a + 100 * B * b + c * C + d * D <= F; d++)
				{
					if ((100 * A * a + 100 * B * b) * E < (c * C + d * D) * 100)  continue;
					if (ans1 == 0 || 100 * (c * C + d * D) * ans1 > 100 * ans2 * (100 * A * a + 100 * B * b + c * C + d * D))
					{
						ans1 = 100 * A * a + 100 * B * b + c * C + d * D;
						ans2 = c * C + d * D;
					}
				}
			}
		}
	}
	printf("%d %d\n", ans1, ans2);

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;

int main(void){
  int N;
  cin >> N;
  
  vector<vector<int>> G(N);
  for(int i=0;i<N;i++){
    int u,k;
    cin >> u >> k;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      G[i].push_back(tmp-1);
    }
  }
  
  vector<int> S(N);
  for(int i=0;i<N;i++){
    S[i] = -1;
  }
  queue<pair<int,int>> Q;
  for(auto it:G[0]){
    Q.push(make_pair(it,1));
  }
  S[0] = 0;
  while(!Q.empty()) {
    auto i = Q.front();
    Q.pop();
    if(S[i.first]>-1){
      continue;
    } else {
      S[i.first] = i.second;
    }
      
    for(auto it: G[i.first]){
      Q.push(make_pair(it,i.second+1));
    }
  }
  
  for(int i=0;i<N;i++){
    cout << i+1 << " " << S[i] << endl;
  }
}



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

int main() {
  int N;
  cin >> N;
  map<int, int> m;
  for (int i = 1; i < N + 1; i++) {
    int A;
    cin >> A;
    m[A] = i;
  }
  for (int i = 1; i < N + 1; i++) {
    auto n = m.at(i);
    cout << n;
    if (i < N) {
      cout << " ";
    }
  }
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int n = input.nextInt();
			int m = input.nextInt();
			
			System.out.println((n - 1) * (m - 1));
		}

	}

}


Measured memory_bytes: 20948
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rt return
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int a[maxn];
int b[maxn];
int main()
{
	gbtb;
    int n,x;
    cin>>x>>n;
    repd(i,1,n)
    {
    	cin>>a[i];
    }
    sort(a+1,a+1+n);
    repd(i,1,n-1)
    {
    	b[i]=a[i+1]-a[i];
    }
    sort(b+1,b+n);
   	ll ans=0ll;
    repd(i,1,n-x)
    {
    	ans+=(1ll*b[i]);
    }
    cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



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

typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll r=0;
    ll x=0;
    for(ll l=0;l<n;l++)
    {
        while(r<n && x+a[r]==(x^a[r]))
            x+=a[r++];
        ans+=(r-l);
        x-=a[l];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
// URL: https://atcoder.jp/contests/abc131/tasks/abc131_d

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n; io.getV(n);
  int[] a, b; io.getC(n, a, b);

  struct T { int a, b; }
  auto t = new T[](n);
  foreach (ref ti, ai, bi; lockstep(t, a, b)) ti = T(ai, bi);
  t.sort!"a.b < b.b";

  auto s = 0;
  foreach (ti; t) {
    s += ti.a;
    if (s > ti.b) {
      io.put("No");
      return;
    }
  }

  io.put("Yes");
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int a[3][3];
bool ans[3][3];

int main(void)
{
    REP(i,3) REP(j,3){
        cin >> a[i][j];
    }
    int N;
    cin >> N;
    REP(k, N){
        int b;
        cin >> b;
        REP(i,3) REP(j,3){
            if(a[i][j] == b){
                ans[i][j] = true;
            }
        }
    }

    bool f = false;
    REP(i, 3){
        if((ans[i][0] && ans[i][1] && ans[i][2])){
            f = true;
        }
        if(ans[0][i] && ans[1][i] && ans[2][i]){
            f=true;
        }
    }

    if(ans[0][0] && ans[1][1] && ans[2][2]){
        f = true;
    }
    if(ans[0][2] && ans[1][1] && ans[2][0]){
        f = true;
    }

    Yes(f);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		long[] b = new long[n + 1];
		long[] c = new long[n + 2];
		b[0] = 0;
		c[0] = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if (i == 0) {
				b[i + 1] = a[i];
				c[i + 1] = Math.max(a[i], 0);
			} else {
				b[i + 1] = b[i] + a[i];
				c[i + 1] = c[i] + Math.max(a[i], 0);
			}
		}
		c[n + 1] = c[n];
		long sum, ans = 0;
		for (int i = k; i <= n; i++) {
			sum = c[i - k];
			sum += c[n + 1] - c[i];
			ans = Math.max(ans, sum);
			sum += b[i] - b[i - k];
			ans = Math.max(ans, sum);
		}

		System.out.println(ans);
	}
}

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

int main() {
    int N;
    cin >> N;
    int d[N+1];
    int result = 0;
    for(int i = 0; i < N; i++) {
        cin >> d[i];
    }
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            result += d[i]*d[j];
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
var
	a,b,x1,y1,x2,y2,x3,y3,x4,y4:longint;
begin
	read(x1,y1,x2,y2);
	a:=x1-x2; b:=y1-y2;
	x3:=x2+b; y3:=y2-a;
	x4:=x3+a; y4:=y3+b;
	writeln(x3,' ',y3,' ',x4,' ',y4);
end.

Measured memory_bytes: 128
cardNum = lambda S:int(list(S)[1])

def bubbleSort(L, n):
  for i in range(n):
    for j in range(n-1, i, -1):
      if cardNum(L[j]) < cardNum(L[j-1]):
        L[j], L[j-1] = L[j-1], L[j]
  return L

def selectionSort(L, n):
  for i in range(n):
    minj = i
    for j in range(i, n):
      if cardNum(L[j]) < cardNum(L[minj]):
        minj = j
    L[i], L[minj] = L[minj], L[i]
  return L

def isStable(Lb, Ls):
  if Lb == Ls:
    return "Stable"
  else:
    return "Not stable"
  
N = int(input())
A = input().split()
B = [i for i in A]
LB = bubbleSort(A, N)
LS = selectionSort(B, N)
print(' '.join(map(str, LB)))
print("Stable")
print(' '.join(map(str, LS)))
print(isStable(LB, LS))


Measured memory_bytes: 5612
#include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  long a[n+2],b[n+1];
  for(int i=1;i<=n+1;i++) cin >> a[i];
  for(int i=1;i<=n;i++) cin >> b[i];
  long sum=0;
  for(int i=n;i>=1;i--){
    if(a[i+1]>=b[i]){
      sum += b[i];
      //a[i+1] -= b[i];
      b[i] = 0;
      continue;
    }else{
      sum += a[i+1];
      //a[i] = 0;
      b[i] -= a[i+1];
    }
    if(a[i]>=b[i]){
      sum += b[i];
      a[i] -= b[i];
      //b[i-1] = 0;
    }else{
      sum += a[i];
      a[i] = 0;
      //b[i-1] -= a[i-1];
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int a, b, c;
      cin >> a >> b >> c;
      if(a==b && b== c)
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007


int main() {
   
    {
        int n,i;cin>>n;
        int cnt=0;
        while(n)
        {
            if(n%10==2)cnt++;
            n/=10;
        }
        cout<<cnt;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, x, y, s, t, u;
  in3(a, b, c);
  in2(x, y);
  s = 99999999999;
  rep(i, 2 * max(x, y) + 1){
    t = max(0ll, x - i / 2);
    u = max(0ll, y - i / 2);
    s = min(s, a * t + b * u + c * i);
  }
  out(s);
  memi;
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    unordered_map<string, int> mp;
    for(int i=0;i<n;i++){
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 17620
#include <stdio.h>

int main(){
     
    int a,b;
    
    scanf("%d%d",&a,&b);

    if(a>b){ printf("a > b\n");}
    else if(a<b){ printf("a < b\n");}
    else{ printf("a == b\n");}
    
    return 0;
}

Measured memory_bytes: 580
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include<bits/stdc++.h>
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007

int main()
{
	int a,b;
	si(a), si(b);
	pi((a+b)%24);
	return 0;
}

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

int main()
{
  int N; cin >> N;
  vector<int> d(N);
  rep(i, N) {
    cin >> d[i];
  }
  int ans = 0;
  rep(i, N-1) {
    for (int j = 1; j < N-i; j++){
      ans += d[i] * d[i + j];
    }

  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import deque

def main():
    h, w = map(int, input().split())
    s = [input() for i in range(h)]

    # Get minimum path length with Dijkstra-BFS
    q = deque()
    queued = [[False] * w for i in range(h)]
    q.append((0, 0, 1))
    queued[0][0] = True
    res = None
    while q:
        i, j, l = q.popleft()
        if (i, j) == (h - 1, w - 1):
            res = l
            break
        for di, dj in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
            i2 = i + di
            j2 = j + dj
            if i2 < 0 or i2 >= h:
                continue
            if j2 < 0 or j2 >= w:
                continue
            if queued[i2][j2]:
                continue
            if s[i2][j2] == "#":
                continue
            q.append((i2, j2, l + 1))
            queued[i2][j2] = True

    if res is None:
        print(-1)
        return

    # (number of white) - (minimum path length)
    num_white = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                num_white += 1
    print(num_white - res)

if __name__ == "__main__":
    main()


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int gcd(int a,int b){
    return b!=0?gcd(b,a%b):a;
}

int main(){
	int n;
    cin>>n;
    int num=1;
    int cnt=0;
    int sum=0;
    if(n==3){
        cout<<2<<" "<<5<<" "<<63<<endl;
    }else{
        while(cnt<n-2){
            num++;
            if(num%2==0 || num%3==0){
                cout<<num<<" ";
                sum+=num;
                cnt++;
            }
        }
        for(int i=num+1;i<=30000;i++){
            for(int j=i+1;j<=30000;j++){
                if(((i%2==0 || i%3==0) && (j%2==0 || j%3==0))
                    && (sum+i+j)%6==0){
                    cout<<i<<" "<<j<<endl;
                    return 0;
                }
            }
        }
    }
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  vl DP(3, 0);
  REP(i, S.size()) { DP[S[i] - 'a']++; }
  if (MAX(DP) - MIN(DP) <= 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int X;
  int pos = 0, time;

  cin >> X;
  X = abs(X);

  for(int i = 1;pos < X;i++){
    pos += i;
    time = i;
  }

  cout << time << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=4e5+10;
int a[maxn];
ll sum[maxn];
int main(){
	int l=read();
	int n=read();
	REP(i,1,n) a[i]=read(),a[i+n]=a[i]+l;
	REP(i,1,2*n) sum[i]=sum[i-1]+a[i];
	ll ans=0;
	REP(i,0,n){
		int cur=min(n-i,i);
		chkmax(ans,2*((sum[n+i]-sum[n+i-cur])-(sum[i+cur]-sum[i]))-min(a[n+i]-l,l-a[i+1]));
		if(i>n-i) chkmax(ans,2*((sum[n+i]-sum[n+i-cur-1])-(sum[i+cur]-sum[i]+l))-(a[n+i]-l));
		if(i<n-i) chkmax(ans,2*((sum[n+i]-sum[n+i-cur]+l)-(sum[i+cur+1]-sum[i]))-(l-a[i+1]));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4992
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(x):
  res = np.ceil((hp - B*x)/(A-B))
  cnt = res[res > 0].sum()
  if cnt <= x:
    return True
  else:
    return False

# 二分探索 #
def nibutan(n):
  left = 0
  right = n
  while left+1 != right:
    middle = (left+right)//2
    if judge(middle):
      right = middle
    else:
      left = middle
  return right

N,A,B = IL()
hp = np.array([I() for i in range(N)])
hp.sort()
n = hp[-1]//B+1

ans = nibutan(n)

print(ans)

Measured memory_bytes: 17084
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll k; cin >> k;
    if(k % 2 == 1) cout << (k/2)*(k/2+1) << endl;
    else cout << (k/2)*(k/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "Yes"
#define __FALSE "No"
using namespace std;

int main() {
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  int max=0,count=0;
  for(int i=0;i<n;i++) {
    cin >> m[i];
    max += m[i];
    count++;
  }
  sort(m.begin(), m.end());
  while(1) {
    max += m[0];
    if(max <= x) count++;
    else break;
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;

int main() {

    char a,b;
    cin>>a>>b;
    int x = a-'0',y=b-'0';
    string res1="",res2="";
    while(x--){
        res1+=b;
    }
    while(y--){
        res2+=a;
    }

    if(res1<=res2)cout<<res1<<endl;
    else cout<<res2<<endl;


    return 0;
}


Measured memory_bytes: 3624