akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<set>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,a;
  set<int> d;
  cin >> N;
  REP(i,N){
    cin >> a;
    if(d.count(a) == 0){
      d.insert(a);
    }else{
      d.erase(a);
    }
  }
  cout << d.size() << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 4864
S = input()
a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
        

for i in range(1, len(S)+1):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
        
print(sum(a))

Measured memory_bytes: 29056
#include <cstdio>

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

    bool card[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            card[i][j] = false;
        }
    }

    for(int i = 0; i < n; i++){
        char c;
        scanf("\n%c", &c);

        int x;
        scanf("%d", &x);

        if(c == 'S'){
            card[0][x - 1] = true;
        }

        else if(c == 'H'){
            card[1][x - 1] = true;
        }

        else if(c == 'C'){
            card[2][x - 1] = true;
        }

        else if(c == 'D'){
            card[3][x - 1] = true;
        }
    }

    char fig[4] = {'S', 'H', 'C', 'D'};
    for(int i = 0; i < 13; i++){
        for(int j = 0; j < 13; j++){
            if(!card[i][j]){
                if(i == 0){
                    printf("S %d\n", j + 1);
                }

                else if(i == 1){
                    printf("H %d\n", j + 1);
                }

                else if(i == 2){
                    printf("C %d\n", j + 1);
                }

                else if(i == 3){
                    printf("D %d\n", j + 1);
                }
            }

        }
    }
    return 0;
}


Measured memory_bytes: 2668
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N, Z, W;
  cin >> N >> Z >> W;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  if (N == 1) cout << abs(a[0] - W) << endl;
  else cout << max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])) << endl;
}

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



Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


def nitti(x, y):
    count = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            count += 1
    return count


x = acinput()


res = 10**20*(-1)

for i in range(2):
    for j in range(2, 4):
        res = max(res, x[i]*x[j])

print(res)


Measured memory_bytes: 27152
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {

    int a;
    
    cin >> a;
    
    cout << a + pow(a, 2) + pow(a, 3) << endl;
    
    
}


Measured memory_bytes: 4156
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int h, w;

string row;
vector<string> board;

int main() {
    GI(h); GI(w);

    FORN(i, h) {
        cin >> row;
        board.PB(row);
    }

    FORN(parity, 2) {
        FORN(i, h) {
            FORN(j, w) {
                if (i == 0) {
                    cout << (parity ? '#' : '.');
                }
                else if (i == h-1) {
                    cout << (1-parity ? '#' : '.');
                }
                else if (board[i][j] == '#') {
                    cout << '#';
                }
                else if (j % 2 == parity) {
                    cout << '#';
                }
                else {
                    cout << '.';
                }
            }
            cout << "\n";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 1024
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>i*i-4:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
if P==i and c+1 ==N:
  ans*=i
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int n,m;
    cin>>n>>m;
    vector<bool> ak(n+1,false);
    ak[1]=true;
   vector<int> box(n+1,1);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        if(ak[a]){
            ak[b]=true;
        }else if(ak[a]==false&&box[b]==0){
            ak[b]=false;
        }
        box[a]--;
        box[b]++;
    }

    int ans =0;
    for(int i=1;i<=n;i++){
        if(ak[i]&&box[i]!=0){
            ans++;
        }
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, i, z;
	string s;
	char r[20000];
	cin>>n;
	cin>>s;
	for(i=0; i<s.size(); i++)
	{
		z=s[i]+n;
		//cout<<z<<endl;
		if(z<=90)
		r[i]=z;
		else
		r[i]=z-26;
	}
	r[i]='\0';
	printf("%s\n", r);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ull = unsigned long long;
int main() {
  ull a, b;
  cin >> a >> b;
  ull x;
  cin >> x;
  if(a == 0) {
    cout << b / x + 1 << endl;
  } else {
    cout << b / x - (a - 1) / x << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
int gcd(int x,int y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n) cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(i==n-1) ans+=a[i];
        else if(a[i+1]<a[i]) ans+=(a[i]-a[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    vector<int> a(3);
    int s1,s2;
    int i,j,tmp;
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    for(i=0;i<2;i++){
        for(j=1;i+j<3;j++){
        if(a.at(i)<a.at(i+j)){
            tmp = a.at(i+j);
            a.at(i+j) = a.at(i);
            a.at(i) = tmp;
        }
        }
    }
    s1 = a.at(2);
    s2 = a.at(1);

    cout << s1 + s2 << endl;

    return 0;

}

Measured memory_bytes: 256
import math
import numpy

line = input().split()

a = int(line[0])
b = int(line[1])
h = int(line[2])
m = int(line[3])

h_r = math.pi * (0.25 - (2 * (h + m / 60) / 12))
m_r = math.pi * (0.25 - (2 * m / 60))

l = numpy.sqrt((a * math.cos(h_r) - b * math.cos(m_r)) ** 2 + (a * math.sin(h_r) - b * math.sin(m_r)) ** 2)
print(l)

Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

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

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\???
// .???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????
// ?????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\??????????????????

int V, E, s, t, d, dp[1<<15][15], e[15][15];

int main() {
	cin >> V >> E;
	rep(i,V) {
		fill(e[i], e[i]+V, inf);
		e[i][i] = 0;
	}
	rep(i,E) {
		cin >> s >> t >> d;
		e[s][t] = d;
	}
	rep(i,1<<V) fill(dp[i], dp[i]+V, inf);
	dp[(1<<V)-1][0] = 0;
	repr(i,(1<<V)-2) {
		rep(j,V) {
			rep(k,V) {
				if (!(i>>k & 1)) chmin(dp[i][j], dp[i|(1<<k)][k]+e[j][k]);
			}
		}
	}
	if (dp[0][0]!=inf) cout << dp[0][0] << ln;
	else cout << -1 << ln;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const int V = 100005;
vi to[V*2];
bool visited[V*2];
vi cnt;

void dfs(int v){
  if(visited[v]) return;
  visited[v]=true;
  cnt[v/V]++;
  for(auto e: to[v]) dfs(e);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n;
  cin>>n;
  rep(i,n){
    int x,y; cin>>x>>y;
    y+=V;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  
  ll ans=0;
  rep(i,V*2){
    if(visited[i]) continue;
    cnt = vi(2);
    dfs(i);
    ans+=(ll)cnt[0]*cnt[1];
  }
  ans-=n;
  cout<<ans<<endl;
}


Measured memory_bytes: 10240
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val s = br.readLine()!!

    val charIndexList = List(10) { mutableListOf<Int>() }
    for ((i, c) in s.withIndex()) charIndexList[c - '0'].add(i)

    var ans = 0
    for (i in 0..9) {
        val firstIndex = charIndexList[i].firstOrNull() ?: continue

        for (j in 0..9) {
            var ngSecond = -1
            var okSecond = charIndexList[j].size
            while (okSecond - ngSecond > 1) {
                val mid = (ngSecond + okSecond) / 2
                if (charIndexList[j][mid] > firstIndex) okSecond = mid else ngSecond = mid
            }

            if (okSecond !in charIndexList[j].indices) continue

            val secondIndex = charIndexList[j][okSecond]
            for (k in 0..9) {
                var ngThird = -1
                var okThird = charIndexList[k].size
                while (okThird - ngThird > 1) {
                    val mid = (okThird + ngThird) / 2
                    if (charIndexList[k][mid] > secondIndex) okThird = mid else ngThird = mid
                }

                if (okThird in charIndexList[k].indices) ans++
            }
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36464
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    auto G = new int[][N];
    foreach (_; 0..M) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0]-1;
        auto B = ab[1]-1;
        G[A] ~= B;
        G[B] ~= A;
    }

    auto P = new bool[](N);
    void walk(int i, ref int[] ps) {
        ps ~= i+1;
        P[i] = true;
        foreach (j; G[i]) if (!P[j]) {
            walk(j, ps);
            break;
        }
    }
    int[] as, bs;
    walk(0, as);
    walk(0, bs);
    bs = bs[1..$];
    bs.reverse();
    writeln(as.length + bs.length);
    writeln((bs ~ as).to!(string[]).join(" "));
}

Measured memory_bytes: 15100
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

bool isPrime(int n){
    if(n==1)return false;
    if(n==2)return true;
    for(int i=2;i<sqrt(n)+1;i++){
        if((n%i)==0)return false;
    }
    return true;
}

int main(){
    
    int n;
    while(cin>>n){
        int cnt=0;
        REP(i,n){
            if(isPrime(i+1)&&isPrime(n-i))cnt++;
        }
        cout<<cnt<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,b;
    cin>>N;
    int A[N];
    for(int i=0;i<N;++i){
        cin>>b;
        A[b-1]=i+1;
    }
    for(int i=0;i<N;++i)cout<<A[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cmath>

using namespace std;


int main()
{
	int n, a, b, c;
    long long int ans = 2e9;

    cin >> n >> a >> b >> c;

	int l[n];
	string s = string(n, '0');

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



	while (s != string(n, '3')){
		if (s[0] == '3'){
			for (int i = 0; i < n; i++){
				if (s[i] != '3') {
					s[i] = s[i] + 1;
					for (int j = 0; j < i; j++){
						s[j] = '0';
					}
					break;
				}
			}
		}
		else s[0] += 1;


        long long int min = 0;
        int da = 0, db = 0, dc = 0;
	    int cnt = 0;
        bool aflg = false, bflg = false, cflg = false;

		for (int i = 0; i < n; i++) {
			if (s[i] == '1'){
				if (da != 0) cnt++;
				da += l[i];
				aflg = true;
			}
			else if (s[i] == '2') {
				if (db != 0) cnt++;
				db += l[i];
				bflg = true;
			}
			else if (s[i] == '3') {
				if (dc != 0) cnt++;
				dc += l[i];
				cflg = true;
			}

		}
		if (aflg == false || bflg == false || cflg == false) continue;
        else {
		    min += abs(da-a);
		    min += abs(db-b);
		    min += abs(dc-c);
		    min += cnt * 10;
        }

		if (ans > min) ans = min;
        
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
/*Program from Luvwgyx*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+10;
int n,X,Y,c[maxn],w[maxn],mn[maxn],cnt[maxn],fac[maxn],inv[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
int power(int a,int b){
    int ret=1;
    for(;b;b>>=1,a=a*a%mod)
        if(b&1)ret=ret*a%mod;
    return ret;
}
void init(){
    memset(mn,63,sizeof(mn));
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
    inv[n]=power(fac[n],mod-2);inv[0]=1;
    for(int i=n-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
signed main(){
    n=read();X=read();Y=read();init();
    for(int i=1;i<=n;i++){
        c[i]=read();w[i]=read();
        mn[c[i]]=min(mn[c[i]],w[i]);
    }int Min=0,Minn=0;
    for(int i=1;i<=n;i++){
        if(mn[i]<mn[Min]){Minn=Min;Min=i;}
        else if(mn[i]<mn[Minn])Minn=i;
    }int sum=0,ans=1;
    for(int i=1;i<=n;i++){
        if(w[i]+mn[c[i]]<=X)w[i]=mn[c[i]];
        if(c[i]!=Min&&mn[Min ]+w[i]<=Y)cnt[c[i]]++;
        if(c[i]==Min&&mn[Minn]+w[i]<=Y)cnt[c[i]]++;
    }for(int i=1;i<=n;i++)if(cnt[i])sum+=cnt[i],ans=ans*inv[cnt[i]]%mod;
    write(ans*fac[sum]%mod);
    return 0;
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int N=1e18;

int32_t main(){
	IOS;
	int a,b,k;
	cin>>a>>b>>k;
	if(a>k) cout<<a-k<<" "<<b<<endl;
	else cout<<"0 "<<max((long long)0,b-(k-a))<<endl;
}

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

using namespace std;
const int length = 16;
const string temp = "CODEFESTIVAL2016";

int main() {
	string s;
	int ans = 0;
	cin >> s;
	for(int i=0;i<length;i++) {
		if(s[i] != temp[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
Author : farhan132
*/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef pair < ll , pair < ll , ll > > cm;

#define ff first
#define ss second
#define pb push_back
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)
#define clean cout.flush()

const ll mod = (ll)1e9+7;
const ll maxn = (ll)1e5+10;
const int nnn = 664579+500;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

//ofstream wr ("txt.txt");
//ifstream rr ("input.txt");


void solve(){
	
	ll n;
	cin >> n;
	if(n >= 30) cout << "Yes\n";
	else cout << "No\n";
	
 	return;
}

int main() {
   
   ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    
    //work();
    while(T--){
    	//cout << "Case #" << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
	
    return 0;
}
/*


*/

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

int main(){
  string S;
  bool flag = 0;
  cin >> S;
  if(S.size() != 26){
    for(char moji='a'; moji<='z'; moji++){
      for(int i=0; i<S.size(); i++){
        if(S.at(i) == moji){
          break;
        }
        if(i == S.size()-1){
          S.push_back(moji);
          cout << S << endl;
          return 0;
        }
      }
    }
  }else{//文字数26のとき
    if(S=="zyxwvutsrqponmlkjihgfedcba"){
      cout << -1 << endl;
      return 0;
    }
    int cnt;
    for(int i=0; i<26; i++){
      //cout << S << endl;
      flag = 0;
      cnt=0;
      S.erase(S.end()-1);//まず末尾を消す]
      if(S.size()==1){
        S.at(0)++;
        cout << S << endl;
        return 0;
      }
      for(int k=1; S.at(S.size()-1)+k<='z'; k++){//末尾の文字をzまで順番に変える
        cnt++;
        for(int j=0; j<S.size()-1; j++){
          if(S.at(j)==S.at(S.size()-1)+k){
            if(S.at(S.size()-1)+k=='z'){
              flag = 1;
            }
            break;
          }else{
            if(j==S.size()-2){
              k=999999;
            }
          }
        }
      }
      if(!flag){
        if(S.at(S.size()-1) == 'z'){
          continue;
        }
        S.at(S.size()-1)+=cnt;
        break;
      }
    }
    cout << S << endl;
  }
}

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

int main(void){
  int k,x;
  cin>>k>>x;

  for(int i=x-k+1;i<x+k;i++){
    cout<<i<<" ";
  }
  cout<<endl;
  return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 58;

int N;
int64 W[4000];
int64 dp[4000][4001];
int opt[4000][4001];

int64 getcost(int left, int right)
{
  return (W[right] - W[left]);
}

int64 rec(int left, int right)
{
  if(~dp[left][right]) {
    return (dp[left][right]);
  }
  if(left + 1 >= right) {
    opt[left][right] = left;
    return (0);
  }
  rec(left, right - 1);
  rec(left + 1, right);
  dp[left][right] = INF;
  for(int k = opt[left][right - 1]; k <= opt[left + 1][right]; k++) {
    int64 cost = rec(left, k) + rec(k, right);
    if(cost < dp[left][right]) {
      dp[left][right] = cost;
      opt[left][right] = k;
    }
  }
  dp[left][right] += getcost(left, right);
  return (dp[left][right]);
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    int64 x;
    cin >> x;
    W[i + 1] = W[i] + x;
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(0, N) << endl;
}

Measured memory_bytes: 173668
import sys
n,xyz=map(int,input().split())

# 10000,5000,1000
# x    ,y   ,z

for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    if (x*10000+y*5000+z*1000)==xyz:
      print(str(x)+" "+str(y)+" "+str(z))
      sys.exit()
print("-1 -1 -1")
      

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

int getdig(int num)
{
    int dig = 1,ten = 10;
    while(num/ten>0){
        ten *= 10;
        dig ++;
    }
    return dig;
}

int main()
{
    int num,ans = 0;
    scanf("%d",&num);
    for(int i=1;i<=num;i++){
        if(getdig(i)%2==1){
            ans ++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
using System;
class Program{
  static long _sum;
  static void Main()
  {
    long n = long.Parse(Console.ReadLine());
    for (long i = 1; i < n + 1; i++)
    {
      _sum += i * calc(n / i);
    }
    Console.WriteLine(_sum);
  }
  static long calc(long x)
  {
    return x * (x + 1) / 2;
  }
}


Measured memory_bytes: 27456
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    std::string s;
    std::cin >> s;
    for(int i=0; i<3; i++)
    {
        if (s[i]==s[i+1])
        {
            std::cout << "Bad" << std::endl;
            return 0;
        }
    }
    std::cout << "Good" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if(s == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
S=input()
if S[0]!='A':
    print('WA')
else:
    tmp=S[2:-1]
    if tmp.count('C')!=1:
        print('WA')
    else:
        T=S.replace('A','')
        U=T.replace('C','')
        if U.islower():
            print('AC')
        else:
            print('WA')

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int A,B,K,I[101],j=0;
  for(int i=0;i<100;i++)I[i]=0;
  cin>>A>>B>>K;
  for(int i=100;i>0;i--){
    if(A%i==0&&B%i==0){
      j++;
      if(K==j){
        cout<<i;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}

int main() {
  int n = getint(), m = getint();
  printf("%d\n", n * (n - 1) / 2 + m * (m - 1) / 2);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    bool ok = true;
    map<char,char> ma, ima;
    for (int i = 0; i < S.size(); ++i) {
        char s = S[i], t = T[i];
        if (ma.count(s)) if (ma[s] != t) ok = false;
        if (ima.count(t)) if (ima[t] != s) ok = false;
        ma[s] = t; ima[t] = s;
    }
    if (ok) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

void insertionSort(vector<int> &A)
{
    repi(i, A.size(), 1)
    {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        repi(k, A.size(), 0)
        {
            cout << A[k] << ((k + 1) % A.size() ? " " : "");
        }
        cout << endl;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    repi(i, n, 0)
    {
        cin >> A[i];
        cout << A[i] << ((i + 1) %n ? " " : "");
    }
    cout << endl;
    insertionSort(A);
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>  // ver2.1.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

int mypow(int x, int n, int m){  //  高速累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  
  int n,m,memo;
  cin >> n >> m;
  int ans = 0;
  rep(i,0,n){
    cin >> memo;
    if(memo >= m) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
 
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a == b) {
            System.out.print("0");
        }
        else{
            int max = Math.max(a,b);
            int min = Math.min(a,b);
            if((max-min) % 2 == 0){
                System.out.print((max+min)/2);
            }
            else{
                System.out.print("IMPOSSIBLE");
            }
            
        }
        scan.close();
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

double getMoreHeadsProb(vector<double> inp) {
    int n=inp.size();
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=n;j++) {
            dp[i][j]=j==0?dp[i-1][j]*(1-inp[i-1]):dp[i-1][j]*(1-inp[i-1])+dp[i-1][j-1]*inp[i-1];
        }
    }
    double res=0;
    for(int i=n/2+1;i<=n;i++) {
        res+=dp[n][i];
    }
    return res;
}

int main(void){
    // Your code here!
    int n=0;
    cin>>n;
    vector<double> inp(n,0);
    for(int i=0;i<n;i++)cin>>inp[i];
    cout<<setprecision(17)<<getMoreHeadsProb(inp)<<endl;
}


Measured memory_bytes: 73816
#include<stdio.h>
#include<math.h>
int main(void){
  long long int n,m,x,c[13],a[13][13],i,j,b,d,k,ans,s[13],money;
  scanf("%lld %lld %lld",&n,&m,&x);
  for(i=0;i<n;i++){
    scanf("%lld",&c[i]);
    for(j=0;j<m;j++){
      scanf("%lld",&a[i][j]);
  }
  }
  ans=1000000000000;
  for(i=0;i<m;i++){
    s[i]=0;
  }
  b=pow(2,n);
  for(i=0;i<b;i++){ //2^n通り
    d=1;
    for(j=0;j<n;j++){ //全桁、つまり全参考書について買うか買わない変えを見る
      if(i&(1<<j)){ 
	money+=c[j]; //買うなら金額を足しておく
	for(k=0;k<m;k++){
	  s[k]+=a[j][k]; //各アルゴリズムの理解度を足す
	}
      }
    }
    for(k=0;k<m;k++){ //各アルゴリズムが全部x以上になっているか？
      if(s[k]<x){
	d=0;
	break;
      }
    }
    if(d==1){
      if(ans>money){
	ans=money;
      }
    }
    money=0;
    for(k=0;k<m;k++){
      s[k]=0;
    }
  }
  if(ans==1000000000000){
    printf("-1\n");
  }else{
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 2596
#include<bits/stdc++.h>
using namespace std;
#define ll long int 
int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        ll f=(x*x)+(y*y);
        double j=(double)sqrt(f);
        if(j<=k)ans++;
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n;
  if(n==1){
    cout<<"Hello World"<<'\n';
  }
  if(n==2){
    cin>>a>>b;
    cout<<a+b<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int const maxn = 1e5 + 10;
int n, m;
ll dis[2][maxn], ans[2][maxn];
bool vis[2][maxn];
int const MOD = 1e9 + 7;
int st, ed;
  
struct Edge {
    int v, next, w;
}e[200000 << 1];
int head[maxn], cnt;
  
void init() {
    memset(head, -1, sizeof(head));
    memset(dis, 0x3f, sizeof(dis));
    cnt = 0;
}
  
void add(int u, int v, int w) {
    e[cnt].v = v;
    e[cnt].w = w;
    e[cnt].next = head[u];
    head[u] = cnt++;
}
  
void dijkstra(int s, ll d[], bool v[], ll ans[]) {
    priority_queue<pair<ll, int> > q;
    d[s] = 0;
    ans[s] = 1;
    q.emplace(0, s);
    while (!q.empty()) {
        int u = q.top().second;
        q.pop();
        if (v[u]) continue;
        v[u] = 1;
        for (int i = head[u]; ~i; i = e[i].next) {
            int v = e[i].v;
            int w = e[i].w;
            if (d[v] > d[u] + w) {
                d[v] = d[u] + w;
                ans[v] = ans[u];
                q.emplace(make_pair(-d[v], v));
            } else if (d[v] == d[u] + w) {
                ans[v] = (ans[v] + ans[u]) % MOD;
            }
        }
    }
  
}
  
int main(void) {
    cin >> n >> m >> st >> ed;
    init();
    for (int i = 1; i <= m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        add(u, v, w);
        add(v, u, w);
    }
    dijkstra(st, dis[0], vis[0], ans[0]);
    dijkstra(ed, dis[1], vis[1], ans[1]);
  
    ll path_num = ((ans[0][ed] % MOD) * (ans[1][st] % MOD)) % MOD;
    ll D = dis[0][ed];
    for (int i = 1; i <= n; i++) {
        if (dis[0][i] == dis[1][i] && D == dis[1][i] * 2) {
            path_num = path_num - ((ans[0][i] * ans[0][i] % MOD) * (ans[1][i] * ans[1][i] % MOD)) % MOD;
            path_num = (path_num + MOD) % MOD;
        }
        for (int u = head[i]; ~u; u = e[u].next) {
            int w = e[u].w;
            int v = e[u].v;
            ll d1 = dis[0][i], d2 = dis[1][v];
            if (d1 + w + d2 == D && d1 * 2 < D && d2 * 2 < D) {
                path_num = path_num - ((ans[0][i] * ans[0][i] % MOD) * (ans[1][v] * ans[1][v] % MOD)) % MOD;
                path_num = (path_num + MOD) % MOD;
            }
        }
    }
    cout << path_num << endl;
      
    return 0;
}

Measured memory_bytes: 15080
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    ll a = 1;
    for (int i = 1; i <= N; ++i) {
        a *= i;
        a %= MOD7;
    }
    cout << a << endl;
}


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

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


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e13

using namespace std;

ll dp[301][302][302];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
	vll h(n+1); h[0] = 0;
	rep(i, n) cin>>h[i+1];

	rep(i, n+1)rep(j, k+2)rep(l, n+1){
		dp[i][j][l] = INF;
	}
	dp[0][0][0] = 0ll;
	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			for(int l=0; l<=n; l++){
				dp[i+1][j][i+1] = min(dp[i+1][j][i+1], dp[i][j][l]+max(0ll, h[i+1]-h[l]));
				dp[i+1][j+1][l] = min(dp[i+1][j+1][l], dp[i][j][l]);
			}
		}
	}

	ll ans = INF;
	for(int l=0; l<=n; l++){
		ans = min(ans, dp[n][k][l]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 214784
#include<bits/stdc++.h>
#define maxn 200100
using namespace std;
typedef long long ll;
struct edge{int r,nxt,w;}e[maxn<<1];
int head[maxn],esz,n,id;
ll anses[maxn],s[maxn],sum;
void addedge(int u,int v,int w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=w;
}
int dfs(int u,int f){
	int sz=1,xs=0;
	for(int t=head[u];t;t=e[t].nxt)if(e[t].r!=f){
		xs=dfs(e[t].r,u),sz+=xs;
		if(2*xs!=n)anses[e[t].w]=(s[e[t].r]-s[u])/(n-2*xs),sum-=anses[e[t].w]*xs*(n-xs)*2;
		else id=e[t].w;
	}
	return sz;
}
int main(){
	scanf("%d",&n);
	for(int i=2,u,v;i<=n;++i)
		scanf("%d%d",&u,&v),addedge(u,v,i);
	for(int i=1;i<=n;++i)scanf("%lld",&s[i]),sum+=s[i];
	dfs(1,0);
	if(id)anses[id]=sum*2/n/n;
	for(int i=2;i<=n;++i)printf("%lld\n",anses[i]);
}

Measured memory_bytes: 16000
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	long long H, W;
	scanf("%lld %lld", &H, &W);
	if (H == 1 || W == 1) printf("1");
	else printf("%lld", (H * W + 1) / 2);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int q, h, s, d; cin >> q >> h >> s >> d;
    int n; cin >> n;

    int a = min(4 * q, min(2 * h, s));
    if(2 * a > d) {
        int ans = (n / 2) * d + (n % 2) * a;
        cout << ans << endl;
        return 0;
    }

    int ans = n * a;

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


Measured memory_bytes: 256
result = []

while True:
    target = input()
    if target == '-':
        break
    shulle_count = int(input())
    h = 0
    for _ in range(shulle_count):
        h += int(input())
    h %= len(target)
    target = target[h:] + target[:h]
    result.append(target)

for word in result:
    print(word)


Measured memory_bytes: 5600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Exception;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		long[] x = new long[n];

		String[] tempX = br.readLine().split(" ");
		for (int i = 0; i < n; i++) 
			x[i] = Long.parseLong(tempX[i]);
		

		long l = Long.parseLong(br.readLine());
		int q = Integer.parseInt(br.readLine());

		int[] aa = new int[q];
		int[] bb = new int[q];

		for (int i = 0; i < q; i++) {
			String[] temp = br.readLine().split(" ");
			aa[i] = Integer.parseInt(temp[0])-1;
			bb[i] = Integer.parseInt(temp[1])-1;
		}


		int[][] dp = new int[n][17];
		int[] length = new int[n];


		int j = Math.abs(Arrays.binarySearch(x, x[0]+l)+1);
		int limit = 0;
		for (int i = 0; i < n; i++) {
			long bound = x[i] + l;
			for (; j < n && x[j] <= bound; j++);
			if (j == n) {
				limit = i;
				break;
			}
			else {
				dp[i][0] = j-1;
				length[i] = 1;
			}
		}

		for (int d = 0; limit > 0; d++) {
			for (int i = 0; i < limit; i++) {
				int t = dp[i][d];
				if (t < limit) {
					dp[i][d+1] = dp[t][d];
					length[i] += 1;
				}
				else {
					limit = i;
					break;
				}
			}
		}

		for (int i = 0; i < q; i++) {
			int a = aa[i];
			int b = bb[i];
			if (a > b) {
				int temp = a;
				a = b;
				b = temp;
			}

			int p = Math.abs(Arrays.binarySearch(dp[a], 0, length[a], b)+1) - 1;
			int cnt = 0;
			while (p >= 0) {
				cnt |= 1 << p;
				a = dp[a][p];
				p = Math.abs(Arrays.binarySearch(dp[a], 0, length[a], b)+1) - 1;
			}

			if (a < b)
				cnt++;
			System.out.println(cnt);
		}

	}
}

Measured memory_bytes: 48120
#include <stdio.h>
char s[100005];
int main()
{
	scanf("%s",s);
	int n=__builtin_strlen(s);
	int is_sym=1;
	for (int i=1;i<n;++i) if (s[i-1]!=s[n-i-1]) is_sym=0;
	if (s[0]=='0' || s[n-1]=='1' || !is_sym) return (int)puts("-1")*0;
	int prev=n-1;
	for (int v=n-2;0<=v;--v)
	{
		printf("%d %d\n",v+1,prev+1);
		if (s[v]=='1') prev=v;
	}
	return 0;
}

Measured memory_bytes: 1408