akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int count1=0;
    int a;
    int arr[100000];
    for(int i=1;i<=n;i++){
        cin>>a;
        arr[a]=i;
    }
    for(int i=1;i<=n;i++){
        cout<<arr[i];
        if(i!=n){
            cout<<" ";
        }
    }

    ALL_UP_WITH;
}


Measured memory_bytes: 1280
// C - Sum of product of pairs
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(){
	int MOD = 1e9 + 7;
	int N; cin>>N;
	vector<int> A(N);
	int s = 0;
	for(int i=0; i<N; ++i){
		cin>>A[i];
		s = ((ll)s + A[i]) % MOD;
	}
	s = (ll)s * s % MOD;
	for(int a:A) s = (s - a * (ll)a) % MOD;
	s = (ll)s * ((MOD + 1) / 2) % MOD;
	cout<< ((ll)s + MOD) % MOD <<endl;
}


Measured memory_bytes: 4036
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int N, M;
 vector<vector<int>> G;
int s, t;

long long dfs() {
    vector<vector<long long>> dist(N, vector<long long>(3, -1));
  
    dist[s][0] = 0;
    queue<pair<int,int>> que;
    que.push({s, 0});
    while (!que.empty()) {
       pair<int,int> cur = que.front(); 
      
      que.pop();
        int curf = cur.first;
        int curs = cur.second;
        for (auto nv : G[curf]) {
            int np = (curs + 1) % 3;
          
            if (dist[nv][np] == -1) {
                dist[nv][np] = dist[curf][curs] + 1;
                que.push({nv, np});
            }
        }
    }
    if (dist[t][0] == -1) return -1;
    else return dist[t][0] / 3;
}

int main() {
  
    cin >> N >> M;
  
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int u, v; 
      
      cin >> u >> v; --u, --v;
      
        G[u].push_back(v);
    }
    cin >> s >> t;
  
    --s, --t;
  
    cout << dfs() << endl;            
}

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

signed main()
{
	ll n;
	cin >> n;
	ll  a[5];
	for(ll i = 0;i<5;i++)cin >> a[i];
	ll mn = a[0];
	for(ll i = 0;i<5;i++)mn=min(a[i],mn);
	cout<<((n-1)/mn)+5<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
  
class Main{
  public static void main(String [] args){
    Scanner scan = new Scanner(System.in);
    int a = Integer.parseInt(scan.next());
    int b = Integer.parseInt(scan.next());
    int c = Integer.parseInt(scan.next());
    if (a < b && b < c){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 17132
#include"bits/stdc++.h"
    using namespace std;
    int main(){
    	string a;
    	cin>>a;
    	for(int i=0;i<a.length();i++){
    		if(a[i]=='7'){
    			cout<<"Yes"<<endl;
    			return 0;
    		}
    	}
    	cout<<"No"<<endl;
    } 

Measured memory_bytes: 3596
def solve(L, R):
  minmod = float('inf')
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      minmod = min((i * j) % 2019, minmod)
      if minmod == 0:
        return minmod
  return minmod

L, R = map(int, input().split(' '))
print(solve(L, R))

Measured memory_bytes: 3060
N=int(input())
T=list(map(int,input().split()))
M=int(input())
Drink=[list(map(int,input().split())) for _ in range(M)]
answer=sum(T)
for i in range(M):
    p=Drink[i][0]
    x=Drink[i][1]
    print(answer-T[p-1]+x)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s[m];
  rep(i,m){
    int k;
    cin >> k;
    rep(j,k){
      int si;
      cin >> si;
      si--;
      s[i].push_back(si);
    }
  }
  int p[m];
  rep(i,m)cin >> p[i];
  int ans = 0;
  rep(S,1<<n){//スイッチの付け方
    bool ok = 1;
    rep(i,m){//それぞれの電球
      int sum=0;
      rep(j,s[i].size())if(S&(1<<s[i][j]))sum += 1;
      if(sum%2!=p[i])ok = 0;
    }
    if(ok)ans++;
  }
  cout << ans << endl;
}


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+' ){
  	cout <<  A + B;
  }
  else if (op == '-' ){
  	cout << A -B ;
  }
}








Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r1 = sc.nextInt() - 1;
		int c1 = sc.nextInt() - 1;
		int r2 = sc.nextInt();
		int c2 = sc.nextInt();
		sc.close();

		int mod = 1000000007;
		long a = nCr(r2 + c2 + 2, c2 + 1, mod) - 1;
		long b = nCr(r1 + c2 + 2, c2 + 1, mod) - 1;
		long c = nCr(r2 + c1 + 2, c1 + 1, mod) - 1;
		long d = nCr(r1 + c1 + 2, c1 + 1, mod) - 1;
		long ans = a - b - c + d + mod + mod;
		ans %= mod;
		System.out.println(ans);
	}

	static long nCr(int n, int r, int m) {
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) % m;
			val = val * modinv(i, m) % m;
		}
		return val;
	}

	static long modinv(long a, int m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
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; }

void _main() {
  int N;
  cin >> N;
  int a[N];
  rep(i, 0, N) cin >> a[i];

  int ans = 0;
  rep(i, 1, N) {
    if (a[i]-1 < i && a[a[i]-1] == i+1) ++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
if($s[0]=="A"){
$c=1;
$i=1;
while($i<$n){
if($c==1&&$i>1&&$i<$n-1){
if($s[$i]=="C"){
--$c;
}else{
if($s[$i]!=strtolower($s[$i])){
echo "WA";
exit;
}
}
}else{
if($s[$i]!=strtolower($s[$i])){
echo "WA";
exit;
}
}
++$i;
}
echo ($c==0)?"AC":"WA";
}else{
echo "WA";
}

Measured memory_bytes: 4728
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		String[] s = toStringArray(nextString());

		long ans = 0;
		long a = 0;
		for(int i=s.length-1;i>-1;i--){
			if("W".equals(s[i])){
				a++;
			}else{
				ans+=a;
			}
		}
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 36144
a, b, c, d = gets.chomp.chars.map(&:to_i)
op = [?+,?-]

op.each do |i|
  op.each do |j|
    op.each do |k|
      if eval "#{a}#{i}#{b}#{j}#{c}#{k}#{d}==7"
        puts "#{a}#{i}#{b}#{j}#{c}#{k}#{d}=7"
        exit
      end
    end
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,a,b,c,ans=0,x,y,p[120000],q[120000],r[120000];
  cin >> n >> a >> b >> c;
  x=a*modinv(a+b)%MOD;
  y=b*modinv(a+b)%MOD;
  p[0]=1;
  FOR(i,1,n+1)p[i]=p[i-1]*x%MOD;
  q[0]=1;
  FOR(i,1,n+1)q[i]=q[i-1]*y%MOD;
  r[0]=1;
  FOR(i,1,n)r[i]=r[i-1]*(n+i-1)%MOD*modinv(i)%MOD;
  rep(i,n)ans=((ans+p[n]%MOD*q[i]%MOD*r[i]%MOD*(n+i))%MOD+MOD)%MOD;
  rep(i,n)ans=((ans+q[n]%MOD*p[i]%MOD*r[i]%MOD*(n+i))%MOD+MOD)%MOD;
  ans=(ans%MOD*100%MOD*modinv(100-c)%MOD+MOD)%MOD;
  printf("%lld\n",ans);
}

Measured memory_bytes: 2944
import sys
s = input()
best = 10**18
for _s in list(set(s)):
    cnt = 0
    _max = 0
    for x in s[::-1]:
        if x == _s:
            cnt = 0
        else:
            cnt += 1
        _max = max(_max, cnt)
    best = min(_max, best)
print(best)

Measured memory_bytes: 3060
n = gets.to_i
strings = n.times.map{gets.chomp.chars.sort.join}.sort
cnt = 1
ans = 0
current = strings.shift
strings.each do|s|
  if s == current
    cnt += 1
  else
    ans += cnt*(cnt-1)/2
    cnt = 1
  end
  current = s
end
ans += cnt*(cnt-1)/2
puts ans

Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
	char str[20];
	ll state=0,a,b,i;
	cin>>a>>b;
	scanf("%s",str);
	if(str[a]!='-')
		state=1;
	for(i=0;i<strlen(str);i++){
		if((str[i]<48 || str[i]>57) && i!=a )
			state=1;
	}
	if(state==1)
		cout<<"No\n";
	else
		cout<<"Yes\n";
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

const ll MX = 1ll << 60;

int main(){
  
  int n;
  cin >> n;
  vector<ll> v(n+1);
  rep(i,n+1)cin >> v[i];
  vector<ll> s(n+2,0);
  for(int i= n+1;i > 0;i--)s[i-1] = s[i]+v[i-1];
  ll res = 0;
  ll pre = 1;
  rep(i,n+1){
    ll k = s[i+1],l;
    if(pre <= 1ll << 60)l = pre;
    else l = MX;
    l -= v[i];
    if(l < 0){
      cout << -1 << endl;
      return 0;
    }
    res += min(k,l)+v[i];
    //printf("depth = %d ,val = %d\n",i,min(k,l)+v[i]);
    if(min(k,l) <= (1ll << 60))pre = min(k,l)*2;
    else pre = MX;
  }
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 4820
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            long ans = 1000;
            for (int i = 0; i <n-1; i++)
            {
                if (ans>=a[i]&&a[i] < a[i + 1]) ans += (a[i + 1] - a[i]) * (ans / a[i]);
            }
            WriteLine(ans);

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 18896
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,check = 0,ans = 1;
  cin >> N;
  map<ll,ll> mp;
  rep(i,N){
    ll tmp = 0; cin >> tmp;
    mp[tmp]++;
  }
  vector<ll>A(N);
  vector<ll>B(N);
  ll i = 0; ll j = 0;
  for (auto p : mp){
    if(p.second > 3){
      A[i] = p.first;
      B[j] = p.first;
      check += 2;
      i++; j++;
    }
    else if(p.second > 1){
      B[j] = p.first;
      check++;
      j++;
    }
  }
  sort(A.begin(), A.end()); //小さい順
  reverse(A.begin(), A.end());
  sort(B.begin(), B.end()); //小さい順
  reverse(B.begin(), B.end());
  if(check < 2){
    cout << "0";
  }
  else{
    cout << max(A[0]*A[0],B[0]*B[1]);
  }
}
      

Measured memory_bytes: 11072
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N,K;
    cin>>N>>K;
    vector<P> A(200001,P{0,0});
    REP(i,N){
        ll a;
        cin>>a;
        A[a].second++;
        A[i+1].first=i+1;
    }
    auto iter=A.begin();
    REP(i,N+1)iter++;
    sort(A.begin(),iter,[&](P& p1,P&p2){return p1.second>p2.second;});
    ll i=K;
    while(A[i].second>0){
        ans+=A[i].second;
        i++;
    }
    cout<<ans<<endl;
    //REP(i,N+1)cout<<A[i].first<<","<<A[i].second<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
long long MOD = 1e9+7;
long long INF = 1e15;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    ll inv[K-1];
    rep2(i, 1, K-1){
        inv[i] = 1;
        ll e[40];
        e[0] = i;
        rep2(j, 1, 40){
            e[j] = (e[j-1]*e[j-1]) % MOD;
        }
        ll k = MOD-2;
        int count = 0;
        while(k > 0){
            if(k % 2 == 1){
                inv[i] *= e[count];
                inv[i] %= MOD;
            }
            k /= 2;
            count++;
        }
    }
    ll c = 1;
    rep2(i, 1, K-1){
        c *= (N*M-1-i);
        c %= MOD;
        c *= inv[i];
        c %= MOD;
    }
    ll sumx = N*(N-1)*(N+1)*M*M/6;
    ll sumy = M*(M-1)*(M+1)*N*N/6;
    ll sum = (sumx + sumy) % MOD;
    cout << (c * sum) % MOD << endl; 
}

Measured memory_bytes: 1792
#include<stdio.h>

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

remainder=N%10;

if(remainder==1){ 
printf("pon\n");}

else if(remainder==2){ 
printf("hon\n");}

else if(remainder==3){ 
printf("bon\n");}

else if(remainder==4){ 
printf("hon\n");}

else if(remainder==5){ 
printf("hon\n");}

else if(remainder==6){ 
printf("pon\n");}

else if(remainder==7){ 
printf("hon\n");}

else if(remainder==8){ 
printf("pon\n");}

else if(remainder==9){ 
printf("hon\n");}

else if(remainder==0){ 
printf("pon\n");}

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
const long long int mod=998244353;
int main(){
  long long int N,x=0;cin>>N;
  vector<long long int>D(N);
  cin>>D.at(0);
  if(D.at(0)==0){ 
    if(N==1)x=1;
    else{ 
      for(long long int i=1;i<N;i++)cin>>D.at(i);
      sort(D.begin(),D.end());
      if(D.at(1)!=0){
        x=1;
        vector<long long int>C(D.at(N-1));
        for(long long int i=0;i<D.at(N-1);i++)
          C.at(i)=upper_bound(D.begin(),D.end(),i)-lower_bound(D.begin(),D.end(),i);
        for(long long int i=1;i<N;i++)
          x=x*C.at(D.at(i)-1)%mod;
      }
    }
  }
  printf("%lld\n",x);
}

Measured memory_bytes: 1792
from collections import defaultdict
while True:
  n, q = list(map(int, input().split()))
  if n==0:
    break

  t = defaultdict(int)
  for i in range(n):
    d = list(map(int, input().split()))
    for j in range(1, len(d)):
      t[d[j]]+=1
  tt = sorted(t.items())
  tt.sort(key=lambda x: -x[1])
  if len(tt)==0 or tt[0][1]<q:
    print(0)
  else:
    print(tt[0][0])


Measured memory_bytes: 6008
#include <iostream>
int main()
{
    using namespace std;
    int A, H, times, res;
    cin >> H >> A;
    times = H / A;
    res = H % A;
    if (res == 0)
    {
        cout << times;
    }
    else
    {
        cout << times + 1;
    }
    return 0;
}

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

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

using namespace std;
using lint=long long;

template<class R>
class matrix{
	vector<vector<R>> a;
public:
	matrix(int n):a(n,vector<R>(n)){}
	matrix(int m,int n):a(m,vector<R>(n)){}

	matrix& operator+=(const matrix& A){
		assert(h()==A.h() && w()==A.w());
		int m=h(),n=w();
		rep(i,m) rep(j,n) (*this)[i][j]+=A[i][j];
		return *this;
	}
	matrix& operator-=(const matrix& A){
		assert(h()==A.h() && w()==A.w());
		int m=h(),n=w();
		rep(i,m) rep(j,n) (*this)[i][j]-=A[i][j];
		return *this;
	}
	matrix& operator*=(const matrix& A){
		assert(w()==A.h());
		int m=h(),n=w(),l=A.w();
		matrix B(m,l);
		rep(i,m) rep(j,l) rep(k,n) B[i][j]+=(*this)[i][k]*A[k][j];
		swap(*this,B);
		return *this;
	}
	matrix operator+(const matrix& A)const{ return matrix(*this)+=A; }
	matrix operator-(const matrix& A)const{ return matrix(*this)-=A; }
	matrix operator*(const matrix& A)const{ return matrix(*this)*=A; }
	const vector<R>& operator[](int i)const{ return a[i]; }
	vector<R>& operator[](int i){ return a[i]; }

	vector<R> operator*(const vector<R>& v)const{
		assert(w()==v.size());
		int m=h(),n=w();
		vector<R> res(m);
		rep(i,m) rep(j,n) res[i]+=(*this)[i][j]*v[j];
		return res;
	}

	int h()const{ return a.size(); }
	int w()const{ return a.empty()?0:a[0].size(); }

	static matrix identity(int n){
		matrix I(n);
		rep(i,n) I[i][i]=R{1};
		return I;
	}
};

template<class R>
matrix<R> pow(matrix<R> A,long long k){
	assert(A.h()==A.w());
	matrix<R> B=matrix<R>::identity(A.h());
	for(;k>0;k>>=1){
		if(k&1) B*=A;
		A*=A;
	}
	return B;
}

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

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

	matrix<mint> A(n);
	rep(i,n) rep(j,n) cin>>A[i][j];

	A=pow(A,k);

	mint ans;
	rep(i,n) rep(j,n) ans+=A[i][j];
	cout<<ans<<'\n';

	return 0;
}


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

using namespace std;

int main()
{
	long long n,i;
	cin>>n;
	vector<long long> h(n),dp(n,0);
	for(i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);	
	}
	cout<<dp[n-1]<<endl;
  /*for(i=0;i<n;i++)
    cout<<dp[i]<<" ";*/
  
}

Measured memory_bytes: 4852
// you**can**do**anything :~  
#include <bits/stdc++.h>
#define ll long long
#define read(i) scanf("%lli" , &i)
const int maxn=5e5+10;
using namespace std;
//vector< pair< ll , ll > >abj[545445];
int main()
{
ll a,b,n ,ma=-76376735675;



read(a);
read(b);
read(n);

ll g=min(b , n);

ll h=  floor( (a*g) /b )- a * floor(g/b);
ll h2=floor( (a* (g-1) ) /b )- a * floor( (g-1) /b);
h =max( h, h2 );


printf("%lli" ,h);

}


Measured memory_bytes: 3784
import math, random
def make_circle(points):
    # Convert to float and randomize order
    shuffled = [(float(p[0]), float(p[1])) for p in points]
    random.shuffle(shuffled)

    # Progressively add points to circle or recompute circle
    c = None
    for (i, p) in enumerate(shuffled):
        if c is None or not _is_in_circle(c, p):
            c = _make_circle_one_point(shuffled[0 : i + 1], p)
    return c


# One boundary point known
def _make_circle_one_point(points, p):
    c = (p[0], p[1], 0.0)
    for (i, q) in enumerate(points):
        if not _is_in_circle(c, q):
            if c[2] == 0.0:
                c = _make_diameter(p, q)
            else:
                c = _make_circle_two_points(points[0 : i + 1], p, q)
    return c


# Two boundary points known
def _make_circle_two_points(points, p, q):
    diameter = _make_diameter(p, q)
    if all(_is_in_circle(diameter, r) for r in points):
        return diameter

    left = None
    right = None
    for r in points:
        cross = _cross_product(p[0], p[1], q[0], q[1], r[0], r[1])
        c = _make_circumcircle(p, q, r)
        if c is None:
            continue
        elif cross > 0.0 and (left is None or _cross_product(p[0], p[1], q[0], q[1], c[0], c[1]) > _cross_product(p[0], p[1], q[0], q[1], left[0], left[1])):
            left = c
        elif cross < 0.0 and (right is None or _cross_product(p[0], p[1], q[0], q[1], c[0], c[1]) < _cross_product(p[0], p[1], q[0], q[1], right[0], right[1])):
            right = c
    return left if (right is None or (left is not None and left[2] <= right[2])) else right


def _make_circumcircle(p0, p1, p2):
    # Mathematical algorithm from Wikipedia: Circumscribed circle
    ax = p0[0]; ay = p0[1]
    bx = p1[0]; by = p1[1]
    cx = p2[0]; cy = p2[1]
    d = (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by)) * 2.0
    if d == 0.0:
        return None
    x = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / d
    y = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / d
    return (x, y, math.hypot(x - ax, y - ay))


def _make_diameter(p0, p1):
    return ((p0[0] + p1[0]) / 2.0, (p0[1] + p1[1]) / 2.0, math.hypot(p0[0] - p1[0], p0[1] - p1[1]) / 2.0)


_EPSILON = 1e-12

def _is_in_circle(c, p):
    return c is not None and math.hypot(p[0] - c[0], p[1] - c[1]) < c[2] + _EPSILON


# Returns twice the signed area of the triangle defined by (x0, y0), (x1, y1), (x2, y2)
def _cross_product(x0, y0, x1, y1, x2, y2):
    return (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0)
  
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]

print(make_circle(p)[2])

Measured memory_bytes: 40124
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	#define ll long long 
	ll n, a, b;
	cin>>n>>a>>b;
	ll sum=a+b;
	ll times=n/sum;
	ll res=times*a;
	n%=sum;
	res+=min(a,n);
	cout<<res;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int a ,int b){
    if (a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
                   
    }
}

int main(){
    int k;
    long mod;
    mod=1000000007;
    cin>>k;
    int ans;
    ans=0;
    for (int i=1;i<k+1;i++){
        for (int j=1;j<k+1;j++){
            for (int l=1; l<k+1;l++){
                int d;
                d=gcd(i,j);
                d=gcd(d,l);
                ans+=d;
                ans%=mod;
                
            }
        }
    }
    cout<<ans<<endl;
    return 0;
    
    
}


Measured memory_bytes: 3532
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    //const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        long[] h = new long[n];
        for (int i = 0; i < n; i++)
        {
            h[i] = cin.NextLong();
        }

        long max = -1;
        long min = 10000000000;
        foreach (var candidate in h)
        {
            if (max < candidate)
            {
                max = candidate;
            }
            if (max - candidate > 1)
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");

    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 25056
lines = readlines
a,b,c,x =  lines.map(&:chomp).map(&:to_i)

index = 0 

a.downto(0) {|an|
    b.downto(0){|bn|
    c.downto(0) {|cn|
    if x == 500*an + 100*bn + 50*cn
        index += 1
    end
}
}
}

p index

Measured memory_bytes: 14288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, MIN = 1;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    if (MIN * 2 <= MIN + K) {
      // 2倍する
      MIN *= 2;
    }
    else {
      // Kを足す
      MIN += K;
    }
  }
  cout << MIN << endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

int N;
int a[100010];

int main() {
	cin >> N;

	bool ok = 1;
	bool t = (N & 1) ^ 1;

	rep(i, N) {
		cin >> a[i];
		if ((a[i]&1)!=t) {
			ok = 0;
		}
	}

	sort(a, a + N);
	int now = 0;
	int pt = 0;

	if (N & 1) {
		if (a[0] != 0) {
			ok = 0;
		}
		pt = 1;
		now = 2;
	} else {
		now = 1;
	}

	for (int i=pt; i<N; i+=2) {
		if (a[i]!=now||a[i+1]!=now) {
			ok = 0;
		}
		now += 2;
	}

	ll ret = 1;
	for (int i = 0; i < (N/2); ++i) {
		ret = ret * 2 % MOD;
	}

	if (!ok) puts("0");
	else cout << ret << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define INF 2147483647

int matrixChainOrder(int *, int);

int **m;

main(){
	int n, i, *p, *arr;

	scanf("%d", &n);
	p = malloc(sizeof(int) * (n + 1));
	m = malloc(sizeof(int*) * n);
	arr = malloc(sizeof(int*) * n * n);
	for (i = 0; i < n; i++){
		m[i] = arr + i*n;
	}

	scanf("%d%d", p, p + 1);
	for (i = 2; i <= n; i++){
		scanf("%*d%d", p + i);
	}
	//for (i = 0; i <= n; i++) printf("%d ", *(p + i));

	printf("%d\n", matrixChainOrder(p, n));

	free(p);
	free(arr);
	free(m);

	return 0;
}

int matrixChainOrder(int *p, int n){
	int i, j, k, l, tmp;

	for (i = 0; i < n; i++){
		m[i][i] = 0;
	}
	for (l = 1; l < n; l++){  // l=??????????????????????´???°-1
		for (i = 0; i < n - l; i++){  // i=???????????????, ???????????????:i+l
			m[i][i + l] = INF;  // ????????¨???????????§?????£??\
			for (k = i; k < i+l ; k++){  // k=????????? (A*B*C)(D*E)?????????C
				tmp = m[i][k] + m[k+1][i+l] + p[i]*p[k+1]*p[i+l+1];
				if (tmp < m[i][i + l]) m[i][i + l] = tmp;
			}
		}
	}
	return m[0][n - 1];
}

Measured memory_bytes: 632
N = int(input())
A = list(map(int, input().split()))
A.sort()

ans = []
f = 0
l = N-1
s = 0

if N == 2:
    ans.append([A[l], A[f]])
    s = A[l] - A[f]
    f += 1
    l -= 1
else:
    hasPlus = True if A[N-2] >= 0 else False
    if hasPlus:
        # make minus
        ans.append([A[f], A[l]])
        s = A[f] - A[l]
        f += 1
        l -= 1
        while f <= l:
            if f == l or A[l-1] < 0:
                # choose plus make plus
                ans.append([A[l], s])
                s = A[l] - s
                l -= 1
                break
            # choose plus make minus
            ans.append([s, A[l]])
            s = s - A[l]
            l -= 1
    else:
        # make plus
        ans.append([A[l], A[f]])
        s = A[l] - A[f]
        f += 1
        l -= 1

# choose minus make plus
while f <= l:
    ans.append([s, A[l]])
    s = s - A[l]
    l -= 1

print(s)
for x, y in ans:
    print(x, y)


Measured memory_bytes: 22448
N, C, K = map(int, input().split()) # 横に2個
T = [int(input()) for _ in range(N)]

T.sort()

first = True
ans = 0
peo = 0
limit = T[-1]
for t in T:
    if peo == C or t > limit:
        ans += 1
        first = True
    if first:
        limit = t + K
        peo = 1
        first = False
    elif t <= limit:
        peo += 1

if peo > 0:
    ans += 1

print(ans)

Measured memory_bytes: 7488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    double r,pi=3.14159265358979;
    cin>>r;
    cout<<setprecision(10)<<2*r*pi;
}


Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
	int b,c,d,t,a[120];
	
	scanf("%d",&b);
	for(c=1;c<=b;c++){
		scanf("%d",&a[c]);
	}	
	for(c=b;c>=1;c--){
		if(c==b)
			printf("%d",a[c]);
		else 
			printf(" %d",a[c]);
		
	}	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main(void){

int n,ca=0,cb=0,cc=0,cd=0,ce=0,cf=0;
double h;

scanf("%d",&n);
for(int i=1; i<=n; i++){
scanf("%lf",&h);
if(h<165.0){
ca++;
}
else if(h>=165.0&&h<170.0){
cb++;
}
else if(h>=170.0&&h<175.0){
cc++;
}
else if(h>=175.0&&h<180.0){
cd++;
}
else if(h>=180.0&&h<185.0){
ce++;
}
else if(h>=185.0){
cf++;
}
}

printf("1:");
for(int i=0;i<ca;i++){
printf("*");
}
printf("\n");
printf("2:");
for(int i=0;i<cb;i++){
printf("*");
}
printf("\n");
printf("3:");
for(int i=0;i<cc;i++){
printf("*");
}
printf("\n");
printf("4:");
for(int i=0;i<cd;i++){
printf("*");
}
printf("\n");
printf("5:");
for(int i=0;i<ce;i++){
printf("*");
}
printf("\n");
printf("6:");
for(int i=0;i<cf;i++){
printf("*");
}
printf("\n");

return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
// =========================DEBUG TEMPLATE============================


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0;
    fo(i,s.length()){
        if(s[i]=='R'){
            r++;
        }
    }
    int ans=0;
    fo(i,r){
        if(s[i]=='W'){
            ans++;
        }     
    }
    cout<<ans<<endl;




}

Measured memory_bytes: 3772
import java.util.*;
import java.lang.*;



public class Main {
    public static void main(String[] args){
     Scanner sc= new Scanner(System.in);
    
    
     String str=sc.nextLine();
     
     for(int i=0;i<str.length();i++){
         
         if(Character.isUpperCase(str.charAt(i))){
            System.out.print(Character.toLowerCase(str.charAt(i))) ;
         }else if(Character.isLowerCase(str.charAt(i))){
            System.out.print(Character.toUpperCase(str.charAt(i)));
         }else{

         System.out.print(str.charAt(i));
         
        } 
       
     }System.out.println("");
      
      
   
}}




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

int main(){

  int n;
   
  cin >> n;
  
  int a[n],b[n],c[n-1];
  
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  rep(i,n-1)cin >> c[i];

  int s = 0;
  
  int pre = 0;
  rep(i,n){
    if(i != 0) {
    	if(a[i] == pre + 1){
        	s += c[pre -1];	
        }
    }
    
    pre = a[i];
    s += b[pre -1];
  }
  cout << s;
    return 0;
}




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

template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }

  Int H(Int n,Int k){
    return C(n+k-1,k);
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      (rinv*=inverse(k))%=MOD;
      if(k%2) (res+=MOD-rinv)%=MOD;
      else (res+=rinv)%=MOD;
    }
    for(Int i=1;i<=n;i++)
      (res*=i)%=MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  Int ans=0;
  for(Int i=1;i<=k;i++){
    Int res=mod.C(k,i)*mod.pow(i,n)%MOD;
    if((k-i)&1) ans+=MOD-res;
    else ans+=res;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 7468
#include <stdio.h>

int main(void)
{
  char arr[15];
  int n;
  int x,y;

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &n);

  y = n;
  x = 0;

  for (;;) {
    x += y % 10;
    y /= 10;

    if (y == 0) {break;}
    
  }

  if (n%x == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }


  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
using namespace std;

int main(void) {

	int A, B;
	string S;
	cin >> A >> B >> S;

	if (S.size() <= A)
	{
		cout << "No" << endl;
		return 0;
	}

	if (S.substr(A, 1) != "-")
	{
		cout << "No" << endl;
		return 0;
	}

	string front = S.substr(0, A);
	if (all_of(front.cbegin(), front.cend(), ::isdigit) == false)
	{
		cout << "No" << endl;
		return 0;
	}

	string rear = S.substr(A + 1);
	if (all_of(rear.cbegin(), rear.cend(), ::isdigit) == false)
	{
		cout << "No" << endl;
		return 0;
	}

    cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
n,w = map(int, input().split())
wv = []
vsum=0
for _ in range(n):
    tmp = list(map(int,input().split()))
    wv.append(tmp)
    vsum += tmp[1]

INF = 1 << 30

dp = [[INF for i in range(vsum+1)] for j in range(n+1)]
dp[0][0]=0

for i in range(1,n+1):
    now_w,now_v =wv[i-1]
    for v in range(vsum+1):
        dp[i][v] = dp[i-1][v]
        if v - now_v >= 0:
            dp[i][v] = min(dp[i][v],dp[i-1][v-now_v] + now_w)

ans=0
for val in range(len(dp[-1])):
    if dp[-1][val] <= w:
        ans=val
print(ans)

Measured memory_bytes: 173052
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define REP(i,m,n) for (int i=m;i<n;i++)
#define FOR(i,m,n,a) for(int i=m;i<n;i+=a)
const ll MOD=1e9+7;

int main(){
  ll sn,cn,ans=0;
  cin >> sn >> cn;

  if(2*sn>cn){
    cout<<cn/2<<endl;
  }
  else{
    ans+=sn;
    sn-=ans;
    cn-=2*ans;

    ans+=cn/4;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, k = map(int, input().split())
d = {i: 0 for i in range(40)}
for n in map(int, input().split()):
    for j in range(40):
        if (n >> j) & 1:
            d[j] += 1
ans = 0
num = 0
for i in range(39, -1, -1):
    if num + 2 ** i <= k:
        if N - 2 * d[i] < 0:
            ans += 2 ** i * d[i]
        else:
            ans += 2 ** i * (N - d[i])
            num += 2 ** i
    else:
        ans += 2 ** i * d[i]
print(ans)

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    double a, b, x;
    cin >> a >> b >> x;

    if(x / (a * a) <= b / 2) printf("%.10lf\n", 90 - atan(2 * x / (a * b * b)) * 180 / M_PI);
    else printf("%.10lf\n", atan(2 * b / a - 2 * x / (a * a * a)) * 180 / M_PI);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,k;
  cin >> n >> m >> k;
  vector<vector<char>>a(n, vector<char>(m));
  for (int i=0;i<n;i++) {
    for (int j=0;j<m;j++) {
    cin >> a[i][j];
    }
  }
  int p=0;
  int q=0;
  for (int s=0;s<(1<<n);s++) {
    for (int t=0;t<(1<<m);t++) {
      for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) {
          if(s & (1<<i) && t & (1<<j) && a[i][j]=='#'){
            p++;
          }
        }
      }
      if(p==k){
        q++;
      }
      p=0;
    }
  }
    cout << q << endl;
}

Measured memory_bytes: 3612
import math

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

for i in range(n-1):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    a[0] += 1
    for j in range(2, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % j == 0:
        a[j-1] += 1
        if (ptr + 1) // j != j:
          a[(ptr + 1) // j - 1] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i] % 2 == 1:
    cnt += 1
    que.append(i+1)

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

Measured memory_bytes: 78824
#include<stdio.h>

int main(void){
    int time,h,m,s;
    scanf("%d",&time);
    h = time/3600;
    time = time - h*3600;
    m = time/60;
    time = time - m*60;
    s = time;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

using namespace std;
#define ll long long
const int N = 1e5 + 5;
vector<int> jobs[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        jobs[a].push_back(b);
    }
    priority_queue<int> pq;
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        for (auto x:jobs[i]) pq.push(x);
        if (pq.size()) ans += pq.top(), pq.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
import bisect
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

pos = defaultdict(list)
for i, c in enumerate(S):
    pos[c].append(i)
for c in pos.keys():
    pos[c] += [p + len(S) for p in pos[c]]

ans = 0
i = 0
for t in T:
    if not pos[t]:
        print(-1)
        exit()
    p = bisect.bisect_left(pos[t], i)
    ans += pos[t][p] - i + 1
    i = pos[t][p] % len(S) + 1
print(ans)


Measured memory_bytes: 49968
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, K = sc.nextInt()
    val R, S, P = sc.nextInt(); sc.nextLine()
    val T = sc.nextLine().toCharArray

    // じゃんけんバトル
    // プレイヤーは筐体とN回じゃんけんを行う
    // アイコの場合、１回のじゃんけんと数える
    // プレイヤがじゃんけんに買った場合、プライヤーはだそたてで以下のスコアをえる
    // ただし、K回前のじゃんけんで出した手と同じ手を出せない(K回目までのじゃんけんで好きな手を出せる
    // 先に出す手がわかっている
    // なので, 出した手を記録しておいて、K回先のやつでK回前の手を参照し、その次のやつで勝てる手に影響がないものを出す
    def solve(N: Int, K: Int, R: Int, S: Int, P: Int, T: Array[Char]): Long = {
      val used = new Array[Char](N)
      val set = Set('r', 's', 'p')
      def win(i: Int): (Char, Int) =
        T(i) match {
          case 'r' => ('p', P)
          case 's' => ('r', R)
          case 'p' => ('s', S)
        }
      def loop(i: Int, acm: Long): Long =
        if (i < N) {
          if (i >= K) {
            val (c, point) = win(i)
            if (c == used(i - K)) {
              if (i + K < N) {
                val (c2, _) = win(i + K)
                used(i) = (set - c2 - c).head
                loop(i + 1, acm)
              } else loop(i + 1, acm)
            } else {
              used(i) = c
              loop(i + 1, acm + point)
            }
          } else {
            val (c, point) = win(i)
            used(i) = c
            loop(i + 1, acm + point)
          }
        } else acm
      loop(0, 0)
    }

    println(solve(N, K, R, S, P, T))
  }

}


Measured memory_bytes: 39748
#include <stdio.h>

int main(void)
{
  int h, w, a, b, ans;

  scanf("%d %d", &h, &w);
  scanf("%d %d", &a, &b);
  
  ans = (h * w) - ((h * b + w * a) - (a * b));
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int> > sw(M);
    REP(i, M){
        int d;
        cin >>d;
        sw[i].resize(d);
        REP(j, d){
            cin >> sw[i][j];
            --sw[i][j];
        }
    }
    vector<int> count(M);
    REP(i, M){
        cin >> count[i];
    }
    int ans = 0;
    REP(i, 1<<N){
        int ncount = 0;
        REP(j, M){
            int nc = 0;
            REP(k, sw[j].size()){
                nc += (i&BIT(sw[j][k]))!=0;
            }
            if(nc % 2  == count[j])++ncount;
        }
        if(ncount == M)++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256