akhauriyash/Code-Regression huggingface dataset:
// ALSD1_7_B Binary Tree
#include <iostream>
#include <algorithm>
#include <vector>
#define NIL -1
#define MAX 25+5
#define INF 100000000

struct Node {
    int depth = 0;
    int height = 0;
    int parent = NIL;
    int L_child = NIL;
    int R_child = NIL;
};

std::vector<Node> tree;

void SetNodeRelation(int node_num, int L_child, int R_child) {
    if (L_child != NIL) {
        tree.at(node_num).L_child = L_child;
        tree.at(L_child).parent = node_num;
    }
    if (R_child != NIL) {
        tree.at(node_num).R_child = R_child;
        tree.at(R_child).parent = node_num;
    }
}

void SetDepth(int node_num, int depth) {
    tree.at(node_num).depth = depth;
    if (tree.at(node_num).L_child != NIL) {
        SetDepth(tree.at(node_num).L_child, depth+1);
    }
    if (tree.at(node_num).R_child != NIL) {
        SetDepth(tree.at(node_num).R_child, depth+1);
    }
    return;
}

void SetHeight(int node_num, int height) {
    tree.at(node_num).height = std::max(tree.at(node_num).height, height);
    if (tree.at(node_num).parent != NIL) {
        SetHeight(tree.at(node_num).parent, height+1);
    }
}

void Output(int node_num) {
    std::cout << "node " << node_num << ": ";
    std::cout << "parent = " << tree.at(node_num).parent << ", ";
    
    int sibling = NIL;
    if (tree.at(node_num).parent == NIL) {
        /* pass */
    } else if (tree.at(tree.at(node_num).parent).L_child != NIL &&
        tree.at(tree.at(node_num).parent).L_child != node_num) {
        sibling = tree.at(tree.at(node_num).parent).L_child;
    } else if (tree.at(tree.at(node_num).parent).R_child != NIL &&
               tree.at(tree.at(node_num).parent).R_child != node_num) {
        sibling = tree.at(tree.at(node_num).parent).R_child;
    }
    std::cout << "sibling = " << sibling << ", ";

    int degree = 0;
    if (tree.at(node_num).L_child != NIL) {
        degree++;
    }
    if (tree.at(node_num).R_child != NIL) {
        degree++;
    }
    std::cout << "degree = " << degree << ", ";

    std::cout << "depth = " << tree.at(node_num).depth << ", ";
    std::cout << "height = " << tree.at(node_num).height << ", ";

    if (tree.at(node_num).parent == NIL) {
        std::cout << "root";
    } else if (degree != 0) {
        std::cout << "internal node";
    } else /* if (degree == 0) */ {
        std::cout << "leaf";
    } std::cout << "\n";
}

int main() {
    int total;
    std::cin >> total;
    tree.resize(total);
    
    int node_num, L_child, R_child;
    for (int i=0; i<total; i++) {
        std::cin >> node_num >> L_child >> R_child;
        SetNodeRelation(node_num, L_child, R_child);
    }

    for (int i=0; i<tree.size(); i++) {
        if (tree.at(i).parent == NIL) {
            SetDepth(i, 0);
            break;
        }
    }
    for (int i=0; i<tree.size(); i++) {
        if (tree.at(i).L_child == NIL &&
            tree.at(i).R_child == NIL) {
            SetHeight(i, 0);
        }
    }

    for (int i=0; i<total; i++) {
        Output(i);
    }
}


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

const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i, int j){
    if(i>j)swap(i,j);
    return id[i][j];
}
bool visited[MAXV];
bool calculated[MAXV];//ループ検出(計算途中か？)
int dp[MAXV];//max length of path from v
int dfs(int v){
    if(visited[v]){
        if(!calculated[v])return -1;
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for(int u : to[v]){
        int res = dfs(u);     
        if(res == -1)return -1;
        dp[v] = max(dp[v],res+1);
    }
    calculated[v] = true;
    return dp[v];
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n,vector<int>(n-1));
    rep(i,n){
        rep(j,n-1){
            cin>>a[i][j];
            a[i][j]--;
        }
    }
    int V = 0;
    //各試合にidを振る
    rep(i,n)rep(j,n){
        if(i<j){
            id[i][j] = V++;
        }
    }
    rep(i,n){
        rep(j,n-1){
            a[i][j] = toId(i,a[i][j]);//idに書き換え
        }
        rep(j,n-2){
            to[a[i][j]].push_back(a[i][j+1]);//辺を張る
        }
    }
    int ans = 0;
    //好きな頂点からdfs
    rep(i,V){
        int res = dfs(i);
        if(res == -1){
            puts("-1");
            return 0;
        }
        ans = max(ans,res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38528
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

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

    int n = s.length();

    ll sum = 0;
    for (int set = 0; set < (1 << (n - 1)); set++) {
        ll acc = 0;
        for(int i = 0; i < n; i++){
            acc = 10 * acc + (s[i] - '0');
            if(set & (1 << i)){
                sum += acc;
                acc = 0;
            }
        }
        sum += acc;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static long MOD = 1000000007L;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String s1 = in.readLine();
		String s2 = in.readLine();
		for (int i = 0; i < s1.length(); ++i) {
			if (s1.charAt(i) != s2.charAt(2 - i)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");

	}
}


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

main(void){
  vector<vector<int>> c(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c.at(i).at(j);
    }
  }
  int x[3],y[3];
  x[0]=0;
  for(int i=0;i<3;i++) y[i]=c[0][i]-x[0];
  for(int i=0;i<3;i++) x[i]=c[i][0]-y[0];
  bool good=true;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(c[i][j]!=x[i]+y[j]) good=false;
    }
  }
  if(good) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    print('#' * (W + 2))
    for a in A:
        print('#' + a + '#')
    print('#' * (W + 2))


if __name__ == "__main__":
    main()


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

int tall[50][50];

int main(){
    int W,H,T;
    cin>>W>>H>>T;
    int p;
    cin>>p;
    for(int i=0;i<p;i++){
        int x,y,t;
        cin>>x>>y>>t;
        tall[x][y]++;
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int s;
            cin>>s;
            ans+=tall[j][i]*s;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3096
Sa=input()
Sb=input()
Sc=input()
a,b,c=0,0,0
d='a'
for i in range(len(Sa)+len(Sb)+len(Sc)+3):
  if d=='a':
    if a==len(Sa):
      print('A')
      exit()
    d=Sa[a]
    a+=1
  elif d=='b':
    if b==len(Sb):
      print('B')
      exit()
    d=Sb[b]
    b+=1
  elif d=='c':
    if c==len(Sc):
      print('C')
      exit()
    d=Sc[c]
    c+=1

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int N;
vector<vector<int>> G;
vector<int> A;

void dfs(int u, int p) {
    if (p != -1) A[u] += A[p];

    for (auto nv : G[u]) {
        if (nv == p) continue;

        dfs(nv, u);
    }
}

int main() {
    int Q; scanf("%d %d", &N, &Q);
    G.resize(N);
    A.assign(N, 0);
    for (int i = 0; i < N - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < Q; i++) {
        int p, x; scanf("%d %d", &p, &x);
        p--;
        A[p] += x;
    }

    dfs(0, -1);

    for (int i = 0; i < N; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");

    return 0;
}

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

using namespace std;


long long n, ans;
int main()
{
  cin >> n;
  ans = n - 1;
  for (long long i = 1; i * i <= n; i++)
  if (n % i == 0) {
    ans = min(ans, i + n / i - 2);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


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

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,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;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        string s;
        cin>>s;
        ll n=s.size();
        ll ans=1;
        ll flag=0;
        REP(i,1,n)
        {
            if(s[i]==s[i-1]&&flag==0)
            {
                if(i==n-1) break;
                flag=1;
                ans++;
                i++;
            }
            else
            {
                flag=0;
                ans++;
            } 
        }
        cout<<ans;
    }

    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 2) cout << n + n;
    else cout << n;
}


Measured memory_bytes: 256
N, K = map(int,raw_input().split())
dict={K:0}
count = 0
k=bin(K)[2:]
a="111111111111111111111111111111" 
for i in k:
    if i == "1":
        dict[int(k[:count]+"0"+a[count+1:len(k)],2)] = 0
    count += 1
 
for i in range(0,N):
    a , b = map(int,raw_input().split())
    for j in dict:
        if j | a == j:
            dict[j] += b
        else:
            pass
        continue
M = 0
for i in dict:
    M = max(M,dict[i])
print M

Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
	int n;
	while(cin >> n) {
		if(n == -1) break;
		complex<double> t(1,0);
		rep(i, n - 1) {
			auto e = t * complex<double>(0,1);
			e /= abs(e);
			t += e;
		}
		printf("%lf\n%lf\n", t.real(), t.imag());
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;

bool is_prime(ll n) {
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      return false;
    }
  }

  return true;  
}

int main () {
  cin >> N;

  vector<int> sosu;

  rep(i, 5555) {
    int tmp = i * 10 + 1;
    if (is_prime(tmp)) sosu.push_back(tmp);
  }

  cout << 2 << " ";

  Rep(i, N-1) {
    cout << sosu[i] <<  " ";
  }

  cout << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdlib>
using namespace std;
struct Data{
	int x1,y1,x2,y2,cnt;
	Data(){}
	Data(int x1,int y1,int x2,int y2,int cnt):
		x1(x1),y1(y1),x2(x2),y2(y2),cnt(cnt){}
};
bool memo[50][50][50][50];
int dx[] = {0,1,-1,0}, dy[] = {1,0,0,-1};
int main() {
	int x,y;
	while(scanf("%d%d",&x,&y),(x|y)) {
		int tx,ty;
		int kx,ky;
		scanf("%d%d",&tx,&ty);
		scanf("%d%d",&kx,&ky);
		tx--;ty--;kx--;ky--;
		int stage[51][51];
		for(int i = 0; i < y; i++) {
			for(int j = 0; j < x; j++) {
				scanf("%d",&stage[i][j]);
			}
		}
		memset(memo,0,sizeof(memo));
		queue<Data> Q;
		Q.push(Data(tx,ty,kx,ky,0));
		int ans = -1;
		while(!Q.empty()) {
			Data d = Q.front();Q.pop();
			if(d.cnt >= 100) break;
			if(d.x1 == d.x2 && d.y1 == d.y2) {
				ans = d.cnt;
				break;
			}
			if(memo[d.x1][d.y1][d.x2][d.y2]) continue;
			memo[d.x1][d.y1][d.x2][d.y2] = true;
			for(int i = 0; i < 4; i++) {
				bool flg1 = false,flg2 = false;
				int nx1 = dx[i] + d.x1, ny1 = dy[i] + d.y1;
				int nx2 = dx[3-i] + d.x2, ny2 = dy[3-i] + d.y2;
				if(nx1 < 0 || nx1 >= x || ny1 < 0 || ny1 >= y || stage[ny1][nx1] == 1) flg1 = true;
				if(nx2 < 0 || nx2 >= x || ny2 < 0 || ny2 >= y || stage[ny2][nx2] == 1) flg2 = true;
				if(!(flg1 | flg2)) {
					Q.push(Data(nx1,ny1,nx2,ny2,d.cnt + 1));
				}
				if(!flg1 && flg2) {
					Q.push(Data(nx1,ny1,d.x2,d.y2,d.cnt+1));
				}
				if(flg1 && !flg2) {
					Q.push(Data(d.x1,d.y1,nx2,ny2,d.cnt+1));
				}
			}
		}
		if(ans == -1) puts("NA");
		else printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    ll C, D;
    cin>>A>>B>>C>>D;
    int n1 = (C + B - 1) / B, n2 = (A + D - 1) / D;
    cout<<(n1 <= n2 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <cassert>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <ctime>

using namespace std;

#define en '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const ll INFLL = 1e18;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int MAX_SIZE = 5e5;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

bool IS_ONE_TEST = 1;
ld START_TIME, TIME;

void fast_in_out() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

bool check(const vector<int> &a, const int &k, const int &m) {
    int cnt = 0;
    for (auto &i: a) {
        if (i > m) {
            cnt += ((i - 1) / m);
        }
    }
    return cnt <= k;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &i: a) {
        cin >> i;
    }
    int l = 0, r = *max_element(all(a));
    while (r - l > 1) {
        int m = (r + l) / 2;
        if (check(a, k, m)) {
            r = m;
        }
        else {
            l = m;
        }
    }
    cout << r << en;
}

int main() {
    START_TIME = clock();
    fast_in_out();
    int TESTS = 1;
    if (!IS_ONE_TEST) cin >> TESTS;
    while (TESTS--) { solve(); }
#ifdef __APPLE__
    TIME = (clock() - START_TIME) / CLOCKS_PER_SEC;
    cerr << en << TIME * 1000 << " ms." << en;
#endif
    return 0;
}

/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define lc (x<<1)  
#define rc (x<<1|1) 
#define mid (l+r)/2   
int const mod=998244353;  
int const N=2e5+10;  
int n,q,pw[N],v[N][10],t[N<<2],tag[N<<2];  
void build(int x,int l,int r){
	if(l==r) {
		t[x]=1LL*pw[n-r] % mod;  
		return ; 
	}  
	build(lc,l,mid); 
	build(rc,mid+1,r);  
	t[x]=(t[lc]+t[rc])%mod;  
}  
void pushdown(int x,int l,int r){
	if(!tag[x]) return ;  
	if(l==r) return ;  
	tag[lc]=tag[rc]=tag[x]; 
	t[lc]=(v[l][tag[x]]-v[mid+1][tag[x]]) % mod;  
	t[rc]=(v[mid+1][tag[x]]-v[r+1][tag[x]])  % mod;  
	t[lc]=(t[lc]+mod)% mod; 
	t[rc]=(t[rc]+mod)% mod;  
	tag[x]=0;  
}  
void update(int x,int l,int r,int ll,int rr,int d){ 
	pushdown(x,l,r); 
	if(ll<=l && r<=rr) { 
		tag[x]=d;  
		t[x]=(v[l][d]-v[r+1][d])  % mod;  
		t[x]=(t[x]+mod)%mod;  
		//cout<<x<<" "<<l<<" "<<r<<" "<<t[x]<<endl; 
		return ;  
	}  
	if(ll<=mid) update(lc,l,mid,ll,rr,d);  
	if(rr>mid) update(rc,mid+1,r,ll,rr,d);  
	t[x]=(t[lc]+t[rc])%mod;  
}   
int main(){
	ios::sync_with_stdio(false); 
	cin.tie(0);  
	cin>>n>>q; 
	pw[0]=1; 
	for(int i=1;i<=n;i++) 
		pw[i]=1LL*pw[i-1]*10% mod;  
	for(int i=1;i<10;i++)
		for(int j=n;j>=1;j--) 
			v[j][i]=(v[j+1][i]+1LL*i*pw[n-j]) % mod ; 
	build(1,1,n);  
	//cout<<t[1]<<endl; 
	while (q--){
		int l,r,d; 
		cin>>l>>r>>d; 
//		cout<<"nima"<<l<<" "<<r<<" "<<d<<endl;  
		update(1,1,n,l,r,d); 
		cout<<t[1]<<endl;  
	}  
	return 0; 
} 



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

int main() {
  int N;
  string s;
  cin >> N >> s;
  int a=0;
  int b=0;
  for(int i=0;i<N;i++){
    if(s[i]=='(')a++;
    else if(a==0)b++;
    else a--;
  }
  for(int i=0;i<b;i++)cout << '(';
  cout << s;
  for(int i=0;i<a;i++)cout << ')';
}



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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int a[n] = {};
  rep(i, q) {
    int x;
    cin >> x;
    ++a[--x];
  }
  rep(i, n) {
    if (k > q - a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char s;
  cin >> s;
  char d ;
  d = char(s+1);
  cout << d<<endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$A = trim(fgets(STDIN));
$B = trim(fgets(STDIN));
//list($a1,$a2,$a3) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));

for($i=1;$i<=3;$i++) {
  if ($i==$A || $i==$B) continue;
  printf("%d\n",$i);
}


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

int main() {
  int r;
  cin>>r;
 
  cout<<r*r<<endl;
  return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b&&b==c&&c==a)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    string S;
    cin >> S;
    ll K;
    cin >> K;

    char ans = '\0';
    for (int i = 0; i < (ll)S.size(); ++i) {
        if (S[i] != '1') {
            if (K - 1 < i) {
                ans = '1';
            }
            else {
                ans = S[i];
            }
            break;
        }
    }

    if (ans == '\0') ans = '1';

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
Imports System
Imports System.IO
Imports System.Collections.Generic

class Program
    shared sub main ()
        dim sw = new StreamWriter(Console.OpenStandardOutput())
        sw.AutoFlush = false
        Console.SetOut(sw)
        dim n = Int32.Parse(Console.ReadLine())
        dim sp() as String = Console.ReadLine().Split()
        dim a(n-1) as Int32
        dim b(n-1) as Int32
        dim t as Int32
        for i as Int32 = 0 to n-1
            Int32.TryParse(sp(i), t)
            a(i) = t
            b(i) = t
        next i
        Array.sort(b)
        dim x = n \ 2 - 1
        for i as Int32 = 0 to n-1
            if a(i) <= b(x) then
                Console.WriteLine(b(x + 1))
            else
                Console.WriteLine(b(x))
            end if
        next i
        Console.Out.Flush()
    end sub
end class

Measured memory_bytes: 45400
import time
MOD =  1000000007
MOD2 = 1000000005
MAX = 100001

facs = [1 for _ in range(MAX)]
inv = [1 for _ in range(MAX)]


for i in range(1, MAX):
	facs[i] = (facs[i-1] * i) % MOD

for i in range(1, MAX):
	inv[i] = pow(facs[i], MOD2, MOD)


def get_facs(x):
	return facs[x]


def get_inv(x):
	return inv[x]

def choose(n, k):

	if k==0 or n==k:
		return 1
	if n==0:
		return 0
	if k>n:
		return 0
	r = (get_facs(n)*get_inv(k)) % MOD
	r = (r*get_inv(n-k)) % MOD
	return r



def main():
	N, K = map(int, input().split())
	numbers = sorted(map(int, input().split()))
	if K==1:
		return 0
	if K==N:
		return abs(numbers[0] - numbers[-1])

	score = 0
	for i, x in enumerate(numbers):
		score += ((choose(i, K-1) - choose(N-1-i, K-1)) * x)

	return score%MOD
	
	
print(main())


Measured memory_bytes: 22188
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<vector<int>> match;
vector<vector<int>> to;
vector<int> memo;
vector<bool> calculated;
int dfs(int n) {
  if(memo[n]) {
    if(calculated[n])
      return memo[n];
    else
      return -1;
  }
  memo[n] = 1;
  rep(i, to[n].size()) {
    int res = dfs(to[n][i]);
    if(res == -1) return -1;
    chmax(memo[n], res+1);
  }
  calculated[n] = true;
  return memo[n];
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  rep(i, N) rep(j, N-1) {
    cin >> A[i][j];
    A[i][j]--;
  }
  match = vector<vector<int>>(N, vector<int>(N));
  int num = 0;
  rep(i, N) rep(j, N) {
    if(i < j) {
      match[i][j] = num;
      num++;
    }
  }
  to = vector<vector<int>>(N*(N-1)/2);
  rep(i, N) {
    rep(j, N-1) {
      int a = i, b = A[i][j];
      if(a > b) swap(a, b);
      A[i][j] = match[a][b];
    }
    rep(j, N-2)
      to[A[i][j+1]].push_back(A[i][j]);
  }
  memo = vector<int>(N*(N-1)/2);
  calculated = vector<bool>(N*(N-1)/2);
  int ans = 0;
  rep(i, N*(N-1)/2) {
    int res = dfs(i);
    if(res == -1) {
      cout << -1 << endl;
      return 0;
    }
    chmax(ans, res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 37504
#include<bits/stdc++.h>
#define ll long long
#define N 220005
using namespace std;
int a[N],n;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	if (a[1]!=0){
		printf("-1\n");
		return 0;
	}
	ll ans=0;
	for (int i=2;i<=n;i++){
		if (a[i]==a[i-1]+1) ans++; else
		if (a[i]>a[i-1]+1){
			printf("-1\n");
			return 0;
		} else ans+=a[i];
	}
	cout<<ans<<endl;
}

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

int main() {
  string S;
  cin >>S;
 if((S.at(0) == S.at(1) && S.at(2) == S.at(3) &&S.at(0) != S.at(2)) || (S.at(0) == S.at(2) && S.at(1) == S.at(3) &&S.at(0) !=S.at(1)) || (S.at(0) == S.at(3) && S.at(2) == S.at(1) && S.at(0) != S.at(2))) 
 {
  cout <<"Yes" <<endl; 
 }
     else {
      cout <<"No" << endl; 
     }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(m)]

    def is_ok(L):
        for s, c in query:
            if L[s - 1] != c:
                break
        else:
            print("".join(map(str, L)))
            exit()
        return

    def dfs(X):
        if len(X) == n:
            x = int("".join(map(str, X)))
            if len(str(x)) == n:
                is_ok(X)
            return

        for i in range(10):
            X.append(i)
            dfs(X)
            X.pop()

    dfs([])
    print(-1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  for(int i = 0; i <= 25; i++) {
    if(4 * i > N) {
      break;
    }
    for(int j = 0; j <= 15; j++) {
      if(4 * i + 7 * j > N) {
        break;
      }
      if(4 * i + 7 * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

const int C = 26;

int main() {
  string A;
  cin >> A;

  vector<int> N;
  for(auto& i: A) N.emplace_back(i - 'a');

  vector<set<int>> P(C);
  for(auto i=0; i<N.size(); ++i) P[N[i]].emplace(i);
  for(auto c=0; c<C; ++c) P[c].emplace(N.size());

  auto next = [&](auto i, auto c) {return *P[c].lower_bound(i);};

  vector<int> dp(N.size()+2, N.size());
  dp[N.size()+1] = 0;
  for(int i=N.size(); 0<=i; --i) for(auto c=0; c<C; ++c) dp[i] = min(dp[i], 1 + dp[1 + next(i, c)]);

  for(auto i=0; i<N.size(); ++i) for(auto c=0; c<C; ++c) if(dp[i] == 1 + dp[1 + next(i, c)]) {
    putchar(c + 'a');
    i = next(i, c);
    break;
  }
  cout << endl;
}


Measured memory_bytes: 11512
object Main {

	def main(arg:Array[String]) = {
		val list = scala.io.StdIn.readLine().split(" ").map(_.toInt).toList;
		val n = list(0);
		val m = list(1);
		val st1 = scala.collection.mutable.Set.empty[Int];
  		val st2 = scala.collection.mutable.Set.empty[Int];

		for(i <- (0 until m)) {
			val v = scala.io.StdIn.readLine().split(" ").map(_.toInt).toList; // (a, b)
			if (v(0) == 1) st1.add(v(1));
			if (v(1) == n) st2.add(v(0));
		}

		println(if ((2 to n - 1).exists(i => st1(i) && st2(i))) "POSSIBLE" else "IMPOSSIBLE");
	}

}


Measured memory_bytes: 74616
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;


void solve(){
    int N;
    cin >> N;

    if (N%1000 == 0) {
        cout << "0" << endl;
    }
    else {
        cout << 1000 - N%1000 << endl;
    }
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y,a,b,mins;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>y>>a>>b;
    if(a>=5&&b>=2){
      cout<<(x*a+y*b)*80/100<<endl;
    }else{
      mins=x*a+y*b;
      if(a<5) a=5;
      if(b<2) b=2;
      mins=min(mins,(x*a+y*b)*80/100);
      cout<<mins<<endl;
    }
  }
  return(0);
}



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

#define ll long long
//~ #define endl '\n'

void solve(){
	int x, y; cin>>x>>y;
	if(x == y){
		cout<<-1<<endl;
	}else if(x > y){
		if(x%y == 0){
			cout<<-1<<endl;
		}else{
			cout<<x<<endl;
		}
	}else{
		cout<<x<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int ty = 1; //cin>>ty;
	while(ty--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}


ll mod = 1000000007;

signed main()
{
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    rep(i, k + 1)
    {
        rep(j,k+1){
            if(0<=s-i-j && s-i-j<=k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF=1LL<<60;
int main(){
    string s;cin >> s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;

	puts(a + b >= c ? "Yes" : "No");

	return 0;
}

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

int main() {
  int p[9];
  for (int i = 0; i < 9; ++i) {
    scanf("%d", &p[i]);
  }

  int a[3],b[3];
  a[0] = 0;
  a[1] = p[3] - p[0];
  a[2] = p[6] - p[0];
  b[0] = p[0];
  b[1] = p[1];
  b[2] = p[2];

  if(p[4]==a[1]+b[1] && p[5]==a[1]+b[2] && p[7]==a[2]+b[1] && p[8]==a[2]+b[2]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long ab = A+B;
        System.out.println(N/ab*A + Math.min((N%ab),A));
    }

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


Measured memory_bytes: 23764
#include <stdio.h>

int main()
{
	int a,b[101],i,j,tmp,alice=0,bob=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&b[i]);
		j=i;
		while(b[i-1]>=b[i]){
			if(i==0)break;
			tmp=b[i];
			b[i]=b[i-1];
			b[i-1]=tmp;
			i=i-1;
		}
		i=j;
	}
	
	for(i=0;i<a;i++){
		if(i%2==0)alice=alice+b[i];
		else bob=bob+b[i];
	}
	
	printf("%d\n",abs(alice-bob));
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 1; i < N; i++) {
        cnt += (N - 1) / i;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[3],val;
bool cmp(int s1,int s2){return s1>s2;}
int main()
{
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3,cmp);
    int cont=a[0]-a[1];
    if((a[0]-a[2]-cont)%2)val++;
    val+=(a[0]-a[2]-cont+1)/2;
    printf("%d",val+cont);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int32_t n;
  cin >> n;

  int64_t dp[2][3]{{0, 0, 0}, {0, 0, 0}};

  rep(i, n) {
    int32_t a, b, c;
    cin >> a >> b >> c;

    dp[i % 2][0] = max(dp[(i + 1) % 2][1], dp[(i + 1) % 2][2]) + a;
    dp[i % 2][1] = max(dp[(i + 1) % 2][0], dp[(i + 1) % 2][2]) + b;
    dp[i % 2][2] = max(dp[(i + 1) % 2][0], dp[(i + 1) % 2][1]) + c;
  }

  cout << max(max(dp[(n + 1) % 2][0], dp[(n + 1) % 2][1]), dp[(n + 1) % 2][2]);
}

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

int main(void)
{
        int n,i,c=0;
        char s[200010];

        scanf("%s",s);
        n=strlen(s);
        for(i=0;i<n;i++)
                c+=s[i]-'0';
        if(c%9==0)printf("Yes\n");
        else printf("No\n");
        return 0;
}


Measured memory_bytes: 1796
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int p[101010],q[101010];
int main()
{
	int h,w,st1=1,st2=1;
	long long ans=0;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		scanf("%d",&p[i]);
		ans+=p[i];
	}
	for(int i=1;i<=w;i++)
	{
		scanf("%d",&q[i]);
		ans+=q[i];
	}
	sort(p+1,p+1+h);
	sort(q+1,q+1+w);
	while(st1<=h&&st2<=w)
	{
		if(p[st1]<=q[st2])
		{
			ans+=(long long)p[st1]*(w-st2+1);
			st1++;
		}
		else
		{
			ans+=(long long)q[st2]*(h-st1+1);
			st2++;
		}
	}
	printf("%lld",ans);
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll A,B;
    string S;
    cin >> A>>B;

    if(A+B>=24){
        cout << A + B - 24 << endl;
    }
    else{
        cout << A + B << endl;
    }
}


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

int main(void)
{
	double q;
	double x;
	
	while (scanf("%lf", &q), q != -1){
		x = q / 2.0;
		while (fabs(x * x * x - q) >= 0.00001 * q){
			x = x - ((x * x * x - q) / (3 * x * x));
		}
		
		printf("%lf\n", x);
	}
	
	return (0);
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string s; cin >> s;
 
	int res = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == '+') {
			++res;
		} else {
			--res;
		}
	}
	cout << res << endl;
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    repl(i, 1, n + 1) {
        int v = i / 10000;
        int w = (i - (i / 10000) * 10000 ) / 1000;
        int x = (i - (i / 1000) * 1000) / 100;
        int y = (i - (i / 100) * 100) / 10;
        int z = i % 10;
        int sum = v + w + x + y + z;
        if(sum >= a && sum <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
   int N, K, count = 0, number;
   cin >> N >> K;
   int d;
   int array[N];
   for(int i = 0; i < N; i++){
       array[i] = 0;
   }
   vector<int> A;
   for(int i = 0; i < K; i++){
       A.resize(0);
       cin >> d;
       for(int j = 0; j < d; j++){
           cin >> number;
           A.push_back(number);
           array[A[j] - 1]++;
       }
   }
   for(int i = 0; i < N; i++){
       if(array[i] == 0){
           count++;
       }
   }
   cout << count << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 ) + 7;
 
bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{
    int64_t a,b,c,d,e;
    std::string bb;
    std::cin>> bb;

    for( int i = 0; i < bb.size(); i++ )
    {
        std::cout<< "x";
    }
}



Measured memory_bytes: 256
from math import sqrt
n=int(input())
def judge(x):
	for i in range(2,int(sqrt(x))+1):
		if x%i == 0:
			return False
		else:
			continue
	return True
for i in range(n,1+10**6):
	if judge(i):
		print(i)
		exit(0)
	else:
		pass
print('error')

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

main()
{
  int tmp,c,i,j,s[3],n;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
   
      scanf("%d %d %d",&s[0],&s[1],&s[2]);
   
   
      for(c=0;c<3;c++){
	for(j=0;j<2;j++){
	  if(s[j]<s[j+1]){
	    tmp=s[j+1];	 
	    s[j+1]=s[j];
	    s[j]=tmp;
	  }
	}
      }

      if(pow(s[0],2)==pow(s[1],2)+pow(s[2],2)){
	printf("YES\n");
      }else{
	printf("NO\n");
      }

      

    }



  return 0;

}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll a;
        cin>>a;
        cout<<(a + a*a +  a*a*a)<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int solve() {
  int a, b, c; scanf("%d%d%d", &a, &b, &c);
  int h[10] = {};
  ++h[a]; ++h[b]; ++h[c];
  for (int i = 1; i < 10; ++i) if (h[i] == 2) return !printf("Yes");
  return !printf("No");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3736
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 136 -C
#define MAX 100000
//#define MAX 101


int main(void) {
	int i, n, h[100000];

	scanf("%d", &n);
	for(i=0;i<n;i++)
	    scanf("%d", &h[i]);
	for (i = n-1; i > 1; i--) {
		if (h[i] >= h[i-1])continue;
		if (h[i] -  h[i - 1] == -1) { h[i - 1]--; continue; }
	    printf("No\n"); return 0;
	}
	printf("Yes\n");
	return 0;
}


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

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

    vector<int> p(n);
    rep (i, n)
        cin >> p[i];

    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.end() - 1, p[n - 1] / 2) << endl;
    return 0;
}

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

int x, y;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    scanf("%d %d", &x, &y);
    printf("%d\n", (4 - x > 0 ? 4 - x : 0) * 100000 + (4 - y > 0 ? 4 - y : 0) * 100000 + (x == 1 && y == 1 ? 400000 : 0));

	return 0;
}


Measured memory_bytes: 256
loop do
    n, d = gets.split.map(&:to_i)
    break if n == 0

    a = (1..n).map { m = gets.split.map(&:to_i)[1..-1]; [m.inject(:+) || 0, *m]}

    l = a.map(&:first).min
    a.each do |c|
        while c[0] > l && c[0] - c[-1] >= l
            c[0] -= c.pop
        end
    end

    if a == [[0]] * n
        puts 'Yes'
        next
    end

    stack = [a]
    reached = {l => 1}

    ok = false
    until stack.empty?
        state = stack.pop
        (0..n-1).each do |i|
            next if state[i].size == 1
            l = state[i][0] - state[i][-1]
            next if reached[l]
            new_state = state.map{|c| c.dup}
            new_state[i][0] -= new_state[i].pop
            h = new_state.map(&:first).max 
            next if h - l > d

            if l == 0
                ok = true
                stack = []
                break
            end 
            reached[l] = 1

            new_state.each do |c|
                while c[0] > l && c[0] - c[-1] >= l
                    c[0] -= c.pop
                end
            end

            stack << new_state
        end
    end

    puts ok ? 'Yes' : 'No'
end

Measured memory_bytes: 111040
def bubbleSort(A, N):
    flag = True
    while flag:
        flag = False
        for j in range(N-1,0,-1):
            if A[j][-1:] < A[j-1][-1:]:
                A[j],A[j-1] = A[j-1],A[j]
                flag = True
    return A

def selectionSort(A, N):
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j][-1:] < A[minj][-1:]:
                minj = j
        if A[i][-1:] != A[minj][-1:]:
            A[i],A[minj] = A[minj],A[i]
    return A
    
def isStable(st,list2):
    for i in range(1,len(st)):
        if list2[i][-1:] == list2[i-1][-1:]:
            if st[i] != list2[i]:
                return "Not stable"
    return "Stable"
    
num = int(input())
li1 = input().split()
stli = bubbleSort(li1[:],num)
li2 = bubbleSort(li1[:],num)
print(*li2,sep=" ")
print(isStable(stli,li2))
li3 = selectionSort(li1[:],num)
print(*li3,sep=" ")
print(isStable(stli[:],li3))


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

int main() {
 int x,stl=0,ans;
 cin >> x;
if(x!=1){
 for(int k=2;k<=x;k++){
  for(int i=1;i<32;i++){
    for(int j=2;j<10;j++){
      if(pow(i,j)==k){

         stl=max(k,stl);
      }
    }
  }
 }
}
else{
  stl=1;
}

  cout << stl << endl;
}


Measured memory_bytes: 256
def main(): 

    N = int(input())
    d = sorted(map(int, input().split()))

    low_middle = len(d) // 2 - 1
    high_middle = len(d) // 2

    if d[low_middle] == d[high_middle]:
        print('0')
    else:
        print( d[high_middle] - d[low_middle])




if __name__ == "__main__":
    main() 

Measured memory_bytes: 13992