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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

#define mp make_pair

int main() {
    int a, b;
    cin >> a >> b;
    string ab, ba;
    for (int i = 0; i < b; i++) {
        ab += std::to_string(a);
    }
    for (int i = 0; i < a; i++) {
        ba += std::to_string(b);
    }
    debug(ab);
    debug(ba);
    cout << min(ab, ba) << endl;
}

Measured memory_bytes: 256
// Problem : E - ∙ (Bullet)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int MOD = 1000000007;
ll modulo(ll a, ll b, ll n) {
  ll x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % n;  // multiplying with base
    }
    y = (y * y) % n;  // squaring the base
    b /= 2;
  }
  return x % n;
}

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    map<pii, int> mp;
    int ans = 0;
    rep(i, 0, n - 1) {
      cin >> a[i] >> b[i];
      if (a[i] == 0 && b[i] == 0) {
        ans = (ans + 1) % MOD;
        continue;
      }
      int sign = 1;
      if ((a[i] > 0 && b[i] < 0) || (a[i] < 0 && b[i] > 0)) {
        sign = -1;
      }
      a[i] = llabs(a[i]);
      b[i] = llabs(b[i]);
      int g = __gcd(a[i], b[i]);
      if (g != 0) {
        a[i] = a[i] / g;
        b[i] = b[i] / g;
      }
      if (b[i] == 0) sign = 1;
      a[i] = sign * a[i];
      pii p = {a[i], b[i]};
      // dbp(p);
      mp[p]++;
    }
    int temp = 1;
    for (auto it : mp) {
      pii p = it.first;
      int cnt = it.second;
      if (cnt == 0) continue;
      pii t;
      t.first = -p.second;
      t.second = p.first;
      int sign = 1;
      if ((t.first > 0 && t.second < 0) || (t.first < 0 && t.second > 0)) {
        sign = -1;
      }
      if (t.second == 0) sign = 1;
      t.first = llabs(t.first) * sign;
      t.second = llabs(t.second);
      // dbp(t);
      // if (!mp.count(t) || mp[t] == 0) continue;
      int cnt2 = mp[t];
      // db2(cnt, cnt2);
      temp =
          (temp * (modulo(2, cnt, MOD) + modulo(2, cnt2, MOD) - 1) % MOD) % MOD;
      mp[t] = 0;
    }
    ans = (ans + temp) % MOD;
    cout << (ans - 1LL + MOD) % MOD;
  }

  return 0;
}


Measured memory_bytes: 31320
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p)
{
    if (p == 0) return 1;
    if (p == 2 || (p & 1)) return mult(x, bin_pow(x, p - 1));
    return bin_pow(bin_pow(x, 2), p / 2);
}
ll rev(ll x)
{
    return bin_pow(x, MOD - 2);
}

const int N = 1010;
ll C[N][N];
ll dp[N];
ll f[N];
ll rf[N];
int n, a, b, c, d;

int main()
{
    for (int i = 0; i < N; i++)
        C[i][0] = C[i][i] = 1;
    for (int i = 1; i < N; i++)
        for (int j = 1; j < i; j++)
            C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);

    f[0] = 1;
    for (int i = 1; i < N; i++)
        f[i] = mult(f[i - 1], i);
    rf[N - 1] = rev(f[N - 1]);
    for (int i = N - 1; i > 0; i--)
        rf[i - 1] = mult(rf[i], i);

    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

    dp[n] = 1;
    for (int x = a; x <= b; x++)
    {
        for (int y = 0; y <= n; y++)
        {
            ll w = 1;
            for (int i = 1; i <= d && i * x <= n - y; i++)
            {
                w = mult(w, C[y + i * x][x]);
                if (i < c) continue;
                dp[y] = add(dp[y], mult(dp[y + i * x], mult(w, rf[i])));
            }
        }
    }
    printf("%lld\n", dp[0]);

    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
int main(){

  //input
  int N,W;
  cin >> N >> W;
  int A[N],B[N];
  for(int i=0;i<N;i++) cin >> A[i] >> B[i];
  
  //dp_setup
  //define:dp[i][j]=i番目までで重さj以下の最大価値
  long long dp[N+1][W+1];
  for(int i=0;i<N+1;i++) for(int j=0;j<W+1;j++) dp[i][j]=0;
  
  //dp_onwork
  for(int i=0;i<N;i++){
    for(int j=0;j<W+1;j++){
      if(j<A[i]) dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],dp[i][j-A[i]]+B[i]);
    }
  }
  
  //output
  
  cout << dp[N][W] << endl;

}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> zero;
    vector<int> enu;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        if (a == 0) zero.emplace_back(b);
        if (b == n - 1) enu.emplace_back(a);
    }
    sort(zero.begin(), zero.end());
    sort(enu.begin(), enu.end());
    vector<int> inter;
    set_intersection(zero.begin(), zero.end(), enu.begin(), enu.end(), inserter(inter, inter.end()));
    cout << (inter.empty() ? "IMPOSSIBLE" : "POSSIBLE") << endl;
}


Measured memory_bytes: 1276
#include<stdio.h>
int main(void){
  int a,b,i,gcm=1,lcm=1;
   while(scanf("%d %d",&a,&b) != EOF){
      gcm=1;lcm=1;
      for(i=2;(i<=a)||(i<=b);i++){
	if(a%i==0&&b%i==0){
	  gcm*=i;
	}
	if(a%i==0||b%i==0){
	  lcm*=i;
	}
	if(a%i==0){
	  a=a/i;
	}
	if(b%i==0){
	  b=b/i;
	}
	if(a%i==0||b%i==0){
	  i=1;
	}
      }
      printf("%d %d\n",gcm,lcm);
        }
    return 0;
}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n, k, q; cin >> n >> k >> q;
        vector<int> point(n);
        for (int i = 0; i < n; i++) {
                point[i] = k - q;
        }

        while (q--) {
                int a; cin >> a;
                point[a - 1]++;
        }

        for (int i = 0; i < n; i++) cout << (point[i] > 0 ? "Yes" : "No") << '\n';
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>

using namespace std;

struct Edge {
	int to, dist, maxV;
};
struct Node {
	int n, prev, v;
	double cost;
};
bool operator >(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

#define INF 1e9
#define EPS 1e-12

int main() {
	int N, M;
	while (cin >> N >> M, N || M) {
		int s, g; cin >> s >> g; --s, --g;

		vector< vector<Edge> > edges(N);
		for (int i = 0; i < M; ++i) {
			int x, y, d, c; cin >> x >> y >> d >> c; --x, --y;
			edges[x].push_back( (Edge){ y, d, c } );
			edges[y].push_back( (Edge){ x, d, c } );
		}

		double ans = INF;
		bool gone[30][30][31] = {0};
		priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push( (Node){s, -1, 0, 0} );
		while ( !Q.empty() ) {
			Node node = Q.top(); Q.pop();
			int n = node.n, prev = node.prev, v = node.v;
			double cost = node.cost;

			if (prev > -1) {
				if (gone[n][prev][v]) continue;
				gone[n][prev][v] = true;
			}

			if (n == g && v == 1) {
				ans = min(ans, cost);
				continue;
			}

			for (int dv = -1; dv <= 1; ++dv) {
				int nv = v+dv;
				if (nv <= 0) continue;
				for (int i = 0; i < edges[n].size(); ++i) {
					Edge& e = edges[n][i];
					if (nv <= e.maxV && e.to != prev) {
						Q.push( (Node){e.to, n, nv, cost+(double)e.dist/nv} );
					}
				}
			}
		}
		if (ans >= INF - EPS) cout << "unreachable" << endl;
		else printf("%.10f\n", ans);
	}
}

Measured memory_bytes: 21364
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		long x = sc.nextLong();
		
		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			System.out.println(x);
		}

		sc.close();
	}
	
}




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

int main()
{
    int n, a[105], count=0;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    for(int i=0; i<n; i+=2) {
        if(a[i]%2 != 0 )
            count++;
    }
    cout<< count << endl;
    return 0;
}


Measured memory_bytes: 3616
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

vs v;

int dfs(int &line, int depth) {
  if (v[line][depth] == '+') {
    int x = 0;
    line++;
    while (v[line].size() > depth + 1) x += dfs(line, depth + 1);
    return x;
  }
  if (v[line][depth] == '*') {
    int x = 1;
    line++;
    while (v[line].size() > depth + 1) x *= dfs(line, depth + 1);
    return x;
  }
  return v[line++][depth] - '0';
}

main {
  int n;
  while (cin >> n, n) {
    v.assign(n + 1, "");
    rep(i, n) cin >> v[i];
    int line = 0;
    cout << dfs(line, 0) << endl;
  }
}

Measured memory_bytes: 3208
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	if ((a/k+1)*k) <= b || a%k == 0 || b%k == 0 {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


Measured memory_bytes: 1752
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = input().rstrip()

lb = [0] * (N+1)
for i, c in enumerate(S, 1):
    lb[i] = lb[i-1] + (1 if c=='#' else 0)

ans = N + 100
bl = lb[-1]
for i in range(N+1):
    j = i+1
    left = lb[i]
    right = N - i - (bl - lb[i])
    ans = min(ans, left+right)
print(ans)



Measured memory_bytes: 17040
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
typedef long long int ll;
using namespace std;
int main(){
int N;
int flag=0;
cin >> N ;
for(int i=0; i<26;i++){
	for(int j=0;j<15;j++){
		if(N==(4*i+j*7)){
			flag=1;
			break;
		}
	}
	if(flag==1){
		break;
	}
}
if(flag==1){
	cout<<"Yes" << endl;
}else{
	cout<<"No" << endl;
}
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    int num[3] = {-1, -1, -1};
    int s, c;
    for (int i = 0; i < m; ++i) {
        cin >> s >> c;
        s--;
        if(num[s] != -1 && num[s] != c || (n > 1 && s == 0 && c == 0)){
            cout << -1 << endl;
            return 0;
        }
        else{
            num[s] = c;
        }
    }

    for (int i = 0; i < n; ++i) {
        if(num[i] == -1){
            if(n > 1 && i == 0){
                num[i] = 1;
            }
            else num[i] = 0;
        }
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += num[i] * pow(10, n-i-1);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import bisect

def main():
    a, b, q = map(int, input().split())
    s = [0 for _ in range(a)]
    for i in range(a):
        s[i] = int(input())
    t = [0 for _ in range(b)]
    for i in range(b):
        t[i] = int(input())
    x = [0 for _ in range(q)]
    for i in range(q):
        x[i] = int(input())

    ans = [10**18 for _ in range(q)]
    for i in range(q):
        next1 = bisect.bisect(s, x[i])
        if next1 > 0:
            d1 = x[i] - s[next1-1]
            next2 = bisect.bisect(t, s[next1-1])
            if next2 > 0:
                d2 = d1 + (s[next1-1] - t[next2-1])
                if d2 < ans[i]:
                    ans[i] = d2
            if next2 < b:
                d2 = d1 + (t[next2] - s[next1-1])
                if d2 < ans[i]:
                    ans[i] = d2
        if next1 < a:
            d1 = s[next1] - x[i]
            next2 = bisect.bisect(t, s[next1])
            if next2 > 0:
                d2 = d1 + (s[next1] - t[next2-1])
                if d2 < ans[i]:
                    ans[i] = d2
            if next2 < b:
                d2 = d1 + (t[next2] - s[next1])
                if d2 < ans[i]:
                    ans[i] = d2

        next1 = bisect.bisect(t, x[i])
        if next1 > 0:
            d1 = x[i] - t[next1-1]
            next2 = bisect.bisect(s, t[next1-1])
            if next2 > 0:
                d2 = d1 + (t[next1-1] - s[next2-1])
                if d2 < ans[i]:
                    ans[i] = d2
            if next2 < a:
                d2 = d1 + (s[next2] - t[next1-1])
                if d2 < ans[i]:
                    ans[i] = d2
        if next1 < b:
            d1 = t[next1] - x[i]
            next2 = bisect.bisect(s, t[next1])
            if next2 > 0:
                d2 = d1 + (t[next1] - s[next2-1])
                if d2 < ans[i]:
                    ans[i] = d2
            if next2 < a:
                d2 = d1 + (s[next2] - t[next1])
                if d2 < ans[i]:
                    ans[i] = d2

    for i in range(q):
        print(ans[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 20920
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD 1e9+7
#define SIZE (int)1e5+5
#define all(x) x.begin(),x.end()

#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back

#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

int64_t dp[(int)1e5+1][101];//(weight , n)
int weight[SIZE];
int64_t value[SIZE];

int64_t knapsack(int v,int n)
{
  if(v == 0)
    return 0;

  if(n == 0)
    return UINT_MAX;

  if( dp[v][n-1] != -1)
    return dp[v][n-1];

  if(value[n-1]<=v)
  {
    dp[v][n-1] = min( knapsack(v-value[n-1],n-1)+ weight[n-1], knapsack(v,n-1) );
  }
  else
    dp[v][n-1] = knapsack(v,n-1);

  //cout<<dp[v[n-1]<<"\n";
  return dp[v][n-1];
}
int ANS = 0;
map<pair<int,int>,bool> done;
void solve(int sum,int last,int w,int n)
{
   //cout<<"for sum:"<<sum<<"\nknapsack value is:"<<knapsack(sum,last)<<"\n";
   if(done.count(make_pair(sum,last)) )
      return;

   done[make_pair(sum,last)] = true;

   if( knapsack(sum,n) <=(int64_t)w){

      ANS=max(ANS,sum);
   }

   if(last == 0)
        return;

   solve(sum+value[last-1],last-1,w,n);
   solve(sum,last-1,w,n);
}

int main()
{
  IOfast;
  int q=1;
  //cin>>q;
  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n,w;
    cin>>n>>w;

    for(int i=0;i<n;i++)
      cin>>weight[i]>>value[i];

    solve(0,n,w,n);
    cout<<ANS;
  }

  return 0;
}


Measured memory_bytes: 228992
def main():

    N = int(input())
    info = []
    for _ in range(N):
        A, B = map(int, input().split())
        info.append([A, B])
    info.sort(key = lambda x: x[1])
    return info[0][0] + info[0][1]


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 21280
s = input()
n = 3
l = ["+", "-"]
# bit全探索
for i in range(2 ** n):
    pm = []
    tmp = ""
    ans = int(s[0])
    for j in range(n):
        if ((i >> j) & 1):
            pm.append(l[0])
        else:
            pm.append(l[1])
    for k in range(n):
        if pm[k] == "+":
            ans += int(s[k + 1])
        else:
            ans -= int(s[k + 1])
    if ans == 7:
        print(s[0]+pm[0]+s[1]+pm[1]+s[2]+pm[2]+s[3]+"=7")
        break

Measured memory_bytes: 3064
def main():
    S = int(input())
    h = S // 3600
    S %= 3600
    m = S // 60
    S %= 60
    s = S
    print(h,end = "")
    print(":",end = "")
    print(m,end = "")
    print(":",end = "")
    print(s,end = "")
    print()

if __name__ == "__main__":
    main()

Measured memory_bytes: 7788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BDistance {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, d; cin >> n >> d;
      d = d*d;
      int ret = 0;
      rep(i, n) {
        ll x, y; cin >> x >> y;
        if (x*x+y*y<=d) {
          ret++;
        }
      }
      cout << ret <<endl;
    }
};

signed main() {
  BDistance solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

// 1-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

long long n, q;

int main() {
  cin >> n >> q;
  auto f = [](long long l, long long r) { return l + r; };
  auto g = [](long long l, long long r) { return l + r; };
  auto h = [](long long l, long long r) { return l + r; };
  SegmentTreeLaze<long long, long long> seg(n, f, g, h, 0,
                                            0);
  for(int i = 0; i < n; ++i) seg.set_val(i, 0);
  for(int i = 0; i < q; ++i) {
    long long c, s, t, x;
    cin >> c >> s;
    --s;
    if(c) { cout << seg.query(s, s + 1) << endl; }
    else {
      cin >> t >> x;
      --t;
      seg.update(s, t + 1, x);
    }
  }
  return 0;
}


Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  map<string,int> memo;
  rep(i,s.size()){
    REP(j,1,6){
      if(i+j>s.size()) continue;
      string t = s.substr(i,j);
      //cout << t << endl;
      memo[t] = 1;
    }
  }

  vector<string> ret;
  int cnt = 0;
  FOR(it,memo){
    ret.push_back(it->first);
    cnt++;
    if(cnt >= 10) break;
  }
  
  cout << ret[K-1] << endl;
  
  return 0;
}


Measured memory_bytes: 1920
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        string w;
        for (; (w = Console.ReadLine()) != null;)
        {
            var k = new int[100];
            var d = new Dictionary<int, int>();
            string[] line = w.Trim().Split(' ');
            d[int.Parse(line[0])] = 1;
            d[int.Parse(line[1])] = 1;
            while (true)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line[0]);
                var b = int.Parse(line[1]);
                if (a == 0 && b == 0) break;
                if (d.ContainsKey(a)) d[a]++;
                else d[a] = 1;
                if (d.ContainsKey(b)) d[b]++;
                else d[b] = 1;
            }
            Console.WriteLine(check(d) ? "OK" : "NG");
        }
    }
    static bool check(Dictionary<int, int> d)
    {
        foreach (var x in d)
        {
            if (x.Key == 1 && x.Value % 2 == 0) return false;
            if (x.Key == 2 && x.Value % 2 == 0) return false;
            if (x.Key != 1 && x.Key != 2 && x.Value % 2 == 1) return false;
        }
        return true;
    }
}



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

using namespace std;

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

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

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

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

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

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

int n,m;
bool ketu[1024];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n)ketu[i+n-1]=false;
  REP(i,m){
    int a;
    scanf("%d",&a);
    ketu[a+n-1] = true;
  }
  int ans = 0;
  FORR(i,0,n-1){
    bool le = ketu[2*i+1];
    bool ri = ketu[2*i+2];
    if(le && ri){
      ketu[i] = true;
    }else{
      if(!le && !ri)ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;

typedef complex<double> P;

double cross(const P &a, const P &b){
  return imag(conj(a) * b);
}

double dot(const P &a, const P &b){
  return real(conj(a) * b);
}

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b, c) > 0) return 1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool intersectSS(const P &a, const P &b, const P &c, const P &d){
  return
    ccw(a, b, c) * ccw(a, b, d) <= 0 &&
    ccw(c, d, a) * ccw(c, d, b) <= 0;
}

double solve(vector<P> &A, vector<P> &B){
  int N = A.size();
  int M = B.size();
  double Bdist = abs(B[0] - B[1]);

  if(!intersectSS(A[0], A[1], B[0], B[1])){
    return abs(A[0] - A[1]) + Bdist;
  }

  double ans = -1;

  for(int i = 2; i < N; i++){
    if(!intersectSS(A[0], A[i], B[0], B[1]) &&
       !intersectSS(A[i], A[1], B[0], B[1])){
      double tmp = abs(A[0] - A[i]) + abs(A[i] - A[1]) + Bdist;

      if(ans == -1 || ans > tmp){
        ans = tmp;
      }
    }
  }

  for(int i = 2; i < N; i++){
    for(int j = 2; j < N; j++){
      if(i == j) continue;

      if(!intersectSS(A[0], A[i], B[0], B[1]) &&
         !intersectSS(A[i], A[j], B[0], B[1]) &&
         !intersectSS(A[j], A[1], B[0], B[1])){
        double tmp =
          abs(A[0] - A[i]) +
          abs(A[i] - A[j]) +
          abs(A[j] - A[1]) +
          Bdist;

        if(ans == -1 || ans > tmp){
          ans = tmp;
        }
      }
    }
  }

  return ans;
}

int main(){
  int N, M;
  vector<P> A, B;

  while(cin >> N >> M){
    A.clear();
    B.clear();

    for(int i = 0; i < N; i++){
      P p;
      cin >> p.real() >> p.imag();
      A.push_back(p);
    }

    for(int i = 0; i < M; i++){
      P p;
      cin >> p.real() >> p.imag();
      B.push_back(p);
    }

    double ans = solve(A, B);
    double tmp = solve(B, A);

    if(ans == -1 || tmp != -1 && ans > tmp){
      ans = tmp;
    }

    if(ans == -1){
      printf("-1\n");
    }
    else{
      printf("%.10f\n", ans);
    }
  }
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
  int N,M;
  cin >> N >> M;
  vec<intl> H(N);
  vec<bool> best(N,1);
  Rep(i,N){
    cin >> H.at(i);
  }
  vec< pair<int,int> > AB(M);
  Rep(i,M){
    cin >> AB.at(i).fi;
    AB.at(i).fi --;
    cin >> AB.at(i).se;
    AB.at(i).se --;
    if ( H.at( AB.at(i).fi ) >= H.at( AB.at(i).se ) ){
      best.at( AB.at(i).se ) =0;
    }
    if ( H.at( AB.at(i).fi ) <= H.at( AB.at(i).se ) ){
      best.at( AB.at(i).fi ) =0;
    }
  }
 
  int sum=0;
  Rep(i,N){
    sum += best.at(i);
  }
  cout << sum;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    map<ll, ll> A;
    vector<ll> X(N);
    REP(i,N){
        ll a;
        cin >> a;
        a--;
        A[a]++;
        X[i] = a;
    }

    ll sum = 0;
    for(auto&& p : A){
        ll a = p.second;
        sum += a * (a - 1) / 2;
    }

    REP(i,N){
        ll a = X[i];
        ll ans = sum;
        ans -= A[a] - 1;
        cout << ans << endl;
    }
    return 0;
}


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

ll k ;

int main(){
  cin >> k ;
  ll count = 1 ; 
  int seven = 7 ;
  while(seven % k != 0 && k % 2 != 0 && count <= 1000001){
    if(seven / k == 0){
      seven = seven * 10 + 7 ;
      count = count + 1 ;
    }
    else{
      seven = (seven % k) * 10 + 7 ;
      count = count + 1 ;
    }
  }
  if(k % 2 == 0 || count >= 1000000) cout << -1 << endl ;
  else cout << count << endl ;
}

Measured memory_bytes: 3528
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	ll n,a,b;
	cin >>n>>a>>b;

	ll r=n%(a+b);
	ll m=n/(a+b);
	ll c=min(a,r);	

	cout<< (m*a+c)<< endl;
	return 0;
}


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

using namespace std;


bool is_753(int num) {
        bool s = false, f = false, t = false;
        for(;num > 0; num /= 10) {
                switch(num % 10) {
                        case 3:
                                t = true;
                                break;
                        case 5:
                                f = true;
                                break;
                        case 7:
                                s = true;
                                break;
                        default:
                                return false;
                }
        }

        return s && f && t;
}

int next(int num) {
        int hoge = num / 1000;
        hoge *= 1000;
        int huga = num % 1000;
        int a[] = {333,335,337,353,355,357,373,375,377,533,535,537,553,555,557,573,575,577,733
                ,735,737,753,755,757,773,775,777};
        for(int i = 0; i < 26; i++) {
                if(huga == a[i]) return hoge + a[i+1];
        }
        return hoge + 1333;
}

int main() {
        int N;
        cin >> N;
        int out = 0;
        for(int i = 357; i <= N; i = next(i)) {
                if( is_753(i) == true) {
                        out++;
                }
        }

        cout << out << endl;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<ll> a(n, 0);
	vector<ll> ret(n, 0);
	rep(i, n) {
		cin >> a[i];
	}

	rep(i, n) {
		if(i % 2 == 0) {
			ret[0] += a[i];
		} else {
			ret[0] -= a[i];
		}
	}

	repd(i, 1, n) {
		ret[i] = (a[i-1] - ret[i-1] / 2) * 2;
	}

	cout << ret[0];
	repd(i, 1, n) {
		cout << " " << (ret[i]);
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 2944
fn main() {
    proconio::input! {
        n: usize,
    }
    let m=100;
    let mut c=vec![0;n];
    for i in 1..m {
        let v=i*i;
        if v>n {
            break;
        }
        for j in 1..m {
            let v=v+j*j+i*j;
            if v>n {
                break;
            }
            for k in 1..m {
                let v=v+k*k+i*k+j*k;
                if v>n {
                    break;
                }
                c[v-1]+=1;
            }
        }
    }
    for c in c{
        println!("{}",c);
    }
}

Measured memory_bytes: 2148
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
  if x < a[i]:
    b = a[:i]
    c = a[i:]
    break
if len(b) > len(c):
  print(len(c))
else:
  print(len(b))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int h,w,a[26];
char s[110][110];
int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;++i)
		scanf("%s",s[i]);
	for(int i=0;i<h;++i)
		for(int j=0;j<w;++j)
			a[s[i][j]-97]++;
	if(h%2==0&&w%2==0){
		for(int i=0;i<26;++i)if(a[i]%4!=0)
			return puts("No"),0;
		puts("Yes");
	} else if(h%2!=w%2){
		for(int i=0;i<26;++i)if(a[i]%2!=0)
			return puts("No"),0;
		int b[4]={0};
		for(int i=0;i<26;++i)b[a[i]%4]++;
		if(h%2)swap(h,w);
		if(b[2]>h/2)return puts("No"),0;
		if(h/2%2!=b[2]%2)return puts("No"),0;
		puts("Yes");
	} else {
		int flag=0;
		for(int i=0;i<26;++i)
			if(a[i]%2&&!flag)flag=i+1;
			else if(a[i]%2)return puts("No"),0;
		if(!flag)return puts("No"),0;
		a[flag-1]--;
		w/=2,h/=2;
		int b[4]={0};
		for(int i=0;i<26;++i)b[a[i]%4]++;
		if((w+h)%2!=b[2]%2)return puts("No"),0;
		if(b[2]>w+h)return puts("No"),0;
		if(w%2&&h%2&&b[2]<2)return puts("No"),0;
		puts("Yes");
	}
}

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

	vector<int>a(n);
	int sum=0;
	int t;
	string ans ="No";
	rep(i,n){
		cin >> t;
		sum+=t;
		if (sum>=h){
			ans="Yes";
			break;
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int data[100];
	int n;
	cin >> n;
	int cnt = 0;
	REP(i,n) cin >> data[i];
	REP(i,n-1){
		int minp,mindata;
		minp = i;
		mindata = data[i];
		FOR(j,i+1,n){
			if(mindata>data[j]){
				minp = j;
				mindata = data[j];
			}
		}
		if(data[i]!=mindata){
			cnt++;
			swap(data[i],data[minp]);
		}
	}
	REP(i,n){
		cout << data[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
	cout << cnt << endl;

}

Measured memory_bytes: 1160
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>  
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100+10;

int n; char a[N],b[N];

int main() {
    n=read(); scanf("%s%s",a+1,b+1);
    for (re int i=n;~i;--i) {
        int flag=1;
        for (re int j=n-i+1,k=1;k<=i;++j,++k)
            if (a[j]!=b[k]) { flag=0; break; }
        if (flag) { printf("%d\n",n+n-i); break; }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }

    Scanner kbd = new Scanner(System.in);
    int ans;
    int[][] map;

    void run(){
	int m = kbd.nextInt();
	while(m>0){
	    solve();
	    m--;
	}
    }

    void solve(){
	ans = 0;
	map = new int[5][5];
	for(int i=0; i<5; i++){
	    for(int j=0; j<5; j++){
		map[i][j] = kbd.nextInt();
	    }
	}
	// テ」ツδ榲」ツδε」ツδ療ヲツコツ姪・ツつ凖」ツ?禿」ツ?禿」ツ?セテ」ツ?ァ

	// テヲツ篠「テァツエツ「テ」ツ?禿」ツ?禿」ツ?凝」ツつ?
	int x=0, y=0, cnt=0;
	for(x=0; x<5; x++){
	    for(y=0; y<5; y++){
		int a = x;
		int b = y;
		for(int i=0; i<5; i++){
		    for(int j=0; j<5; j++){
			cnt = count(a, b, i, j);	
			//System.out.println(cnt+" "+ans);
			if(ans<cnt){
			    ans = cnt;	
			}
			cnt = 0;
		    }
		}
		
	    }
	}
	System.out.println(ans);
    }

    int count(int a, int b, int i, int j){
	boolean tf = true;
	for(int n=0; n<=i; n++){
	    for(int l=0; l<=j; l++){
		if(b+j>=5 || a+i>=5) tf = false;
		else if(map[b+l][a+n]==1){
		    //System.out.println(map[y+j][x+i]);
		}
		else tf = false;
	    }
	}
	if(tf)
	    return (i+1)*(j+1);
	else return -1;
    }
}

Measured memory_bytes: 26552
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,h,w;
  cin>>h>>w>>n;
  VVI sol(h,VI(w));
  in nxtc=0;
  in rmc=0;
  forn(i,h){
    forn(j,w){
      if(rmc==0){
	++nxtc;
	cin>>rmc;
      }
      --rmc;
      sol[i][j]=nxtc;
    }
    if(i%2==1){
      reverse(all(sol[i]));
    }
    forn(j,w)
      cout<<sol[i][j]<<" ";
    cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,val=0;
    scanf("%lld",&n);
    ll a[n];
    for (int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        val=val^a[i];
    }
    for (int i=0;i<n;i++)
    {
        ll ans=val^a[i];
        printf("%lld ",ans);
    }
    return 0;
}

Measured memory_bytes: 5240
from collections import deque
K = int(input())
q = deque([[1],[2],[3],[4],[5],[6],[7],[8],[9]])
cnt = 0
while cnt != K:
    nums = q.popleft()
    last = nums[-1]
    if last == 9:
        tmp = nums.copy()
        tmp.append(8)
        q.append(tmp)

        tmp = nums.copy()
        tmp.append(9)
        q.append(tmp)
    elif last == 0:
        tmp = nums.copy()
        tmp.append(0)
        q.append(tmp)

        tmp = nums.copy()
        tmp.append(1)
        q.append(tmp)
    else:
        tmp = nums.copy()
        tmp.append(last-1)
        q.append(tmp)

        tmp = nums.copy()
        tmp.append(last)
        q.append(tmp)

        tmp = nums.copy()
        tmp.append(last+1)
        q.append(tmp)

    cnt += 1
ans = 0
l = len(nums)
for i in range(l):
    ans += nums[i]*10**(l-i-1)
print(ans)

Measured memory_bytes: 45300
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  cin >> n >>d>>x;
  int tmp;
  int ans=x;
  for(int i=0;i<n;i++){
    cin >> tmp;
    ans+= (d-1)/tmp +1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";

signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int n, k; cin>>n>>k;
	int h[n+1];
	for(int i=1; i<=n; i++)
		cin>>h[i];
	
	int dp[n+1];
	fill(dp, dp+n+1, 1e9+8);
	dp[1] = 0;
	
	for(int i=1; i<=n; i++)
	{
		for(int j=i+1; j<=i+k && j<=n; j++)
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
	}
	cout<<dp[n]<<"\n";
	
	
return 0;
}

Measured memory_bytes: 1024
N,L=map(int,input().split())
dic={}

for _ in range(N):
    word=input()
    if not word in dic:
        dic[word]=1
    else:
        dic[word]+=1

ans=''

dic=sorted(dic.items())

for k,v in dic:
    for _ in range(v):
        ans+=k

print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<char> c(N);
  for (int i = 0; i < N; ++i) {
    cin >> c[i];
  }

  int red = 0;
  for (int i = 0; i < N; ++i) {
    if (c[i] == 'R') {
      ++red;
    }
  }

  int ans = 0;
  for (int i = 0; i < red; ++i) {
    if (c[i] == 'W') {
      ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588
using System;

namespace ABC159a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            int V = M + N;

            int comb = V * (V - 1) / 2;

            int ng = M * N;

            Console.WriteLine(comb - ng);
        }
    }
}


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

int main()
{
    long long a,b,c;
    cin >> a >> b >> c;
    if((a*b*c) % 2 == 0)
        cout << "0\n";
    else
        cout << min(a*b,min(b*c,c*a)) << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>

using namespace std;

int main()
{
	int *w, *b;
	char input[200001];
	string str;
	int n;
	int i;
	int ub, lb;
	int lmin;

	w = new int[200002];
	b = new int[200002];
	scanf("%d", &n);

	scanf("%s", input);

	str = input;

	for (i = n - 1; i >= 0; i--)
	{
		if (str[i] == '.')
		{
			break;
		}
	}

	ub = i;

	for (i = 0; i < n; i++)
	{
		if (str[i] == '#')
		{
			break;
		}
	}

	lb = i;

	w[0] = 0;
	b[ub - lb + 1] = 0;

	for (i = lb; i <= ub; i++)
	{
		if (str[i] == '#')
		{
			w[i - lb + 1] = w[i - lb] + 1;
		}

		else
		{
			w[i - lb + 1] = w[i - lb];
		}
	}

	for (i = ub; i >= lb; i--)
	{
		if (str[i] == '.')
		{
			b[i - lb] = b[i - lb + 1] + 1;
		}

		else
		{
			b[i - lb] = b[i - lb + 1];
		}
	}

	lmin = w[0] + b[0];

	for (i = 1; i <= ub - lb + 1; i++)
	{
		if (w[i] + b[i] < lmin)
		{
			lmin = w[i] + b[i];
		}
	}

	printf("%d\n", lmin);

	return 0;
}

Measured memory_bytes: 2176
/*input
3
2 3
1 1
3 2
*/
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
typedef long long int lld;
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define Error(x) cerr << #x << " = " << (x) <<endl;
#define Error2(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cerr<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cerr<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define popcount __builtin_popcountll
typedef pair<lld,lld> PA;
#define lim 1000010
#define lim2 3003
// inline lld sqr(lld x) { return x * x; }
// map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

lld B[lim],A[lim];
lld n,m,p,q;
string S[lim];

lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
bool bitSet(lld n,lld i){
    if((n&(1<<i))!=0) return true;
    else return false;
}

void mmod(long long int& cur) {
    while (cur >= mod) {
        cur -= mod;
    }
}


int main(){
    lld T,i,j,h,l,r,k,s,b,c,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,secondMin,indicator;
    sc(n);
    rep(i,1,n) sc2(A[i],B[i]);
    a=A[1];
    b=B[1];
    rep(i,2,n){
        c=((a-1)/A[i]+1)*A[i];
        d=((b-1)/B[i]+1)*B[i];
        t=max(c/A[i],d/B[i]);
        a=A[i]*t;
        b=B[i]*t;
        // Error2(a,b);
    }
    prL(a+b);
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++){
		cout<<i;
		if(i!=x+k-1)cout<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
A = list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(A)
for _ in range(M):
  heapq.heappush(A,((heapq.heappop(A)*-1)//2)*-1)

print(sum(A)*-1)

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using vi  = vector<int>;
using pii = pair<int,int>;

class UnionFind{
public:
  vi data;

  UnionFind(int size){
    data.resize(size,-1);
    //rep(i, size) data[i] = -1;
  }

  bool unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x != y){
      if(data[y] < data[x]) swap(x,y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

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

  int root(int x){ // どの集合か
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  int size(int x){
    return -data[root(x)];
  }
};

signed main(){
  int n, m; cin >> n >> m;
  vector<pii> q(m);
  rep(i,m){
    cin >> q[i].first >> q[i].second;
    q[i].first--;
    q[i].second--;
  }
  reverse(all(q));

  vi ans = {n*(n-1)/2};
  int c = 0;
  UnionFind uf(n);
  rep(i,m){
    if(not uf.find(q[i].first,q[i].second)){
      int tmpa = uf.size(q[i].first);
      int tmpb = uf.size(q[i].second);
      uf.unite(q[i].first,q[i].second);
      //c += tmpc*(tmpc-1)/2 - tmpa*(tmpa-1)/2 - tmpb*(tmpb-1)/2;
      c += tmpa * tmpb;
    }
    ans.push_back(ans[0] - c);
  }
  reverse(all(ans));
  FOR(i,1,m+1) cout << ans[i] << endl;
}


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

ll gyaku(ll a){
  ll d=1,e=1;
  r(i,15){
    d*=a;
    d%=1000000007;
  }
  r(i,66666667){
    e*=d;
    e%=1000000007;
  }
  return e;
}

int main() {
  ll x,y,a,b;
  cin >> x >> y;
  a=(2*x-y)/3;
  b=(2*y-x)/3;
  if(a+2*b!=y||b+2*a!=x||a<0||b<0){
   cout<<0<<endl;
  }
  else { ll A=1,B=1,C=1;
    a=(2*x-y)/3;
    b=(2*y-x)/3;
    r(i,a+b){
      C*=(i+1);
      C%=1000000007;
      if(i==a-1)A=C;
      if(i==b-1)B=C;
    }
    ll f = (C*gyaku(A)%1000000007)*gyaku(B)%1000000007;
    cout<<f<<endl;
       }
}


Measured memory_bytes: 256