akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define f first
#define s second
#define INF 1000000007
ll fi[3000001];
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll InverseEuler(ll n, ll MOD)
{
 return binpow(n,MOD-2,MOD);
}
ll fin[300001];
ll C(ll n, ll r, ll MOD)
{
    if(r!=0 && r!=n)
 return (fi[n]*((fin[r] * fin[n-r]) % MOD)) % MOD;
   else
    return 1ll;
}
void solve()
{
    fi[0] = 1ll;
	for(ll i = 1 ; i <= 300000ll ; i++)
		fi[i] = (fi[i-1]*i)%mod;
    for(ll i=1;i<=300000;i++)
        fin[i]=InverseEuler(fi[i],mod);
   ll h,w,n;
   cin>>h>>w>>n;
   pair<ll,ll> ar[n+1];
   for(int x=0;x<n;x++)
    cin>>ar[x].f>>ar[x].s;
    ar[n]={h,w};
    sort(ar,ar+n+1);
    ll dp[n+1]={0};
    for(int x=0;x<=n;x++)
    {   dp[x]=C(ar[x].f+ar[x].s-2,ar[x].f-1,INF);
        for(int y=0;y<x;y++)
        {
           if(ar[y].f<=ar[x].f && ar[y].s<=ar[x].s)
            {
                 dp[x]-=(dp[y]*C(ar[x].f+ar[x].s-(ar[y].f+ar[y].s),ar[x].s-ar[y].s,INF))%mod;
                dp[x]=(mod+dp[x])%mod;
            }
        }
    }
    cout<<dp[n];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<pair<char, int> > run_length_factorization(string s){
    vector<pair<char, int> > res;
    s += '$';
    char c = s[0];
    int now = 1;
    for(int i = 1; i < s.size(); i++){
        if(s[i] != c){
            res.push_back(pair<char, int>(c, now));
            c = s[i]; now = 1;
        }else now++;
    }
    return res;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    vector<pair<char, int> > rl = run_length_factorization(s);
    if(rl.size() == 1){
        cout << s.size() * k / 2 << endl;
    }else if(rl[0].first == rl[rl.size() - 1].first){
        int sum = 0;
        for(int i = 1; i < rl.size() - 1; i++){
            sum += rl[i].second / 2;
        }
        cout << sum * k + rl[0].second / 2 + rl[rl.size() - 1].second / 2 + 
            (rl[0].second + rl[rl.size() - 1].second) / 2 * (k - 1) << endl;
    }else{
        int sum = 0;
        for(auto i : rl){
            sum += i.second / 2;
        }
        cout << sum * k << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String pre = sc.next();
        String pre2 = pre;
        String rear = sc.next();
        
        String join = pre.concat(pre2);
        if(join.contains(rear)){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
        
    }
}


Measured memory_bytes: 26284
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int datanum,x_now,y_now,index_x,index_y,hight_now;
    int i,j,zv_counter=0;
    int tmp_height,height;
    int field[128][8]={{0}};
    int ispeak=1;
    
    cin >> datanum;
    
    for(i=0;i<datanum;i++){
        cin >> field[i][0] >>field[i][1] >> field[i][2];
        if(field[i][2]!=0){
            zv_counter++;
            index_x=field[i][0];
            index_y=field[i][1];
        }
    }
    //
    tmp_height = 0;
    //
    for(j=0;j<10201;j++){
        x_now = j%101;
        y_now = j/101;
        ispeak= 1;

        for(i=0;i<datanum;i++){
            if(field[i][2]!=0){
                height = field[i][2] + abs(field[i][0]-x_now) + abs(field[i][1]-y_now);
                break;
            }
        }
        for(i=0;i<datanum;i++){
            
            tmp_height = field[i][2] + abs(field[i][0]-x_now) + abs(field[i][1]-y_now);
            
            if(field[i][2] != 0 && height != tmp_height){
                ispeak = 0;   
            }else if(zv_counter <= 1){
                x_now=index_x;
                y_now=index_y;
            }
        }
        if(ispeak) break;
    }
    cout <<x_now<<" "<<y_now<<" "<<height<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
using namespace std;
 
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
 
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(){
    int x,y,a,b,c;
    cin >> a >> b >> c >> x >> y;
    if(x<y){swap(x,y); swap(a,b);}
    // assume x>y
    int ans=0;
    if(a+b < c*2){
        // only use a b,
        ans = x*a + y*b;
    }else{
        ans += y*c*2;
        x-=y;
        if(a > c*2){
            ans += x * c * 2;
        }else{
            ans += x * a;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int a, b, c;
    int count = 0;
    
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++){
        if (c % i == 0) count ++;
    }
    cout << count << endl;
}




Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string S;cin>>S;
    if(S=="hi" or S=="hihi" or S=="hihihi" or S=="hihihihi" or S=="hihihihihi")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import heapq
    n, m, *ab = map(int, open(0).read().split())
    l = [[] for _ in range(m + 1)]
    for i, j in zip(*[iter(ab)] * 2):
        if i <= m:
            l[i].append(-j)

    ans = 0
    h = []
    for i in range(1, m + 1):
        g = l[i]
        for j in g:
            heapq.heappush(h, j)
        if len(h) > 0:
            x = heapq.heappop(h)
            ans += x

    print(-ans)


if __name__ == '__main__':
    main()


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

double one(int n, int x[], int y[]) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
        sum += abs(x[i] - y[i]);
    }
    return sum;
}

double two(int n, int x[], int y[]) {
    double sum = 0;

    for (int i = 0; i < n; i++) {
        sum += pow(abs(x[i] - y[i]), 2.0);
    }

    return sqrt(sum);
}

double three(int n, int x[], int y[]) {
    double sum = 0;

    for (int i = 0; i < n; i++) {
        sum += pow(abs(x[i] - y[i]), 3.0); 
    }

    return cbrt(sum);
}

double last(int n, int x[], int y[]) {
    double sum = 0;

    for (int i = 0; i < n; i++) {
        double a = abs(x[i] - y[i]);
        if (sum < a) {
            sum = a;
        }
    }

    return sum;
}

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

    int x[n] = {};
    int y[n] = {};

    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        x[i] = a;
    }
    for (int i = 0; i < n; i++) {
        cin >> a;
        y[i] = a;
    }

    cout << fixed << setprecision(6) << one(n, x, y) << endl;
    cout << fixed << setprecision(6) << two(n, x, y) << endl;
    cout << fixed << setprecision(6) << three(n, x, y) << endl;
    cout << fixed << setprecision(6) << last(n, x, y) << endl;
}


Measured memory_bytes: 3512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <random>
#include <set>
#include <sstream>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
double arr[MAXN];
ll v[MAXN];
pair<int, int> pv[MAXN];
struct FenwickTree {
    FenwickTree() {}
    inline void increase(int t, int x) {
        if (!t) return;
        for (int i = t; i <= 100; i += lowbit(i)) _arr[i] += x;
    }
    inline int getSum(int t) {
        int s = 0;
        for (int i = t; i; i -= lowbit(i)) s += _arr[i];
        return s;
    }
    int _arr[105];
    inline int lowbit(int x) { return x & (-x); }
};
FenwickTree tree[22];
struct Point {
    double x, y;
};
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll N = 1e18;
    for (int i = 1; i <= n; i++) {
        scanf("%lf", &arr[i]);
        v[i] = llround(arr[i] * 1e9);
        ll x = v[i];
        int c2 = 0, c5 = 0;
        while (x && x % 2 == 0) {
            x /= 2;
            c2++;
        }
        while (x && x % 5 == 0) {
            x /= 5;
            c5++;
        }
        pv[i] = {c2, c5};
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int n2 = max(0, 18 - pv[i].first);
        int n5 = max(0, 18 - pv[i].second);
        for (int k = n5; k < 22; k++) {
            ans += tree[k].getSum(100) - tree[k].getSum(n2);
        }
        tree[pv[i].second].increase(pv[i].first + 1, 1);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 8564
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s = input()

    if s[0] == "A":
        cnt = 0
        for i in range(2, len(s)-1):
            if s[i] == "C":
                cnt += 1

        if cnt == 1 and s[-1] != "C":
            for i in set(s):
                if i != "A" and i != "C":
                    if ord("a") <= ord(i) <= ord("z"):
                        continue
                    else:
                        print("WA")
                        break
            else:
                print("AC")
        else:
            print("WA")

    else:
        print("WA")


if __name__ == '__main__':
    main()


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

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

   if(n == m) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
s = input()
left_index = []
puddles = []

for i in range(len(s)):
    if s[i] == "\\":
        left_index.append(i)

    elif s[i] == "/" and len(left_index) > 0:
        left = left_index.pop()
        puddle = i - left

        while len(puddles) > 0 and puddles[-1][0] > left:
            puddle += puddles.pop()[1]

        puddles.append([left, puddle])

ans = [p[1] for p in puddles]
print(sum(ans))
if len(ans): print(len(ans), " ".join(map(str, ans)))
else : print(len(ans))



Measured memory_bytes: 6244
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const ll mod=998244353;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  string s;cin>>s;
  int n=s.size();
  if(n==3){
    if(s[0]==s[1]&&s[1]==s[2])cout<<1<<endl;
    else if(s[0]==s[1]||s[1]==s[2])cout<<6<<endl;
    else if(s[0]==s[2])cout<<7<<endl;
    else cout<<3<<endl;
    return 0;
    }
  
  int b=0,c=0;
  rep(i,n){
    if(s[i]=='a'){b+=2;c+=2;}
    if(s[i]=='b')b++;
    if(s[i]=='c')c++;
    }
  ll ok=1,flag=1;
  rep(i,n-1){
    if(s[i]==s[i+1])flag=0;
    if(s[i]!=s[i+1])ok=0;
    }
  if(ok){
    cout<<1<<endl;
    return 0;
    }
  b%=3;c%=3;
  ll dp[n][3][3][3],dpp[n][3][3][3];
  rep(i,3)rep(j,3)rep(k,3)
    dp[0][i][j][k]=dpp[0][i][j][k]=0;
  dp[0][0][2][2]=dpp[0][0][2][2]=1;
  dp[0][1][1][0]=dpp[0][1][1][0]=1;
  dp[0][2][0][1]=dpp[0][2][0][1]=1;
  rep(i,n-1)rep(j,3)rep(k,3){
    dp[i+1][0][j][k]=(dp[i][0][(j+1)%3][(k+1)%3]+dp[i][1][(j+1)%3][(k+1)%3]+dp[i][2][(j+1)%3][(k+1)%3])%mod;
    dp[i+1][1][j][k]=(dp[i][0][(j+2)%3][k]+dp[i][1][(j+2)%3][k]+dp[i][2][(j+2)%3][k])%mod;
    dp[i+1][2][j][k]=(dp[i][0][j][(k+2)%3]+dp[i][1][j][(k+2)%3]+dp[i][2][j][(k+2)%3])%mod;
    dpp[i+1][0][j][k]=(dpp[i][1][(j+1)%3][(k+1)%3]+dpp[i][2][(j+1)%3][(k+1)%3])%mod;
    dpp[i+1][1][j][k]=(dpp[i][0][(j+2)%3][k]+dpp[i][2][(j+2)%3][k])%mod;
    dpp[i+1][2][j][k]=(dpp[i][0][j][(k+2)%3]+dpp[i][1][j][(k+2)%3])%mod;
    }
  ll ans=flag;
  rep(i,3)ans+=dp[n-1][i][b][c]-dpp[n-1][i][b][c]+mod;
  ans%=mod;
  cout<<ans<<endl;
  return 0;    
  }

Measured memory_bytes: 84996
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a > 0 && k > a) ans += a;
    if(a > 0 && a >= k) ans += k;
    if(k - a - b > 0) ans -= k - a - b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		new Main();
	}
	
	public Main(){
		doIt();
	}
	
	public void doIt(){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[]sentence = str.split(" ");
		String maxStr = "";
		int freq = 0;
		int maxFreq = 0;
		String freqStr = "";
		for(int i = 0; i < sentence.length; i++){
			String target = sentence[i];
			if(maxStr.length() < target.length()){
				maxStr = target;
			}
			for(int k = i + 1; k < sentence.length; k++){
				if(target.equals(sentence[k])){
					freq++;
				}
			}
			if(maxFreq < freq){
				freqStr = target;
				maxFreq = freq;
			}
			freq = 0;
		}
		System.out.println(freqStr+" "+maxStr);
	}
	
}

Measured memory_bytes: 17132
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


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

    vector<int> towns;
    rep(i,N){
        towns.push_back(i);
    }

    vector<double> ans;
    do{
        double tmp = 0;
        for (int i = 0; i < N-1; i++){
            int X = x[towns[i]];
            int Y = y[towns[i]];
            int X2 = x[towns[i+1]];
            int Y2 = y[towns[i+1]];

            tmp += sqrt((X-X2)*(X-X2)+(Y-Y2)*(Y-Y2));
        }
        ans.push_back(tmp);
    }while(next_permutation(towns.begin(),towns.end()));

    double sum = 0;
    rep(i,ans.size()){
        sum += ans[i];
    }

    cout << fixed << setprecision(15);
    cout << sum/ans.size() << endl;
}

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

int main() {

    int N, D;
    cin >> N >> D;
	int range = 1 + 2 * D;
	int add = 1;
	if(N % range == 0){
		add = 0;
	}
    cout << N / range + add;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    double t, x;
    R t >> x;
    co(t / x);
}


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

int main() {
  long long N;
  long long K;
  cin >> N >> K;
  vector<long long> A(N), B(N,-1);
  for (long long i=0; i<N; i++) {
    cin >> A[i];
    A[i]--;
  }
  B[0]=0;
  long long pos=0, shuuki=0;
  long long machi;
  for (long long i=1; i<=K; i++) {
    pos=A[pos];
    //cout << pos << endl;
    if (B[pos]==-1) {
      B[pos]=i;
      continue;
    }
    else {
      shuuki = i-B[pos];
      //cout << B[pos] << endl;
      break;
    }
  }
  if (shuuki!=0) {
    K-=B[pos];
    long long mm = K-(K/shuuki)*shuuki;
    long long k=B[pos]+mm;
    for (long long i=0; i<N; i++) {
      if (B[i]==k) {
        machi=i+1;
        break;
      }
    }
  }
  else {
    machi=pos+1;
  }
  //cout << shuuki << endl;
  cout << machi << endl;
}


Measured memory_bytes: 6416
from collections import deque

n=int(input())
que_r=deque()

for i in range(n):
    s=input()
    l=len(s)
    if s[0]=="i":
        que_r.appendleft(s[7:])
    elif s[6]==" ":
        try:
            que_r.remove(s[7:])
        except: pass
    elif l>10:
        que_r.popleft()
    elif l>6:
        que_r.pop()

print(*que_r)


Measured memory_bytes: 69732
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define ld long double
#define MAX (2000 + 10)
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7;
ld eps = 1e-9;



void deal(){
	
	ld a;
	cin>>a;
	cout<<setp(14)<<2*M_PI*a;
}


int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}





























Measured memory_bytes: 3808
/*
  数字の和(与えられた数の各桁の和を計算するプログラム)
  2018/02/21
*/

#include<stdio.h>
int main(void){
  char num[1000];
  int i,sum;
  while(1){
    scanf("%s",num);
    i =0;
    if(num[i] == '0')
      break;
    sum =0;
    while(num[i] != '\0'){
      sum += (int)(num[i]-'0');
      i++;
    }
    printf("%d\n",sum);
  }
  return 0;
}


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

int main(){
    int a, b, ans;
    cin >> a >> b;
    ans = 0;
    for (int i = 0; i < 2; i++) {
        if (a > b) {
            ans += a;
            a--;
        }else{
            ans += b;
            b--;
        }
        
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  int b=1e15;
  rep1(i,sqrt(a)+1){
  if(a%i==0){
    if(b>i+a/i)
  b=i+a/i;
  }
  }
  cout<<b-2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 500003
typedef long long ll;

using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
ll arr[100000][3];

ll dp(ll v[][3],ll i,ll j,ll n)
{
    if(i>=n)
    {
        return 0;
    }
    if(arr[i][j]!=-1)
    {
        return arr[i][j];
    }
    arr[i+1][(j+1)%3]=dp(v,i+1,(j+1)%3,n);
    arr[i+1][(j+2)%3]=dp(v,i+1,(j+2)%3,n);
    arr[i][j]=v[i][j]+max(arr[i+1][(j+1)%3],arr[i+1][(j+2)%3]);
    return arr[i][j];
}


int main(){
    
    
        ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
forr(i,0,100000)
{
    arr[i][0]=arr[i][1]=arr[i][2]=-1;
    
}

 ll sum=0,act=0,k,n,q,f;
cin>>n;

ll v[n][3];

forr(i,0,n)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
      
    }
    ll a=dp(v,0,0,n);
    ll b=dp(v,0,1,n);
    ll c=dp(v,0,2,n);
    ll d=max(a,b);
   // cout<<a<<"" <<b<<" "<<c<<endl;
    d=max(d,c);
 cout<<d<<endl;

return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----


----解説ここまで---- */


int main() {

	LL N, C, K;
	cin >> N >> C >> K;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	SORT(a);

	LL ans = 0;
	for (LL i = 0; i < N;) {
		ans++;
		LL t = i;
		while (t < N&&t - i < C&&a[t] <= a[i] + K)t++;
		i = t;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
def answer(flag)
  if flag
    puts "Yes"
    exit
  end
end

a = []
3.times do
  a << gets.split.map(&:to_i)
end
n = gets.to_i
b = n.times.map { gets.to_i }
c = Array.new(3) { Array.new(3, false) }
b.each do |bi|
  3.times do |i|
    3.times do |j|
      if a[i][j] == bi
        c[i][j] = true
      end
    end
  end
end

flag = false
# naname
flag = (c[0][0] && c[1][1] && c[2][2])
answer(flag)
flag = (c[0][2] && c[1][1] && c[2][0])
answer(flag)

# yoko
3.times do |i|
  flag = c[i].all?
  answer(flag)
end

#tate
3.times do |i|
  flag = (c[0][i] && c[1][i] && c[2][i])
  answer(flag)
end
puts "No"


Measured memory_bytes: 1788
fun main(args: Array<String>) {
    readLine()
    val hs = listOf(0).plus(readLine()!!.split(' ').map { it.toInt() })

    var c = 0
    for (i in (1 until hs.size)) {
        c += Math.max(0, hs[i] - hs[i - 1])
    }

    println(c)
}


Measured memory_bytes: 38116
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int count[3] = { 0 };
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		count[S[i] - 'a']++;
	}
	if (abs(count[0] - count[1]) <= 1 && abs(count[1] - count[2]) <= 1 && abs(count[2] - count[0]) <= 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long int li;
typedef long long ll;
typedef long double ld;

int main()
{
	ll n, s = 0, x, y, d;
	cin >> n >> d;
	for (int i = 0; i < n; i++)
	{
		cin >> x >> y;
		if (x * x + y * y <= d * d)
			s++;
	}
	cout << s << "\n";
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ans(n+10,0);
    int a,b;
    for(int i = 1; i <= m; i++){
        cin >> a >> b;
        ans[a]++;
        ans[b]++;
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
// LightOj Pass : qavajxyq

#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << x << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7 ;
const ll INF = 1e18;

ll powmod(ll a, ll b, ll mod = MOD){
	ll res = 1ll;
	b %= (mod - 1ll), a %= mod;
	while(b){
		if(b%2 == 1)	res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}
	int cnt[100010];
bool comp(int a, int b){
	return cnt[a] > cnt[b];
}

int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;

	int n = s.length();
	if(s.back() == '1' or s[0] == '0'){
		cout << -1;
		return 0;
	}
	bool state = true;

	for(int l = 0, r = n-2; r >= 0; r--, l++){
		if(s[l] != s[r]){
			state = false;
		}
	}

	if(!state){
		cout << -1;
		return 0;
	}

	int cur = 2, ptr = 2;
	cout << 1 << " " << 2 << "\n";
	for(int i = 1; i < n-1; i++){
			cur++;
			cout << ptr << " " << cur << "\n";
		if((s[i] - '0')){
			ptr = cur;
		}
	}
}

Measured memory_bytes: 1616
#define DBG 0 //submit 0
#if DBG
    #include <algorithm>
    #include<array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    bool a = false;
    int i,j,k,tmp = 0,tmpi = 0,ans = 0;
    int N;
    //string S;
    cin >> N;


  	//sort(L.begin(),L.end(),greater<int>());
    for(i=1;i<10;i++){
      if((N/i <= 9)&&(i*(N/i) == N)){
        a = true;
        break;
      }
    }
  
  	if(a){
       cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

}


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

typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> pip;

const ll MAX_N = 2e5 + 10, MOD = 1e9 + 7;
ll n, m, ans;
ll Arr[MAX_N];
ll psum[MAX_N];

bool can(ll d) {
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        ll ind = lower_bound(Arr, Arr + n, d - Arr[i]) - Arr;
        if (i < ind)
            continue;

        cnt++;
        if (ind < i)
            cnt += 2 * (i - ind);
    }

    return cnt >= m;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> m;
    for (ll i = 0; i < n; i++)
        cin >> Arr[i];
    sort(Arr, Arr + n);

    ll s = 0, e = 3e5;
    while (e - s > 1) {
        ll mid = e + s >> 1;
        if (can(mid))
            s = mid;
        else
            e = mid;
    }

    psum[0] = Arr[0];
    for (ll i = 1; i < n; i++)
        psum[i] = psum[i - 1] + Arr[i];

    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        ll ind = lower_bound(Arr, Arr + n, s - Arr[i]) - Arr;
        if (i < ind)
            continue;

        ans += Arr[i] * 2;
        cnt++;
        if (Arr[i] * 2 == s) {
            ans -= Arr[i] * 2;
            cnt--;
        }

        if (ind < i) {
            cnt += 2 * (i - ind);
            ans += 2 * Arr[i] * (i - ind);
            ans += 2 * (psum[i - 1] - (ind? psum[ind - 1]: 0));
            if (Arr[i] + Arr[ind] == s) {
                cnt -= 2;
                ans -= 2 * (Arr[i] + Arr[ind]);
            }
        }
    }

    cout << ans + (m - cnt) * s << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll sum = 0;
    REP(i, N) {
        cin >> vec[i];
        sum += vec[i];
    }
    sum -= vec[0];
    sum %= MOD;

    ll ans = 0;
    REP(i, N-1) {
        ans += vec[i] * sum;
        ans %= MOD;
        sum -= vec[i + 1];
        if (sum < 0) {
            sum += MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
int num,a,b,sol=0;
cin>>num>>a>>b;
int temp;
for(int i=0;i<num;i++){
cin>>temp;
if(temp<a||temp>=b)
sol++;

}
cout<<sol<<endl;
return 0;
}

Measured memory_bytes: 256
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
while True:
    N = int(input())
    if N == 0:
        break
    table = list(map(int,input().split()))
 
    tmp_sum = 0
    for i in range(len(table)):
        tmp_sum += table[i]
    B = tmp_sum/len(table) #平均
 
    squared_sum = 0
    for i in range(len(table)):
        squared_sum += table[i]*table[i]
    A = squared_sum/len(table)
 
    print("%.10f"%(math.sqrt(A-B*B)))


Measured memory_bytes: 6400
x_input = ''
try:
    while True:
        x = input()
        x_input = x + x_input
        if x == '':
            break
except EOFError:
    pass

for i in range(97, 123):
    x_low = x_input.lower()

    print(chr(i), ':', str(x_low.count(chr(i))))



Measured memory_bytes: 5568
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

bool par(int n) {
    return (n%2==0);
}

int main(){

    int n;
    cin >> n;

    if (n%1000) cout << 1000 - n%1000 << endl;
    else cout << 0 << endl; 
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 55;
int a[5];
int main(int argc, char const *argv[])
{
    for(int i=1;i<=3;i++)cin>>a[i];
    sort(a+1,a+4);
    int ans = 0;
    int k = a[2]-a[1];
    if(k&1)ans+=k/2+2;
    else ans+=k/2;
    ans+=a[3]-a[2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (x : y : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ f x y

f :: Int -> Int -> Int
f x y = g x + g y + h x y

g :: Int -> Int
g 1 = 300000
g 2 = 200000
g 3 = 100000
g _ = 0

h :: Int -> Int -> Int
h 1 1 = 400000
h _ _ = 0

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;

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

int main() {
    int h, w, i, j, k, count, x, y, nx, ny;
    char c;
    char map_[100][100];
    queue<pair<int, int> > q;

    while (true) {
        cin >> h >> w;
        if (h==0 && w==0) {
            break;
        }
        for (i=0; i<h; i++) {
            getchar();
            for (j=0; j<w; j++) {
                map_[i][j] = getchar();
            }
        }
        count = 0;
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                if (map_[i][j] == 'x') {
                    continue;
                }
                count++;
                q.push(make_pair(i, j));
                c = map_[i][j];
                map_[i][j] = 'x';
                while (q.size() > 0) {
                    x = q.front().first;
                    y = q.front().second;
                    q.pop();
                    for (k=0; k<4; k++) {
                        nx = x+dx[k];
                        ny = y+dy[k];
                        if (nx<0 || ny<0 || nx>=h || ny>=w) {
                            continue;
                        }
                        if (map_[nx][ny] == c) {
                            q.push(make_pair(nx, ny));
                            map_[nx][ny] = 'x';
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1228
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,$x = gets.split.map(&:to_i)
$p,$b = 2.times.map{Array.new(51,0)}
$p[0] = 1
50.times do |i|
    $p[i+1] = $p[i]*2+1
    $b[i+1] = $b[i]*2+2
end

$ret = 0
def calc_p(d)
    return $ret if $x == 0
    if $x >= $p[d]+$b[d]
        $x -= $p[d]+$b[d]
        $ret += $p[d]
    else
        $x -= 1
        calc_p(d-1)
        return $ret if $x == 0
        $x -= 1
        $ret += 1
        calc_p(d-1)
        return $ret if $x == 0
        $x -= 1
    end
end
calc_p(n)
puts $ret

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
  int a[20000], b[20000], count=0,number[20000], i;
  char op = 'c';
  for (i=0; i<=20000; i++) {
    scanf("%d %c %d", &a[i+1] ,&op ,&b[i+1]);
    if (op == '?') {break;
    }
    count++;
    if ( op == '+' ){
      number[i+1]=a[i+1]+b[i+1];
    }
    else if ( op == '-' ){
      number[i+1]=a[i+1]-b[i+1];
    }
    else if ( op == '*' ){
      number[i+1]=a[i+1]*b[i+1];
    }
    else if ( op == '/' ){
      number[i+1]=a[i+1]/b[i+1];
    }
    else {

    }
  }

   for (i=1; i<=count; i++) {
    printf("%d\n" ,number[i]);
   }
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#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++)
int main() {
  int N;
  cin >> N;
  int64_t P = 1;
  rep(i, N) {
    P *= (i + 1) % 1000000007;
    P = P % 1000000007;
  }
  cout << P << endl;
}


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

int main() {
	// your code goes here
	
	int a,b;
	cin>>a>>b;
	if(b==1){
		cout<<"0";
		return 0;
	}
	if(a>=b){
		cout<<"1";
		return 0;
	}
	int cnt=1;
	int var=b-a;
	a--;
	cnt+=(var/a);
	if(var%a!=0)
		cnt++;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans=ans+1
print(ans)

Measured memory_bytes: 3064
var
i,j,c,d,e,b:longint;
s,s1,s2,s3:string;
begin
read(s);
s:=' '+s;
for i:=1 to length(s) do
if (s[i]=' ') and (s[i+1]<>' ') then write(s[i+1]);
end.

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 10000
#define NIL -1
struct Node_struct{int p, l, r;};
typedef struct Node_struct Node;
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if( u == NIL) return;
  D[u] = d;
  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].l != NIL) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL) h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].p == NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
  return NIL;
}

void print(int u){
   printf("node %d: parent = %d, sibling = %d, ", u, T[u].p, getSibling(u));
   int deg = 0;
   if(T[u].l != NIL) deg++;
   if(T[u].r != NIL) deg++;
   printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);

   if(T[u].p == NIL) printf("root\n");
   else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
   else printf("internal node\n");
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);

  for(i=0; i<n; i++) T[i].p = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l,&r);
    T[v].l = l;
    T[v].r = r;
    if( l != NIL) T[l].p = v;
    if( r != NIL) T[r].p = v;
  }

  for(i=0; i<n; i++) if(T[i].p == NIL) root = i;

  setDepth(root, 0);
  setHeight(root);

  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 2052
L = input()
MOD = 10**9+7
l = len(L)
dp0 = [0]*(l+1)
dp1 = [0]*(l+1)
dp1[0] = 1
for i in range(1,l+1):
  c = L[i-1]
  if c=='1':
    dp0[i] = dp0[i-1]*3+dp1[i-1]
    dp1[i] = dp1[i-1]*2
  else:
    dp0[i] = dp0[i-1]*3
    dp1[i] = dp1[i-1]
  dp0[i] %= MOD
  dp1[i] %= MOD
print((dp0[-1]+dp1[-1])%MOD)

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

using namespace std;
#define int long long
using ld = long double;

signed main() {
    int n, k;
    cin >> n >> k;
    int dp[k+1] = {0};
    int arr[n+1];
    int i;
    for(i=1;i<=n;i++)
        cin >> arr[i];
    int j;
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i >= arr[j])
                dp[i]|=(1 - dp[i - arr[j]]);
        }
    }
    if(dp[k] == 1)
        cout << "First";
    else
        cout << "Second";
    // dp[n][0][0]
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=1; b<=a; b++){
		c=b;d=0;
		while(c>0){
			c/=10;
			d++;
		}
		if(d%2==1) e++;
	}
	cout<<e;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 44
 int function(int n){
   int i,F[MAX];
   if(n==0||n==1)return 1;
   F[0]=1;
   F[1]=1;
   for(i=2;i<=n;i++)F[i]=F[i-2]+F[i-1];
return F[n];
 }
 int main(){

   int x,n;

   scanf("%d",&n);
   x=function(n);
   printf("%d\n",x);
   return 0;
 }



Measured memory_bytes: 2104
#include <stdio.h>

#define N 101

int main() {
	int i,j,n;
	int u,k,v;
	int M[N][N] = {};

	scanf("%d", &n);
	for (i=1;i<=n;i++) {
		scanf("%d%d",&u,&k);
		for (j=1;j<=k;j++) {
			scanf("%d",&v);
			M[u][v] = 1;
		}
	}

	for (i=1;i<=n;i++) {
		for (j=1;j<=n;j++) {
			printf("%d",M[i][j]);
			if (j != n) printf(" ");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int main() {
    ll n;
    cin >> n;
    ll ans=0;
 
    ll five = 5;
 
    while(five*2<=n) {
        if (n%five == 0) {
            ans += n/(2*five);
        } else {
            if(n%2 == 0) {
                ans += n/(2*five);
            } else {
                ans += n/(2*five) +1;
            }
        }
        five *= 5;
    }

    if (n%2 == 1) ans = 0;
    cout << ans << endl;
}
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N, D;
int X[30][30];
int ans;

int main(){
	cin >> N >> D;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < D; j++){
			cin >> X[i][j];
		}
	}
	for (int i = 0; i < N; i++){
		for (int j = i+1; j < N; j++){
			int sum = 0;
			for (int k = 0; k < D; k++){
				int diff = abs(X[i][k] - X[j][k]);
				sum += diff*diff;
			}
			bool flag = false;
			for (int k = 0; k <= sum; k++){
				if (k*k == sum){
					flag = true;
				}
			}
			if (flag)ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

int a[200005],b[200005];
int n,m,tot=1;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	sort(a+1,a+n+1);sort(b+1,b+m+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[tot]) tot++;
		if(tot>m)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");
}

Measured memory_bytes: 1664
# B
# 2020/03/07 0:22-
s = input()

l = 0
r = 3
ans = abs(int(s[l:r]) - 753)
while r != len(s)+1:
    l += 1
    r += 1
    if ans > abs(int(s[l:r]) - 753):
        ans = abs(int(s[l:r]) - 753)
        
print(ans)

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

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

const int N = (int) 1e3 + 10;
const int P = (int) 1e9 + 7;
int n, a, b, c, d;
int fac[N], inv[N], g[N][N], dp[N][N];

int Power(int a, int k) {
    int ans = 1;
    while (k) {
        if (k & 1) ans = (LL) ans * a % P;
        a = (LL) a * a % P;
        k >>= 1;
    }
    return ans;
}

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

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

    fac[0] = inv[0] = 1;
    for (int i = 1; i <= 1000; ++i) {
        fac[i] = (LL) fac[i - 1] * i % P;
        inv[i] = Power(fac[i], P - 2);
    }
    for (int v = 1; v <= 1000; ++v) {
        g[v][0] = 1;
        for (int i = 1; i <= 1000; ++i) g[v][i] = (LL) g[v][i - 1] * inv[v] % P;
    }

    dp[a - 1][0] = 1;
    for (int v = a; v <= b; ++v)
        for (int s = 0; s <= n; ++s) {
            dp[v][s] = dp[v - 1][s];
            for (int i = c; i <= d && i * v <= s; ++i) {
                int coef = (LL) fac[i * v] * g[v][i] % P * inv[i] % P;
                int ways = (LL) fac[s] * inv[i * v] % P * inv[s - i * v] % P;
                dp[v][s] = (dp[v][s] + (LL) dp[v - 1][s - i * v] * coef % P * ways) % P;
            }
        }

    printf("%d", dp[b][n]);
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  vector<int> vec(200,0);
  rep(i,b){
    int x;
    cin >> x;
    vec[x]++;
  }
  int now=0;
  bool k=true;
  while(k){
    if(a-now>=0){
      if(vec[a-now]==0) {
        cout << a-now << endl;
        break;
      }
    }
    else{
      cout << a-now << endl;
      break;
    }
    if(vec[a+now]==0) {
      cout << a+now << endl;
      break;
    }
    now++;
  }

}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define sp(x) fixed<<setprecision(x)
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define die(x) return cout << x << endl, 0
#define fastio ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
const int MAXN = 100 * 1000 + 10;
int n, p, neg;
int a[MAXN], dp[MAXN];
int main(){
    fastio;
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
    }
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
//    cout << "dp0: " << dp[0] << endl << "dp1: " << dp[1] << endl;
    for(int i = 2; i < n; i ++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
//        cout << "dp" << i << ": min( " << dp[i - 1] << " + " << a[i] << " - " << a[i - 1] << ", " << dp[i - 2] << " + " << a[i] << " - " << a[i - 2] << " );\n";
    }
    die(dp[n - 1]);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 2e6 + 10;
ll fact[MAXN];
const ll MOD = 1e6 + 3;

ll power(ll x,ll y){
    ll res = 1;

    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y >>= 1;
    }
    return res;
}

ll invmod(ll x){
    return power(x,MOD-2);
}

void solve(){   
    fact[0] = 1;
    FOR(i,1,MAXN-1) fact[i] = (fact[i-1]*i)%MOD;

    ll q; cin>>q;

    while(q--){
        ll x,d,n; cin>>x>>d>>n;
        
        if(d == 0){
            cout<<power(x,n)<<endl;
            continue;
        }

        ll inv_x_d = (x*invmod(d))%MOD;

        if(inv_x_d + n - 1 >= MOD){
            cout<<0<<endl;
            continue;
        }

        ll ans = (fact[inv_x_d + n-1]*invmod(fact[inv_x_d-1]))%MOD;
        ans = (ans*power(d,n))%MOD;
        cout<<ans<<endl;
    } 
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 16512