akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int main(){
	long long a;scanf("%lld",&a);

	printf("0 0 ");
	long long X2,Y2,X3,Y3;
	Y2=1;
	X3=(1000000000-a%1000000000)%1000000000;
	a+=X3;
	X2=a/1000000000;
	Y3=1000000000;
	printf("%lld %lld %lld %lld\n",X2,Y2,X3,Y3);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18+1;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

ll fact[1000001];

template<typename T> void factorial(T m){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i <= 1000000; ++i){
        fact[i] = fact[i-1] * i % m;
    }

}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return fact[n] * Pow<T>(fact[k], m-2, m) % m * Pow<T>(fact[n-k], m-2, m) % m;
}

struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int main(){
    ll x, y; cin >> x >> y;
    ll one_two = 0, two_one = 0;
    while(x > 0 && y > 0){
        if(x > y){
            x -= 2;
            y -= 1;
            two_one++;
        }else{
            x -= 1;
            y -= 2;
            one_two++;
        }
    }
    factorial<ll>(MOD);
    if(x == 0 && y == 0) cout << combination<ll>(two_one+one_two, one_two, MOD) << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(){
   int n,a,b;
   cin>>n;
   int i,sum,j,ans=9999;
   for(i=1;i<=n/2;i++){
       sum=0;
       if(ans<i%10) continue;
       a=i;
       b=n-a;
       while(1){
           sum+=b%10;
           b/=10;
           if(b==0) break;
       }
       if(ans<sum) continue;
       while(1){
           sum+=a%10;
           a/=10;
           if(a==0) break;
       }
       if(ans>sum) ans=sum;
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
xy=[list(map(int, input().split())) for _ in range(m)]

ball=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
    x=xy[i][0]-1
    y=xy[i][1]-1
    if red[x]:
        red[y]=True
        if ball[x]==1:
            red[x]=False
    ball[y]+=1
    ball[x]-=1
print(red.count(True))


Measured memory_bytes: 91300
import math

info = list(map(int, input().split()))
count = 0

for i in range(info[0]):
    cood = list(map(int, input().split()))
    dist = math.sqrt(cood[0]** 2 + cood[1]** 2)
    if dist <= info[1]:
        count += 1

print(count)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
int num[10];

bool judge(int n){
    while(n){
        if(num[n % 10])
            return false;
        n /= 10;
    }
    return true;
}

int main(){
    int n, k, x;
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= k; i++){
        scanf("%d", &x);
        num[x]++;
    }
    for(int i = n; ;i++){
        if(judge(i)){
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))

d = {}
for a in A:
    if a not in d.keys():d[a] = 0
    d[a] += 1
s = sum(A)
q = int(input())
for i in range(q):
    b,c = map(int,input().split())
    if b in d.keys():
        s += d[b]*(c-b)
        if c not in d.keys():d[c] = 0
        d[c] += d[b]
        d[b] = 0
    print(s)


Measured memory_bytes: 20276
#include <stdio.h>
#include <string.h>

int main ()
{
   char str1[102];
   char str2[102];
   int ret,len,i,j;
   char temp;
   scanf("%s %s",str1,str2);

   len = strlen(str1);
   for(i=0;i<=len-1;i++)
   {
        temp = str1[len-1];
        for(j=len-1;j>=1;j--)
        {
            str1[j] = str1[j-1];
        }
        str1[0] = temp;
        while (strcmp (str1,str2) == 0)
        {
              puts("Yes");
              return 0;
        }
   }
   printf("No\n");
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n,k;cin>>n>>k;
    ll cnt=0;
    vector<ll>a(n+1);
    rep(i,k){
        ll d;cin>>d;
        rep(j,d){
            ll s;cin>>s;
            a[s]++;
        }
    }
    REP(i,1,n+1){
        if(a[i])continue;
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3604
import numpy as np

import sys
sys.setrecursionlimit(1000000)

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if abs(a-b) > k or abs(a-c) > k or abs(a-d) > k or abs(a-e) > k or abs(b-c) > k or abs(b-d) > k or abs(c-d) > k or abs(c-e) > k or abs(d-e) > k:
    print (":(")
else:
    print ("Yay!")

Measured memory_bytes: 21452
H, W, K = map(int, input().split())
A = [[0] * W for _ in range(H)]
for i in range(K):
    y, x, v = map(int, input().split())
    A[y - 1][x - 1] = v
dp = [[0] * 4 for i in range(W)]
pre = []
dp[0][1] = A[0][0]
for i in range(H):
    for j in range(W):
        for k in range(4):
            if i:
                if k == 1:
                        dp[j][k] = max(dp[j][k], max(pre[j]) + A[i][j])
                if k == 0:
                        dp[j][k] = max(dp[j][k], max(pre[j]))
            if j:
                if 0 < k:
                    dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + A[i][j])
                dp[j][k] = max(dp[j][k], dp[j - 1][k])
    pre = dp
ans = 0
for j in range(W):
    ans = max(ans, max(dp[j]))
print(ans)


Measured memory_bytes: 146920
N = int(input())
A = [(i, int(input())) for i in range(N)]

B = sorted(A, key=lambda x: x[1])
largest_index = B[-1][0]
for i in range(N):
    if A[i][0] == largest_index:
        print(B[-2][1])
    else:
        print(B[-1][1])

Measured memory_bytes: 83288
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, s, b = s_map()
    
    print(a[0] + s[0] + b[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 72580
#include <iostream>

using namespace std;

int N, Y;


void solve()
{
	int a, b = 0, c;
	Y /= 1000;
	int tmp = Y - N;
	for (; tmp % 9 != 0; tmp -= 4, b++);
	a = tmp / 9;
	c = N - a - b;
	if (a >= 0 && a + b <= N) cout << a << " " << b << " " << c << endl;
	else cout << "-1 -1 -1" << endl;
}

int main()
{
	cin >> N >> Y;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<vector>
#define ll long long
#define dd double
using namespace std;

int main() {
	ll n;
	string s;
	ll m;
	while (cin >> n) {
		cin >> s;
		cin >> m;
		char x = s[m - 1];
		for (ll i = 0; i < s.size(); i++) {
			if (s[i] != x) {
				cout << '*';
			}
			else {
				cout << s[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  int n; cin >> n;
  cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


vector<int> v[200000];
P p[200000];
signed main(){
  int n, m;
  scanf("%lld%lld", &n, &m);
  rep(i,m){
    int x, y;
    scanf("%lld%lld", &x, &y);
    p[i] = P(x, y);
    v[x].pb(y);
  }
  rrep(i,n){sort(v[i].begin(), v[i].end());}
  rep(i,m){
    int x = p[i].fi, y = p[i].se;
    int idx = lower_bound(v[x].begin(), v[x].end(), y)-v[x].begin()+1;
    string str = "";
    str += string(6-to_string(x).size(), '0');
    str += to_string(x);
    str += string(6-to_string(idx).size(), '0');
    str += to_string(idx);
    cout << str << endl;
    // printf("%lld %lld\n", x, idx);
  }
  return 0;
}

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

int main()
{
	ll k;
	cin >> k;
	if(k%2==0||k%5==0)
	{
		cout << -1<<endl;
		return 0;
	}
	ll ans =0;
	ll now = 7;
	while(now%k!=0)
	{
		now *= 10;
		now +=7;
		now %= k;	
		ans++;
	}
	cout << ans+1 << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[105][100005];
int n;
int f(int idx,int val,int weight[],int value[]){
    if(idx>=n){
        return val==0 ? 0:INT_MAX;
    }
    int &ans=dp[idx][val];
    if(ans!=0){
        return ans;
    }
    ans=f(idx+1,val,weight,value);
    if(value[idx]<=val){
        ans=min(ans,weight[idx]+f(idx+1,val-value[idx],weight,value));
    }
    return ans;
}

int32_t main() {
    memset(dp,0,sizeof(dp));
	int w;
	cin>>n>>w;
	int weight[n];
	int value[n];
	for(int i=0;i<n;i++){
	    cin>>weight[i]>>value[i];
	}
	for(int i=100004;i>=0;i--){
	    if(f(0,i,weight,value)<=w){
	        cout<<i<<endl;
	        return 0;
	    }
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 85556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		int data[]=new int[100];
		int count=0;
		for(int i=0;i<n;i++) {
			data[i]=sc.nextInt();
		}
		
		for(int i=0;i<n;i++) {
			if(i==0) {
				count++;
			}else {
				boolean flag=true;
				for(int j=0;j<i;j++) {
					if(data[i]<data[j]) {
						flag=false;
						break;
					}
				}
				if(flag) {
					count++;
				}
			}
		}
		
 
		System.out.println(count);
	}
}


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> c(M);
    for(ll i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        c.at(i) = make_pair(b, a);
    }
    ll cnt = 1;

    sort(c.begin(), c.end());
    ll left = c.at(0).second;
    ll right = c.at(0).first;
    for(ll i=1;i<M; i++){
        if(right <= c.at(i).second){
            left = c.at(i).second;
            right = c.at(i).first;
            cnt++;
        }
    }

    cout << cnt << endl;


}

Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

A = sorted(A, reverse=True)
S = sum(A)
ans = "No"
for i in range(M):
    if A[i] >= S / (4 * M):
        ans = "Yes"
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<pair<int, int>> abs(n);
    for(int i=0; i<n; ++i){
        int a, b; cin >> a >> b;
        abs[i]=make_pair(a, b);
    }
    sort(abs.begin(), abs.end());
    long long ans=0;
    for(auto ab : abs){
        if(m>ab.second){
            m-=ab.second;
            ans+=(long long)ab.first*ab.second;
        } else{
            ans+=(long long)ab.first*m;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int n, m;
vector<int> G[100000];
bool used[100000];

bool rec(int from, vector<int>& v) {
  if (used[from]) return false;
  used[from] = true;
  v.push_back(from);
  for (int to : G[from]) {
    bool res = rec(to, v);
    if (res) return true;
  }
  return true;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<int> v;
  rec(0, v);
  reverse(v.begin(), v.end());
  v.pop_back();
  used[0] = false;
  rec(0, v);
  
  cout << v.size() << endl;
  for (int i : v) {
    cout << i + 1 << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 11128
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    cout << (N - 1) / (K - 1) + !!((N - 1) % (K - 1)) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  const int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, k, v;
  int ans;
  for(i = 2; i <= MAX_V; i++){
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++){
    if(prime[i]){
      for(k = 2 * i; k <= MAX_V; k += i){
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &v) != EOF){
    int count = 0;
    for(k = 2; k <= v; k++){
      ans = prime[k];
      if(ans == 1){
        count++;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 4928
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

class ModInt(x: Long) {

    companion object {
        const val MOD = 1e9.toLong() + 7
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

val fac = mutableListOf<ModInt>()

fun fact(n: Long): ModInt {
    if (fac.count() == 0) fac.add(ModInt(1))
    while (fac.count() <= n) {
        fac.add(fac.last() * ModInt(fac.count().toLong()))
    }
    return fac[n.toInt()]
}

fun comb(n: Long, k: Long): ModInt {
    return fact(n) / fact(k) / fact(n - k)
}

fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    val c = Array(k + 1) { ModInt(0) }
    for (i in k downTo 1) {
        var num = ModInt((k / i).toLong()).pow(n.toLong())
        var j = 2
        while (i * j <= k) {
            num -= c[i * j]
            j++
        }
        c[i] = num
    }
    var ans = ModInt(0)
    for (i in 1..k) {
        ans += ModInt(i.toLong()) * c[i]
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 59216
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

inline int encode (int *a) {
	int code = 0;
	For (i, 0, 25)
		code += (a[i] & 1) << i;
	return code;
} 

const int N = 2e5 + 1e3;
map<int, int> minv;
char str[N];
int dp[N];
int cnt[26];
int main () {
	Set(dp, 0x3f);
	dp[0] = 0;
	minv[0] = 0;
	scanf ("%s", str + 1);
	int n = strlen(str + 1);
	For (i, 1, n) {
		++cnt[str[i] - 'a'];
		dp[i] = dp[i - 1] + 1;
		int now = encode(cnt);
		For (j, 0, 25)
			For (k, 0, 1)
				if (minv.find(now ^ (k << j) ) != minv.end() )
					chkmin(dp[i], minv[now ^ (k << j)] + 1);
		if (minv.find(now) == minv.end() )
			minv[now] = dp[i] ;
		else
			chkmin(minv[now], dp[i] );
	}
	printf ("%d\n", dp[n]);
}


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

int N, K;
vector<int> a;

bool solve(vector<int> &res) {
    int prev = -1;
    for (int _ = 0; _ < K+1; ++_) {
        int ma = 10000;
        int mai = -1;
        for (int i = 0; i < N; ++i) {
            if (i == prev) continue;
            if (ma >= a[i]) ma = a[i], mai = i;
        }
        for (int i = 0; i < N; ++i) {
            if (i == prev || i == mai) continue;
            res.push_back(i + 1);
            --a[i];
            if (a[i] < 0) return false;
        }
        res.push_back(mai + 1);
        --a[mai];
        if (a[mai] < 0) return false;
        prev = mai;
    }
    return true;
}

int main() {
    cin >> N >> K;
    a.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> res;
    if (!solve(res)) cout << -1 << endl;
    else {
        cout << res.size() << endl;
        for (auto c : res) cout << c << " ";
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		int n = sc.nextInt(),m = sc.nextInt();
		int total = 0;
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			total += a[i]; 
		}
		int cnt = 0;
		for(int i:a) {
			if(4*m*i >= total) cnt++;
		}
		if(cnt>=m)
			out.println("Yes");
		else
			out.println("No");
		out.close();
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			return a;
		}
	}

}

Measured memory_bytes: 23124
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e18;


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n),top(n);
    ll s=0;
    rep(i,n){
        cin >> a[i];
        s^=a[i];
    }
    rep(i,n){
        a[i] &= ~s;
    }
    ll r=0;
    for(ll i=60;i>=0;i--){
        ll j=r;
        for(;j<n;j++){
            if(a[j]>>i&1){
                swap(a[j],a[r]);
                break;
            }
        }
        if(j==n) continue;
        top[r]=i;
        rep(k,n){
            if(k==r) continue;
            if(a[k]>>i&1){
                a[k]^=a[r];
            }
        }
        r++;
    }
    ll ans=s;
    ll x=0;
    for(ll i=60;i>=0;i--){
        ll nx=x|(1ll<<i);
        ll b=nx;
        rep(j,r){
            if(b>>top[j]&1) b^= a[j];
        }
        if((b&nx)==0) x=nx;
    }
    ans+=2*x;
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
char s[5];
bool vis[5];

int main() {
	scanf("%s", s);
	int cnt = 0;
	for(int i = 0; i < strlen(s); i++) {
		if(vis[s[i]] == 0 && (s[i] == 'a' || s[i] == 'b' || s[i] == 'c')) {
			cnt++;
			vis[s[i]] = 1;
		}
	}
	if(cnt == 3) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]

use std::cmp::{self, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{self, Debug, Display};
use std::io::{self, Read, Write};
use std::process;
use std::str::{self, FromStr};


fn solve(s: String) -> Option<usize> {
    let s = s.as_bytes();
    let (mut i, mut j, mut r) = (0, s.len() - 1, 0);
    loop {
        if i >= j {
            return Some(r);
        }
        if s[i] == s[j] {
            i += 1;
            j -= 1;
        } else if s[i] == 'x' as u8 {
            i += 1;
            r += 1;
        } else if s[j] == 'x' as u8 {
            j -= 1;
            r += 1;
        } else {
            return None;
        }
    }
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    match solve(sc.next()) {
        Some(x) => println!("{}", x),
        None => println!("-1"),
    }
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


bool compare (string s1,string s2)
{
	return s1.length()<s2.length();
}

ll a[100004];
ll size[100004];

ll root(ll x)
{
	while (a[x]!=x)
		x=a[x];
	return x;
}

ll join (ll x,ll y)
{
	ll rx=root(x);
	ll ry=root(y);
	if (size[rx]<size[ry])
	{
		a[rx]=ry;
		size[ry]+=size[rx];
	}
	else
	{
		a[ry]=rx;
		size[rx]+=size[ry];	
	}
}

int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	for (ll i=1;i<=n;i++)
	{
		a[i]=i;
		size[i]=1;
	}
	for (ll i=0;i<m;i++)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		if (root(x)!=root(y))
			join(x,y);
	}
	set <ll> s;
	for (ll i=1;i<=n;i++)
		s.insert(root(i));
	cout<<s.size();
	

}

Measured memory_bytes: 6528
import queue

h,w = map(int,input().split())
si = [input() for i in range(h)]

q = queue.Queue()

check = [-1]*(h*w)

vx = [0,1,0,-1]
vy = [1,0,-1,0]

for i in range(h*w):
    y = i//w
    x = i%w
    if si[y][x] == '#':
        if check[i] != -1:
            continue
        q.put([i,'#'])
        check[i] = i
        
        while not q.empty():
            num, clr = q.get()
            y = num//w
            x = num%w
            
            for j in range(4):
                ny = y + vy[j]
                nx = x + vx[j]
                if ny >= 0 and ny < h and nx >= 0 and nx < w:
                    new_num = ny*w+nx
                    if check[new_num] != -1:
                        continue
                    #print(new_num)
                    if clr == '#':
                        if si[ny][nx] == '.':
                            q.put([new_num,'.'])
                            check[new_num] = check[num]
                    else:
                        if si[ny][nx] == '#':
                            q.put([new_num,'#'])
                            check[new_num] = check[num]
    
#print(check)

ans = 0

li = [0]*(h*w+1)

for i in range(h):
    for j in range(w):
        if si[i][j] == '.':
            li[check[i*w+j]] += 1

#print(li)

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            ans += li[check[i*w+j]]
            
print(ans)

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

int main(){
  int64_t N,K;
  cin >> N >> K;
  vector<int64_t> A(N);
  vector<bool> checked(N,false);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  //ループの開始を求める。
  checked.at(0) = true;
  int64_t next = A.at(0) - 1;
  while(true){
    if(checked.at(next) == false) {
      checked.at(next) = true;
      next = A.at(next) - 1;
    }else{
      break;
    }
  }
  int64_t loop_s_idx = next;
  int64_t idx = loop_s_idx;
  int64_t loop_c = 0;
  //1回のループで何回街をまわるか求める
  while(true){
    loop_c++;
    idx = A.at(idx) - 1;
    if(idx == loop_s_idx){
      break;
    }
  }
  //ループに入るまでに何回街をまわる必要があるか求める
  int64_t to_loop_c = 0;
  for(int i = 0;true;){
    if(i == loop_s_idx) break;
    i = A.at(i) - 1;
    to_loop_c++;
  }
  if(K > to_loop_c) K = to_loop_c + (K - to_loop_c)  % loop_c;
  //移動先を求める
  int ans = 1;
  for(int i = 0; i < K;i++){
    ans = A.at(ans - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int64_t n; cin >> n;
    auto tab = prime_factor(n);

    int res = 0;
    for (auto e: tab) {
        int tmp = 1;
        while(e.second >= tmp) {
               e.second-=tmp;
          	   tmp++;
               res++;
        } 
    }
    cout << res << "\n";
}


Measured memory_bytes: 3652
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll n;
  cin>>n; n;
	string s;
  cin>>s; s="0"+s; ++n;
	using AR=array<int,10>;
	vector<AR> nxt(n+1);
	{
		AR ar; fill(all(ar),n);
		nxt[n]=ar;
		rrep(i,n){
			nxt[i]=ar;
			ar[s[i]-'0']=i;
		}
	}
	int re=0;
	rep(i,1000){
		vector<int> a{i/100,i/10%10,i%10};
		int cur=0;
		rep(i,3){
			cur=nxt[cur][a[i]];
		}
		if(cur<n){
			++re;
			out(i,1);
		}		
	}
	cout<<re NL;
	return 0;
}


Measured memory_bytes: 1536
n,m = map(int,input().split())
if n>=m:
  print(0)
  exit()
list1 = list(map(int,input().split()))
list1.sort()
list2 = []
for i in range(m-1):
	list2.append(list1[i+1]-list1[i])
list2.sort(reverse = True)
cut = 0
for j in range(n-1):
	cut+= list2[j]
print(max(list1)-min(list1)-cut)

Measured memory_bytes: 56872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double k=abs((h/6+m/60/6-m/30)*acos(-1));
  double ans=a*a+b*b-2*a*b*cos(k);
  printf("%.12f\n",sqrt(ans));
  return(0);
}


Measured memory_bytes: 4260
#include<stdio.h>
int main(void){
    int a,b,k,i;
    scanf("%d %d %d",&a,&b,&k);
    for(i=a;i<=b;i++){
        if(i<a+k||i>b-k){
            printf("%d\n",i);
        }
        else{
            continue;
        }
    }
	return 0;		
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	vector<int> a;
	vector<int> b;

	for (int i = 0; i < 7; i++)
	{
		int temp[2];

		cin >> temp[0] >> temp[1];

		a.push_back(temp[0]);
		b.push_back(temp[1]);
	}

	for (vector<int>::size_type i = 0; i < 7; i++)
	{
		cout << a[i] - b[i] << endl;
	}

	return 0;
}

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

struct StSeq
{
  int m_nBgn;
  int m_nEnd;

  StSeq() : m_nBgn(0), m_nEnd(0)
  { }
};

void fnInput(vector<vector<int>>& rvvnAdjcy, vector<StSeq>& rvoDFSrch)
{
  int nxSiz;
  cin >> nxSiz;

  rvvnAdjcy.resize(nxSiz + 1, vector<int>(nxSiz + 1, 0));
  for (int i = 0; i < nxSiz; ++i)
  {
    int nx, nySiz;
    cin >> nx >> nySiz;
    for (int j = 0; j < nySiz; ++j)
    {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StSeq oSeq;
  rvoDFSrch.resize(nxSiz + 1, oSeq);
}

void fnDepthFirstSearch(const vector<vector<int>>& cnrvvnAdjcy, vector<StSeq>& rvoDFSrch, int nx)
{
  static int stnCnt = 0;

  if (rvoDFSrch[nx].m_nBgn)  return;
  rvoDFSrch[nx].m_nBgn = ++stnCnt;

  for (int ny = 1; ny < cnrvvnAdjcy.size(); ++ny)
    if (cnrvvnAdjcy[nx][ny] == 1  &&
        nx != ny                )
      fnDepthFirstSearch(cnrvvnAdjcy, rvoDFSrch, ny);

  rvoDFSrch[nx].m_nEnd = ++stnCnt;
}

void fnResult(const vector<StSeq>& cnrvoDFSrch)
{
  for (int i = 1; i < cnrvoDFSrch.size(); ++i)
    cout << i <<  " " << cnrvoDFSrch[i].m_nBgn << " " << cnrvoDFSrch[i].m_nEnd << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  vector<StSeq> voDFSrch;

  fnInput(vvnAdjcy, voDFSrch);
  for (int nx = 1; nx < voDFSrch.size(); ++nx)
    fnDepthFirstSearch(vvnAdjcy, voDFSrch, nx);
  fnResult(voDFSrch);

  return 0;
}

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

using namespace std;
#define ll long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

struct uni_find_weight
{
	vector<int> par;
	vector<int> rank;
	vector<int> diff_weight;
	int sz;
	uni_find_weight(int n) {init(n);}
	void init(int n) {
		par.resize(n);
		rank.resize(n);
		diff_weight.resize(n);
		rep(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = 0;
		sz = n;
	}
	int root(int x) {
		if (par[x] == x) return x;
		int r = root(par[x]);
		diff_weight[x] += diff_weight[par[x]];
		return par[x] = r;
	}
	int weight(int x) {
		root(x);
		return diff_weight[x];
	}
	int diff(int x, int y) {return weight(y) - weight(x);}
	bool same(int x, int y) {return root(x) == root(y);}
	bool unite(int x, int y, int w) {
		int nx = root(x);
		int ny = root(y);
		if (nx == ny) return w == diff(x, y);
		w += weight(x);
		w -= weight(y);
		x = nx;
		y = ny;
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) rank[x]++;
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}
	int size() {return sz;}
};

int main()
{
	int n, q;
	cin >> n >> q;
	uni_find_weight uf(n);
	rep(i, q) {
		CIN(int, a);
		CIN(int, b);
		CIN(int, w);
		if (!uf.unite(a-1, b-1, w)) {
			PRINT(0);
			return 0;
		}
	}
	PRINT(1);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
int main(){
    string s;
    cin>>s;
    rep(i,s.length()) cout<<"x";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  int lnth=s.length();
  for(int i=0;i<lnth;i++){
  	if(s[i]!=t[i]){
  		cout<<"No"<<endl;
  		return 0;
  	}
  }
  cout<<"Yes"<<endl;
  	
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
int main(){
	int n;
	cin>>n;
	int h[n],dp[n];
	
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	
	dp[0]=0;

	for(int i=1;i<n;i++){
		dp[i]=INT_MAX;
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if(i>=2)
			dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout<<dp[n-1];


}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <math.h>
#define Abs(x) ((x>=0)?x:-x)


int main()
{

	//FILE* fin = freopen("input.txt", "r", stdin);
	while (1){

		int sumt = 0, sumh = 0, n, m;
		int cardt[100], cardh[100];
		scanf("%d", &n);
		scanf("%d", &m);
		if (n == 0 && m == 0){
			break;
		}
		int i = 0;
		while (i < n){
			scanf("%d", &cardt[i]);
			sumt += cardt[i];
			i++;
		}
		i = 0;
		while (i < m){
			scanf("%d", &cardh[i]);
			sumh += cardh[i];
			i++;
		}

		if ((sumt + sumh) % 2 == 1){
			printf("%d\n", -1);
			continue;
		}

		int j, temp, diff, flag = 0, csum = 300, I = 0, J = 0;
		diff = sumt - sumh;
		//printf("sumt=%d sumh=%d diff=%d\n", sumt, sumh, diff);
		for (i = 0; i < n; i++){
			for (j = 0; j < m; j++){
				if (cardt[i] - cardh[j] == (diff / 2)){
					flag = 1;
					if ((cardt[i] + cardh[j]) < csum){
						I = i;
						J = j;
						csum = cardt[i] + cardh[j];
					}
				}
			}
		}
		if (flag == 0){
			printf("%d\n", -1);
			continue;
		}
		
		sumt = sumt - cardt[I] + cardh[J];
		sumh = sumt + cardt[I] - cardh[J];
		if (sumt == sumt){
			printf("%d %d\n", cardt[I], cardh[J]);
		}
	
	}
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
MOD = 10**9+7
a=10
b=9
c=8
for i in range(n-1):
    a*=10
    b*=9
    c*=8
    if i%10==0:
        a=a%MOD
        b=b%MOD
        c=c%MOD

a=a%MOD
b=b%MOD
c=c%MOD
ans = (a-2*b+c)%MOD
print(ans)

Measured memory_bytes: 9196