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

const int MOD = 1000000007;
const int INF = 1e9;

int n, m, k;
const int max_n = 1e5;
vector<vector<int>> friends(max_n+1);
vector<vector<int>> blocks(max_n+1);
vector<int> dame(max_n + 1);
vector<int> group_number(max_n+1, 0);
vector<int> group_size(max_n + 1, 1);
vector<int> blocks_number(max_n+1, 0);
vector<int> blocks_size(max_n + 1, 1);

void dfs(int i, int itr){
  for(auto next : friends[i]){
    if(group_number[next] != 0) continue;
    group_number[next] = itr;
    group_size[itr] ++;
    dfs(next, itr);
  }
  return;
}

int main(){
  cin >> n >> m >> k;
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    a--, b--;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  // for(int i = 0; i < k; i++){
  //   int c,d;
  //   cin >> c >> d;
  //   c--, d--;
  //   blocks[c].push_back(d);
  //   blocks[d].push_back(c);
  // }

  int itr = 1;
  for(int i = 0; i < n; i++){
    if(group_number[i] != 0) continue;
    group_number[i] = itr;
    dfs(i, itr);
    itr++;
  }
  // for(int i = 0; i < n; i++){
  //   cout << group_number[i] << endl;
  // }

  for(int i = 0; i < k; i++){
    int c,d;
    cin >> c >> d;
    c--, d--;
    if(group_number[c] == group_number[d]){
      dame[c] ++;
      dame[d] ++;
    }
  }

  for(int i = 0; i < n; i++){
    int size = friends[i].size();
    int same_roots = group_size[group_number[i]];
    int suggestion = same_roots - size - dame[i] - 1;
    // cout << same_roots << "-" << size << "-" << "1" << "=" << suggestion << endl;
    cout << suggestion << endl;
  }

  return 0;
}

Measured memory_bytes: 14028
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N << endl;
    return 0;
  } else {
    cout << N * 2 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int p[50625],i,j,n;
	for(i=0;i<50625;i++){p[i]=1;}
	for(i=2;i<226;i++){
		if(p[i-1]==1){
			for(j=i*i;j<50625;j+=i){p[j-1]=0;}
		}
	}
	while(scanf("%d",&n)!=EOF){
		i=n-1;
		while(p[i-1]!=1)i--;
		printf("%d ",i);
		i=n+1;
		while(p[i-1]!=1)i++;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

vector<int>ee[N];
int used[N];
vector<int>e[N];
int c[N];
void dfs(int p,int k) {
	used[k] = 1;
	f(i, ee[k].size()) {
		if (ee[k][i] != p) {
			if (used[ee[k][i]] == 0)dfs(k, ee[k][i]);
			else if (used[ee[k][i]]==1) {
				e[k].push_back(ee[k][i]);
				c[k]++;
			}
		}
	}
	if (p != -1) {
		if (c[k] % 2 == 0) {
			e[p].push_back(k);
			c[p]++;
		}
		else {
			e[k].push_back(p);
			c[k]++;
		}
	}
	used[k] = 2;
}




int main() {
	int a[N];
	int n, m, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n, &m);
	f(i, m) {
		scanf("%d %d", &x, &y);
		x--;
		y--;
		ee[x].push_back(y);
		ee[y].push_back(x);
	}
	if (m%2 == 1) {
		printf("-1\n");
		return 0;
	}
	f(i, n) {
		used[i] = 0;
		c[i] = 0;
	}
	dfs(-1, 0);
	f(i, n) {
		f(j, e[i].size()) {
			printf("%d %d\n", i + 1, e[i][j] + 1);
		}
	}



	return 0;
}

Measured memory_bytes: 21248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) (X).begin(), (x).end()
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  rep (i, N) cin >> x[i] >> y[i];
  double sum = 0;
  rep (i, N) {
    rep (j, N) {
      double dis = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
      sum += dis;
    }
  }
  cout << setprecision(15) << sum / N << endl;
  return 0;
}


Measured memory_bytes: 256
n,x = (int(x) for x in input().split())
l=list(map(int,input().split()))
k=0
d=0

while d<=x:
   if len(l)<=k:
    break
   else:
    d=d+l[k]
    k=k+1
if d<=x:
  print(k+1)
else:print(k)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char);
long long getKey(char *);
int h1(int);
int h2(int);
int find(char *);
int insert(char *);

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i=0;i<M;i++) H[i][0]='\0';
    
    scanf("%d", &n);
    
    for(i=0;i<n;i++){
	scanf("%s %s",com,str);
	
	if(com[0]=='i') insert(str);
	else {
	  if (find(str)) printf("yes\n");
	  else printf("no\n");
	}
    }
    
    return 0;
}

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char *str){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  int result;

  result= key%M;
  return result;
  
}

int h2(int key){
  int result;

  result=1+(key%(M-1));
  return result;
}

int find(char *str){
  long long key,h;
  int i;

  key=getKey(str);

  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}


int insert(char *str){
  long long key,h;
  int i;

  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }    
  }
  return 0;
}



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

int main(){

    int N,M;
    bool ans=true;
    cin>>N;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    cin>>M;
    vector<int> T(M);
    for(int i=0;i<M;i++){
        cin>>T[i];
    }
    sort(T.begin(),T.end());
    int cnt;
    for(int i=0;i<M;i++){
        if(i==0||T.at(i)!=T.at(i-1)){
        cnt=upper_bound(S.begin(),S.end(),T[i])-lower_bound(S.begin(),S.end(),T[i]);
        if(cnt==0) ans=false;
        else cnt--;
        }
        else{
            if(cnt==0) ans=false;
            else cnt--;
        }
        }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
    


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

int main(){
    vector<vector<int>> bingo(3,vector<int>(3,0));
    rep(i,3) rep(j,3) cin >> bingo.at(i).at(j);
    int n;
    cin >> n;
    vector<int> nums(n,0);
    rep(i,n) cin >> nums.at(i);
    // yoko
    rep(i,3){
        vector<bool> b(3,false);
        bool ans = true;
        rep(j,3){
            rep(k,n){
                if(bingo.at(i).at(j) == nums.at(k)){
                    b.at(j) =true;
                    break;
                }
            }
        }
        rep(j,3)if(!b.at(j)) ans = false;
        if(ans){
            cout << "Yes" << endl;
            return 0;
        }
    }
    // tate
    rep(i,3){
        vector<bool> b(3,false);
        bool ans = true;
        rep(j,3){
            rep(k,n){
                if(bingo.at(j).at(i) == nums.at(k)){
                    b.at(j) =true;
                    break;
                }
            }
        }
        rep(j,3)if(!b.at(j)) ans = false;
        if(ans){
            cout << "Yes" << endl;
            return 0;
        }
    }
    //naname
    vector<int> tmp1;
    vector<int> tmp2;
    rep(i,n){
        if(bingo.at(0).at(0) == nums.at(i)) tmp1.push_back(nums.at(i));
        else if(bingo.at(1).at(1) == nums.at(i)) {
            tmp1.push_back(nums.at(i));
            tmp2.push_back(nums.at(i));
        }
        else if(bingo.at(2).at(2) == nums.at(i)) {
            tmp1.push_back(nums.at(i));
        }
        else if(bingo.at(0).at(2) == nums.at(i)) tmp2.push_back(nums.at(i));
        else if(bingo.at(2).at(0) == nums.at(i)) tmp2.push_back(nums.at(i)); 
    }
    if(tmp1.size() >= 3 || tmp2.size() >= 3){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N; cin >> N;
    vector<string> S(N);
    map<string, int> ch;
    rep(i, N) { 
        cin >> S.at(i);
        ch[S[i]]++;
    }

    int res = 0;
    rep(i, N) res = max(res, ch[S[i]]);
    for (auto it = ch.begin(); it != ch.end(); it++) {
        if (it->second == res) cout << it->first << endl;
    }
}

Measured memory_bytes: 25180
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n,w;
    cin >> n >> w;
    vector<ll> wei(n),val(n);
    rep(i,n) cin >> wei[i] >> val[i];
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
    rep2(i,1,n+1) rep(j,w+1) {
        chmax(dp[i][j],dp[i-1][j]);
        if(wei[i-1] <= j) chmax(dp[i][j],dp[i-1][j-wei[i-1]]+val[i-1]);
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N, M, ans;

bool used_num[10];
bool non_zero[26];
ll c[26];
string s[12];
vector<P> cs;

bool check() {
	ll sum = 0;
	for (int i = 0; i < M; i++) {
		sum += c[cs[i].first] * cs[i].second;
	}
	return sum == 0;
}

void f(int m) {
	if (m == M) {
		if (check()) ans++;
		return;
	}
	for (int i = 0; i <= 9; i++) {
		if (i == 0 && non_zero[cs[m].first]) continue;
		if (!used_num[i]) {
			used_num[i] = true;
			cs[m].second = i;
			f(m + 1);
			used_num[i] = false;
		}
	}
}

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

	while (cin >> N , N) {
		bool use_char[26] = {0};
		fill(non_zero, non_zero + 26, false);

		for (int i = 0; i < N; i++) {
			cin >> s[i];
			for (int j = 0; j < s[i].length(); j++) {
				if (j == 0 && s[i].length() >= 2) non_zero[s[i][j] - 'A'] = true;
				use_char[s[i][j] - 'A'] = true;
			}
		}

		cs.clear();
		for (int i = 0; i < 26; i++) {
			if (use_char[i]) cs.push_back(P(i, -1));
		}
		M = cs.size();

		fill(c, c + 26, 0);
		for (int i = 0; i < N; i++) {
			ll cc = 1;
			for (int j = s[i].length() - 1; j >= 0; j--) {
				if (i != N - 1) c[s[i][j] - 'A'] += cc;
				else c[s[i][j] - 'A'] -= cc;
				cc *= 10;
			}
		}

		ans = 0;
		f(0);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    vector<ll> z(n), w(n);
    rep(i, n) {
        z[i] = x[i] + y[i];
        w[i] = x[i] - y[i];
    }

    ll zMax = -LLINF, zMin = LLINF;
    ll wMax = -LLINF, wMin = LLINF;
    rep(i, n) {
        chmax(zMax, z[i]); chmin(zMin, z[i]);
        chmax(wMax, w[i]); chmin(wMin, w[i]);
    }
    cout << max(zMax - zMin, wMax - wMin) << endl;
}


Measured memory_bytes: 9528
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
  int n,m;
  cin>>n>>m;
  vector<int> vec[m+1];
  for(int i=1;i<=m;i++){
    int k;
    cin>>k;
    for(int j=1;j<=k;j++){
      int a;
      cin>>a;
      vec[i].push_back(a);
    }
  }
  
  int p[m+1];
  for(int i=1;i<=m;i++){
    cin>>p[i];
  }
  
  
int ans=0;
    // 全探索 --- bit は {0, 1, ..., n-1} の 2^n 通りの部分集合全体を動きます。
    bool exist = false;
    for (int bit = 0; bit < (1<<n); ++bit){
       int gl[n+1];
      for(int i=1;i<=n;i++){
        gl[i]=0;}
      
      bool suc=true;
      
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が S に入っているなら足す
                gl[i+1]++;
            }
        }
          for(int i=1;i<=m;i++){
          int k=0;
            for(int j=0;j<vec[i].size();j++){
              k+=gl[vec[i][j]];}
            if(k%2!=p[i]) {
              suc=false;
              break;}
           
          }
             if(suc){ans++;}
           
        }
        
      
      cout<<ans<<endl;
      return 0;

      
  


}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a < b:
	if a < c:
		x = a
		if b < c:
			y = b
			z = c
		else:
			y = c
			z = b
	else:
		x = c
		y = a
		z = b
elif a < c:
	 	x = b
	 	y = a
	 	z = c
elif b < c:
	x = b
	y = c
	z = a
else:
	x = c
	y = b
	z = a
	
print(x, y, z) 

Measured memory_bytes: 7600
import java.io.BufferedReader
import java.io.BufferedWriter

fun main() = Case().exec(::solve)
fun solve(c: Case) {
    val n = c.long().toInt()
    val towns = (0 until n).map { ind -> c.intList().let { Town(ind, it[0], it[1]) }}
    val edges = towns.sortedBy { it.x }.zipWithNext().map {
        Kruskal.Edge(it.first.id, it.second.id, it.second.x - it.first.x)
    } + towns.sortedBy { it.y }.zipWithNext().map {
        Kruskal.Edge(it.first.id, it.second.id, it.second.y - it.first.y)
    }
    c.println(Kruskal.solve(n, edges))
}

data class Town(val id: Int, val y: Int, val x: Int)

object Kruskal {
    fun solve(nodeSize: Int, edges: List<Edge>): Long {
        val unionFind = UnionFind(nodeSize)
        var cost = 0L
        edges.sortedBy { it.cost }.forEach { edge ->
            if (unionFind.same(edge.from, edge.to)) return@forEach
            unionFind.unite(edge.from, edge.to)
            cost += edge.cost
        }
        return cost
    }

    data class Edge(val from: Int, val to: Int, val cost: Int)

    private class UnionFind(n: Int) {
        val par = (0 until n).toMutableList()
        fun root(x: Int): Int = if (par[x] == x) x else root(par[x]).also { par[x] = it }
        fun same(x: Int, y: Int): Boolean = root(x) == root(y)
        fun unite(x: Int, y: Int) {
            if (root(x) != root(y)) par[root(x)] = root(y)
        }
    }
}

class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }
    private fun execInThread(fn: (Case) -> Unit) =
        Thread(null, { fn(this) }, "solve", 64 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
            .apply { start() }.join()

    fun println(c: CharSequence?) = out.appendln(c)
    fun println(c: Number) = println(c.toString())
    fun string(): String = input.readLine().trimEnd()
    fun int(): Int = string().toInt()
    fun long(): Long = string().toLong()
    fun intList(): List<Int> = string().split(" ").map { it.toInt() }
    fun longList(): List<Long> = string().split(" ").map { it.toLong() }
}

Measured memory_bytes: 87604
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	string s;
	cin >> s;
	int g=0;
	for(int i =0;i < s.size();i++){
		if(s[i] == 'g')g++;
		else g--;
	}
	cout << g / 2 << endl;
	return 0;
}


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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

const int N = 1005;
char s[N][N];

int main()
{
	int n = _, m = _, a = _, b = _;
	for( int i = 1; i <= n; i++ ) 
		for( int j = 1; j <= m; j++ ) s[i][j] = '1';
	// for( int i = 0; ++i <= n; putchar('\n'))
		// for( int j = 0; ++j <= m; )
			// putchar(s[i][j]);
	for( int i = 1; i <= b; i++ ) 
		for( int j = 1; j <= a; j++ ) s[i][j] = '0';
	// for( int i = 0; ++i <= n; putchar('\n'))
	// 	for( int j = 0; ++j <= m; )
	// 		putchar(s[i][j]);
	for( int i = b + 1; i <= n; i++ ) 
		for( int j = a + 1; j <= m; j++ ) s[i][j] = '0';
	for( int i = 0; ++i <= n; putchar('\n'))
		for( int j = 0; ++j <= m; )
			putchar(s[i][j]);
}
/*
	每行有a个0, m-a个1
	每列有b个0, n-b个1
*/

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
map< string, ll> mpp;
vector<ll> ans;	
int main()
{
	IOS
	ll s;
	cin>>s;
	ll i;
	ll x1=0,y1=0;
	ll x2=1000000000,y2=1;
	ll y3=s/x2;
	ll x3=(x2*y3)-s;
	while(x3<0)
	{
		y3++;
		x3=(x2*y3)-s;
	}
	cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<"\n";
	return 0;

}             

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N, X = map(int,readline().split())

T = [0] * (N + 1) # レベルiバーガーの厚さ
P = [0] * (N + 1) # レベルiバーガーのパティの数

T[1] = 5
P[1] = 3

for i in range(2, N + 1):
  T[i] = T[i - 1] * 2 + 3
  P[i] = P[i - 1] * 2 + 1

# Nバーガー,X枚目
stack = [[N,X]]
ans = 0

while stack:
  n, x = stack.pop()
  if x <= 0:
    continue
  if x >= T[n]:
    ans += P[n]
    continue
  if n == 1:
    ans += min(x - 1,3)
    continue
  stack.append([n - 1,x - 1])
  ans += (x >= T[n - 1] + 2) * 1
  stack.append([n - 1, x - (T[n - 1] + 2)])

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;


int main() 
{
	int n, a[3][20];
	int nn = 0;
	cin >> n;
	for (int j = 0; j < 2; j++)
		for (int i = 0; i < n; i++)
		{
			cin >> a[j][i];
		}
	for (int i = 0; i < n-1; i++)
	{
		cin >> a[2][i];
	}
	for (int i = 0; i < n; i++)
	{
		nn += a[1][a[0][i] - 1];
		if ((a[0][i] + 1) == (a[0][i+1]))
			nn += a[2][a[0][i]-1];
	}
	cout << nn << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int64_t n,c,d,e;
 cin>>n;
 c=0;//0のかず
 d=1000;
 e=0;
 vector<int>a(n);
 vector<int>b(n-1);
 for(int i=0;i<n;i++){
   cin>>a.at(i);
 }
 for(int i=1;i<n;i++){
   if(a.at(i)<a.at(i-1)){
     b.at(i-1)=-1;
    }
    else if(a.at(i)>a.at(i-1)){
      b.at(i-1)=1;
    }
    else{
      b.at(i-1)=0;
      c++;
    }
  }
  vector<int>x(n-c);
  x.at(0)=a.at(0);
  int j=1;
  for(int i=0;i<n-1;i++){
    if(b.at(i)==0){
      continue;
    }
    else{
      x.at(j)=a.at(i+1);
      j++;
    }
  }
  if(n-c!=1){
  if(x.at(1)>x.at(0)){
    e=d/x.at(0);
    d=d%x.at(0);
  }
  }
  for(int i=1;i<n-c-1;i++){
    if(x.at(i)<x.at(i-1)&&x.at(i)<x.at(i+1)){
      e=d/x.at(i);
      d=d%x.at(i);
    }
    else if(x.at(i)>x.at(i-1)&&x.at(i)>x.at(i+1)){
      d=d+x.at(i)*e;
      e=0;
    }
  }
  cout<<d+e*x.at(n-c-1)<<endl;
}

Measured memory_bytes: 3636
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

void dfs(vector<int> adj[], int sv, vector<bool> &vis){
	vis[sv] = true;
	for(int i = 0; i < adj[sv].size(); i++){
		if(!vis[adj[sv][i]]){
			dfs(adj, adj[sv][i], vis);
		}
	}
}
ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
}  
int nCr(int n, int r) {
    ll x = 1, y = 1;
    rep(i, 0, r) {
        x = x * (n - i) % mod;
        y = y * (i + 1) % mod;
    }
    return x * power(y, mod - 2) % mod;
}

signed main(){
	FASTIO
	ll n, a, b;
    cin >> n >> a >> b;
 
    ll ans = power(2, n) - 1 - nCr(n, a) - nCr(n, b);
 
    cout << (ans % mod + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n;
cin >> n;
int a[n],b[n];
for(int i=0;i<n;i++){
    cin >> a[i];
}
for(int i=0;i<n;i++){
    b[i]=i+1;
}
 vector<pair<int,int>>p(n);
 for(int i=0;i<n;i++){
     p[i]=make_pair(a[i],b[i]);
 }

 sort(p.begin(),p.end());

 for(int i=0;i<n;i++){
     cout << p[i].second << endl;
 }
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 2432
n=int(input())
da=list(map(int,input().split()))
co=[0,0,0]
for i in da:
    if i%4==0:
        co[0]+=1
    elif i%2==0:
        co[1]+=1
    else:
        co[2]+=1
if co[0] >= co[2]:
    print('Yes')
elif co[0]+1 == co[2] and co[1]==0:
    print('Yes')
else:
    print('No')

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;
#define MOD 1000000007

int main(void)
{
    IOS
    string s;
    cin >> s;

    int l = s.size();

    vector<INT64> dp1(l,0);
    vector<INT64> dp2(l,0);

    REP(l){
        if (i == 0) {
            dp1[0] = 1;
            dp2[0] = 2;
        } else {
            if (s[i] == '1') {
                dp1[i] = (dp1[i-1] * 3 + dp2[i-1]) % MOD;
                dp2[i] = dp2[i-1] * 2 % MOD;
            } else {
                dp1[i] = (dp1[i-1] * 3) % MOD;
                dp2[i] = dp2[i-1];
            }
        }
    }

    cout << (dp1[l-1] + dp2[l-1]) % MOD << endl;


    return 0;
}


Measured memory_bytes: 2000
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);
	ll n, t;
	cin >> n >> t;

	vector<ll> w(n), v(n);
	rep(i, n)
		cin >> w[i] >> v[i];

	ll dp[105][100005];
	memset(dp, 0, sizeof(dp));

	rep(i, n) {
		rep(j, t + 1) {
			if (w[i] > j)
				dp[i + 1][j] = dp[i][j];
			else
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
		}
	}

	cout << dp[n][t] << endl;

	return 0;
}

Measured memory_bytes: 82304
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if(a == 5 && b == 5 && c == 7){
      System.out.println("YES");
    }else if(a == 5 && b == 7 && c == 5){
      System.out.println("YES");
    }else if(a == 7 && b == 5 && c == 5){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21716
# frozen_string_literal: true

n, @k = gets.split(' ').map(&:to_i)
@weights = n.times.map { gets.to_i }

def loadable?(cap)
  truck = 0
  loadage = 0
  @weights.each do |weight|
    if loadage + weight <= cap
      loadage += weight
    else
      truck += 1
      return false if truck >= @k

      loadage = weight
    end
  end
  true
end

cap_right = @weights.sum
cap_left = @weights.max

def search_bin(left, right)
  return left if left == right

  if left + 1 == right
    return loadable?(left) ? left : right
  end

  mid = (left + right) / 2
  if loadable?(mid)
    search_bin(left, mid)
  else
    search_bin(mid + 1, right)
  end
end

puts search_bin(cap_left, cap_right)



Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
int main() {
char a,b;
cin>>a>>b;
if(a=='H'||a=='D'||b=='H'||b=='D'){
    if(b=='H'){
        printf("%c",a);
    }else {
        if(a=='H'){
            printf("D");
        }else{
            printf("H");
        }
    }
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

ll dp[3010][3010][4] = {};

int main(void){
	ll r, c, k;
	cin >> r >> c >> k;
	Vec x(k), y(k), v(k);
	rep(i, k) cin >> x[i] >> y[i] >> v[i];

	map<P, ll> item;
	rep(i, k) item[{x[i] - 1, y[i] - 1}] = v[i];

	rep(i, r) {
		rep(j, c) {
			bool flg = (item.find({i, j}) != item.end());
			ll t = 0;
			if (flg) t = item[{i, j}];
			rep(k, 4) {
				if (!i && !j) {
					dp[i][j][1] = t;
					continue;
				}

				if (!j) {
					chmax(dp[i][j][k], dp[i - 1][j][k]);
					chmax(dp[i][j][1], dp[i - 1][j][k] + t);
					continue;
				}

				if (!i) {
					chmax(dp[i][j][k], dp[i][j - 1][k]);
					if (k) chmax(dp[i][j][k], dp[i][j - 1][k - 1] + t);
					continue;
				}

				chmax(dp[i][j][k], dp[i - 1][j][k]);
				chmax(dp[i][j][1], dp[i - 1][j][k] + t);
				chmax(dp[i][j][k], dp[i][j - 1][k]);
				if (k) chmax(dp[i][j][k], dp[i][j - 1][k - 1] + t);
			}
		}
	}

	ll ans = 0;
	rep(i, 4) chmax(ans, dp[r - 1][c - 1][i]);
	co(ans);

	return 0;
}


Measured memory_bytes: 302700
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String

N = int(input()) # String
H = list(map(int, input().split()))

C = np.zeros(len(H), dtype=int)

C[N - 1] = 0

for i in reversed(range(N - 1)):
    if H[i] >= H[i+1]:
        C[i] = C[i+1] + 1
    else:
        C[i] = 0

        
print(max(C))


Measured memory_bytes: 23384
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y){ ll ans = 1;x %= MOD;while(y){if(y&1)ans = (x * ans) % MOD;x = (x * x) % MOD;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}
using namespace std;

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;
}

int main() {
    fastio;
    solve();
}


Measured memory_bytes: 3616
def solve():
    can_positive = False
    if len(P) > 0:
        if k < n: can_positive = True
        else: can_positive = len(M)%2 == 0
    else: can_positive = k%2 == 0

    if can_positive:
        P.sort()
        M.sort(reverse=True)
        a = [P.pop()] if k%2 else [1]
        while len(P) >= 2: a.append(P.pop() * P.pop())
        while len(M) >= 2: a.append(M.pop() * M.pop())
        return a[:1] + sorted(a[1:], reverse=True)[:(k-k%2)//2]
    else: return sorted(P+M, key=lambda x:abs(x))[:k]

n, k = map(int, input().split())
P, M = [], []
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


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

typedef long long ll;

const int mod = 1000000007;

struct mat {
    int t[3][3];
};
mat E, C, D, A, B, Q;
mat mult(mat a, mat b) {
    mat ret;
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
        ret.t[i][j] = 0;
        for(int k = 0; k < 3; k++) {
            ret.t[i][j] += (ll)a.t[i][k] * b.t[k][j] % mod;
            ret.t[i][j] %= mod;
        }
    }
    return ret;
}
mat po(mat x, int n) {
    mat ret = E;
    while(n) {
        if(n & 1) ret = mult(ret, x);
        x = mult(x, x);
        n /= 2;
    }
    return ret;
}
mat sum(mat a, mat b) {
    mat ret;
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) {
        ret.t[i][j] = ((a.t[i][j] + b.t[i][j]) % mod + mod) % mod;
    }
    return ret;
}

int N, M;

int main() {
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) E.t[i][j] = i == j;
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) Q.t[i][j] = -(i == j);
    C.t[0][0] = 2; C.t[0][1] = 1; C.t[0][2] = 2;
    C.t[1][0] = 1; C.t[1][1] = 1; C.t[1][2] = 2;
    C.t[2][0] = 1; C.t[2][1] = 0; C.t[2][2] = 1;
    D.t[0][0] = 1; D.t[0][1] = 0; D.t[0][2] = 0;
    D.t[1][0] = 0; D.t[1][1] = 0; D.t[1][2] = 0;
    D.t[2][0] = 0; D.t[2][1] = 0; D.t[2][2] = 0;

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

    int ans = mult(mult(sum(C, Q), po(C, N - 1)), D).t[0][0];
    D.t[0][0] = 0;
    A = D;
    B = D;
    D.t[0][0] = 1;
    int b = 0;
    for(int i = 0; i < M; i++) {
        int x; scanf("%d", &x);
        int t = mult(mult(sum(C, Q), po(C, x - 1)), D).t[0][0];
        int d = mult(mult(sum(C, Q), po(C, N - x - 1)), D).t[0][0];

        mat tmp = po(C, x - b - 1);
        B = mult(tmp, A);
        A = mult(mult(C, tmp), A);

        t -= (mult(A, D).t[0][0] - mult(B, D).t[0][0] + mod) % mod;
        t = (t % mod + mod) % mod;

        ans -= (ll)t * d % mod;
        ans = (ans % mod + mod) % mod;

        D.t[0][0] = t;
        A = sum(A, D);
        B = sum(B, D);
        D.t[0][0] = 1;

        b = x;
    }
    printf("%d", ans);
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max(p, max(q, r)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MN=200000+5;
const int P=1000000007;
using namespace std;
typedef long long ll;
template<typename T>T IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	in*=f;return in;
}
int n,X,Y,N,mn=INT_MAX,_mn,p;ll ans;
vector<int>v[MN];
ll fac[MN],inv[MN];
int c[MN],vis[MN],cnt;
ll qp(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%P)if(b&1)c=c*a%P;return c;}
void input(){
	IN(n),IN(X),IN(Y);fac[0]=1,N=200000;
	for(int i=1;i<=N;++i)fac[i]=fac[i-1]*i%P;
	inv[N]=qp(fac[N],P-2);
	for(int i=N;i>=1;--i)inv[i-1]=inv[i]*i%P;
	for(int i=1,x,y;i<=n;++i){
		IN(x),IN(y),v[x].push_back(y);
		if(y<=mn)p=x,_mn=mn,mn=y;
		else if(y<_mn)_mn=y;
	}
	for(int i=1;i<=n;++i)if(v[i].size()){
		sort(v[i].begin(),v[i].end());
		if(i!=p&&v[i][0]+mn<=Y)vis[i]=1;
		else if(i==p&&v[i][0]+_mn<=Y)vis[i]=1;
		if(vis[i]){
			cnt++;
			c[0]++;c[i]=1;
			for(int j=1;j<v[i].size();++j){
				if(v[i][j]+v[i][0]<=X)c[0]++,c[i]++;
				else if(i==p&&v[i][j]+_mn<=Y)c[0]++,c[i]++;
				else if(i!=p&&v[i][j]+mn<=Y)c[0]++,c[i]++;
			}
		}
	}
	ans=fac[c[0]];
	for(int i=1;i<=n;++i)if(vis[i]){
		ans=ans*inv[c[i]]%P;
	}
	printf("%lld\n",ans);
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    cin >> N;
    int H[100001] = {0};
    int mincost[100001] = {INF};
    rep(i, N) {
        int hi;
        cin >> hi;
        H[i] = hi;
    }

    mincost[0] = 0;
    mincost[1] = abs(H[0] - H[1]);

    for(int i = 2; i < N; i++) {
        mincost[i] = min(
            (mincost[i-1] + abs(H[i] - H[i-1])),
            (mincost[i-2] + abs(H[i] - H[i-2]))
        );
    }

    cout << mincost[N-1] << endl;
}


Measured memory_bytes: 1024
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def is_consistent(cx, cy, X, Y, H, N):
    h_proposal = None
    max_h = math.inf
    for i in range(N):
        if H[i] > 0:
            if h_proposal is not None and h_proposal != H[i]+abs(X[i]-cx)+abs(Y[i]-cy):
                return None
            h_proposal = H[i]+abs(X[i]-cx)+abs(Y[i]-cy)
        else:
            max_h = min(max_h, abs(X[i]-cx)+abs(Y[i]-cy))
    if h_proposal is not None and h_proposal <= max_h:
        return cx, cy, h_proposal

def solve():
    N = read_int()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = read_ints()
        X.append(x)
        Y.append(y)
        H.append(h)
    # h == max(H-abs(x-cx)-abs(y-cy), 0)
    for cx in range(101):
        for cy in range(101):
            answer = is_consistent(cx, cy, X, Y, H, N)
            if answer is not None:
                return answer


if __name__ == '__main__':
    print(*solve())


Measured memory_bytes: 74456
def solve(idx: int, l: list) -> None:
  if idx >= len(l)-1:
    res.append(sum(map(int, "".join(l).split("+"))))
    return
  solve(idx+1, l)
  copied = l.copy()
  copied.insert(idx+1, "+")
  solve(idx+2, copied)

S = list(input())
res = []
solve(0, S.copy())
print(sum(res))


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    rirep(i, n)
    {
        bool c = true;
        rep(j, i)
        {
            c = c && (s[n - i + j] == t[j]);
        }

        if (c)
        {
            cout << 2 * n - i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	LL n, r = 0;
	int x, m;
	std::cin >> n >> x >> m;
	std::vector<LL> s;
	std::vector<int> mp(m, -1);
	int d, id = 0, now = x;
	while (1) {
		if (mp[now] != -1) {
			d = id - mp[now];
			id = mp[now];
			break;
		}
		mp[now] = id;
		s.emplace_back(now);
		now = LL(now) * now % m;
		++id;
	}
	if (id >= n) {
		for (int i = 0; i < n; ++i) r += s[i];
		std::cout << r << std::endl;
		return 0;
	}
	for (int i = 0; i < id; ++i) r += s[i];
	n -= id;
	LL sd = 0;
	for (int i = 0; i < d; ++i) sd += s[id + i];
	r += (n / d) * sd;
	n %= d;
	for (int i = 0; i < n; ++i) r += s[id + i];
	std::cout << r << std::endl;
	return 0;
}

Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long int d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++){
    long long int x,y;
    cin >> x >> y;
    if (x*x+y*y <= d*d){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
def cross_section_area(data):
    area = 0;
    sections = [];
    stack = [];
    for i in range(len(data)):
        if data[i] == '\\':
            stack.append(i);
        elif data[i] == '/' and len(stack) > 0:
            j = stack.pop();
            section_area = i - j;
            area += section_area;
            while len(sections) > 0 and sections[-1][0] > j:
                section_area += sections[-1][1];
                sections.pop();
            sections.append([j, section_area]);
    print(area);
    print(len(sections), *[n[1] for n in sections]);

cross_section_area(input());


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 1010000;
long long fac[MAX], finv[MAX], inv[MAX];
bool initialized = false;

/**
 * @fn
 * This function must be called at first.
 */
void combination_init() {
    initialized = true;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

/**
 * @fn
 * Calculates the combination  ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ n ≤ 10^7
 * @return nCK % MOD
 */
long long combination(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/**
 * @fn
 * Calculates the factorial of the number.
 *
 * @return N! % MOD
 */
long long factorial(int n) {
    assert(initialized);
    if (n < 0) return 0;
    return fac[n] % MOD;
}

/**
 * @fn
 * Calculates the combination ( nCK % p: N choose K mod p).
 *
 * @brief constraint: 1 ≤ k ≤ 10^7 and 1 ≤ n ≤ 10^9
 * @return nCK % MOD
 */
long long combination2(int n, int k) {
    assert(initialized);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll res = 1;
    k = min(k, n - k);
    for (long long x = 1; x <= k; x++) {
        res *= (n - x + 1);
        res %= MOD;
        res *= inv[x];
        res %= MOD;
    }
    return res;
}

void Main() {
    ll X, Y;
    cin >> X >> Y;
    if (2 * X - Y >= 0 && 2 * Y - X >= 0 && (2 * X - Y) % 3 == 0 && (2 * Y - X) % 3 == 0) {
        combination_init();
        ll ans = combination((X + Y) / 3, (2 * X - Y) / 3);
        cout << ans << '\n';
    } else {
        cout << 0 << '\n';
    }

}

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


Measured memory_bytes: 23936
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

int main()
{
    dd a, b;
    cin >> a >> b;
    cout << fixed << std::left << setw(20) << setprecision(0) << floor(a * b) << endl;
}

Measured memory_bytes: 3796
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#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 REP(i, n) for (int i = 0; i < n; ++i)

int N, A, B;
int ans = 0;

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

  ans = min(A*N, B);

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


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<string> s(N);
    rep (i, N) {
        cin >> s[i];
    }

    ll ans = 0;
    rep (i, N) {
        for (ll j = 0; j < s[i].size()-1; j++) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') {
                ans++;
            }
        }
    }

    ll a = 0;
    ll b = 0;
    ll banda = 0;
    rep (i, N) {
        if (s[i].front() == 'B' && s[i].back() == 'A') {
            banda++;
        } else if (s[i].front() == 'B' && s[i].back() != 'A') {
            b++;
        } else if (s[i].front() != 'B' && s[i].back() == 'A') {
            a++;
        }
    }

    if (a == 0 && b == 0 && banda > 0) {
        cout << ans + min(a, b) + banda - 1 << endl;
    } else {
        cout << ans + min(a, b) + banda << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int MOD = 1000000007; 
int main(){
    string s;
    string va = "abcdefghijklmnopqrstuvwxyz";
    string vava = "A";
    cin >> s;
    set <char> vavava;
    for(int i = 0; i < s.size(); i++)
        vavava.insert(s[i]);
    auto itr = vavava.begin();
    for(int i = 0; i < va.size(); i++){
        if(va[i] != *itr){
            cout << va[i] << endl;
            return 0;
        }
        itr++;
    }
    cout << "None" << endl;
} 

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int ara[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		
		System.out.println(ara[scan.nextInt() -1]);
		
		
	}
	
}


Measured memory_bytes: 21844