akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll X;
    cin >> X;
    int cnt = X / 100;
    if(X - cnt * 100 > 5 * cnt) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

def list_split(list_in):
    list_out=[];
    ind=0
    for i in range(len(list_in)):
        if (list_in[i]==0):# & sum(list_in[ind:i])>0:
            if sum(list_in[ind:i])>0:
                list_out.append(list_in[ind:i])
            ind=i+1

        if i==(len(list_in)-1):
            if sum(list_in[ind:i+1])>0:
                list_out.append(list_in[ind:i+1])
    return(list_out)


import numpy as np

def count_min(list_in):
    count = 0
    out_list=[]
    for i in list_in:
        tmp_count=min(i)
        tmp=list(np.array(i)-min(i))
        tmp=list_split(tmp)
        if tmp!=[[]]:
            out_list.extend(tmp)
        count=count+tmp_count
    return(count,out_list)

check=0
total_count=0
new_list=list_split(a)
while check==0:
    tmp_count,new_list=count_min(new_list)
    total_count=total_count+tmp_count
    if len(new_list)==0:
        break
    
    
print(total_count)   
    

Measured memory_bytes: 12444
import java.util.*;

class Main{
 	public static void main(String... args){
    	String s = new Scanner(System.in).next();
    	System.out.println(s.matches("hi") || s.matches("hihi") || s.matches("hihihi") || s.matches("hihihihi") || s.matches("hihihihihi") ? "Yes" : "No");
    }
}

Measured memory_bytes: 22100
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
int main(){
	ll ans=0, sum=0;
	int n=read();
	for (int i=1;i<=n;i++){
		int x=read();
		ans+=sum*x%mo;
		sum=(sum+x)%mo;
	}
	cout<<ans%mo<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main()
{
  long long int N, K;

  cin >> N >> K;

  vector< pair< int, int > > arr(N);

  for(int i = 0; i < N; i++) {
    cin >> arr[i].first >> arr[i].second;
  }

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

  long long int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(cnt + arr[i].second >= K) {cout << arr[i].first << endl; return 0;}
    cnt += arr[i].second;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int mxN = 1e5 + 5;
vector<int> adj[mxN];
int depth[mxN];
int dfs(int Node) {
	int &ret = depth[Node];
	if(ret != -1)
		return ret;
	if(!adj[Node].size())
		return ret = 0;
	int maxi = 0;
	for(int x : adj[Node]) {
		maxi = max(maxi, 1 + dfs(x));
	}
	return ret = maxi;
}

int main() {
	int n, m;
	cin >> n >> m;
	while(m--) {
		int f, t;
		cin >> f >> t;
		adj[f].push_back(t);
	}
	memset(depth, -1, sizeof depth);
	int answer = 0;
	for(int i = 1; i <= n; ++i) {
		dfs(i);
		answer = max(answer, depth[i]);
	}
	cout << answer;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)


//----------------------------------
//----------------------------------

signed main()
{
    ios::sync_with_stdio(false);
	int h,w;
	int sharp = 0;
	cin >> h >> w;
	vector<vector<char>> a;
	a.push_back(vector<char>(w+2, '.'));
	h++;
	REP(i, 1, h)
	{
		a.push_back(vector<char>());
		a[i].push_back('.');
		REP(j, 0, w)
		{
			char tmp;
			cin >> tmp;
			a[i].push_back(tmp);
			sharp += tmp == '#';
		}
		a[i].push_back('.');
	}
	a.push_back(vector<char>(w+2, '.'));
	h--;

	bool possible = true;
	int nx = 1;
	int ny = 1;
	int count = 1;

	while(true)
	{
		/* cerr << nx << ';' << ny << '\n'; */
		if(nx == h && ny == w)
			break;
		else if(a[nx+1][ny] == '#')
		{
			if(a[nx][ny+1] == '#')
			{
				possible = false;
				break;
			}
			nx++;
			count++;
		}
		else if(a[nx][ny+1] == '#')
		{
			ny++;
			count++;
		}
		else
		{
			possible = false;
			break;
		}
	}
	if(count != sharp)
		possible = false;
	cout << (possible ? "Possible\n" : "Impossible\n");

}


Measured memory_bytes: 256
def main():
    sx, sy, tx, ty = list(map(int, input().split()))
    dx = tx - sx
    dy = ty - sy
    ans = ''
    # 行き1
    ans += 'U' * dy + 'R' * dx
    # 帰り1
    ans += 'D' * dy + 'L' * dx
    # 行き2
    ans += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
    # 帰り2
    ans += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
    # 答え
    print(ans)
    

if __name__ == "__main__":
    main()


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

using namespace std;
#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll ans=0;
    priority_queue<ll> pq;
    int n,k; cin>>n>>k;
    for(int i=0;i<n;i++){
        ll x; cin>>x;
        pq.push(-x);
    }
    int kk=max(n-k,0);
    while(kk--){
        ll t=-pq.top(); pq.pop();
        ans+=t;
    }
    cout<<ans;
    return 0;
}

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

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

using namespace std;

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

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

ll gcd(ll a, ll b){ // assume a <= b
    if(a > b)
        return gcd(b, a);
    if(b % a == 0 || a == 1 || a == 0)
        return a;
    else
        return gcd(b % a, a);
}

int main() {
    ll N, X;
    cin >> N >> X;
    ll x, idx = 0; vector<ll> xs(N);
    while(cin >> x){
        xs[idx] = abs(x - X); idx++;
    }
    
    ll res = xs[0];
    for (ll i = 1; i < xs.size(); i++) {
        res = gcd(res, xs[i]);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1024
import itertools
S = input()
opt_list = list(itertools.product([0, 1], repeat=3)) #0:+を入れる, 1:-を入れる
res_opt = ['+', '+', '+']
for opt in opt_list:
    tmp = int(S[0])
    for i in range(3):
        if opt[i] == 0:
            tmp += int(S[i + 1])
            res_opt[i] = '+'
        else:
            tmp -= int(S[i + 1])
            res_opt[i] = '-'
    
    if tmp == 7:
        res = S[0] + res_opt[0] + S[1] + res_opt[1] + S[2] + res_opt[2] + S[3] + '=7'
        
print(res)

Measured memory_bytes: 3316
a,b=input().split()
a=int(a)
b=int(b)
choose=0
if a<b:
  choose+=b
  b-=1
else:
  choose+=a
  a-=1
if a<b:
  choose+=b
  b-=1
else:
  choose+=a
  a-=1
print(choose)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
long N, D, A, i, j, t, X, H, G, M=0, ans=0; cin >> N >> D >> A; vector< pair<long, long> > V;
for(i=0; i<N; i++){ scanf("%ld %ld", &X, &H); G=(H+A-1)/A; M=max(M, G); V.push_back(make_pair(X, G)); }
sort(V.begin(), V.end());
if(V[0].first+2*D>=V[N-1].first){ ans=M; }
else{
for(i=0; i<N; i++){ 
  if(V[i].second<=0){ continue; }
  for(t=V[i].first+2*D, j=i+1; j<N; j++){ if(V[j].first<=t){ V[j].second-=V[i].second; }else{ break; } }
  ans+=V[i].second;
}
}
cout << ans << "\n";
}

Measured memory_bytes: 6256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n;cin >>n;
  vector<ll> l(n);
  rep(i,n)cin >>l[i];
  ll ans =0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[k]+l[j]>l[i]){
          if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
          ans++;
         // cout <<i<<j<<k<<endl;
          }
        }
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3636
'use strict';

const receive = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\s/);

const main = input => {
  const [a, b, c, ...rest] = input.map(x => Number(x));
  const ans = (a * b * c === 175 && a + b + c === 17) ? 'YES' : 'NO';
  console.log(ans);
};

main(receive);



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

using namespace std;

int main()
{   
    int h,n,sum=0;
    cin >> h >> n;
    rep(i,n){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum>=h)
        cout << "Yes";
    else
        cout << "No";
    return 0;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 1e5, maxm = 2e5;
const int md = 1e9 + 7;

struct Edge {
    int u, v, dd;
    Edge() {}
    Edge(int _u, int _v, int _dd) { u = _u, v = _v, dd = _dd; }
} edge[maxm + 5];

int n, m, S, T;
vector<pii> G[maxn + 5];
LL dist1[maxn + 5], dist2[maxn + 5], cnt1[maxn + 5], cnt2[maxn + 5];

void Run(int ss, LL* dist, LL *cnt) {
    for(int i = 1; i <= n; ++i) dist[i] = 1LL << 60, cnt[i] = 0;
    priority_queue<pair<LL,int>> que;
    dist[ss] = 0, cnt[ss] = 1, que.push(MP(0LL,ss));
    while(!que.empty()) {
        pair<LL,int> x = que.top(); que.pop();
        if(-x.fi != dist[x.se]) continue;
        for(auto it : G[x.se]) {
            if(-x.fi + it.se < dist[it.fi]) {
                dist[it.fi] = -x.fi + it.se, cnt[it.fi] = cnt[x.se];
                que.push(MP(-dist[it.fi],it.fi));
            }
            else if(-x.fi + it.se == dist[it.fi])
                cnt[it.fi] = (cnt[it.fi] + cnt[x.se]) % md;
        }
    }
}

int main() {
    scanf("%d%d%d%d", &n, &m, &S, &T);
    for(int i = 1, u, v, d; i <= m; ++i) {
        scanf("%d%d%d", &u, &v, &d);
        edge[i] = Edge(u,v,d);
        G[u].PB( MP(v,d) );
        G[v].PB( MP(u,d) );
    }
    Run(S, dist1, cnt1);
    Run(T, dist2, cnt2);
    LL ans = (cnt1[T] - 1 + md) % md * cnt1[T] % md;
    for(int i = 1; i <= n; ++i)
        if(dist1[i] == dist2[i] && (dist1[i] << 1) == dist1[T]) {
            LL tmp = cnt1[i] * cnt2[i] % md;
            ans = (ans - (tmp-1+md) % md * tmp % md + md) % md;
        }
    for(int i = 1; i <= m; ++i) {
        int u = edge[i].u, v = edge[i].v, d = edge[i].dd;
        if(abs(dist1[u]-dist2[v]) < d && dist1[u] + d + dist2[v] == dist1[T]) {
            LL tmp = cnt1[u] * cnt2[v] % md;
            ans = (ans - (tmp-1+md) % md * tmp % md + md) % md;
        }
        u = edge[i].v, v = edge[i].u;
        if(abs(dist1[u]-dist2[v]) < d && dist1[u] + d + dist2[v] == dist1[T]) {
            LL tmp = cnt1[u] * cnt2[v] % md;
            ans = (ans - (tmp-1+md) % md * tmp % md + md) % md;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 17492
#include <iostream>
#include <vector>
using namespace std;
int main() {
    string moji;
    char ans[3];
    char buf;
    int count = 0;
    cin >> moji;
    for (int i = 0; i <moji.size() ; ++i) {
        if(i == 0){
           ans[0] = moji[i];
        }
        if(i != 0 && i != moji.size() - 1){
            count++;
        }
        if(i == moji.size() -1){
            ans[1] = moji[i];
        }
    }
    cout << ans[0] << count << ans[1] << endl;
}

Measured memory_bytes: 256
while True:
    L = input()
    if L == 0:
        break
    n = 2
    ans = 1
    while n * n <= L:
        if L % n == 0:
            S = 0
            while L % n == 0:
                L /= n
                S += 1
            ans *= S * 2 + 1
        n += 1

    if L != 1:
        ans *= 3

    print ans / 2 + 1


Measured memory_bytes: 4648
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if(op.equals("+")) System.out.println(a+b);
		else System.out.println(a-b);
	}
}

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

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(lambda x: int(x)-1, input().split())) for N in range(N)]
val = [[0] * C for _ in range(3)]
for i in range(N):
    for j in range(N):
        for k in range(C):
            val[(i + j) % 3][k] += D[c[i][j]][k]
ans = float('inf')
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            ans = min(ans, val[0][i] + val[1][j] + val[2][k])
print(ans)

Measured memory_bytes: 44764
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] t = new int[N];
    int[] x = new int[N];
    int[] y = new int[N];

    for (int i = 0; i < N; i++) {
      t[i] = sc.nextInt();
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }

    sc.close();

    String result = "Yes";

    for (int i = 0; i < N; i++) {
      if (t[i] < x[i] + y[i]) {
        result = "No";
        break;
      } else {
        if (t[i] % 2 == 1 && (x[i] + y[i]) % 2 == 0) {
          result = "No";
          break;
        }
      }
    }

    System.out.println(result);

  }

}

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

main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(a,min(b,c))<<' '<<max(a,max(b,c))<<endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, K, Q, A[101010], cnt[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K >> Q;
    rep(i, 0, Q) cin >> A[i];
    rep(i, 0, Q) cnt[A[i] - 1]++;

    rep(i, 0, N) {
        int k = K - (Q - cnt[i]);
        if(0 < k)
            printf("Yes\n");
        else
            printf("No\n");
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>
#include <sstream>
#include <iomanip>

using namespace std;

using Graph = vector<vector<int> >;

vector<int> seen;

class CT
{
public:
	pair<int, int> py;
	int index;

	bool operator<(CT other) {
		return py < other.py;
	}
};

int main()
{
	int N, M;

	cin >> N >> M;

	if (N >= M) {
		cout << 0;
		return 0;
	}

	vector<int> Xs(M);

	for (int mi = 0; mi < M; mi++) {
		cin >> Xs[mi];
	}
	sort(Xs.begin(), Xs.end());


	vector<int> Ls(M - 1);

	for (int mi = 0; mi < M - 1; mi++) {
		Ls[mi] = Xs[mi + 1] - Xs[mi];
	}

	sort(Ls.rbegin(), Ls.rend());

	int ans = Xs[M-1] - Xs[0];
	for (int ni = 0; ni < N-1; ni++) {
		ans -= Ls[ni];
	}


	//printf("%d %d %lld", xi, yi, H + gap);

	cout << ans;
	

	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct PCB
{
	char name[20];	// 进程名称 
	int time;		// 进程运行所需时间 
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue()
{
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

// 返回最小值 
int min(int a, int b)
{
	return a < b ? a : b;
}

int main()
{
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	
	// 按顺序将所有任务添加至队列
	for(int i = 1; i <= n; ++ i)
	{
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}
	head = 1;
	tail = n + 1;
	
	// 模拟
	while(head != tail)
	{
		u = dequeue();
		c = min(q, u.time);	// 执行时间片q或所需时间u.time的处理 
		u.time -= c;		// 计算剩余的所需时间 
		elaps += c;			// 累计已经过的时间
		if(u.time > 0)		// 如果处理尚未结束, 则重新添加至队列 
		{
			enqueue(u);
		}
		else
		{
			printf("%s %d\n", u.name, elaps);
		} 
	} 
	
	return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
#define RI register
using namespace std;
const int N=(1<<17)+10,mod=1e9+7;
typedef long long ll;

int n,A,B,bs;
int bel[N],tim;
int ans[N],cnt,S;
bool vs[N];

inline int cont(int x)
{
	int re=0,i;
	for(i=0;i<n;++i) if((x>>i)&1) re++;
	return re;
}

vector<int> cal(int t,int x)
{
	vector<int>re;re.resize((1<<t));
	if(t==1){re[1]=1;return re;}
	int pos,i;
	for(i=0;i<t;++i) if((x>>i)&1) {pos=i;break;}
	vector<int>nw;
	nw=cal(t-1,1);
	for(i=0;i<(1<<(t-1));++i) re[i]=(((nw[i]>>pos)<<(pos+1))|(nw[i]&((1<<pos)-1)));
	nw=cal(t-1,(((x>>(pos+1))<<pos)|(x&((1<<pos)-1)))^1);
	for(i=0;i<(1<<(t-1));++i){
		if(pos>0) re[i+(1<<(t-1))]=1^((1<<pos)|((nw[i]>>(pos))<<(pos+1))|(nw[i]&((1<<pos)-1)));
		else re[i+(1<<(t-1))]=1|((nw[i]^1)<<1);
	}
	return re;
}

int main(){
	int i,j,x,y;
	scanf("%d%d%d",&n,&A,&B);
	S=(1<<n);bs=A;B^=A;
	if(cont(B)%2==0) {puts("NO");return 0;}
	puts("YES");
	vector<int> as=cal(n,B);
	for(i=0;i<S;++i) printf("%d ",as[i]^A);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
         public static void main(String[] args) {
		int i = 1;
                Scanner sc = new Scanner(System.in);
                while (true) {
			int num = sc.nextInt();
			if (num == 0) break;
			System.out.printf("Case %d: %d\n", i, num);
			i ++;
		}
	}
}

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

int main(){
  string s;
  cin>>s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        switch (S) {
            case "Sunny":
                System.out.println("Cloudy");
                break;
            case "Cloudy":
                System.out.println("Rainy");
                break;
            case "Rainy":
                System.out.println("Sunny");
                break;
        }
    }
}

Measured memory_bytes: 20560
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pr make_pair
#define fi first
#define se second
#define ms(x, y) memset(x, y, sizeof(x))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;
int main() {
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a - 1, n - b) + (b - a + 1) / 2;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 2e5+2;
int f[N],g[N],r[N],h[N];
void init(int *a, int n,int mod) {
	if(mod <= 0) return;
	a[0] = 1%mod;
	for(int i=1;i<n;++i) a[i]=a[i-1]*2%mod;
}
int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);std::cin.tie(nullptr);
	for(int i=1;i<N;++i){
		h[i] = h[i%__builtin_popcount(i)]+1;
	}
	string s;
	int n;
	cin >> n >> s;
	int cnt = 0;
	for(auto &c:s) if(c=='1') ++cnt;
	init(f,n,cnt+1);
	init(g,n,cnt-1);
	auto inc = [](int &x,int y,int mod){
		if((x+=y)>=mod && (mod > 0)) x-=mod;
	};
	int rf = 0, rg = 0;
	for(int i=0; i<n; ++i) if(s[i]=='1'){
		inc(rf,f[n-1-i],cnt+1);
		inc(rg,g[n-1-i],cnt-1);
	}
	for(int i=0;i<n;++i){
		if(s[i]=='0'){
			int x = f[n-1-i];
			inc(x,rf,cnt+1);
			r[i] = h[x]+1;
		}else{
			int x = cnt-1 - g[n-1-i];
			inc(x,rg,cnt-1);
			if(cnt==1) r[i]=0;
			else r[i] = h[x]+1;
		}
	}
	for (int i=0;i<n;++i) {
		cout<<r[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6900
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char str[1000000];
int mod[2][11];

int main() {
  while (scanf("%s", str), str[0] != '0') {
    MEMSET(mod, 0);
    int len = strlen(str);
    ll ans = 0;
    REP(i, len) {
      int prev = i & 1;
      int next = (i + 1) & 1;
      int num = str[i] - '0';
      MEMSET(mod[next], 0);
      REP(j, 11) {
        int nmod = (j * 10 + num) % 11;
        mod[next][nmod] = mod[prev][j];
      }
      ans += mod[next][0];
      if (num != 0) { mod[next][num]++; };
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
struct Solver {
    Solver() {
        cin >> N >> A >> B >> C;
        l.reserve(N);
        for (int i = 0; i < N; i++) cin >> l[i];
        cout << solve(0, 0, 0, 0) << endl;
    }
    int solve(int cnt, int a, int b, int c) {
        if (cnt == N) {
            if (min(a, min(b, c)) == 0) return 1e9;
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
        auto v = {
            solve(cnt + 1, a, b, c),
            solve(cnt + 1, a + l[cnt], b, c) + 10,
            solve(cnt + 1, a, b + l[cnt], c) + 10,
            solve(cnt + 1, a, b, c + l[cnt]) + 10
        };
        return *min_element(v.begin(), v.end());
    }
    int N, A, B, C;
    vector<int> l;
};
int main() {
    Solver();
}


Measured memory_bytes: 384
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var [a,b,c]=input.trim().split(" ").map(Number);
var i=0;
var j=0;
var sum=0;
while(true){
   if(c<=sum)break;
   i++;
   j++;
   sum+=a;
   if(j==7){
      sum+=b;
      j=0;
   }
}
console.log(i);


Measured memory_bytes: 15404
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
using namespace std;
const int mod = 1000000007;
//char c[MAX][MAX];
int step[MAX][MAX];
int H,W,N; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    int n,k; cin >> n >> k;
    int A[100][100],d[100];
    rep(i,k) {
        cin >> d[i];
        rep(j,d[i]) cin >> A[i][j];
    }
    int cnt=0;
    int p[101];
    rep(i,k) {
        rep(j,d[i]){
            if(A[i][j] >= 1) p[A[i][j]] ++;
        }
    }
    for(int i=1;i<n+1;i++) if(p[i] == 0) cnt++; 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
    int n,x;
    while(true){
        scanf("%d %d",&n,&x);
        if(n == 0 && x == 0) break;
        int counter = 0;
        for(int a = 1;a < x/3 && a <= n - 2;a++){
            for(int b = a + 1;b < x - (a+b) && b <= n-1;b++){
                if(x - a - b <= n) counter++;
            }
        }
        printf("%d\n",counter);
    }
}


Measured memory_bytes: 2740
#include <iostream>

using namespace std;

long long int N, a, num[100001] = {}, ans = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a;
		if (a > 100000) {
			ans++;
		}
		else {
			num[a]++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (num[i] >= i) {
			ans += num[i] - i;
		}
		else {
			ans += num[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  long long k;
  cin >> k;
  for(int i = 0; i < k; i++){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main()
{
   int D;
   cin>>D;
   if(D==22) cout<<"Christmas Eve Eve Eve"<<endl;
   else if(D==23) cout<<"Christmas Eve Eve"<<endl;
   else if(D==24) cout<<"Christmas Eve"<<endl;
   else if(D==25) cout<<"Christmas"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int S,W;
    cin >> S >> W;
    if(S<=W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }

    return 0;
}

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

int main(){
  
  string a,b;
  cin >> a >> b;
  
  b.pop_back();
  
  if( b == a ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
  
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
    int a,b,x,y,z,maxim;
    cin>>a>>b;
    x=a+b;
    y=a*b;
    z=a-b;
    maxim=max(x,y);
    maxim=max(maxim,z);
    cout<<maxim;
}


Measured memory_bytes: 3612
def resolve():
    def dfs(v):
        dist = [-1] * N
        stack = [v]
        dist[v] = 0
        while stack:
            v = stack.pop()
            for to in G[v]:
                if dist[to] != -1:
                    continue
                dist[to] = dist[v] + 1
                stack.append(to)
        return dist

    N, taka, aoki = map(int, input().split())
    taka -= 1
    aoki -= 1
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        G[a].append(b)
        G[b].append(a)

    dist_Tk = dfs(taka)
    dist_Ao = dfs(aoki)

    ans = 0
    for i in range(N):
        if dist_Tk[i] < dist_Ao[i]:
            ans = max(ans, dist_Ao[i] - 1)

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 33444
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef unsigned long long ull;

int main() {FIN
	
	ull a, b, n, x;
	cin >> a >> b >> n;
	x = min(n, b - 1);
	cout << ((a * x) / b) - a * (x / b) << "\n";
		
	return 0;
}


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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
	int n; cin >> n;
	if (n < 1000)
		cout << "ABC" << endl;
	else cout << "ABD" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
ll ch(ll n)
{
    ll r = 0;
    while (n % 2 == 0)
    {
        n /= 2;
        r++;
    }
    return r;
}
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll k = ch(a[0]);
    rep(i, n)
    {
        if (k != ch(a[i]))
        {
            cout << 0 << endl;
            return 0;
        }
        ll K = k;
        while (K--)
        {
            a[i] /= 2;
        }
    }
    ll now = a[0];
    rep(i, n)
    {
        if (now * (ll)pow(2LL, k - 1) > m)
        {
            cout << 0 << endl;
            return 0;
        }
        now = now * a[i] / __gcd(now, a[i]);
    }
    now *= (ll)pow(2LL, k - 1);
    cout << m / now - m / (2 * now) << endl;
}

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

signed main()
{
  char a, b;
  cin >> a >> b;

  if (a == 'H') {
    if (b == 'H') cout << "H" << endl;
    if (b == 'D') cout << "D" << endl;
  }
  else {
    if (b == 'D') cout << "H" << endl;
    if (b == 'H') cout << "D" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;
string s,ans="Good";
int main(){
cin>>s;
rep(i,s.length()-1){
    if(s[i]==s[i+1])ans="Bad";
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

//long int factorial(int x){
//  if(x==0)
//    return 1;
//  printf("%d %d\n",x, x*factorial(x-1));
//  return x*factorial(x-1);  
//}

int main(){
  int n, m, sum;
  scanf("%d %d",&n, &m);
  
  if(n<2 && m<2)
    sum = 0;
  else if(n<2)
//    sum = factorial(m)/factorial(2)/factorial(m-2);
    sum = m*(m-1)/2;
  else if(m<2)
//    sum = factorial(n)/factorial(2)/factorial(n-2);
    sum = n*(n-1)/2;
  else
//    sum = factorial(n,n)/factorial(2)/factorial(n-2) + factorial(m)/factorial(2)/factorial(m-2);
    sum = m*(m-1)/2 + n*(n-1)/2;

  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << ((x - z) / (y + z)) << endl;
}

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

using namespace std;
typedef long long int ll;

ll A[81][81];
ll B[81][81];
ll D[81][81];
bool dp[81][81][6500];

int main() {

    ll H, W; cin >> H >> W;
 
    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            cin >> A[i][j];
        }
    }

    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            cin >> B[i][j];
            D[i][j] = abs(A[i][j] - B[i][j]);
        }
    }

    //初期化
    dp[0][0][D[0][0]] = true;

    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            for(ll k = 0; k < 6400; k++){
                if(dp[i][j][k]){
                    dp[i][j+1][abs(k - D[i][j+1])] = true;
                    dp[i][j+1][abs(k + D[i][j+1])] = true;
                    
                    dp[i+1][j][abs(k - D[i+1][j])] = true; 
                    dp[i+1][j][abs(k + D[i+1][j])] = true;
                     
                }
            }
        }
    }

    for(ll k = 0; k < 6400; k++){
        if(dp[H-1][W-1][k]){
            cout << k << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 41856
#include <iostream>

using namespace std;

int A, B, C, X, Y;

int res = 0;

int main()
{
  cin >> A >> B >> C >> X >> Y;
  if (A + B < 2 * C)
  {
    res = A * X + B * Y;
  }
  else if (A + B >= 2 * C && X > Y && A > 2 * C)
  {
    res = Y * C * 2 + (X - Y) * 2 * C;
  }
  else if (A + B >= 2 * C && Y >= X && B > 2 * C)
  {
    res = X * C * 2 + (Y - X) * 2 * C;
  }
  else if (A + B >= 2 * C && X > Y && A <= 2 * C)
  {
    res = Y * C * 2 + (X - Y) * A;
  }
  else if (A + B >= 2 * C && Y >= X && B <= 2 * C)
  {
    res = X * C * 2 + (Y - X) * B;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main () {
  string s;
  cin >> s;
 
  int n = (int)s.size();
  stack<char> st;
  for (int i = 0; i < n; ++i) {
    if (st.empty()) st.push(s[i]);
    else if (s[i] == 'S') st.push(s[i]);
    else {
      if (st.top() == 'S') st.pop();
      else st.push(s[i]);
    }
  }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 644
import java.util.Scanner;

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

        String s = String.valueOf(i);
        String str = "9";

        if(s.indexOf(str) >= 0){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

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

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;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int MAXIMAM = 2147480000;

const int MAX = 2001;

int main() {
    ll N, K;
    cin >> N >> K;
    ll BLUE = K;
    ll BLUE_BETWEEN = K - 1;
    ll RED = N - K;
    ll RED_SPACES = RED + 1;

    vector<vector<ll>> tri(N+1,vector<ll>(N+1));
    tri[0][0] = 1;

    for(int n=1;n<=N;n++){
        for(int k=0;k<=n;k++){
            if(k == 0){                                                
                tri[n][k] = tri[n-1][k];
            } else {
                tri[n][k] = (tri[n-1][k] + tri[n-1][k-1]) % MOD;
            }
        }
    }

    for(int i=1;i<=K;i++){
        cout << (tri[RED_SPACES][i] * tri[BLUE_BETWEEN][i-1]) % MOD << endl;
    }
}

Measured memory_bytes: 31616
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b) {
	return (int)(*(double*)a - *(double*)b);
}
double linear(double p1[], double p2[], double x) {
	double gradient = (p1[1] - p2[1]) / (p1[0] - p2[0]);
	return gradient * x + (p1[1] - gradient * p1[0]);
}
int main() {
	double data[3][2], p[2], y[2];
	double *a, *b, *c;
	while (scanf(" %lf %lf %lf %lf %lf %lf %lf %lf",
				&data[0][0], &data[0][1],
				&data[1][0], &data[1][1],
				&data[2][0], &data[2][1],
				&p[0], &p[1]) != EOF) {
		qsort(data, 3, sizeof(double) * 2, compare);
		a = data[0];
		b = data[1];
		c = data[2];
		if (p[0] <= a[0] || c[0] <= p[0]) {
			puts("NO");
			continue;
		}
		if (a[0] == b[0] || (b[0] <= p[0] && p[0] <= c[0])) {
			y[0] = linear(b, c, p[0]);
			y[1] = linear(a, c, p[0]);
		} else if (b[0] == c[0] || (a[0] <= p[0] && p[0] <= b[0])) {
			y[0] = linear(a, b, p[0]);
			y[1] = linear(a, c, p[0]);
		} else {
			puts("NO");
			continue;
		}
		qsort(y, 2, sizeof(double), compare);
		if (y[0] < p[1] && p[1] < y[1]) {
			puts("YES");
		} else {
			puts("NO");
		}
	}
	return 0;
}

Measured memory_bytes: 616
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: i128};

    if n < 2 {
        println!("0")
    } else {
        let mut result = f(n, 10) - f(n, 9) * 2 + f(n, 8);
        result = result % (10i32.pow(9) + 7) as i128;
        result = (result + (10i32.pow(9) + 7) as i128) % (10i32.pow(9) + 7) as i128;
        println!("{}", result);
    }
}

fn f(n: i128, base: i128) -> i128 {
    let mut result = 1;
    for _ in 0..n {
        result = result * base % (10i32.pow(9) + 7) as i128;
    }
    return result;
}


Measured memory_bytes: 2168
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(1){
  scanf("%d %d",&h,&w);
  if(h==0 && w==0) break;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      printf("#");
    }
    printf("\n");
  }printf("\n");
  
  }
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define rollcall cout<<"I'm Sucu."<<endl
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl
 
signed main(){
    int a,b;
    cin >> a >> b;
    if(a+b==15){cout << "+" << endl;return 0;}
    if(a*b==15){cout << "*" << endl;return 0;}
    cout << "x" << endl;
    
    return 0;
}   


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#define N (100000+1000)
using namespace std;

struct Edge{int to,next;}edge[N<<1];
int n,u,v,dep[N],f[N][22],ans;
int head[N],num_edge;

void add(int u,int v)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	head[u]=num_edge;
}

void Dfs(int x,int fa)
{
	for (int i=head[x]; i; i=edge[i].next)
		if (edge[i].to!=fa)
		{
			Dfs(edge[i].to,x);
			for (int j=0; j<=20; ++j)
				f[x][j]+=f[edge[i].to][j];
		}
	int lim=0;
	for (int i=20; i>=0; --i)
		if (f[x][i]>1) {lim=i+1; break;}
	while (f[x][lim]) lim++;
	dep[x]=lim;
	for (int j=0; j<=lim-1; ++j) f[x][j]=0;
	f[x][lim]++; ans=max(ans,dep[x]);
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n-1; ++i)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	Dfs(1,0);
	printf("%d\n",ans);
}

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

ll Pow(ll x, ll n, ll mod){
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod,n/2,mod);
  else return x * Pow(x,n-1,mod) % mod;
}

void extgcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return;
  }
  extgcd(b, a%b, y, x);
  y -= a/b*x;
  return; 
}

ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a,m,x,y);
  return (m + x % m) % m;
}

int main(){
  ll n, mod;
  cin >> n >> mod;
  string s;
  cin >> s;
  ll ans = 0;
  if(mod == 2) {
    rep(i,n) {
      if((s[i]-'0') % 2 == 0) ans += i+1;
    }
  } else if(mod == 5) {
    rep(i,n) {
      if(s[i] == '5' || s[i] == '0') ans += i+1;
    }
  } else {
    map<ll,ll> m;
    ll v = 0, d = 1;
    m[0]++;
    rep(i,n) {
      v = (v*10 + (s[i]-'0')) % mod;
      (d *= 10) %= mod;
      ll c = (v*mod_inverse(d,mod)) % mod;
      ans += m[c];
      m[c]++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1028
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,m,k;
ll a[N],b[N],pre1[N],pre2[N];
//<<-----Implement Functions Here---->>//
ll func1(ll mid,ll x){
	if(pre2[mid]<=x)return 1;
	return 0;
}
ll binsearch1(ll l,ll r,ll x)
{
	ll ans = -1;
	while(l<=r)
	{	
		ll mid = (l+r)/2;
		if(func1(mid,x)){ans = mid;l = mid+1;}
		else r = mid-1;
	}
	return ans;
}
ll func(ll mid,ll x){
	ll max1 = -1e+18;
	for(ll i=0;i<=n;i++){
		ll x1 = x-pre1[i];ll num =  i;
		if(x1<0)continue;//cout<<x1<<" "<<num<<" ";
		num += binsearch1(0,m,x1);
		max1 = max(num,max1);
		//cout<<num<<" ";
	}
	//cout<<max1<<" "<<endl;
	if(max1>=mid)return 1;
	return 0;
}
ll binsearch(ll l,ll r,ll x)
{
	ll ans = -1;
	while(l<=r)
	{	
		ll mid = (l+r)/2;
		//cout<<mid<<" "<<x<<endl;
		if(func(mid,x)){ans = mid;l = mid+1;}
		else r = mid-1;
		
	}
	return ans;
}

//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>m>>k;
		for(ll i=1;i<=n;i++)cin>>a[i];
		for(ll i=1;i<=m;i++)cin>>b[i];
		pre1[1] = a[1];pre2[1] = b[1];
		for(ll i=2;i<=n;i++)pre1[i] += pre1[i-1]+a[i];
		for(ll i=2;i<=m;i++)pre2[i] += pre2[i-1]+b[i];
		cout<<binsearch(0,m+n,k);
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 16912
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

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

    int n;
    int pt = 0, px = 0, py = 0;
    cin >> n;
    rep(i, n) {
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(px - x) + abs(py - y);
        if (d > (t - pt) || d % 2 != (t - pt) % 2) {
            cout << "No" << endl;
            exit(0);
        }
        pt = t;
        px = x;
        py = y;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc = initScanner(os.Stdin)
	S := scanString(sc)

	fmt.Println(resolve(S))
}

func resolve(S string) string {
	s := strings.Split(S, "")
	sort.Strings(s)

	used := make([]string, len(S))

	for i, v := range s {
		for _, uv := range used {
			if v == uv {
				return "no"
			}
		}
		used[i] = v
	}

	return "yes"
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int num;
			while ((num = Integer.parseInt(br.readLine())) != 0) {
				int total = 0;
				for (int i = 0; i < num; i = i + 4) {
					int hit = Integer.parseInt(br.readLine());
					total += hit;
				}
				System.out.println(total);
			}
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}



Measured memory_bytes: 23944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int a = 0, b = 0;
	string s, t;

	cin >> s >> t;
	while (1) {
		if (a == s.size()) break;
		cout << s[a++];
		if (b == t.size()) break;
		cout << t[b++];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256