akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	int i,n,A,B;cin>>n>>A>>B;
	if(n==0){return false;}
	vector<int>ten(n);
	for(i=0;i<n;i++){cin>>ten[i];}
	pair<int,int>ans=mp(0,0);
	for(i=A-1;i<=B-1;i++){maxeq(ans,mp(ten[i]-ten[i+1],i));}
	cout<<ans.sec+1<<endl;
	return true;
}
int main(void){
	while(solve()){}
}


Measured memory_bytes: 3020
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

ab = sorted(ab)

s = 0
ans =ab[0][0]

for i, j in enumerate(ab):
  s += j[1]
  if s >= K:
    ans = ab[i][0]
    break
  else:
    ans = j[0]
  
print(ans)
  

Measured memory_bytes: 28640
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.math.BigDecimal;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);

        String str=sc.next();
        char[] c = str.toCharArray();

        int code = (int)c[0];

        if(code<91){
            System.out.println("A");
        }else{
            System.out.println("a");
        }

        //System.out.println(code);


        //END
    }
}





Measured memory_bytes: 35604
a, b = map(int, input().split())


def f(keta, x):
    val = 2**keta
    if x < (2 ** (keta)):
        return False
    else:
        x -= (val-1)
        ans = x // (2*val) * val
        ans += min(val,x-val*2*(x//(2*val)))
        return ans
if b == 0:
    print(0)
    exit()
ans = []
i = 0
while f(i,b) != False:
    #print(i)
    val = f(i,b)
    if f(i,a-1) != False:
        val -= f(i,a-1)
    #print(val)
    ans += str(val % 2)
    i += 1

ans.reverse()
print(int(''.join(ans),2))

# print(ans)
# print(f(2, 4))
# print(f(1,4))
# print(bin(435))
# print(f(0,4),f(0,1))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n>>b>>a;
    if((b-a)%2==0)
    {
        cout<<"Alice"<<endl;
    }
    else
    {
        cout<<"Borys"<<endl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
bitset<10> connect[10];
int flag[10];

int main(){
  int n, m, tmp;
  cin >> n >> m;
  REP(i, m){
    int k; cin >> k;
    REP(j, k) { cin >> tmp; connect[i].set(tmp-1); }
  }
  int res = 0;
  REP(i, m) cin >> flag[i];
  REP(i, 1<<n) {
    bitset<10> target(i);
    bool isok=true;
    REP(j, m) if((target&connect[j]).count()%2 != flag[j]){ isok=false; break; }
    if(isok) res++;
  }
  cout << res << endl;
  return 0;
}

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

Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define int long long

signed main(){

   int A, B, C;
   cin>> A>> B>> C;

   int a[3]={A, B, C};
   int ans=1e18;
   for(int i=0; i<3; i++){
      if(a[i]%2==0){
         ans=0;
      }else{
         ans=min(ans, a[(i+1)%3]*a[(i+2)%3]);
      }
   }

   cout<< ans<< endl;

   return 0;
}


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

b = []
c = []
for i in range(m):
    a = (list(map(int,input().split())))
    b.append(a[0])
    c.append(a[1])
for i in range(1,n+1):
    print(b.count(i)+c.count(i))

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

int main(){
  int n, m, l;
  cin >> n >> m >> l;
  long long A[n][m], B[m][l], C[n][l];
  
  for(int i=0; i<n; i++)
    for(int j=0; j<m; j++)
      cin >> A[i][j];
  for(int i=0; i<m; i++)
    for(int j=0; j<l; j++)
      cin >> B[i][j];

  /* Multiplication */
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      long long tmp=0;
      for(int k=0; k<m; k++){
        tmp += A[i][k] * B[k][j];
      }
      C[i][j] = tmp;
    }
  }

  /* Output */
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      if(j > 0) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3336
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    vector<vector<int>> g(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,n) {
        bool ok = true;
        for (auto v : g[i]) {
            if (h[i] <= h[v]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
	string s, t;
	cin >> N >> s >> t;
	for (int i = N;i >= 0;-- i) { // 一致する文字数
		for (int j = 0;j < i;++ j) if (s[N - i + j] != t[j]) goto retry;
		cout << (N << 1) - i;
		return 0;
		retry:;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

文字数を決め打てばどこが一致してるか分かるので、それを調べれば良い
*/

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
N = int(input())
A = list(map(int, input().split()))
acts = [(x, i) for i, x in enumerate(A)]
acts.sort()
dp = [[-1]*N for _ in range(N)]

def solve(l, r):
    if r < l:
        return 0
    if dp[l][r] >= 0:
        return dp[l][r]
    k = r - l
    act, init_pos = acts[k]
    gain_l = act * abs(l - init_pos)
    gain_r = act * abs(r - init_pos)
    res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))
    return res

print(solve(0, N-1))


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

void solve()
{
  ll k, a, b; cin >> k >> a >> b;
  ll ans = 1;
  if(b - a <= 1) { //お金に変えても増えないなら
    ans += k; //k回たたく
  } else if(k >= a - 1) {
    ans += a - 1; //まずa枚まで増やす
    k -= a - 1;
    ans += (k / 2) * (b - a) + k % 2; //2回の操作でb-a枚ずつ増やしてって、1回余ってたら叩いて増やす
  } else {
    ans += k; // k回叩いてもa枚以下のとき
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 256
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
f = bisect.bisect_left(a,0)
res = []
if f == 0:
    t = a[0]
    for i in range(1,n-1):
        res.append([t,a[i]])
        t = t - a[i]
    res.append([a[n-1],t])
    t = a[n-1] - t
elif f == n:
    t = a[n-1]
    for i in range(n-1):
        res.append([t,a[i]])
        t = t - a[i]
else:
    t = a[f-1]
    for i in range(f+1,n):
        res.append([t,a[i]])
        t = t - a[i]
    res.append([a[f],t])
    t = a[f] - t
    for i in range(f-1):
        res.append([t,a[i]])
        t = t - a[i]
    

print(t)
for sres in res:
    print(" ".join(map(str, sres)))

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int x,k,d,ans;
	cin>>x>>k>>d;
	if(x<0)
		x*=-1;
	int n=x/d;
	if(x%d!=0)
		++n;
	int val=x-n*d;
	if(n>=k)
		ans=x-k*d;
	else
	{
		k-=n;
		if(k%2)
			ans=val+d;
		else
			ans=val;
	}
	cout<<abs(ans);
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
string s; 
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	int len = s.size();
	if(len & 1) {
		cout << "No" << endl; 
		return 0;
	}
	for(int i = 0;i < s.size() - 1;i++){
		if(s[i] == 'h' && s[i + 1] == 'i') i++;
		else{
			cout << "No" << endl;
			return 0;
		}
	}
	 
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int q=sc.nextInt();
		int h=n,w=n;
		int row[]=new int[h+1];
		int col[]=new int[w+1];
		Arrays.fill(row,w);
		Arrays.fill(col,h);
		long ans=(long)(n-2)*(n-2);
		while(q-->0) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			if(x==1) {
				if(y<w) {
					for(int i=y;i<w;i++)
						col[i]=h;
					w=y;
				}
				ans-=(col[y]-2);
			}
			else {
				if(y<h) {
					for(int i=y;i<h;i++)
						row[i]=w;
					h=y;
				}
				ans-=(row[y]-2);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 65128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e5 + 10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;

void solve() {
    ll n,a[MAX],sum=0;
    cin>>n;
    a[0]=0;
    for (int i = 1; i <= n; ++i) {
        cin>>a[i];
        if (a[i]<a[i-1])sum+=(a[i-1]-a[i]),a[i]=a[i-1];
    }
    cout<<sum<<endl;
}

int main() {
    int _ = 1;
//    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B,C,D;
      cin >> A >> B >> C >> D;
     
      if (A+B > C+D) {
        cout << "Left" << endl;
      }
      else if(A+B < C+D){
        cout << "Right" << endl;
      }
      else{
        cout << "Balanced" << endl;
      }
          
    }

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n;
	double c; 
	cin>>n;
	c=n*2*3.14159265358979323846264338327950288419716939937510;
	cout<<setiosflags(ios::fixed)<<setprecision(20)<<c;
return 0;
}

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

using namespace std;

template<class T>
vector<vector<T>> ScanVectors(size_t all_size, size_t vec_size) {
  vector<vector<T>> vectors(all_size);
  for (size_t i = 0; i < all_size; i++) {
    for (size_t j = 0; j < vec_size; j++) {
      T in; cin >> in; vectors[j].emplace_back(in);
    }
  }
  return vectors;
}

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

int main() {
  size_t N, K;
  cin >> N >> K;

  auto H = ScanVectors<size_t>(N, 1)[0];
  sort(H.rbegin(), H.rend());

  size_t sum = 0;
  for (size_t i = K; i < N; i++) {
    sum += H[i];
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
    int N,M;
    cin>>N;
    if(N%2 == 1){
        M=N/2+1;
    } else{
        M=N/2;
    }
    cout<< M<<endl;
}


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

    int main(void)
    {
        char *findingC;
        char *findingF;
        int c = 'C';
        int f = 'F';
        char word[101];
        scanf("%s", &word);
        findingC = strchr(word, c);
        if (findingC!=NULL)
        {
            findingF = strchr(findingC, f);
            if(findingF!=NULL)
            {
                printf("Yes");
            }
            else
            {
                printf("No");
            }
        }
        else
        {
            printf("No");
        }

        return 0;
    }


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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int cnt = 0;
  for (int i = 0; i < k+1; i++) {
    if (a >= b) {
      b *= 2;
      cnt++;
    }
    else if (b >= c) {
      c *= 2;
      cnt++;
    }
    else break;
  }
  if (cnt == k+1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int N;
int K;
const int MAXN =1e5+10;
int memo[MAXN];
vector<int> mvc;
#define INF 0x3f3f3f3f
int dfs(int u){
	if(u==N-1)return 0;
	if(memo[u]!=-1)return memo[u];
	int ans=INF;
	for(int i=1;i<=K;i++){
		if(u+i>=N)break;
		ans=min(ans,dfs(u+i)+abs(mvc[u]-mvc[u+i]));
	}
	return memo[u]=ans;
}
int main(){
	int n,k;
	cin>>n>>k;
	N=n;
	K=k;
	
	memset(memo,-1,sizeof(memo));
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		mvc.push_back(t);
	}
	int ans=dfs(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7416
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += min(abs(a[i]) * 2, abs(a[i] - k) * 2);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	if (N == 1)
	{
		cout << "Hello World" << endl;
	}
	else
	{
		cout << A + B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    arr = [list(map(int, input().rstrip().split())) for _ in range(n)]
    memo = [0] * (10 ** 5 + 1)
    for i, j in arr:
        memo[i] += j
    cnt = 0
    for i, j in enumerate(memo):
        cnt += j
        if cnt >= k:
            print(i)
            break


if __name__ == "__main__":
    main()

Measured memory_bytes: 30172
#include <stdio.h>
int main(void){
    int n;
    while(~scanf("%d",&n)){
        int count = 0;
        for(int a=0; a<10; a++){
            for(int b=0; b<10; b++){
                for(int c=0; c<10; c++){
                    for(int d=0; d<10; d++){
                        int sum = n - (a + b + c + d);
                        if(sum == 0){
                            count++;
                        }
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}



Measured memory_bytes: 2056
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long k = Long.parseLong(in.nextLine());
        // String[] tmp = in.nextLine().trim().split("\\s");
        // int a = Integer.parseInt(tmp[0]);
        // int b = Integer.parseInt(tmp[1]);
        in.close();
        int i = 0;
        long base = 100;
        while(base < k){
            long inc = (long)(base * 0.01);
            base += inc;
            i++;
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 35732
#include<stdio.h>

int main(){
  int a, b, c, nrhombo = 0, nrectangle = 0;
  while ( scanf("%d,%d,%d", &a, &b, &c) != EOF ) {
    if ( a == b ) nrhombo++;
    else if ( a*a + b*b == c*c ) nrectangle++;
  }
  printf("%d\n%d\n", nrectangle, nrhombo);
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    char Ga,Gb;
    if(a == 4 || a == 6 || a == 9 || a == 11) Ga = 2;
    else if (a == 2) Ga = 3;
    else Ga = 1;
    if(b == 4 || b == 6 || b == 9 || b == 11) Gb = 2;
    else if (b == 2) Gb = 3;
    else Gb = 1;

    if(Ga == Gb) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010000;
int n;
ll inv[N],fac[N],fnv[N];

int main() {
	scanf("%d",&n);
	inv[1]=1;
	rep(i,2,n+1) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	fac[0]=fnv[0]=1;
	rep(i,1,n+1) fac[i]=fac[i-1]*i%mod,fnv[i]=fnv[i-1]*inv[i]%mod;
	ll pw=1,q=1,ans=n;
	rep(p,2,n+1) {
		ll w=inv[p]*fac[n]%mod*fnv[p]%mod*fnv[n-p]%mod;
		pw=pw*2%mod;
		q=(pw-q)%mod;
		w=w*q%mod;
		ans=(ans+w)%mod;
	}
	ans=ans*inv[n]%mod*powmod(3,mod-1-n)%mod;
	if (ans<0) ans+=mod;
	printf("%lld\n",ans);
}


Measured memory_bytes: 23808
#include <iostream>
using namespace std;
int main(void){
    int a,b,k;
    int count=0;
    cin >>a>>b>>k;
    
    for(int i=100;i>=1;i--){
        if(a%i==0&&b%i==0){
            count++;
            if(count==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x = [str(i),str(j),str(k)]
            ok = False
            ind = 0
            for _,t in enumerate(s):
                if x[ind] == t:
                    ind += 1
                    if ind == 3:
                        ok = True
                        break
            if ok: res += 1
print(res)

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

int main() {
  int a;
  int b;
  int x;
  cin >> a;
  cin >> b;
  //cout << a + b << endl;
  //----------------------
  //a+bが2で割り切れるとき
  if ((a+b) % 2 == 0) {
    //cout << "aaaaaa" << endl;
    cout << (a+b) / 2;
  //----------------------------
  //a+bが2で割り切れないとき
  } else {
    //cout << "unko" << endl;
    x = (a+b) / 2;
    cout << x + 1 << endl;
  }
  //----------------------------
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int M, N, sum = 0;
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    sort(rALL(A));
    if (A.at(M - 1) * 4 * M < sum){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    if (n==1){
        cout << "Hello World" << endl;
    }
    else{
        int a,b;cin>>a>>b;
        cout << a+b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923
vi exist(1000005, 0);

vii dir = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, h, w, u, v, x, y, t = 0;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string s; 

    time_t tic, toc;
    tic = clock();

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> h >> w >> k;
        ll x1, x2, y1, y2;
        
        cin >> x1 >> y1 >> x2 >> y2;
        x1--, x2--, y1--, y2--;

        vector<string> g(h);
        for(i = 0; i < h; i++){
            cin >> g[i];
        }

        vvi dist(h, vi(w, -1));
        dist[x1][y1] = 0;

        queue<pii> q;
        q.push({x1, y1});
        vvi done(h, vi(w, 0));
        while(!q.empty()){
            x = q.front().F;
            y = q.front().S;
            done[x][y] = 1;

            q.pop();

            loop(z, dir){
                for(l = 1; l <= k; l++){
                    int nx = x + z.F*l;
                    int ny = y + z.S*l;

                    if(nx < 0 or ny < 0 or nx >= h or ny >= w) break;
                    if(g[nx][ny] == '@') break;
                    if(done[nx][ny]) break;
                    
                    if(dist[nx][ny] != -1 and dist[x][y] + 1 > dist[nx][ny]) break;
                    else if(dist[nx][ny] != -1) continue;

                    dist[nx][ny] = dist[x][y] + 1;
                    q.push({nx, ny}); 
                }
            }
        }

        cout << dist[x2][y2] << nl;
    }   
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 35444
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string.h>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pp pair<ll,ll>
using namespace std;
struct node 
{
	vector<pp> e;
}no[100005];
int main()
{
	int n,a,b,c,q,k,used[100005];
	ll dist[100005];
	pp tmp;
	scanf("%d",&n);
	while(--n)
	{
		scanf("%d%d%d",&a,&b,&c);
		tmp.first=b;
		tmp.second=c;
		no[a].e.push_back(tmp);
		tmp.first=a;
		tmp.second=c;
		no[b].e.push_back(tmp);
	}
	scanf("%d%d",&q,&k);
	memset(used,0,sizeof(used));
	memset(dist,0,sizeof(dist));
	queue<int>qu;
	qu.push(k);
	used[k]=1;
	dist[k]=0;
	while(!qu.empty())
	{
		int tt=qu.front();
		qu.pop();
		for(int i=0;i<no[tt].e.size();i++)
		{
			if(used[no[tt].e[i].first]==0)
			{
				qu.push(no[tt].e[i].first);
				dist[no[tt].e[i].first]=dist[tt]+no[tt].e[i].second;
				used[no[tt].e[i].first]=1;
			}
		}
	}
	for(int i=0;i<q;i++)
	{
		scanf("%d%d",&a,&b);
		cout<<dist[a]+dist[b]<<endl;
	}
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;
bool ck(string t,ll r){
    bool ans = true;
    if(r+t.size()>s.size()){
        return false;
    }
    rep(i,t.size()){
        if(s[i+r]!=t[i])ans = false;
    }
    return ans;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    bool ans = true;
    string d = "dream";
    string dd = "dreamer";
    string e = "erase";
    string ee = "eraser";
    ll idx = 0;
    while(1){
        if(idx >= s.size())break;
        if(s[idx]=='d'){
            if(ck(d,idx) && ( ck(e,idx+d.size()) || ck(ee,idx+d.size()) ) ){
                if(ck(ee,idx+d.size())){
                    idx += d.size() + ee.size();
                }else{
                    idx += d.size() + e.size();
                }
            }else if(ck(dd,idx)){
                idx += dd.size();
            }else if(ck(d,idx)){
                idx += d.size();
            }else{
                ans = false;
                break;
            }
        }else if(s[idx]=='e'){
            if(ck(ee,idx)){
                idx += ee.size();
                
            }else if(ck(e,idx)){
                idx += e.size();
            }else{
                ans = false;
                break;
            }
        }else{
            ans = false;
            break;
        }
    }
    YES(ans);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a < c && b > c) {
		cout << "Yes" << endl;
	}
	else if (a > c && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
 
}

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

int main(){
    int n, a[110000];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    map <int, int> mp;
    for(int i = 0; i < n; i++){
        mp[a[i]]++;
    }
    int ans = 0;
    for(auto p: mp){
        int x = p.first;
        int y = p.second;
        if(y < x) ans += y;
        else ans += y - x;
    }
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, x, a[101010];
void solve(){
	cin >> n >> x;
	int g;
	a[0] = x;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a,a+n+1);
	
	for(int i = 1; i <= n; i++){
		if(i > 1){
			g = __gcd(g, a[i]-a[i-1]);
		}
		else if(i == 1){
			g = a[i]-a[i-1];
		}
	}
	
	cout << g << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif
 
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
 
namespace roll{
    using H = unsigned long long;
                     //0123456789
    constexpr H p[] = {14414443,
                       1000000007,
                       90001};
    constexpr int MX = 1123456;
    H hs[3][MX];
    H rh[3][MX];
    template<int m = 1>
    void build(const string s){
        const int n = s.size();
        REP(i,m){
            hs[i][0] = 0;
            rh[i][0] = 1;
            REP(i,m)REP(j,n){
                hs[i][j+1] = hs[i][j]*p[i] + s[j];
                rh[i][j+1] = rh[i][j]*p[i];
            }
        }
    }
    template<int m = 1>
    H get(const int l,const int r){
        H ret = 0;
        REP(i,m){
            ret ^= hs[i][r] - hs[i][l] * rh[i][r-l];
        }
        return ret;
    }
}
typedef roll::H H;
int n,m;
int main(){
    string s,t;
    cin>>s>>t;
    n=s.size();
    m=t.size();
    roll::build(t);
    H base = roll::get(0,m);
    roll::build(s);
    LL ret=0;
    unordered_map<H,int> memo;
    REP(i,n-m+1){
        memo[roll::get(i,i+m)-base]++;
    }
    string u(m,'b'-'a');
    roll::build(u);
    REP(i,m){
        int p = m-i-1;
        H diff = roll::get(0,p+1)-roll::get(0,p);
        FOR(k,'a','z'+1)if(k!=t[i])if(memo.count(diff*(k-t[i]))){
                ret+=memo[diff*(k-t[i])];
            }
        FOR(k,'A','Z'+1)if(k!=t[i])if(memo.count(diff*(k-t[i]))){
                ret+=memo[diff*(k-t[i])];
            }
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 21844
#include<iostream>
#include<queue>
#include<cmath>
#include<algorithm>

#include<iomanip>


#define MAXN 10002
using namespace std;

int par[MAXN];

class E{
	public:
	E(){
		
	}
	E(int u,int v,double c):from(u),to(v),cost(c){
	}
	public:
		int from,to;
		double cost;
		
	bool operator >(const class E&e) const
	{
		return cost<e.cost;
	}
};
priority_queue<E,vector<E>,greater<E> > pq;

int N,M,V;

void init(int V)
{
	for(int i=1;i<=V;i++)
	 par[i] = -1;
	 return ;
}

int find(int x)
{
	if(par[x]<0)
	  return x;
	else
	 return par[x] = find(par[x]);
}
int same(int a,int b)
{
	return find(a)==find(b);
}
void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	if(par[x]<par[y])
	 par[y] = x;
	else
	{
		if(par[x]==par[y])
		  par[y]--;
		par[x] = y;
	}
	return ;
}
double kruskal()
{
	double res = 0;
	init(V);
	while(!pq.empty())
	{
		class E e = pq.top();
		pq.pop();
		if(!same(e.from,e.to))
	      {
	      	unite(e.from,e.to);
	      	res +=e.cost;
		  }
	}
	return res;
}
pair<int,int> pile[MAXN];


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	 cin >> N >> M;
	 V = N;
	 double sum = 0;
	for(int i=1;i<=N;i++)
	  cin>> pile[i].first >> pile[i].second;
	for(int i=1;i<=M;i++)
	{
		int u,v;
		double c;
		cin >> u >> v;
		int x1 = pile[u].first,y1 = pile[u].second,x2 = pile[v].first,y2 = pile[v].second;
		double s2 = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
		c = sqrt(s2);
		pq.push( E(u,v,c));
		sum+=c;
	}
	cout<<fixed;
	cout<<setprecision(3);
	cout << sum-kruskal()<<endl;
	 
}


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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

int main()
{
    _fastio
    ll x;
    cin>>x;
    if(x>=400 && x<=599)
        cout<<"8"<<en;
    else if(x>=600 && x<=799)
        cout<<"7"<<en;
    else if(x>=800 && x<=999)
        cout<<"6"<<en;
    else if(x>=1000 && x<=1199)
        cout<<"5"<<en;
    else if(x>=1200 && x<=1399)
        cout<<"4"<<en;
    else if(x>=1400 && x<=1599)
        cout<<"3"<<en;
    else if(x>=1600 && x<=1799)
        cout<<"2"<<en;
    else
        cout<<"1"<<en;
}


Measured memory_bytes: 3648
n=int(input())
ds=[int(i) for i in input().split()]
counts={}

if ds[0]!=0:
  ans=0

else:  
    for i in range(1,n):
      if ds[i] not in counts:
        counts[ds[i]]=1
      else:
        counts[ds[i]]+=1
    c=0
    for i in range(1,len(counts)+1):
      if i in counts:
        c+=1
    if c==len(counts):
      ans=1
      for i in range(1,len(counts)):
          x=(counts[i]**counts[i+1])%998244353
          ans*=x
          ans%998244353
    else:
      ans=0

print(ans%998244353)
  

Measured memory_bytes: 62124
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
using namespace std;
long long binSearch(vector<long long>& v, long long key){
	//key:検索対象
	//v:データ列(ソート済)
	//見つからなかった場合でもその値より大きい最小値のインデックスを返す、vectorの外に出てしまう場合は気にしないので使う側で対策必要
	long long left = 0,right = (long long)v.size(),mid;
	while (left < right){
		mid = (left + right) / 2;
		if (v[mid] == key){
			return mid;
		}
		else if (key < v[mid]){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return left;

}

int main(){
	int N, T;
	vector<int> ts;
	cin >> N >> T;
	for (int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		ts.push_back(tmp);
	}
	int last = -1,ans=0;
	for (int time : ts){

		if (time - last < T && last!=-1){
			ans -= T - (time - last);
		}
		last = time;
		ans += T;

	}
	cout << ans << endl;


	return 0;
}

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

fun PrintWriter.solve(sc: FastScanner) {
    val x = sc.nextLong()
    var n = 100L
    var i = 0
    while (n < x) {
        i++
        n = (n * 1.01).toLong()
    }
    println(i)
}

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: 34336
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N, M, Q, p[510][510];
   cin >> N >> M >> Q;
   for (int i = 1; i <= M; i++) {
      int L, R;
      cin >> L >> R;
      p[L][R]++;
   }
   for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
         p[i][j] += p[i][j - 1];
      }
   }
   for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
         p[i][j] += p[i - 1][j];
      }
   }
   for (int i = 1; i <= Q; i++) {
      int L, R;
      cin >> L >> R;
      cout << p[R][R] + p[L - 1][L - 1] - p[L - 1][R] - p[R][L - 1] << endl;
   }
   return 0;
}


Measured memory_bytes: 1920
a,b,m = [int(i) for i in input().split()]

al = [int(i) for i in input().split()]
bl = [int(i) for i in input().split()]

ans = min(al) + min(bl)

for i in range(m):
    ai,bi,ci = [int(i) for i in input().split()]
    ans = min(ans,al[ai-1] + bl[bi-1] - ci)
    
print(ans)

Measured memory_bytes: 18488
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main()
{
  int n;
  cin >> n;
  int fact = 1;
  for (int i = 1; i <= n;i++){
    fact *= i;
  }
  vector<double> x(n), y(n);
  vector<int> v(n);
  for (int i = 0; i < n;i++){
    v[i] = i;
  }
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i];
    }
  double ans = 0;
  for (int i = 0; i < fact; i++)
  {
    for (int i = 1; i < n;i++){
      ans += sqrt((x[v[i]] - x[v[i - 1]]) * (x[v[i]] - x[v[i - 1]]) + (y[v[i]] - y[v[i - 1]]) * (y[v[i]] - y[v[i - 1]]));
    }
    next_permutation(v.begin(), v.end());
  }
  cout <<fixed<<setprecision(12)<< ans / fact << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //CASH MONEY
 
	public static void main(String[] args) { //Ball out dawg
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		HashSet<Integer> set = new HashSet<Integer>();
		for (int i = 0; i < N; i++) set.add(I.nextInt());
		O.pln(set.size());
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


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

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


    int n;
    cin >> n;
    vector<int> e(101, 0);
    vector<int> x(n, 0);
    for (int i = 0; i < n; i ++) cin >> x[i];
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j < n; j++) {
            e[i] += (x[j] - i) * (x[j] - i);
        }
    }
    auto iter = min_element(e.begin(), e.end());
    int idx = distance(e.begin(), iter);
    cout << e[idx] << endl;
    return 0;
}



Measured memory_bytes: 256
#!/bin/python

import math
import os
import random
import re
import sys

def solution(color, cost):
    global counter_mod
    for i in range(len(color)):
        for j in range(len(color)):
            counter_mod[(i+j)%3][color[i][j]-1] += 1
    min = sys.maxint
    for i in range(len(cost)):
        for j in range(len(cost)):
            if j == i:
                continue
            for k in range(len(cost)):
                if (k == i or k == j):
                    continue
                sum = 0
                for l in range(len(counter_mod[0])):
                    sum += counter_mod[0][l]*cost[l][i]
                    sum += counter_mod[1][l]*cost[l][j]
                    sum += counter_mod[2][l]*cost[l][k]
                if sum < min:
                    min = sum
    return min

if __name__ == '__main__':
    
    nk = raw_input().split()
    n = int(nk[0])
    c = int(nk[1])
    color = []
    cost = []
    temp_counter = []
    for i in range(c):
        temp = raw_input().split()
        for j in range(c):
            temp[j] = int(temp[j])
        cost.append(temp)
        temp_counter.append(0)
    counter_mod = [temp_counter[:],temp_counter[:],temp_counter[:]]
    
    for i in range(n):
        temp = raw_input().split()
        for j in range(n):
            temp[j] = int(temp[j])
        color.append(temp)
    
    result = solution(color, cost)

    print result


Measured memory_bytes: 5992
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		List<Integer> heights = new ArrayList<>();
		
		try(Scanner sc = new Scanner(System.in);){
			
			for(int i = 0; i < 10; i++) {
				heights.add(sc.nextInt());
			}
		}
		
		heights.sort(Comparator.reverseOrder());
		
		for(int i = 0; i < 3; i++) {
			System.out.println(heights.get(i));
		}
	}
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    Int(n);
    vi data(n);
    rep(i, n) cin >> data[i];

    int ans = 0;
    bool state = false;
    rep(i, n) {
        if (data[i] == i + 1) {
            if (state) {
                state = false;
            } else {
                state = true;
                ans++;
            }
        } else {
            state = false;
        }
    }

    std::cout << ans << std::endl;




    return 0;
}





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

int main(){
	long long int x,y,c;
	while(1){
		cin>>x>>y;
		if(x==0&&y==0) break;
		if(x<y) swap(x,y);
		c=0;
		int f=1;
		while(f){
			x%=y;
			swap(x,y);
			if(y==0) f=0;
			c++;
		}
		cout<<x<<" "<<c<<endl;
	}
	return 0;
}


Measured memory_bytes: 2992