akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lec11B
{
    class Element
    {
        public int id;
        public int degree;
        public int [] next_list;
        public int state;
        public int d;
        public int f;

        public void Setting(int n)
        {
            next_list = new int[n];
            state = 0; 
        }

    }
    class Program
    {
        static  int time = 0;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Element [] arr = new Element[n];

            for (int i = 0; i < n; i++)
            {
                string [] input = (Console.ReadLine()).Split(' ');

                arr[int.Parse(input[0])-1] = new Element();
                arr[int.Parse(input[0])-1].id = int.Parse(input[0]);
                arr[int.Parse(input[0])-1].Setting(int.Parse(input[1]));
                arr[int.Parse(input[0])-1].degree = int.Parse(input[1]);

                for (int j = 0; j < int.Parse(input[1]); j++)
                {
                    arr[int.Parse(input[0])-1].next_list[j] = int.Parse(input[j + 2]);
                }

            }

            DFS(arr);

            for (int i= 0; i < n; i++)
            {
                Console.WriteLine(arr[i].id + " " + arr[i].d + " " + arr[i].f);
            }

            Console.ReadLine();
        }

        static void DFS(Element [] g)
        {
            for ( int i = 1; i <= g.Length; i++)
            {
                if (g[i-1].state == 0) {
                    Visit(g, i);
                }
            }

        }

        static void Visit(Element [] u , int i)
        {
            u[i-1].state = 1;
            time++;
            u[i-1].d = time;

            foreach (int j in  u[i-1].next_list)
            {
                if (u[j-1].state == 0)
                {
                    Visit(u, j);
                }
            }
            u[i-1].state += 1;
            time++;
            u[i-1].f = time;

         }
    }
}


Measured memory_bytes: 17940
#include <string>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;

int main() {
	string S, T;
	cin >> S >> T;
	string tmp = T.substr(0, T.size()-1);
	if (S == tmp) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}
	return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, M; cin >> N >> M;
    vector<P> pv(M);
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        pv[i] = make_pair(b, a);
    }
    sort(all(pv));
    int right = -1;
    int res = 0;
    for(auto p: pv){
        if(right <= p.second){
            res++;
            right = p.first;
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <string>
#include <math.h>
#define MOD 1000000007

using namespace std;
int main()
{
    long long ans=0;
    int a[201][201];
    int c[10][10];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>c[i][j];
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(a[i][j]==-1||a[i][j]==1)continue;
            else ans+=c[a[i][j]][1];
        }
    }
    cout<<ans<<endl;
    return 0;


}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cassert>
using namespace std;

int A[1000000], n;

int main(){
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
  }

  int q, k, sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ){
    scanf("%d", &k);
    if ( *lower_bound(A, A + n, k) == k) sum++;
  }

  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
bool prime[1000009];
int dp[1000009];
void seive()
{
    memset(prime,true,sizeof prime);
    prime[0]=prime[1]=false;
    for(int i=2; i*i<=100001; i++)
    {
        if(prime[i]==true)
        {
            for(int j=i*2; j<=100001; j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
void pre()
{
    dp[0]=0;
    for(int i=1; i<=100000; i++)
    {
        int n=i;
        int nn=(n+1)/2;
        if(prime[n]==true && prime[nn]==true)
        {
            dp[i]=dp[i-1]+1;
        }
        else
        {
            dp[i]=dp[i-1];
        }
    }
}
int main()
{
    seive();
    pre();
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<dp[r]-dp[l-1]<<endl;
    }
}


Measured memory_bytes: 3840
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int M = sc.nextInt();
   boolean[] one_to_i = new boolean[N+1];
   boolean[] i_to_n = new boolean[N+1];
   int tmpa = 0;
   int tmpb = 0;
   for(int i=0;i<M;i++)
   {
     tmpa = sc.nextInt();
     tmpb = sc.nextInt(); 
     if(tmpa==1) one_to_i[tmpb] = true;
     if(tmpb==N) i_to_n[tmpa] = true;
   }
   boolean forans = false;
   String ans = "IMPOSSIBLE";
   for(int i=1;i<N;i++)
   {
     if(one_to_i[i])
     {
       if(i_to_n[i]) 
       {
         forans = true;
         break;
       }
     }
   }
   if(forans) ans = "POSSIBLE"; 
   System.out.println(ans);
 }
}

Measured memory_bytes: 93424
#include<iostream>
#include<string>
using namespace std;
bool func() {
	string str;
	cin >> str;
	int res = 1;
	for (int i = 1; i < str.size(); ++i) {
		if (str[i] == str[i - 1]) {
			if (++res == 3) {
				return true;
			}
		}
		else {
			res = 1;
		}
	}
	return false;
}
int main() {
	cout << (func() ? "Yes" : "No") << endl;
	return 0;
}

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

int main() {
  int K, X;
  int S;	
  cin >> K >> X;	
  S = 500*K;
  if(S>=X){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 09.08.2020 15:50:51       
**/
#include <bits/stdc++.h>

using namespace std;

typedef uint64_t HT;

mt19937 rng(787788789);

struct hash61 {
  static const HT md = (1LL << 61) - 1;
  static HT step;
  static vector<HT> pw;
 
  static HT addmod(HT a, HT b) {
    a += b;
    if (a >= md) a -= md;
    return a;
  }
 
  static HT submod(HT a, HT b) {
    a += md - b;
    if (a >= md) a -= md;
    return a;
  }
 
  static HT mulmod(HT a, HT b) {
    HT l1 = (uint32_t) a, h1 = a >> 32, l2 = (uint32_t) b, h2 = b >> 32;
    HT l = l1 * l2, m = l1 * h2 + l2 * h1, h = h1 * h2;
    HT ret = (l & md) + (l >> 61) + (h << 3) + (m >> 29) + (m << 35 >> 3) + 1;
    ret = (ret & md) + (ret >> 61);
    ret = (ret & md) + (ret >> 61);
    return ret - 1;
  }
 
  void ensure_pw(int sz) {
    int cur = (int) pw.size();
    if (cur < sz) {
      pw.resize(sz);
      for (int i = cur; i < sz; i++) {
        pw[i] = mulmod(pw[i - 1], step);
      }
    }
  }
 
  vector<HT> pref;
  int n;
 
  template<typename T>
  hash61(const T& s) {
    n = (int) s.size();
    ensure_pw(n + 1);
    pref.resize(n + 1);
    pref[0] = 1;
    for (int i = 0; i < n; i++) {
      pref[i + 1] = addmod(mulmod(pref[i], step), s[i]);
    }
  }
 
  inline HT operator()(const int from, const int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    return submod(pref[to + 1], mulmod(pref[from], pw[to - from + 1]));
  }
};
 
HT hash61::step = (md >> 2) + rng() % (md >> 1);
vector<HT> hash61::pw = vector<HT>(1, 1);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  vector<HT> h(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    h[i] = 0;
    for (int j = (int) s[i].size() - 1; j >= 0; j--) {
      h[i] = hash61::addmod(hash61::mulmod(h[i], hash61::step), (int) s[i][j]);
    }
  }
  sort(h.begin(), h.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    vector<int> cnt(26, 0);
    for (char c : s[i]) {
      cnt[(int) (c - 'a')] += 1;
    }
    HT hh = 0;
    for (int j = (int) s[i].size() - 1; j >= 1; j--) {
      for (int c = 0; c < 26; c++) {
        if (cnt[c] > 0) {
          HT f = hash61::addmod(hash61::mulmod(hh, hash61::step), (int) (c + 'a'));
          auto it = lower_bound(h.begin(), h.end(), f);
          if (it != h.end() && *it == f) {
            ++ans;
          }
        }
      }
      hh = hash61::addmod(hash61::mulmod(hh, hash61::step), (int) s[i][j]);
      cnt[(int) (s[i][j] - 'a')] -= 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11100
#include <iostream>
#include <vector>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

int main()
{
	int n, m, ans=0;
	cin >> n >> m;
	vector<int> h(n);
	vector<bool> good(n, true);
	rep (i, n) {
		cin >> h.at(i);
	}
	rep (i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (h.at(a) <= h.at(b)) good.at(a) = false;
		if (h.at(b) <= h.at(a)) good.at(b) = false;
	}
	for (auto a : good) if (a) ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3796
#https://atcoder.jp/contests/abc132/tasks/abc132_b

n = int(input())
p = [int(i) for i in input().split()]

cnt = 0
for i in range(1,n-1):
    q = [p[i-1],p[i],p[i+1]]
    q.sort()
    if p[i] == q[1]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
main = do
    str <- getLine
    let [a, b] = map read $ words $ str :: [Integer]
    let i2b =  i2b' where i2b' 0 = []; i2b' n = mod n 2 : i2b' (div n 2)
    let toMod x = x `mod` 1000000007
    let ans = foldl (\x y -> toMod (x * y) ) 1 $ filter (/=0) $ zipWith (*) (iterate (toMod . (^2) ) a) $ i2b b
    putStrLn $ show ans

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 2000000000
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to;
};

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

ll fac[2000020];

ll calc(ll r, ll c) {
    return fac[r + c] * modpow(fac[r], MOD - 2, MOD) % MOD *
           modpow(fac[c], MOD - 2, MOD) % MOD;
}

signed main() {
    fac[0] = 1;
    rep(i, 2000010) fac[i + 1] = fac[i] * (i + 1) % MOD;
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans = calc(r2 + 1, c2 + 1) - calc(r2 + 1, c1) - calc(r1, c2 + 1) +
             calc(r1, c1);
    ans %= MOD;
    if(ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
// SZ = 1e6 だと10ms
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true, sc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
            }
            if (cnt == N) {
                sc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else if (sc) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 19020
using System;

class Program
{
 public static void Main()
 {
   int[] sum = new int[3];
   int max = 0;
   var num = Console.ReadLine().Split(' ');
   var A = int.Parse(num[0]);
   var B = int.Parse(num[1]);
   sum[0] = A + B;
   sum[1] = A - B;
   sum[2] = A * B;
   
   max = Math.Max(sum[0],sum[1]);
   max = Math.Max(max,sum[2]);
   
   Console.WriteLine(max);
 }
}


Measured memory_bytes: 13140
from collections import deque
n,m = map(int, input().split())


graph = [[] for _ in range(n+1)]
for i in range (m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

#print(graph)

dist = [-1]*2 + [0 for i in range (n-1)]

d = deque([1])
#print(d)

while d:
    v = d.popleft()
    for i in graph[v]:
        if dist[i] == 0:
            dist[i] = v
            d.append(i)

print("Yes")
ans = dist[2:]
print(*ans, sep="\n")

Measured memory_bytes: 36596
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	double r;
	double s=0, l=0, PI=3.141592653589;
	cin >> r;
	
	s = PI*r*r;
	l = 2*PI*r;
	
	printf("%f %f\n", s, l);
	
	return 0;
}

Measured memory_bytes: 3272
def calc_watering_num(h, offset, left, right):
        if left > right:
                return 0
        min_h = None
        min_h_indices = []
        for i in range(left, right + 1):
                if min_h is None or min_h > h[i] - offset:
                        min_h = h[i] - offset
                        min_h_indices = [i]
                elif min_h == h[i] - offset:
                        min_h_indices.append(i)
        if len(min_h_indices) == right - left + 1:
                return min_h
        num = min_h
        prev = left
        for i in min_h_indices:
                num += calc_watering_num(h, offset + min_h, prev, i - 1)
                prev = i + 1
        num += calc_watering_num(h, offset + min_h, prev, right)
        return num


input()
h = [int(v) for v in input().split()]
print(calc_watering_num(h, 0, 0, len(h) - 1))

Measured memory_bytes: 3064
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

K = ri()
X = K // 50
mod = K % 50
a = [49 - mod + X for i in range(50)]
for i in range(mod):
    a[i] += 51
print(50)
print(plis(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,w,h,t;
	scanf("%d %d %d",&h,&w,&n);
	t=max(h,w);
	if(n%t==0)
	{
		printf("%d",n/t);
	}
	else
	{
		printf("%d",n/t+1);
	}
	return 0;
}

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

using namespace std;

int memo[100][100][201], mat[101][101], n, m;

int solve(int i, int j, int b) {
    if (i == n || j == m)
        return 1e9;
    if (i == n - 1 && j == m - 1)
        return b;

    int &r = memo[i][j][b];
    if (r == -1) {
        r = 1e9;
        if (!mat[i][j])
            r = min(solve(i + 1, j, b + (mat[i + 1][j] == 1)), solve(i, j + 1, b + (mat[i][j + 1] == 1)));
        else
            r = min(solve(i + 1, j, b), solve(i, j + 1, b));
    }

    return r;
}

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

    memset(memo, -1, sizeof memo);

    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            mat[i][j] = (c == '#');
        }

    cout << solve(0, 0, mat[0][0]) << '\n';

    return 0;
}


Measured memory_bytes: 8192
import java.io.*;
import java.util.Scanner;
 
public class Main {
    public static boolean range(int a, int b, int c) {
        if (a >= b) return false;
        if (b >= c) return false;
        return true;
    }
 
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (range(a, b, c)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26268
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   if(Arr[i]==-1)break;
   var a=Arr[i];
   var sum=1150;
   if(a>10 && a<=20)sum=1150+125*(a-10);
   else if(a>20 && a<=30)sum=1150+125*10+140*(a-20);
   else if(a>30)sum=1150+125*10+140*10+160*(a-30);
   console.log(4280-sum);
}

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

using namespace std;

long gcd(long a, long b){
	long c;
	while(b){
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}

int main(){
	long n;
	long x, a, dif;
	cin >> n >> x;

	cin >> a;
	dif = abs(x - a);
	for(long i = 1 ; i < n ; i++){
		cin >> a;
		dif = gcd(abs(x-a) , dif);
	}

	cout << dif << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,a[110000];int x[3],ans;
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  x[0] = x[1] = x[2] = 0;ans = 1;
  rep(i,n){
    int cnt = 0;
    rep(j,3){
      if(x[j] == a[i]){
        cnt++;
        if(cnt == 1){
          x[j]++;
        }
      }
    }
    ans = ans * cnt % MOD;
  }
  cout << ans << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
ll s, t, d;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m ;
	vpll a;
	ll cou = 0;
	for(ll i=0;i<n;i++) {
		cin >> x >> y;
		a.pb({x,y});
	}
	sort(all(a));
	for(ll i=0;i<n;i++) {
		if(m <= a[i].s) {
			cou+=m*a[i].f;
			break;
		}
		cou+=a[i].f*a[i].s;
		m-=a[i].s;
	}	
	cout<<cou;newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5340
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T, typename U>
T max(T x, U y)
{
    return x>y ? x : y;
}
template <typename T, typename U>
T min(T x, U y)
{
    return x<y ? x : y;
}
ll b[1000000];
ll _(ll i,ll j)
{
    if(i==0)return b[j];
    else return b[j]-b[i-1];
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;
    ll a[n];ll sm=0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];sm+=a[i];
    }
    
    b[0]=a[0];
    for (int i = 1; i < n; ++i)
    {
        b[i]=a[i]+b[i-1];
    }
    ll dp[n][n];
    memset(dp, 0, sizeof(dp));
    for(ll i=n-1;i>=0;i--)
    {
        for(ll j=i;j<n;j++)
        {
            if(i==j)dp[i][j]=a[i];
            else
            {
                ll p1=dp[i+1][j];ll q1=dp[i][j-1];
                ll p2=_(i+1,j)-p1;ll q2=_(i,j-1)-q1;
                dp[i][j]=max(p2+a[i],q2+a[j]);
                /*if(p>q)dp[i][j]=a[j];
                else if(p<q)dp[i][j]=a[i];
                else if(p==q)dp[i][j]=max(a[i],a[j]);*/
            }
        }
    }
    /*for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[0][n-1]-(sm-dp[0][n-1]);
    //trace(sm);
    }

Measured memory_bytes: 70656
import math
 
a,b,h,m=map(int, input().split())
 
h_kaku=(2*math.pi*(h+m/60))/12
m_kaku=(2*math.pi*m)/60
 
h_x=a * math.cos(-h_kaku+math.pi/2)
h_y=a * math.sin(-h_kaku+math.pi/2)
 
m_x=b * math.cos(-m_kaku+math.pi/2)
m_y=b * math.sin(-m_kaku+math.pi/2)
 
nagasa=math.sqrt((h_x-m_x)**2+(h_y-m_y)**2)
print(nagasa)

Measured memory_bytes: 9584
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll N, K;
vector<ll> stones;
vector<ll> dp;

ll rec (int curr){
    if(curr >= N-1){
        return 0;
    }
    if(dp[curr] != -1){
        return dp[curr];
    }
    
    ll res = oo;

    FOR(i, 1, K+1){
        if(curr+i >= N){ break;}
        ll new_cost = abs(stones[curr] - stones[curr+i]);
        ll next = rec(curr + i) + new_cost;
        res = min(res, next);
    }
    dp[curr] = res;
    return res;
}

int main() {

    cin >> N >> K;
    stones.resize(N);
    dp.assign(N, -1);
    FOR(i, 0, N){
        cin >> stones[i];
    }
    
    cout << rec(0) << endl;
    
    return 0;
}



Measured memory_bytes: 9600
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  200005
vi a[N];

void solve()
{
	ll n;
	cin>>n;
	ll x;
	rep(i,2,n+1)
	{
		cin>>x;
		a[x].pb(i);
	}
	rep(i,1,n+1)
	{
		cout<<sz(a[i])<<endl;
	}
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll X;

    cin >> X;
    for(long long i = -200; i <= 200; i++ ){
        for(long long j= -200; j <= 200; j++ ){
            long long A = (i*i*i*i*i);
            long long B = (j*j*j*j*j);
            if( A - B == X ){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

long a,b,c;

int main(){
    cin>>a>>b>>c;

    if(c-a-b<0){
        cout<<"No";
    }else if(a*a+b*b+c*c-2*a*b-2*b*c-2*c*a>0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int F[50];

int fibonacci(int n){
  if(n==0||n==1) return F[n]=1;
  if(F[n]!=-1) return F[n];
  return F[n]=fibonacci(n-1)+fibonacci(n-2);
}

int main(){
  int n, i;
  for(i=0;i<50;i++) F[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0; 
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;

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

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

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

int n;
ll aa,bb;
vector<pll> bugu[5];

const int N = 1<<15;
set<ll> seg[2*N];

bool query(int l,int r,ll ymn,ll ymx,int a,int b,int k){
  if(r<=a || b<=l)return false;
  if(l<=a && b<=r){
    ll v = *(seg[k].lower_bound(ymn));
    return ymn <= v && v <= ymx;
  }else{
    int m = (a+b)/2;
    return query(l,r,ymn,ymx,a,m,2*k+1) || query(l,r,ymn,ymx,m,b,2*k+2);
  }
}

const ll INF = 1e18;

int main(){
  scanf("%d%lld%lld",&n,&aa,&bb);
  REP(i,n){
    int t;ll x,y;scanf("%d%lld%lld",&t,&x,&y);
    --t;
    bugu[t].push_back(pll(x,y));
  }
  sort(bugu,bugu+5,[&](vector<pll> a,vector<pll> b){return a.size() > b.size();});
  REP(i,5)bugu[i].push_back(pll(0,0));

  // rekkyo
  vector<pll> mp;
  set<ll> xs;
  REP(i,bugu[3].size())REP(j,bugu[4].size()){
    ll x=0, y=0;
    x+=bugu[3][i].first;  y+=bugu[3][i].second;
    x+=bugu[4][j].first;  y+=bugu[4][j].second;
    mp.push_back(pll(x,y));
    xs.insert(x);
  }
  xs.insert(INF);
  xs.insert(-INF);
  // zaatu
  map<ll,int> ids;
  {
    int it = 0;
    for(ll x : xs){
      ids[x] = it++;
    }
  }
  // construct set on segment tree
  REP(i,N){
    seg[i+N-1].insert(INF);
    seg[i+N-1].insert(-INF);
  }
  for(pll P : mp){
    ll x = ids[P.first];
    ll y = P.second;
    seg[x+N-1].insert(y);
  }
  FOR(i,0,N-1){
    int lch = 2*i+1;
    int rch = 2*i+2;
    for(ll y : seg[lch]){
      seg[i].insert(y);
    }
    for(ll y : seg[rch]){
      seg[i].insert(y);
    }
  }

  // query
  REP(i,bugu[0].size())REP(j,bugu[1].size())REP(k,bugu[2].size()){
    ll x=0, y=0;
    x+=bugu[0][i].first;  y+=bugu[0][i].second;
    x+=bugu[1][j].first;  y+=bugu[1][j].second;
    x+=bugu[2][k].first;  y+=bugu[2][k].second;
    // a <= x + tx <= b
    // a <= y + ty <= b
    // a-x <= tx <= b-x
    // a-y <= ty <= b-y
    int leftx = ids.lower_bound(aa-x)->second;
    int rightx = ids.upper_bound(bb-x)->second;
    bool ok = query(leftx,rightx,aa-y,bb-y,0,N,0);
    if(ok){
      puts("Yes");
      return 0;
    }
  }
  puts("No");

  return 0;
}

Measured memory_bytes: 12936
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

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

	int tmp = 0;
	for(int i = n-1;i > 0;i--){
		for(int j = 0; j < i;j++){
			if(array[j] > array[j+1]){
				tmp = array[j+1];
				array[j+1] = array[j];
				array[j] = tmp;
				change_count++;
			}
		}
	}

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long

typedef pair<int, int> PP;

int sign(int N){
	if (N > 0) return 1;
	if (N < 0) return -1;
	return 0;
}

int main(){

	int H, W;
	int a[501][501];
	vector<pair<PP,PP>> list;

	cin >> H >> W;

	for (int h = 1; h <= H; h++)
		for (int w = 1; w <= W; w++)
			cin >> a[h][w];

	for (int h = 1; h <= H; h++)
	for (int w = 1; w <= W; w++){
			// 奇数があったら
			if (a[h][w] % 2 == 1){
				// 右へ向かう
				if (w != W){
					list.push_back(pair<PP, PP>(PP(h, w), PP(h, w + 1)));
					a[h][w] --;
					a[h][w + 1]++;
					continue;
				}
				// 下へ向かう
				if (h != H){
					list.push_back(pair<PP, PP>(PP(h, w), PP(h + 1, w)));
					a[h][w] --;
					a[h + 1][w]++;
				}
			}
	}
		

	cout << list.size() << endl;
	for (int i = 0; i < list.size(); i++){
		cout << list[i].first.first << " " << list[i].first.second << " "
			<< list[i].second.first << " " << list[i].second.second << endl;
	}

	return 0;
}


Measured memory_bytes: 5104
/**
*    author:  yuya1234
*    created: 09.07.2020 10:02:44
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int a[n],A[n+1];
  MEMSET(A,0);
  REP(i,n)
  {
    cin>>a[i];
    A[a[i]]++;
  }

  ll sum=0;
  REP(i,n+1)
  {
    ll tt=A[i];
    sum+=(tt*(tt-1))/2;
  }

  REP(i,n)
  {
    ll tt=A[a[i]]-1;
    cout<<sum-tt<<endl;
  }

  return 0;
}

Measured memory_bytes: 5176
#include <iostream>
#include <string>
//插入排序
using namespace std;
int main(){
	int i,j,k,m,n;
	int a[105];
	while(cin>>n)
	{
		for(i=0;i<n;i++)
			cin>>a[i];
		for(i=0;i<n-1;i++)
			cout<<a[i]<<" ";
		cout<<a[n-1]<<endl; 
		for(i=1;i<n;i++)
		{
			m=a[i];
			for(j=i-1;j>=0;j--)
			{
				if(a[j]>m)
					a[j+1]=a[j];
				else break;
			}
			a[j+1]=m;
			for(k=0;k<n-1;k++)
				cout<<a[k]<<" ";
			cout<<a[n-1]<<endl;	
		}
		
	}
} 


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include<algorithm>
#include <iomanip>
#include <limits>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> tmp(N,0);
	for (int i = 0;i < N;i++) {
		cin >> tmp[i];
	}
	vector<long long> P(N,0);
	for (int i = 0;i < N;i++) {
		P[i] = (tmp[i] + 1);
	}
	vector<long long> S(N+1, 0);
	for (int i = 1;i < N+1;i++) {
		S[i] = S[i - 1] + P[i-1];
	}
	long long max = 0;
	for (int i = 0;i < N - K + 1;i++) {
		max = std::max(max,S[K+i] - S[i]);
	}

	cout << fixed << std::setprecision(10) << max/2.0 << endl;

	return 0;
}




Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Inf 0x3f3f3f3f


int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int ans=s2.find(s1);
	if(ans!=0)
	cout<<"No"<<endl;
	else
	{
		cout<<"Yes"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3624
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll cnt=0,n,k;
  cin >> n >> k; 
  ll h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h,h+n,greater<ll>());
  for(int i=0;i<n;i++){
    if(i>=k)cnt += h[i];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int sec(int,int,int);

int main(){
 
  int i=0;

  while(i<3) {
    int ha,ma,sa,hb,mb,sb;
    scanf("%d %d %d",&ha,&ma,&sa);
    scanf("%d %d %d",&hb,&mb,&sb);

    int seca=sec(ha,ma,sa);
    int secb=sec(hb,mb,sb);
    int secc=secb-seca;

    int hc,mc,sc;
    hc=secc/3600;
    secc%=3600;
    mc=secc/60;
    secc%=60;
    sc=secc;

    printf("%d %d %d\n",hc,mc,sc);

    i++;
  }
  return 0;
}

int sec(int h,int m,int s){
  int sec;
  sec=h*3600+m*60+s;
  return sec;
}

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

// Begin {{{
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)

#ifndef DEBUG
#define dump(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<int> a(N + 10);
    reps(i, 1, N) cin >> a[i];
    reps(k, 1, M) reps(i, 1, N - 1) {
        if (a[i] % k > a[i+1] % k) swap(a[i], a[i+1]);
    }
    reps(i, 1, N) cout << a[i] << "\n";
    return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
const int N=1e5+5;
int pa[N],cnt[N],fr[N];
 int n,m,k;
int search(int x){
    //return pa[x]==pa[pa[x]]?pa[x]:pa[x]=search(pa[x]);
    if(pa[x]!=pa[pa[x]]) pa[x]=search(pa[x]);
    return pa[x];
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    cin>>n>>m>>k;
   // while(cin>>n>>m>>k)
    
        for(int i=1;i<=n;i++){
            pa[i]=i; cnt[i]=1; fr[i]=0;
        }
        int x,y;
        while(m--)
        {
            cin>>x>>y;
            int a=search(x);
            int b=search(y);
            fr[x]++;    fr[y]++;
            if(a!=b){
                pa[a]=b;
                cnt[b]+=cnt[a];
            }
        }
        for(int i=1;i<=n;i++){
            cnt[i]=cnt[search(i)];
        }
        while(k--)
        {
            cin>>x>>y;
            int a=search(x);
            int b=search(y);
            if(a==b){
                cnt[x]--,cnt[y]--;
            }
        }
        for(int i=1;i<=n;i++)
            cout<<cnt[i]-fr[i]-1<<' ';
        cout<<endl;
    


    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    vector<int>x{a,b,c};
    sort(x.begin(),x.end());
    cout << x[0] << ' ' << x[1] << ' ' << x[2];
    cout << endl;
}



Measured memory_bytes: 3088
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		while(N > 0) {
			if(N % 10 == 7) {
				System.out.println("Yes");
				return;
			}
			N /= 10;
		}
		System.out.println("No");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

signed main(void)
{
	string s, t;
	int ans, cnt;
	cin >> s >> t;

	ans = 1e9;
	rep(i, s.size() - t.size() + 1)
	{
		cnt = 0;
		rep(j, t.size())
		{
			if (s[i + j] != t[j])
				cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


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

signed main(){
  string s;
  cin>>s;
  int f=0,a=0,b=0;
  if(s[0]!='A')f++;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C')a=1,b=i;
  }
  if(!a)f=1;
  for(int i=1;i<s.size();i++){
    if(i==b)continue;
    if(!('a'<=s[i]&&s[i]<='z'))f=1;
  }
  if(f)cout<<"WA"<<endl;
  else cout<<"AC"<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll X,Y;
	while(cin>>X>>Y) {
		ll v = X;
		ll ans = 1;
		while(1) {
			if(v*2<=Y) {
				ans++;
				v*=2;
			} else break;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256